Package net.sf.mpxj

Examples of net.sf.mpxj.Duration


            Task task = m_projectFile.getTaskByUniqueID(taskID);
            Resource resource = m_projectFile.getResourceByUniqueID(resourceID);

            if (task != null && resource != null)
            {
               Duration work = task.getWork();
               int percentComplete = NumberUtility.getInt(task.getPercentageComplete());

               ResourceAssignment assignment = task.addResourceAssignment(resource);
               assignment.setUnits(units);
               assignment.setWork(work);

               if (percentComplete != 0)
               {
                  Duration actualWork = Duration.getInstance((work.getDuration() * percentComplete) / 100, work.getUnits());
                  assignment.setActualWork(actualWork);
                  assignment.setRemainingWork(Duration.getInstance(work.getDuration() - actualWork.getDuration(), work.getUnits()));
               }
               else
               {
                  assignment.setRemainingWork(work);
               }

               assignment.setStart(task.getStart());
               assignment.setFinish(task.getFinish());

               tasksWithAssignments.add(task);

               m_projectFile.fireAssignmentReadEvent(assignment);
            }
         }

         //
         // Adjust work per assignment for tasks with multiple assignments
         //
         for (Task task : tasksWithAssignments)
         {
            List<ResourceAssignment> assignments = task.getResourceAssignments();
            if (assignments.size() > 1)
            {
               double maxUnits = 0;
               for (ResourceAssignment assignment : assignments)
               {
                  maxUnits += assignment.getUnits().doubleValue();
               }

               for (ResourceAssignment assignment : assignments)
               {
                  Duration work = assignment.getWork();
                  double factor = assignment.getUnits().doubleValue() / maxUnits;

                  work = Duration.getInstance(work.getDuration() * factor, work.getUnits());
                  assignment.setWork(work);
                  Duration actualWork = assignment.getActualWork();
                  if (actualWork != null)
                  {
                     actualWork = Duration.getInstance(actualWork.getDuration() * factor, actualWork.getUnits());
                     assignment.setActualWork(actualWork);
                  }

                  Duration remainingWork = assignment.getRemainingWork();
                  if (remainingWork != null)
                  {
                     remainingWork = Duration.getInstance(remainingWork.getDuration() * factor, remainingWork.getUnits());
                     assignment.setRemainingWork(remainingWork);
                  }
               }
            }
         }
View Full Code Here


    * @param value string representation of a duration
    * @return Duration instance
    */
   private Duration getDuration(String value)
   {
      Duration result = null;

      if (value != null && value.length() != 0)
      {
         double seconds = getLong(value);
         double hours = seconds / (60 * 60);
 
View Full Code Here

   private String formatDuration(Object value)
   {
      String result = null;
      if (value instanceof Duration)
      {
         Duration duration = (Duration) value;
         result = m_formats.getDurationDecimalFormat().format(duration.getDuration()) + formatTimeUnit(duration.getUnits());
      }
      return result;
   }
View Full Code Here

      if (relation != null)
      {
         StringBuffer sb = new StringBuffer(relation.getTargetTask().getID().toString());

         Duration duration = relation.getLag();
         RelationType type = relation.getType();
         double durationValue = duration.getDuration();

         if ((durationValue != 0) || (type != RelationType.FINISH_START))
         {
            String[] typeNames = LocaleData.getStringArray(m_locale, LocaleData.RELATION_TYPES);
            sb.append(typeNames[type.getValue()]);
View Full Code Here

    * @return the value of the required field
    * @throws MPXJException normally thrown when parsing fails
    */
   public Duration getDuration(int field) throws MPXJException
   {
      Duration result;

      if ((field < m_fields.length) && (m_fields[field].length() != 0))
      {
         result = DurationUtility.getInstance(m_fields[field], m_formats.getDurationDecimalFormat(), m_locale);
      }
View Full Code Here

TOP

Related Classes of net.sf.mpxj.Duration

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.