%%ontology
@uses: configOptions
%

%%namespace
dco http://denkbares.com/ConfigOptions/
%


!! Definitions Configuration Options

%%turtle
dco:ConfigOption a owl:Class .
dco:ChoiceConfigOption rdfs:subClassOf ConfigOption .
dco:NumConfigOption rdfs:subClassOf ConfigOption .
dco:ConfigOptionAssignment a owl:Class .
dco:hasOption a owl:ObjectProperty .
dco:hasOptionValue a owl:ObjectProperty .
dco:ChoiceValue a owl:Class .
dco:availableChoice a owl:ObjectProperty .

%


!! Definitions Constraints

%%turtle
dco:Constraint a owl:Class .
dco:ContradictingConstraint rdfs:subClassOf Constraint .
dco:hasDisjointSet a owl:ObjectProperty .
dco:hasValueA a owl:ObjectProperty .
dco:hasValueB a owl:ObjectProperty .
dco:contradicts a owl:ObjectProperty .

% 


!! Definitions Car configuration set

%%turtle
dco:CarConfigSet a owl:Class.
dco:hasConfigAssignment a owl:ObjectProperty .

%


! Option Engine

%%turtle
dco:Engine a dco:ChoiceConfigOption ; 
	dco:availableChoice dco:SmallEngine, dco:MediumEngine, dco:Turbo .
	
dco:SmallEngine a ChoiceValue .
dco:MediumEngine a ChoiceValue .  
dco:Turbo a ChoiceValue .

%


! Option Hitch

%%turtle
dco:Hitch a dco:ChoiceConfigOption ; 
	dco:availableChoice WithHitch, WithoutHitch .
	
dco:WithHitch a ChoiceValue .
dco:WithoutHitch a ChoiceValue .  

%


! Option Edition

%%turtle
dco:Edition a dco:ChoiceConfigOption ; 
	dco:availableChoice FamilyEdition, SportsEdition, OffroadEdition .
	
dco:FamilyEdition a ChoiceValue .
dco:SportsEdition a ChoiceValue . 
dco:OffroadEdition a ChoiceValue .   

%


! Option Number of Doors

%%turtle
dco:NumberOfDoors a dco:NumConfigOption .
	
%


! Constraint 1 : Hitch contradicts Small Engine

%%

%%turtle
dco:HitchConstradictsSmallEngine a ContradictingConstraint ; 
	hasValueA dco:WithHitch;
	hasValueB dco:SmallEngine .

%


!! Car 1

%%turtle
dco:Car1 a CarConfigSet ;
	hasConfigAssignment 
	[ hasOption Engine; hasOptionValue MediumEngine ] ,
	[ hasOption Hitch; hasOptionValue WithHitch] .
%

%%sparql
SELECT ?option ?value WHERE {
dco:Car1 dco:hasConfigAssignment ?assignment.
?assignment dco:hasOption ?option .
?assignment dco:hasOptionValue ?value .
}

%


!! Car 2

%%turtle
dco:Car2 a CarConfigSet ;
	hasConfigAssignment 
	[ hasOption Engine; hasOptionValue SmallEngine ] ,
	[ hasOption Hitch; hasOptionValue WithHitch] .
%

%%sparql
SELECT ?option ?value WHERE {
dco:Car2 dco:hasConfigAssignment ?assignment.
?assignment dco:hasOption ?option .
?assignment dco:hasOptionValue ?value .
}

%


! Car Ill-defined

%%turtle
dco:CarX a CarConfigSet ;
	hasConfigAssignment 
	[ hasOption Engine; hasOptionValue WithHitch ] ,
	[ hasOption Hitch; hasOptionValue SportsEdition] .
%

%%sparql
SELECT ?option ?value WHERE {
dco:CarX dco:hasConfigAssignment ?assignment.
?assignment dco:hasOption ?option .
?assignment dco:hasOptionValue ?value .
}

%


!! Assignment Consistency Query 

%%Sparql
SELECT ?car ?option ?value {
?car rdf:type dco:CarConfigSet .
?car dco:hasConfigAssignment ?assignment .
?assignment dco:hasOptionValue ?value .
?assignment dco:hasOption ?option .
FILTER NOT EXISTS {
?option dco:availableChoice ?value .
}

}
%


!! Constraint Validation Query

%%sparql
SELECT ?car ?constraint WHERE {
?constraint rdf:type dco:Constraint .
?constraint dco:hasValueA ?valueA .
?constraint dco:hasValueB ?valueB .

?car rdf:type dco:CarConfigSet .
?car dco:hasConfigAssignment ?assignment1 .
?assignment1 dco:hasOptionValue ?valueA .
?car dco:hasConfigAssignment ?assignment2 .
?assignment2 dco:hasOptionValue ?valueB .


}

%

%%package configOptions