diff --git a/src/spdx/writer/rdf/relationship_writer.py b/src/spdx/writer/rdf/relationship_writer.py index fcef9648f..5f7ab274a 100644 --- a/src/spdx/writer/rdf/relationship_writer.py +++ b/src/spdx/writer/rdf/relationship_writer.py @@ -10,7 +10,7 @@ # limitations under the License. from typing import Dict -from rdflib import Graph, BNode, RDF, URIRef +from rdflib import Graph, BNode, RDF, URIRef, RDFS, Literal from spdx.model.relationship import Relationship from spdx.model.spdx_no_assertion import SpdxNoAssertion @@ -34,7 +34,7 @@ def add_relationship_to_graph(relationship: Relationship, graph: Graph, doc_name graph.add((relationship_node, SPDX_NAMESPACE.relatedSpdxElement, URIRef(add_namespace_to_spdx_id(relationship.related_spdx_element_id, doc_namespace, external_doc_ref_to_namespace)))) - + graph.add((relationship_node, RDFS.comment, Literal(relationship.comment))) relationship_resource = URIRef( add_namespace_to_spdx_id(relationship.spdx_element_id, doc_namespace, external_doc_ref_to_namespace)) graph.add((relationship_resource, SPDX_NAMESPACE.relationship, relationship_node)) diff --git a/tests/spdx/writer/rdf/test_relationship_writer.py b/tests/spdx/writer/rdf/test_relationship_writer.py index 998da1db8..fd028d618 100644 --- a/tests/spdx/writer/rdf/test_relationship_writer.py +++ b/tests/spdx/writer/rdf/test_relationship_writer.py @@ -8,7 +8,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from rdflib import Graph, URIRef +from rdflib import Graph, URIRef, RDFS, Literal from spdx.writer.rdf.relationship_writer import add_relationship_to_graph from spdx.rdfschema.namespace import SPDX_NAMESPACE @@ -23,3 +23,4 @@ def test_add_relationship_to_graph(): assert(URIRef("docNamespace#SPDXRef-DOCUMENT"), SPDX_NAMESPACE.relationship, None) in graph assert (None, SPDX_NAMESPACE.relationshipType, SPDX_NAMESPACE.relationshipType_describes) in graph assert (None, SPDX_NAMESPACE.relatedSpdxElement, URIRef("docNamespace#SPDXRef-File")) in graph + assert (None, RDFS.comment, Literal(relationship.comment)) in graph