aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornegrello2013-09-04 21:26:21 (EDT)
committerSamuel Padgett2013-09-05 09:51:11 (EDT)
commit499554ebe9457686f7ca719e1c1630a166395ce8 (patch)
tree046f6629b37c898bfb956305848681f19ccbae1b
parent55175c86229661beb6952e20cbcde2a495161da2 (diff)
downloadorg.eclipse.lyo.core-499554ebe9457686f7ca719e1c1630a166395ce8.zip
org.eclipse.lyo.core-499554ebe9457686f7ca719e1c1630a166395ce8.tar.gz
org.eclipse.lyo.core-499554ebe9457686f7ca719e1c1630a166395ce8.tar.bz2
Bug 416152: Allow extended properties and types in query responserefs/changes/80/15980/5
Change-Id: I3f87a6b574824fd76c835188155800e608a4a542 Signed-off-by: negrello <fnegre@br.ibm.com>
-rw-r--r--org.eclipse.lyo.oslc4j.core/src/main/java/org/eclipse/lyo/oslc4j/core/model/ResponseInfo.java7
-rw-r--r--org.eclipse.lyo.oslc4j.provider.jena/src/main/java/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java15
-rw-r--r--org.eclipse.lyo.oslc4j.provider.json4j/src/org/eclipse/lyo/oslc4j/provider/json4j/JsonHelper.java51
3 files changed, 69 insertions, 4 deletions
diff --git a/org.eclipse.lyo.oslc4j.core/src/main/java/org/eclipse/lyo/oslc4j/core/model/ResponseInfo.java b/org.eclipse.lyo.oslc4j.core/src/main/java/org/eclipse/lyo/oslc4j/core/model/ResponseInfo.java
index b6a3ff8..16e22aa 100644
--- a/org.eclipse.lyo.oslc4j.core/src/main/java/org/eclipse/lyo/oslc4j/core/model/ResponseInfo.java
+++ b/org.eclipse.lyo.oslc4j.core/src/main/java/org/eclipse/lyo/oslc4j/core/model/ResponseInfo.java
@@ -38,6 +38,7 @@ public abstract class ResponseInfo<T extends Object>
this.totalCount = totalCount;
this.nextPage = nextPage;
+ this.container = new FilteredResource<T>(resource, properties);
}
public
@@ -50,6 +51,7 @@ public abstract class ResponseInfo<T extends Object>
{
this(resource, properties, totalCount,
nextPage == null ? null : nextPage.toString());
+ this.container = new FilteredResource<T>(resource, properties);
}
public Integer
@@ -60,4 +62,9 @@ public abstract class ResponseInfo<T extends Object>
private final Integer totalCount;
private final String nextPage;
+ private FilteredResource<T> container;
+
+ public FilteredResource<T> getContainer() {
+ return container;
+ }
}
diff --git a/org.eclipse.lyo.oslc4j.provider.jena/src/main/java/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java b/org.eclipse.lyo.oslc4j.provider.jena/src/main/java/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java
index c4a1678..8351af7 100644
--- a/org.eclipse.lyo.oslc4j.provider.jena/src/main/java/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java
+++ b/org.eclipse.lyo.oslc4j.provider.jena/src/main/java/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java
@@ -80,6 +80,7 @@ import org.eclipse.lyo.oslc4j.core.exception.OslcCoreMisusedOccursException;
import org.eclipse.lyo.oslc4j.core.exception.OslcCoreRelativeURIException;
import org.eclipse.lyo.oslc4j.core.model.AbstractResource;
import org.eclipse.lyo.oslc4j.core.model.AnyResource;
+import org.eclipse.lyo.oslc4j.core.model.FilteredResource;
import org.eclipse.lyo.oslc4j.core.model.IExtendedResource;
import org.eclipse.lyo.oslc4j.core.model.IReifiedResource;
import org.eclipse.lyo.oslc4j.core.model.IResource;
@@ -176,13 +177,21 @@ public final class JenaModelHelper
{
if(OSLC4JUtils.isQueryResultListAsContainer())
{
- descriptionResource = model.createResource(descriptionAbout, RDFS.Container);
+ descriptionResource = model.createResource(descriptionAbout, RDFS.Container);
}
else
{
descriptionResource = model.createResource(descriptionAbout);
}
+ Map<IExtendedResource,Resource> visitedResources = new HashMap<IExtendedResource,Resource>();
+ handleExtendedProperties(FilteredResource.class,
+ model,
+ descriptionResource,
+ (IExtendedResource) responseInfo.getContainer(),
+ properties,
+ visitedResources);
+
if (responseInfoAbout != null)
{
final Resource responseInfoResource = model.createResource(responseInfoAbout,
@@ -201,7 +210,7 @@ public final class JenaModelHelper
model.createResource(responseInfo.nextPage()));
}
- Map<IExtendedResource,Resource> visitedResources = new HashMap<IExtendedResource,Resource>();
+ visitedResources = new HashMap<IExtendedResource,Resource>();
handleExtendedProperties(ResponseInfo.class,
model,
responseInfoResource,
@@ -211,7 +220,7 @@ public final class JenaModelHelper
}
}
}
-
+
for (final Object object : objects)
{
handleSingleResource(descriptionResource,
diff --git a/org.eclipse.lyo.oslc4j.provider.json4j/src/org/eclipse/lyo/oslc4j/provider/json4j/JsonHelper.java b/org.eclipse.lyo.oslc4j.provider.json4j/src/org/eclipse/lyo/oslc4j/provider/json4j/JsonHelper.java
index 18e26cd..b97eada 100644
--- a/org.eclipse.lyo.oslc4j.provider.json4j/src/org/eclipse/lyo/oslc4j/provider/json4j/JsonHelper.java
+++ b/org.eclipse.lyo.oslc4j.provider.json4j/src/org/eclipse/lyo/oslc4j/provider/json4j/JsonHelper.java
@@ -183,7 +183,7 @@ public final class JsonHelper
jsonArray.add(jsonObject);
}
}
-
+
// Ensure we have an rdf prefix
final String rdfPrefix = ensureNamespacePrefix(OslcConstants.RDF_NAMESPACE_PREFIX,
OslcConstants.RDF_NAMESPACE,
@@ -214,6 +214,14 @@ public final class JsonHelper
resultJSONObject.put(rdfPrefix + JSON_PROPERTY_DELIMITER + JSON_PROPERTY_SUFFIX_TYPE,
containerTypesJSONArray);
+
+ Map<Object,JSONObject> visitedObjects = new HashMap<Object,JSONObject>();
+ addExtendedProperties(namespaceMappings,
+ reverseNamespaceMappings,
+ resultJSONObject,
+ (IExtendedResource) responseInfo.getContainer(),
+ properties,
+ visitedObjects);
}
@@ -826,6 +834,47 @@ public final class JsonHelper
InvocationTargetException,
OslcCoreApplicationException
{
+
+ // Ensure we have an rdf prefix
+ final String rdfPrefix = ensureNamespacePrefix(OslcConstants.RDF_NAMESPACE_PREFIX,
+ OslcConstants.RDF_NAMESPACE,
+ namespaceMappings,
+ reverseNamespaceMappings);
+
+ String rdfTypeKey = rdfPrefix + JSON_PROPERTY_DELIMITER + JSON_PROPERTY_SUFFIX_TYPE;
+ JSONArray typesJSONArray;
+ if (jsonObject.containsKey(rdfTypeKey))
+ {
+ typesJSONArray = (JSONArray) jsonObject.get(rdfTypeKey);
+ } else {
+ typesJSONArray = new JSONArray();
+ }
+
+ final JSONObject typeJSONObject = new JSONObject();
+
+ for (final URI type : extendedResource.getTypes())
+ {
+ final String propertyName = type.toString();
+
+ if (properties != null &&
+ properties.get(propertyName) == null &&
+ ! (properties instanceof NestedWildcardProperties) &&
+ ! (properties instanceof SingletonWildcardProperties))
+ {
+ continue;
+ }
+
+ typeJSONObject.put(rdfPrefix + JSON_PROPERTY_DELIMITER + JSON_PROPERTY_SUFFIX_RESOURCE,
+ propertyName);
+
+ typesJSONArray.add(typeJSONObject);
+ }
+
+ if (typesJSONArray.size() > 0)
+ {
+ jsonObject.put(rdfPrefix + JSON_PROPERTY_DELIMITER + JSON_PROPERTY_SUFFIX_TYPE, typesJSONArray);
+ }
+
for (Map.Entry<QName, Object> extendedProperty : extendedResource.getExtendedProperties().entrySet())
{
final String namespace = extendedProperty.getKey().getNamespaceURI();