/*
* Copyright 2012 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.drools.planner.core.testdata.domain;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.drools.planner.api.domain.solution.PlanningEntityCollectionProperty;
import org.drools.planner.core.domain.entity.PlanningEntityDescriptor;
import org.drools.planner.core.domain.solution.SolutionDescriptor;
import org.drools.planner.core.score.buildin.simple.SimpleScore;
import org.drools.planner.core.solution.Solution;
public class TestdataSolution extends TestdataObject implements Solution<SimpleScore> {
public static SolutionDescriptor buildSolutionDescriptor() {
SolutionDescriptor solutionDescriptor = new SolutionDescriptor(TestdataSolution.class);
solutionDescriptor.processAnnotations();
PlanningEntityDescriptor entityDescriptor = new PlanningEntityDescriptor(
solutionDescriptor, TestdataEntity.class);
entityDescriptor.processAnnotations();
solutionDescriptor.addPlanningEntityDescriptor(
entityDescriptor);
return solutionDescriptor;
}
private List<TestdataValue> valueList;
private List<TestdataEntity> entityList;
private SimpleScore score;
public TestdataSolution() {
}
public TestdataSolution(String code) {
super(code);
}
public List<TestdataValue> getValueList() {
return valueList;
}
public void setValueList(List<TestdataValue> valueList) {
this.valueList = valueList;
}
@PlanningEntityCollectionProperty
public List<TestdataEntity> getEntityList() {
return entityList;
}
public void setEntityList(List<TestdataEntity> entityList) {
this.entityList = entityList;
}
public SimpleScore getScore() {
return score;
}
public void setScore(SimpleScore score) {
this.score = score;
}
// ************************************************************************
// Complex methods
// ************************************************************************
public Collection<? extends Object> getProblemFacts() {
return valueList;
}
public TestdataSolution cloneSolution() {
TestdataSolution clone = new TestdataSolution();
clone.code = code;
clone.entityList = entityList;
List<TestdataEntity> clonedEntityList = new ArrayList<TestdataEntity>(
entityList.size());
for (TestdataEntity entity : entityList) {
TestdataEntity clonedEntity = entity.clone();
clonedEntityList.add(clonedEntity);
}
clone.entityList = clonedEntityList;
clone.score = score;
return clone;
}
}