import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.acquisition.AcquisitionsCommon;
return new AcquisitionClient();
}
- /* (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
// ---------------------------------------------------------------
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Optionally output additional data about list members for debugging.
- boolean iterateThroughList = true;
- if(iterateThroughList && logger.isDebugEnabled()){
- ListItemsInAbstractCommonList(list, logger, testName);
+ if(logger.isTraceEnabled()){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
}
- 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 */
--- /dev/null
+package org.collectionspace.services.common;\r
+\r
+import java.util.List;\r
+\r
+import org.collectionspace.services.jaxb.AbstractCommonList;\r
+import org.slf4j.Logger;\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.Node;\r
+\r
+public class AbstractCommonListUtils {\r
+ public static void ListItemsInAbstractCommonList(\r
+ AbstractCommonList list, Logger logger, String testName) {\r
+ List<AbstractCommonList.ListItem> items =\r
+ list.getListItem();\r
+ int i = 0;\r
+ for(AbstractCommonList.ListItem item : items){\r
+ List<Element> elList = item.getAny();\r
+ StringBuilder elementStrings = new StringBuilder();\r
+ for(Element el : elList) {\r
+ Node textEl = el.getFirstChild();\r
+ elementStrings.append("["+el.getNodeName()+":"+((textEl!=null)?textEl.getNodeValue():"NULL")+"] ");\r
+ }\r
+ logger.debug(testName + ": list-item[" + i + "]: "+elementStrings.toString());\r
+ i++;\r
+ }\r
+ }\r
+\r
+ public static String ListItemGetCSID(AbstractCommonList.ListItem item) {\r
+ return ListItemGetElementValue(item, "csid");\r
+ }\r
+\r
+ public static String ListItemGetElementValue(AbstractCommonList.ListItem item,\r
+ String elName) {\r
+ List<Element> elList = item.getAny();\r
+ for(Element el : elList) {\r
+ if(elName.equalsIgnoreCase(el.getNodeName())) {\r
+ Node textEl = el.getFirstChild();\r
+ return textEl.getNodeValue();\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+\r
+\r
+\r
+}\r
*/
package org.collectionspace.services.nuxeo.client.java;
-import java.io.InputStream;
import java.util.Collection;
+import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.workflow.WorkflowClient;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.authorization_mgt.AuthorizationCommon;
import org.collectionspace.services.common.context.JaxRsContext;
import org.collectionspace.services.common.context.MultipartServiceContext;
import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.datetime.DateTimeFormatUtils;
import org.collectionspace.services.common.document.BadRequestException;
-import org.collectionspace.services.common.document.DocumentNotFoundException;
import org.collectionspace.services.common.document.DocumentUtils;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentHandler.Action;
import org.collectionspace.services.common.security.SecurityUtils;
-import org.collectionspace.services.common.security.UnauthorizedException;
import org.collectionspace.services.common.service.ObjectPartType;
import org.collectionspace.services.common.storage.jpa.JpaStorageUtils;
import org.collectionspace.services.common.vocabulary.RefNameUtils;
import org.dom4j.Element;
-import org.jboss.resteasy.plugins.providers.multipart.InputPart;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.DocumentModelList;
import org.nuxeo.ecm.core.api.model.Property;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.dom4j.Document;
/**
* RemoteDocumentModelHandler
throws Exception {
//check if this is an xml part
if (part.getMediaType().equals(MediaType.APPLICATION_XML_TYPE)) {
-// Document document = DocumentUtils.parseDocument(payload, partMeta,
-// false /*don't validate*/);
Element element = part.getElementBody();
Map<String, Object> objectProps = DocumentUtils.parseProperties(partMeta, element, ctx);
if (action == Action.UPDATE) {
protected static String getXPathStringValue(DocumentModel docModel, String schema, String xpath) {
xpath = schema+":"+xpath;
try {
- return (String)docModel.getPropertyValue(xpath);
+ Object value = docModel.getPropertyValue(xpath);
+ String returnVal = null;
+ if(value==null) {
+ // Nothing to do - leave returnVal null
+ } else if(value instanceof GregorianCalendar) {
+ returnVal = DateTimeFormatUtils.formatAsISO8601Timestamp((GregorianCalendar)value);
+ } else {
+ returnVal = value.toString();
+ }
+ return returnVal;
} catch(PropertyException pe) {
throw new RuntimeException("Problem retrieving property {"+xpath+"}. Bad XPath spec?"
+pe.getLocalizedMessage());
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.intake.EntryMethodList;
import org.collectionspace.services.intake.FieldCollectionEventNameList;
import org.collectionspace.services.intake.CurrentLocationGroup;
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = true;
if (iterateThroughList && logger.isDebugEnabled()) {
- ListItemsInAbstractCommonList(list, logger, testName);
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.loanin.LenderGroup;
import org.collectionspace.services.loanin.LenderGroupList;
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = true;
if(iterateThroughList && logger.isDebugEnabled()){
- ListItemsInAbstractCommonList(list, logger, testName);
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.loanout.LoanedObjectStatusGroup;
import org.collectionspace.services.loanout.LoanedObjectStatusGroupList;
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = true;
if(iterateThroughList && logger.isDebugEnabled()){
- ListItemsInAbstractCommonList(list, logger, testName);
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
package org.collectionspace.services.client;
+import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
-import org.collectionspace.services.movement.MovementsCommonList;
/**
* MovementClient.java
* $LastChangedDate$
*
*/
-public class MovementClient extends AbstractPoxServiceClientImpl<MovementsCommonList, MovementProxy> {
+public class MovementClient extends AbstractCommonListPoxServiceClientImpl<MovementProxy> {
public static final String SERVICE_NAME = "movements";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
return MovementProxy.class;
}
- /*
- * Proxied service calls
- */
-
- /**
- * @return
- * @see org.collectionspace.services.client.MovementProxy#readList()
- */
- public ClientResponse<MovementsCommonList> readList() {
- return getProxy().readList();
- }
/**
* @param sortFieldName
* @return
* @see org.collectionspace.services.client.MovementProxy#readList(java.lang.String)
*/
- public ClientResponse<MovementsCommonList> readListSortedBy(String sortFieldName) {
+ public ClientResponse<AbstractCommonList> readListSortedBy(String sortFieldName) {
return getProxy().readListSortedBy(sortFieldName);
}
* @return
* @see org.collectionspace.services.client.MovementProxy#keywordSearchSortedBy(java.lang.String, java.lang.String)
*/
- public ClientResponse<MovementsCommonList> keywordSearchSortedBy(String keywords, String sortFieldName) {
+ public ClientResponse<AbstractCommonList> keywordSearchSortedBy(String keywords, String sortFieldName) {
return getProxy().keywordSearchSortedBy(keywords, sortFieldName);
}
}
import javax.ws.rs.QueryParam;
import org.collectionspace.services.client.workflow.WorkflowClient;
-import org.collectionspace.services.movement.MovementsCommonList;
+import org.collectionspace.services.jaxb.AbstractCommonList;
/**
* MovementProxy.java
@Path("/movements/")
@Produces("application/xml")
@Consumes("application/xml")
-public interface MovementProxy extends CollectionSpacePoxProxy<MovementsCommonList> {
+public interface MovementProxy extends CollectionSpaceCommonListPoxProxy {
- // List
- @GET
- @Produces({"application/xml"})
- ClientResponse<MovementsCommonList> readList();
-
// Sorted list
@GET
@Produces({"application/xml"})
- ClientResponse<MovementsCommonList> readListSortedBy(
+ ClientResponse<AbstractCommonList> readListSortedBy(
@QueryParam(IClientQueryParams.SORT_BY_PARAM) String sortFieldName);
@Override
@GET
@Produces({"application/xml"})
- ClientResponse<MovementsCommonList> readIncludeDeleted(
+ ClientResponse<AbstractCommonList> readIncludeDeleted(
@QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
@Override
@GET
@Produces({"application/xml"})
- ClientResponse<MovementsCommonList> keywordSearchIncludeDeleted(
+ ClientResponse<AbstractCommonList> keywordSearchIncludeDeleted(
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
@QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
@GET
@Produces({"application/xml"})
- ClientResponse<MovementsCommonList> keywordSearchSortedBy(
+ ClientResponse<AbstractCommonList> keywordSearchSortedBy(
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
@QueryParam(IClientQueryParams.SORT_BY_PARAM) String sortFieldName);
}
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.MovementClient;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.movement.MovementsCommon;
-import org.collectionspace.services.movement.MovementsCommonList;
import org.collectionspace.services.movement.MovementMethodsList;
import org.jboss.resteasy.client.ClientResponse;
return new MovementClient();
}
- /* (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(MovementsCommonList.class);
- }
-
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
- ClientResponse<MovementsCommonList> res = client.readList();
- MovementsCommonList 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 = true;
- if(iterateThroughList && logger.isDebugEnabled()){
- List<MovementsCommonList.MovementListItem> items =
- list.getMovementListItem();
- int i = 0;
- for(MovementsCommonList.MovementListItem item : items){
- logger.debug(testName + ": list-item[" + i + "] csid=" +
- item.getCsid());
- logger.debug(testName + ": list-item[" + i + "] movementReferenceNumber=" +
- item.getMovementReferenceNumber());
- logger.debug(testName + ": list-item[" + i + "] locationDate=" +
- item.getLocationDate());
- logger.debug(testName + ": list-item[" + i + "] URI=" +
- item.getUri());
- i++;
- }
+ if(logger.isTraceEnabled()){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
-
}
// Failure outcomes
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.movement.MovementsCommon;
-import org.collectionspace.services.movement.MovementsCommonList;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
private List<String> movementIdsCreated = new ArrayList<String>();
private final String SORT_FIELD_SEPARATOR = ", ";
private final Locale LOCALE = Locale.US;
+ private final String LOCATION_DATE_EL_NAME = "locationDate";
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
if (logger.isDebugEnabled()) {
logger.debug("Sorting on field name=" + sortFieldName);
}
- MovementsCommonList list = readSortedList(sortFieldName);
- List<MovementsCommonList.MovementListItem> items =
- list.getMovementListItem();
+ AbstractCommonList list = readSortedList(sortFieldName);
+ List<AbstractCommonList.ListItem> items =
+ list.getListItem();
ArrayList<String> values = new ArrayList<String>();
Collator localeSpecificCollator = Collator.getInstance(LOCALE);
int i = 0;
- for (MovementsCommonList.MovementListItem item : items) {
+ for (AbstractCommonList.ListItem item : items) {
// Because movementNote is not currently a summary field
// (returned in summary list items), we will need to verify
// sort order by retrieving full records, using the
// IDs provided in the summary list items. amd then retriving
// the value of that field from each of those records.
- MovementsCommon movement = read(item.getCsid());
+ MovementsCommon movement = read(AbstractCommonListUtils.ListItemGetCSID(item));
values.add(i, movement.getMovementNote());
if (logger.isDebugEnabled()) {
logger.debug("list-item[" + i + "] movementNote=" + values.get(i));
if (logger.isDebugEnabled()) {
logger.debug("Sorting on field name=" + sortFieldName);
}
- MovementsCommonList list = keywordSearchSortedBy(TEST_SPECIFIC_KEYWORD, sortFieldName);
- List<MovementsCommonList.MovementListItem> items =
- list.getMovementListItem();
+ AbstractCommonList list = keywordSearchSortedBy(TEST_SPECIFIC_KEYWORD, sortFieldName);
+ List<AbstractCommonList.ListItem> items =
+ list.getListItem();
ArrayList<String> values = new ArrayList<String>();
Collator localeSpecificCollator = Collator.getInstance(LOCALE);
int i = 0;
- for (MovementsCommonList.MovementListItem item : items) {
+ for (AbstractCommonList.ListItem item : items) {
// Because movementNote is not currently a summary field
// (returned in summary list items), we will need to verify
// sort order by retrieving full records, using the
// IDs provided in the summary list items. amd then retriving
// the value of that field from each of those records.
- MovementsCommon movement = read(item.getCsid());
+ MovementsCommon movement = read(AbstractCommonListUtils.ListItemGetCSID(item));
values.add(i, movement.getMovementNote());
if (logger.isDebugEnabled()) {
logger.debug("list-item[" + i + "] movementNote=" + values.get(i));
if (logger.isDebugEnabled()) {
logger.debug("Sorting on field name=" + sortFieldName);
}
- MovementsCommonList list = readSortedList(sortFieldName);
- List<MovementsCommonList.MovementListItem> items =
- list.getMovementListItem();
+ AbstractCommonList list = readSortedList(sortFieldName);
+ List<AbstractCommonList.ListItem> items =
+ list.getListItem();
ArrayList<String> values = new ArrayList<String>();
Collator localeSpecificCollator = Collator.getInstance(LOCALE);
int i = 0;
- for (MovementsCommonList.MovementListItem item : items) {
+ for (AbstractCommonList.ListItem item : items) {
// Because movementNote is not currently a summary field
// (returned in summary list items), we will need to verify
// sort order by retrieving full records, using the
// IDs provided in the summary list items. amd then retriving
// the value of that field from each of those records.
- MovementsCommon movement = read(item.getCsid());
+ MovementsCommon movement = read(AbstractCommonListUtils.ListItemGetCSID(item));
values.add(i, movement.getMovementNote());
if (logger.isDebugEnabled()) {
logger.debug("list-item[" + i + "] movementNote=" + values.get(i));
if (logger.isDebugEnabled()) {
logger.debug("Sorting on field name=" + sortFieldName);
}
- MovementsCommonList list = readSortedList(sortFieldName);
- List<MovementsCommonList.MovementListItem> items =
- list.getMovementListItem();
+ AbstractCommonList list = readSortedList(sortFieldName);
+ List<AbstractCommonList.ListItem> items =
+ list.getListItem();
ArrayList<String> values = new ArrayList<String>();
Comparator<String> comparator = String.CASE_INSENSITIVE_ORDER;
int i = 0;
- for (MovementsCommonList.MovementListItem item : items) {
- values.add(i, item.getLocationDate());
+ for (AbstractCommonList.ListItem item : items) {
+ String locDate =
+ AbstractCommonListUtils.ListItemGetElementValue(item, LOCATION_DATE_EL_NAME);
+ values.add(i, locDate);
if (logger.isDebugEnabled()) {
logger.debug("list-item[" + i + "] locationDate=" + values.get(i));
}
if (logger.isDebugEnabled()) {
logger.debug("Sorting on field name=" + sortFieldName);
}
- MovementsCommonList list = readSortedList(sortFieldName);
- List<MovementsCommonList.MovementListItem> items =
- list.getMovementListItem();
+ AbstractCommonList list = readSortedList(sortFieldName);
+ List<AbstractCommonList.ListItem> items =
+ list.getListItem();
ArrayList<String> values = new ArrayList<String>();
Comparator<String> comparator = String.CASE_INSENSITIVE_ORDER;
int i = 0;
- for (MovementsCommonList.MovementListItem item : items) {
- values.add(i, item.getLocationDate());
+ for (AbstractCommonList.ListItem item : items) {
+ String locDate =
+ AbstractCommonListUtils.ListItemGetElementValue(item, LOCATION_DATE_EL_NAME);
+ values.add(i, locDate);
if (logger.isDebugEnabled()) {
logger.debug("list-item[" + i + "] locationDate=" + values.get(i));
}
logger.debug("Sorting on field names=" + firstSortFieldName + " and " + secondSortFieldName);
}
String sortExpression = firstSortFieldName + SORT_FIELD_SEPARATOR + secondSortFieldName;
- MovementsCommonList list = readSortedList(sortExpression);
- List<MovementsCommonList.MovementListItem> items =
- list.getMovementListItem();
+ AbstractCommonList list = readSortedList(sortExpression);
+ List<AbstractCommonList.ListItem> items =
+ list.getListItem();
ArrayList<String> firstFieldValues = new ArrayList<String>();
ArrayList<String> secondFieldValues = new ArrayList<String>();
Collator localeSpecificCollator = Collator.getInstance(LOCALE);
Comparator<String> comparator = String.CASE_INSENSITIVE_ORDER;
int i = 0;
- for (MovementsCommonList.MovementListItem item : items) {
+ for (AbstractCommonList.ListItem item : items) {
// Because movementNote is not currently a summary field
// (returned in summary list items), we will need to verify
// sort order by retrieving full records, using the
// IDs provided in the summary list items. amd then retriving
// the value of that field from each of those records.
- MovementsCommon movement = read(item.getCsid());
+ MovementsCommon movement = read(AbstractCommonListUtils.ListItemGetCSID(item));
firstFieldValues.add(i, movement.getMovementNote());
secondFieldValues.add(i, movement.getLocationDate());
if (logger.isDebugEnabled()) {
logger.debug("Sorting on field names=" + firstSortFieldName + " and " + secondSortFieldName);
}
String sortExpression = firstSortFieldName + SORT_FIELD_SEPARATOR + secondSortFieldName;
- MovementsCommonList list = readSortedList(sortExpression);
- List<MovementsCommonList.MovementListItem> items =
- list.getMovementListItem();
+ AbstractCommonList list = readSortedList(sortExpression);
+ List<AbstractCommonList.ListItem> items =
+ list.getListItem();
ArrayList<String> firstFieldValues = new ArrayList<String>();
ArrayList<String> secondFieldValues = new ArrayList<String>();
Collator localeSpecificCollator = Collator.getInstance(LOCALE);
Comparator<String> comparator = String.CASE_INSENSITIVE_ORDER;
int i = 0;
- for (MovementsCommonList.MovementListItem item : items) {
+ for (AbstractCommonList.ListItem item : items) {
// Because movementNote is not currently a summary field
// (returned in summary list items), we will need to verify
// sort order by retrieving full records, using the
// IDs provided in the summary list items. amd then retriving
// the value of that field from each of those records.
- MovementsCommon movement = read(item.getCsid());
+ MovementsCommon movement = read(AbstractCommonListUtils.ListItemGetCSID(item));
firstFieldValues.add(i, movement.getLocationDate());
secondFieldValues.add(i, movement.getMovementNote());
if (logger.isDebugEnabled()) {
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
final String EMPTY_SORT_FIELD_NAME = "";
- ClientResponse<MovementsCommonList> res =
+ ClientResponse<AbstractCommonList> res =
client.readListSortedBy(EMPTY_SORT_FIELD_NAME);
int statusCode = res.getStatus();
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
- ClientResponse<MovementsCommonList> res =
+ ClientResponse<AbstractCommonList> res =
client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE);
int statusCode = res.getStatus();
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
final String INVALID_SORT_ORDER_IDENTIFIER = "NO_DIRECTION";
- ClientResponse<MovementsCommonList> res =
+ ClientResponse<AbstractCommonList> res =
client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE
+ " " + INVALID_SORT_ORDER_IDENTIFIER);
int statusCode = res.getStatus();
return multipart;
}
- private MovementsCommonList readSortedList(String sortFieldName) throws Exception {
+ private AbstractCommonList readSortedList(String sortFieldName) throws Exception {
String testName = "readSortedList";
testSetup(STATUS_OK, ServiceRequestType.READ);
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
- ClientResponse<MovementsCommonList> res =
+ ClientResponse<AbstractCommonList> res =
client.readListSortedBy(sortFieldName);
- MovementsCommonList list = res.getEntity();
+ AbstractCommonList list = res.getEntity();
int statusCode = res.getStatus();
// Check the status code of the response: does it match
}
- private MovementsCommonList keywordSearchSortedBy(String keywords,
+ private AbstractCommonList keywordSearchSortedBy(String keywords,
String sortFieldName) throws Exception {
String testName = "keywordSearchSortedBy";
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
- ClientResponse<MovementsCommonList> res =
+ ClientResponse<AbstractCommonList> res =
client.keywordSearchSortedBy(keywords, sortFieldName);
- MovementsCommonList list = res.getEntity();
+ AbstractCommonList list = res.getEntity();
int statusCode = res.getStatus();
// Check the status code of the response: does it match
</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>
-
- <!-- movements records, as in nuxeo repository -->
- <xs:element name="movements-common-list">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="abstractCommonList">
- <xs:sequence>
- <xs:element name="movement-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="movementReferenceNumber" type="xs:string"
- minOccurs="1" />
- <xs:element name="currentLocation" type="xs:string"
- minOccurs="1" />
- <xs:element name="locationDate" 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.movement.nuxeo;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.List;
-
-import org.collectionspace.services.MovementJAXBSchema;
-import org.collectionspace.services.common.datetime.DateTimeFormatUtils;
-import org.collectionspace.services.common.document.DocumentWrapper;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.movement.MovementsCommon;
-import org.collectionspace.services.movement.MovementsCommonList;
-import org.collectionspace.services.movement.MovementsCommonList.MovementListItem;
-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 MovementDocumentModelHandler.
* $LastChangedDate$
*/
public class MovementDocumentModelHandler
- extends RemoteDocumentModelHandlerImpl<MovementsCommon, MovementsCommonList> {
-
- /** The logger. */
- private final Logger logger = LoggerFactory.getLogger(MovementDocumentModelHandler.class);
-
- /** The Movement. */
- private MovementsCommon Movement;
-
- /** The Movement list. */
- private MovementsCommonList MovementList;
-
- /**
- * Gets the common part.
- *
- * @return the common part
- */
- @Override
- public MovementsCommon getCommonPart() {
- return Movement;
- }
-
- /**
- * Sets the common part.
- *
- * @param Movement the new common part
- */
- @Override
- public void setCommonPart(MovementsCommon Movement) {
- this.Movement = Movement;
- }
-
- /**
- * Gets the common part list.
- *
- * @return the common part list
- */
- @Override
- public MovementsCommonList getCommonPartList() {
- return MovementList;
- }
-
- /**
- * Sets the common part list.
- *
- * @param MovementList the new common part list
- */
- @Override
- public void setCommonPartList(MovementsCommonList MovementList) {
- this.MovementList = MovementList;
- }
-
- /**
- * Extract common part.
- *
- * @param wrapDoc the wrap doc
- * @return the Movements common
- * @throws Exception the exception
- */
- @Override
- public MovementsCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
- throws Exception {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Fill common part.
- *
- * @param MovementObject the Movement object
- * @param wrapDoc the wrap doc
- * @throws Exception the exception
- */
- @Override
- public void fillCommonPart(MovementsCommon MovementObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Extract common part list.
- *
- * @param wrapDoc the wrap doc
- * @return the Movements common list
- * @throws Exception the exception
- */
- @Override
- public MovementsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- MovementsCommonList coList = extractPagingInfo(new MovementsCommonList(), wrapDoc);
- AbstractCommonList commonList = (AbstractCommonList) coList;
- commonList.setFieldsReturned("movementReferenceNumber|currentLocation|locationDate|uri|csid");
- List<MovementsCommonList.MovementListItem> list = coList.getMovementListItem();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- String label = getServiceContext().getCommonPartLabel();
- while(iter.hasNext()){
- DocumentModel docModel = iter.next();
- MovementListItem ilistItem = new MovementListItem();
- ilistItem.setMovementReferenceNumber((String) docModel.getProperty(label,
- MovementJAXBSchema.MOVEMENT_REFERENCE_NUMBER));
- ilistItem.setCurrentLocation((String) docModel.getProperty(label,
- MovementJAXBSchema.CURRENT_LOCATION));
- GregorianCalendar gcal = (GregorianCalendar) docModel.getProperty(label,
- MovementJAXBSchema.LOCATION_DATE);
- ilistItem.setLocationDate(DateTimeFormatUtils.formatAsISO8601Timestamp(gcal));
- 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 MovementConstants.NUXEO_SCHEMA_NAME + ":" + prop;
- }
+ extends DocHandlerBase<MovementsCommon> {
}
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.objectexit.ObjectexitCommon;
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = true;
if(iterateThroughList && logger.isDebugEnabled()){
- ListItemsInAbstractCommonList(list, logger, testName);
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.ReportClient;
+import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.report.ReportsCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if (iterateThroughList && logger.isDebugEnabled()) {
- ListItemsInAbstractCommonList(list, logger, testName);
+ if(logger.isTraceEnabled()){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
// We must find the basic one we created
boolean fFoundBaseItem = false;
for (AbstractCommonList.ListItem item : items) {
- if(knownResourceId.equalsIgnoreCase(ListItemGetCSID(item))) {
+ if(knownResourceId.equalsIgnoreCase(AbstractCommonListUtils.ListItemGetCSID(item))) {
fFoundBaseItem = true;
break;
}
items = list.getListItem();
// We must NOT find the basic one we created
for (AbstractCommonList.ListItem item : items) {
- Assert.assertNotSame(ListItemGetCSID(item), knownResourceId,
+ Assert.assertNotSame(AbstractCommonListUtils.ListItemGetCSID(item), knownResourceId,
"readListFiltered(\"Intake\", \"single\") incorrectly returned base item");
}
items = list.getListItem();
// We must NOT find the basic one we created
for (AbstractCommonList.ListItem item : items) {
- Assert.assertNotSame(ListItemGetCSID(item), knownResourceId,
+ Assert.assertNotSame(AbstractCommonListUtils.ListItemGetCSID(item), knownResourceId,
"readListFiltered(\""+testDocType+"\", \"group\") incorrectly returned base item");
}
}