diff --git a/bundles/io.github.linkedfactory.opcua/src/main/java/io/github/linkedfactory/opcua/NodeSetToRdf.java b/bundles/io.github.linkedfactory.opcua/src/main/java/io/github/linkedfactory/opcua/NodeSetToRdf.java index 916a6084..17490ee5 100644 --- a/bundles/io.github.linkedfactory.opcua/src/main/java/io/github/linkedfactory/opcua/NodeSetToRdf.java +++ b/bundles/io.github.linkedfactory.opcua/src/main/java/io/github/linkedfactory/opcua/NodeSetToRdf.java @@ -30,6 +30,7 @@ import org.eclipse.milo.opcua.sdk.core.Reference; import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; +import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; import org.eclipse.milo.opcua.stack.core.types.enumerated.NodeClass; import javax.xml.bind.JAXBException; @@ -74,6 +75,11 @@ URI toUri(NodeId nodeId) { return URIs.createURI(nsUri).appendLocalPart(id); } + URI toUri(QualifiedName name) { + String nsUri = nodeSet.getNamespaceTable().getUri(name.getNamespaceIndex()); + return URIs.createURI(nsUri).appendLocalPart(name.getName()); + } + /** * Converts a nodeset to an RDF representation. */ @@ -142,6 +148,10 @@ void convert() { IResource rdfNode = em.createNamed(toUri(id), nodeType).as(IResource.class); rdfNode.setRdfsLabel(attrs.getDisplayName().getText()); rdfNode.setRdfsComment(attrs.getDescription().getText()); + QualifiedName browseName = attrs.getBrowseName(); + if (browseName != null) { + rdfNode.addProperty(UA_NAMESPACE.appendLocalPart("browseName"), toUri(browseName)); + } switch (attrs.getNodeClass()) { case ReferenceType: // mark defined references also as object properties @@ -166,6 +176,7 @@ void convert() { } // map references to RDF + boolean nodeIsReference = attrs.getNodeClass() == NodeClass.ReferenceType; List refs = nodeSet.getExplicitReferences().get(id); refs.stream().forEach(ref -> { ExpandedNodeId targetIdExpanded = ref.getTargetNodeId(); @@ -178,12 +189,13 @@ void convert() { em.add(new Statement(rdfTarget, refUri, rdfNode)); } - // convert HasSubType to rdfs:subClassOf + // convert HasSubType to rdfs:subClassOf / rdfs:subPropertyOf if (PROPERTY_HASSUBTYPE.equals(refUri)) { + URI property = nodeIsReference ? RDFS.PROPERTY_SUBPROPERTYOF : RDFS.PROPERTY_SUBCLASSOF; if (ref.isForward()) { - em.add(new Statement(rdfTarget, RDFS.PROPERTY_SUBCLASSOF, rdfNode)); + em.add(new Statement(rdfTarget, property, rdfNode)); } else { - em.add(new Statement(rdfNode, RDFS.PROPERTY_SUBCLASSOF, rdfTarget)); + em.add(new Statement(rdfNode, property, rdfTarget)); } }