I modified the BOMNode.java to customize for our requirements. The file
compiles successfully, When i run a BOM simulation, it shows: org.ofbiz.webapp.event.EventHandlerException: Service invocation error (null) I added a rate field to BOMNode.java and modiied the loadChildren() method as follows : protected void loadChildren(String partBomTypeId, Date inDate, List productFeatures, int type) throws GenericEntityException { if (product == null) { throw new GenericEntityException("product is null"); } // If the date is null, set it to today. if (inDate == null) inDate = new Date(); bomTypeId = partBomTypeId; // GenericDelegator delegator = product.getDelegator(); List rows = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", product.get("productId"), "productAssocTypeId", partBomTypeId), UtilMisc.toList("sequenceNum")); rows = EntityUtil.filterByDate(rows, inDate); if ((rows == null || rows.size() == 0) && substitutedNode != null) { // If no child is found and this is a substituted node // we try to search for substituted node's children. rows = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", substitutedNode.getProduct().get("productId"), "productAssocTypeId", partBomTypeId), UtilMisc.toList("sequenceNum")); rows = EntityUtil.filterByDate(rows, inDate); } children = new ArrayList(rows); childrenNodes = new ArrayList(); Iterator childrenIterator = children.iterator(); GenericValue oneChild = null; BOMNode oneChildNode = null; while(childrenIterator.hasNext()) { oneChild = (GenericValue)childrenIterator.next(); // Configurator oneChildNode = configurator(oneChild, productFeatures, getRootNode().getProductForRules(), inDate); // If the node is null this means that the node has been discarded by the rules. if (oneChildNode != null) { oneChildNode.setParentNode(this); switch (type) { case BOMTree.EXPLOSION: oneChildNode.loadChildren(partBomTypeId, inDate, productFeatures, BOMTree.EXPLOSION); break; case BOMTree.EXPLOSION_MANUFACTURING: if (!oneChildNode.isWarehouseManaged()) { oneChildNode.loadChildren(partBomTypeId, inDate, productFeatures, type); } break; } } childrenNodes.add(oneChildNode); } //-----Comment By: Midhat Ali. Customization Start Here ------- HashMap conditions=new HashMap(); conditions.put("PRODUCT_ID",this.product); List costs=null; GenericValue costComp=null; if (childrenNodes.isEmpty()) { costs=delegator.findByAnd("CostComponent",conditions); Iterator costIterator=costs.iterator(); while(costIterator.hasNext()) { costComp=(GenericValue)costIterator.next(); rate+=Double.parseDouble(costComp.get("cost").toString()); } } else { childrenIterator=childrenNodes.iterator(); while(childrenIterator.hasNext()) { oneChild=(GenericValue)childrenIterator.next(); rate+=Double.parseDouble(oneChild.get("rate").toString()); } } //-----Comment By: Midhat Ali. Customization Ends Here ------- } Please help |
Free forum by Nabble | Edit this page |