Example usage for org.hibernate.criterion Projections groupProperty

List of usage examples for org.hibernate.criterion Projections groupProperty

Introduction

In this page you can find the example usage for org.hibernate.criterion Projections groupProperty.

Prototype

public static PropertyProjection groupProperty(String propertyName) 

Source Link

Document

A grouping property value projection

Usage

From source file:com.denimgroup.threadfix.data.dao.hibernate.HibernateChannelTypeDao.java

License:Mozilla Public License

@Override
public List<ChannelType> loadAllHasVulnMapping() {
    Criteria criteria = getSession().createCriteria(getClassReference())
            .createAlias("channelVulnerabilities", "channelVulns").setProjection(Projections.projectionList()
                    .add(Projections.groupProperty("name"), "name").add(Projections.groupProperty("id"), "id"));

    Order order = getOrder();// w w w.  j  a v  a  2s  .  c o  m
    if (order != null) {
        criteria.addOrder(order);
    }
    criteria.setResultTransformer(Transformers.aliasToBean(ChannelType.class));

    return criteria.list();
}

From source file:com.denimgroup.threadfix.data.dao.hibernate.HibernateEventDao.java

License:Mozilla Public License

private List<Event> retrieveGrouped(List<String> eventActions, User user, Date startTime, Date stopTime,
        Set<Integer> appIds, Set<Integer> teamIds, Set<Integer> vulnIds, Set<Integer> defectIds) {
    Criteria criteria = getEventCriteria(eventActions, user, startTime, stopTime, appIds, teamIds, vulnIds,
            defectIds);/*  www.j  a v  a  2s.  com*/

    criteria.setProjection(Projections.projectionList().add(Projections.count("id").as("groupCount"))
            .add(Projections.groupProperty("eventAction").as("eventAction"))
            .add(Projections.groupProperty("scan").as("scan"))
            .add(Projections.groupProperty("deletedScanId").as("deletedScanId"))
            .add(Projections.min("date"), "date").add(Projections.groupProperty("application"), "application")
            .add(Projections.groupProperty("user"), "user"));

    criteria.setResultTransformer(Transformers.aliasToBean(Event.class));

    List<Event> events = criteria.list();

    for (Event event : events) {
        EventAction eventAction = event.getEventActionEnum();
        EventAction groupedEventAction = eventAction.getGroupedEventAction();
        String groupedEventActionString = groupedEventAction.name();
        event.setEventAction(groupedEventActionString);
    }

    return events;
}

From source file:com.denimgroup.threadfix.data.dao.hibernate.HibernateScanDao.java

License:Mozilla Public License

@Override
@SuppressWarnings("unchecked")
public List<Scan> retrieveByApplicationIdList(List<Integer> applicationIdList) {

    if (applicationIdList == null || applicationIdList.isEmpty()) {
        return list();
    }/*from   w  ww. j a v a 2s  .c  o  m*/

    List<Integer> scanIds = sessionFactory.getCurrentSession().createCriteria(Application.class)
            .add(Restrictions.in("id", applicationIdList)).createAlias("scans", "scans")
            .add(Restrictions.eq("scans.lockedMetadata", false))
            .setProjection(Projections.groupProperty("scans.id")).list();

    if (scanIds != null && !scanIds.isEmpty()) {
        return sessionFactory.getCurrentSession().createCriteria(Scan.class).add(Restrictions.in("id", scanIds))
                .list();
    } else {
        return list();
    }

}

From source file:com.denimgroup.threadfix.data.dao.hibernate.HibernateVulnerabilitySearchDao.java

License:Mozilla Public License

@Override
public List<VulnerabilityTreeElement> getTree(VulnerabilitySearchParameters parameters) {
    assert parameters != null;

    Criteria criteria = VulnerabilitySearchCriteriaConstructor
            .getCriteriaWithRestrictions(sessionFactory.getCurrentSession(), parameters);

    criteria.setProjection(Projections.projectionList().add(Projections.countDistinct("id"), "numResults")
            .add(Projections.groupProperty("severity.intValue"))
            .add(Projections.groupProperty("genericVulnAlias.id"), "genericVulnerabilityId")
            .add(Projections.groupProperty("genericVulnAlias.name"), "genericVulnerabilityName")
            .add(Projections.groupProperty("genericVulnAlias.cweId"), "genericVulnerabilityDisplayId")
            .add(Projections.groupProperty("severity.intValue"), "severityIntValue"))
            .addOrder(Order.desc("severityIntValue")).addOrder(Order.desc("numResults"));

    criteria.setResultTransformer(Transformers.aliasToBean(VulnerabilityTreeElement.class));

    return (List<VulnerabilityTreeElement>) criteria.list();
}

From source file:com.denimgroup.threadfix.data.dao.hibernate.HibernateVulnerabilitySearchDao.java

License:Mozilla Public License

@Override
public List<Map> getScanComparison(VulnerabilitySearchParameters parameters, boolean isFalsePositive) {
    assert parameters != null;
    List<Integer> idList = getVulnIdList(parameters);

    if (idList.isEmpty())
        return list();

    Session session = sessionFactory.getCurrentSession();

    List<Map> fullList = list();

    // TODO refactor this to reduce duplication or remove the need for it
    int current = 0;
    while (current < idList.size()) {

        int start = current, end = current + 500;
        if (end > idList.size()) {
            end = idList.size();//  ww w  .j av  a2s.  c o  m
        }

        List<Integer> thisPage = idList.subList(start, end);

        Criteria criteria = session.createCriteria(Vulnerability.class);

        criteria.createAlias("findings", "finding");
        criteria.createAlias("finding.scan", "scan");
        criteria.createAlias("scan.applicationChannel", "applicationChannel");
        criteria.createAlias("applicationChannel.channelType", "channelType");
        criteria.add(Restrictions.in("id", thisPage));

        ProjectionList projectionList = Projections.projectionList()
                .add(Projections.groupProperty("channelType.name"), "channelName")
                .add(Projections.alias(Projections.countDistinct("id"), "foundCount"));

        if (!isFalsePositive) {
            projectionList.add(Projections.groupProperty("foundHAMEndpoint"), "foundHAMEndpoint");
        }
        criteria.setProjection(projectionList);
        criteria.addOrder(Order.desc("foundCount"));
        criteria.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);

        List results = (List<Map>) criteria.list();
        fullList.addAll(results);

        current += 500;
    }

    return fullList;

}

From source file:com.eucalyptus.cloudwatch.common.internal.domain.metricdata.MetricManager.java

License:Open Source License

public static List<Collection<MetricStatistics>> getManyMetricStatistics(
        List<GetMetricStatisticsParams> getMetricStatisticsParamses) {
    if (getMetricStatisticsParamses == null)
        throw new IllegalArgumentException("getMetricStatisticsParamses can not be null");
    Date now = new Date();
    Map<GetMetricStatisticsParams, Collection<MetricStatistics>> resultMap = Maps.newHashMap();
    Multimap<Class, GetMetricStatisticsParams> hashGroupMap = LinkedListMultimap.create();
    for (GetMetricStatisticsParams getMetricStatisticsParams : getMetricStatisticsParamses) {
        if (getMetricStatisticsParams == null)
            throw new IllegalArgumentException("getMetricStatisticsParams can not be null");
        getMetricStatisticsParams.validate(now);
        Class metricEntityClass = MetricEntityFactory.getClassForEntitiesGet(
                getMetricStatisticsParams.getMetricType(), getMetricStatisticsParams.getDimensionHash());
        hashGroupMap.put(metricEntityClass, getMetricStatisticsParams);
    }//from w ww  .ja v  a  2  s.  co m
    for (Class metricEntityClass : hashGroupMap.keySet()) {
        try (final TransactionResource db = Entities.transactionFor(metricEntityClass)) {
            // set some global criteria to start (for narrowing?)
            Date minDate = null;
            Date maxDate = null;
            Junction disjunction = Restrictions.disjunction();
            Map<GetMetricStatisticsParams, TreeMap<GetMetricStatisticsAggregationKey, MetricStatistics>> multiAggregationMap = Maps
                    .newHashMap();
            for (GetMetricStatisticsParams getMetricStatisticsParams : hashGroupMap.get(metricEntityClass)) {
                multiAggregationMap.put(getMetricStatisticsParams,
                        new TreeMap<GetMetricStatisticsAggregationKey, MetricStatistics>(
                                GetMetricStatisticsAggregationKey.COMPARATOR_WITH_NULLS.INSTANCE));
                Junction conjunction = Restrictions.conjunction();
                conjunction = conjunction
                        .add(Restrictions.lt("timestamp", getMetricStatisticsParams.getEndTime()));
                conjunction = conjunction
                        .add(Restrictions.ge("timestamp", getMetricStatisticsParams.getStartTime()));
                conjunction = conjunction
                        .add(Restrictions.eq("accountId", getMetricStatisticsParams.getAccountId()));
                conjunction = conjunction
                        .add(Restrictions.eq("metricName", getMetricStatisticsParams.getMetricName()));
                conjunction = conjunction
                        .add(Restrictions.eq("namespace", getMetricStatisticsParams.getNamespace()));
                conjunction = conjunction.add(
                        Restrictions.eq("dimensionHash", hash(getMetricStatisticsParams.getDimensionMap())));
                if (getMetricStatisticsParams.getUnits() != null) {
                    conjunction = conjunction
                            .add(Restrictions.eq("units", getMetricStatisticsParams.getUnits()));
                }
                disjunction = disjunction.add(conjunction);
                if (minDate == null || getMetricStatisticsParams.getStartTime().before(minDate)) {
                    minDate = getMetricStatisticsParams.getStartTime();
                }
                if (maxDate == null || getMetricStatisticsParams.getEndTime().after(maxDate)) {
                    maxDate = getMetricStatisticsParams.getEndTime();
                }
            }
            Criteria criteria = Entities.createCriteria(metricEntityClass);
            criteria = criteria.add(Restrictions.lt("timestamp", maxDate));
            criteria = criteria.add(Restrictions.ge("timestamp", minDate));
            criteria = criteria.add(disjunction);

            ProjectionList projectionList = Projections.projectionList();
            projectionList.add(Projections.max("sampleMax"));
            projectionList.add(Projections.min("sampleMin"));
            projectionList.add(Projections.sum("sampleSize"));
            projectionList.add(Projections.sum("sampleSum"));
            projectionList.add(Projections.groupProperty("units"));
            projectionList.add(Projections.groupProperty("timestamp"));
            projectionList.add(Projections.groupProperty("accountId"));
            projectionList.add(Projections.groupProperty("metricName"));
            projectionList.add(Projections.groupProperty("metricType"));
            projectionList.add(Projections.groupProperty("namespace"));
            projectionList.add(Projections.groupProperty("dimensionHash"));
            criteria.setProjection(projectionList);
            criteria.addOrder(Order.asc("timestamp"));

            ScrollableResults results = criteria.setCacheMode(CacheMode.IGNORE).scroll(ScrollMode.FORWARD_ONLY);
            while (results.next()) {
                MetricEntity me = getMetricEntity(results);
                for (GetMetricStatisticsParams getMetricStatisticsParams : hashGroupMap
                        .get(metricEntityClass)) {
                    if (metricDataMatches(getMetricStatisticsParams, me)) {
                        Map<GetMetricStatisticsAggregationKey, MetricStatistics> aggregationMap = multiAggregationMap
                                .get(getMetricStatisticsParams);
                        GetMetricStatisticsAggregationKey key = new GetMetricStatisticsAggregationKey(me,
                                getMetricStatisticsParams.getStartTime(), getMetricStatisticsParams.getPeriod(),
                                getMetricStatisticsParams.getDimensionHash());
                        MetricStatistics item = new MetricStatistics(me,
                                getMetricStatisticsParams.getStartTime(), getMetricStatisticsParams.getPeriod(),
                                getMetricStatisticsParams.getDimensions());
                        if (!aggregationMap.containsKey(key)) {
                            aggregationMap.put(key, item);
                        } else {
                            MetricStatistics totalSoFar = aggregationMap.get(key);
                            totalSoFar.setSampleMax(Math.max(item.getSampleMax(), totalSoFar.getSampleMax()));
                            totalSoFar.setSampleMin(Math.min(item.getSampleMin(), totalSoFar.getSampleMin()));
                            totalSoFar.setSampleSize(totalSoFar.getSampleSize() + item.getSampleSize());
                            totalSoFar.setSampleSum(totalSoFar.getSampleSum() + item.getSampleSum());
                        }
                    }
                }
            }
            for (GetMetricStatisticsParams getMetricStatisticsParams : multiAggregationMap.keySet()) {
                resultMap.put(getMetricStatisticsParams,
                        multiAggregationMap.get(getMetricStatisticsParams).values());
            }
        }
    }
    List<Collection<MetricStatistics>> resultList = Lists.newArrayList();
    for (GetMetricStatisticsParams getMetricStatisticsParams : getMetricStatisticsParamses) {
        if (resultMap.get(getMetricStatisticsParams) == null) {
            resultList.add(new ArrayList<MetricStatistics>());
        } else {
            resultList.add(resultMap.get(getMetricStatisticsParams));
        }
    }
    return resultList;
}

From source file:com.eucalyptus.cloudwatch.common.internal.domain.metricdata.MetricManager.java

License:Open Source License

public static Collection<MetricStatistics> getMetricStatistics(
        GetMetricStatisticsParams getMetricStatisticsParams) {
    if (getMetricStatisticsParams == null)
        throw new IllegalArgumentException("getMetricStatisticsParams can not be null");
    Date now = new Date();
    getMetricStatisticsParams.validate(now);
    Class metricEntityClass = MetricEntityFactory.getClassForEntitiesGet(
            getMetricStatisticsParams.getMetricType(), getMetricStatisticsParams.getDimensionHash());
    Map<GetMetricStatisticsAggregationKey, MetricStatistics> aggregationMap = new TreeMap<GetMetricStatisticsAggregationKey, MetricStatistics>(
            GetMetricStatisticsAggregationKey.COMPARATOR_WITH_NULLS.INSTANCE);
    try (final TransactionResource db = Entities.transactionFor(metricEntityClass)) {
        Criteria criteria = Entities.createCriteria(metricEntityClass);
        criteria = criteria.add(Restrictions.eq("accountId", getMetricStatisticsParams.getAccountId()));
        criteria = criteria.add(Restrictions.eq("metricName", getMetricStatisticsParams.getMetricName()));
        criteria = criteria.add(Restrictions.eq("namespace", getMetricStatisticsParams.getNamespace()));
        criteria = criteria.add(Restrictions.lt("timestamp", getMetricStatisticsParams.getEndTime()));
        criteria = criteria.add(Restrictions.ge("timestamp", getMetricStatisticsParams.getStartTime()));
        criteria = criteria.add(Restrictions.eq("dimensionHash", getMetricStatisticsParams.getDimensionHash()));
        if (getMetricStatisticsParams.getUnits() != null) {
            criteria = criteria.add(Restrictions.eq("units", getMetricStatisticsParams.getUnits()));
        }//from   ww  w  .  j av  a 2 s . c  o m

        ProjectionList projectionList = Projections.projectionList();
        projectionList.add(Projections.max("sampleMax"));
        projectionList.add(Projections.min("sampleMin"));
        projectionList.add(Projections.sum("sampleSize"));
        projectionList.add(Projections.sum("sampleSum"));
        projectionList.add(Projections.groupProperty("units"));
        projectionList.add(Projections.groupProperty("timestamp"));
        criteria.setProjection(projectionList);
        criteria.addOrder(Order.asc("timestamp"));
        ScrollableResults results = criteria.setCacheMode(CacheMode.IGNORE).scroll(ScrollMode.FORWARD_ONLY);
        while (results.next()) {
            MetricEntity me = getMetricEntity(getMetricStatisticsParams.getAccountId(),
                    getMetricStatisticsParams.getMetricName(), getMetricStatisticsParams.getNamespace(),
                    getMetricStatisticsParams.getMetricType(), getMetricStatisticsParams.getDimensionHash(),
                    results);
            GetMetricStatisticsAggregationKey key = new GetMetricStatisticsAggregationKey(me,
                    getMetricStatisticsParams.getStartTime(), getMetricStatisticsParams.getPeriod(),
                    getMetricStatisticsParams.getDimensionHash());
            MetricStatistics item = new MetricStatistics(me, getMetricStatisticsParams.getStartTime(),
                    getMetricStatisticsParams.getPeriod(), getMetricStatisticsParams.getDimensions());
            if (!aggregationMap.containsKey(key)) {
                aggregationMap.put(key, item);
            } else {
                MetricStatistics totalSoFar = aggregationMap.get(key);
                totalSoFar.setSampleMax(Math.max(item.getSampleMax(), totalSoFar.getSampleMax()));
                totalSoFar.setSampleMin(Math.min(item.getSampleMin(), totalSoFar.getSampleMin()));
                totalSoFar.setSampleSize(totalSoFar.getSampleSize() + item.getSampleSize());
                totalSoFar.setSampleSum(totalSoFar.getSampleSum() + item.getSampleSum());
            }
        }
    }
    return Lists.newArrayList(aggregationMap.values());
}

From source file:com.evolveum.midpoint.repo.sql.QueryInterpreterTest.java

License:Apache License

private void addFullObjectProjectionList(String prefix, ProjectionList list, boolean group) {
    if (prefix == null) {
        prefix = "";
    } else {//from w  ww.  j av a  2  s  . c o  m
        prefix = prefix + ".";
    }

    if (group) {
        list.add(Projections.groupProperty(prefix + "fullObject"));
        list.add(Projections.groupProperty(prefix + "stringsCount"));
        list.add(Projections.groupProperty(prefix + "longsCount"));
        list.add(Projections.groupProperty(prefix + "datesCount"));
        list.add(Projections.groupProperty(prefix + "referencesCount"));
        list.add(Projections.groupProperty(prefix + "polysCount"));
    } else {
        list.add(Projections.property(prefix + "fullObject"));
        list.add(Projections.property(prefix + "stringsCount"));
        list.add(Projections.property(prefix + "longsCount"));
        list.add(Projections.property(prefix + "datesCount"));
        list.add(Projections.property(prefix + "referencesCount"));
        list.add(Projections.property(prefix + "polysCount"));
    }
}

From source file:com.gps.rptbean.DataSourceFactory.java

public static JRDataSource buildYearlyDataSource(Vehicle v, String year, String measureName) {

    assert (v != null);
    assert (year != null);

    Date startDate = null;//from w w w. ja  v  a2s  .  c o  m
    try {
        startDate = (new SimpleDateFormat("yyyy")).parse(year);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    Calendar cal = Calendar.getInstance();
    cal.setTime(startDate);
    cal.add(Calendar.YEAR, 1);
    Date endDate = cal.getTime();

    Session session = HibernateUtil.getSession();

    List results = session.createCriteria(FRuningLog.class)
            .setProjection(Projections.projectionList().add(Projections.rowCount(), "rowCount")
                    .add(Projections.sum(measureName), "total")
                    .add(Projections.groupProperty("yearMonth"), "yearMonth"))
            .add(Restrictions.eq("vehicle.vehicleId", v.getVehicleId()))
            .add(Restrictions.le("startDate", endDate)).add(Restrictions.ge("startDate", startDate))
            .addOrder(Order.asc("yearMonth")).list();

    //   
    //      FRuningLogBean fruningLogBean = new FRuningLogBean();
    //      
    //      fruningLogBean.setVehicleId(v.getVehicleId());
    //      fruningLogBean.setStartDateStart(startDate);
    //      fruningLogBean.setStartDateEnd(endDate);
    //      
    //      fruningLogBean.getList();
    YearlyDataSource ds = null;
    ds = new YearlyDataSource();

    Iterator iter = results.iterator();

    while (iter.hasNext()) {
        Object[] row = (Object[]) iter.next();
        Integer count = (Integer) row[0];
        Double total = (Double) row[1];
        String yearMonth = (String) row[2];

        int idx = getIndex(yearMonth);
        YearlyBean bean = new YearlyBean(idx);
        bean.setVehicleId(v.getVehicleId());
        bean.setLicensePad(v.getLicensPadNumber());
        bean.setMeasure1(total);
        ds.addRecord(idx, bean);
    }

    return ds;

}

From source file:com.gps.rptbean.DataSourceFactory.java

public static JRDataSource buildMonthlyCostDataSource(Vehicle v, Date start, Date end) {

    CostAnalysisDataSource result = new CostAnalysisDataSource();

    assert (v != null);
    assert (start != null);
    assert (end != null);
    int index = 1;

    Session session = HibernateUtil.getSession();

    List results = session.createCriteria(FRuningLog.class)
            .setProjection(Projections.projectionList().add(Projections.rowCount(), "runCount")
                    .add(Projections.sum("totalCost"), "total").add(Projections.sum("actualGas"), "totalGas")
                    .add(Projections.sum("gasByCashCost"), "totalGasCash")
                    .add(Projections.sum("gasByCardCost"), "totalGasCard")
                    .add(Projections.sum("actualDistance"), "totalDistance")
                    .add(Projections.sum("actualRoadFee"), "totalRoadFee")
                    .add(Projections.sum("overLimitFee"), "totalOverLimitFee")
                    .add(Projections.groupProperty("vehicle.vehicleId"), "vehicleId"))
            .add(Restrictions.eq("vehicle.vehicleId", v.getVehicleId())).add(Restrictions.le("startDate", end))
            .add(Restrictions.ge("startDate", start)).list();

    Double gas = (Double) ((Object[]) results.get(0))[2];
    Double gasByCash = (Double) ((Object[]) results.get(0))[3];
    Double gasByCard = (Double) ((Object[]) results.get(0))[4];

    Double gasFee = gasByCash + gasByCard;
    Double roadFee = (Double) ((Object[]) results.get(0))[6];
    Double limitFee = (Double) ((Object[]) results.get(0))[7];

    CostAnalysisBean bean1 = new CostAnalysisBean();
    bean1.setCategoryName("");
    bean1.setIndex(index);//www .  ja  v  a2s.  co  m
    bean1.setLicensePad(v.getLicensPadNumber());
    bean1.setMeasure1(gasFee);
    bean1.setVehicleId(v.getVehicleId());
    result.addRecord(index - 1, bean1);
    index++;

    CostAnalysisBean bean2 = new CostAnalysisBean();
    bean2.setCategoryName("");
    bean2.setIndex(index);
    bean2.setLicensePad(v.getLicensPadNumber());
    bean2.setMeasure1(roadFee);
    bean2.setVehicleId(v.getVehicleId());
    result.addRecord(index - 1, bean2);
    index++;

    CostAnalysisBean bean3 = new CostAnalysisBean();
    bean3.setCategoryName("?");
    bean3.setIndex(index);
    bean3.setLicensePad(v.getLicensPadNumber());
    bean3.setMeasure1(limitFee);
    bean3.setVehicleId(v.getVehicleId());
    result.addRecord(index - 1, bean3);
    index++;

    results = null;
    results = session.createCriteria(FMaintain.class)
            .setProjection(Projections.projectionList().add(Projections.rowCount(), "runCount")
                    .add(Projections.sum("cost"), "total")
                    .add(Projections.groupProperty("vehicle.vehicleId"), "vehicleId"))
            .add(Restrictions.eq("vehicle.vehicleId", v.getVehicleId()))
            .add(Restrictions.le("maintainDate", end)).add(Restrictions.ge("maintainDate", start)).list();

    if (results.size() > 0) {
        Double maitainFee = (Double) ((Object[]) results.get(0))[1];

        CostAnalysisBean bean4 = new CostAnalysisBean();
        bean4.setCategoryName("?");
        bean4.setIndex(index);
        bean4.setLicensePad(v.getLicensPadNumber());
        bean4.setMeasure1(maitainFee);
        bean4.setVehicleId(v.getVehicleId());
        result.addRecord(index - 1, bean4);
        index++;
    }

    String yearMonth = new SimpleDateFormat("yyyyMM").format(start);
    results = null;
    results = session.createCriteria(FExpenseLog.class)
            .setProjection(Projections.projectionList().add(Projections.rowCount(), "runCount")
                    .add(Projections.sum("amount"), "total")
                    .add(Projections.groupProperty("category1"), "category1"))
            .add(Restrictions.eq("vehicle.vehicleId", v.getVehicleId()))
            .add(Restrictions.eq("yearMonth", yearMonth)).list();

    Iterator iter = results.iterator();

    while (iter.hasNext()) {
        Object[] row = (Object[]) iter.next();
        Integer count = (Integer) row[0];
        Double total = (Double) row[1];
        String category = (String) row[2];

        CostAnalysisBean bean = new CostAnalysisBean();
        bean.setIndex(index);
        bean.setCategoryName(category);
        bean.setVehicleId(v.getVehicleId());
        bean.setLicensePad(v.getLicensPadNumber());
        bean.setMeasure1(total);
        result.addRecord(index - 1, bean);
        index++;
    }

    return result;
}