]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-3332, CSPACE-3784 Updated reports to use DocHandlerBase. Cleaned up that class...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Wed, 20 Jul 2011 21:07:42 +0000 (21:07 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Wed, 20 Jul 2011 21:07:42 +0000 (21:07 +0000)
13 files changed:
services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionClient.java
services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionProxy.java
services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java
services/client/src/main/java/org/collectionspace/services/client/AbstractCommonListPoxServiceClientImpl.java [new file with mode: 0644]
services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceCommonListPoxProxy.java [new file with mode: 0644]
services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java
services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java
services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java
services/report/client/src/main/java/org/collectionspace/services/client/ReportProxy.java
services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java
services/report/jaxb/src/main/resources/reports-common.xsd
services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java

index 6a4c74ccf17b7045c29fa2e3b535ca01f44fe4f1..77fff67dfd6037b9668ceb27689131402e05c2d0 100644 (file)
@@ -8,7 +8,7 @@ import org.collectionspace.services.jaxb.AbstractCommonList;
 
  * @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;
@@ -31,25 +31,4 @@ public class AcquisitionClient extends AbstractPoxServiceClientImpl<AbstractComm
                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);
-    }
 }
index c37c86a0d786a086d1e988fe387309478221cc97..e85fad7dd6e9dca4ed13c84d1c35dfcc4eed1711 100644 (file)
@@ -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<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 {
+       
 }
index ce89d07804af7e24693189f044e7b98da2c80e45..2bc8e65ce23e5dcc8405549b0cafc8c6c5c29e23 100644 (file)
@@ -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<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.
 
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 (file)
index 0000000..507c0cf
--- /dev/null
@@ -0,0 +1,31 @@
+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
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 (file)
index 0000000..8c3f46b
--- /dev/null
@@ -0,0 +1,28 @@
+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
index f48155d362e685f41e91dd279ce1d6e9ee509c16..d9423b90d78128dad2951bdc43b9e6e1ca9b6c43 100644 (file)
@@ -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<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 */
@@ -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<AbstractCommonList> response) {
+        return response.getEntity(AbstractCommonList.class);
+    }
+
     // ---------------------------------------------------------------
     // CRUD tests : CREATE tests
     //
index ceb3e322fc54f553d1dbdd5dc7c6b573327e779c..91f2a87611cb33b389c2d5301e47d3948c4bbf2c 100644 (file)
             </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>
index 3421583a1607f02dd89633c3a3a478c52e7c0c31..cbafe1030023bb2ba46ac86a8c930f7c26ef8482 100755 (executable)
@@ -25,6 +25,7 @@ package org.collectionspace.services.nuxeo.client.java;
 \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
@@ -35,6 +36,7 @@ import org.collectionspace.services.common.service.ListResultField;
 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
@@ -62,6 +64,8 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
     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
@@ -136,14 +140,9 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
         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
@@ -160,24 +159,24 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
         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
@@ -185,10 +184,16 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
                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
@@ -206,6 +211,7 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
         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
@@ -226,6 +232,9 @@ public abstract class DocHandlerBase<T> extends RemoteDocumentModelHandlerImpl<T
      * @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
index d919d307a9dcda22b7f775631819ec89f17d2b4b..9f5c7429b2cb110f110da7a8012b17d42b5f7748 100644 (file)
  */
 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<ReportsCommonList, ReportProxy> {
+public class ReportClient extends AbstractCommonListPoxServiceClientImpl<ReportProxy> {
 
     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<ReportsCommonList
                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);
     }
index 908e78a613a9922bee8438ee7c7537305136b3b7..68f236aedf99e749c7b3214579281a04d528cbc4 100644 (file)
@@ -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<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);    
 }
index 78c6ef25ce88c426ed5a21ce1920b0511aa7a079..673b14f47edd5ced955972d46da88ee06a78f12d 100644 (file)
@@ -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<AbstractCommonList> 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<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
@@ -295,23 +285,10 @@ public class ReportServiceTest extends AbstractServiceTestImpl {
                 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);
         }
     }
 
@@ -326,9 +303,9 @@ public class ReportServiceTest extends AbstractServiceTestImpl {
 
        // 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
@@ -340,12 +317,12 @@ public class ReportServiceTest extends AbstractServiceTestImpl {
                        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;
                        }
@@ -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");
                }
     }
index b5637a625d2c4bdff89c549500cb1bfefe5f7eff..61493144d700e36f0d55cc36703fc08c83df283e 100644 (file)
                </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>
 
index 36ec574e1c604013b9aa63a7e1ce5114592f3890..1f739c1b1e953373517a0336c3b7e13e9171b567 100644 (file)
  */
 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<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;
-    }
 }