%%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:option a owl:ObjectProperty .
dco:val 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 [ option Hitch; val WithHitch] ;
	hasValueB [ option Engine; val SmallEngine ] .

%


!! Car 1

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

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

%


!! Car 2

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

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

%


! Ill-defined Car

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

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

%


!! Assignment Consistency Query 

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

}
%


!! Constraint Validation Query

%%sparql
SELECT ?car ?constraint WHERE {
?constraint rdf:type dco:Constraint .
?constraint dco:hasValueA ?constraintAssignmentA .
?constraintAssignmentA dco:option ?constraintAssignmentAOption .
?constraintAssignmentA dco:value ?valueA .
?constraint dco:hasValueB ?constraintAssignmentB .
?constraintAssignmentB dco:option ?constraintAssignmentBOption .
?constraintAssignmentB dco:value ?valueB .

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


}

%

%%package configOptions