diff --git a/src/main/java/com/ontotext/trree/plugin/mongodb/MongoDBPlugin.java b/src/main/java/com/ontotext/trree/plugin/mongodb/MongoDBPlugin.java index d84e990..5556558 100644 --- a/src/main/java/com/ontotext/trree/plugin/mongodb/MongoDBPlugin.java +++ b/src/main/java/com/ontotext/trree/plugin/mongodb/MongoDBPlugin.java @@ -173,7 +173,7 @@ public double estimate(long subject, long predicate, long object, long context, if (predicate == rdf_type) { if (ctx != null && ctx.iters != null && object != 0 && object != Entities.BOUND) { String suffix = Utils.matchPrefix( - pluginConnection.getEntities().get(object).stringValue(), NAMESPACE_INST); + pluginConnection.getEntities().get(object).stringValue(), NAMESPACE_INST, NAMESPACE); if (suffix != null && suffix.length() > 0) { return 0.3; } @@ -243,7 +243,7 @@ public StatementIterator interpret(long subject, long predicate, long object, lo if (predicate == rdf_type && context == 0) { if (object >= 0) return null; - String suffix = Utils.matchPrefix(Utils.getString(entities, object), NAMESPACE_INST); + String suffix = Utils.matchPrefix(Utils.getString(entities, object), NAMESPACE_INST, NAMESPACE); if (suffix == null) return null; if (ctx.iters != null) { @@ -421,7 +421,7 @@ public StatementIterator interpret(long subject, long predicate, long object, lo if (context != 0) { MongoResultIterator iterator; - String suffix = Utils.matchPrefix(entities.get(context).stringValue(), NAMESPACE_INST); + String suffix = Utils.matchPrefix(entities.get(context).stringValue(), NAMESPACE, NAMESPACE_INST); if (suffix != null && suffix.length() > 0) { if (ctx.iters == null) { // no iterators up until this moment so we probably have model pattern before the actual query definition @@ -502,7 +502,7 @@ public boolean interpretUpdate(long subject, long predicate, long object, long c || predicate == passwordId || predicate == authDbId) { // no valid object or subject // get new instance localname - String suffix = Utils.matchPrefix(Utils.getString(pluginConnection.getEntities(), subject), NAMESPACE_INST); + String suffix = Utils.matchPrefix(Utils.getString(pluginConnection.getEntities(), subject), NAMESPACE_INST, NAMESPACE); if (suffix == null) { getLogger().error("No valid localname for the instance when registering a connection to MongoDB"); return true; @@ -541,7 +541,7 @@ public boolean interpretUpdate(long subject, long predicate, long object, long c return true; } if (predicate == dropId) { - String suffix = Utils.matchPrefix(Utils.getString(pluginConnection.getEntities(), subject), NAMESPACE_INST); + String suffix = Utils.matchPrefix(Utils.getString(pluginConnection.getEntities(), subject), NAMESPACE_INST, NAMESPACE); if (suffix == null) { getLogger().error("No valid localname for the instance when registering a connection to MongoDB"); return true; @@ -614,7 +614,7 @@ protected MongoResultIterator getIteratorOrNull(long subject, long context, Cont } protected MongoResultIterator createMainIterator(long graphId, Entities entities, ContextImpl ctx) { - String suffix = Utils.matchPrefix(entities.get(graphId).stringValue(), NAMESPACE_INST); + String suffix = Utils.matchPrefix(entities.get(graphId).stringValue(), NAMESPACE_INST, NAMESPACE); if (StringUtils.isBlank(suffix)) { getLogger().error("Invalid MongoDB inst {}!", suffix); return null; @@ -864,7 +864,10 @@ private boolean isAlreadyDelegateToSomeoneElse(ContextImpl ctx, MongoResultItera @Override public StatementIterator createEntityIter(long pred) { // we should have actual iterator instance when entity iterator is requested - return getDelegate().createEntityIter(pred); + MongoResultIterator iterator = getDelegate(); + if (iterator == null) + return StatementIterator.EMPTY; + return iterator.createEntityIter(pred); } @Override public void setQuery(String query) {