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(); }
private static OrderElement getRootOrder(Task task) { OrderElement order = task.getOrderElement(); while (order.getParent() != null) { order = order.getParent(); } return order; }
public ProjectStatusReportDTO(OrderElement orderElement, Order orderToAppendName) { code = orderElement.getCode(); if (orderToAppendName != null) { name = orderElement.getName() + " (" + orderToAppendName.getName() + ")"; } else { name = Util.getPrefixSpacesDependingOnDepth(orderElement) + orderElement.getName(); } Integer estimatedHours = orderElement.getWorkHours(); this.estimatedHours = estimatedHours != null ? EffortDuration.hours(estimatedHours) : null; TaskSource taskSource = orderElement.getTaskSource(); if (taskSource != null) { plannedHours = taskSource.getTask().getSumOfAssignedEffort(); } SumChargedEffort sumChargedEffort = orderElement.getSumChargedEffort(); if (sumChargedEffort != null) { imputedHours = sumChargedEffort.getTotalChargedEffort(); } setBudget(orderElement.getSubstractedBudget()); setExpensesBudget(orderElement.getBudget()); setResourcesBudget(orderElement.getResourcesBudget()); }
@Test @Transactional public void ifAnOrderLineIsScheduledItsTypeChanges() { Order order = givenOrderFromPrepareForCreate(); OrderElement line = OrderLine.createOrderLineWithUnfixedPercentage(20); line.useSchedulingDataFor(order.getCurrentOrderVersion()); line.getSchedulingState().unschedule(); order.add(line); assertFalse(order.getSchedulingState().isSomewhatScheduled()); line.getSchedulingState().schedule(); assertTrue(order.getSchedulingState().isSomewhatScheduled()); }
@Test @Transactional @Ignore("FIXME pending review after rename to libreplan") public void createOrderWithScheduledOrderLine() { Order order = givenOrderFromPrepareForCreate(); OrderElement line = OrderLine.createOrderLineWithUnfixedPercentage(20); order.add(line); line.setName(UUID.randomUUID().toString()); line.setCode(UUID.randomUUID().toString()); assert line.getSchedulingState().isSomewhatScheduled(); orderModel.save(); assertTrue(orderDAO.exists(order.getId())); TaskSource lineTaskSource = line.getTaskSource(); assertTrue(taskSourceDAO.exists(lineTaskSource.getId())); }
private static QueueTask createDivForElement(IDatesMapper datesMapper, LimitingResourceQueueElement queueElement) { final Task task = queueElement.getResourceAllocation().getTask(); final OrderElement order = getRootOrder(task); QueueTask result = new QueueTask(queueElement); String cssClass = "queue-element"; result.setTooltiptext(createTooltiptext(queueElement)); int startPixels = getStartPixels(datesMapper, queueElement); result.setLeft(forCSS(startPixels)); if ( startPixels < 0 ) { cssClass += " truncated-start "; } int taskWidth = getWidthPixels(datesMapper, queueElement); if ( (startPixels + taskWidth) > datesMapper.getHorizontalSize() ) { taskWidth = datesMapper.getHorizontalSize() - startPixels; cssClass += " truncated-end "; } else { result.appendChild(generateNonWorkableShade(datesMapper, queueElement)); } result.setWidth(forCSS(taskWidth)); LocalDate deadlineDate = task.getDeadline(); boolean isOrderDeadline = false; if ( deadlineDate == null ) { Date orderDate = order.getDeadline(); if ( orderDate != null ) { deadlineDate = LocalDate.fromDateFields(orderDate); isOrderDeadline = true; } } if ( deadlineDate != null ) { int deadlinePosition = getDeadlinePixels(datesMapper, deadlineDate); if ( deadlinePosition < datesMapper.getHorizontalSize() ) { Div deadline = new Div(); deadline.setSclass(isOrderDeadline ? "deadline order-deadline" : "deadline"); deadline.setLeft((deadlinePosition - startPixels - DEADLINE_MARK_HALF_WIDTH) + "px"); result.appendChild(deadline); result.appendChild(generateNonWorkableShade(datesMapper, queueElement)); } if ( deadlineDate.isBefore(queueElement.getEndDate()) ) { cssClass += " unmet-deadline "; } } result.setClass(cssClass); result.appendChild(generateCompletionShade(datesMapper, queueElement)); Component progressBar = generateProgressBar(datesMapper, queueElement); if ( progressBar != null ) { result.appendChild(progressBar); } return result; }
private void initialize(OrderElement orderElement) { orderElement.getName(); (orderDAO.loadOrderAvoidingProxyFor(orderElement)).getName(); }