Package org.libreplan.business.resources.entities

Examples of org.libreplan.business.resources.entities.Resource


        if (expenseSheetLines.isEmpty()) {
            return true;
        }

        Resource resource = expenseSheetLines.iterator().next().getResource();

        for (ExpenseSheetLine line : expenseSheetLines) {
            Resource resourceLine = line.getResource();
            if ((resourceLine == null)
                    || (!resourceLine.getId().equals(resource.getId()))) {
                return false;
            }
        }

        return true;
View Full Code Here


    public static <T extends DayAssignment> Map<Resource, List<T>> byResource(
            Collection<? extends T> assignments) {
        Map<Resource, List<T>> result = new HashMap<Resource, List<T>>();
        for (T assignment : assignments) {
            Resource resource = assignment.getResource();
            if (!result.containsKey(resource)) {
                result.put(resource, new ArrayList<T>());
            }
            result.get(resource).add(assignment);
        }
View Full Code Here

    @Override
    @Transactional
    protected Resource toEntity(ResourceDTO entityDTO)
        throws ValidationException, RecoverableErrorException {

        Resource resource = ResourceConverter.toEntity(entityDTO);

        // set the generated code to its criterion satisfaction, its resources
        // cost categories assignment and its resource calendar
        generateCodes(resource);
View Full Code Here

    public final static Resource toEntity(ResourceDTO resourceDTO)
        throws ValidationException, RecoverableErrorException {

        checkResourceDTOType(resourceDTO);

        Resource resource;

        if (resourceDTO instanceof MachineDTO) {
            resource = createResourceWithBasicData((MachineDTO) resourceDTO);
        } else {
            resource = createResourceWithBasicData((WorkerDTO) resourceDTO);
View Full Code Here

    }

    @Test
    @Transactional
    public void saveResourceWithCalendar() throws InstanceNotFoundException {
        Resource resource = givenValidWorker();
        ResourceCalendar resourceCalendar = givenValidResourceCalendar();

        resource.setCalendar(resourceCalendar);

        resourceDAO.save(resource);
        resourceDAO.flush();
        sessionFactory.getCurrentSession().evict(resource);

        Resource foundResource = resourceDAO.find(resource.getId());
        assertNotSame(resource, foundResource);
        assertNotNull(foundResource.getCalendar());
        assertThat(foundResource.getCalendar().getId(),
                equalTo(resourceCalendar.getId()));
    }
View Full Code Here

    }

    @Test
    public void theHierarchyOfCriterionsIsConsidered() {
        final Criterion[] parentCriteron = { null };
        Resource worker = transactionService
                .runOnTransaction(new IOnTransaction<Resource>() {
                    @Override
                    public Resource execute() {
                        Worker result = givenValidWorker();
                        CriterionType type = createCriterionType("testType");
                        Criterion parent = createCriterion("parent", type);
                        parentCriteron[0] = parent;
                        Criterion child = createCriterion("child", type);
                        child.setParent(parent);
                        addSatisfactionsOn(result,
                                Interval.from(new LocalDate(1970, 1, 1)), child);
                        return result;
                    }
        });
        final Criterion parent = transactionService
                .runOnReadOnlyTransaction(new IOnTransaction<Criterion>() {

                    @Override
                    public Criterion execute() {
                        return criterionDAO
                                .findExistingEntity(parentCriteron[0].getId());
                    }
                });
        List<Resource> resources = transactionService
                .runOnReadOnlyTransaction(new IOnTransaction<List<Resource>>() {

                    @Override
                    public List<Resource> execute() {
                        return resourcesSearcher.searchBoth()
                                .byCriteria(Collections.singleton(parent))
                                .execute();
                    }
                });
        assertThat(resources.size(), equalTo(1));
        Resource resource = resources.get(0);
        assertThat(resource.getId(), equalTo(worker.getId()));
    }
View Full Code Here

        List<LimitingResourceQueue> result = new ArrayList<LimitingResourceQueue>();
        ResourceEnum resourceType = generic.getResourceType();
        Set<Criterion> criteria = generic.getCriterions();

        for (LimitingResourceQueue each : queues) {
            Resource resource = each.getResource();
            if (resource.getType().equals(resourceType)
                    && resource.satisfiesCriterionsAtSomePoint(criteria)) {
                result.add(each);
            }
        }
        return result;
    }
View Full Code Here

    private void updateOrCreateWorkReportLineAndAddToWorkReport(WorkReport workReport,
            OrderElement orderElement,
            List<WorkLogItemDTO> workLogItems) {

        for (WorkLogItemDTO workLogItem : workLogItems) {
            Resource resource = getWorker(workLogItem.getAuthor().getName());
            if (resource == null) {
                continue;
            }

            WorkReportLine workReportLine;
View Full Code Here

    }

    public static String getResourceOrCriteria(
            ResourceAllocation<?> resourceAllocation) {
        if (resourceAllocation instanceof SpecificResourceAllocation) {
            final Resource resource = ((SpecificResourceAllocation) resourceAllocation)
                    .getResource();
            return (resource != null) ? resource.getName() : "";
        } else if (resourceAllocation instanceof GenericResourceAllocation) {
            GenericResourceAllocation genericAllocation = (GenericResourceAllocation) resourceAllocation;
            return Criterion.getCaptionFor(genericAllocation);
        }
        return StringUtils.EMPTY;
View Full Code Here

            LocalDate date,
            IAssignedEffortForResource assignedEffortForEachResource,
            List<ResourceWithAssignedDuration> resources) {
        List<ResourceWithAssignedDuration> result = new ArrayList<ResourceWithAssignedDuration>();
        for (ResourceWithAssignedDuration each : resources) {
            Resource resource = each.resource;
            ICalendar calendar = generateCalendarFor(resource);
            Capacity capacityWithOvertime = calendar
                    .getCapacityWithOvertime(date);
            if (capacityWithOvertime.isOverAssignableWithoutLimit()) {
                result.add(each);
View Full Code Here

TOP

Related Classes of org.libreplan.business.resources.entities.Resource

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.