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:36:38 UTC
svn commit: r1539369 -
/stanbol/branches/release-0.12/entityhub/yard/sesame/src/main/java/org/apache/stanbol/entityhub/yard/sesame/SesameYard.java
Author: rwesten
Date: Wed Nov 6 15:36:38 2013
New Revision: 1539369
URL: http://svn.apache.org/r1539369
Log:
merged fix for STANBOL-1206 and STANBOL-1207 to the 0.12.0 releaseing branch
Modified:
stanbol/branches/release-0.12/entityhub/yard/sesame/src/main/java/org/apache/stanbol/entityhub/yard/sesame/SesameYard.java
Modified: stanbol/branches/release-0.12/entityhub/yard/sesame/src/main/java/org/apache/stanbol/entityhub/yard/sesame/SesameYard.java
URL: http://svn.apache.org/viewvc/stanbol/branches/release-0.12/entityhub/yard/sesame/src/main/java/org/apache/stanbol/entityhub/yard/sesame/SesameYard.java?rev=1539369&r1=1539368&r2=1539369&view=diff
==============================================================================
--- stanbol/branches/release-0.12/entityhub/yard/sesame/src/main/java/org/apache/stanbol/entityhub/yard/sesame/SesameYard.java (original)
+++ stanbol/branches/release-0.12/entityhub/yard/sesame/src/main/java/org/apache/stanbol/entityhub/yard/sesame/SesameYard.java Wed Nov 6 15:36:38 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()));