]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-4172,CSPACE-3332: Revised Loanout service to return CommonList format for...
authorAron Roberts <aron@socrates.berkeley.edu>
Thu, 21 Jul 2011 02:20:43 +0000 (02:20 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Thu, 21 Jul 2011 02:20:43 +0000 (02:20 +0000)
services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutClient.java
services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutProxy.java
services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java
services/loanout/jaxb/src/main/resources/loansout-common.xsd
services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutDocumentModelHandler.java

index 6818e5ffc65605f9b75b12d81ad33bfe97a5543f..4968940b7e47f1144bf87f5f1dff6b050fce0334 100644 (file)
  */
 package org.collectionspace.services.client;
 
-import org.jboss.resteasy.client.ClientResponse;
-import org.collectionspace.services.loanout.LoansoutCommonList;
-
 /**
  * LoanoutClient.java
  *
  * $LastChangedRevision$
  * $LastChangedDate$
  */
-public class LoanoutClient extends AbstractPoxServiceClientImpl<LoansoutCommonList, LoanoutProxy> {
-       public static final String SERVICE_NAME = "loansout";
-       public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;       
-       public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
-       public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";     
-       public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
+public class LoanoutClient extends AbstractCommonListPoxServiceClientImpl<LoanoutProxy> {
+
+    public static final String SERVICE_NAME = "loansout";
+    public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
+    public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
+    public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
+    public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
 
-       @Override
-       public String getServiceName() {
-               return SERVICE_NAME;
-       }
+    @Override
+    public String getServiceName() {
+        return SERVICE_NAME;
+    }
 
     @Override
     public String getServicePathComponent() {
         return SERVICE_PATH_COMPONENT;
     }
 
-       @Override
-       public Class<LoanoutProxy> getProxyClass() {
-               // TODO Auto-generated method stub
-               return LoanoutProxy.class;
-       }
-
-       /*
-     * Proxied service calls
-     */
+    @Override
+    public Class<LoanoutProxy> getProxyClass() {
+        // TODO Auto-generated method stub
+        return LoanoutProxy.class;
+    }
 
-    /**
-     * @return
-     * @see org.collectionspace.services.client.LoanoutProxy#getLoanout()
-     */
-    public ClientResponse<LoansoutCommonList> readList() {
-        return getProxy().readList();
-    }    
 }
index 76bfa8fbec9f1e09b75bf17cdf41d70c76bf0603..4a622c4d9a5c532e7e5fd690a868bdd1fa73ba7f 100644 (file)
@@ -1,38 +1,41 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.collectionspace.services.client;
 
-import org.jboss.resteasy.client.ClientResponse;
 import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
-import org.collectionspace.services.loanout.LoansoutCommonList;
-import org.collectionspace.services.client.workflow.WorkflowClient;
 
 
 /**
- * @version $Revision$
+ * LoanoutProxy.java
+ *
+ * $LastChangedRevision$
+ * $LastChangedDate$
  */
 @Path("/loansout/")
 @Produces({"application/xml"})
 @Consumes({"application/xml"})
-public interface LoanoutProxy extends CollectionSpacePoxProxy<LoansoutCommonList> {    
-    // List
-    @GET
-    @Produces({"application/xml"})
-    ClientResponse<LoansoutCommonList> readList();
-
-    @Override
-       @GET
-    @Produces({"application/xml"})
-    ClientResponse<LoansoutCommonList> readIncludeDeleted(
-            @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-            
-    @Override
-    @GET
-    @Produces({"application/xml"})
-    ClientResponse<LoansoutCommonList> keywordSearchIncludeDeleted(
-           @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
-            @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
+public interface LoanoutProxy extends CollectionSpaceCommonListPoxProxy {
 }
index bb3975981d63e55b2a55f4f91baf3b5336572499..8d8a993f875514c673b112fbe914beace8d6bdfb 100644 (file)
@@ -36,7 +36,6 @@ import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.loanout.LoanedObjectStatusGroup;
 import org.collectionspace.services.loanout.LoanedObjectStatusGroupList;
 import org.collectionspace.services.loanout.LoansoutCommon;
-import org.collectionspace.services.loanout.LoansoutCommonList;
 
 import org.jboss.resteasy.client.ClientResponse;
 
@@ -75,7 +74,7 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
     @Override
     protected AbstractCommonList getAbstractCommonList(
             ClientResponse<AbstractCommonList> response) {
-        return response.getEntity(LoansoutCommonList.class);
+        return response.getEntity(AbstractCommonList.class);
     }
 
     // ---------------------------------------------------------------
@@ -372,8 +371,8 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
 
         // Submit the request to the service and store the response.
         LoanoutClient client = new LoanoutClient();
-        ClientResponse<LoansoutCommonList> res = client.readList();
-        LoansoutCommonList 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
@@ -386,20 +385,9 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
-        boolean iterateThroughList = false;
-        if (iterateThroughList && logger.isDebugEnabled()) {
-            List<LoansoutCommonList.LoanoutListItem> items =
-                    list.getLoanoutListItem();
-            int i = 0;
-            for (LoansoutCommonList.LoanoutListItem item : items) {
-                logger.debug(testName + ": list-item[" + i + "] csid="
-                        + item.getCsid());
-                logger.debug(testName + ": list-item[" + i + "] loanOutNumber="
-                        + item.getLoanOutNumber());
-                logger.debug(testName + ": list-item[" + i + "] URI="
-                        + item.getUri());
-                i++;
-            }
+        boolean iterateThroughList = true;
+        if(iterateThroughList && logger.isDebugEnabled()){
+               ListItemsInAbstractCommonList(list, logger, testName);
         }
 
     }
index 16147eaa749a30bfcb734358385a292bfc534e4a..6f69e019fa3a07e1d9c3fc2165cecd07b192940e 100644 (file)
             <xs:element name="loanedObjectStatusNote" type="xs:string"/>
         </xs:sequence>
     </xs:complexType>
-    <!-- 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>
     
-    <!-- loansout records, as in nuxeo repository -->
-    <xs:element name="loansout-common-list">
-        <xs:complexType>
-            <xs:complexContent>
-                <xs:extension base="abstractCommonList">                    
-                    <xs:sequence>
-                        <xs:element name="loanout-list-item" maxOccurs="unbounded">
-                            <xs:complexType>
-                                <xs:sequence>
-                                    <xs:element name="loanOutNumber" type="xs:string"
-                                        minOccurs="1" />
-                                    <xs:element name="borrower" type="xs:string"
-                                        minOccurs="1" />
-                                    <xs:element name="loanReturnDate" type="xs:string"
-                                        minOccurs="1" />
-                                    <!-- uri to retrive 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 fa9daec830974dcd977cf0352ac442abbfcf3e49..cb9c88a12eec1dfdfb3f4e8a1a2086781e954507 100644 (file)
  */
 package org.collectionspace.services.loanout.nuxeo;
 
-import java.util.Iterator;
-import java.util.List;
-
-import org.collectionspace.services.LoanoutJAXBSchema;
-import org.collectionspace.services.common.document.DocumentWrapper;
-import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.loanout.LoansoutCommon;
-import org.collectionspace.services.loanout.LoansoutCommonList;
-import org.collectionspace.services.loanout.LoansoutCommonList.LoanoutListItem;
-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;
 
 /**
  * The Class LoanoutDocumentModelHandler.
  */
 public class LoanoutDocumentModelHandler
-        extends RemoteDocumentModelHandlerImpl<LoansoutCommon, LoansoutCommonList> {
-
-    /** The logger. */
-    private final Logger logger = LoggerFactory.getLogger(LoanoutDocumentModelHandler.class);
-    
-    /** The loanout. */
-    private LoansoutCommon loanout;
-    
-    /** The loanout list. */
-    private LoansoutCommonList loanoutList;
-
-
-    /**
-     * Gets the common part.
-     *
-     * @return the common part
-     */
-    @Override
-    public LoansoutCommon getCommonPart() {
-        return loanout;
-    }
-
-    /**
-     * Sets the common part.
-     *
-     * @param loanout the new common part
-     */
-    @Override
-    public void setCommonPart(LoansoutCommon loanout) {
-        this.loanout = loanout;
-    }
-
-    /**
-     * Gets the common part list.
-     *
-     * @return the common part list
-     */
-    @Override
-    public LoansoutCommonList getCommonPartList() {
-        return loanoutList;
-    }
-
-    /**
-     * Sets the common part list.
-     *
-     * @param loanoutList the new common part list
-     */
-    @Override
-    public void setCommonPartList(LoansoutCommonList loanoutList) {
-        this.loanoutList = loanoutList;
-    }
-
-    /**
-     * Extract common part.
-     *
-     * @param wrapDoc the wrap doc
-     * @return the loansout common
-     * @throws Exception the exception
-     */
-    @Override
-    public LoansoutCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
-            throws Exception {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * Fill common part.
-     *
-     * @param loanoutObject the loanout object
-     * @param wrapDoc the wrap doc
-     * @throws Exception the exception
-     */
-    @Override
-    public void fillCommonPart(LoansoutCommon loanoutObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * Extract common part list.
-     *
-     * @param wrapDoc the wrap doc
-     * @return the loansout common list
-     * @throws Exception the exception
-     */
-    @Override
-    public LoansoutCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
-        LoansoutCommonList coList = extractPagingInfo(new LoansoutCommonList(), wrapDoc);
-        AbstractCommonList commonList = (AbstractCommonList) coList;
-        commonList.setFieldsReturned("loanOutNumber|borrower|loanReturnDate|uri|csid");
-        List<LoansoutCommonList.LoanoutListItem> list = coList.getLoanoutListItem();
-        Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
-        String label = getServiceContext().getCommonPartLabel();
-        while(iter.hasNext()){
-            DocumentModel docModel = iter.next();
-            LoanoutListItem ilistItem = new LoanoutListItem();
-            ilistItem.setLoanOutNumber((String) docModel.getProperty(label,
-                    LoanoutJAXBSchema.LOAN_OUT_NUMBER));
-            ilistItem.setBorrower((String) docModel.getProperty(label,
-                    LoanoutJAXBSchema.BORROWER));
-            ilistItem.setLoanReturnDate((String) docModel.getProperty(label,
-                    LoanoutJAXBSchema.LOAN_RETURN_DATE));
-            String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
-            ilistItem.setUri(getServiceContextPath() + id);
-            ilistItem.setCsid(id);
-            list.add(ilistItem);
-        }
-
-        return coList;
-    }
-
-    /**
-     * Gets the q property.
-     *
-     * @param prop the prop
-     * @return the q property
-     */
-    @Override
-    public String getQProperty(String prop) {
-        return LoanoutConstants.NUXEO_SCHEMA_NAME + ":" + prop;
-    }
+        extends DocHandlerBase<LoansoutCommon> {
  
 }