Package org.libreplan.business.planner.entities

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


            LimitingResourceQueue queue = getQueueFor(element
                    .getResource());
            Validate.notNull(queue);
            return Collections.singletonList(queue);
        } else if (resourceAllocation instanceof GenericResourceAllocation) {
            final GenericResourceAllocation generic = (GenericResourceAllocation) element
                    .getResourceAllocation();
            return findQueuesMatchingCriteria(generic);
        }
        throw new RuntimeException("unexpected type of: " + resourceAllocation);
    }
View Full Code Here


        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

            ResourceAllocation<?> resourceAllocation) {
        if (resourceAllocation instanceof HibernateProxy) {
            resourceAllocation = (ResourceAllocation<?>) ((HibernateProxy) resourceAllocation)
                    .getHibernateLazyInitializer().getImplementation();
            if (resourceAllocation instanceof GenericResourceAllocation) {
                GenericResourceAllocation generic = (GenericResourceAllocation) resourceAllocation;
                initializeCriteria(generic.getCriterions());
            }
            Hibernate.initialize(resourceAllocation.getAssignments());
            Hibernate.initialize(resourceAllocation.getLimitingResourceQueueElement());
        }
        return resourceAllocation;
View Full Code Here

    private Map<Criterion, List<GenericResourceAllocation>> byCriterion(
            List<Object> results) {

        Map<Criterion, List<GenericResourceAllocation>> result = new HashMap<Criterion, List<GenericResourceAllocation>>();
        for (Object row : results) {
            GenericResourceAllocation allocation = getAllocation(row);
            Criterion criterion = getCriterion(row);
            if (!result.containsKey(criterion)) {
                result.put(criterion,
                        new ArrayList<GenericResourceAllocation>());
            }
View Full Code Here

        replay(derivedFrom);
    }

    private void givenGenericDerivedFrom(Resource... resources) {
        derivedFrom = createNiceMock(GenericResourceAllocation.class);
        GenericResourceAllocation generic = (GenericResourceAllocation) derivedFrom;
        expect(generic.getAssociatedResources()).andReturn(
                Arrays.asList(resources));
        replay(derivedFrom);
    }
View Full Code Here

        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()
                .toString(), element.getEndDate()));

        return result.toString();
View Full Code Here

    public Set<Long> getCriteriaIds() {
        Set<Long> result = new HashSet<Long>();

        if (resourceAllocation instanceof GenericResourceAllocation) {
            GenericResourceAllocation generic = (GenericResourceAllocation) resourceAllocation;
            for (Criterion each: generic.getCriterions()) {
                result.add(each.getId());
            }
        }
        return result;
    }
View Full Code Here

    }

    @Test
    public void theCriterionsAreCopied() {
        givenGenericResourceAllocation();
        GenericResourceAllocation copied = (GenericResourceAllocation) genericResourceAllocation
                .copy(mockScenario());
        assertThat(copied.getCriterions(), equalTo(criterions));
    }
View Full Code Here

        }

        @Override
        public boolean isSatisfiedBy(ResourceAllocation<?> resourceAllocation) {
            if (resourceAllocation instanceof GenericResourceAllocation) {
                GenericResourceAllocation g = (GenericResourceAllocation) resourceAllocation;
                Set<Criterion> allocationCriterions = g.getCriterions();
                return someCriterionIn(allocationCriterions);
            }
            return false;
        }
View Full Code Here

        return result;
    }

    @Override
    public ResourcesPerDayModification toResourcesPerDayModification(Task task) {
        GenericResourceAllocation newGeneric = createGenericAllocation(task);
        return ResourcesPerDayModification
                .create(newGeneric, getResourcesPerDayEditedValue(), this.resources);
    }
View Full Code Here

TOP

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

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.