private static String createTooltiptext(LimitingResourceQueueElement element) {
        final Task task = element.getResourceAllocation().getTask();
        final OrderElement order = getRootOrder(task);

        StringBuilder result = new StringBuilder();
        result.append(_("Project: {0}", order.getName())).append(" ");
        result.append(_("Task: {0}", task.getName())).append(" ");
        result.append(_("Completed: {0}%", element.getAdvancePercentage().multiply(new BigDecimal(100)))).append(" ");

        final ResourceAllocation<?> resourceAllocation = element.getResourceAllocation();

        if ( resourceAllocation instanceof SpecificResourceAllocation ) {

            final SpecificResourceAllocation specific = (SpecificResourceAllocation) resourceAllocation;
            result.append(_("Resource: {0}", specific.getResource().getName())).append(" ");

        } else if ( resourceAllocation instanceof GenericResourceAllocation ) {

            final GenericResourceAllocation generic = (GenericResourceAllocation) resourceAllocation;

            /* TODO resolve deprecated */
            result.append(_("Criteria: {0}", Criterion.getCaptionFor(generic.getCriterions()))).append(" ");

        }
        result.append(_("Allocation: [{0},{1}]", element.getStartDate().toString(), element.getEndDate()));

        return result.toString();
    }
 public static GenericResourceAllocation create(
     Task task, ResourceEnum resourceType, Collection<? extends Criterion> criterions) {
   Validate.notNull(resourceType);
   GenericResourceAllocation result = new GenericResourceAllocation(task);
   result.criterions = new HashSet<Criterion>(criterions);
   result.resourceType = resourceType;
   result.setResourcesPerDayToAmount(1);
   return create(result);
 }
 public static Map<Set<Criterion>, List<GenericResourceAllocation>> byCriterions(
     Collection<GenericResourceAllocation> genericAllocations) {
   Map<Set<Criterion>, List<GenericResourceAllocation>> result =
       new HashMap<Set<Criterion>, List<GenericResourceAllocation>>();
   for (GenericResourceAllocation genericResourceAllocation : genericAllocations) {
     Set<Criterion> criterions = genericResourceAllocation.getCriterions();
     if (!result.containsKey(criterions)) {
       result.put(criterions, new ArrayList<GenericResourceAllocation>());
     }
     result.get(criterions).add(genericResourceAllocation);
   }
   return result;
 }
    public static GenericAllocationRow from(
            GenericResourceAllocation resourceAllocation,
            IResourcesSearcher searchModel) {
        GenericAllocationRow result = initializeDefault(
                new GenericAllocationRow(resourceAllocation),
                resourceAllocation.getResourceType());

        ResourceType type = resourceAllocation.isLimiting() ?
                ResourceType.LIMITING_RESOURCE :
                ResourceType.NON_LIMITING_RESOURCE;

        result.criterions = resourceAllocation.getCriterions();
        result.resources = new ArrayList<Resource>(searchModel
                .searchBy(resourceAllocation.getResourceType())
                .byCriteria(resourceAllocation.getCriterions())
                .byResourceType(type).execute());
        result.setName(Criterion
                .getCaptionFor(resourceAllocation));
        return result;
    }
 private GenericResourceAllocation createGenericAllocation(Task task) {
     GenericResourceAllocation result = GenericResourceAllocation.create(
             task, resourceType, criterions);
     GenericResourceAllocation origin = (GenericResourceAllocation) getOrigin();
     if (origin != null) {
         result.overrideConsolidatedDayAssignments(origin);
         result.setAssignmentFunctionWithoutApply(origin.getAssignmentFunction());
     }
     return result;
 }
 private void initializeCriteria(GenericResourceAllocation generic) {
     for (Criterion each : generic.getCriterions()) {
         initializeCriterion(each);
     }
 }
Exemple #7
0
 public static String getCaptionFor(
         GenericResourceAllocation allocation) {
     return getCaptionFor(allocation.getResourceType(),
             allocation.getCriterions());
 }
 public void overrideConsolidatedDayAssignments(GenericResourceAllocation origin) {
   if (origin != null) {
     List<GenericDayAssignment> originAssignments = origin.getConsolidatedAssignments();
     resetAssignmentsTo(GenericDayAssignment.copyToAssignmentsWithoutParent(originAssignments));
   }
 }
 @Override
 ResourceAllocation<GenericDayAssignment> createCopy(Scenario scenario) {
   GenericResourceAllocation allocation = create();
   allocation.criterions = new HashSet<Criterion>(criterions);
   return allocation;
 }