You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2015/07/06 10:56:52 UTC

svn commit: r1689339 - in /stanbol/trunk/entityhub/indexing: core/src/main/java/org/apache/stanbol/entityhub/indexing/core/processor/ source/jenatdb/src/main/java/org/apache/stanbol/entityhub/indexing/source/jenatdb/

Author: rwesten
Date: Mon Jul  6 08:56:51 2015
New Revision: 1689339

URL: http://svn.apache.org/r1689339
Log:
fixes for STANBOL-1433 and STANBOL-1434: The EntityTypeFilter now supports exclusions without explicitly mention '*'; The Jena TDB indexing source now correctly handles LDPath statements traversing over BNodes that where converted to URIs as part of the indexing process

Modified:
    stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/processor/FieldValueFilter.java
    stanbol/trunk/entityhub/indexing/source/jenatdb/src/main/java/org/apache/stanbol/entityhub/indexing/source/jenatdb/RdfIndexingSource.java

Modified: stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/processor/FieldValueFilter.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/processor/FieldValueFilter.java?rev=1689339&r1=1689338&r2=1689339&view=diff
==============================================================================
--- stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/processor/FieldValueFilter.java (original)
+++ stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/processor/FieldValueFilter.java Mon Jul  6 08:56:51 2015
@@ -107,17 +107,18 @@ public class FieldValueFilter implements
 
     @Override
     public void setConfiguration(Map<String,Object> config) {
+        log.info("> configure {}",getClass().getSimpleName());
         IndexingConfig indexingConfig = (IndexingConfig)config.get(IndexingConfig.KEY_INDEXING_CONFIG);
         nsPrefixProvider = indexingConfig.getNamespacePrefixService();
         Object value = config.get(PARAM_FIELD);
         if(value == null || value.toString().isEmpty()){
             this.field = getUri(DEFAULT_FIELD);
-            log.info("Using default Field {}",field);
         } else {
             this.field = getUri(value.toString());
-            log.info("configured Field: {}",field);
         }
+        log.info(" - field: {}",field);
         value = config.get(PARAM_VALUES);
+        log.info(" - filters:");
         parseFilterConfig(value);
     }
 
@@ -156,6 +157,7 @@ public class FieldValueFilter implements
                     entry = "";
                 }
                 if(!includeAll && entry.equals("*")){
+                    log.info("    - includeAll");
                     includeAll = true;
                     continue;
                 }
@@ -177,8 +179,14 @@ public class FieldValueFilter implements
                 }
                 //if exclude add to this.exclude otherwise to this.values
                 (exclude ? this.exclude : this.included).add(uri);
+                log.info("    - {} {}",exclude ? "exclude" : "include", uri.isEmpty() ? "<empty>" : uri);
             }
         }
+        //if only excludes are configured add the include all
+        if(!includeAll && !exclude.isEmpty() && included.isEmpty()){
+            log.info("    - includeAll (because only exclusions are configured");
+            includeAll = true;
+        }
     }
 
     /**

Modified: stanbol/trunk/entityhub/indexing/source/jenatdb/src/main/java/org/apache/stanbol/entityhub/indexing/source/jenatdb/RdfIndexingSource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/source/jenatdb/src/main/java/org/apache/stanbol/entityhub/indexing/source/jenatdb/RdfIndexingSource.java?rev=1689339&r1=1689338&r2=1689339&view=diff
==============================================================================
--- stanbol/trunk/entityhub/indexing/source/jenatdb/src/main/java/org/apache/stanbol/entityhub/indexing/source/jenatdb/RdfIndexingSource.java (original)
+++ stanbol/trunk/entityhub/indexing/source/jenatdb/src/main/java/org/apache/stanbol/entityhub/indexing/source/jenatdb/RdfIndexingSource.java Mon Jul  6 08:56:51 2015
@@ -52,6 +52,7 @@ import com.hp.hpl.jena.datatypes.RDFData
 import com.hp.hpl.jena.datatypes.xsd.XSDDateTime;
 import com.hp.hpl.jena.datatypes.xsd.XSDDuration;
 import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.graph.NodeFactory;
 import com.hp.hpl.jena.graph.Triple;
 import com.hp.hpl.jena.graph.impl.LiteralLabel;
 import com.hp.hpl.jena.query.Query;
@@ -395,9 +396,9 @@ public class RdfIndexingSource extends A
         final Node resource;
         //STANBOL-765: check if the parsed id represents an bnode
         if(bnodePrefix != null && id.startsWith(bnodePrefix)){
-            resource = Node.createAnon(AnonId.create(id.substring(bnodePrefix.length())));
+            resource = NodeFactory.createAnon(AnonId.create(id.substring(bnodePrefix.length())));
         } else {
-            resource = Node.createURI(id);
+            resource = NodeFactory.createURI(id);
         }
         Representation source = vf.createRepresentation(id);
         boolean found;
@@ -788,6 +789,9 @@ public class RdfIndexingSource extends A
     @Override
     public Collection<Node> listObjects(Node subject, Node property) {
         Collection<Node> nodes = new ArrayList<Node>();
+        if(bnodePrefix != null && subject.isURI() && subject.getURI().startsWith(bnodePrefix)){
+            subject = NodeFactory.createAnon(new AnonId(subject.getURI().substring(bnodePrefix.length())));
+        }
         ExtendedIterator<Triple> it = indexingDataset.getDefaultGraph().find(subject, property, null);
         while(it.hasNext()){
             //STANBOL-765: we need also to transform bnodes to URIs for the
@@ -796,7 +800,7 @@ public class RdfIndexingSource extends A
             if(bnodePrefix != null && object.isBlank()){
                 StringBuilder sb = new StringBuilder(bnodePrefix);
                 sb.append(object.getBlankNodeId().getLabelString());
-                object = Node.createURI(sb.toString());
+                object = NodeFactory.createURI(sb.toString());
             }
             nodes.add(object);
         }
@@ -806,6 +810,9 @@ public class RdfIndexingSource extends A
     @Override
     public Collection<Node> listSubjects(Node property, Node object) {
         Collection<Node> nodes = new ArrayList<Node>();
+        if(bnodePrefix != null && object.isURI() && object.getURI().startsWith(bnodePrefix)){
+            object = NodeFactory.createAnon(new AnonId(object.getURI().substring(bnodePrefix.length())));
+        }
         ExtendedIterator<Triple> it = indexingDataset.getDefaultGraph().find(null, property, object);
         while(it.hasNext()){
             Node subject = it.next().getSubject();
@@ -814,7 +821,7 @@ public class RdfIndexingSource extends A
             if(bnodePrefix != null && subject.isBlank()){
                 StringBuilder sb = new StringBuilder(bnodePrefix);
                 sb.append(subject.getBlankNodeId().getLabelString());
-                subject = Node.createURI(sb.toString());
+                subject = NodeFactory.createURI(sb.toString());
             }
             nodes.add(subject);
         }
@@ -834,7 +841,7 @@ public class RdfIndexingSource extends A
     @Override
     public Node createURI(String uri) {
         if(bnodePrefix != null && uri.startsWith(bnodePrefix)){
-            return Node.createAnon(AnonId.create(uri.substring(bnodePrefix.length())));
+            return NodeFactory.createAnon(AnonId.create(uri.substring(bnodePrefix.length())));
         } else {
             return super.createURI(uri);
         }