aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Fiedler2011-10-25 18:28:38 (EDT)
committerSteve Speicher2011-10-25 18:28:38 (EDT)
commit1090e036e9cd839651127763d08a197029e38806 (patch)
tree6aa44a1ceab35775a24c3980fc197672bffe2b08
parent0564a8a0a63a9c3f4a1263e0cc3a097159402433 (diff)
downloadorg.eclipse.lyo.rio-1090e036e9cd839651127763d08a197029e38806.zip
org.eclipse.lyo.rio-1090e036e9cd839651127763d08a197029e38806.tar.gz
org.eclipse.lyo.rio-1090e036e9cd839651127763d08a197029e38806.tar.bz2
Bug362012 - update buildResponseResource to put query results in element
with correct about.
-rw-r--r--org.eclipse.lyo.rio.am/src/main/java/org/eclipse/lyo/oslc/am/linktype/LinkTypeQueryService.java31
-rw-r--r--org.eclipse.lyo.rio.am/src/main/java/org/eclipse/lyo/oslc/am/resource/ResourceService.java28
-rw-r--r--org.eclipse.lyo.rio.cm/src/main/java/org/eclipse/lyo/rio/cm/changerequest/ChangeRequestService.java28
-rw-r--r--org.eclipse.lyo.rio.core/src/main/java/org/eclipse/lyo/rio/core/IConstants.java4
-rw-r--r--org.eclipse.lyo.rio.rm/src/main/java/org/eclipse/lyo/oslc/rm/services/requirement/RequirementService.java28
-rw-r--r--org.eclipse.lyo.rio.rm/src/main/java/org/eclipse/lyo/oslc/rm/services/requirementcollection/RequirementCollectionService.java30
6 files changed, 101 insertions, 48 deletions
diff --git a/org.eclipse.lyo.rio.am/src/main/java/org/eclipse/lyo/oslc/am/linktype/LinkTypeQueryService.java b/org.eclipse.lyo.rio.am/src/main/java/org/eclipse/lyo/oslc/am/linktype/LinkTypeQueryService.java
index 4381f12..3ce3c79 100644
--- a/org.eclipse.lyo.rio.am/src/main/java/org/eclipse/lyo/oslc/am/linktype/LinkTypeQueryService.java
+++ b/org.eclipse.lyo.rio.am/src/main/java/org/eclipse/lyo/oslc/am/linktype/LinkTypeQueryService.java
@@ -31,6 +31,7 @@ import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.lyo.oslc.am.common.IAmConstants;
import org.eclipse.lyo.rio.core.IConstants;
+import org.eclipse.lyo.rio.l10n.Messages;
import org.eclipse.lyo.rio.query.PName;
import org.eclipse.lyo.rio.query.SimpleQueryBuilder;
import org.eclipse.lyo.rio.services.RioBaseService;
@@ -109,23 +110,33 @@ public class LinkTypeQueryService extends RioBaseService {
rdf.setAttribute("xmlns:" + namespacePrefixes.get(namespace), namespace); //$NON-NLS-1$
}
- Element responseElement = doc.createElementNS(IConstants.OSLC_NAMESPACE, IConstants.OSLC_PTERM_RESPONSEINFO);
- responseElement.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
- rdf.appendChild(responseElement);
-
+ Element queryDescrElement = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
+ queryDescrElement.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
+ rdf.appendChild(queryDescrElement);
+
Element title = doc.createElementNS(IConstants.DCTERMS_NAMESPACE, IConstants.DCTERMS_PTERM_TITLE);
- responseElement.appendChild(title);
- title.setTextContent("Messages.QueryService_QUERY_RESULTS_TITLE");
+ queryDescrElement.appendChild(title);
+ title.setTextContent(Messages.getString("ResourceQuery.Title"));
+
+ Element count = doc.createElementNS(IConstants.OSLC_NAMESPACE, IConstants.OSLC_PTERM_TOTALCOUNT);
+ queryDescrElement.appendChild(count);
+ count.setTextContent(Integer.toString(results.size()));
+
+ Element rdfType = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_TYPE);
+ rdfType.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_RESOURCE, IConstants.OSLC_RESPONSEINFO);
+ queryDescrElement.appendChild(rdfType);
+
- Element rdfDescr = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
- rdf.appendChild(rdfDescr);
- rdfDescr.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
+ Element resultDescr = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
+ rdf.appendChild(resultDescr);
+ String baseUri = reqUri.split("\\?")[0];
+ resultDescr.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, baseUri);
Iterator<Map<String, RioValue>> iterator = results.iterator();
while( iterator.hasNext() ) {
Element rdfMem = doc.createElementNS(IConstants.RDFS_NAMESPACE, IConstants.RDFS_PTERM_MEMBER);
- rdfDescr.appendChild(rdfMem);
+ resultDescr.appendChild(rdfMem);
Map<String, RioValue> map = iterator.next();
RioValue uri = map.get("uri"); //$NON-NLS-1$
rdfMem.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_RESOURCE, uri.stringValue());
diff --git a/org.eclipse.lyo.rio.am/src/main/java/org/eclipse/lyo/oslc/am/resource/ResourceService.java b/org.eclipse.lyo.rio.am/src/main/java/org/eclipse/lyo/oslc/am/resource/ResourceService.java
index d28f57a..4717097 100644
--- a/org.eclipse.lyo.rio.am/src/main/java/org/eclipse/lyo/oslc/am/resource/ResourceService.java
+++ b/org.eclipse.lyo.rio.am/src/main/java/org/eclipse/lyo/oslc/am/resource/ResourceService.java
@@ -520,23 +520,33 @@ public class ResourceService extends RioBaseService {
rdf.setAttribute("xmlns:" + namespacePrefixes.get(namespace), namespace); //$NON-NLS-1$
}
- Element responseElement = doc.createElementNS(IConstants.OSLC_NAMESPACE, IConstants.OSLC_PTERM_RESPONSEINFO);
- responseElement.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
- rdf.appendChild(responseElement);
-
+ Element queryDescrElement = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
+ queryDescrElement.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
+ rdf.appendChild(queryDescrElement);
+
Element title = doc.createElementNS(IConstants.DCTERMS_NAMESPACE, IConstants.DCTERMS_PTERM_TITLE);
- responseElement.appendChild(title);
+ queryDescrElement.appendChild(title);
title.setTextContent(Messages.getString("ResourceQuery.Title"));
- Element rdfDescr = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
- rdf.appendChild(rdfDescr);
- rdfDescr.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
+ Element count = doc.createElementNS(IConstants.OSLC_NAMESPACE, IConstants.OSLC_PTERM_TOTALCOUNT);
+ queryDescrElement.appendChild(count);
+ count.setTextContent(Integer.toString(results.size()));
+
+ Element rdfType = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_TYPE);
+ rdfType.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_RESOURCE, IConstants.OSLC_RESPONSEINFO);
+ queryDescrElement.appendChild(rdfType);
+
+
+ Element resultDescr = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
+ rdf.appendChild(resultDescr);
+ String baseUri = reqUri.split("\\?")[0];
+ resultDescr.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, baseUri);
Iterator<Map<String, RioValue>> iterator = results.iterator();
while( iterator.hasNext() ) {
Element rdfMem = doc.createElementNS(IConstants.RDFS_NAMESPACE, IConstants.RDFS_PTERM_MEMBER);
- rdfDescr.appendChild(rdfMem);
+ resultDescr.appendChild(rdfMem);
Map<String, RioValue> map = iterator.next();
RioValue uri = map.get("uri"); //$NON-NLS-1$
rdfMem.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_RESOURCE, uri.stringValue());
diff --git a/org.eclipse.lyo.rio.cm/src/main/java/org/eclipse/lyo/rio/cm/changerequest/ChangeRequestService.java b/org.eclipse.lyo.rio.cm/src/main/java/org/eclipse/lyo/rio/cm/changerequest/ChangeRequestService.java
index 1215e44..9811a6c 100644
--- a/org.eclipse.lyo.rio.cm/src/main/java/org/eclipse/lyo/rio/cm/changerequest/ChangeRequestService.java
+++ b/org.eclipse.lyo.rio.cm/src/main/java/org/eclipse/lyo/rio/cm/changerequest/ChangeRequestService.java
@@ -329,23 +329,33 @@ public class ChangeRequestService extends RioBaseService {
rdf.setAttribute("xmlns:" + namespacePrefixes.get(namespace), namespace); //$NON-NLS-1$
}
- Element responseElement = doc.createElementNS(IConstants.OSLC_NAMESPACE, IConstants.OSLC_PTERM_RESPONSEINFO);
- responseElement.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
- rdf.appendChild(responseElement);
-
+ Element queryDescrElement = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
+ queryDescrElement.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
+ rdf.appendChild(queryDescrElement);
+
Element title = doc.createElementNS(IConstants.DCTERMS_NAMESPACE, IConstants.DCTERMS_PTERM_TITLE);
- responseElement.appendChild(title);
+ queryDescrElement.appendChild(title);
title.setTextContent(Messages.getString("ResourceQuery.Title"));
- Element rdfDescr = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
- rdf.appendChild(rdfDescr);
- rdfDescr.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
+ Element count = doc.createElementNS(IConstants.OSLC_NAMESPACE, IConstants.OSLC_PTERM_TOTALCOUNT);
+ queryDescrElement.appendChild(count);
+ count.setTextContent(Integer.toString(results.size()));
+
+ Element rdfType = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_TYPE);
+ rdfType.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_RESOURCE, IConstants.OSLC_RESPONSEINFO);
+ queryDescrElement.appendChild(rdfType);
+
+
+ Element resultDescr = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
+ rdf.appendChild(resultDescr);
+ String baseUri = reqUri.split("\\?")[0];
+ resultDescr.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, baseUri);
Iterator<Map<String, RioValue>> iterator = results.iterator();
while( iterator.hasNext() ) {
Element rdfMem = doc.createElementNS(IConstants.RDFS_NAMESPACE, IConstants.RDFS_PTERM_MEMBER);
- rdfDescr.appendChild(rdfMem);
+ resultDescr.appendChild(rdfMem);
Map<String, RioValue> map = iterator.next();
RioValue uri = map.get("uri"); //$NON-NLS-1$
rdfMem.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_RESOURCE, uri.stringValue());
diff --git a/org.eclipse.lyo.rio.core/src/main/java/org/eclipse/lyo/rio/core/IConstants.java b/org.eclipse.lyo.rio.core/src/main/java/org/eclipse/lyo/rio/core/IConstants.java
index c803b48..d25bbca 100644
--- a/org.eclipse.lyo.rio.core/src/main/java/org/eclipse/lyo/rio/core/IConstants.java
+++ b/org.eclipse.lyo.rio.core/src/main/java/org/eclipse/lyo/rio/core/IConstants.java
@@ -237,7 +237,9 @@ public interface IConstants extends IRioConstants {
public static final String OSLC_TERM_OAUTHACCESSTOKENURI = "oauthAccessTokenURI";
public static final String OSLC_PTERM_OAUTHACCESSTOKENURI = OSLC_PREFIX + ':' + OSLC_TERM_OAUTHACCESSTOKENURI;
public static final String OSLC_OAUTHACCESSTOKENURI = OSLC_NAMESPACE + OSLC_TERM_OAUTHACCESSTOKENURI;
-
+ public static final String OSLC_TERM_TOTALCOUNT = "totalCount";
+ public static final String OSLC_PTERM_TOTALCOUNT = OSLC_PREFIX + ':' + OSLC_TERM_TOTALCOUNT;
+ public static final String OSLC_TOTALCOUNT = OSLC_NAMESPACE + OSLC_TERM_TOTALCOUNT;
// dcterms
public static final String DCTERMS_NAMESPACE = "http://purl.org/dc/terms/";
public static final String DCTERMS_PREFIX = "dcterms";
diff --git a/org.eclipse.lyo.rio.rm/src/main/java/org/eclipse/lyo/oslc/rm/services/requirement/RequirementService.java b/org.eclipse.lyo.rio.rm/src/main/java/org/eclipse/lyo/oslc/rm/services/requirement/RequirementService.java
index 9ab1bf0..5a96a85 100644
--- a/org.eclipse.lyo.rio.rm/src/main/java/org/eclipse/lyo/oslc/rm/services/requirement/RequirementService.java
+++ b/org.eclipse.lyo.rio.rm/src/main/java/org/eclipse/lyo/oslc/rm/services/requirement/RequirementService.java
@@ -333,23 +333,33 @@ public class RequirementService extends RioBaseService {
rdf.setAttribute("xmlns:" + namespacePrefixes.get(namespace), namespace); //$NON-NLS-1$
}
- Element responseElement = doc.createElementNS(IConstants.OSLC_NAMESPACE, IConstants.OSLC_PTERM_RESPONSEINFO);
- responseElement.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
- rdf.appendChild(responseElement);
-
+ Element queryDescrElement = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
+ queryDescrElement.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
+ rdf.appendChild(queryDescrElement);
+
Element title = doc.createElementNS(IConstants.DCTERMS_NAMESPACE, IConstants.DCTERMS_PTERM_TITLE);
- responseElement.appendChild(title);
+ queryDescrElement.appendChild(title);
title.setTextContent(Messages.getString("ResourceQuery.Title"));
- Element rdfDescr = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
- rdf.appendChild(rdfDescr);
- rdfDescr.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
+ Element count = doc.createElementNS(IConstants.OSLC_NAMESPACE, IConstants.OSLC_PTERM_TOTALCOUNT);
+ queryDescrElement.appendChild(count);
+ count.setTextContent(Integer.toString(results.size()));
+
+ Element rdfType = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_TYPE);
+ rdfType.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_RESOURCE, IConstants.OSLC_RESPONSEINFO);
+ queryDescrElement.appendChild(rdfType);
+
+
+ Element resultDescr = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
+ rdf.appendChild(resultDescr);
+ String baseUri = reqUri.split("\\?")[0];
+ resultDescr.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, baseUri);
Iterator<Map<String, RioValue>> iterator = results.iterator();
while( iterator.hasNext() ) {
Element rdfMem = doc.createElementNS(IConstants.RDFS_NAMESPACE, IConstants.RDFS_PTERM_MEMBER);
- rdfDescr.appendChild(rdfMem);
+ resultDescr.appendChild(rdfMem);
Map<String, RioValue> map = iterator.next();
RioValue uri = map.get("uri"); //$NON-NLS-1$
rdfMem.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_RESOURCE, uri.stringValue());
diff --git a/org.eclipse.lyo.rio.rm/src/main/java/org/eclipse/lyo/oslc/rm/services/requirementcollection/RequirementCollectionService.java b/org.eclipse.lyo.rio.rm/src/main/java/org/eclipse/lyo/oslc/rm/services/requirementcollection/RequirementCollectionService.java
index 3ac3876..a300cfc 100644
--- a/org.eclipse.lyo.rio.rm/src/main/java/org/eclipse/lyo/oslc/rm/services/requirementcollection/RequirementCollectionService.java
+++ b/org.eclipse.lyo.rio.rm/src/main/java/org/eclipse/lyo/oslc/rm/services/requirementcollection/RequirementCollectionService.java
@@ -299,23 +299,33 @@ public class RequirementCollectionService extends RioBaseService {
rdf.setAttribute("xmlns:" + namespacePrefixes.get(namespace), namespace); //$NON-NLS-1$
}
- Element responseElement = doc.createElementNS(IConstants.OSLC_NAMESPACE, IConstants.OSLC_PTERM_RESPONSEINFO);
- responseElement.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
- rdf.appendChild(responseElement);
-
+ Element queryDescrElement = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
+ queryDescrElement.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
+ rdf.appendChild(queryDescrElement);
+
Element title = doc.createElementNS(IConstants.DCTERMS_NAMESPACE, IConstants.DCTERMS_PTERM_TITLE);
- responseElement.appendChild(title);
- title.setTextContent("Messages.QueryService_QUERY_RESULTS_TITLE");
+ queryDescrElement.appendChild(title);
+ title.setTextContent(Messages.getString("ResourceQuery.Title"));
+
+ Element count = doc.createElementNS(IConstants.OSLC_NAMESPACE, IConstants.OSLC_PTERM_TOTALCOUNT);
+ queryDescrElement.appendChild(count);
+ count.setTextContent(Integer.toString(results.size()));
+
+ Element rdfType = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_TYPE);
+ rdfType.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_RESOURCE, IConstants.OSLC_RESPONSEINFO);
+ queryDescrElement.appendChild(rdfType);
+
- Element rdfDescr = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
- rdf.appendChild(rdfDescr);
- rdfDescr.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, reqUri);
+ Element resultDescr = doc.createElementNS(IConstants.RDF_NAMESPACE, IConstants.RDF_TYPE_PTERM_DESCRIPTION);
+ rdf.appendChild(resultDescr);
+ String baseUri = reqUri.split("\\?")[0];
+ resultDescr.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_ABOUT, baseUri);
Iterator<Map<String, RioValue>> iterator = results.iterator();
while( iterator.hasNext() ) {
Element rdfMem = doc.createElementNS(IConstants.RDFS_NAMESPACE, IConstants.RDFS_PTERM_MEMBER);
- rdfDescr.appendChild(rdfMem);
+ resultDescr.appendChild(rdfMem);
Map<String, RioValue> map = iterator.next();
RioValue uri = map.get("uri"); //$NON-NLS-1$
rdfMem.setAttributeNS(IConstants.RDF_NAMESPACE, IConstants.RDF_PTERM_RESOURCE, uri.stringValue());