* @version $Revision:$
*/
-public class AcquisitionClient extends AbstractPoxServiceClientImpl<AbstractCommonList, AcquisitionProxy> {
+public class AcquisitionClient extends AbstractCommonListPoxServiceClientImpl<AcquisitionProxy> {
public static final String SERVICE_NAME = "acquisitions";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
return AcquisitionProxy.class;
}
- /*
- * Proxied service calls.
- */
-
- /**
- * @return
- * @see org.collectionspace.hello.client.IntakeProxy#getIntake()
- */
- public ClientResponse<AbstractCommonList> readList() {
- return getProxy().readList();
- }
-
- /**
- * @param csid
- * @return
- * @see org.collectionspace.hello.client.IntakeProxy#getIntake(java.lang.String)
- */
- @Override
- public ClientResponse<String> read(String csid) {
- return getProxy().read(csid);
- }
}
@Path(AcquisitionClient.SERVICE_PATH_PROXY)
@Produces({"application/xml"})
@Consumes({"application/xml"})
-public interface AcquisitionProxy extends CollectionSpacePoxProxy<AbstractCommonList> {
- @GET
- ClientResponse<AbstractCommonList> readList();
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<AbstractCommonList> readIncludeDeleted(
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<AbstractCommonList> keywordSearchIncludeDeleted(
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
+public interface AcquisitionProxy extends CollectionSpaceCommonListPoxProxy {
+
}
import org.collectionspace.services.acquisition.AcquisitionSourceList;
import org.collectionspace.services.acquisition.OwnerList;
import org.jboss.resteasy.client.ClientResponse;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
import org.testng.Assert;
import org.testng.annotations.Test;
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = true;
if(iterateThroughList && logger.isDebugEnabled()){
- List<AbstractCommonList.ListItem> items =
- list.getListItem();
- int i = 0;
- for(AbstractCommonList.ListItem item : items){
- List<Element> elList = item.getAny();
- StringBuilder elementStrings = new StringBuilder();
- for(Element el : elList) {
- Node textEl = el.getFirstChild();
- elementStrings.append("["+el.getNodeName()+":"+((textEl!=null)?textEl.getNodeValue():"NULL")+"] ");
- }
- logger.debug(testName + ": list-item[" + i + "]: "+elementStrings.toString());
- i++;
- }
+ ListItemsInAbstractCommonList(list, logger, testName);
}
}
-
+
// Failure outcomes
// None at present.
--- /dev/null
+package org.collectionspace.services.client;\r
+\r
+import org.collectionspace.services.jaxb.AbstractCommonList;\r
+import org.jboss.resteasy.client.ClientResponse;\r
+\r
+public abstract class AbstractCommonListPoxServiceClientImpl<P \r
+ extends CollectionSpaceCommonListPoxProxy> extends\r
+ AbstractPoxServiceClientImpl<AbstractCommonList, P> {\r
+\r
+ /*\r
+ * Proxied service calls.\r
+ */\r
+ \r
+ /**\r
+ * @return\r
+ * @see org.collectionspace.hello.client.IntakeProxy#getIntake()\r
+ */\r
+ public ClientResponse<AbstractCommonList> readList() {\r
+ return getProxy().readList();\r
+ }\r
+\r
+ /**\r
+ * @param csid\r
+ * @return\r
+ * @see org.collectionspace.hello.client.IntakeProxy#getIntake(java.lang.String)\r
+ */\r
+ @Override\r
+ public ClientResponse<String> read(String csid) {\r
+ return getProxy().read(csid);\r
+ }\r
+}\r
--- /dev/null
+package org.collectionspace.services.client;\r
+\r
+import javax.ws.rs.GET;\r
+import javax.ws.rs.Produces;\r
+import javax.ws.rs.QueryParam;\r
+\r
+import org.collectionspace.services.client.workflow.WorkflowClient;\r
+import org.collectionspace.services.jaxb.AbstractCommonList;\r
+import org.jboss.resteasy.client.ClientResponse;\r
+\r
+public interface CollectionSpaceCommonListPoxProxy extends CollectionSpacePoxProxy<AbstractCommonList> {\r
+ @GET\r
+ ClientResponse<AbstractCommonList> readList();\r
+ \r
+ @Override\r
+ @GET\r
+ @Produces({"application/xml"})\r
+ ClientResponse<AbstractCommonList> readIncludeDeleted(\r
+ @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);\r
+\r
+ @Override\r
+ @GET\r
+ @Produces({"application/xml"})\r
+ ClientResponse<AbstractCommonList> keywordSearchIncludeDeleted(\r
+ @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,\r
+ @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);\r
+\r
+}\r
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
import javax.activation.MimetypesFileTypeMap;
import javax.ws.rs.core.Response;
return result;
}
+
+ protected void ListItemsInAbstractCommonList(
+ AbstractCommonList list, Logger logger, String testName) {
+ List<AbstractCommonList.ListItem> items =
+ list.getListItem();
+ int i = 0;
+ for(AbstractCommonList.ListItem item : items){
+ List<Element> elList = item.getAny();
+ StringBuilder elementStrings = new StringBuilder();
+ for(Element el : elList) {
+ Node textEl = el.getFirstChild();
+ elementStrings.append("["+el.getNodeName()+":"+((textEl!=null)?textEl.getNodeValue():"NULL")+"] ");
+ }
+ logger.debug(testName + ": list-item[" + i + "]: "+elementStrings.toString());
+ i++;
+ }
+ }
+
+ protected static String ListItemGetCSID(AbstractCommonList.ListItem item) {
+ List<Element> elList = item.getAny();
+ for(Element el : elList) {
+ if("csid".equalsIgnoreCase(el.getNodeName())) {
+ Node textEl = el.getFirstChild();
+ return textEl.getNodeValue();
+ }
+ }
+ return null;
+ }
+
+
/* Use this to keep track of resources to delete */
protected List<String> allResourceIdsCreated = new ArrayList<String>();
/* Use this to track authority items */
return result;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
+ */
+ @Override
+ protected AbstractCommonList getAbstractCommonList(
+ ClientResponse<AbstractCommonList> response) {
+ return response.getEntity(AbstractCommonList.class);
+ }
+
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
//
</service:uriPath>-->
<service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
<service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.report.nuxeo.ReportDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>name</service:element>
+ <service:xpath>name</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
<service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.report.nuxeo.ReportValidatorHandler</service:validatorHandler>
<service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
<service:classname>org.collectionspace.services.report.nuxeo.ReportPostInitHandler</service:classname>
<service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
<service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.acquisition.nuxeo.AcquisitionDocumentModelHandler</service:documentHandler>
<service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.loanin.nuxeo.AcquisitionDocumentModelHandler</service:classname>
<service:params>
- <service:SchemaName>acquisition</service:SchemaName>
- <service:DublinCoreTitle>acquisition</service:DublinCoreTitle>
- <service:SummaryFields>acquisitionReferenceNumber|acquisitionSources|owners|uri|csid</service:SummaryFields>
- <service:AbstractCommonListClassname />
- <service:CommonListItemClassname />
- <service:ListResultsItemMethodName>getAcquisitionListItem</service:ListResultsItemMethodName>
<service:ListResultsFields>
<service:ListResultField>
<service:element>acquisitionReferenceNumber</service:element>
\r
import java.lang.reflect.Method;\r
import java.util.ArrayList;\r
+import java.util.GregorianCalendar;\r
import java.util.HashMap;\r
import java.util.Iterator;\r
import java.util.List;\r
import org.collectionspace.services.common.service.DocHandlerParams;\r
import org.collectionspace.services.common.service.ServiceBindingType;\r
import org.collectionspace.services.common.context.MultipartServiceContext;\r
+import org.collectionspace.services.common.datetime.DateTimeFormatUtils;\r
import org.collectionspace.services.common.document.DocumentException;\r
import org.collectionspace.services.common.document.DocumentWrapper;\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
private final Logger logger = LoggerFactory.getLogger(this.getClass());\r
\r
private AbstractCommonList commonList;\r
+ \r
+ protected static final int NUM_STANDARD_LIST_RESULT_FIELDS = 3;\r
\r
@Override\r
public AbstractCommonList getCommonPartList() {\r
throw new UnsupportedOperationException();\r
}\r
\r
- //Laramie20110427 Restored this method since it correctly grabs all params from DocHandlerParams.\r
- @Override\r
- public AbstractCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {\r
- String classname = getDocHandlerParams().getAbstractCommonListClassname();\r
- if (Tools.isBlank(classname)){\r
- return extractCommonPartListPATRICK(wrapDoc);\r
- }\r
-\r
+ // This is an old hack restored by Laramie in confusion about how the \r
+ // replacement model works. Will be removed ASAP.\r
+ public AbstractCommonList extractCommonPartListLaramieHACK(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {\r
String label = getServiceContext().getCommonPartLabel();\r
AbstractCommonList commonList = createAbstractCommonListImpl();\r
//LC extractPagingInfo((commonList), wrapDoc);\r
return commonList;\r
}\r
\r
- // Laramie20110427 I renamed this method, and restored the method of the same name above.\r
- // this makes the AbstractCommonList descendents as specified in DocHandlerParams\r
- // get pulled in correctly. XPath search works.\r
- // And I commented out the @Override annotation:\r
- //@Override\r
- public AbstractCommonList extractCommonPartListPATRICK(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {\r
- //String label = getServiceContext().getCommonPartLabel();\r
+ @Override\r
+ public AbstractCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {\r
+ String classname = getDocHandlerParams().getAbstractCommonListClassname();\r
+ if (!Tools.isBlank(classname)){\r
+ return extractCommonPartListLaramieHACK(wrapDoc);\r
+ }\r
\r
String commonSchema = getServiceContext().getCommonPartLabel();\r
CommonList commonList = new CommonList();\r
extractPagingInfo(commonList, wrapDoc);\r
- List<ListResultField> resultsFields = getListItemsArray(); //Lookup in tenant-bindings.xml\r
- int nFields = resultsFields.size()+2;\r
+ List<ListResultField> resultsFields = getListItemsArray();\r
+ int nFields = resultsFields.size()+NUM_STANDARD_LIST_RESULT_FIELDS;\r
String fields[] = new String[nFields];\r
fields[0] = "csid";\r
fields[1] = "uri";\r
- for(int i=2;i<nFields;i++) {\r
- ListResultField field = resultsFields.get(i-2); \r
+ fields[2] = "updatedAt";\r
+ for(int i=NUM_STANDARD_LIST_RESULT_FIELDS;i<nFields;i++) {\r
+ ListResultField field = resultsFields.get(i-NUM_STANDARD_LIST_RESULT_FIELDS); \r
fields[i]=field.getElement();\r
}\r
commonList.setFieldsReturned(fields);\r
HashMap<String,String> item = new HashMap<String,String>();\r
while(iter.hasNext()){\r
DocumentModel docModel = iter.next();\r
- String id = NuxeoUtils.getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());\r
+ String id = NuxeoUtils.getCsid(docModel);\r
item.put(fields[0], id);\r
String uri = getServiceContextPath() + id;\r
item.put(fields[1], uri);\r
+ GregorianCalendar cal = (GregorianCalendar)\r
+ docModel.getProperty(COLLECTIONSPACE_CORE_SCHEMA,\r
+ COLLECTIONSPACE_CORE_UPDATED_AT);\r
+ String updatedAt = DateTimeFormatUtils.formatAsISO8601Timestamp(cal);\r
+ item.put(fields[2], updatedAt);\r
+\r
for (ListResultField field : resultsFields ){\r
String schema = field.getSchema();\r
if(schema==null || schema.trim().isEmpty())\r
return commonList;\r
}\r
\r
+ // TODO - get rid of this if we can - appears to be unused.\r
@Override\r
public String getQProperty(String prop) throws DocumentException {\r
return getDocHandlerParams().getSchemaName() + ":" + prop;\r
* @param wrapDoc the wrap doc\r
* @throws Exception the exception\r
*/\r
+ // TODO - Remove this? \r
+ // This look like it is never used in a sensible way. It just stuffs a static\r
+ // String that matches the service name into a bogus field.\r
protected void fillDublinCoreObject(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {\r
DocHandlerParams.Params docHandlerParams = null;\r
try {\r
*/
package org.collectionspace.services.client;
-//import org.collectionspace.services.common.context.ServiceContext;
-import javax.ws.rs.QueryParam;
-
-import org.collectionspace.services.report.ReportsCommonList;
+import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
/**
* @version $Revision:$
* FIXME: http://issues.collectionspace.org/browse/CSPACE-1684
*/
-public class ReportClient extends AbstractPoxServiceClientImpl<ReportsCommonList, ReportProxy> {
+public class ReportClient extends AbstractCommonListPoxServiceClientImpl<ReportProxy> {
public static final String SERVICE_NAME = "reports";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
return ReportProxy.class;
}
- /*
- * Proxied service calls.
- */
-
- /**
- * @return
- * @see org.collectionspace.services.client.ReportProxy#getReport()
- */
- public ClientResponse<ReportsCommonList> readList() {
- return getProxy().readList();
- }
-
/**
* @return
* @see org.collectionspace.services.client.ReportProxy#getReport()
*/
- public ClientResponse<ReportsCommonList> readListFiltered(
+ public ClientResponse<AbstractCommonList> readListFiltered(
String docType, String mode) {
return getProxy().readListFiltered(docType, mode);
}
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
-import org.collectionspace.services.report.ReportsCommonList;
-import org.collectionspace.services.client.workflow.WorkflowClient;
-
+import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
/**
@Path("/reports/")
@Produces({"application/xml;charset=UTF-8"})
@Consumes({"application/xml"})
-public interface ReportProxy extends CollectionSpacePoxProxy<ReportsCommonList> {
- /**
- * Read list.
- *
- * @return the client response
- */
- @GET
- @Produces({"application/xml"})
- ClientResponse<ReportsCommonList> readList();
-
+public interface ReportProxy extends CollectionSpaceCommonListPoxProxy {
+
@GET
@Produces({"application/xml"})
- ClientResponse<ReportsCommonList> readListFiltered(
+ ClientResponse<AbstractCommonList> readListFiltered(
@QueryParam(IQueryManager.SEARCH_TYPE_DOCTYPE) String docType,
@QueryParam(IQueryManager.SEARCH_TYPE_INVCOATION_MODE) String mode);
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<ReportsCommonList> readIncludeDeleted(
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<ReportsCommonList> keywordSearchIncludeDeleted(
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
}
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.ReportClient;
import org.collectionspace.services.report.ReportsCommon;
-import org.collectionspace.services.report.ReportsCommonList;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
return new ReportClient();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(ReportsCommonList.class);
- }
-
// @Override
// protected PoxPayloadOut createInstance(String identifier) {
// PoxPayloadOut multipart = createReportInstance(identifier);
// Submit the request to the service and store the response.
ReportClient client = new ReportClient();
- ClientResponse<ReportsCommonList> res = client.readList();
- ReportsCommonList list = res.getEntity();
+ ClientResponse<AbstractCommonList> res = client.readList();
+ AbstractCommonList list = res.getEntity();
int statusCode = res.getStatus();
// Check the status code of the response: does it match
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- List<ReportsCommonList.ReportListItem> items =
- list.getReportListItem();
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = false;
if (iterateThroughList && logger.isDebugEnabled()) {
- int i = 0;
- for (ReportsCommonList.ReportListItem item : items) {
- logger.debug(testName + ": list-item[" + i + "] csid="
- + item.getCsid());
- logger.debug(testName + ": list-item[" + i + "] name="
- + item.getName());
- logger.debug(testName + ": list-item[" + i + "] outputMIME="
- + item.getOutputMIME());
- logger.debug(testName + ": list-item[" + i + "] URI="
- + item.getUri());
- i++;
- }
+ ListItemsInAbstractCommonList(list, logger, testName);
}
}
// Submit the request to the service and store the response.
ReportClient client = new ReportClient();
- ClientResponse<ReportsCommonList> res = client.readListFiltered(
+ ClientResponse<AbstractCommonList> res = client.readListFiltered(
testDocType, "single");
- ReportsCommonList list = res.getEntity();
+ AbstractCommonList list = res.getEntity();
int statusCode = res.getStatus();
// Check the status code of the response: does it match
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- List<ReportsCommonList.ReportListItem> items =
- list.getReportListItem();
+ List<AbstractCommonList.ListItem> items =
+ list.getListItem();
// We must find the basic one we created
boolean fFoundBaseItem = false;
- for (ReportsCommonList.ReportListItem item : items) {
- if(knownResourceId.equalsIgnoreCase(item.getCsid())) {
+ for (AbstractCommonList.ListItem item : items) {
+ if(knownResourceId.equalsIgnoreCase(ListItemGetCSID(item))) {
fFoundBaseItem = true;
break;
}
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- items = list.getReportListItem();
+ items = list.getListItem();
// We must NOT find the basic one we created
- for (ReportsCommonList.ReportListItem item : items) {
- Assert.assertNotSame(item.getCsid(), knownResourceId,
+ for (AbstractCommonList.ListItem item : items) {
+ Assert.assertNotSame(ListItemGetCSID(item), knownResourceId,
"readListFiltered(\"Intake\", \"single\") incorrectly returned base item");
}
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- items = list.getReportListItem();
+ items = list.getListItem();
// We must NOT find the basic one we created
- for (ReportsCommonList.ReportListItem item : items) {
- Assert.assertNotSame(item.getCsid(), knownResourceId,
+ for (AbstractCommonList.ListItem item : items) {
+ Assert.assertNotSame(ListItemGetCSID(item), knownResourceId,
"readListFiltered(\""+testDocType+"\", \"group\") incorrectly returned base item");
}
}
</xs:complexType>
</xs:element>
- <!-- This is the base class for paginated lists -->
- <xs:complexType name="abstractCommonList">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:complexType>
-
- <!-- report records, as in nuxeo repository -->
- <xs:element name="reports-common-list">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="abstractCommonList">
- <xs:sequence>
- <xs:element name="report-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="name" type="xs:string"
- minOccurs="1" />
- <xs:element name="outputMIME" type="xs:string"
- minOccurs="1" />
- <xs:element name="forDocType" type="xs:string"
- minOccurs="1" />
- <xs:element name="supportsSingleDoc" type="xs:boolean"
- minOccurs="1" />
- <xs:element name="supportsDocList" type="xs:boolean"
- minOccurs="1" />
- <xs:element name="supportsGroup" type="xs:boolean"
- minOccurs="1" />
- <!-- uri to retrive report details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
</xs:schema>
*/
package org.collectionspace.services.report.nuxeo;
-import java.util.Iterator;
-import java.util.List;
-
-import org.collectionspace.services.ReportJAXBSchema;
-import org.collectionspace.services.common.document.DocumentWrapper;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.report.ReportsCommon;
-import org.collectionspace.services.report.ReportsCommonList;
-import org.collectionspace.services.report.ReportsCommonList.ReportListItem;
-import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
/**
* ReportDocumentModelHandler
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class ReportDocumentModelHandler
- extends RemoteDocumentModelHandlerImpl<ReportsCommon, ReportsCommonList> {
-
- /** The logger. */
- private final Logger logger = LoggerFactory.getLogger(ReportDocumentModelHandler.class);
- /**
- * report is used to stash JAXB object to use when handle is called
- * for Action.CREATE, Action.UPDATE or Action.GET
- */
- private ReportsCommon report;
- /**
- * reportList is stashed when handle is called
- * for ACTION.GET_ALL
- */
- private ReportsCommonList reportList;
-
-
- /**
- * getCommonPart get associated report
- * @return
- */
- @Override
- public ReportsCommon getCommonPart() {
- return report;
- }
-
- /**
- * setCommonPart set associated report
- * @param report
- */
- @Override
- public void setCommonPart(ReportsCommon report) {
- this.report = report;
- }
-
- /**
- * getCommonPartList get associated report (for index/GET_ALL)
- * @return
- */
- @Override
- public ReportsCommonList getCommonPartList() {
- return reportList;
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
- */
- @Override
- public void setCommonPartList(ReportsCommonList reportList) {
- this.reportList = reportList;
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public ReportsCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
- throws Exception {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#fillCommonPart(java.lang.Object, org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public void fillCommonPart(ReportsCommon reportObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public ReportsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- ReportsCommonList coList = this.extractPagingInfo(new ReportsCommonList(), wrapDoc);
- AbstractCommonList commonList = (AbstractCommonList) coList;
- commonList.setFieldsReturned("name|uri|csid");
- List<ReportsCommonList.ReportListItem> list = coList.getReportListItem();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- String label = getServiceContext().getCommonPartLabel();
- while(iter.hasNext()){
- DocumentModel docModel = iter.next();
- ReportListItem ilistItem = new ReportListItem();
- ilistItem.setName((String) docModel.getProperty(label,
- ReportJAXBSchema.NAME));
- String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
- ilistItem.setUri(getServiceContextPath() + id);
- ilistItem.setCsid(id);
- list.add(ilistItem);
- }
-
- return coList;
- }
+public class ReportDocumentModelHandler extends DocHandlerBase<ReportsCommon> {
- /**
- * getQProperty converts the given property to qualified schema property
- * @param prop
- * @return
- */
- @Override
- public String getQProperty(String prop) {
- return ReportConstants.NUXEO_SCHEMA_NAME + ":" + prop;
- }
-
}