Package org.libreplan.business.orders.entities

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


            public Void execute() {
                Order foundOrder = orderDAO.findExistingEntity(orderLine.getOrder().getId());
                assertNotNull(foundOrder);
                assertThat(foundOrder.getChildren().size(), equalTo(1));

                OrderElement orderElement = foundOrder.getChildren().get(0);
                assertNotNull(orderElement);

                return null;
            }
        });

        Map<LocalDate, BigDecimal> values = givenValidMapValues(1, 0, BigDecimal.ZERO);
        final int previousCommunications = this.getNumSubcontractorCommunications();

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                OrderElementWithAdvanceMeasurementsOrEndDateListDTO orderElementWithAdvanceMeasurementsOrEndDateListDTO = givenOrderWithEndDateListDTO(
                orderElementCode, externalCompany);
                reportAdvancesService
                        .updateAdvancesOrEndDate(orderElementWithAdvanceMeasurementsOrEndDateListDTO);
                return null;
            }
        });

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                OrderElement orderElement;
                try {
                    orderElement = orderElementDAO.findByCode(orderElementCode);

                assertNotNull(orderElement);
                DirectAdvanceAssignment directAdvanceAssignmentSubcontractor = orderElement
                        .getDirectAdvanceAssignmentSubcontractor();
                assertNull(directAdvanceAssignmentSubcontractor);

                int currentCommunications = subcontractorCommunicationDAO.getAll().size();
                assertThat((previousCommunications + 1), equalTo(currentCommunications));

                Task task = (Task) orderElement.getTaskSource().getTask();
                SubcontractedTaskData subcontractedTaskData = task.getSubcontractedTaskData();
                assertNotNull(subcontractedTaskData);
                assertThat(subcontractedTaskData.getEndDatesCommunicatedFromSubcontractor().size(),
                        equalTo(1));
                } catch (InstanceNotFoundException e) {
View Full Code Here


            public Void execute() {
                Order foundOrder = orderDAO.findExistingEntity(orderLine.getOrder().getId());
                assertNotNull(foundOrder);
                assertThat(foundOrder.getChildren().size(), equalTo(1));

                OrderElement orderElement = foundOrder.getChildren().get(0);
                assertNotNull(orderElement);
                return null;
            }
        });

        final int previousCommunications = getNumSubcontractorCommunications();
        final Map<LocalDate, BigDecimal> values = givenValidMapValues(1, 0, BigDecimal.ZERO);
        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                OrderElementWithAdvanceMeasurementsOrEndDateListDTO orderElementWithAdvanceMeasurementsListDTO = givenOrderElementWithAdvanceMeasurementsAndEndDateListDTO(
                        orderElementCode, values, externalCompany);
                reportAdvancesService
                        .updateAdvancesOrEndDate(orderElementWithAdvanceMeasurementsListDTO);
                return null;
            }
        });

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                try {
                    OrderElement orderElement = orderElementDAO.findByCode(orderElementCode);
                    assertNotNull(orderElement);
                    DirectAdvanceAssignment directAdvanceAssignmentSubcontractor = orderElement
                            .getDirectAdvanceAssignmentSubcontractor();
                    assertNotNull(directAdvanceAssignmentSubcontractor);
                    assertTrue(directAdvanceAssignmentSubcontractor.getReportGlobalAdvance());
                    assertThat(
                            directAdvanceAssignmentSubcontractor.getAdvanceMeasurements().size(),
                            equalTo(1));

                    for (Entry<LocalDate, BigDecimal> entry : values.entrySet()) {
                        AdvanceMeasurement advanceMeasurement = directAdvanceAssignmentSubcontractor
                                .getAdvanceMeasurements().first();
                        assertThat(advanceMeasurement.getDate(), equalTo(entry.getKey()));
                        assertThat(advanceMeasurement.getValue(), equalTo(entry.getValue()));
                    }

                    int currentCommunications = subcontractorCommunicationDAO.getAll().size();
                    assertThat((previousCommunications + 2), equalTo(currentCommunications));

                    Task task = (Task) orderElement.getTaskSource().getTask();
                    SubcontractedTaskData subcontractedTaskData = task.getSubcontractedTaskData();
                    assertNotNull(subcontractedTaskData);
                    assertThat(subcontractedTaskData.getEndDatesCommunicatedFromSubcontractor()
                            .size(), equalTo(1));
                } catch (InstanceNotFoundException e) {
View Full Code Here

            public Void execute() {
                Order foundOrder = orderDAO.findExistingEntity(idOrder);
                assertNotNull(foundOrder);
                assertThat(foundOrder.getChildren().size(), equalTo(1));

                OrderElement orderElement = foundOrder.getChildren().get(0);
                assertNotNull(orderElement);

                DirectAdvanceAssignment directAdvanceAssignmentSubcontractor = orderElement
                        .getDirectAdvanceAssignmentSubcontractor();
                assertNotNull(directAdvanceAssignmentSubcontractor);
                assertTrue(directAdvanceAssignmentSubcontractor.getReportGlobalAdvance());
                assertThat(directAdvanceAssignmentSubcontractor.getAdvanceMeasurements().size(),
                        equalTo(numMeasures));
View Full Code Here

                } catch (InstanceNotFoundException e) {
                    assertTrue(true);
                }

                try {
                    OrderElement order = orderElementDAO.findByCode(code);
                    assertTrue(order.getChildren().isEmpty());
                } catch (InstanceNotFoundException e) {
                    fail();
                }
                return null;
            }
View Full Code Here

        OrderListDTO orderListDTO = createOrderListDTO(orderDTO);
        List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList = orderElementService
                .addOrders(orderListDTO).instanceConstraintViolationsList;
        assertThat(instanceConstraintViolationsList.size(), equalTo(0));

        final OrderElement orderElement = transactionService
                .runOnTransaction(new IOnTransaction<OrderElement>() {
                    @Override
                    public OrderElement execute() {
                        try {
                            OrderElement element = orderElementDAO
                                    .findUniqueByCode(code);
                            element.getLabels().size();
                            return element;
                        } catch (InstanceNotFoundException e) {
                            throw new RuntimeException(e);
                        }
                    }
                });

        assertNotNull(orderElement);
        assertThat(orderElement.getLabels().size(), equalTo(1));

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                orderElementDAO.flush();
                sessionFactory.getCurrentSession().evict(orderElement);
                return null;
            }
        });

        LabelReferenceDTO labelReferenceDTO2 = new LabelReferenceDTO(labelCode);
        orderDTO.labels.add(labelReferenceDTO2);

        orderListDTO = createOrderListDTO(orderDTO);
        instanceConstraintViolationsList = orderElementService
                .addOrders(orderListDTO).instanceConstraintViolationsList;

        assertThat(instanceConstraintViolationsList.size(), equalTo(0));

        OrderElement orderElement2 = transactionService
                .runOnTransaction(new IOnTransaction<OrderElement>() {
                    @Override
                    public OrderElement execute() {
                        try {
                            OrderElement element = orderElementDAO
                                    .findUniqueByCode(code);
                            element.getLabels().size();
                            return element;
                        } catch (InstanceNotFoundException e) {
                            throw new RuntimeException(e);
                        }
                    }
View Full Code Here

        OrderListDTO orderListDTO = createOrderListDTO(orderDTO);
        List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList = orderElementService
                .addOrders(orderListDTO).instanceConstraintViolationsList;
        assertThat(instanceConstraintViolationsList.size(), equalTo(0));

        final OrderElement orderElement = transactionService
                .runOnTransaction(new IOnTransaction<OrderElement>() {
                    @Override
                    public OrderElement execute() {
                        try {
                            OrderElement element = orderElementDAO
                                    .findUniqueByCode(code);
                            element.getMaterialAssignments().size();
                            return element;
                        } catch (InstanceNotFoundException e) {
                            throw new RuntimeException(e);
                        }
                    }
                });

        assertNotNull(orderElement);
        assertThat(orderElement.getMaterialAssignments().size(), equalTo(1));

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                orderElementDAO.flush();
                sessionFactory.getCurrentSession().evict(orderElement);
                return null;
            }
        });

        orderDTO.materialAssignments.iterator().next().units = BigDecimal
                .valueOf(150.0);

        MaterialAssignmentDTO materialAssignmentDTO2 = new MaterialAssignmentDTO(
                materialcode2, BigDecimal.valueOf(200.0), BigDecimal.ONE, null);
        orderDTO.materialAssignments.add(materialAssignmentDTO);
        orderDTO.materialAssignments.add(materialAssignmentDTO2);

        orderListDTO = createOrderListDTO(orderDTO);
        instanceConstraintViolationsList = orderElementService
                .addOrders(orderListDTO).instanceConstraintViolationsList;
        assertThat(instanceConstraintViolationsList.size(), equalTo(0));

        OrderElement orderElement2 = transactionService
                .runOnTransaction(new IOnTransaction<OrderElement>() {
                    @Override
                    public OrderElement execute() {
                        try {
                            OrderElement element = orderElementDAO
                                    .findUniqueByCode(code);
                            for (MaterialAssignment materialAssignment : element
                                    .getMaterialAssignments()) {
                                materialAssignment.getMaterial().getCode();
                            }
                            return element;
                        } catch (InstanceNotFoundException e) {
View Full Code Here

        List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList = orderElementService
                .addOrders(orderListDTO).instanceConstraintViolationsList;
        assertTrue(instanceConstraintViolationsList.toString(),
                instanceConstraintViolationsList.size() == 0);

        final OrderElement orderElement = transactionService
                .runOnTransaction(new IOnTransaction<OrderElement>() {
                    @Override
                    public OrderElement execute() {
                        try {
                            return orderElementDAO.findUniqueByCode(code);
                        } catch (InstanceNotFoundException e) {
                            throw new RuntimeException(e);
                        }
                    }
                });
        assertNotNull(orderElement);

        final OrderLine orderLine = transactionService
                .runOnTransaction(new IOnTransaction<OrderLine>() {
                    @Override
                    public OrderLine execute() {
                        try {
                            OrderLine line = (OrderLine) orderElementDAO
                                    .findUniqueByCode(orderLineCode);
                            line.getHoursGroups().size();
                            return line;
                        } catch (InstanceNotFoundException e) {
                            throw new RuntimeException(e);
                        }
                    }
                });
        assertNotNull(orderLine);
        assertThat(orderLine.getHoursGroups().size(), equalTo(1));

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                orderElementDAO.flush();
                sessionFactory.getCurrentSession().evict(orderElement);
                sessionFactory.getCurrentSession().evict(orderLine);
                return null;
            }
        });

        orderLineDTO.hoursGroups.iterator().next().workingHours = 1500;
        HoursGroupDTO hoursGroupDTO2 = new HoursGroupDTO("hours-groupXX",
                ResourceEnumDTO.WORKER, 2000,
                new HashSet<CriterionRequirementDTO>());
        orderLineDTO.hoursGroups.add(hoursGroupDTO2);

        orderListDTO = createOrderListDTO(orderDTO);
        instanceConstraintViolationsList = orderElementService
                .addOrders(orderListDTO).instanceConstraintViolationsList;
        assertThat(instanceConstraintViolationsList.size(), equalTo(0));

        final OrderElement orderElement2 = transactionService
                .runOnTransaction(new IOnTransaction<OrderElement>() {
                    @Override
                    public OrderElement execute() {
                        try {
                            return orderElementDAO.findUniqueByCode(code);
View Full Code Here

        OrderListDTO orderListDTO = createOrderListDTO(orderDTO);
        List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList = orderElementService
                .addOrders(orderListDTO).instanceConstraintViolationsList;
        assertThat(instanceConstraintViolationsList.size(), equalTo(0));

        OrderElement orderElement = transactionService
                .runOnTransaction(new IOnTransaction<OrderElement>() {
                    @Override
                    public OrderElement execute() {
                        try {
                            OrderElement element = orderElementDAO
                                    .findUniqueByCode(code);
                            element.getDirectAdvanceAssignmentSubcontractor()
                                    .getAdvanceMeasurements().size();
                            return element;
                        } catch (InstanceNotFoundException e) {
                            throw new RuntimeException(e);
                        }
View Full Code Here

    private Map<OrderElement, List<OrderCostsPerResourceDTO>> groupWorkReportLinesByOrderElment(
            List<OrderCostsPerResourceDTO> workingHoursPerWorkerList) {
        Map<OrderElement, List<OrderCostsPerResourceDTO>> mapWRL = new HashMap<OrderElement, List<OrderCostsPerResourceDTO>>();
        for (OrderCostsPerResourceDTO dto : workingHoursPerWorkerList) {
            OrderElement orderElement = dto.getOrderElement();
            if (mapWRL.get(orderElement) == null) {
                mapWRL.put(orderElement, new ArrayList<OrderCostsPerResourceDTO>());
            }
            mapWRL.get(orderElement).add(dto);
        }
View Full Code Here

    private Map<OrderElement, List<CostExpenseSheetDTO>> groupExpensesByOrderElment(
            List<CostExpenseSheetDTO> costExpenseSheetList) {
        Map<OrderElement, List<CostExpenseSheetDTO>> mapES = new HashMap<OrderElement, List<CostExpenseSheetDTO>>();
        for (CostExpenseSheetDTO dto : costExpenseSheetList) {
            OrderElement orderElement = dto.getOrderElement();
            if (mapES.get(orderElement) == null) {
                mapES.put(orderElement, new ArrayList<CostExpenseSheetDTO>());
            }
            mapES.get(orderElement).add(dto);
        }
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.