Package org.ofbiz.entity

Examples of org.ofbiz.entity.GenericEntity$NullField


        return null;
    }

    public String getAffiliateId() {
        try {
            GenericEntity distributorRole = EntityUtil.getFirst(orderHeader.getRelatedByAnd("OrderRole", UtilMisc.toMap("roleTypeId", "AFFILIATE")));

            return distributorRole == null ? null : distributorRole.getString("partyId");
        } catch (GenericEntityException e) {
            Debug.logWarning(e, module);
        }
        return null;
    }
View Full Code Here


            EntityListIterator removeEli = delegator.find("EntitySyncRemove", findValCondition, null, null, UtilMisc.toList(ModelEntity.STAMP_TX_FIELD, ModelEntity.STAMP_FIELD), null);
            GenericValue entitySyncRemove = null;
            while ((entitySyncRemove = (GenericValue) removeEli.next()) != null) {
                // pull the PK from the EntitySyncRemove in the primaryKeyRemoved field, de-XML-serialize it
                String primaryKeyRemoved = entitySyncRemove.getString("primaryKeyRemoved");
                GenericEntity pkToRemove = null;
                try {
                    pkToRemove = (GenericEntity) XmlSerializer.deserialize(primaryKeyRemoved, delegator);
                } catch (IOException e) {
                    String errorMsg = "Error deserializing GenericPK to remove in Entity Sync Data for entitySyncId [" + entitySyncId + "] and entitySyncRemoveId [" + entitySyncRemove.getString("entitySyncRemoveId") + "]: " + e.toString();
                    Debug.logError(e, errorMsg, module);
                    throw new SyncDataErrorException(errorMsg, e);
                } catch (SAXException e) {
                    String errorMsg = "Error deserializing GenericPK to remove in Entity Sync Data for entitySyncId [" + entitySyncId + "] and entitySyncRemoveId [" + entitySyncRemove.getString("entitySyncRemoveId") + "]: " + e.toString();
                    Debug.logError(e, errorMsg, module);
                    throw new SyncDataErrorException(errorMsg, e);
                } catch (ParserConfigurationException e) {
                    String errorMsg = "Error deserializing GenericPK to remove in Entity Sync Data for entitySyncId [" + entitySyncId + "] and entitySyncRemoveId [" + entitySyncRemove.getString("entitySyncRemoveId") + "]: " + e.toString();
                    Debug.logError(e, errorMsg, module);
                    throw new SyncDataErrorException(errorMsg, e);
                } catch (SerializeException e) {
                    String errorMsg = "Error deserializing GenericPK to remove in Entity Sync Data for entitySyncId [" + entitySyncId + "] and entitySyncRemoveId [" + entitySyncRemove.getString("entitySyncRemoveId") + "]: " + e.toString();
                    Debug.logError(e, errorMsg, module);
                    throw new SyncDataErrorException(errorMsg, e);
                }
               
                // set the stamp fields for future reference
                pkToRemove.set(ModelEntity.STAMP_TX_FIELD, entitySyncRemove.get(ModelEntity.STAMP_TX_FIELD));
                pkToRemove.set(ModelEntity.STAMP_FIELD, entitySyncRemove.get(ModelEntity.STAMP_FIELD));
                pkToRemove.set(ModelEntity.CREATE_STAMP_TX_FIELD, entitySyncRemove.get(ModelEntity.CREATE_STAMP_TX_FIELD));
                pkToRemove.set(ModelEntity.CREATE_STAMP_FIELD, entitySyncRemove.get(ModelEntity.CREATE_STAMP_FIELD));

                if (this.entityNameToUseSet.contains(pkToRemove.getEntityName())) {
                    keysToRemove.add(pkToRemove);
                }
            }
            removeEli.close();

            // if we didn't find anything for this entity, find the next value's Timestamp and keep track of it
            if (keysToRemove.size() == 0) {
                EntityCondition findNextCondition = EntityCondition.makeCondition(ModelEntity.STAMP_TX_FIELD, EntityOperator.GREATER_THAN_EQUAL_TO, currentRunEndTime);
                EntityListIterator eliNext = delegator.find("EntitySyncRemove", findNextCondition, null, null, UtilMisc.toList(ModelEntity.STAMP_TX_FIELD), null);
                // get the first element and it's tx time value...
                GenericValue firstVal = (GenericValue) eliNext.next();
                eliNext.close();
                if (firstVal != null) {
                    Timestamp nextTxTime = firstVal.getTimestamp(ModelEntity.STAMP_TX_FIELD);
                    if (this.nextUpdateTxTime == null || nextTxTime.before(this.nextUpdateTxTime)) {
                        this.nextUpdateTxTime = nextTxTime;
                    }
                }
            }
        } catch (GenericEntityException e) {
            try {
                TransactionUtil.rollback(beganTransaction, "Entity Engine error in assembleKeysToRemove", e);
            } catch (GenericTransactionException e2) {
                Debug.logWarning(e2, "Unable to call rollback()", module);
            }
            throw new SyncDataErrorException("Error getting keys to remove from the datasource", e);
        } catch (Throwable t) {
            try {
                TransactionUtil.rollback(beganTransaction, "General error in assembleKeysToRemove", t);
            } catch (GenericTransactionException e2) {
                Debug.logWarning(e2, "Unable to call rollback()", module);
            }
            throw new SyncDataErrorException("Caught runtime error while getting keys to remove", t);
        }

        try {
            TransactionUtil.commit(beganTransaction);
        } catch (GenericTransactionException e) {
            throw new SyncDataErrorException("Commit transaction failed", e);
        }

        // TEST SECTION: leave false for normal use
        boolean logValues = false;
        if (logValues && keysToRemove.size() > 0) {
            StringBuilder toRemoveInfo = new StringBuilder();
            Iterator keysToRemoveIter = keysToRemove.iterator();
            while (keysToRemoveIter.hasNext()) {
                GenericEntity keyToRemove = (GenericEntity) keysToRemoveIter.next();
                toRemoveInfo.append("\n-->[");
                toRemoveInfo.append(keyToRemove.get(ModelEntity.STAMP_TX_FIELD));
                toRemoveInfo.append(":");
                toRemoveInfo.append(keyToRemove.get(ModelEntity.STAMP_FIELD));
                toRemoveInfo.append("] ");
                toRemoveInfo.append(keyToRemove);
            }
            Debug.logInfo(toRemoveInfo.toString(), module);
        }
View Full Code Here

         finAccountCode = finAccountCode.toUpperCase().replaceAll(filterRegex.pattern(), "");
        
         // now we need to get the encrypted version of the fin account code the user passed in to look up against FinAccount
         // we do this by making a temporary generic entity with same finAccountCode and then doing a match
         ModelEntity finAccountEntity = delegator.getModelEntity("FinAccount");
         GenericEntity encryptedFinAccount = GenericEntity.createGenericEntity(finAccountEntity, UtilMisc.toMap("finAccountCode", finAccountCode));
         delegator.encryptFields(encryptedFinAccount);
         String encryptedFinAccountCode = encryptedFinAccount.getString("finAccountCode");
        
         // now look for the account
         List accounts = delegator.findByAnd("FinAccount", UtilMisc.toMap("finAccountCode", encryptedFinAccountCode));
         accounts = EntityUtil.filterByDate(accounts);
        
View Full Code Here

                List productAssocs = delegator.findByAndCache("ProductAssoc", UtilMisc.toMap(
                        "productIdTo", productId,
                        "productAssocTypeId", "PRODUCT_VARIANT"));
                productAssocs = EntityUtil.filterByDate(productAssocs);
                if (productAssocs.size() > 0) {
                    GenericEntity productAssoc = EntityUtil.getFirst(productAssocs);
                    agreementItems = delegator.findByAndCache("AgreementItemAndProductAppl", UtilMisc.toMap(
                            "productId", productAssoc.getString("productId"),
                            "agreementItemTypeId", "AGREEMENT_COMMISSION"));
                }
            }
            // this is not very efficient if there were many
            agreementItems = EntityUtil.filterByDate(agreementItems);
View Full Code Here

        return partyObject;
    }

    public String getDistributorId() {
        try {
            GenericEntity distributorRole = EntityUtil.getFirst(orderHeader.getRelatedByAnd("OrderRole", UtilMisc.toMap("roleTypeId", "DISTRIBUTOR")));

            return distributorRole == null ? null : distributorRole.getString("partyId");
        } catch (GenericEntityException e) {
            Debug.logWarning(e, module);
        }
        return null;
    }
View Full Code Here

        return null;
    }

    public String getAffiliateId() {
        try {
            GenericEntity distributorRole = EntityUtil.getFirst(orderHeader.getRelatedByAnd("OrderRole", UtilMisc.toMap("roleTypeId", "AFFILIATE")));

            return distributorRole == null ? null : distributorRole.getString("partyId");
        } catch (GenericEntityException e) {
            Debug.logWarning(e, module);
        }
        return null;
    }
View Full Code Here

            servicePathMap = null;
           
            if(servicePathObject instanceof HashMap){
                servicePathMap = (HashMap)servicePathObject;
            }else if(servicePathObject instanceof GenericEntity){
                GenericEntity servicePathEntity = (GenericEntity)servicePathObject;
                Set servicePathEntitySet = servicePathEntity.keySet();
                Iterator spesItr = servicePathEntitySet.iterator();
                servicePathMap = FastMap.newInstance();
                while(spesItr.hasNext()){
                    String spesKey = (String)spesItr.next();
                    servicePathMap.put(spesKey, servicePathEntity.get(spesKey));
                }
            }else if(servicePathObject instanceof Collection){
                Collection servicePathColl = (Collection)servicePathObject;
                Iterator splItr = servicePathColl.iterator();
                int count=0;
View Full Code Here

            delegator = GenericDelegator.getGenericDelegator(delegatorName);
        }

        Map inMap = (Map) mapAcsr.get(methodContext);
        if (UtilValidate.isEmpty(entityName) && inMap instanceof GenericEntity) {
            GenericEntity inEntity = (GenericEntity) inMap;
            entityName = inEntity.getEntityName();
        }
       
        Collection fieldsToSelectList = null;
        if (!fieldsToSelectListAcsr.isEmpty()) {
            fieldsToSelectList = (Collection) fieldsToSelectListAcsr.get(methodContext);
View Full Code Here

            }
           
            // iterate through to remove list and remove each
            Iterator keyToRemoveIter = keysToRemove.iterator();
            while (keyToRemoveIter.hasNext()) {
                GenericEntity pkToRemove = (GenericEntity) keyToRemoveIter.next();
               
                // check to see if it exists, if so remove and count, if not just count already removed
                // always do a removeByAnd, if it was a removeByAnd great, if it was a removeByPrimaryKey, this will also work and save us a query
                pkToRemove.setIsFromEntitySync(true);
               
                // remove the stamp fields inserted by EntitySyncContext.java at or near line 646
                pkToRemove.remove(ModelEntity.STAMP_TX_FIELD);
                pkToRemove.remove(ModelEntity.STAMP_FIELD);
                pkToRemove.remove(ModelEntity.CREATE_STAMP_TX_FIELD);
                pkToRemove.remove(ModelEntity.CREATE_STAMP_FIELD);
               
                int numRemByAnd = delegator.removeByAnd(pkToRemove.getEntityName(), pkToRemove);
                if (numRemByAnd == 0) {
                    toRemoveAlreadyDeleted++;
                } else {
                    toRemoveDeleted++;
                }
View Full Code Here

             * it qualifies and add it to the list of existingVariantProductIds.
             */
            List productAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT")));
            Iterator productAssocIter = productAssocs.iterator();
            while (productAssocIter.hasNext()) {
                GenericEntity productAssoc = (GenericEntity) productAssocIter.next();

                //for each associated product, if it has all standard features, display it's productId
                boolean hasAllFeatures = true;
                Iterator curProductFeatureAndApplIter = curProductFeatureAndAppls.iterator();
                while (curProductFeatureAndApplIter.hasNext()) {
                    String productFeatureAndAppl = (String) curProductFeatureAndApplIter.next();
                    Map findByMap = UtilMisc.toMap("productId", productAssoc.getString("productIdTo"),
                            "productFeatureId", productFeatureAndAppl,
                            "productFeatureApplTypeId", "STANDARD_FEATURE");

                    //Debug.log("Using findByMap: " + findByMap);

                    List standardProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAppl", findByMap));
                    if (UtilValidate.isEmpty(standardProductFeatureAndAppls)) {
                        // Debug.log("Does NOT have this standard feature");
                        hasAllFeatures = false;
                        break;
                    } else {
                        // Debug.log("DOES have this standard feature");
                    }
                }

                if (hasAllFeatures) {
                    // add to list of existing variants: productId=productAssoc.productIdTo
                    existingVariantProductIds.add(productAssoc.get("productIdTo"));
                }
            }
            results = ServiceUtil.returnSuccess();
            results.put("variantProductIds", existingVariantProductIds);
        } catch (GenericEntityException ex) {
View Full Code Here

TOP

Related Classes of org.ofbiz.entity.GenericEntity$NullField

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.