Package com.projity.pm.assignment.contour

Examples of com.projity.pm.assignment.contour.AbstractContourBucket


    if (interval.getStart() == 0) // ignore degenerate range
      return;
    if (interval.getStart() == interval.getEnd())
      return;

    AbstractContourBucket bucket = null;
    long intervalDuration = 0;
//    System.out.println("--interval " + new java.util.Date(interval.getStart()) + " - " + new java.util.Date(interval.getEnd()));

    // if beginning a replacement interval
    if (replacementGenerator.isCurrentActive() && replacementGenerator.currentStart() == interval.getStart()) {
      intervalDuration = workCalendar.compare(replacementGenerator.getEnd(),replacementGenerator.getStart(), false); // get duration of new region
     
      // if inserting during a non-working time, need to adjust assignment calendar
      if (intervalDuration == 0) {
        assignment.addCalendarTime(interval.getStart(),interval.getEnd());
      }

      //need to shift start to make room for new ones
      if (interval.getStart() < assignment.getStart()) {
        assignment.setStart(interval.getStart());
      }
     
      IntervalValue replacementIntervalValue = (IntervalValue)replacementGenerator.current();
      bucket = PersonalContourBucket.getInstance(intervalDuration,replacementIntervalValue.getValue()); // make a new bucket
      activeDate = replacementGenerator.currentEnd(); // ignore everything in the future until active date
 
    } else if (interval.getStart() >= activeDate) { // use contour bucket
      intervalDuration = workCalendar.compare(interval.getEnd(),interval.getStart(), false);
      if (intervalDuration == 0) // don't treat degenerate cased
        return;
      if (contourBucketIntervalGenerator.current() == null) { // if not active, then insert dead time
        bucket =PersonalContourBucket.getInstance(intervalDuration,0); // make a new non-workingbucket
      } else {
        bucket = (AbstractContourBucket) contourBucketIntervalGenerator.current();
        if (intervalDuration != bucket.getBucketDuration(assignmentWork)) // try to use existing bucket
          bucket = PersonalContourBucket.getInstance(intervalDuration,bucket.getUnits()); // make a new bucket
       
      }
    }
    if (bucket == null) // if no bucket, then do nothing
      return;

    // merge with previous if units are identical
    if (previous != null && previous.getUnits() == bucket.getUnits()) {
      collection.remove(previous);
      bucket = PersonalContourBucket.getInstance(bucket.getBucketDuration(assignmentWork) + previous.getBucketDuration(assignmentWork),previous.getUnits());
    }

    collection.add(bucket);
    previous = bucket; // for merge
  }
View Full Code Here


   * Calculate regular work, overtime work, and add them to get total work
   * @param object The SelectFrom from the algorithm
   */ 
  public void execute(Object object) {
    HasStartAndEnd interval = (HasStartAndEnd)object;
    AbstractContourBucket bucket = (AbstractContourBucket) contourBucketIntervalGenerator.current();
    if (bucket != null && bucket.getUnits() != 0) { // neither regular or overtime if contour has 0 units
      double bucketDuration = workCalendar.compare(interval.getEnd(),interval.getStart(), false);
     
      //When we handle overhead, we need to have another interval generator which keeps overhead in sorted order
      // The bucket duration should be multiplied by 1 - overhead.  Code also needs to exist in costFunctor.  maybe others too
      // double overhead = overheadIntervalGenerator.current();
      // bucketDuration *= (1.0 - overhead);
      if (assignmentDuration != 0) {
        bucketDuration /= assignmentDuration; // for unitless
      }

      regularValue += bucket.getEffectiveUnits(assignment.getUnits()) * bucketDuration;
      overtimeValue += overtimeUnits * bucketDuration;
      value = regularValue + overtimeValue;
//      System.out.println("interval " + new java.util.Date(interval.getStart()) + " " + new java.util.Date(interval.getEnd()) +  " bucket " + com.projity.datatype.DurationFormat.format((long) bucketDuration) + " units " + bucket.getEffectiveUnits(assignment.getUnits()) + " perso " + (bucket instanceof PersonalContourBucket));
    }
  }
View Full Code Here

    if (threshold)
      maximumUnits = assignment.getResource().getMaximumUnits();
  }
  public void execute(Object object) {
    HasStartAndEnd interval = (HasStartAndEnd)object;
    AbstractContourBucket bucket = (AbstractContourBucket) contourBucketIntervalGenerator.current();
    if (bucket != null) {   
      long bitOfWork = workCalendar.compare(interval.getEnd(),interval.getStart(), false);
      work += bitOfWork;
      value += bucket.getEffectiveUnits(assignment.getUnits()) * bitOfWork;
    }
  }
 
View Full Code Here

    this.fixedCostDate = fixedCostDate;
    this.proratedCost = proratedCost;
  }
  public void execute(Object object) {
    HasStartAndEnd interval = (HasStartAndEnd)object;   
    AbstractContourBucket bucket = (AbstractContourBucket) contourBucketIntervalGenerator.current();
   
   
    if (bucket != null) {
      CostRate costRate = (CostRate)costRateGenerator.current();
      double bucketUnits = bucket.getEffectiveUnits(assignment.getUnits());
      if (bucketUnits != 0.0) { // there are never values if there is no normal cost.
        // calculate regular and overtime
        long bucketDuration = workCalendar.compare(interval.getEnd(),interval.getStart(), false);

        //When we handle overhead, we need to have another interval generator which keeps overhead in sorted order
View Full Code Here

  /* (non-Javadoc)
   * @see org.apache.commons.collections.Closure#execute(java.lang.Object)
   */
  public void execute(Object arg0) {
    Query query = (Query)arg0;
    AbstractContourBucket fromBucket = (AbstractContourBucket) query.currentGroupByObject();
    costContour[index++] = PersonalContourBucket.getInstance(fromBucket.getBucketDuration(assignmentDuration),cost.getValue());
  }
View Full Code Here

   * Add buckets to the collection.  The new interval has priority over the existing contour.  Buckets
   * are re-used if they are identical.
   */
  public void execute(Object object) {
    HasStartAndEnd interval = (HasStartAndEnd)object;
    AbstractContourBucket bucket = (AbstractContourBucket) contourBucketIntervalGenerator.current();
    if (bucket == null)
      return;
    if (bucket instanceof PersonalContourBucket)
      list.add(bucket);
    else
      list.add(PersonalContourBucket.getInstance(bucket.getBucketDuration(assignmentDuration),bucket.getUnits() * multiplier));
  }
 
View Full Code Here

  }
  private PeakUnitsFunctor(Assignment assignment, WorkCalendar workCalendar, ContourBucketIntervalGenerator contourBucketIntervalGenerator) {
    super(assignment,workCalendar, contourBucketIntervalGenerator);
  }
  public void execute(Object object) {
    AbstractContourBucket bucket = (AbstractContourBucket) contourBucketIntervalGenerator.current();
    if (bucket != null) {
      value = Math.max(value,bucket.getEffectiveUnits(assignment.getUnits()));
    }
  }
View Full Code Here

TOP

Related Classes of com.projity.pm.assignment.contour.AbstractContourBucket

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.