%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % The RuleML-2009 Organizational Agent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Import external ContractLog libraries for % mathematical, lists and date / time computations % and access to external data sources, e.g. % Semantic Web ontologies, iCal Calendars etc. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% :-eval(consult('ContractLog/math.prova')). :-eval(consult('ContractLog/datetime.prova')). :-eval(consult('ContractLog/list.prova')). :-eval(consult('ContractLog/update.prova')). :-eval(consult('ContractLog/utils.prova')). :-eval(consult('ContractLog/calendar.prova')). % calendar API :-eval(consult('ContractLog/owl.prova')). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Performative vocabulary of organizational agent % More complex vocabularies (e.g. FIPA ACL) might be defined as Semantic Web ontologies %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% performative(request):-performative(query). performative(query). performative(XID,Performative):- performative(Performative). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Import meta interpreter axioms for priority computation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% :-eval(add("use_caseWellnessRules/Wellness-Rules/meta_rules/priority_computation.prova")). processList([]) :- !. processList([X|Y]):- free(X), Temp = [X], assert(aVar(Temp)), println(["Free ",X]), processList(Y). processList([X|Y]):- bound(X), println(["Bound ",X]), processList(Y). retractAll([]) :- !. retractAll([X|Y]) :- retract(aVar(X)), retractAll(Y). %WELLNESSRULES - PROFILEID,INOUT,STARTTIME,ENDTIME,LOCATION,DURATION,FITNESSLEVEL processMessage(XID,From,Primitive,myActivity(ProfileID,Activity,InOut,MinRSVP,MaxRSVP,StartTime,EndTime,Location,Duration,FitnessLevel)):- free(ProfileID), free(InOut), free(StartTime), free(EndTime), free(Location), free(Duration), free(FitnessLevel), bound(Activity), bound(MinRSVP), bound(MaxRSVP), println(["---------------------------------------------"]), println(["NEW QUERY"]), println(["---------------------------------------------"]), println(["Received message from browser."]), concat(["wellnessRules_",Activity],Topic), assigned(XID,Agent,Topic,wellnessRules_responsible), println(["Responsible PA: ",Agent]), sendMsg(XID,esb,Agent, "query",myActivity(ProfileID,Activity,InOut,MinRSVP,MaxRSVP,StartTime,EndTime,Location,Duration,FitnessLevel)), println(["Sent message to the ",Agent," PA."]), println([""]), rcvMult(XID,esb,Agent,"answer", substitutions(ProfileID,InOut,StartTime,EndTime,Location,Duration,FitnessLevel)), println(["Received message from the ",Agent," PA."]), sendMsg(XID,esb,From, "answer", myActivity(ProfileID,Activity,InOut,MinRSVP,MaxRSVP,StartTime,EndTime,Location,Duration,FitnessLevel)), println(["Sent message to browser."]). %WELLNESSRULES - PROFILEID,INOUT,STARTTIME,ENDTIME,LOCATION,DURATION processMessage(XID,From,Primitive,myActivity(ProfileID,Activity,InOut,MinRSVP,MaxRSVP,StartTime,EndTime,Location,Duration,FitnessLevel)):- free(ProfileID), free(InOut), free(StartTime), free(EndTime), free(Location), free(Duration), bound(Activity), bound(MinRSVP), bound(MaxRSVP), bound(FitnessLevel), println(["---------------------------------------------"]), println(["NEW QUERY"]), println(["---------------------------------------------"]), println(["Received message from browser."]), concat(["wellnessRules_",Activity],Topic), assigned(XID,Agent,Topic,wellnessRules_responsible), println(["Responsible PA: ",Agent]), sendMsg(XID,esb,Agent, "query",myActivity(ProfileID,Activity,InOut,MinRSVP,MaxRSVP,StartTime,EndTime,Location,Duration,FitnessLevel)), println(["Sent message to the ",Agent," PA."]), println([""]), rcvMult(XID,esb,Agent,"answer", substitutions(ProfileID,InOut,StartTime,EndTime,Location,Duration)), println(["Received message from the ",Agent," PA."]), sendMsg(XID,esb,From, "answer", myActivity(ProfileID,Activity,InOut,MinRSVP,MaxRSVP,StartTime,EndTime,Location,Duration,FitnessLevel)), println(["Sent message to browser."]). %WELLNESSRULES - INOUT,STARTTIME,ENDTIME,LOCATION,DURATION processMessage(XID,From,Primitive,myActivity(ProfileID,Activity,InOut,MinRSVP,MaxRSVP,StartTime,EndTime,Location,Duration,FitnessLevel)):- free(InOut), free(StartTime), free(EndTime), free(Duration), bound(ProfileID), bound(Activity), bound(MinRSVP), bound(MaxRSVP), bound(Location), bound(FitnessLevel), println(["---------------------------------------------"]), println(["---------------------------------------------"]), println(["Received message from browser."]), concat(["wellnessRules_",Activity],Topic), assigned(XID,Agent,Topic,wellnessRules_responsible), println(["Responsible PA: ",Agent]), sendMsg(XID,esb,Agent, "query",myActivity(ProfileID,Activity,InOut,MinRSVP,MaxRSVP,StartTime,EndTime,Location,Duration,FitnessLevel)), println(["Sent message to the ",Agent," PA."]), println([""]), rcvMult(XID,esb,Agent,"answer", substitutions(InOut,StartTime,EndTime,Duration)), println(["Received message from the ",Agent," PA."]), sendMsg(XID,esb,From, "answer", myActivity(ProfileID,Activity,InOut,MinRSVP,MaxRSVP,StartTime,EndTime,Location,Duration,FitnessLevel)), println(["Sent message to browser."]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Main rule for this use case: % % "Single point of entry" % % An external person/agent requests information from the % RuleML-2009 organization. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% rcvMsg(XID,esb, From, Performative, [X|Args]) :- understandPerformative(XID, From, Performative, [X|Args]), processMessage(XID, From, Performative, [X|Args]). rcvMsg(XID,esb, From, Performative, [X|Args]) :- understandPerformative(XID, From, Performative, [X|Args]), rcvMsg(XID,esb,Agent,no_further_answers, Payload), println([""]), println(["Complete"]), println(["---------------------------------------------"]), println(["---------------------------------------------"]), println([""]), println([""]), sendMsg(XID,esb,From,no_further_answers,[X|Args]). % sendMsg(XID,esb,From,end_of_transmission,[X|Args]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % rules for processing the message %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % try to understand the performative of the message understandPerformative(XID, From, "answer", PayLoad) :- !, fail(). understandPerformative(XID, From, "end_of_transmission", PayLoad) :- !, fail(). understandPerformative(XID, From, "no_further_answers", PayLoad) :- !, fail(). understandPerformative(XID, From, Performative, PayLoad) :- performative(Performative). understandPerformative(XID, From, Performative, PayLoad) :- not(performative(Performative)), sendMsg(XID,esb,From,"answer", notUnderstood("performative",Performative)), sendMsg(XID,esb,From,"no_further_answers", PayLoad), fail(). % look-up interface processMessage(XID,From,Primitive,[X|Args]):- not(interface([X|Args],ModeDeclarations,Description)), sendMsg(XID,esb,From,"answer", noPublicInterface(interface([X|Args]))), sendMsg(XID,esb,From,"no_further_answers", [X|Args]), fail(). processMessage(XID,From,Primitive,[Function|Arguments]):- interface([Function|Arguments],ModeDeclarations,Description), %TODO: write rule which checks signature and mode declarations (dynamic testing) derive([Function,XID|Arguments]), sendMsg(XID,esb,From, "answer", [Function|Arguments]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Import Responsibility Assignment Matrix from ontology and define % the query functions of the organizational agent on top %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %import external ontology of responsibility assignment matrix import("http://ruleml.org/WellnessRules/files/WellnessRules.owl"). %use external OWL Lite reasoner for a list of available reasoners %see the OWL2PROVA API reasoner("owl"). %Personal agent/coach agent(XID,Agent:ruleml2009_Organizing_Committee). agent(XID,Agent):- sendMsg(XID,esb,"WellnessRules","no_further_answers", agent(Member)),fail(). %responsibility domain of RuleML 2009 responsibility(XID,Domain:wellnessRules_Responsibility). %role such as "responsible", "informed", "accountable" etc. role(XID,Role:owl_ObjectProperty). %responsibility assignment matrix %e.g. ruleml2009_GeneralChair ruleml2009_responsible ruleml2009_Symposium assigned(XID,Agent,Responsibility,Role):- import(URL), reasoner(Reasoner), rdf(URL,Reasoner,Agent,Role,Responsibility). interface(XID,Signature,Modes,Description):- interface(Signature,Modes,Description). interface(performative(Performative),performative("?"),"vocabulary of performatives of the agent"). interface(interface(Signature, ModeDeclaration, Description),interface("?","?","?"),"the public interfaces of the agent"). interface(submit(Requester, Type, Result),submit("+","+","-"),"submital rules"). interface(agent(Agent),agent("?"),"the agents of RuleML-2008 defined in an external ontology"). interface(topic(Topic),topic("?"),"the responsibility topics/domains of RuleML-2008"). interface(role(Role),role("?"),"the defined roles of the responsibility assignment matrix for RuleML-2008"). interface(assigned(Agent,Topic,Role),assigned("?","?","?"),"the defined responsibility assignment matrix for RuleML-2008"). interface(getContact(Topic,Request,Contact),getContact("+","+","-"),"request personal contact information for a certain Topic and Request regarding RuleML-2008"). interface(myActivity(ProfileID,Activity,InOut,MinRSVP,MaxRSVP,StartTime,EndTime,Place,Duration,FitnessLevel),blah(),"WelnessRules MyActivity Rule"). interface(open(Phase),open("-"),"returns the currently active RuleML-2008 phases"). interface(dates(Phase,Start,End),dates("+","-","-"),"returns the start and end date of a phase"). interface(permit(ContactAuthor,submit(ContactAuthor,Submission)),permit("?",submit("?","?")), "permission to submit to RuleML-2008"). interface(submitted(Submission),submitted("?"),"request submitted submissions"). interface(obliged(Reviewer,submit(Reviewer,Review)),obliged("?",submit("?","?")), "review obligations for reviewer"). interface(forbid(Reviewer,review(submission(Authors,Abstract,Paper),Review)),forbid("?",review(submission("?","?","?"),"?")), "forbid reviewer to review his own submissions"). interface(accepted(Submission),accepted("?"),"accepted submissions"). interface(fee(Phase,Fee),fee("?","?"),"registration fee"). interface(computeFee(Participant,Fee),computeFee("?","?"),"compute registration fee for participant"). interface(oblige(Participant,pay(Fee)),oblige("?",pay("?")),"obligation for registered participants to pay fee"). interface(permit(Participant,attend),permit("?","-"),"permission to attend the conference"). interface(permit(Participant,register(Participant)),permit("?",register("?")), "permission to register to RuleML-2008").