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 2013/11/06 16:26:14 UTC

svn commit: r1539361 - in /stanbol/trunk/entityhub/yard/sesame: pom.xml src/main/java/org/apache/stanbol/entityhub/yard/sesame/SesameYard.java src/test/resources/ src/test/resources/log4j.properties

Author: rwesten
Date: Wed Nov  6 15:26:13 2013
New Revision: 1539361

URL: http://svn.apache.org/r1539361
Log:
fixes for STANBOL-1206 and STANBOL-1207; minor: also changed unit test logging to log4j

Added:
    stanbol/trunk/entityhub/yard/sesame/src/test/resources/
    stanbol/trunk/entityhub/yard/sesame/src/test/resources/log4j.properties
Modified:
    stanbol/trunk/entityhub/yard/sesame/pom.xml
    stanbol/trunk/entityhub/yard/sesame/src/main/java/org/apache/stanbol/entityhub/yard/sesame/SesameYard.java

Modified: stanbol/trunk/entityhub/yard/sesame/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/yard/sesame/pom.xml?rev=1539361&r1=1539360&r2=1539361&view=diff
==============================================================================
--- stanbol/trunk/entityhub/yard/sesame/pom.xml (original)
+++ stanbol/trunk/entityhub/yard/sesame/pom.xml Wed Nov  6 15:26:13 2013
@@ -123,9 +123,9 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
+    <dependency>  <!-- used for debug level logging during tests -->
       <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-simple</artifactId>
+      <artifactId>slf4j-log4j12</artifactId>
       <scope>test</scope>
     </dependency>
   </dependencies>

Modified: stanbol/trunk/entityhub/yard/sesame/src/main/java/org/apache/stanbol/entityhub/yard/sesame/SesameYard.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/yard/sesame/src/main/java/org/apache/stanbol/entityhub/yard/sesame/SesameYard.java?rev=1539361&r1=1539360&r2=1539361&view=diff
==============================================================================
--- stanbol/trunk/entityhub/yard/sesame/src/main/java/org/apache/stanbol/entityhub/yard/sesame/SesameYard.java (original)
+++ stanbol/trunk/entityhub/yard/sesame/src/main/java/org/apache/stanbol/entityhub/yard/sesame/SesameYard.java Wed Nov  6 15:26:13 2013
@@ -277,7 +277,7 @@ public class SesameYard extends Abstract
      */
     protected final Representation getRepresentation(RepositoryConnection con, URI uri, boolean check) throws RepositoryException {
         if(!check || isRepresentation(con,uri)){
-            return createRepresentationGraph(con,uri);
+            return createRepresentationGraph(con, valueFactory, uri);
         } else {
             return null; //not found
         }
@@ -287,11 +287,12 @@ public class SesameYard extends Abstract
      * Extracts the triples that belong to the {@link Representation} with the
      * parsed id from the Sesame repository.
      * @param con the repository connection
+     * @param valueFactory the {@link RdfValueFactory} to use
      * @param uri the subject of the Representation to extract
      * @return the representation with the extracted data.
      * @throws RepositoryException 
      */
-    protected RdfRepresentation createRepresentationGraph(RepositoryConnection con, URI uri) throws RepositoryException{
+    protected RdfRepresentation createRepresentationGraph(RepositoryConnection con, RdfValueFactory valueFactory, URI uri) throws RepositoryException{
         RdfRepresentation rep = valueFactory.createRdfRepresentation(uri);
         Model model = rep.getModel();
         extractRepresentation(con, model, uri, new HashSet<BNode>());
@@ -584,7 +585,7 @@ public class SesameYard extends Abstract
                 getConfig().getMaxQueryResultNumber());
             results = executeSparqlFieldQuery(con, query, limit, false);
             //parse the results
-            List<String> ids = new ArrayList<String>(limit);
+            List<String> ids = limit > 0 ? new ArrayList<String>(limit) : new ArrayList<String>();
             while(results.hasNext()){
                 BindingSet result = results.next();
                 Value value = result.getValue(query.getRootVariableName());
@@ -672,14 +673,16 @@ public class SesameYard extends Abstract
             //are added to the same Sesame Model
             Model model = new TreeModel();
             RdfValueFactory valueFactory = new RdfValueFactory(model, sesameFactory);
-            List<Representation> representations = new ArrayList<Representation>(limit);
+            List<Representation> representations = limit > 0 ? 
+                    new ArrayList<Representation>(limit) : new ArrayList<Representation>();
             while(results.hasNext()){
                 BindingSet result = results.next();
                 Value value = result.getValue(query.getRootVariableName());
                 if(value instanceof URI){
-                    createRepresentationGraph(con, (URI)value); //copy all data to the model
+                    //copy all data to the model and create the representation
+                    RdfRepresentation rep = createRepresentationGraph(con, valueFactory, (URI)value); 
                     model.add(queryRoot, queryResult, value); //link the result with the query result
-                    representations.add(valueFactory.createRdfRepresentation((URI)value));
+                    representations.add(rep);
                 } //ignore non URI results
             }
             con.commit();
@@ -721,7 +724,8 @@ public class SesameYard extends Abstract
             //are added to the same Sesame Model
             Model model = new TreeModel();
             RdfValueFactory valueFactory = new RdfValueFactory(model, sesameFactory);
-            List<Representation> representations = new ArrayList<Representation>(limit);
+            List<Representation> representations = limit > 0 ? new ArrayList<Representation>(limit)
+                    : new ArrayList<Representation>();
             Map<String,URI> bindings = new HashMap<String,URI>(query.getFieldVariableMappings().size());
             for(Entry<String,String> mapping : query.getFieldVariableMappings().entrySet()){
                 bindings.put(mapping.getValue(), sesameFactory.createURI(mapping.getKey()));

Added: stanbol/trunk/entityhub/yard/sesame/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/yard/sesame/src/test/resources/log4j.properties?rev=1539361&view=auto
==============================================================================
--- stanbol/trunk/entityhub/yard/sesame/src/test/resources/log4j.properties (added)
+++ stanbol/trunk/entityhub/yard/sesame/src/test/resources/log4j.properties Wed Nov  6 15:26:13 2013
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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.
+
+# Root logger option
+log4j.rootLogger=INFO, stdout
+ 
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+log4j.logger.org.apache.stanbol.entityhub.yard.sesame=DEBUG
\ No newline at end of file