Package org.libreplan.business.planner.entities

Examples of org.libreplan.business.planner.entities.SpecificResourceAllocation


        return result;
    }

    private void givenSpecificDerivedFrom(Resource resource) {
        derivedFrom = createNiceMock(SpecificResourceAllocation.class);
        SpecificResourceAllocation specific = (SpecificResourceAllocation) derivedFrom;
        expect(specific.getResource()).andReturn(resource).anyTimes();
        replay(derivedFrom);
    }
View Full Code Here


        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) {
            final SpecificResourceAllocation specific = (SpecificResourceAllocation) resourceAllocation;
            result.append(_("Resource: {0}", specific.getResource().getName()) + " ");
        } else if (resourceAllocation instanceof GenericResourceAllocation) {
            final GenericResourceAllocation generic = (GenericResourceAllocation) resourceAllocation;
            result.append(_("Criteria: {0}", Criterion.getCaptionFor(generic.getCriterions())) + " ");
        }
        result.append(_("Allocation: [{0},{1}]", element.getStartDate()
View Full Code Here

        this.creationTimestamp = creationTimestamp;
    }

    public Resource getResource() {
        if (resourceAllocation instanceof SpecificResourceAllocation) {
            final SpecificResourceAllocation specific = (SpecificResourceAllocation) resourceAllocation;
            return specific.getResource();
        }
        return null;
    }
View Full Code Here

        }

        @Override
        public boolean isSatisfiedBy(ResourceAllocation<?> resourceAllocation) {
            if (resourceAllocation instanceof SpecificResourceAllocation) {
                SpecificResourceAllocation s = (SpecificResourceAllocation) resourceAllocation;
                return s.interferesWith(criterion, startInclusive, endExclusive);
            }
            return false;
        }
View Full Code Here

        TaskSourceSynchronization synchronization = TaskSource
                .mustAdd(taskSource);
        synchronization.apply(TaskSource.persistTaskSources(taskSourceDAO));
        Task task = (Task) taskSource.getTask();
        if (ResourceAllocationType.SPECIFIC_RESOURCE_ALLOCATION.equals(type)) {
            SpecificResourceAllocation specificResourceAllocation = SpecificResourceAllocation
                    .createForTesting(ResourcesPerDay.amount(1),
                            task);
            Worker worker = (Worker) createValidWorker();
            resourceDAO.save(worker);
            specificResourceAllocation.setResource(worker);

            return specificResourceAllocation;
        }
        if (ResourceAllocationType.GENERIC_RESOURCE_ALLOCATION.equals(type)) {
            GenericResourceAllocation specificResourceAllocation = GenericResourceAllocation
View Full Code Here

    }

    @Test
    @Transactional
    public void testSaveSpecificResourceAllocation() {
        SpecificResourceAllocation resourceAllocation = createValidSpecificResourceAllocation();
        resourceAllocationDAO.save(resourceAllocation);
        assertTrue(resourceAllocationDAO.exists(resourceAllocation.getId()));
    }
View Full Code Here

    @Test
    @Transactional
    public void testRemoveSpecificResourceAllocation()
            throws InstanceNotFoundException {
        SpecificResourceAllocation resourceAllocation = createValidSpecificResourceAllocation();
        resourceAllocationDAO.save(resourceAllocation);
        resourceAllocationDAO.remove(resourceAllocation.getId());
        assertFalse(resourceAllocationDAO.exists(resourceAllocation.getId()));
    }
View Full Code Here

    @Test
    @Transactional
    public void testListSpecificResourceAllocation() {
        int previous = resourceAllocationDAO.list(ResourceAllocation.class).size();

        SpecificResourceAllocation resourceAllocation1 = createValidSpecificResourceAllocation();
        resourceAllocationDAO.save(resourceAllocation1);
        ResourceAllocation<?> resourceAllocation2 = createValidSpecificResourceAllocation();
        resourceAllocationDAO.save(resourceAllocation1);
        resourceAllocationDAO.save(resourceAllocation2);
View Full Code Here

    public static List<SpecificAllocationRow> toSpecificAllocations(
            Collection<? extends ResourceAllocation<?>> resourceAllocations) {
        List<SpecificAllocationRow> result = new ArrayList<SpecificAllocationRow>();
        for (ResourceAllocation<?> resourceAllocation : resourceAllocations) {
            if (resourceAllocation instanceof SpecificResourceAllocation) {
                SpecificResourceAllocation specific = (SpecificResourceAllocation) resourceAllocation;
                result.add(from(specific));
            }
        }
        return result;
    }
View Full Code Here

        return ResourcesPerDayModification.create(createSpecific(task),
                getResourcesPerDayEditedValue());
    }

    private SpecificResourceAllocation createSpecific(Task task) {
        SpecificResourceAllocation specific = SpecificResourceAllocation
                .create(task);
        specific.setResource(resource);
        SpecificResourceAllocation origin = (SpecificResourceAllocation) getOrigin();
        specific.overrideConsolidatedDayAssignments(origin);
        if (origin != null) {
            specific.setAssignmentFunctionWithoutApply(origin.getAssignmentFunction());
        }
        return specific;
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.planner.entities.SpecificResourceAllocation

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.