Example usage for org.hibernate ScrollMode FORWARD_ONLY

List of usage examples for org.hibernate ScrollMode FORWARD_ONLY

Introduction

In this page you can find the example usage for org.hibernate ScrollMode FORWARD_ONLY.

Prototype

ScrollMode FORWARD_ONLY

To view the source code for org.hibernate ScrollMode FORWARD_ONLY.

Click Source Link

Document

Requests a scrollable result that is only scrollable forwards.

Usage

From source file:org.openbravo.costing.InventoryAmountUpdateProcess.java

License:Open Source License

private ScrollableResults getStockLines(Set<String> childOrgs, Date date, Product product, Warehouse warehouse,
        boolean backdatedTransactionsFixed) {
    StringBuffer select = new StringBuffer();
    StringBuffer subSelect = new StringBuffer();

    select.append("select trx." + MaterialTransaction.PROPERTY_ATTRIBUTESETVALUE + ".id");
    select.append(", trx." + MaterialTransaction.PROPERTY_UOM + ".id");
    select.append(", trx." + MaterialTransaction.PROPERTY_ORDERUOM + ".id");
    select.append(", trx." + MaterialTransaction.PROPERTY_STORAGEBIN + ".id");
    select.append(", loc." + Locator.PROPERTY_WAREHOUSE + ".id");
    select.append(", sum(trx." + MaterialTransaction.PROPERTY_MOVEMENTQUANTITY + ")");
    select.append(", sum(trx." + MaterialTransaction.PROPERTY_ORDERQUANTITY + ")");
    select.append(" from " + MaterialTransaction.ENTITY_NAME + " as trx");
    select.append("    join trx." + MaterialTransaction.PROPERTY_STORAGEBIN + " as loc");
    select.append(" where trx." + MaterialTransaction.PROPERTY_ORGANIZATION + ".id in (:orgs)");
    if (date != null) {
        if (backdatedTransactionsFixed) {
            select.append("   and trx." + MaterialTransaction.PROPERTY_MOVEMENTDATE + " <= :date");
        } else {//  w  ww  . j  a v a2 s.  c o  m
            subSelect.append("select min(trx." + MaterialTransaction.PROPERTY_TRANSACTIONPROCESSDATE + ")");
            subSelect.append(" from " + MaterialTransaction.ENTITY_NAME + " as trx");
            subSelect.append("   join trx." + MaterialTransaction.PROPERTY_STORAGEBIN + " as locator");
            subSelect.append(" where trx." + MaterialTransaction.PROPERTY_PRODUCT + ".id = :product");
            subSelect.append(" and trx." + MaterialTransaction.PROPERTY_MOVEMENTDATE + " > :date");
            // Include only transactions that have its cost calculated
            subSelect.append("   and trx." + MaterialTransaction.PROPERTY_ISCOSTCALCULATED + " = true");
            if (warehouse != null) {
                subSelect.append("  and locator." + Locator.PROPERTY_WAREHOUSE + ".id = :warehouse");
            }
            subSelect.append("   and trx." + MaterialTransaction.PROPERTY_ORGANIZATION + ".id in (:orgs)");

            Query trxsubQry = OBDal.getInstance().getSession().createQuery(subSelect.toString());
            trxsubQry.setParameter("date", date);
            trxsubQry.setParameter("product", product.getId());
            if (warehouse != null) {
                trxsubQry.setParameter("warehouse", warehouse.getId());
            }
            trxsubQry.setParameterList("orgs", childOrgs);
            Object trxprocessDate = trxsubQry.uniqueResult();
            if (trxprocessDate != null) {
                date = (Date) trxprocessDate;
                select.append("   and trx." + MaterialTransaction.PROPERTY_TRANSACTIONPROCESSDATE + " < :date");
            } else {
                select.append("   and trx." + MaterialTransaction.PROPERTY_MOVEMENTDATE + " <= :date");
            }
        }
    }
    if (warehouse != null) {
        select.append("   and loc." + Locator.PROPERTY_WAREHOUSE + " = :warehouse");
    }
    select.append("   and trx." + MaterialTransaction.PROPERTY_PRODUCT + " = :product");
    select.append(" group by trx." + MaterialTransaction.PROPERTY_ATTRIBUTESETVALUE + ".id");
    select.append(", trx." + MaterialTransaction.PROPERTY_UOM + ".id");
    select.append(", trx." + MaterialTransaction.PROPERTY_ORDERUOM + ".id");
    select.append(", trx." + MaterialTransaction.PROPERTY_STORAGEBIN + ".id");
    select.append(", loc." + Locator.PROPERTY_WAREHOUSE + ".id");
    select.append(" having ");
    select.append(" sum(trx." + MaterialTransaction.PROPERTY_MOVEMENTQUANTITY + ") <> 0");
    select.append(" order by loc." + Locator.PROPERTY_WAREHOUSE + ".id");
    select.append(", trx." + MaterialTransaction.PROPERTY_STORAGEBIN + ".id");
    select.append(", trx." + MaterialTransaction.PROPERTY_ATTRIBUTESETVALUE + ".id");
    select.append(", trx." + MaterialTransaction.PROPERTY_UOM + ".id");
    select.append(", trx." + MaterialTransaction.PROPERTY_ORDERUOM + ".id");

    Query stockLinesQry = OBDal.getInstance().getSession().createQuery(select.toString());
    stockLinesQry.setParameterList("orgs", childOrgs);
    if (date != null) {
        stockLinesQry.setTimestamp("date", date);
    }
    if (warehouse != null) {
        stockLinesQry.setParameter("warehouse", warehouse);
    }
    stockLinesQry.setParameter("product", product);
    stockLinesQry.setFetchSize(1000);
    ScrollableResults stockLines = stockLinesQry.scroll(ScrollMode.FORWARD_ONLY);
    return stockLines;
}

From source file:org.openbravo.costing.LandedCostProcess.java

License:Open Source License

private CostAdjustment generateCostAdjustment(String strLandedCostId, JSONObject message) {
    LandedCost landedCost = OBDal.getInstance().get(LandedCost.class, strLandedCostId);
    Date referenceDate = landedCost.getReferenceDate();
    CostAdjustment ca = CostAdjustmentUtils.insertCostAdjustmentHeader(landedCost.getOrganization(), "LC");

    String strResult = OBMessageUtils.messageBD("LandedCostProcessed");
    Map<String, String> map = new HashMap<String, String>();
    map.put("documentNo", ca.getDocumentNo());
    try {/*w ww.  j  a v a 2  s .  c  o  m*/
        message.put("title", OBMessageUtils.messageBD("Success"));
        message.put("text", OBMessageUtils.parseTranslation(strResult, map));
    } catch (JSONException ignore) {
    }

    StringBuffer hql = new StringBuffer();
    hql.append(" select sum(rla." + LCReceiptLineAmt.PROPERTY_AMOUNT + ") as amt");
    hql.append("   , rla." + LCReceiptLineAmt.PROPERTY_LANDEDCOSTCOST + ".currency.id as lcCostCurrency");
    hql.append("   , rla." + LCReceipt.PROPERTY_GOODSSHIPMENTLINE + ".id as receipt");
    hql.append("   , (select " + MaterialTransaction.PROPERTY_TRANSACTIONPROCESSDATE + " from "
            + MaterialTransaction.ENTITY_NAME + " as transaction where "
            + MaterialTransaction.PROPERTY_GOODSSHIPMENTLINE + ".id = rla."
            + LCReceipt.PROPERTY_GOODSSHIPMENTLINE + ".id) as trxprocessdate");
    hql.append(" from " + LCReceiptLineAmt.ENTITY_NAME + " as rla");
    hql.append("   join rla." + LCReceiptLineAmt.PROPERTY_LANDEDCOSTRECEIPT + " as rl");
    hql.append(" where rl." + LCReceipt.PROPERTY_LANDEDCOST + " = :lc");
    hql.append("   and rla." + LCReceiptLineAmt.PROPERTY_ISMATCHINGADJUSTMENT + " = false ");
    hql.append(" group by rla." + LCReceiptLineAmt.PROPERTY_LANDEDCOSTCOST + ".currency.id");
    hql.append(" , rla." + LCReceipt.PROPERTY_GOODSSHIPMENTLINE + ".id");
    hql.append(" order by trxprocessdate, amt");

    Query qryLCRLA = OBDal.getInstance().getSession().createQuery(hql.toString());
    qryLCRLA.setParameter("lc", landedCost);

    ScrollableResults receiptamts = qryLCRLA.scroll(ScrollMode.FORWARD_ONLY);
    int i = 0;
    try {
        while (receiptamts.next()) {
            log.debug("Process receipt amounts");
            Object[] receiptAmt = receiptamts.get();
            BigDecimal amt = (BigDecimal) receiptAmt[0];
            Currency lcCostCurrency = OBDal.getInstance().get(Currency.class, receiptAmt[1]);
            ShipmentInOutLine receiptLine = OBDal.getInstance().get(ShipmentInOutLine.class, receiptAmt[2]);
            // MaterialTransaction receiptLine = (MaterialTransaction) record[1];
            MaterialTransaction trx = receiptLine.getMaterialMgmtMaterialTransactionList().get(0);
            CostAdjustmentLine cal = CostAdjustmentUtils.insertCostAdjustmentLine(trx, ca, amt, true,
                    referenceDate);
            cal.setNeedsPosting(Boolean.FALSE);
            cal.setUnitCost(Boolean.FALSE);
            cal.setCurrency(lcCostCurrency);
            cal.setLineNo((i + 1) * 10L);
            OBDal.getInstance().save(cal);

            if (i % 100 == 0) {
                OBDal.getInstance().flush();
                OBDal.getInstance().getSession().clear();
                ca = OBDal.getInstance().get(CostAdjustment.class, ca.getId());
            }
            i++;
        }
    } finally {
        receiptamts.close();
    }

    CostAdjustmentProcess.doProcessCostAdjustment(ca);

    return ca;
}

From source file:org.openbravo.costing.LCMatchingProcess.java

License:Open Source License

private String generateCostAdjustment(String strLCCostId, JSONObject message) throws JSONException {
    LandedCostCost lcCost = OBDal.getInstance().get(LandedCostCost.class, strLCCostId);
    Date referenceDate = lcCost.getAccountingDate();
    CostAdjustment ca = CostAdjustmentUtils.insertCostAdjustmentHeader(lcCost.getOrganization(), "LC");

    String strResult = OBMessageUtils.messageBD("LCMatchingProcessed");
    Map<String, String> map = new HashMap<String, String>();
    map.put("documentNo", ca.getDocumentNo());
    message.put("title", OBMessageUtils.messageBD("Success"));
    message.put("text", OBMessageUtils.parseTranslation(strResult, map));

    StringBuffer hql = new StringBuffer();
    hql.append(" select sum(rla." + LCReceiptLineAmt.PROPERTY_AMOUNT + ") as amt");
    hql.append("   , rla." + LCReceipt.PROPERTY_GOODSSHIPMENTLINE + ".id as receipt");
    hql.append("   , (select " + MaterialTransaction.PROPERTY_TRANSACTIONPROCESSDATE + " from "
            + MaterialTransaction.ENTITY_NAME + " as transaction where "
            + MaterialTransaction.PROPERTY_GOODSSHIPMENTLINE + ".id = rla."
            + LCReceipt.PROPERTY_GOODSSHIPMENTLINE + ".id) as trxprocessdate");
    hql.append(" from " + LCReceiptLineAmt.ENTITY_NAME + " as rla");
    hql.append(" where rla." + LCReceiptLineAmt.PROPERTY_LANDEDCOSTCOST + " = :lcc");
    hql.append("   and rla." + LCReceiptLineAmt.PROPERTY_ISMATCHINGADJUSTMENT + " = true ");
    hql.append(" group by rla." + LCReceipt.PROPERTY_GOODSSHIPMENTLINE + ".id");
    hql.append(" order by trxprocessdate, amt");

    Query qryLCRLA = OBDal.getInstance().getSession().createQuery(hql.toString());
    qryLCRLA.setParameter("lcc", lcCost);

    ScrollableResults receiptamts = qryLCRLA.scroll(ScrollMode.FORWARD_ONLY);
    int i = 0;//from w  ww  .ja  v a2 s .  co  m
    try {
        while (receiptamts.next()) {
            Object[] receiptAmt = receiptamts.get();
            BigDecimal amt = (BigDecimal) receiptAmt[0];
            ShipmentInOutLine receiptLine = OBDal.getInstance().get(ShipmentInOutLine.class, receiptAmt[1]);
            MaterialTransaction trx = receiptLine.getMaterialMgmtMaterialTransactionList().get(0);
            CostAdjustmentLine cal = CostAdjustmentUtils.insertCostAdjustmentLine(trx, ca, amt, true,
                    referenceDate);
            cal.setNeedsPosting(Boolean.FALSE);
            cal.setUnitCost(Boolean.FALSE);
            cal.setCurrency(lcCost.getCurrency());
            OBDal.getInstance().save(cal);

            if (i % 100 == 0) {
                OBDal.getInstance().flush();
                OBDal.getInstance().getSession().clear();
                ca = OBDal.getInstance().get(CostAdjustment.class, ca.getId());
            }
            i++;
        }
    } finally {
        receiptamts.close();
    }
    ca = OBDal.getInstance().get(CostAdjustment.class, ca.getId());
    CostAdjustmentProcess.doProcessCostAdjustment(ca);
    return ca.getId();
}

From source file:org.openbravo.costing.PriceDifferenceProcess.java

License:Open Source License

/**
 * @return the message to be shown to the user properly formatted and translated to the user
 *         language.//from  w ww .j av  a2  s . c  om
 * @throws OBException
 *           when there is an error that prevents the cost adjustment to be processed.
 * @throws OBException
 */
public static JSONObject processPriceDifference(Date date, Product product) throws OBException {

    JSONObject message = null;
    costAdjHeader = null;
    boolean costAdjCreated = false;
    int count = 0;
    OBCriteria<MaterialTransaction> mTrxs = OBDal.getInstance().createCriteria(MaterialTransaction.class);
    if (date != null) {
        mTrxs.add(Restrictions.le(MaterialTransaction.PROPERTY_MOVEMENTDATE, date));
    }
    if (product != null) {
        mTrxs.add(Restrictions.eq(MaterialTransaction.PROPERTY_PRODUCT, product));
    }
    mTrxs.add(Restrictions.eq(MaterialTransaction.PROPERTY_CHECKPRICEDIFFERENCE, true));
    mTrxs.add(Restrictions.eq(MaterialTransaction.PROPERTY_ISCOSTCALCULATED, true));
    mTrxs.addOrderBy(MaterialTransaction.PROPERTY_MOVEMENTDATE, true);
    mTrxs.addOrderBy(MaterialTransaction.PROPERTY_TRANSACTIONPROCESSDATE, true);
    ScrollableResults lines = mTrxs.scroll(ScrollMode.FORWARD_ONLY);

    try {
        while (lines.next()) {
            MaterialTransaction line = (MaterialTransaction) lines.get(0);
            costAdjCreated = calculateTransactionPriceDifference(line);
            if (costAdjCreated) {
                count++;
            }

        }
    } finally {
        lines.close();
    }

    Map<String, String> map = new HashMap<String, String>();
    map.put("trxsNumber", Integer.toString(count));
    String messageText = OBMessageUtils.messageBD("PriceDifferenceChecked");

    if (costAdjHeader != null) {
        OBDal.getInstance().flush();
        message = CostAdjustmentProcess.doProcessCostAdjustment(costAdjHeader);
        try {
            if (message.get("severity") != "success") {
                throw new OBException(OBMessageUtils.parseTranslation("@ErrorProcessingCostAdj@") + ": "
                        + costAdjHeader.getDocumentNo() + " - " + message.getString("text"));
            } else {
                message.put("title", OBMessageUtils.messageBD("Success"));
                message.put("text", OBMessageUtils.parseTranslation(messageText, map));
            }
        } catch (JSONException e) {
            throw new OBException(OBMessageUtils.parseTranslation("@ErrorProcessingCostAdj@"));
        }
        return message;
    } else {
        try {
            message = new JSONObject();
            message.put("severity", "success");
            message.put("title", OBMessageUtils.messageBD("Success"));
            message.put("text", OBMessageUtils.parseTranslation(messageText, map));
        } catch (JSONException ignore) {
        }
        return message;
    }
}

From source file:org.openbravo.costing.StandardCostAdjustment.java

License:Open Source License

private ScrollableResults getRelatedTransactions(Date firstDate, Date endingDate) {
    OrganizationStructureProvider osp = OBContext.getOBContext()
            .getOrganizationStructureProvider((String) DalUtil.getId(getCostOrg().getClient()));
    HashMap<CostDimension, BaseOBObject> costDimensions = getCostDimensions();
    Set<String> orgs = osp.getChildTree(strCostOrgId, true);
    CostingRule costingRule = getCostingRule();
    if (isManufacturingProduct) {
        orgs = osp.getChildTree("0", false);
        costDimensions = CostingUtils.getEmptyDimensions();
    }//w  w  w.  j  av  a  2  s.  c o m
    Warehouse warehouse = (Warehouse) costDimensions.get(CostDimension.Warehouse);
    MaterialTransaction trx = getTransaction();

    StringBuffer where = new StringBuffer();
    where.append(" as trx");
    where.append("\n join trx." + Product.PROPERTY_ORGANIZATION + " as org");
    where.append("\n join trx." + Product.PROPERTY_STORAGEBIN + " as loc");

    where.append("\n where trx." + MaterialTransaction.PROPERTY_ISCOSTCALCULATED + " = true");
    where.append("  and trx." + MaterialTransaction.PROPERTY_PRODUCT + " = :product");
    where.append("  and trx." + MaterialTransaction.PROPERTY_MOVEMENTDATE + " >= :mvtdate");
    where.append("  and trx." + MaterialTransaction.PROPERTY_MOVEMENTDATE + " <= :enddate");
    where.append("  and org.id in (:orgs)");
    if (warehouse != null) {
        where.append("  and loc." + Locator.PROPERTY_WAREHOUSE + " = :warehouse");
    }
    where.append("  and trx." + MaterialTransaction.PROPERTY_TRANSACTIONPROCESSDATE + " > :startdate");

    OBQuery<MaterialTransaction> trxQry = OBDal.getInstance().createQuery(MaterialTransaction.class,
            where.toString());
    trxQry.setFilterOnReadableOrganization(false);
    trxQry.setNamedParameter("mvtdate", firstDate);
    trxQry.setNamedParameter("enddate", endingDate);
    trxQry.setNamedParameter("orgs", orgs);
    trxQry.setNamedParameter("product", trx.getProduct());
    if (warehouse != null) {
        trxQry.setNamedParameter("warehouse", warehouse);
    }
    trxQry.setNamedParameter("startdate", CostingUtils.getCostingRuleStartingDate(costingRule));

    return trxQry.scroll(ScrollMode.FORWARD_ONLY);

}

From source file:org.openbravo.dal.service.OBQuery.java

License:Open Source License

/**
 * Computes the row number of a record which has the id which is passed in as a parameter. The
 * rownumber computation takes into account the filter and sorting settings of the the OBQuery
 * object.//from w  ww . j  a  v  a  2s  .  c o  m
 * 
 * @param targetId
 *          the record id
 * @return the row number or -1 if not found
 */
public int getRowNumber(String targetId) {
    String qryStr = createQueryString();
    if (qryStr.toLowerCase().contains(FROM_SPACED)) {
        final int index = qryStr.indexOf(FROM_SPACED) + FROM_SPACED.length();
        qryStr = qryStr.substring(index);
    }
    final Query qry = getSession().createQuery("select " + usedAlias + "id " + FROM_SPACED + qryStr);
    setParameters(qry);

    final ScrollableResults results = qry.scroll(ScrollMode.FORWARD_ONLY);
    try {
        while (results.next()) {
            final String id = results.getString(0);
            if (id.equals(targetId)) {
                return results.getRowNumber();
            }
        }
    } finally {
        results.close();
    }
    return -1;
}

From source file:org.openbravo.erpCommon.ad_actionButton.MRPManufacturingPlanProcess.java

License:Open Source License

private ScrollableResults getLinesToUpdate(String productionRunId) {
    StringBuffer where = new StringBuffer();
    where.append(" where " + ProductionRunLine.PROPERTY_MANUFACTURINGPLAN + ".id = :prodRun");
    where.append("   and " + ProductionRunLine.PROPERTY_QUANTITY + " < 0");
    where.append("   and " + ProductionRunLine.PROPERTY_TRANSACTIONTYPE + " <> 'WR'");
    OBQuery<ProductionRunLine> prlQry = OBDal.getInstance().createQuery(ProductionRunLine.class,
            where.toString());/* ww w. j  a  v a2s .co m*/
    prlQry.setNamedParameter("prodRun", productionRunId);

    prlQry.setFetchSize(1000);
    return prlQry.scroll(ScrollMode.FORWARD_ONLY);
}

From source file:org.openbravo.erpCommon.ad_process.MRPPurchaseCreateReservations.java

License:Open Source License

private ScrollableResults getPRLinesIncoming(PurchasingRun mrpPurchaseRun) {
    StringBuffer where = new StringBuffer();
    where.append(" where " + PurchasingRunLine.PROPERTY_PURCHASINGPLAN + ".id = :purchaserun");
    where.append("   and " + PurchasingRunLine.PROPERTY_QUANTITY + " > 0");
    where.append(" order by " + PurchasingRunLine.PROPERTY_PRODUCT + ","
            + PurchasingRunLine.PROPERTY_PLANNEDDATE + ", CASE " + PurchasingRunLine.PROPERTY_TRANSACTIONTYPE
            + " WHEN 'ST' THEN 0 WHEN 'MS' THEN 2 ELSE 1 END");

    OBQuery<PurchasingRunLine> soQry = OBDal.getInstance().createQuery(PurchasingRunLine.class,
            where.toString());/*from  w w w .jav a2s  .com*/
    soQry.setNamedParameter("purchaserun", mrpPurchaseRun.getId());
    soQry.setFetchSize(1000);
    return soQry.scroll(ScrollMode.FORWARD_ONLY);
}

From source file:org.openbravo.erpCommon.ad_process.MRPPurchaseCreateReservations.java

License:Open Source License

private ScrollableResults getPRLinesOutgoing(PurchasingRun mrpPurchaseRun) {
    StringBuffer where = new StringBuffer();
    where.append(" where " + PurchasingRunLine.PROPERTY_PURCHASINGPLAN + ".id = :purchaserun");
    where.append("   and " + PurchasingRunLine.PROPERTY_QUANTITY + " < 0");
    where.append(" order by " + PurchasingRunLine.PROPERTY_PRODUCT + ","
            + PurchasingRunLine.PROPERTY_PLANNEDDATE + ", CASE " + PurchasingRunLine.PROPERTY_TRANSACTIONTYPE
            + " WHEN 'ST' THEN 0 WHEN 'MS' THEN 2 ELSE 3 END");

    OBQuery<PurchasingRunLine> soQry = OBDal.getInstance().createQuery(PurchasingRunLine.class,
            where.toString());/*from  w  w  w . j  av a2  s .c o  m*/
    soQry.setNamedParameter("purchaserun", mrpPurchaseRun.getId());
    soQry.setFetchSize(1000);
    return soQry.scroll(ScrollMode.FORWARD_ONLY);
}

From source file:org.openbravo.erpCommon.utility.WindowTree.java

License:Open Source License

private List<WindowTreeData> applyWhereClause(List<WindowTreeData> subList, String strTabId) {
    String entityName = null, hqlWhereClause = null;
    try {//w w w. ja v a2  s. com
        OBContext.setAdminMode();
        Tab tabData = OBDal.getInstance().get(org.openbravo.model.ad.ui.Tab.class, strTabId);
        if (tabData != null) {
            entityName = tabData.getTable().getName();
            hqlWhereClause = tabData.getHqlwhereclause();
        }
    } catch (Exception e) {
        log4j.error("Exception while retrieving hqlWhereClause " + e);
    } finally {
        OBContext.restorePreviousMode();
    }

    List<WindowTreeData> newSubList = new ArrayList<WindowTreeData>();
    if (hqlWhereClause != null && !hqlWhereClause.trim().isEmpty()) {
        hqlWhereClause = hqlWhereClause.replaceAll("\\be.", "");
        OBQuery<BaseOBObject> entityResults = OBDal.getInstance().createQuery("" + entityName + "",
                hqlWhereClause);
        if (nodeIdList == null) {
            nodeIdList = new ArrayList<String>();
        }

        if (nodeIdList.size() == 0 && nodeIdList.size() != entityResults.count()) {
            ScrollableResults entityData = entityResults.scroll(ScrollMode.FORWARD_ONLY);
            int clearEachLoops = 100;
            int i = 0;
            try {
                while (entityData.next()) {
                    i++;
                    BaseOBObject entity = (BaseOBObject) entityData.get()[0];
                    if (entity.getId() != null) {
                        nodeIdList.add(entity.getId().toString());
                    }
                    if (i % clearEachLoops == 0) {
                        OBDal.getInstance().getSession().clear();
                    }
                }
            } finally {
                entityData.close();
            }
        }

        for (WindowTreeData elem : subList) {
            if (nodeIdList.contains(elem.nodeId)) {
                newSubList.add(elem);
            }
        }
    } else {
        newSubList = subList;
    }
    return newSubList;
}