From: Aron Roberts Date: Thu, 21 Jul 2011 02:20:43 +0000 (+0000) Subject: CSPACE-4172,CSPACE-3332: Revised Loanout service to return CommonList format for... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=925cdd304ab7f57e3ef436e60bcabcb36e65528e;p=tmp%2Fjakarta-migration.git CSPACE-4172,CSPACE-3332: Revised Loanout service to return CommonList format for list results. --- diff --git a/services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutClient.java b/services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutClient.java index 6818e5ffc..4968940b7 100644 --- a/services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutClient.java +++ b/services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutClient.java @@ -16,47 +16,34 @@ */ 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 { - 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 { + + 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 getProxyClass() { - // TODO Auto-generated method stub - return LoanoutProxy.class; - } - - /* - * Proxied service calls - */ + @Override + public Class getProxyClass() { + // TODO Auto-generated method stub + return LoanoutProxy.class; + } - /** - * @return - * @see org.collectionspace.services.client.LoanoutProxy#getLoanout() - */ - public ClientResponse readList() { - return getProxy().readList(); - } } diff --git a/services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutProxy.java b/services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutProxy.java index 76bfa8fbe..4a622c4d9 100644 --- a/services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutProxy.java +++ b/services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutProxy.java @@ -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 { - // List - @GET - @Produces({"application/xml"}) - 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 LoanoutProxy extends CollectionSpaceCommonListPoxProxy { } diff --git a/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java b/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java index bb3975981..8d8a993f8 100644 --- a/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java +++ b/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java @@ -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 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 res = client.readList(); - LoansoutCommonList 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 @@ -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 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); } } diff --git a/services/loanout/jaxb/src/main/resources/loansout-common.xsd b/services/loanout/jaxb/src/main/resources/loansout-common.xsd index 16147eaa7..6f69e019f 100644 --- a/services/loanout/jaxb/src/main/resources/loansout-common.xsd +++ b/services/loanout/jaxb/src/main/resources/loansout-common.xsd @@ -64,44 +64,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutDocumentModelHandler.java b/services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutDocumentModelHandler.java index fa9daec83..cb9c88a12 100644 --- a/services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutDocumentModelHandler.java +++ b/services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutDocumentModelHandler.java @@ -23,146 +23,14 @@ */ 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 { - - /** 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 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 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 wrapDoc) throws Exception { - LoansoutCommonList coList = extractPagingInfo(new LoansoutCommonList(), wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("loanOutNumber|borrower|loanReturnDate|uri|csid"); - List list = coList.getLoanoutListItem(); - Iterator 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 { }