From 67da2d83d2bd90d4efa199aed9a49e460908775b Mon Sep 17 00:00:00 2001 From: Patrick Schmitz Date: Wed, 20 Jul 2011 21:07:42 +0000 Subject: [PATCH] CSPACE-3332, CSPACE-3784 Updated reports to use DocHandlerBase. Cleaned up that class to begin removing the hacks left in an earlier revision. Added some support utilities to the test framework to ease the debugging of list results, and fetching CSID values from list result items. Added new base definitions for the proxy interfaces and client classes of services that AbstractCommonList in list results. Changed the Acquisition handler to use the proper model for DocHandlerBase. --- .../services/client/AcquisitionClient.java | 23 +--- .../services/client/AcquisitionProxy.java | 18 +-- .../client/test/AcquisitionServiceTest.java | 18 +-- ...bstractCommonListPoxServiceClientImpl.java | 31 +++++ .../CollectionSpaceCommonListPoxProxy.java | 28 +++++ .../client/test/AbstractServiceTestImpl.java | 41 ++++++ .../tenants/tenant-bindings-proto.xml | 17 +-- .../nuxeo/client/java/DocHandlerBase.java | 49 +++++--- .../services/client/ReportClient.java | 21 +--- .../services/client/ReportProxy.java | 30 +---- .../client/test/ReportServiceTest.java | 53 +++----- .../src/main/resources/reports-common.xsd | 44 ------- .../nuxeo/ReportDocumentModelHandler.java | 119 +----------------- 13 files changed, 168 insertions(+), 324 deletions(-) create mode 100644 services/client/src/main/java/org/collectionspace/services/client/AbstractCommonListPoxServiceClientImpl.java create mode 100644 services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceCommonListPoxProxy.java diff --git a/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionClient.java b/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionClient.java index 6a4c74ccf..77fff67df 100644 --- a/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionClient.java +++ b/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionClient.java @@ -8,7 +8,7 @@ import org.collectionspace.services.jaxb.AbstractCommonList; * @version $Revision:$ */ -public class AcquisitionClient extends AbstractPoxServiceClientImpl { +public class AcquisitionClient extends AbstractCommonListPoxServiceClientImpl { 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; @@ -31,25 +31,4 @@ public class AcquisitionClient extends AbstractPoxServiceClientImpl readList() { - return getProxy().readList(); - } - - /** - * @param csid - * @return - * @see org.collectionspace.hello.client.IntakeProxy#getIntake(java.lang.String) - */ - @Override - public ClientResponse read(String csid) { - return getProxy().read(csid); - } } diff --git a/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionProxy.java b/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionProxy.java index c37c86a0d..e85fad7dd 100644 --- a/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionProxy.java +++ b/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionProxy.java @@ -16,20 +16,6 @@ import org.jboss.resteasy.client.ClientResponse; @Path(AcquisitionClient.SERVICE_PATH_PROXY) @Produces({"application/xml"}) @Consumes({"application/xml"}) -public interface AcquisitionProxy extends CollectionSpacePoxProxy { - @GET - ClientResponse readList(); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse readIncludeDeleted( - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse keywordSearchIncludeDeleted( - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); +public interface AcquisitionProxy extends CollectionSpaceCommonListPoxProxy { + } diff --git a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java index ce89d0780..2bc8e65ce 100644 --- a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java +++ b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java @@ -38,8 +38,6 @@ import org.collectionspace.services.acquisition.AcquisitionDateList; 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; @@ -416,23 +414,11 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // Optionally output additional data about list members for debugging. boolean iterateThroughList = true; if(iterateThroughList && logger.isDebugEnabled()){ - List items = - list.getListItem(); - int i = 0; - for(AbstractCommonList.ListItem item : items){ - List 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. diff --git a/services/client/src/main/java/org/collectionspace/services/client/AbstractCommonListPoxServiceClientImpl.java b/services/client/src/main/java/org/collectionspace/services/client/AbstractCommonListPoxServiceClientImpl.java new file mode 100644 index 000000000..507c0cf30 --- /dev/null +++ b/services/client/src/main/java/org/collectionspace/services/client/AbstractCommonListPoxServiceClientImpl.java @@ -0,0 +1,31 @@ +package org.collectionspace.services.client; + +import org.collectionspace.services.jaxb.AbstractCommonList; +import org.jboss.resteasy.client.ClientResponse; + +public abstract class AbstractCommonListPoxServiceClientImpl

extends + AbstractPoxServiceClientImpl { + + /* + * Proxied service calls. + */ + + /** + * @return + * @see org.collectionspace.hello.client.IntakeProxy#getIntake() + */ + public ClientResponse readList() { + return getProxy().readList(); + } + + /** + * @param csid + * @return + * @see org.collectionspace.hello.client.IntakeProxy#getIntake(java.lang.String) + */ + @Override + public ClientResponse read(String csid) { + return getProxy().read(csid); + } +} diff --git a/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceCommonListPoxProxy.java b/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceCommonListPoxProxy.java new file mode 100644 index 000000000..8c3f46bed --- /dev/null +++ b/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceCommonListPoxProxy.java @@ -0,0 +1,28 @@ +package org.collectionspace.services.client; + +import javax.ws.rs.GET; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; + +import org.collectionspace.services.client.workflow.WorkflowClient; +import org.collectionspace.services.jaxb.AbstractCommonList; +import org.jboss.resteasy.client.ClientResponse; + +public interface CollectionSpaceCommonListPoxProxy extends CollectionSpacePoxProxy { + @GET + ClientResponse readList(); + + @Override + @GET + @Produces({"application/xml"}) + ClientResponse readIncludeDeleted( + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); + + @Override + @GET + @Produces({"application/xml"}) + ClientResponse keywordSearchIncludeDeleted( + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); + +} diff --git a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java index f48155d36..d9423b90d 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java +++ b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java @@ -47,6 +47,8 @@ import org.slf4j.LoggerFactory; 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; @@ -93,6 +95,36 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements return result; } + + protected void ListItemsInAbstractCommonList( + AbstractCommonList list, Logger logger, String testName) { + List items = + list.getListItem(); + int i = 0; + for(AbstractCommonList.ListItem item : items){ + List 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 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 allResourceIdsCreated = new ArrayList(); /* Use this to track authority items */ @@ -116,6 +148,15 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements return result; } + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) + */ + @Override + protected AbstractCommonList getAbstractCommonList( + ClientResponse response) { + return response.getEntity(AbstractCommonList.class); + } + // --------------------------------------------------------------- // CRUD tests : CREATE tests // diff --git a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml index ceb3e322f..91f2a8761 100644 --- a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml +++ b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml @@ -867,6 +867,16 @@ --> default-domain org.collectionspace.services.report.nuxeo.ReportDocumentModelHandler + + + + + name + name + + + + org.collectionspace.services.report.nuxeo.ReportValidatorHandler org.collectionspace.services.report.nuxeo.ReportPostInitHandler @@ -1575,14 +1585,7 @@ default-domain org.collectionspace.services.acquisition.nuxeo.AcquisitionDocumentModelHandler - org.collectionspace.services.loanin.nuxeo.AcquisitionDocumentModelHandler - acquisition - acquisition - acquisitionReferenceNumber|acquisitionSources|owners|uri|csid - - - getAcquisitionListItem acquisitionReferenceNumber diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java index 3421583a1..cbafe1030 100755 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java @@ -25,6 +25,7 @@ package org.collectionspace.services.nuxeo.client.java; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -35,6 +36,7 @@ import org.collectionspace.services.common.service.ListResultField; import org.collectionspace.services.common.service.DocHandlerParams; import org.collectionspace.services.common.service.ServiceBindingType; import org.collectionspace.services.common.context.MultipartServiceContext; +import org.collectionspace.services.common.datetime.DateTimeFormatUtils; import org.collectionspace.services.common.document.DocumentException; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.jaxb.AbstractCommonList; @@ -62,6 +64,8 @@ public abstract class DocHandlerBase extends RemoteDocumentModelHandlerImpl extends RemoteDocumentModelHandlerImpl wrapDoc) throws Exception { - String classname = getDocHandlerParams().getAbstractCommonListClassname(); - if (Tools.isBlank(classname)){ - return extractCommonPartListPATRICK(wrapDoc); - } - + // This is an old hack restored by Laramie in confusion about how the + // replacement model works. Will be removed ASAP. + public AbstractCommonList extractCommonPartListLaramieHACK(DocumentWrapper wrapDoc) throws Exception { String label = getServiceContext().getCommonPartLabel(); AbstractCommonList commonList = createAbstractCommonListImpl(); //LC extractPagingInfo((commonList), wrapDoc); @@ -160,24 +159,24 @@ public abstract class DocHandlerBase extends RemoteDocumentModelHandlerImpl wrapDoc) throws Exception { - //String label = getServiceContext().getCommonPartLabel(); + @Override + public AbstractCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { + String classname = getDocHandlerParams().getAbstractCommonListClassname(); + if (!Tools.isBlank(classname)){ + return extractCommonPartListLaramieHACK(wrapDoc); + } String commonSchema = getServiceContext().getCommonPartLabel(); CommonList commonList = new CommonList(); extractPagingInfo(commonList, wrapDoc); - List resultsFields = getListItemsArray(); //Lookup in tenant-bindings.xml - int nFields = resultsFields.size()+2; + List resultsFields = getListItemsArray(); + int nFields = resultsFields.size()+NUM_STANDARD_LIST_RESULT_FIELDS; String fields[] = new String[nFields]; fields[0] = "csid"; fields[1] = "uri"; - for(int i=2;i extends RemoteDocumentModelHandlerImpl item = new HashMap(); while(iter.hasNext()){ DocumentModel docModel = iter.next(); - String id = NuxeoUtils.getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); + String id = NuxeoUtils.getCsid(docModel); item.put(fields[0], id); String uri = getServiceContextPath() + id; item.put(fields[1], uri); + GregorianCalendar cal = (GregorianCalendar) + docModel.getProperty(COLLECTIONSPACE_CORE_SCHEMA, + COLLECTIONSPACE_CORE_UPDATED_AT); + String updatedAt = DateTimeFormatUtils.formatAsISO8601Timestamp(cal); + item.put(fields[2], updatedAt); + for (ListResultField field : resultsFields ){ String schema = field.getSchema(); if(schema==null || schema.trim().isEmpty()) @@ -206,6 +211,7 @@ public abstract class DocHandlerBase extends RemoteDocumentModelHandlerImpl extends RemoteDocumentModelHandlerImpl wrapDoc) throws Exception { DocHandlerParams.Params docHandlerParams = null; try { diff --git a/services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java b/services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java index d919d307a..9f5c7429b 100644 --- a/services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java +++ b/services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java @@ -26,10 +26,7 @@ */ 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; /** @@ -38,7 +35,7 @@ import org.jboss.resteasy.client.ClientResponse; * @version $Revision:$ * FIXME: http://issues.collectionspace.org/browse/CSPACE-1684 */ -public class ReportClient extends AbstractPoxServiceClientImpl { +public class ReportClient extends AbstractCommonListPoxServiceClientImpl { public static final String SERVICE_NAME = "reports"; public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; @@ -59,23 +56,11 @@ public class ReportClient extends AbstractPoxServiceClientImpl readList() { - return getProxy().readList(); - } - /** * @return * @see org.collectionspace.services.client.ReportProxy#getReport() */ - public ClientResponse readListFiltered( + public ClientResponse readListFiltered( String docType, String mode) { return getProxy().readListFiltered(docType, mode); } diff --git a/services/report/client/src/main/java/org/collectionspace/services/client/ReportProxy.java b/services/report/client/src/main/java/org/collectionspace/services/client/ReportProxy.java index 908e78a61..68f236aed 100644 --- a/services/report/client/src/main/java/org/collectionspace/services/client/ReportProxy.java +++ b/services/report/client/src/main/java/org/collectionspace/services/client/ReportProxy.java @@ -32,9 +32,7 @@ import javax.ws.rs.Path; 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; /** @@ -44,32 +42,12 @@ import org.jboss.resteasy.client.ClientResponse; @Path("/reports/") @Produces({"application/xml;charset=UTF-8"}) @Consumes({"application/xml"}) -public interface ReportProxy extends CollectionSpacePoxProxy { - /** - * Read list. - * - * @return the client response - */ - @GET - @Produces({"application/xml"}) - ClientResponse readList(); - +public interface ReportProxy extends CollectionSpaceCommonListPoxProxy { + @GET @Produces({"application/xml"}) - ClientResponse readListFiltered( + ClientResponse readListFiltered( @QueryParam(IQueryManager.SEARCH_TYPE_DOCTYPE) String docType, @QueryParam(IQueryManager.SEARCH_TYPE_INVCOATION_MODE) String mode); - @Override - @GET - @Produces({"application/xml"}) - ClientResponse readIncludeDeleted( - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse keywordSearchIncludeDeleted( - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); } diff --git a/services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java b/services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java index 78c6ef25c..673b14f47 100644 --- a/services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java +++ b/services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java @@ -34,7 +34,6 @@ import org.collectionspace.services.client.PoxPayloadIn; 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; @@ -74,15 +73,6 @@ public class ReportServiceTest extends AbstractServiceTestImpl { return new ReportClient(); } - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) - */ - @Override - protected AbstractCommonList getAbstractCommonList( - ClientResponse response) { - return response.getEntity(ReportsCommonList.class); - } - // @Override // protected PoxPayloadOut createInstance(String identifier) { // PoxPayloadOut multipart = createReportInstance(identifier); @@ -282,8 +272,8 @@ public class ReportServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. ReportClient client = new ReportClient(); - ClientResponse res = client.readList(); - ReportsCommonList list = res.getEntity(); + ClientResponse res = client.readList(); + AbstractCommonList list = res.getEntity(); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -295,23 +285,10 @@ public class ReportServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - List 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); } } @@ -326,9 +303,9 @@ public class ReportServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. ReportClient client = new ReportClient(); - ClientResponse res = client.readListFiltered( + ClientResponse 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 @@ -340,12 +317,12 @@ public class ReportServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - List items = - list.getReportListItem(); + List 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; } @@ -367,10 +344,10 @@ public class ReportServiceTest extends AbstractServiceTestImpl { 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"); } @@ -388,10 +365,10 @@ public class ReportServiceTest extends AbstractServiceTestImpl { 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"); } } diff --git a/services/report/jaxb/src/main/resources/reports-common.xsd b/services/report/jaxb/src/main/resources/reports-common.xsd index b5637a625..61493144d 100644 --- a/services/report/jaxb/src/main/resources/reports-common.xsd +++ b/services/report/jaxb/src/main/resources/reports-common.xsd @@ -53,49 +53,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java b/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java index 36ec574e1..1f739c1b1 100644 --- a/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java +++ b/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java @@ -23,21 +23,8 @@ */ 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 @@ -45,109 +32,7 @@ import org.slf4j.LoggerFactory; * $LastChangedRevision: $ * $LastChangedDate: $ */ -public class ReportDocumentModelHandler - extends RemoteDocumentModelHandlerImpl { - - /** 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 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 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 wrapDoc) throws Exception { - ReportsCommonList coList = this.extractPagingInfo(new ReportsCommonList(), wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("name|uri|csid"); - List list = coList.getReportListItem(); - Iterator 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 { - /** - * getQProperty converts the given property to qualified schema property - * @param prop - * @return - */ - @Override - public String getQProperty(String prop) { - return ReportConstants.NUXEO_SCHEMA_NAME + ":" + prop; - } - } -- 2.47.3