Package org.libreplan.business.orders.entities

Examples of org.libreplan.business.orders.entities.OrderElement


    @Override
    public BigDecimal getTotalUnits() {
        BigDecimal result = BigDecimal.ZERO;

        final OrderElement orderElement = getOrderElement();
        if (orderElement != null) {
            result = result.add(orderElement.getTotalMaterialAssigmentUnits());
        }
        return result;
    }
View Full Code Here


    }

    public BigDecimal getTotalPrice() {
        BigDecimal result = new BigDecimal(0);

        final OrderElement orderElement = getOrderElement();
        if (orderElement != null) {
            result = orderElement.getTotalMaterialAssigmentPrice();
        }
        return result.setScale(2, RoundingMode.HALF_UP);
    }
View Full Code Here

        validateQueueElement(element);
        return createDivForElement(datesMapper, element);
    }

    private static OrderElement getRootOrder(Task task) {
        OrderElement order = task.getOrderElement();
        while (order.getParent() != null) {
            order = order.getParent();
        }
        return order;
    }
View Full Code Here

        return order;
    }

    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()) + " ");
        result.append(_("Task: {0}", task.getName()) + " ");
        result.append(_("Completed: {0}%", element.getAdvancePercentage().multiply(new BigDecimal(100))) + " ");

        final ResourceAllocation<?> resourceAllocation = element.getResourceAllocation();
        if (resourceAllocation instanceof SpecificResourceAllocation) {
View Full Code Here

    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;
            }
        }
View Full Code Here

        }
        resourceDAO.save(resource);
    }

    private void givenOrderElement() {
        OrderElement orderElement = OrderLine.createOrderLineWithUnfixedPercentage(100);
        orderElement.setCode("default-order-element-" + UUID.randomUUID());
        orderElement.setName("default-order-element-" + UUID.randomUUID());
        orderElement.getHoursGroups().get(0)
                .setCode("default-hours-group-" + UUID.randomUUID());
        orderElementDAO.save(orderElement);

        orderElements.add(orderElement);
    }
View Full Code Here

            }
        });
        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                OrderElement orderElement;
                try {
                    orderElement = orderElementDAO.findByCode(orderElements.get(0).getCode());
                    assertThat(moneyCostCalculator.getExpensesMoneyCost(orderElement),
                            equalTo(new BigDecimal(65).setScale(2)));
                } catch (InstanceNotFoundException e) {
View Full Code Here

            }
        });
        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                OrderElement orderElement;
                try {
                    orderElement = orderElementDAO.findByCode(orderElements.get(0).getCode());
                    assertThat(moneyCostCalculator.getExpensesMoneyCost(orderElement),
                            equalTo(new BigDecimal(130).setScale(2)));
View Full Code Here

     * @param name
     *            name for the orderLine to be added or updated
     */
    private OrderLine syncOrderLine(Order order, String code,
            String name) {
        OrderElement orderElement = order.getOrderElement(code);
        if (orderElement != null && !orderElement.isLeaf()) {
            return null;
        }

        OrderLine orderLine = (OrderLine) orderElement;
        if (orderLine == null) {
View Full Code Here

    @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()));
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.orders.entities.OrderElement

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.