Is it possible in rdf4j to filter a model by their rdf:id
? I tried already the following approach:
model.filter(res, null, null)
But with this, I also get all occurrences of rdf:resource
and rdf:about
. At the moment I filter first the whole model for all occurrences of the wanted type (which returns a model). And then I filter this model for the resource and with this resource, I filter the whole model for the needed model-part:
Model typeModel = model.filter(null, RDF.TYPE, iri);
// the following obj contains only the id (found in an rdf:about or rdf:resource)
// normally I also do some checks before .iterator().next()
Resource res = typeModel.filter((Resource) obj, null, null).subjects().iterator().next();
Model resModel = model.filter(res, null, null);
I think my solution creates too much overhead because I would also need a typeModel
for each Type. Is there another way of filtering the model for the rdf:id
?
UPDATE:
Here is a short example: I need to find the ACLineSegment
with the help of the rdf:resource
of the Terminal.ConductingEquipment
.
<cim:Terminal rdf:ID="_8fd6a918-5a8d-42f2-ae19-3ee77bc76911">
<cim:ACDCTerminal.sequenceNumber>2</cim:ACDCTerminal.sequenceNumber>
<cim:IdentifiedObject.name>XXXX</cim:IdentifiedObject.name>
<cim:Terminal.ConductingEquipment rdf:resource="#_50c99578-6e17-45e1-a113-a4a28d643b40" />
<cim:Terminal.ConnectivityNode rdf:resource="#_eefd8021-6f56-4154-9b2b-9e275c0f43d0" />
<cim:Terminal.phases rdf:resource="http://iec.ch/TC57/2013/CIM-schema-cim16#PhaseCode.ABC" />
</cim:Terminal>
<cim:ACLineSegment rdf:ID="_50c99578-6e17-45e1-a113-a4a28d643b40">
<cim:ACLineSegment.b0ch>5.44828e-5</cim:ACLineSegment.b0ch>
<cim:ACLineSegment.bch>5.44828e-5</cim:ACLineSegment.bch>
....
</cim:ACLineSegment>