protected Schedule getWaterPolicySchedule(FeedingPolicy fp) {
   Vector sched_els = new Vector(0);
   if (fp != null) {
     RangeRuleParameterEntry[] waterRanges = fp.getWaterPolicyRanges();
     ObjectScheduleElement element;
     long start, end;
     // e.g., min = 0 then start is C + 0 or C - Day of the operation
     // e.g., min = 1 then start is C + 1 or 2nd day of the operation
     if (waterRanges.length > 0) {
       start =
           parentPlugin
               .getTimeUtils()
               .addNDays(logOPlan.getStartTime(), waterRanges[0].getRangeMin());
       for (int i = 0; i < waterRanges.length; i++) {
         end =
             parentPlugin
                 .getTimeUtils()
                 .addNDays(
                     start, (waterRanges[i].getRangeMax() - waterRanges[i].getRangeMin() + 1));
         KeyRuleParameterEntry[] keys = fp.getRangeKeys(waterRanges[i]);
         element =
             new ObjectScheduleElement(
                 start,
                 end,
                 addWater(new HashMap(), BOTTLED_WATER, new Double(keys[0].getValue())));
         sched_els.addElement(element);
         start = end;
       }
     }
   } // else feeding policy is null return empty schedule
   return parentPlugin.getScheduleUtils().newObjectSchedule(sched_els.elements());
 }
 protected Schedule getEnhancementPolicySchedule(FeedingPolicy fp) {
   Vector sched_els = new Vector(0);
   String[] nsns = {FRESH_FRUITS, FRESH_VEGETABLES};
   if (fp != null) {
     RangeRuleParameterEntry[] eRanges = fp.getEnhancementsPolicyRanges();
     ObjectScheduleElement element;
     long start, end;
     // e.g., min = 0 then start is C + 0 or C - Day of the operation
     // e.g., min = 1 then start is C + 1 or 2nd day of the operation
     if (eRanges.length > 0) {
       start =
           parentPlugin.getTimeUtils().addNDays(logOPlan.getStartTime(), eRanges[0].getRangeMin());
       for (int i = 0; i < eRanges.length; i++) {
         end =
             parentPlugin
                 .getTimeUtils()
                 .addNDays(start, (eRanges[i].getRangeMax() - eRanges[i].getRangeMin() + 1));
         element =
             new ObjectScheduleElement(start, end, addEnhancements(new HashMap(), nsns, i, fp));
         sched_els.addElement(element);
         start = end;
       }
     }
   } // else feeding policy is null return empty schedule
   return parentPlugin.getScheduleUtils().newObjectSchedule(sched_els.elements());
 }
 protected Schedule getFeedingPolicySchedule(FeedingPolicy fp) {
   Vector sched_els = new Vector();
   ObjectScheduleElement ose;
   long start, end;
   ObjectScheduleElement element;
   Vector mealsSched = createMealAndSupplementSchedule(fp);
   for (int i = 0; i < mealsSched.size(); i++) {
     ose = (ObjectScheduleElement) mealsSched.elementAt(i);
     // e.g., min = 0 then start is C + 0 or C - Day of the operation
     // e.g., min = 1 then start is C + 1 or 2nd day of the operation
     start =
         parentPlugin.getTimeUtils().addNDays(logOPlan.getStartTime(), (int) ose.getStartTime());
     end =
         parentPlugin
             .getTimeUtils()
             .addNDays(start, ((int) ose.getEndTime() - (int) ose.getStartTime() + 1));
     element = new ObjectScheduleElement(start, end, ose.getObject());
     sched_els.addElement(element);
     start = end;
   }
   return parentPlugin.getScheduleUtils().newObjectSchedule(sched_els.elements());
 }
 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;
 }