Package org.libreplan.business.orders.entities

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


                    .getName());
        }

        Criteria c = getSession().createCriteria(OrderElement.class);
        c.add(Restrictions.eq("externalCode", code.trim()).ignoreCase());
        OrderElement entity = (OrderElement) c.uniqueResult();

        if (entity == null) {
            throw new InstanceNotFoundException(code, getEntityClass()
                    .getName());
        } else {
View Full Code Here


    public OrderElement findRepeatedOrderCodeInDB(OrderElement order) {
        final Map<String, OrderElement> orderElements = createMapByCode(getOrderAndAllChildren(order));
        final Map<String, OrderElement> orderElementsInDB = createMapByCode(getAll());

        for (String code : orderElements.keySet()) {
            OrderElement orderElement = orderElements.get(code);
            OrderElement orderElementInDB = orderElementsInDB.get(code);

            // There's an element in the DB with the same code and it's a
            // different element in a different order
            if (orderElementInDB != null
                    && !orderElementInDB.getId().equals(orderElement.getId())
                    && !orderElementInDB.getOrder().getId()
                            .equals(orderElement.getOrder().getId())) {
                return orderElement;
            }
        }
        return null;
View Full Code Here

    }

    @Override
    public boolean hasImputedExpenseSheet(Long id)
            throws InstanceNotFoundException {
        OrderElement orderElement = find(id);
        return (!expenseSheetLineDAO.findByOrderElement(orderElement).isEmpty());
    }
View Full Code Here

        return (!expenseSheetLineDAO.findByOrderElement(orderElement).isEmpty());
    }

    @Override
    public boolean hasImputedExpenseSheetThisOrAnyOfItsChildren(Long id) throws InstanceNotFoundException {
        OrderElement orderElement = find(id);
        return (!expenseSheetLineDAO.findByOrderElementAndChildren(orderElement).isEmpty());
    }
View Full Code Here

        return existsByCodeInAnotherOrder(orderElement);
    }

    private boolean existsByCodeInAnotherOrder(OrderElement orderElement) {
        try {
            OrderElement found = findUniqueByCode(orderElement.getCode());
            return !areInTheSameOrder(orderElement, found);
        } catch (InstanceNotFoundException e) {
            return false;
        }
    }
View Full Code Here

                } else {

                    String codeOrderElement = PredefinedConnectorProperties.JIRA_CODE_PREFIX
                            + order.getCode() + "-" + issue.getKey();

                    OrderElement orderElement = order.getOrderElement(codeOrderElement);

                    if (orderElement == null) {
                        synchronizationInfo.addFailedReason(_(
                                "Order element \"{0}\" not found", code));
                    } else {
View Full Code Here

     * @param communicationDate
     */
    public void updateCommunicationDate(Date communicationDate) {
        DirectAdvanceAssignment advanceAssignment = (DirectAdvanceAssignment) getAdvanceAssignment();
        if (advanceAssignment.isFake()) {
            OrderElement orderElement = advanceAssignment.getOrderElement();
            Set<DirectAdvanceAssignment> directAdvanceAssignments = orderElement
                    .getAllDirectAdvanceAssignments(advanceAssignment
                            .getAdvanceType());
            for (DirectAdvanceAssignment directAdvanceAssignment : directAdvanceAssignments) {
                for (AdvanceMeasurement advanceMeasurement : directAdvanceAssignment
                        .getAdvanceMeasurements()) {
View Full Code Here

    // FIXME: Needed to fetch order.name in QueueComponent.composeTooltiptext.
    // Try to replace it with a HQL query instead of iterating all the way up
    // through order
    private void initializeRootOrder(Task task) {
        Hibernate.initialize(task.getOrderElement());
        OrderElement order = task.getOrderElement();
        do {
            Hibernate.initialize(order.getParent());
            order = order.getParent();
        } while (order.getParent() != null);
    }
View Full Code Here

    @DELETE
    @Path("/{code}/")
    @Transactional
    public Response removeOrderElement(@PathParam("code") String code) {
        try {
            OrderElement orderElement = orderElementDAO.findByCode(code);
            String errorMessage = checkRemovalValidation(orderElement);
            if (errorMessage != null) {
                return Response.status(Status.FORBIDDEN)
                        .entity(new ErrorDTO(errorMessage)).build();
            }

            if (orderElement.isOrder()) {
                orderModel.remove((Order) orderElement);
            } else {
                Order order = orderDAO.loadOrderAvoidingProxyFor(orderElement);
                orderModel.initEdit(order, null);
                order = orderModel.getOrder();

                orderElement = findOrderElement(order, orderElement.getId());

                OrderLineGroup parent = orderElement.getParent();
                parent.remove(orderElement);
                orderElement.detachFromParent();

                if (!parent.isOrder() && parent.getChildren().isEmpty()) {
                    OrderElement newElement = parent.toLeaf();
                    if (!order.isCodeAutogenerated()) {
                        newElement.setCode(UUID.randomUUID().toString());
                    }
                    parent.getParent().replace(parent, newElement);
                    parent.detachFromParent();
                }
View Full Code Here

    private OrderElement findOrderElement(OrderElement orderElement, Long id) {
        if (orderElement.getId().equals(id)) {
            return orderElement;
        }
        for (OrderElement child : orderElement.getChildren()) {
            OrderElement found = findOrderElement(child, id);
            if (found != null) {
                return found;
            }
        }
        return null;
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.