Examples of TypeOfWorkHours


Examples of org.libreplan.business.costcategories.entities.TypeOfWorkHours

                .findUniqueByName(PredefinedConnectors.JIRA.getName());
        if (connector == null) {
            throw new ConnectorException(_("JIRA connector not found"));
        }

        TypeOfWorkHours typeOfWorkHours;
        String name = connector.getPropertiesAsMap().get(
                PredefinedConnectorProperties.JIRA_HOURS_TYPE);

        if (StringUtils.isBlank(name)) {
            throw new ConnectorException(
View Full Code Here

Examples of org.libreplan.business.costcategories.entities.TypeOfWorkHours

    @Test
    @Transactional
    public void testCanAddHourCost() {
        CostCategory costCategory = createValidCostCategory();
        TypeOfWorkHours type1 = TypeOfWorkHours.create(UUID.randomUUID().toString(),
                UUID.randomUUID().toString());
        type1.setDefaultPrice(BigDecimal.TEN);
        typeOfWorkHoursDAO.save(type1);
        HourCost hourCost1 = HourCost.create(BigDecimal.ONE, new LocalDate(2009, 11,1));
        hourCost1.setType(type1);
        hourCost1.setEndDate(new LocalDate(2009, 11,10));
        costCategory.addHourCost(hourCost1);

        HourCost hourCost2 = HourCost.create(BigDecimal.ONE, new LocalDate(2009, 11,1));
        hourCost2.setType(type1);
        hourCost2.setEndDate(new LocalDate(2009, 11,10));
        assertFalse(costCategory.canAddHourCost(hourCost2));

        hourCost2.setInitDate(new LocalDate(2009,10,15));
        hourCost2.setEndDate(new LocalDate(2009,11,1));
        assertFalse(costCategory.canAddHourCost(hourCost2));

        hourCost2.setInitDate(new LocalDate(2009,11,10));
        hourCost2.setEndDate(new LocalDate(2009,11,10));
        assertFalse(costCategory.canAddHourCost(hourCost2));

        hourCost2.setInitDate(new LocalDate(2009,10,15));
        hourCost2.setEndDate(new LocalDate(2009,10,20));
        assertTrue(costCategory.canAddHourCost(hourCost2));

        TypeOfWorkHours type2 = TypeOfWorkHours.create(UUID.randomUUID().toString(),
                UUID.randomUUID().toString());
        type2.setDefaultPrice(BigDecimal.TEN);
        typeOfWorkHoursDAO.save(type2);
        hourCost2.setType(type2);
        hourCost2.setInitDate(new LocalDate(2009,10,15));
        hourCost2.setEndDate(new LocalDate(2009,11,1));
        assertTrue(costCategory.canAddHourCost(hourCost2));
View Full Code Here

Examples of org.libreplan.business.costcategories.entities.TypeOfWorkHours

    @Test
    @Transactional
    public void testListHourCosts() {
        CostCategory costCategory = createValidCostCategory();
        HourCost hourCost = HourCost.create(BigDecimal.ONE, new LocalDate(2009,11,1));
        TypeOfWorkHours type =
            TypeOfWorkHours.create(UUID.randomUUID().toString(), UUID.randomUUID().toString());
        hourCost.setType(type);
        int previous = costCategory.getHourCosts().size();

        costCategory.addHourCost(hourCost);
View Full Code Here

Examples of org.libreplan.business.costcategories.entities.TypeOfWorkHours

    @Test(expected=ValidationException.class)
    @Transactional
    public void testHourCostsOverlap() {
        CostCategory costCategory = createValidCostCategory();
        TypeOfWorkHours type1 = TypeOfWorkHours.create(UUID.randomUUID().toString(),
                UUID.randomUUID().toString());
        type1.setDefaultPrice(BigDecimal.TEN);
        TypeOfWorkHours type2 = TypeOfWorkHours.create(UUID.randomUUID().toString(),
                UUID.randomUUID().toString());
        type2.setDefaultPrice(BigDecimal.TEN);
        //types have to be saved before using them
        //otherwise, the overlapping validation will fail
        typeOfWorkHoursDAO.save(type1);
        typeOfWorkHoursDAO.save(type2);
View Full Code Here

Examples of org.libreplan.business.costcategories.entities.TypeOfWorkHours

    public BigDecimal calculateBudgetFromCriteriaAndCostCategories() {
        BigDecimal totalBudget = new BigDecimal(0);

        Configuration configuration = Registry.getConfigurationDAO()
                .getConfiguration();
        TypeOfWorkHours typeofWorkHours = configuration
                .getBudgetDefaultTypeOfWorkHours();
        if (!configuration.isEnabledAutomaticBudget()
                || (configuration.getBudgetDefaultTypeOfWorkHours() == null)) {
            return totalBudget;
        }
View Full Code Here

Examples of org.libreplan.business.costcategories.entities.TypeOfWorkHours

    private List<OrderElement> orderElements = new ArrayList<OrderElement>();
    private WorkReportType workReportType;
    private WorkReport workReport;

    private void givenTypeOfWorkHours(BigDecimal defaultPrice) {
        TypeOfWorkHours typeOfWorkHours = TypeOfWorkHours.createUnvalidated(
                "default-type-of-work-hours-" + UUID.randomUUID(),
                "default-type-of-work-hours-" + UUID.randomUUID(), true,
                defaultPrice);
        typeOfWorkHoursDAO.save(typeOfWorkHours);
        typesOfWorkHours.add(typeOfWorkHours);
View Full Code Here

Examples of org.libreplan.business.costcategories.entities.TypeOfWorkHours

        givenTypeOfWorkHours(typeOfWorkHoursCodeB);
    }

    private void givenTypeOfWorkHours(String code) {

        TypeOfWorkHours typeOfWorkHours = TypeOfWorkHours.create();

        typeOfWorkHours.setCode(code);
        typeOfWorkHours.setName("name" + UUID.randomUUID());
        typeOfWorkHours.setDefaultPrice(BigDecimal.TEN);

        typeOfWorkHoursDAO.save(typeOfWorkHours);
        typeOfWorkHoursDAO.flush();
        sessionFactory.getCurrentSession().evict(typeOfWorkHours);
        typeOfWorkHours.dontPoseAsTransientObjectAnymore();
    }
View Full Code Here

Examples of org.libreplan.business.costcategories.entities.TypeOfWorkHours

                assertTrue(typeOfWorkHoursDAO.existsByCode(cc1.code));
                return null;
            }
        });

        final TypeOfWorkHours typeOfWorkHours = transactionService
                .runOnTransaction(new IOnTransaction<TypeOfWorkHours>() {
                    @Override
                    public TypeOfWorkHours execute() {
                        try {
                            return typeOfWorkHoursDAO.findByCode(cc1.code);
                        } catch (InstanceNotFoundException e) {
                            throw new RuntimeException(e);
                        }
                    }
                });

        assertTrue(typeOfWorkHours.getName().equalsIgnoreCase(
                "newTypeOfWorkHours"));
        assertTrue(typeOfWorkHours.getEnabled());
        assertTrue(typeOfWorkHours.getDefaultPrice().compareTo(
                new BigDecimal(5)) == 0);

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

        typeOfWorkHours.dontPoseAsTransientObjectAnymore();

        // Update the previous type of work hours
        TypeOfWorkHoursDTO cc2 = new TypeOfWorkHoursDTO(cc1.code, "updateCC1",
                false, new BigDecimal(100));

        typeOfWorkHoursListDTO = createTypeOfWorkHoursListDTO(cc2);

        instanceConstraintViolationsList = typeOfWorkHoursService
                .addTypeOfWorkHours(typeOfWorkHoursListDTO).instanceConstraintViolationsList;

        /* Test. */
        assertTrue(instanceConstraintViolationsList.toString(),
                instanceConstraintViolationsList.size() == 0);
        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                assertTrue(typeOfWorkHoursDAO.existsByCode(cc1.code));
                return null;
            }
        });

        // Check if the changes was updated
        TypeOfWorkHours typeOfWorkHours2 = transactionService
                .runOnTransaction(new IOnTransaction<TypeOfWorkHours>() {
                    @Override
                    public TypeOfWorkHours execute() {
                        try {
                            return typeOfWorkHoursDAO.findByCode(cc1.code);
                        } catch (InstanceNotFoundException e) {
                            throw new RuntimeException(e);
                        }
                    }
                });
        assertTrue(typeOfWorkHours2.getName().equalsIgnoreCase("updateCC1"));
        assertFalse(typeOfWorkHours2.getEnabled());
        assertTrue(typeOfWorkHours2.getDefaultPrice().compareTo(
                new BigDecimal(100)) == 0);
    }
View Full Code Here

Examples of org.libreplan.business.costcategories.entities.TypeOfWorkHours

            labelTypeDAO.save(labelType_B);
        }
    }

    private void givenTypeOfWorkHoursStored() {
        TypeOfWorkHours typeOfWorkHours = findOrCreate(typeOfWorkHoursDAO,
                TypeOfWorkHours.class, typeOfWorkHoursCode);

        if (typeOfWorkHours.isNewObject()) {
            typeOfWorkHours.setCode(typeOfWorkHoursCode);
            typeOfWorkHours.setName("type-of-work-hours-name-"
                    + UUID.randomUUID());
            typeOfWorkHours.setDefaultPrice(BigDecimal.TEN);

            typeOfWorkHoursDAO.save(typeOfWorkHours);
        }
    }
View Full Code Here

Examples of org.libreplan.business.costcategories.entities.TypeOfWorkHours

    private WorkReportLine createEmptyWorkReportLine(Worker worker) {
        OrderLine leaf = OrderLine.create();
        leaf.setCode(_("All project tasks"));

        TypeOfWorkHours w = TypeOfWorkHours.create();
        w.setDefaultPrice(new BigDecimal(0));

        WorkReportLine wrl = new WorkReportLine();
        wrl.setEffort(EffortDuration.zero());
        wrl.setTypeOfWorkHours(w);
        wrl.setResource(worker);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.