Package com.projity.pm.time

Examples of com.projity.pm.time.HasStartAndEnd


   * @see org.apache.commons.collections.Closure#execute(java.lang.Object)
   */
  public void execute(Object object) {
    value += ((DoubleValue)object).getValue();

    HasStartAndEnd interval = (HasStartAndEnd)object;
   
    calculatedValues.set(generator == null ? 0 : generator.getIndex(),
        interval.getStart(),
        interval.getEnd(),
        value,
        null);
  }
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;
   
    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 {
View Full Code Here

  /* (non-Javadoc)
   * @see org.apache.commons.collections.Closure#execute(java.lang.Object)
   */
  public void execute(Object object) {
    HasStartAndEnd interval = (HasStartAndEnd)object;
    System.out.println(new Date(interval.getStart()) + " " + new Date(interval.getEnd()) + " value " +  child);
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.apache.commons.collections.Closure#execute(java.lang.Object)
   */
  public void execute(Object object) {
    HasStartAndEnd interval = (HasStartAndEnd)object;
 
    if (interval.getStart() == triggerDate && interval.getEnd() == triggerDate) {   
      value = constant;
      constant = 0.0; // reset so not called twice
    }
  }
View Full Code Here

  /**
   * Increment the subtotal by adding up all child functors.  If the value is achieved, calculate the
   * instant in the range at which it occurs.
   */
  public void execute(Object object) {
    HasStartAndEnd interval = (HasStartAndEnd) object;
    value = childList.getValue();
    total+= value;
  }
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);
View Full Code Here

    super(assignment,workCalendar, contourBucketIntervalGenerator);
    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

  /**
   * Increment the subtotal by adding up all child functors.  If the value is achieved, calculate the
   * instant in the range at which it occurs.
   */
  public void execute(Object object) {
    HasStartAndEnd interval = (HasStartAndEnd) object;

    double sum = childList.getValue();
    subtotal += sum;
//System.out.println("subtotal is " + DurationFormat.format((long)subtotal) + "interval is " + new java.util.Date(interval.getStart()) + new java.util.Date(interval.getEnd()));  
    if (date == 0 && subtotal >= value) {
      if (value == 0.0) { // take care of degenerate case
        date = interval.getStart();
        return;
      }
      // if just an instant but the instant has costs that put it over the top, return the instant
      if (interval.getStart() == interval.getEnd()) {
        date = interval.getStart();
        return;
      }
         
      double fixedSum = childList.getFixedValue(); // get fixed only
      if (subtotal + fixedSum - sum >= value) { // if the fixed cost alone puts it over
        date = interval.getStart();
        return;
      }

      // figure out the date using a prorated amount of variable cost
      sum -= fixedSum; // remove any fixed sum
      double fractionOfDuration = (sum - (subtotal - value)) / sum;
     
      AssignmentFieldFunctor aNonZeroFunctor = childList.getANonZeroFunctor();
     
      long duration = aNonZeroFunctor.getWorkCalendar().compare(interval.getEnd(),interval.getStart(), false);     
      date = aNonZeroFunctor.getWorkCalendar().add(interval.getStart(),(long) (duration * fractionOfDuration),true);
    }
   
  }
 
View Full Code Here

  }
  private FixedCostFunctor(Assignment assignment) {
    super(assignment,assignment.getEffectiveWorkCalendar(), null);
  }
  public void execute(Object object) {
    HasStartAndEnd interval = (HasStartAndEnd)object;   
    value = assignment.getTask().fixedCost(interval.getStart(),interval.getEnd());
  }
View Full Code Here

    this.costRateGenerator = costRateGenerator;
    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
        // The bucket duration should be multiplied by 1 - overhead.  Code also needs to exist in workFunctor.  maybe others too
        // double overhead = overheadIntervalGenerator.current();
        // bucketDuration *= (1.0 - overhead);
   
        // might as well calculate work too
        regularWork += bucketUnits * bucketDuration;
        overtimeWork += overtimeUnits * bucketDuration;
        work = regularWork + overtimeWork;
       
       
       
        double bucketOvertime = costRate.getOvertimeRate().getValue() * overtimeUnits;
        double bucketRegular = costRate.getStandardRate().getValue() * bucketUnits;
        if (assignment.isTemporal()) { // for work resources or time based material
          bucketRegular *= bucketDuration;
          bucketOvertime *= bucketDuration;
        }
        overtimeValue += bucketOvertime;
        regularValue += bucketRegular;
        value += (bucketOvertime + bucketRegular);
       
        // Below is fixed cost processing.
        double costPerUse = costRate.getCostPerUse();
        if (costPerUse != 0.0D) {
          double fraction = 1.0D; // fraction of fixed cost to use - only relevant if prorated
          if (proratedCost) { // prorated across duration
            long assignmentDuration = assignment.getDuration();
            if (assignmentDuration != 0) {
              fraction =  ((double)bucketDuration) / assignment.getDuration();
            }
          } else { // at a certain date - start or end
            // make sure that the start or end date falls within the interval
            if (interval.getStart() > fixedCostDate || interval.getEnd() < fixedCostDate)
              return; // not in range
          }
          // Notice how the cost per use is multiplied by the assignment units, which itself is the peak units used. 
          double bucketFixed = fraction * costPerUse * assignment.getUnits();
          fixedValue += bucketFixed;
View Full Code Here

TOP

Related Classes of com.projity.pm.time.HasStartAndEnd

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.