public Collection getConsumed() { if (consumedItems == null) { synchronized (cachedDBValues) { Asset asset = myPG.getMei(); if (asset instanceof AggregateAsset) { asset = ((AggregateAsset) asset).getAsset(); } String typeId = asset.getTypeIdentificationPG().getTypeIdentification(); consumedItems = (Collection) cachedDBValues.get(typeId); if (consumedItems == null) { consumedItems = parentPlugin.generateRationList(); if (consumedItems.isEmpty()) { if (logger.isDebugEnabled()) { logger.debug( "getConsumed(): Database query returned EMPTY result set for " + myPG.getMei() + ", " + supplyType); } } else { cachedDBValues.put(typeId, consumedItems); } } } } return consumedItems; }
public List getPredicates() { ArrayList predList = new ArrayList(); predList.add(new OrgActivityPred()); predList.add(new LogisticsOPlanPredicate()); predList.add(new FeedingPolicyPred(myPG.getService())); return predList; }
public Schedule getParameterSchedule(Collection col, TimeSpan span) { Schedule paramSchedule = null; Vector params = new Vector(); Iterator predList = col.iterator(); UnaryPredicate predicate; // DEBUG // String myOrgName = // parentPlugin.getMyOrg().getItemIdentificationPG().getItemIdentification(); // if (myOrgName.indexOf("35-ARBN") >= 0) { // System.out.println("getParamSched() Asset is "+ // myPG.getMei().getTypeIdentificationPG().getTypeIdentification()); // } ArrayList consumerlist = new ArrayList(); consumerlist.add(myPG.getMei()); Schedule consumerSched = parentPlugin.getScheduleUtils().createConsumerSchedule(consumerlist); consumerSched = parentPlugin.getScheduleUtils().convertQuantitySchedule(consumerSched); params.add(parentPlugin.getScheduleUtils().trimObjectSchedule(consumerSched, span)); while (predList.hasNext()) { Iterator list = ((Collection) predList.next()).iterator(); predicate = (UnaryPredicate) list.next(); if (predicate instanceof OrgActivityPred) { Collection orgColl = (Collection) list.next(); if ((orgColl == null) || (orgColl.isEmpty())) { return null; } Schedule orgActSched = parentPlugin.getScheduleUtils().createOrgActivitySchedule(orgColl); params.add(parentPlugin.getScheduleUtils().trimObjectSchedule(orgActSched, span)); // if (myOrgName.indexOf("35-ARBN") >= 0) { // System.out.println("getParamSched() OrgActSched "+orgActSched); // } } else if (predicate instanceof LogisticsOPlanPredicate) { Collection oplanColl = (Collection) list.next(); if ((oplanColl == null) || (oplanColl.isEmpty())) { return null; } Iterator it = oplanColl.iterator(); if (it.hasNext()) { logOPlan = (LogisticsOPlan) it.next(); } } else if (predicate instanceof FeedingPolicyPred) { Collection fpColl = (Collection) list.next(); if ((fpColl == null) || (fpColl.isEmpty())) { return null; } Iterator it = fpColl.iterator(); Schedule sched; if (it.hasNext()) { feedingPolicy = (FeedingPolicy) it.next(); sched = getFeedingPolicySchedule(feedingPolicy); params.add(parentPlugin.getScheduleUtils().trimObjectSchedule(sched, span)); sched = getEnhancementPolicySchedule(feedingPolicy); params.add(parentPlugin.getScheduleUtils().trimObjectSchedule(sched, span)); sched = getWaterPolicySchedule(feedingPolicy); params.add(parentPlugin.getScheduleUtils().trimObjectSchedule(sched, span)); } } else { if (logger.isErrorEnabled()) { logger.error("getParameterSchedule: unknown predicate " + predicate); } } } paramSchedule = parentPlugin.getScheduleUtils().getMergedSchedule(params); return paramSchedule; }