Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Org.eclipse.higgins.js.pds.client API usage example"
(→Execution) |
(→call setAttributes()) |
||
Line 65: | Line 65: | ||
Example call to setAttributes (domain, attributes[]) | Example call to setAttributes (domain, attributes[]) | ||
− | * | + | * attVals[0] := (http://nytimes#gender, "female") |
− | * | + | * attVals[1] := (http://nytimes#bFirstName, "Alice") // "billing first name" |
− | * '''setAttributes''' ("nytimes.com", | + | |
+ | * '''setAttributes''' ("nytimes.com", attvals[]) | ||
=== Execution === | === Execution === | ||
Line 78: | Line 79: | ||
** result: newPersonRole == p:Ecommerce | ** result: newPersonRole == p:Ecommerce | ||
* attributes[] := extractAttributes () | * attributes[] := extractAttributes () | ||
− | ** result: attributes[] == (http://nytimes.com# | + | ** result: attributes[] == (http://nytimes.com#gender, http://nytimes.com#bFirstName) |
* rolesAtts[] := findRoles() | * rolesAtts[] := findRoles() | ||
− | ** result: rolesAtts[] == ((p:Byer, http://nytimes.com# | + | ** result: rolesAtts[] == ((p:Byer, http://nytimes.com#bFirstName), (p:Ecommerce, http://nytimes.com#gender)) |
* sortByRole | * sortByRole | ||
− | ** result: rolesAtts[] == ((p:Byer, http://nytimes.com# | + | ** result: rolesAtts[] == ((p:Byer, http://nytimes.com#bFirstName), (p:Ecommerce, http://nytimes.com#gender)) |
* person := http://azigo.com/ptrevithick/nytimes.com#me | * person := http://azigo.com/ptrevithick/nytimes.com#me | ||
* Since ''person'' doesn't exist we create the statements: | * Since ''person'' doesn't exist we create the statements: | ||
Line 92: | Line 93: | ||
** person == targetPersons[0] | ** person == targetPersons[0] | ||
** partialAttVals[] := subsetAttVals () | ** partialAttVals[] := subsetAttVals () | ||
− | *** result: partialAttVals[] == (http://nytimes.com# | + | *** result: partialAttVals[] == (http://nytimes.com#gender, "female") |
− | + | ** Loop: av==(http://nytimes.com#gender, "female") | |
− | + | *** class := getNamespace() | |
− | ** | + | **** result: class=="http://nytimes.com" |
− | *** result: class == http://nytimes.com | + | *** latt : getLocalAtt() |
− | ** | + | **** result: latt=="phone" |
− | *** result: | + | *** rule := getRule (template=http://azigo.com/sys/template/nytimes.com, class=http://nytimes.com, att="gender") |
− | ** rule := getRule (template=http://azigo.com/sys/template/nytimes.com, class=http://nytimes.com, att=" | + | *** result rule==(see "rule #1" in Initial State section above) |
− | *** result | + | |
− | + | ||
− | + | ||
== Final State == | == Final State == | ||
[[Image:Setattributes final state 2.0.103.png|center]] | [[Image:Setattributes final state 2.0.103.png|center]] |
Revision as of 14:04, 20 September 2011
{{#eclipseproject:technology.higgins|eclipse_custom_style.css}}
We show an example of calling getAttributes, calling setAttributes and then calling getAttributes a second time. In all cases we read/write the same two attributes in the nytimes.com namespace, bFirstName and phone.
Contents
Initial State
Contexts
NYTimes template
The template context http://azigo.com/sys/templates/nytimes.com contains (among other things) the following mapping rules:
:NYTimesPerson a owl:Class ; rdfs:subClassOf <http://www.eclipse.org/higgins/ontologies/2010/6/higgins#Person> ;
rule #1:
map:nameRule [ a map:roleSameAs ; map:equivalentAttribute fp:givenName ; map:predicate :bFirstName ; map:role <http://www.eclipse.org/higgins/ontologies/2010/6/persona#Buyer> ] ;
rule #2:
map:telephoneRule [ a map:roleSameAs ; map:equivalentAttribute fp:phone ; map:predicate :phone ; map:role <http://www.eclipse.org/higgins/ontologies/2010/6/persona#Ecommerce> ] .
call getAttributes()
Call
Example call to getAttributes (domain, audience, attributes[], where[], future)
- atts[0] := (http://nytimes#phone, false, nil) // a phone number
- atts[1] := (http://nytimes#bFirstName, false, nil) // "billing first name"
- getAttributes ("nytimes.com", nil, atts, nil, nil)
Execution
- context := getConnectionContext ()
- result: context == http://azigo.com/ptrevithick/nytimes.com)
- call findRoles()
- result:
- ((p:eCommerce, (nytimes.com#bFirstName, nil, nil))
- (p:Buyer, (nytimes.com#phone, nil, nil)))
- result:
- call sortByRole()
- result:
- ((p:eCommerce, (nytimes.com#bFirstName, nil, nil))
- (p:Buyer, (nytimes.com#phone, nil, nil)))
- result:
- Try to pull attributes from #me person in the nytimes.com
- result: no result: the nytimes.com context doesn't yet exist
- Try to pull attributes from #me person in root context
- call findPersonByRole()
- result: nil (no persons found that match role)
- result: no attribute/values found
call setAttributes()
Call
Example call to setAttributes (domain, attributes[])
- attVals[0] := (http://nytimes#gender, "female")
- attVals[1] := (http://nytimes#bFirstName, "Alice") // "billing first name"
- setAttributes ("nytimes.com", attvals[])
Execution
- context := getConnectionContext ()
- result: context == http://azigo.com/ptrevithick/nytimes.com
- template := getConnectionTemplate ()
- result: template == http://azigo.com/sys/template/nytimes.com
- Since context doesn't exist, create it from template
- newPersonRole := value of role attribute of Participant ContextPrototype
- result: newPersonRole == p:Ecommerce
- attributes[] := extractAttributes ()
- result: attributes[] == (http://nytimes.com#gender, http://nytimes.com#bFirstName)
- rolesAtts[] := findRoles()
- result: rolesAtts[] == ((p:Byer, http://nytimes.com#bFirstName), (p:Ecommerce, http://nytimes.com#gender))
- sortByRole
- result: rolesAtts[] == ((p:Byer, http://nytimes.com#bFirstName), (p:Ecommerce, http://nytimes.com#gender))
- person := http://azigo.com/ptrevithick/nytimes.com#me
- Since person doesn't exist we create the statements:
- (subj=:me pred=rdf:type obj=persona:Person) in context
- (subj=:me pred=p:role obj=(newPersonRole==persona:Ecommerce)) in context
- Loop(0) ra==(p:Ecommerce, http://nytimes.com#phone) // Loop: For every pair ra in rolesAtts...
- targetPersons[] := findPersonsByRole (person, p:Ecommerce)
- result: targetPersons[0] == <the :me person created above>; targetPersons[] is of size == 1
- person == targetPersons[0]
- partialAttVals[] := subsetAttVals ()
- result: partialAttVals[] == (http://nytimes.com#gender, "female")
- Loop: av==(http://nytimes.com#gender, "female")
- class := getNamespace()
- result: class=="http://nytimes.com"
- latt : getLocalAtt()
- result: latt=="phone"
- rule := getRule (template=http://azigo.com/sys/template/nytimes.com, class=http://nytimes.com, att="gender")
- result rule==(see "rule #1" in Initial State section above)
- class := getNamespace()
- targetPersons[] := findPersonsByRole (person, p:Ecommerce)