#   Issue tracking - Worksflow application definiion ontology
#
# Finite state automaton ontology
#
# See requirements for tracking tools http://www.w3.org/2005/01/06-tool-req.html
#
@keywords a, is, of.

@prefix :	<http://www.w3.org/2005/01/wf/flow#>.

@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix s: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix doc: <http://www.w3.org/2000/10/swap/pim/doc#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
@prefix contact: <http://www.w3.org/2000/10/swap/pim/contact#> .
@prefix ex:  <#>.

Task a s:Class;
	s:label "task";
	s:comment """Something to be done in a wide sense,
	an agenda item at a meeting is one example, but any
	issue or task in this ontology is such a thing.
	The requirement for this framework was that it would allow
	one to customize ontologies for things such as agenda items,
	action items, working group issues with a spec, w3c Last Call issues,
	software bugs and administrative requests.
	In π-calculus, a process.
	Make your type of issue a subclass of Task.
	""".


State	a s:Class;
	s:subClassOf Class;   # So we can use rdf:type to indicate state
	s:label "State";
	s:comment """The application ontology defines states.""".

state	a rdf:Property;
	s:label "state";
	s:subPropertyOf rdf:type;  # or equivalentTo?
	s:domain Task;
	s:range	State.

TerminalState a s:Class;
	s:subClassOf State;
	s:label "terminal state";
	s:comment """A state from which there are no transisions.""".

NonTerminalState a s:Class;
	s:label "non-terminal state";
	owl:disjointWith TerminalState;
	s:comment """A state from which there are transisions.""".


Action		a s:Class;
		s:label "action";
		s:comment """The universal class of things which
can change the state of a task.
Included now: Creation, Transition. (Maybe in the future
more π-calculus constructions such as splitting & merging tasks,
and import/export of obligations to a foreign opaque system.)""".

Transition 	a s:Class; s:subClassOf Action;	
		s:label		"transition";
		s:comment """A transition is a change of state of
a task. Typical properties include date and/or source
(a document causing the transition), and a final state.""".

Creation 	a s:Class; s:subClassOf Action;	
		s:label		"creation";
		s:comment """A creation is a change from existence
to non-existence
a task. Typical properties include date and/or source
(a document causing the transition), and a final state.""".


date	s:range	DateTime.

final	a 		rdf:Property;
		s:label		"to";
		s:domain	Transition;
		s:range	State.

task		a		rdf:Property;
		s:range		Task;
		s:label		"task".
		
requires	a rdf:Property;
		s:label "requires";
		s:domain	Transition;
		s:range		rdf:List; # Of properties for validation
		s:comment	"""To be a valid transition,
		a necessary (but not necessarily sufficuent) condition
		is that there be recorded these properties for the record""".

affects		a rdf:Property;
		s:label "affects";
		s:domain	doc:Work;
		s:range		Task.


{ ?x a Transition; task ?t; source ?doc } => { ?doc affects ?t }.

# { ?x a Action} =>  { ?x s:subPropertyOf affects}.
		

creates		a rdf:Property;
		s:label "creates";
		s:domain	doc:Work;
		s:range		Task.


allowedTransitions a rdf:Property;
		s:domain	State;
		s:range		rdf:List; # @@@ of Action
		s:label		"allowed transitions";
		s:comment	"""The state machine is defined
	by these lists of transition allowed for each issue.
	(An interesting option in the Web is to make an allowed transition
	to a state in soemone else's ontology, which in turn allows
	transitions into many ontologies.  So a finite state maxchine
	may become very large. In practice this means that a task handed
	off to another organization may be processed on all kinds of ways.)""".

	{ ?x a TerminalState} => { ?x allowedTransitions () }.

final 		a rdf:Property;
		s:label		"to";
		s:range	State.

issue		a		rdf:Property;
		s:label		"issue";
		s:comment
		"""A transition changes the state of the given issue.""".
		
source	a		rdf:Property;
		s:label		"source";
		s:comment	"""The source of a transition is
				the document by which it happened""";
		s:range		doc:Work.

assignee	a		rdf:Property;
		s:label		"assigned to";
		s:domain	Transition;
		s:range		contact:SocialEntity;
		s:comment	"""Some transitions are parameterized
	by the person ro group to who a task has been assigned.""".

#ends
