Package org.drools.planner.core.domain.entity

Examples of org.drools.planner.core.domain.entity.PlanningEntityDescriptor


    }

    private Object findTrailingEntity(Object planningEntity) {
        Object trailingEntity = null;
        PlanningEntityDescriptor entityDescriptor = planningVariableDescriptor.getPlanningEntityDescriptor();
        for (Object suspectedTrailingEntity : entityDescriptor.extractEntities(scoreDirector.getWorkingSolution())) {
            if (planningVariableDescriptor.getValue(suspectedTrailingEntity) == planningEntity) {
                if (trailingEntity != null) {
                    throw new IllegalStateException("The planningEntity (" + planningEntity
                            + ") has multiple trailing entities (" + trailingEntity + ") ("
                            + suspectedTrailingEntity + ") pointing to it for chained planningVariable ("
View Full Code Here


    public void phaseStarted(BruteForceSolverPhaseScope bruteForceSolverPhaseScope) {
        List<Object> workingPlanningEntityList = bruteForceSolverPhaseScope.getWorkingPlanningEntityList();
        planningVariableWalkerList = new ArrayList<PlanningVariableWalker>(workingPlanningEntityList.size());
        for (Object planningEntity : workingPlanningEntityList) {
            PlanningEntityDescriptor planningEntityDescriptor = solutionDescriptor.getPlanningEntityDescriptor(
                    planningEntity.getClass());
            PlanningVariableWalker planningVariableWalker = new PlanningVariableWalker(planningEntityDescriptor);
            List<PlanningValueWalker> planningValueWalkerList = buildPlanningValueWalkerList(planningEntityDescriptor);
            planningVariableWalker.setPlanningValueWalkerList(planningValueWalkerList);
            planningVariableWalkerList.add(planningVariableWalker);
View Full Code Here

            return values;
        }
        Collection<Object> filteredValues = new ArrayList<Object>(values.size());
        for (Object value : values) {
            if (value.getClass().isAnnotationPresent(PlanningEntity.class)) {
                PlanningEntityDescriptor entityDescriptor = variableDescriptor.getPlanningEntityDescriptor()
                        .getSolutionDescriptor().getPlanningEntityDescriptor(value.getClass());
                if (entityDescriptor == null) {
                    throw new IllegalArgumentException("The planningEntityClass ("
                            + variableDescriptor.getPlanningEntityDescriptor().getPlanningEntityClass()
                            + ") has a PlanningVariable annotated property ("
                            + variableDescriptor.getVariableName()
                            + ") with excludeUninitializedPlanningEntity (true),"
                            + " but a planning value class (" + value.getClass()
                            + ") annotated with PlanningEntity is a non configured as a planning entity.");
                }
                if (entityDescriptor.isInitialized(value)) {
                    filteredValues.add(value);
                }
            }
        }
        return filteredValues;
View Full Code Here

        }
        masterPlanningVariableDescriptor.addDependentPlanningVariableDescriptor(this);
        String mappedByPropertyName = dependentPlanningVariableAnnotation.mappedBy();
        if (!mappedByPropertyName.equals("")) {
            Class<?> oppositeClass = variablePropertyDescriptor.getPropertyType();
            PlanningEntityDescriptor oppositePlanningEntityDescriptor
                    = planningEntityDescriptor.getSolutionDescriptor().getPlanningEntityDescriptor(oppositeClass);
            if (oppositePlanningEntityDescriptor == null) {
                throw new IllegalStateException("The planningEntityClass ("
                        + planningEntityDescriptor.getPlanningEntityClass()
                        + ") has a DependentPlanningVariable annotated property (" + variablePropertyDescriptor.getName()
                        + ") that refers to a mappedByPropertyName (" + mappedByPropertyName
                        + ") on the oppositeClass (" + oppositeClass
                        + ") that is not a PlanningEntity.");
            }
            PlanningVariableDescriptor mappedByPlanningVariableDescriptor
                    = oppositePlanningEntityDescriptor.getPlanningVariableDescriptor(mappedByPropertyName);
            if (mappedByPlanningVariableDescriptor == null) {
                throw new IllegalStateException("The planningEntityClass ("
                        + planningEntityDescriptor.getPlanningEntityClass()
                        + ") has a DependentPlanningVariable annotated property (" + variablePropertyDescriptor.getName()
                        + ") that refers to a mappedByPropertyName (" + mappedByPropertyName
View Full Code Here

            // TODO Multiple MUST BE SUPPORTED TOO
            throw new UnsupportedOperationException("Currently the greedyFit implementation only supports " +
                    "1 planningEntityImplementationClass.");
        }
        Class<?> planningEntityImplementationClass = planningEntityImplementationClassSet.iterator().next();
        PlanningEntityDescriptor planningEntityDescriptor = solutionDescriptor.getPlanningEntityDescriptor(planningEntityImplementationClass);
        PlanningVariableWalker planningVariableWalker = new PlanningVariableWalker(planningEntityDescriptor);
        List<PlanningValueWalker> planningValueWalkerList = new ArrayList<PlanningValueWalker>();
        for (PlanningVariableDescriptor planningVariableDescriptor
                : planningEntityDescriptor.getPlanningVariableDescriptors()) {
            PlanningValueSelector planningValueSelector = new PlanningValueSelector(planningVariableDescriptor);
            planningValueSelector.setSelectionOrder(determinePlanningValueSelectionOrder());
            PlanningValueWalker planningValueWalker = new PlanningValueWalker(
                    planningVariableDescriptor, planningValueSelector);
            planningValueWalkerList.add(planningValueWalker);
View Full Code Here

    // ************************************************************************
    // Builder methods
    // ************************************************************************

    public PlanningEntitySelector buildPlanningEntitySelector(SolutionDescriptor solutionDescriptor) {
        PlanningEntityDescriptor planningEntityDescriptor;
        Class<?> resolvedEntityClass;
        if (planningEntityClass != null) {
            resolvedEntityClass = planningEntityClass;
        } else {
            Set<Class<?>> planningEntityImplementationClassSet
View Full Code Here

    public Collection<PlanningEntityDescriptor> getPlanningEntityDescriptors() {
        return planningEntityDescriptorMap.values();
    }

    public boolean hasPlanningEntityDescriptor(Class<?> planningEntityImplementationClass) {
        PlanningEntityDescriptor planningEntityDescriptor = null;
        Class<?> planningEntityClass = planningEntityImplementationClass;
        while (planningEntityClass != null) {
            planningEntityDescriptor = planningEntityDescriptorMap.get(planningEntityClass);
            if (planningEntityDescriptor != null) {
                return true;
View Full Code Here

        }
        return false;
    }

    public PlanningEntityDescriptor getPlanningEntityDescriptor(Class<?> planningEntityImplementationClass) {
        PlanningEntityDescriptor planningEntityDescriptor = null;
        Class<?> planningEntityClass = planningEntityImplementationClass;
        while (planningEntityClass != null) {
            planningEntityDescriptor = planningEntityDescriptorMap.get(planningEntityClass);
            if (planningEntityDescriptor != null) {
                return planningEntityDescriptor;
View Full Code Here

        Collection<Object> facts = new ArrayList<Object>();
        facts.addAll(solution.getProblemFacts());
        for (PropertyDescriptor entityPropertyDescriptor : entityPropertyDescriptorMap.values()) {
            Object entity = extractPlanningEntity(entityPropertyDescriptor, solution);
            if (entity != null) {
                PlanningEntityDescriptor planningEntityDescriptor = getPlanningEntityDescriptor(entity.getClass());
                if (planningEntityDescriptor.isInitialized(entity)) {
                    facts.add(entity);
                }
            }
        }
        for (PropertyDescriptor entityCollectionPropertyDescriptor : entityCollectionPropertyDescriptorMap.values()) {
            Collection<?> entityCollection = extractPlanningEntityCollection(
                    entityCollectionPropertyDescriptor, solution);
            for (Object entity : entityCollection) {
                PlanningEntityDescriptor planningEntityDescriptor = getPlanningEntityDescriptor(entity.getClass());
                if (planningEntityDescriptor.isInitialized(entity)) {
                    facts.add(entity);
                }
            }
        }
        return facts;
View Full Code Here

    public long getProblemScale(Solution solution) {
        long problemScale = 0L;
        for (PropertyDescriptor entityPropertyDescriptor : entityPropertyDescriptorMap.values()) {
            Object entity = extractPlanningEntity(entityPropertyDescriptor, solution);
            if (entity != null) {
                PlanningEntityDescriptor planningEntityDescriptor = getPlanningEntityDescriptor(entity.getClass());
                problemScale += planningEntityDescriptor.getProblemScale(solution, entity);
            }
        }
        for (PropertyDescriptor entityCollectionPropertyDescriptor : entityCollectionPropertyDescriptorMap.values()) {
            Collection<?> entityCollection = extractPlanningEntityCollection(
                    entityCollectionPropertyDescriptor, solution);
            for (Object entity : entityCollection) {
                PlanningEntityDescriptor planningEntityDescriptor = getPlanningEntityDescriptor(entity.getClass());
                problemScale += planningEntityDescriptor.getProblemScale(solution, entity);
            }
        }
        return problemScale;
    }
View Full Code Here

TOP

Related Classes of org.drools.planner.core.domain.entity.PlanningEntityDescriptor

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.