Package com.projity.pm.calendar

Examples of com.projity.pm.calendar.WorkCalendar


  }
  /* (non-Javadoc)
   * @see com.projity.pm.scheduling.Schedule#moveInterval(java.lang.Object, long, long, com.projity.pm.scheduling.ScheduleInterval)
   */
  public void moveInterval(Object eventSource, long start, long end, ScheduleInterval oldInterval, boolean isChild) {
    WorkCalendar cal = getEffectiveWorkCalendar();
    start = cal.adjustInsideCalendar(start,false);
    boolean shifting = cal.compare(start,oldInterval.getStart(),false) != 0;
    long assignmentStart = getEarliestAssignmentStart();
    long amountFromStart = cal.compare(oldInterval.getStart(),assignmentStart,false); // possible that they are not the same but there is no working time between them
    if (shifting && amountFromStart == 0L) { // see if first bar shifted -The first bar is drawn from the first assignment and not from the task start.
      // To figure out the new task start, see how much the shift of this bar is, then apply that difference to the task start
      long shift = cal.compare(start,assignmentStart,false);
      long newTaskStart = cal.add(getStart(),shift,false);
      setStart(newTaskStart);
    } else {
      long amount =cal.compare(end,oldInterval.getEnd(),false);
      if (amount == 0L) // skip if nothing moved
        return;

      Iterator i = getAssignments().iterator();
      Assignment assignment;
View Full Code Here


  /** returns the amount of effort that the resource as available to work on the assignment
   *
   * @return
   */
  long getResourceAvailability() {
    WorkCalendar cal = resource.getEffectiveWorkCalendar();
    if (cal == null)
      cal = task.getOwningProject().getEffectiveWorkCalendar();
    //TODO implement time-scaled availability
    return (long) resource.getMaximumUnits() * cal.compare(getFinish(),getStart(),false);
  }
 
View Full Code Here

    setEnd(actualFinish);
    setPercentComplete(1.0D);
  }   
  
  public long getEnd() {
    WorkCalendar cal = getEffectiveWorkCalendar();
    long finish = cal.add(getStart(),getDuration(),true);
    if (getPercentComplete() > 0.0 && getPercentComplete() < 1.0) {
      long dependencyStart = getDependencyStart();
      if (dependencyStart > getTaskStart()) {
        long splitDuration  = cal.compare(dependencyStart,getTaskStart(),false);
        finish = cal.add(finish,splitDuration,true);
      }
    }
    return finish;
  }
View Full Code Here

    if (task==null) return false;
    else return task.isJustModified();
  }
  public void addCalendarTime(long start, long end) {
    if (actualExceptionsCalendar == null) {
      WorkCalendar base = getEffectiveWorkCalendar();
      actualExceptionsCalendar = CalendarService.getInstance().getStandardBasedInstance();
      try {
        actualExceptionsCalendar.setBaseCalendar(base);
      } catch (CircularDependencyException e) {
        // TODO Auto-generated catch block
View Full Code Here

    if (isLabor() && work < 60000) {
      work *= Duration.timeUnitFactor(TimeUnit.HOURS);
      System.out.println("modifying invalid work to make it hours");
    }
    long remainingWork = work - getActualWork(null);
    WorkCalendar cal = getEffectiveWorkCalendar();
    if (!FieldContext.hasInterval(context)) {
      long currentRemainingWork = Duration.millis(getWork(context)) - Duration.millis(getActualWork(context));
      if (currentRemainingWork == 0 && remainingWork == 0)
        adjustRemainingUnits(0, 0, true, false); //TODO is this ok?
      else {
        if (getTaskSchedulingType() == SchedulingType.FIXED_UNITS)
          adjustRemainingDuration(remainingWork, false);
        else if (getTaskSchedulingType() == SchedulingType.FIXED_DURATION && currentRemainingWork > 0)
          adjustRemainingWork( ((double)remainingWork) / currentRemainingWork, true);
//          newDetail().setWorkContour(getWorkContour().adjustUnits((((double)remainingWork) / currentRemainingWork), getActualDuration()));

        else
          newDetail().adjustRemainingDuration(remainingWork); // just set duration

      }
    } else {
      long start = cal.adjustInsideCalendar(context.getStart(),false);
      long end = cal.adjustInsideCalendar(context.getEnd(),true);
      if (end > start)
        setWorkInterval(start, end, work);
      if (getRate().getValue() == 0.0D) {// special case if units was 0
        double rate = ((double)work) / cal.compare(end,start,false); // use rate for the period as the assignment's rate
        this.forceUnits(rate);
      }
    }
  }
View Full Code Here

      }
    }
  }

  private boolean addWorkingTimeIfRequired(long work,FieldContext context, boolean actual) {
    WorkCalendar cal = getEffectiveWorkCalendar();
    // adjust start and end inside the calendar
    long start = cal.adjustInsideCalendar(context.getStart(),false);
    long end = cal.adjustInsideCalendar(context.getEnd(),true);
    if (work != 0 && !verifyBounds(start,end))
      return false;

    // if adding during non calendar time
    if (end <= start && work != 0) {
      start = context.getStart();
      end = context.getEnd();
  //    example 10 day task -  MTWTFSSMTWTF
  //    initial bar:          =====  =====
  //    calendar time add      ====== ====   here I make a saturday working, so the task finishes sooner
  //        shift the saturday     =====  =====  shifting the saturday puts the task back as it was
  //    set the interval       ====== =====  now I set the saturday value

//      System.out.println("before adding" + getWorkContour());
      addCalendarTime(start, end);
      cal = getEffectiveWorkCalendar();
      if (actual && getTask().getActualStart() == 0) {
        long taskStart = cal.adjustInsideCalendar(start, false);
        ((NormalTask)getTask()).setActualStartNoEvent(taskStart);
      }
      long addedDuration = cal.compare(end,start, false);
//      System.out.println("before shift" + getWorkContour());
      shift(start,end, addedDuration); // shift the remaining contour to the right by the duration of the inserted time
//      System.out.println("after shift" + getWorkContour());

      getTask().recalculateLater(this); // task needs to be recalculated
View Full Code Here

    //TODO treat cost values - they are currently ignored
    if (type == ACTUAL_WORK || type == WORK || type == REMAINING_WORK) {
      if (value != 0 && !verifyBounds(start,end))
        return;
      if (Environment.isImporting()) {
        WorkCalendar cal = getEffectiveWorkCalendar();
        start = cal.adjustInsideCalendar(start,false);
        end = cal.adjustInsideCalendar(end,true);
      }

      setWorkInterval(start,end,value);
      if (type == ACTUAL_WORK && end > getStop() && value > 0.0D) // bug fix - actuals were lost
        setStop(end);
View Full Code Here

   * @param value - value of interval (an wmount of work (duration), not units)
   */
  private void setWorkInterval(long start, long end, double value) {
    moveDelayToContour();
    long assignmentStart = getStart(); // the start including any delay
    WorkCalendar cal = getEffectiveWorkCalendar();

    if (end > getFinish()) { //  add end if necessary
      if (value == 0) {
        this.setEnd(start);
        return; // don't extend if value is 0
      }
      makeContourPersonal();
      long extraDuration = cal.compare(end,getFinish(),false);
      setDurationMillis(getDurationMillis() + extraDuration);
      AbstractContour contour = PersonalContour.addEmptyBucket(getWorkContour(), extraDuration,true);
      newDetail().setWorkContour(contour);

      // adjust task end too
      if (end > getTask().getEnd())
        getTask().setEnd(end);
    } else if (start < assignmentStart) { // if before assignment start
//      if (value == 0)
//        return; // don't extend if value is 0
      long taskStart = getTask().getStart();
      if (start < taskStart)  {
        long shiftAmount = cal.compare(taskStart,start, false);
        setDurationMillis(getDurationMillis() + shiftAmount);
        if (!getWorkContour().isPersonal())
          makeContourPersonal();
        newDetail().setWorkContour(PersonalContour.addEmptyBucket(getWorkContour(), shiftAmount,false)); // add empty space before
        getTask().setScheduleConstraintAndUpdate(ConstraintType.SNLT, start); // this can set start before project duration.
        taskStart = getTask().getStart();
      }
      assignmentStart = taskStart;
    }

    long startDuration = cal.compare(start,assignmentStart,false);
    long endDuration = cal.compare(end,assignmentStart,false);
    if (startDuration == endDuration)
      return;

    if (!getWorkContour().isPersonal())
      makeContourPersonal();
View Full Code Here

      newDetail().removeEmptyBucketAtDuration(duration);
  }

  public void shift(long start, long end, long shiftDuration) {
    //get bounds.
    WorkCalendar cal = getEffectiveWorkCalendar();

    if (getTask().inProgress() && cal.compare(getStop(),start,false) > 0) { // if stop greater than start, can't change it
    //  System.out.println("Not shifting - stop = " + new Date(getStop()) + "start " + new Date(start));
      return;
    }
    long taskStart = getTask().getStart();
    start = Math.max(start,getStop()); //only shift remaining
    start = Math.max(start,taskStart); // dont shift before task start of course
    long startOffset = cal.compare(start,taskStart,false);
    long endOffset = cal.compare(end,taskStart,false);

    if (getResume() != 0 && start >= getResume()) {
      long splitDuration = detail.getSplitDuration();
      startOffset -= splitDuration;
      endOffset -= splitDuration;
    }

    if (startOffset >=endOffset) // this prevents moving a completed interval
      return;
    boolean firstBar = (cal.compare(getStart(),start,false) == 0);
    MutableInterval range = getRangeThatIntervalCanBeMoved(start,startOffset,endOffset);
    if (firstBar)
      range.setStart(range.getStart() - calcTotalDelay());
    if (shiftDuration > 0)
      shiftDuration = Math.min(shiftDuration,range.getEnd() - endOffset); // don't allow to shift more than possible
View Full Code Here

  }

  public void extend(long start, long end, long extendDuration) {
    if (end < getStop())
      return;
    WorkCalendar cal = getEffectiveWorkCalendar();
    long startOffset = cal.compare(start,getStart(),false);
    long endOffset = cal.compare(end,getStart(),false);

//    if (start >= getResume()) {
//      long splitDuration = detail.getSplitDuration();
//      startOffset -= splitDuration;
//      endOffset -= splitDuration;
View Full Code Here

TOP

Related Classes of com.projity.pm.calendar.WorkCalendar

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.