We are developing an application which is using Marklogic as the document store for entities. We are planning to establish relationship between entities using semantics.
For example: Company is an entity and "ABC Corporation" is an instance of Company entity. Likewise Truck is an entity and "Volvo 101" is an instance of Truck entity.
We intend to define these relations by creating the triples as below when user creates instance of business entities in UI.
However we are facing issues when we use GraphManager.merge() as this method is adding new triple to the graph every time when the subject, predicate and object are same . The existing triple is not being overwritten.
We also tried the write/writeAs method and still see the same behavior.
We also looked at sesame and jena api's provided by Marklogic but couldn't find good documentation. If we intend to do lot of semantic operations and build triples dynamically which is the better api to use for semantics ? Marklogic-java-api or sesame or jena?
Code snippet:
String subjectURI = "http://example.org/entityinstance/ABCCorporation";
String predicateURI = "http://example.org/relation/instanceof";
String objectURI = "http://example.org/entity/company";
String graphURI = "http://example.org/graph/Relation";
public void createTriple(String subjectURI, String predicateURI,
String objectURI, String graphURI)
{
DatabaseClient client = markLogicConnectionHelper.getMLConnection();
String tripleStore = "<" + subjectURI + ">" + " " + " <" + predicateURI
+ ">" + " " + "<" + objectURI + ">" + ".";
GraphManager graphManager = client.newGraphManager();
graphManager.setDefaultMimetype(RDFMimeTypes.NTRIPLES);
graphManager.merge(graphURI, new StringHandle(tripleStore));
}