Skip to main content

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.

Jump to: navigation, search

Org.eclipse.higgins.js.pds.client API usage example

Revision as of 14:17, 21 September 2011 by Unnamed Poltroon (Talk) (Call)

{{#eclipseproject:technology.higgins|eclipse_custom_style.css}}

We show an example of calling getAttributes and then calling setAttributes. In all cases we read/write the same two attributes in the nytimes.com namespace, bFirstName and phone.

Initial State

Contexts

Pdsclient example 2.0.101.png

NYTimes template

The template context http://azigo.com/sys/templates/nytimes.com contains (among other things) a class named "http://nytimes.com" that has the following mapping rules:

 :NYTimesPerson
     a       owl:Class ;
     rdfs:subClassOf <http://www.eclipse.org/higgins/ontologies/2010/6/higgins#Person> ;

rule #1:

     map:nameRule
             [ rdf:type map:rolePathLiteral ;
               map:mappedAtt <http://www.w3.org/2006/vcard/ns#given-name> ;
               map:path <http://www.w3.org/2006/vcard/ns#n> ;
               map:predicate :bFirstName ;
               map:role <http://www.eclipse.org/higgins/ontologies/2010/6/persona#Buyer>
             ] ;

rule #2:

     map:relationshipsRule
             [ rdf:type map:roleSameAs ;
               map:equivalentAttribute
                       fp:gender ;
               map:predicate :gender ;
               map:role <http://www.eclipse.org/higgins/ontologies/2010/6/persona#Ecommerce>
             ] ;

FlatPersonaPerson (relevant sections only)

rule #3:

     map:relationshipsRule
             [ rdf:type map:roleLiteral ;
               map:mappedAtt <http://xmlns.com/foaf/0.1/gender> ;
               map:predicate :gender ;
               map:role map:roleParam
             ] .

call getAttributes()

Call

Example call to getAttributes (domain, attributes[], where[], future)

Execution

  • context := getConnectionContext ()
  • call findRoles()
    • result:
      • ((p:eCommerce, (nytimes.com#gender, nil, nil))
      • (p:Buyer, (nytimes.com#gender, nil, nil)))
  • call sortByRole()
    • result:
      • ((p:eCommerce, (nytimes.com#gender, nil, nil))
      • (p:Buyer, (nytimes.com#bFirstName, nil, nil)))
  • 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[])

  • setAttributes ("nytimes.com", attvals[])

Execution

0:pushEvalRule (:me, rule #2 above, "female")

  • mappingRule := getRuleName()
    • result: mappingRule == "roleSameAs" so call pushRoleSameAs (person=:me, rule #2 above, "female")
pushRuleSameAs (template, person=:me, rule, value)
  • equivAtt := getRuleField (rule, map:equivalentAttribute)
    • result: equivAtt == fp:gender
  • newRule := findRule (template, eqivAtt)
    • result: returns rule #3 above!
  • pushEvalRule (person=:me, newRule, "Alice") // recursion

0:0: pushEvalRule (:me, rule #3 above, "female")

  • mappingRule := getRuleName()
    • result: mappingRule == "roleLiteral" so call pushRoleLiteral (person=:me, rule #3 above, "female")
pushRoleLiteral (person=:me, rule #3, "female")
  • mappedAtt := getruleField()
    • result: mappedAtt == foaf:gender
  • add new foaf:gender attribute to :me and sets value to "female"

1:pushEvalRule (person= :7643, rule #1 above, "Alice")

  • mappingRule := getRuleField()
    • result: mappingRule == rolePathLiteral
  • call pushRoleLiteral(template, 7643, rule #1, "Alice")
pushRulePathLiteral(template, 7643, rule #1, "Alice")
  • path := getRuleField ()
    • result: path == "v:n"
  • since :7643 doesn't have a v:n attribute then we create a v:Name object
    • result obj:= new v:Name
  • mappedAtt := getRuleField ()
    • result: mappedAtt == v:given-name
  • since obj is new it doesn't have a v:given-name so we add v:given-name to it

Final State

Red is newly created context

Pdsclient final state 2.0.106.png

Back to the top