*/
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();
- }
}
+/**
+ * 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 {
}
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;
@Override
protected AbstractCommonList getAbstractCommonList(
ClientResponse<AbstractCommonList> response) {
- return response.getEntity(LoansoutCommonList.class);
+ return response.getEntity(AbstractCommonList.class);
}
// ---------------------------------------------------------------
// 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
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);
}
}
<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>
*/
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> {
}