aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Pitschke2012-11-12 10:06:06 (EST)
committerSteve Pitschke2012-11-12 10:06:06 (EST)
commitf963b86f94a7eb9cbe50859acbd741ea775eacb1 (patch)
tree7851b6dea2b46fe86a6199e9d6d18db9f4e97b50
parentc8f90cf0048e06088f32abf7963428b6075df308 (diff)
downloadorg.eclipse.lyo.core-f963b86f94a7eb9cbe50859acbd741ea775eacb1.zip
org.eclipse.lyo.core-f963b86f94a7eb9cbe50859acbd741ea775eacb1.tar.gz
org.eclipse.lyo.core-f963b86f94a7eb9cbe50859acbd741ea775eacb1.tar.bz2
Bug 390919: Apply Patch to Fix JUnit Failuresrefs/changes/38/8638/1
-rw-r--r--OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java34
1 files changed, 30 insertions, 4 deletions
diff --git a/OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java b/OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java
index f0fad97..8f399b0 100644
--- a/OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java
+++ b/OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java
@@ -94,7 +94,6 @@ import com.hp.hpl.jena.rdf.model.Container;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
-import com.hp.hpl.jena.rdf.model.NodeIterator;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFList;
import com.hp.hpl.jena.rdf.model.RDFNode;
@@ -104,6 +103,8 @@ import com.hp.hpl.jena.rdf.model.ResIterator;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator;
+import com.hp.hpl.jena.util.iterator.ExtendedIterator;
+import com.hp.hpl.jena.util.iterator.Map1;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.RDFS;
@@ -546,14 +547,23 @@ public final class JenaModelHelper
visitedResources.put(getVisitedResourceName(object.asResource()), objects);
}
- else if (multiple && object.canAs(Container.class))
+ else if (multiple && isRdfCollectionResource(object.getModel(), object))
{
objects = new ArrayList<RDFNode>();
- NodeIterator iterator = object.as(Container.class).iterator();
+
+ ExtendedIterator<RDFNode> iterator =
+ object.asResource().listProperties(RDFS.member).
+ mapWith(new Map1<Statement, RDFNode>()
+ {
+ @Override
+ public RDFNode map1(Statement o) {
+ return o.getObject();
+ }
+ });
while (iterator.hasNext())
{
- RDFNode o = iterator.nextNode();
+ RDFNode o = iterator.next();
if (o.isResource())
{
@@ -843,6 +853,22 @@ public final class JenaModelHelper
}
}
+ private static boolean isRdfCollectionResource(Model model, RDFNode object)
+ {
+ if (object.isResource())
+ {
+ Resource resource = object.asResource();
+ if (resource.hasProperty(RDF.type, model.getResource(RDF_TYPE_URI + RDF_ALT))
+ || resource.hasProperty(RDF.type, model.getResource(RDF_TYPE_URI + RDF_BAG))
+ || resource.hasProperty(RDF.type, model.getResource(RDF_TYPE_URI + RDF_SEQ)))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Generates a prefix for unrecognized namespaces when reading in unknown
* properties and content.