Package org.ofbiz.entity.model

Examples of org.ofbiz.entity.model.DynamicViewEntity


    public List getAllIdsForProcessesWithExpiriedDeadlines(long l, SharkTransaction trans) throws PersistenceException {
        if (Debug.infoOn()) Debug.log(":: getAllIdsForProcessesWithExpiriedDeadlines ::", module);
        GenericDelegator delegator = SharkContainer.getDelegator();
        List processIds = new ArrayList();

        DynamicViewEntity view = new DynamicViewEntity();
        view.addMemberEntity("WFDL", org.ofbiz.shark.SharkConstants.WfDeadline);
        view.addMemberEntity("WFPR", org.ofbiz.shark.SharkConstants.WfProcess);
        view.addMemberEntity("WFAC", org.ofbiz.shark.SharkConstants.WfActivity);
        view.addAlias("WFPR", org.ofbiz.shark.SharkConstants.currentState, "processState", null, null, null, null);
        view.addAlias("WFAC", org.ofbiz.shark.SharkConstants.currentState, "activityState", null, null, null, null);
        view.addViewLink("WFDL", "WFPR", Boolean.FALSE, ModelKeyMap.makeKeyMapList(org.ofbiz.shark.SharkConstants.processId));
        view.addViewLink("WFDL", "WFAC", Boolean.FALSE, ModelKeyMap.makeKeyMapList(org.ofbiz.shark.SharkConstants.activityId));

        EntityListIterator eli = null;
        try {
            EntityCondition procState = EntityCondition.makeCondition("processState", EntityOperator.EQUALS, "open.running");
            EntityCondition actState1 = EntityCondition.makeCondition("activityState", EntityOperator.EQUALS, "open.not_running.not_started");
View Full Code Here


        return this.condition;
    }

    public List runQuery() throws GenericEntityException {
        GenericDelegator delegator = this.getDelegator();
        DynamicViewEntity view = this.makeView();
        EntityListIterator eli = null;
        List result = null;
        try {
            eli = delegator.findListIteratorByCondition(view, this.getCondition(), null, null, null, null);
            result = eli.getCompleteList();
View Full Code Here

    protected GenericDelegator getDelegator() {
        return SharkContainer.getDelegator();
    }

    private DynamicViewEntity makeView() {
        DynamicViewEntity view = new DynamicViewEntity();


        // create the members
        Iterator eni = this.entityNames.entrySet().iterator();
        while (eni.hasNext()) {
            Map.Entry entry = (Map.Entry) eni.next();
            view.addMemberEntity((String) entry.getKey(), (String) entry.getValue());
        }

        // set alias all fields
        Iterator aai = autoFields.iterator();
        while (aai.hasNext()) {
            String alias = (String) aai.next();
            view.addAliasAll(alias, "");
        }

        // create the other field aliases
        Iterator fni = fieldNames.keySet().iterator();
        while (fni.hasNext()) {
            String entityAlias = (String) fni.next();
            Map fieldMap = (Map) fieldNames.get(entityAlias);
            Iterator fmi = fieldMap.entrySet().iterator();
            while (fmi.hasNext()) {
                Map.Entry entry = (Map.Entry) fmi.next();
                view.addAlias(entityAlias, (String) entry.getValue(), (String) entry.getKey(), null, null, null, null);
            }
        }

        // add the view links
        Iterator vli = this.viewLinks.iterator();
        while (vli.hasNext()) {
            ViewLink vl = (ViewLink) vli.next();
            view.addViewLink(vl.entityAlias, vl.relEntityAlias, new Boolean(vl.relOptional), vl.keyMaps);
        }

        return view;
    }
View Full Code Here

        if (!canViewPo) {
            conditions.add(new EntityExpr("orderTypeId", EntityOperator.NOT_EQUAL, "PURCHASE_ORDER"));
        }

        // dynamic view entity
        DynamicViewEntity dve = new DynamicViewEntity();
        dve.addMemberEntity("OH", "OrderHeader");
        dve.addAliasAll("OH", ""); // no prefix
        dve.addRelation("one-nofk", "", "OrderType", UtilMisc.toList(new ModelKeyMap("orderTypeId", "orderTypeId")));
        dve.addRelation("one-nofk", "", "StatusItem", UtilMisc.toList(new ModelKeyMap("statusId", "statusId")));

        // start the lookup
        String orderId = (String) context.get("orderId");
        if (UtilValidate.isNotEmpty(orderId)) {
            paramList.add("orderId=" + orderId);
            conditions.add(makeExpr("orderId", orderId));
        }

        // the base order header fields
        List orderTypeList = (List) context.get("orderTypeId");
        if (orderTypeList != null) {
            Iterator i = orderTypeList.iterator();
            List orExprs = FastList.newInstance();
            while (i.hasNext()) {
                String orderTypeId = (String) i.next();
                paramList.add("orderTypeId=" + orderTypeId);

                if (!"PURCHASE_ORDER".equals(orderTypeId) || ("PURCHASE_ORDER".equals(orderTypeId) && canViewPo)) {
                    orExprs.add(new EntityExpr("orderTypeId", EntityOperator.EQUALS, orderTypeId));
                }
            }
            conditions.add(new EntityConditionList(orExprs, EntityOperator.OR));
        }

        String orderName = (String) context.get("orderName");
        if (UtilValidate.isNotEmpty(orderName)) {
            paramList.add("orderName=" + orderName);
            conditions.add(makeExpr("orderName", orderName, true));
        }

        List orderStatusList = (List) context.get("orderStatusId");
        if (orderStatusList != null) {
            Iterator i = orderStatusList.iterator();
            List orExprs = FastList.newInstance();
            while (i.hasNext()) {
                String orderStatusId = (String) i.next();
                paramList.add("orderStatusId=" + orderStatusId);
                if ("PENDING".equals(orderStatusId)) {
                    List pendExprs = FastList.newInstance();
                    pendExprs.add(new EntityExpr("statusId", EntityOperator.EQUALS, "ORDER_CREATED"));
                    pendExprs.add(new EntityExpr("statusId", EntityOperator.EQUALS, "ORDER_PROCESSING"));
                    pendExprs.add(new EntityExpr("statusId", EntityOperator.EQUALS, "ORDER_APPROVED"));
                    orExprs.add(new EntityConditionList(pendExprs, EntityOperator.OR));
                } else {
                    orExprs.add(new EntityExpr("statusId", EntityOperator.EQUALS, orderStatusId));
                }
            }
            conditions.add(new EntityConditionList(orExprs, EntityOperator.OR));
        }

        List productStoreList = (List) context.get("productStoreId");
        if (productStoreList != null) {
            Iterator i = productStoreList.iterator();
            List orExprs = FastList.newInstance();
            while (i.hasNext()) {
                String productStoreId = (String) i.next();
                paramList.add("productStoreId=" + productStoreId);
                orExprs.add(new EntityExpr("productStoreId", EntityOperator.EQUALS, productStoreId));
            }
            conditions.add(new EntityConditionList(orExprs, EntityOperator.OR));
        }

        List webSiteList = (List) context.get("orderWebSiteId");
        if (webSiteList != null) {
            Iterator i = webSiteList.iterator();
            List orExprs = FastList.newInstance();
            while (i.hasNext()) {
                String webSiteId = (String) i.next();
                paramList.add("webSiteId=" + webSiteId);
                orExprs.add(new EntityExpr("webSiteId", EntityOperator.EQUALS, webSiteId));
            }
            conditions.add(new EntityConditionList(orExprs, EntityOperator.OR));
        }

        List saleChannelList = (List) context.get("salesChannelEnumId");
        if (saleChannelList != null) {
            Iterator i = saleChannelList.iterator();
            List orExprs = FastList.newInstance();
            while (i.hasNext()) {
                String salesChannelEnumId = (String) i.next();
                paramList.add("salesChannelEnumId=" + salesChannelEnumId);
                orExprs.add(new EntityExpr("salesChannelEnumId", EntityOperator.EQUALS, salesChannelEnumId));
            }
            conditions.add(new EntityConditionList(orExprs, EntityOperator.OR));
        }

        String createdBy = (String) context.get("createdBy");
        if (UtilValidate.isNotEmpty(createdBy)) {
            paramList.add("createdBy=" + createdBy);
            conditions.add(makeExpr("createdBy", createdBy));
        }

        String terminalId = (String) context.get("terminalId");
        if (UtilValidate.isNotEmpty(terminalId)) {
            paramList.add("terminalId=" + terminalId);
            conditions.add(makeExpr("terminalId", terminalId));
        }

        String transactionId = (String) context.get("transactionId");
        if (UtilValidate.isNotEmpty(transactionId)) {
            paramList.add("transactionId=" + transactionId);
            conditions.add(makeExpr("transactionId", transactionId));
        }

        String externalId = (String) context.get("externalId");
        if (UtilValidate.isNotEmpty(externalId)) {
            paramList.add("externalId=" + externalId);
            conditions.add(makeExpr("externalId", externalId));
        }

        String internalCode = (String) context.get("internalCode");
        if (UtilValidate.isNotEmpty(internalCode)) {
            paramList.add("internalCode=" + internalCode);
            conditions.add(makeExpr("internalCode", internalCode));
        }

        String dateField = "Y".equals(useEntryDate) ? "entryDate" : "orderDate";
        String minDate = (String) context.get("minDate");
        if (UtilValidate.isNotEmpty(minDate) && minDate.length() > 8) {
            minDate = minDate.trim();
            if (minDate.length() < 14) minDate = minDate + " " + "00:00:00.000";
            paramList.add("minDate=" + minDate);

            try {
                Object converted = ObjectType.simpleTypeConvert(minDate, "Timestamp", null, null);
                if (converted != null) {
                    conditions.add(new EntityExpr(dateField, EntityOperator.GREATER_THAN_EQUAL_TO, converted));
                }
            } catch (GeneralException e) {
                Debug.logWarning(e.getMessage(), module);
            }
        }

        String maxDate = (String) context.get("maxDate");
        if (UtilValidate.isNotEmpty(maxDate) && maxDate.length() > 8) {
            maxDate = maxDate.trim();
            if (maxDate.length() < 14) maxDate = maxDate + " " + "23:59:59.999";
            paramList.add("maxDate=" + maxDate);

            try {
                Object converted = ObjectType.simpleTypeConvert(maxDate, "Timestamp", null, null);
                if (converted != null) {
                    conditions.add(new EntityExpr("orderDate", EntityOperator.LESS_THAN_EQUAL_TO, converted));
                }
            } catch (GeneralException e) {
                Debug.logWarning(e.getMessage(), module);
            }
        }

        // party (role) fields
        String userLoginId = (String) context.get("userLoginId");
        String partyId = (String) context.get("partyId");
        List roleTypeList = (List) context.get("roleTypeId");

        if (UtilValidate.isNotEmpty(userLoginId) && UtilValidate.isEmpty(partyId)) {
            GenericValue ul = null;
            try {
                ul = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", userLoginId));
            } catch (GenericEntityException e) {
                Debug.logWarning(e.getMessage(), module);
            }
            if (ul != null) {
                partyId = ul.getString("partyId");
            }
        }

        // add the role data to the view
        if (roleTypeList != null || partyId != null) {
            dve.addMemberEntity("OT", "OrderRole");
            dve.addAlias("OT", "partyId");
            dve.addAlias("OT", "roleTypeId");
            dve.addViewLink("OH", "OT", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("orderId", "orderId")));
        }

        if (UtilValidate.isNotEmpty(partyId)) {
            paramList.add("partyId=" + partyId);
            fieldsToSelect.add("partyId");
            conditions.add(makeExpr("partyId", partyId));
        }

        if (roleTypeList != null) {
            fieldsToSelect.add("roleTypeId");
            Iterator i = roleTypeList.iterator();
            List orExprs = FastList.newInstance();
            while (i.hasNext()) {
                String roleTypeId = (String) i.next();
                paramList.add("roleTypeId=" + roleTypeId);
                orExprs.add(makeExpr("roleTypeId", roleTypeId));
            }
            conditions.add(new EntityConditionList(orExprs, EntityOperator.OR));
        }

        // order item fields
        String correspondingPoId = (String) context.get("correspondingPoId");
        String subscriptionId = (String) context.get("subscriptionId");
        String productId = (String) context.get("productId");
        String budgetId = (String) context.get("budgetId");
        String quoteId = (String) context.get("quoteId");

        if (correspondingPoId != null || subscriptionId != null || productId != null || budgetId != null || quoteId != null) {
            dve.addMemberEntity("OI", "OrderItem");
            dve.addAlias("OI", "correspondingPoId");
            dve.addAlias("OI", "subscriptionId");
            dve.addAlias("OI", "productId");
            dve.addAlias("OI", "budgetId");
            dve.addAlias("OI", "quoteId");
            dve.addViewLink("OH", "OI", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("orderId", "orderId")));
        }

        if (UtilValidate.isNotEmpty(correspondingPoId)) {
            paramList.add("correspondingPoId=" + correspondingPoId);
            conditions.add(makeExpr("correspondingPoId", correspondingPoId));
        }

        if (UtilValidate.isNotEmpty(subscriptionId)) {
            paramList.add("subscriptionId=" + subscriptionId);
            conditions.add(makeExpr("subscriptionId", subscriptionId));
        }

        if (UtilValidate.isNotEmpty(productId)) {
            paramList.add("productId=" + productId);
            if (productId.startsWith("%") || productId.startsWith("*") || productId.endsWith("%") || productId.endsWith("*")) {
                conditions.add(makeExpr("productId", productId));
            } else {
                GenericValue product = null;
                try {
                    product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
                } catch (GenericEntityException e) {
                    Debug.logWarning(e.getMessage(), module);
                }
                if (product != null) {
                    String isVirtual = product.getString("isVirtual");
                    if (isVirtual != null && "Y".equals(isVirtual)) {
                        List orExprs = FastList.newInstance();
                        orExprs.add(new EntityExpr("productId", EntityOperator.EQUALS, productId));

                        Map varLookup = null;
                        try {
                            varLookup = dispatcher.runSync("getAllProductVariants", UtilMisc.toMap("productId", productId));
                        } catch (GenericServiceException e) {
                            Debug.logWarning(e.getMessage(), module);
                        }
                        List variants = (List) varLookup.get("assocProducts");
                        if (variants != null) {
                            Iterator i = variants.iterator();
                            while (i.hasNext()) {
                                GenericValue v = (GenericValue) i.next();
                                orExprs.add(new EntityExpr("productId", EntityOperator.EQUALS, v.getString("productIdTo")));
                            }
                        }
                        conditions.add(new EntityConditionList(orExprs, EntityOperator.OR));
                    } else {
                        conditions.add(new EntityExpr("productId", EntityOperator.EQUALS, productId));
                    }
                }
            }
        }

        if (UtilValidate.isNotEmpty(budgetId)) {
            paramList.add("budgetId=" + budgetId);
            conditions.add(makeExpr("budgetId", budgetId));
        }

        if (UtilValidate.isNotEmpty(quoteId)) {
            paramList.add("quoteId=" + quoteId);
            conditions.add(makeExpr("quoteId", quoteId));
        }

        // payment preference fields
        String billingAccountId = (String) context.get("billingAccountId");
        String finAccountId = (String) context.get("finAccountId");
        String cardNumber = (String) context.get("cardNumber");
        String accountNumber = (String) context.get("accountNumber");

        if (billingAccountId != null || finAccountId != null || cardNumber != null || accountNumber != null) {
            dve.addMemberEntity("OP", "OrderPaymentPreference");
            dve.addAlias("OP", "billingAccountId");
            dve.addAlias("OP", "finAccountId");
            dve.addAlias("OP", "paymentMethodId");
            dve.addViewLink("OH", "OP", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("orderId", "orderId")));
        }

        // search by billing account ID
        if (UtilValidate.isNotEmpty(billingAccountId)) {
            paramList.add("billingAccountId=" + billingAccountId);
            conditions.add(makeExpr("billingAccountId", billingAccountId));
        }

        // search by fin account ID
        if (UtilValidate.isNotEmpty(finAccountId)) {
            paramList.add("finAccountId=" + finAccountId);
            conditions.add(makeExpr("finAccountId", finAccountId));
        }

        // search by card number
        if (UtilValidate.isNotEmpty(cardNumber)) {
            dve.addMemberEntity("CC", "CreditCard");
            dve.addAlias("CC", "cardNumber");
            dve.addViewLink("OP", "CC", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("paymentMethodId", "paymentMethodId")));

            paramList.add("cardNumber=" + cardNumber);
            conditions.add(makeExpr("cardNumber", cardNumber));
        }

        // search by eft account number
        if (UtilValidate.isNotEmpty(accountNumber)) {
            dve.addMemberEntity("EF", "EftAccount");
            dve.addAlias("EF", "accountNumber");
            dve.addViewLink("OP", "EF", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("paymentMethodId", "paymentMethodId")));

            paramList.add("accountNumber=" + accountNumber);
            conditions.add(makeExpr("accountNumber", accountNumber));
        }

        // shipment/inventory item
        String inventoryItemId = (String) context.get("inventoryItemId");
        String softIdentifier = (String) context.get("softIdentifier");
        String serialNumber = (String) context.get("serialNumber");
        String shipmentId = (String) context.get("shipmentId");

        if (shipmentId != null || inventoryItemId != null || softIdentifier != null || serialNumber != null) {
            dve.addMemberEntity("II", "ItemIssuance");
            dve.addAlias("II", "shipmentId");
            dve.addAlias("II", "inventoryItemId");
            dve.addViewLink("OH", "II", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("orderId", "orderId")));

            if (softIdentifier != null || serialNumber != null) {
                dve.addMemberEntity("IV", "InventoryItem");
                dve.addAlias("IV", "softIdentifier");
                dve.addAlias("IV", "serialNumber");
                dve.addViewLink("II", "IV", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("inventoryItemId", "inventoryItemId")));
            }
        }

        if (UtilValidate.isNotEmpty(inventoryItemId)) {
            paramList.add("inventoryItemId=" + inventoryItemId);
            conditions.add(makeExpr("inventoryItemId", inventoryItemId));
        }

        if (UtilValidate.isNotEmpty(softIdentifier)) {
            paramList.add("softIdentifier=" + softIdentifier);
            conditions.add(makeExpr("softIdentifier", softIdentifier, true));
        }

        if (UtilValidate.isNotEmpty(serialNumber)) {
            paramList.add("serialNumber=" + serialNumber);
            conditions.add(makeExpr("serialNumber", serialNumber, true));
        }

        if (UtilValidate.isNotEmpty(shipmentId)) {
            paramList.add("shipmentId=" + shipmentId);
            conditions.add(makeExpr("shipmentId", shipmentId));
        }

        // back order checking
        String hasBackOrders = (String) context.get("hasBackOrders");
        if (UtilValidate.isNotEmpty(hasBackOrders)) {
            dve.addMemberEntity("IR", "OrderItemShipGrpInvRes");
            dve.addAlias("IR", "quantityNotAvailable");
            dve.addViewLink("OH", "IR", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("orderId", "orderId")));

            paramList.add("hasBackOrders=" + hasBackOrders);
            if ("Y".equals(hasBackOrders)) {
                conditions.add(new EntityExpr("quantityNotAvailable", EntityOperator.NOT_EQUAL, null));
                conditions.add(new EntityExpr("quantityNotAvailable", EntityOperator.GREATER_THAN, new Double(0)));
View Full Code Here

                result.put("listPrice", onePrice.getDouble("price"));
                result.put("wholeSalePrice", onePrice.getDouble("price"));
            }
        }
   
        DynamicViewEntity salesUsageViewEntity = new DynamicViewEntity();
        DynamicViewEntity productionUsageViewEntity = new DynamicViewEntity();
        if (! UtilValidate.isEmpty(checkTime)) {
   
            // Construct a dynamic view entity to search against for sales usage quantities
            salesUsageViewEntity.addMemberEntity("OI", "OrderItem");
            salesUsageViewEntity.addMemberEntity("OH", "OrderHeader");
            salesUsageViewEntity.addMemberEntity("ItIss", "ItemIssuance");
            salesUsageViewEntity.addMemberEntity("InvIt", "InventoryItem");
            salesUsageViewEntity.addViewLink("OI", "OH", new Boolean(false), ModelKeyMap.makeKeyMapList("orderId"));
            salesUsageViewEntity.addViewLink("OI", "ItIss", new Boolean(false), ModelKeyMap.makeKeyMapList("orderId", "orderId", "orderItemSeqId", "orderItemSeqId"));
            salesUsageViewEntity.addViewLink("ItIss", "InvIt", new Boolean(false), ModelKeyMap.makeKeyMapList("inventoryItemId"));
            salesUsageViewEntity.addAlias("OI", "productId");
            salesUsageViewEntity.addAlias("OH", "statusId");
            salesUsageViewEntity.addAlias("OH", "orderTypeId");
            salesUsageViewEntity.addAlias("OH", "orderDate");
            salesUsageViewEntity.addAlias("ItIss", "inventoryItemId");
            salesUsageViewEntity.addAlias("ItIss", "quantity");
            salesUsageViewEntity.addAlias("InvIt", "facilityId");
       
            // Construct a dynamic view entity to search against for production usage quantities
            productionUsageViewEntity.addMemberEntity("WEIA", "WorkEffortInventoryAssign");
            productionUsageViewEntity.addMemberEntity("WE", "WorkEffort");
            productionUsageViewEntity.addMemberEntity("II", "InventoryItem");
            productionUsageViewEntity.addViewLink("WEIA", "WE", new Boolean(false), ModelKeyMap.makeKeyMapList("workEffortId"));
            productionUsageViewEntity.addViewLink("WEIA", "II", new Boolean(false), ModelKeyMap.makeKeyMapList("inventoryItemId"));
            productionUsageViewEntity.addAlias("WEIA", "quantity");
            productionUsageViewEntity.addAlias("WE", "actualCompletionDate");
            productionUsageViewEntity.addAlias("WE", "workEffortTypeId");
            productionUsageViewEntity.addAlias("II", "facilityId");
            productionUsageViewEntity.addAlias("II", "productId");

        }
        if (! UtilValidate.isEmpty(checkTime)) {
           
            // Make a query against the sales usage view entity
View Full Code Here

        Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
        Locale locale = (Locale) context.get("locale");
        String errMsg = null;

        try {
            DynamicViewEntity dve = new DynamicViewEntity();
            dve.addMemberEntity("PCM", "ProductCategoryMember");
            dve.addAlias("PCM", "productId", null, null, null, Boolean.TRUE, null);
            dve.addAlias("PCM", "productCategoryId", null, null, null, Boolean.TRUE, null);
            dve.addAlias("PCM", "fromDate", null, null, null, null, null);
            dve.addAlias("PCM", "thruDate", null, null, null, null, null);
            dve.addAlias("PCM", "productIdCount", "productId", null, null, null, "count");

            EntityCondition condition = new EntityConditionList(UtilMisc.toList(
                    new EntityExpr("fromDate", EntityOperator.LESS_THAN, nowTimestamp),
                    new EntityExpr("thruDate", EntityOperator.EQUALS, null)
                    ), EntityOperator.AND);
View Full Code Here

        Locale locale = (Locale) context.get("locale");
        String errMsg = null;

        Debug.logInfo("Starting makeStandAloneFromSingleVariantVirtuals", module);

        DynamicViewEntity dve = new DynamicViewEntity();
        dve.addMemberEntity("PVIRT", "Product");
        dve.addMemberEntity("PVA", "ProductAssoc");
        //dve.addMemberEntity("PVAR", "Product");
        dve.addViewLink("PVIRT", "PVA", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("productId", "productId")));
        //dve.addViewLink("PVA", "PVAR", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("productIdTo", "productId")));
        dve.addAlias("PVIRT", "productId", null, null, null, Boolean.TRUE, null);
        dve.addAlias("PVIRT", "salesDiscontinuationDate", null, null, null, null, null);
        dve.addAlias("PVA", "productAssocTypeId", null, null, null, null, null);
        dve.addAlias("PVA", "fromDate", null, null, null, null, null);
        dve.addAlias("PVA", "thruDate", null, null, null, null, null);
        dve.addAlias("PVA", "productIdToCount", "productIdTo", null, null, null, "count-distinct");
        //dve.addAlias("PVAR", "variantProductId", "productId", null, null, null, null);

        try {
            EntityCondition condition = new EntityConditionList(UtilMisc.toList(
                    new EntityExpr("productAssocTypeId", EntityOperator.EQUALS, "PRODUCT_VARIANT"),
View Full Code Here

    public List getAllIdsForProcessesWithExpiriedDeadlines(long l, SharkTransaction trans) throws PersistenceException {
        if (Debug.infoOn()) Debug.log(":: getAllIdsForProcessesWithExpiriedDeadlines ::", module);
        GenericDelegator delegator = SharkContainer.getDelegator();
        List processIds = new ArrayList();

        DynamicViewEntity view = new DynamicViewEntity();
        view.addMemberEntity("WFDL", org.ofbiz.shark.SharkConstants.WfDeadline);
        view.addMemberEntity("WFPR", org.ofbiz.shark.SharkConstants.WfProcess);
        view.addMemberEntity("WFAC", org.ofbiz.shark.SharkConstants.WfActivity);
        view.addAlias("WFPR", org.ofbiz.shark.SharkConstants.currentState, "processState", null, null, null, null);
        view.addAlias("WFAC", org.ofbiz.shark.SharkConstants.currentState, "activityState", null, null, null, null);
        view.addViewLink("WFDL", "WFPR", Boolean.FALSE, ModelKeyMap.makeKeyMapList(org.ofbiz.shark.SharkConstants.processId));
        view.addViewLink("WFDL", "WFAC", Boolean.FALSE, ModelKeyMap.makeKeyMapList(org.ofbiz.shark.SharkConstants.activityId));

        EntityListIterator eli = null;
        try {
            EntityCondition procState = new EntityExpr("processState", EntityOperator.EQUALS, "open.running");
            EntityCondition actState1 = new EntityExpr("activityState", EntityOperator.EQUALS, "open.not_running.not_started");
View Full Code Here

        return this.condition;
    }

    public List runQuery() throws GenericEntityException {
        GenericDelegator delegator = this.getDelegator();
        DynamicViewEntity view = this.makeView();
        EntityListIterator eli = null;
        List result = null;
        try {
            eli = delegator.findListIteratorByCondition(view, this.getCondition(), null, null, null, null);
            result = eli.getCompleteList();
View Full Code Here

    protected GenericDelegator getDelegator() {
        return SharkContainer.getDelegator();
    }

    private DynamicViewEntity makeView() {
        DynamicViewEntity view = new DynamicViewEntity();


        // create the members
        Iterator eni = this.entityNames.entrySet().iterator();
        while (eni.hasNext()) {
            Map.Entry entry = (Map.Entry) eni.next();
            view.addMemberEntity((String) entry.getKey(), (String) entry.getValue());
        }

        // set alias all fields
        Iterator aai = autoFields.iterator();
        while (aai.hasNext()) {
            String alias = (String) aai.next();
            view.addAliasAll(alias, "");
        }

        // create the other field aliases
        Iterator fni = fieldNames.keySet().iterator();
        while (fni.hasNext()) {
            String entityAlias = (String) fni.next();
            Map fieldMap = (Map) fieldNames.get(entityAlias);
            Iterator fmi = fieldMap.entrySet().iterator();
            while (fmi.hasNext()) {
                Map.Entry entry = (Map.Entry) fmi.next();
                view.addAlias(entityAlias, (String) entry.getValue(), (String) entry.getKey(), null, null, null, null);
            }
        }

        // add the view links
        Iterator vli = this.viewLinks.iterator();
        while (vli.hasNext()) {
            ViewLink vl = (ViewLink) vli.next();
            view.addViewLink(vl.entityAlias, vl.relEntityAlias, new Boolean(vl.relOptional), vl.keyMaps);
        }

        return view;
    }
View Full Code Here

TOP

Related Classes of org.ofbiz.entity.model.DynamicViewEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.