object
elements in the Jena model mapping allows to specify classes in the Owl ontology and their properties, and simplify filling the ontology.
name
: The name which will be used to represent an individual of this classclassName
: The name of the associated class in the OntologynameSuffix
: If this attribute is present, it will automatically add the associated suffix to the name of the element in the ontology<object name="flightplan" className="FlightPlan" nameSuffix="_flightplan"> <dataProperty name="label" property="Label" isName="true"/> <property name="waypoint" eltRef="waypoint" property="hasWaypoint" /> </object>Individuals of the
FlightPlan
class can be created with the following code:MappedElement fp = envOp.addElement("flightplan", eltName);The
nameSuffix
attribute ensures that the name of the individual will use the suffix. For example, if you have:MappedElement fp = envOp.addElement("flightplan", "FP1");The individual will have the name
FP1_flightplan
.
class
element in the mappings file.nameMethod
attribute specifies which method will be used to get the name of the instance.org.my.Waypoint
Java class to the Waypoint
class in the Ontology:<objectsMappings> <classTypes> <class path="org.my.Waypoint" nameMethod="getName"> <type object="waypoint" /> </class> </classTypes> <object name="waypoint" className="Waypoint"> <geometry /> <dataProperty name="label" property="Label" isName="true"/> <property name="hasWaypointType" eltRef="WaypointType" property="hasWaypointType" cardinality="one" /> </object> </objectsMappings>The following code will allow to add a Waypoint to the Ontology:
public class MyModule { private ElementsOperations wptOp = null; public void init(Module module) { ObjectMappings mappings = new ObjectMappings(); URL url = <the Mappings XML file URL> mappings.parse(module, url); wptOp = new ElementsOperations(module, mappings); } public void subscribe(ServiceInstance<?, ?> service) { Waypoint waypoint = service.getData("waypoint"); MappedElement elt = wptOp.addElement(waypoint); float latitude = waypoint.getLatitude(); float longitude = waypoint.getLongitude(); elt.setPosition(latitude, longitude); elt.addProperty("hasWaypointType", "NAV"); } }
selector
syntax. org.my.Zone
Java instance to a TaskZone
or RefuelZone
Ontology class depending on the return value of the getName()
method: <objectsMappings> <constants> <constant name="Task" value="1" type="short" /> <constant name="Refuel" value="2" type="short" /> </constants> <classTypes> <class path="org.my.Zone" nameMethod="getName"> <selector method="getNature"> <type value="Task" object="TaskZone" /> <type value="Refuel" object="RefuelZone" /> </selector> </class> </classTypes> <object name="TaskZone" className="TaskZone"> <geometry /> <dataProperty name="label" property="Label" isName="true"/> </object> <object name="RefuelZone" className="RefuelZone"> <geometry /> <dataProperty name="label" property="Label" isName="true"/> </object> </objectsMappings>The following code will allow to add a Zone to the Ontology:
public class MyModule { private ElementsOperations wptOp = null; public void init(Module module) { ObjectMappings mappings = new ObjectMappings(); URL url = <the Mappings XML file URL> mappings.parse(module, url); wptOp = new ElementsOperations(module, mappings); } public void subscribe(ServiceInstance<?, ?> service) { Waypoint waypoint = service.getData("zone"); MappedElement elt = wptOp.addElement(zone); float latitude = waypoint.getLatitude(); float longitude = waypoint.getLongitude(); elt.setPosition(latitude, longitude); } }
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence