use of won.protocol.util.NeedModelWrapper in project webofneeds by researchstudio-sat.
the class GoalInstantiationProducer method createAllGoalCombinationInstantiationResults.
/**
* create all possible goal instantiations between two needs.
* That means trying to combine each two goals of the two needs.
*
* @return
*/
public Collection<GoalInstantiationResult> createAllGoalCombinationInstantiationResults() {
NeedModelWrapper needWrapper1 = new NeedModelWrapper(need1);
NeedModelWrapper needWrapper2 = new NeedModelWrapper(need2);
Collection<GoalInstantiationResult> results = new LinkedList<>();
for (Resource goal1 : needWrapper1.getGoals()) {
for (Resource goal2 : needWrapper2.getGoals()) {
GoalInstantiationResult instantiationResult = findInstantiationForGoals(goal1, goal2);
results.add(instantiationResult);
}
}
return results;
}
use of won.protocol.util.NeedModelWrapper in project webofneeds by researchstudio-sat.
the class GoalInstantiationProducer method createGoalInstantiationResults.
private Collection<GoalInstantiationResult> createGoalInstantiationResults(Dataset need) {
NeedModelWrapper needWrapper = new NeedModelWrapper(need);
Collection<GoalInstantiationResult> results = new LinkedList<>();
for (Resource goal : needWrapper.getGoals()) {
results.add(findInstantiationForGoal(goal));
}
return results;
}
use of won.protocol.util.NeedModelWrapper in project webofneeds by researchstudio-sat.
the class GoalInstantiationTest method example5_singleGoalsValidity.
@Test
public void example5_singleGoalsValidity() throws IOException {
// check that the goals from each need can be validated successfully without each other
Dataset need1 = loadDataset(baseFolder + "ex5_need.trig");
Dataset need2 = loadDataset(baseFolder + "ex5_need_debug.trig");
Dataset conversation = loadDataset(baseFolder + "ex5_conversation.trig");
GoalInstantiationProducer goalInstantiation = new GoalInstantiationProducer(need1, need2, conversation, "http://example.org/", "http://example.org/blended/");
Collection<GoalInstantiationResult> results = goalInstantiation.createAllGoalCombinationInstantiationResults();
NeedModelWrapper needWrapper1 = new NeedModelWrapper(need1);
Resource goal = needWrapper1.getGoals().iterator().next();
GoalInstantiationResult result = goalInstantiation.findInstantiationForGoal(goal);
Assert.assertTrue(result.isConform());
NeedModelWrapper needWrapper2 = new NeedModelWrapper(need2);
goal = needWrapper1.getGoals().iterator().next();
result = goalInstantiation.findInstantiationForGoal(goal);
Assert.assertTrue(result.isConform());
}
use of won.protocol.util.NeedModelWrapper in project webofneeds by researchstudio-sat.
the class GoalInstantiationTest method example1_allInfoInTwoGoals.
@Test
public void example1_allInfoInTwoGoals() throws IOException {
Dataset need1 = loadDataset(baseFolder + "ex1_need.trig");
Dataset need2 = loadDataset(baseFolder + "ex1_need_debug.trig");
Dataset conversation = loadDataset(baseFolder + "ex1_conversation.trig");
GoalInstantiationProducer goalInstantiation = new GoalInstantiationProducer(need1, need2, conversation, "http://example.org/", "http://example.org/blended/");
Collection<GoalInstantiationResult> results = goalInstantiation.createAllGoalCombinationInstantiationResults();
// instantiation of combined goals must be conform
Assert.assertEquals(1, results.size());
System.out.println(results.iterator().next().toString());
Assert.assertTrue(results.iterator().next().isConform());
// instantiation of goal of need1 fails cause driver is missing
NeedModelWrapper needWrapper1 = new NeedModelWrapper(need1);
Resource goal = needWrapper1.getGoals().iterator().next();
GoalInstantiationResult result = goalInstantiation.findInstantiationForGoal(goal);
System.out.println(result.toString());
Assert.assertFalse(result.isConform());
Assert.assertEquals("hasDriver", result.getShaclReportWrapper().getValidationResults().iterator().next().getResultPath().getLocalName());
// instantiation of goal of need2 fails cause 3 attributes are missing: location, time, client
NeedModelWrapper needWrapper2 = new NeedModelWrapper(need2);
goal = needWrapper2.getGoals().iterator().next();
result = goalInstantiation.findInstantiationForGoal(goal);
System.out.println(result.toString());
Assert.assertFalse(result.isConform());
Assert.assertEquals(3, result.getShaclReportWrapper().getValidationResults().size());
}
use of won.protocol.util.NeedModelWrapper in project webofneeds by researchstudio-sat.
the class GoalInstantiationTest method example2_allInfoInTwoGoalsAndMessage.
@Test
public void example2_allInfoInTwoGoalsAndMessage() throws IOException {
Dataset need1 = loadDataset(baseFolder + "ex2_need.trig");
Dataset need2 = loadDataset(baseFolder + "ex2_need_debug.trig");
Dataset conversationWithoutPickupTime = loadDataset(baseFolder + "ex1_conversation.trig");
Dataset conversationWithPickupTime = loadDataset(baseFolder + "ex2_conversation.trig");
// this conversation doas not contain the missing pickup time info so the goals cannot be fulfilled
GoalInstantiationProducer goalInstantiation = new GoalInstantiationProducer(need1, need2, conversationWithoutPickupTime, "http://example.org/", "http://example.org/blended/");
Collection<GoalInstantiationResult> results = goalInstantiation.createAllGoalCombinationInstantiationResults();
Assert.assertEquals(1, results.size());
System.out.println(results.iterator().next().toString());
Assert.assertFalse(results.iterator().next().isConform());
// this conversation contains the missing pickup info so the goals can be fulfilled
goalInstantiation = new GoalInstantiationProducer(need1, need2, conversationWithPickupTime, "http://example.org/", "http://example.org/blended/");
results = goalInstantiation.createAllGoalCombinationInstantiationResults();
Assert.assertEquals(1, results.size());
System.out.println(results.iterator().next().toString());
Assert.assertTrue(results.iterator().next().isConform());
// instantiation of goal of need1 fails cause driver is missing
NeedModelWrapper needWrapper1 = new NeedModelWrapper(need1);
Resource goal = needWrapper1.getGoals().iterator().next();
GoalInstantiationResult result = goalInstantiation.findInstantiationForGoal(goal);
System.out.println(result.toString());
Assert.assertFalse(result.isConform());
Assert.assertEquals("hasDriver", result.getShaclReportWrapper().getValidationResults().iterator().next().getResultPath().getLocalName());
// instantiation of goal of need2 fails cause 3 attributes are missing: location, time, client
NeedModelWrapper needWrapper2 = new NeedModelWrapper(need2);
goal = needWrapper2.getGoals().iterator().next();
result = goalInstantiation.findInstantiationForGoal(goal);
System.out.println(result.toString());
Assert.assertFalse(result.isConform());
Assert.assertEquals(3, result.getShaclReportWrapper().getValidationResults().size());
}
Aggregations