From 3bb4b0a3c5ee7d545219809d15eba077aa3b4f61 Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Wed, 28 Apr 2010 08:50:27 +0000 Subject: [PATCH] CSPACE-1349, 1422, 1428, 1429, 1469, 1465, 1466, 1468, 1470, 1473: Adding pagination support in list response payloads of all Nuxeo based services. Passes *ALL* current tests and merged with the latest set of sources. --- services/acquisition/jaxb/pom.xml | 5 + .../main/resources/acquisitions_common.xsd | 52 +++++---- .../AcquisitionDocumentModelHandler.java | 8 +- services/collectionobject/jaxb/.classpath | 1 + services/collectionobject/jaxb/.project | 1 + .../jaxb/.settings/org.eclipse.jdt.core.prefs | 3 +- services/collectionobject/jaxb/pom.xml | 5 + .../resources/collectionobjects_common.xsd | 57 ++++++---- .../CollectionObjectDocumentModelHandler.java | 37 ++++-- .../java/RemoteDocumentModelHandlerImpl.java | 30 +++++ services/contact/jaxb/pom.xml | 5 + .../src/main/resources/contacts-common.xsd | 47 +++++--- .../nuxeo/ContactDocumentModelHandler.java | 82 ++++++++------ services/dimension/jaxb/pom.xml | 5 + .../src/main/resources/dimensions-common.xsd | 48 +++++--- .../nuxeo/DimensionDocumentModelHandler.java | 9 +- services/intake/jaxb/pom.xml | 5 + .../src/main/resources/intakes-common.xsd | 49 +++++--- .../nuxeo/IntakeDocumentModelHandler.java | 22 ++-- .../src/main/resources/relations_common.xsd | 46 +++++--- services/loanin/jaxb/pom.xml | 5 + .../src/main/resources/loansin-common.xsd | 49 +++++--- .../nuxeo/LoaninDocumentModelHandler.java | 29 +++-- services/loanout/jaxb/pom.xml | 5 + .../src/main/resources/loansout-common.xsd | 49 +++++--- .../nuxeo/LoanoutDocumentModelHandler.java | 75 ++++++++----- services/organization/jaxb/pom.xml | 5 + .../main/resources/organization_common.xsd | 61 +++++----- .../main/resources/orgauthority_common.xsd | 84 ++++++++------ .../OrgAuthorityDocumentModelHandler.java | 39 +++---- .../OrganizationDocumentModelHandler.java | 94 +++++++++------- services/person/jaxb/pom.xml | 5 + .../jaxb/src/main/resources/person_common.xsd | 72 +++++++----- .../main/resources/personauthority_common.xsd | 85 ++++++++------ .../PersonAuthorityDocumentModelHandler.java | 21 +--- .../nuxeo/PersonDocumentModelHandler.java | 106 ++++++++++-------- .../nuxeo/RelationDocumentModelHandler.java | 38 +++++-- services/vocabulary/jaxb/.classpath | 1 + services/vocabulary/jaxb/pom.xml | 5 + .../src/main/resources/vocabulary_common.xsd | 85 ++++++++------ .../main/resources/vocabularyitem_common.xsd | 52 +++++---- .../nuxeo/VocabularyDocumentModelHandler.java | 37 +++--- .../VocabularyItemDocumentModelHandler.java | 69 ++++-------- 43 files changed, 964 insertions(+), 624 deletions(-) diff --git a/services/acquisition/jaxb/pom.xml b/services/acquisition/jaxb/pom.xml index 6951c5022..b9c6e6867 100644 --- a/services/acquisition/jaxb/pom.xml +++ b/services/acquisition/jaxb/pom.xml @@ -26,6 +26,11 @@ org.jvnet.jaxb2_commons runtime + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + diff --git a/services/acquisition/jaxb/src/main/resources/acquisitions_common.xsd b/services/acquisition/jaxb/src/main/resources/acquisitions_common.xsd index 04fd09a6e..db4f19f54 100644 --- a/services/acquisition/jaxb/src/main/resources/acquisitions_common.xsd +++ b/services/acquisition/jaxb/src/main/resources/acquisitions_common.xsd @@ -13,11 +13,12 @@ + version="0.1"> + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java index df4958b0a..ca01cc5ee 100644 --- a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java +++ b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java @@ -108,13 +108,9 @@ public class AcquisitionDocumentModelHandler @Override public AcquisitionsCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - DocumentModelList docList = wrapDoc.getWrappedObject(); - AcquisitionsCommonList coList = new AcquisitionsCommonList(); + AcquisitionsCommonList coList = this.extractPagingInfo(new AcquisitionsCommonList(), wrapDoc); List list = coList.getAcquisitionListItem(); - - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - Iterator iter = docList.iterator(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); while (iter.hasNext()) { DocumentModel docModel = iter.next(); AcquisitionListItem listItem = new AcquisitionListItem(); diff --git a/services/collectionobject/jaxb/.classpath b/services/collectionobject/jaxb/.classpath index 557f8a4e0..8f8348dc2 100644 --- a/services/collectionobject/jaxb/.classpath +++ b/services/collectionobject/jaxb/.classpath @@ -6,5 +6,6 @@ + diff --git a/services/collectionobject/jaxb/.project b/services/collectionobject/jaxb/.project index d210da466..6079d9391 100644 --- a/services/collectionobject/jaxb/.project +++ b/services/collectionobject/jaxb/.project @@ -3,6 +3,7 @@ org.collectionspace.services.collectionobject.jaxb + org.collectionspace.services.jaxb diff --git a/services/collectionobject/jaxb/.settings/org.eclipse.jdt.core.prefs b/services/collectionobject/jaxb/.settings/org.eclipse.jdt.core.prefs index 25d00994a..7d255d4d3 100644 --- a/services/collectionobject/jaxb/.settings/org.eclipse.jdt.core.prefs +++ b/services/collectionobject/jaxb/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,6 @@ -#Wed Feb 10 17:35:27 PST 2010 +#Tue Apr 27 13:04:23 PDT 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.6 diff --git a/services/collectionobject/jaxb/pom.xml b/services/collectionobject/jaxb/pom.xml index 1417f3a15..da8c113b8 100644 --- a/services/collectionobject/jaxb/pom.xml +++ b/services/collectionobject/jaxb/pom.xml @@ -26,6 +26,11 @@ org.jvnet.jaxb2_commons runtime + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + diff --git a/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd b/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd index 9cec1b41a..20fbbaed8 100644 --- a/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd +++ b/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd @@ -13,12 +13,13 @@ - + version="0.1"> + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectDocumentModelHandler.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectDocumentModelHandler.java index 3194e3937..b2d934876 100644 --- a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectDocumentModelHandler.java +++ b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectDocumentModelHandler.java @@ -26,6 +26,8 @@ package org.collectionspace.services.collectionobject.nuxeo; import java.util.Iterator; import java.util.List; +//import org.collectionspace.services.jaxb.AbstractCommonList; + import org.collectionspace.services.CollectionObjectListItemJAXBSchema; import org.collectionspace.services.collectionobject.CollectionobjectsCommon; import org.collectionspace.services.collectionobject.CollectionobjectsCommonList; @@ -47,6 +49,7 @@ import org.slf4j.LoggerFactory; public class CollectionObjectDocumentModelHandler extends RemoteDocumentModelHandlerImpl { + /** The logger. */ private final Logger logger = LoggerFactory.getLogger(CollectionObjectDocumentModelHandler.class); /** * collectionObject is used to stash JAXB object to use when handle is called @@ -86,32 +89,40 @@ public class CollectionObjectDocumentModelHandler return collectionObjectList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object) + */ @Override public void setCommonPartList(CollectionobjectsCommonList collectionObjectList) { this.collectionObjectList = collectionObjectList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public CollectionobjectsCommon extractCommonPart(DocumentWrapper 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(CollectionobjectsCommon co, DocumentWrapper 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 CollectionobjectsCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - DocumentModelList docList = wrapDoc.getWrappedObject(); - - CollectionobjectsCommonList coList = new CollectionobjectsCommonList(); + CollectionobjectsCommonList coList = this.extractPagingInfo(new CollectionobjectsCommonList(), + wrapDoc); List list = coList.getCollectionObjectListItem(); - - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - Iterator iter = docList.iterator(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); while(iter.hasNext()){ DocumentModel docModel = iter.next(); CollectionObjectListItem coListItem = new CollectionObjectListItem(); @@ -128,6 +139,9 @@ public class CollectionObjectDocumentModelHandler return coList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#fillAllParts(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public void fillAllParts(DocumentWrapper wrapDoc) throws Exception { @@ -135,6 +149,12 @@ public class CollectionObjectDocumentModelHandler fillDublinCoreObject(wrapDoc); //dublincore might not be needed in future } + /** + * Fill dublin core object. + * + * @param wrapDoc the wrap doc + * @throws Exception the exception + */ private void fillDublinCoreObject(DocumentWrapper wrapDoc) throws Exception { DocumentModel docModel = wrapDoc.getWrappedObject(); //FIXME property setter should be dynamically set using schema inspection @@ -143,6 +163,9 @@ public class CollectionObjectDocumentModelHandler docModel.setPropertyValue("dublincore:title", CollectionObjectConstants.NUXEO_DC_TITLE); } + /* (non-Javadoc) + * @see org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl#getQProperty(java.lang.String) + */ @Override public String getQProperty(String prop) { return CollectionObjectConstants.NUXEO_SCHEMA_NAME + ":" + prop; diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java index 4ea6e9309..dbcb98eb5 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java @@ -34,17 +34,21 @@ import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.common.context.MultipartServiceContext; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.BadRequestException; 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.service.ObjectPartType; import org.collectionspace.services.common.vocabulary.RefNameUtils; +//import org.collectionspace.services.vocabulary.VocabulariesCommonList; 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.PropertyException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -98,6 +102,32 @@ public abstract class RemoteDocumentModelHandlerImpl ctx.addOutputPart(schema, doc, partMeta.getContent().getContentType()); } + + /** + * Extract paging info. + * + * @param commonsList the commons list + * @return the tL + * @throws Exception the exception + */ + protected TL extractPagingInfo(TL theCommonList, DocumentWrapper wrapDoc) + throws Exception { + AbstractCommonList commonList = (AbstractCommonList)theCommonList; + + DocumentFilter docFilter = this.getDocumentFilter(); + long pageSize = docFilter.getPageSize(); + long pageNum = docFilter.getOffset() / pageSize; + // set the page size and page numer + commonList.setPageNum(pageNum); + commonList.setPageSize(pageSize); + // set the total result size + DocumentModelList docList = wrapDoc.getWrappedObject(); + commonList.setTotalItems(docList.totalSize()); + + return (TL)commonList; + } + + @Override public void extractAllParts(DocumentWrapper wrapDoc) throws Exception { diff --git a/services/contact/jaxb/pom.xml b/services/contact/jaxb/pom.xml index 1f3efc861..9449813d6 100644 --- a/services/contact/jaxb/pom.xml +++ b/services/contact/jaxb/pom.xml @@ -26,6 +26,11 @@ org.jvnet.jaxb2_commons runtime + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + diff --git a/services/contact/jaxb/src/main/resources/contacts-common.xsd b/services/contact/jaxb/src/main/resources/contacts-common.xsd index dd669e7d1..c1913871b 100644 --- a/services/contact/jaxb/src/main/resources/contacts-common.xsd +++ b/services/contact/jaxb/src/main/resources/contacts-common.xsd @@ -13,6 +13,8 @@ - + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/services/contact/service/src/main/java/org/collectionspace/services/contact/nuxeo/ContactDocumentModelHandler.java b/services/contact/service/src/main/java/org/collectionspace/services/contact/nuxeo/ContactDocumentModelHandler.java index 0149e4cfd..90ad4e972 100644 --- a/services/contact/service/src/main/java/org/collectionspace/services/contact/nuxeo/ContactDocumentModelHandler.java +++ b/services/contact/service/src/main/java/org/collectionspace/services/contact/nuxeo/ContactDocumentModelHandler.java @@ -41,99 +41,119 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * ContactDocumentModelHandler - * - * $LastChangedRevision: $ - * $LastChangedDate: $ + * The Class ContactDocumentModelHandler. */ public class ContactDocumentModelHandler extends RemoteDocumentModelHandlerImpl { + /** The logger. */ private final Logger logger = LoggerFactory.getLogger(ContactDocumentModelHandler.class); - /** - * contact is used to stash JAXB object to use when handle is called - * for Action.CREATE, Action.UPDATE or Action.GET - */ + + /** The contact. */ private ContactsCommon contact; - /** - * contactList is stashed when handle is called - * for ACTION.GET_ALL - */ + + /** The contact list. */ private ContactsCommonList contactList; + /** The in authority. */ private String inAuthority; + /** + * Gets the in authority. + * + * @return the in authority + */ public String getInAuthority() { return inAuthority; } + /** + * Sets the in authority. + * + * @param inAuthority the new in authority + */ public void setInAuthority(String inAuthority) { this.inAuthority = inAuthority; } + /** The in item. */ private String inItem; + /** + * Gets the in item. + * + * @return the in item + */ public String getInItem() { return inItem; } + /** + * Sets the in item. + * + * @param inItem the new in item + */ public void setInItem(String inItem) { this.inItem = inItem; } - /** - * getCommonPart get associated contact - * @return + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#getCommonPart() */ @Override public ContactsCommon getCommonPart() { return contact; } - /** - * setCommonPart set associated contact - * @param contact + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPart(java.lang.Object) */ @Override public void setCommonPart(ContactsCommon contact) { this.contact = contact; } - /** - * getCommonPartList get associated contact (for index/GET_ALL) - * @return + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#getCommonPartList() */ @Override public ContactsCommonList getCommonPartList() { return contactList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object) + */ @Override public void setCommonPartList(ContactsCommonList contactList) { this.contactList = contactList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public ContactsCommon extractCommonPart(DocumentWrapper 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(ContactsCommon contactObject, DocumentWrapper 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 ContactsCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - DocumentModelList docList = wrapDoc.getWrappedObject(); - - ContactsCommonList coList = new ContactsCommonList(); + ContactsCommonList coList = extractPagingInfo(new ContactsCommonList(), wrapDoc); List list = coList.getContactListItem(); - - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - Iterator iter = docList.iterator(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); while(iter.hasNext()){ DocumentModel docModel = iter.next(); ContactListItem clistItem = new ContactListItem(); @@ -151,10 +171,8 @@ public class ContactDocumentModelHandler return coList; } - /** - * getQProperty converts the given property to qualified schema property - * @param prop - * @return + /* (non-Javadoc) + * @see org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl#getQProperty(java.lang.String) */ @Override public String getQProperty(String prop) { diff --git a/services/dimension/jaxb/pom.xml b/services/dimension/jaxb/pom.xml index 29ed8baf5..ccd5849d4 100644 --- a/services/dimension/jaxb/pom.xml +++ b/services/dimension/jaxb/pom.xml @@ -27,6 +27,11 @@ org.jvnet.jaxb2_commons runtime + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + diff --git a/services/dimension/jaxb/src/main/resources/dimensions-common.xsd b/services/dimension/jaxb/src/main/resources/dimensions-common.xsd index 5d5c25357..ddbdb0cae 100644 --- a/services/dimension/jaxb/src/main/resources/dimensions-common.xsd +++ b/services/dimension/jaxb/src/main/resources/dimensions-common.xsd @@ -13,11 +13,12 @@ + version="0.1"> + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java index cf36a1868..4f2d68c6f 100644 --- a/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java +++ b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java @@ -107,14 +107,9 @@ public class DimensionDocumentModelHandler @Override public DimensionsCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - DocumentModelList docList = wrapDoc.getWrappedObject(); - - DimensionsCommonList coList = new DimensionsCommonList(); + DimensionsCommonList coList = extractPagingInfo(new DimensionsCommonList(), wrapDoc) ; List list = coList.getDimensionListItem(); - - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - Iterator iter = docList.iterator(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); while(iter.hasNext()){ DocumentModel docModel = iter.next(); DimensionListItem ilistItem = new DimensionListItem(); diff --git a/services/intake/jaxb/pom.xml b/services/intake/jaxb/pom.xml index 302fc9260..c20ccf711 100644 --- a/services/intake/jaxb/pom.xml +++ b/services/intake/jaxb/pom.xml @@ -26,6 +26,11 @@ org.jvnet.jaxb2_commons runtime + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + diff --git a/services/intake/jaxb/src/main/resources/intakes-common.xsd b/services/intake/jaxb/src/main/resources/intakes-common.xsd index 1d2c578e7..862d1c8d4 100644 --- a/services/intake/jaxb/src/main/resources/intakes-common.xsd +++ b/services/intake/jaxb/src/main/resources/intakes-common.xsd @@ -13,6 +13,8 @@ + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java b/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java index 30107afa3..39e77383b 100644 --- a/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java +++ b/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java @@ -47,6 +47,7 @@ import org.slf4j.LoggerFactory; public class IntakeDocumentModelHandler extends RemoteDocumentModelHandlerImpl { + /** The logger. */ private final Logger logger = LoggerFactory.getLogger(IntakeDocumentModelHandler.class); /** * intake is used to stash JAXB object to use when handle is called @@ -87,32 +88,39 @@ public class IntakeDocumentModelHandler return intakeList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object) + */ @Override public void setCommonPartList(IntakesCommonList intakeList) { this.intakeList = intakeList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public IntakesCommon extractCommonPart(DocumentWrapper 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(IntakesCommon intakeObject, DocumentWrapper 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 IntakesCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - DocumentModelList docList = wrapDoc.getWrappedObject(); - - IntakesCommonList coList = new IntakesCommonList(); + IntakesCommonList coList = this.extractPagingInfo(new IntakesCommonList(), wrapDoc); List list = coList.getIntakeListItem(); - - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - Iterator iter = docList.iterator(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); while(iter.hasNext()){ DocumentModel docModel = iter.next(); IntakeListItem ilistItem = new IntakeListItem(); diff --git a/services/jaxb/src/main/resources/relations_common.xsd b/services/jaxb/src/main/resources/relations_common.xsd index 9ab41ebc6..f4ff97616 100644 --- a/services/jaxb/src/main/resources/relations_common.xsd +++ b/services/jaxb/src/main/resources/relations_common.xsd @@ -13,10 +13,11 @@ + targetNamespace="http://collectionspace.org/services/relation"> @@ -45,25 +46,38 @@ + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + diff --git a/services/loanin/jaxb/pom.xml b/services/loanin/jaxb/pom.xml index 4bbc8dd6f..3cf6146fb 100644 --- a/services/loanin/jaxb/pom.xml +++ b/services/loanin/jaxb/pom.xml @@ -26,6 +26,11 @@ org.jvnet.jaxb2_commons runtime + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + diff --git a/services/loanin/jaxb/src/main/resources/loansin-common.xsd b/services/loanin/jaxb/src/main/resources/loansin-common.xsd index d4af271a1..5cda41333 100644 --- a/services/loanin/jaxb/src/main/resources/loansin-common.xsd +++ b/services/loanin/jaxb/src/main/resources/loansin-common.xsd @@ -13,6 +13,8 @@ + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java b/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java index 0aebab8a7..0b9ce11a4 100644 --- a/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java +++ b/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java @@ -47,6 +47,7 @@ import org.slf4j.LoggerFactory; public class LoaninDocumentModelHandler extends RemoteDocumentModelHandlerImpl { + /** The logger. */ private final Logger logger = LoggerFactory.getLogger(LoaninDocumentModelHandler.class); /** * loanin is used to stash JAXB object to use when handle is called @@ -59,7 +60,6 @@ public class LoaninDocumentModelHandler */ private LoansinCommonList loaninList; - /** * getCommonPart get associated loanin * @return @@ -84,35 +84,42 @@ public class LoaninDocumentModelHandler */ @Override public LoansinCommonList getCommonPartList() { - return loaninList; + return this.loaninList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object) + */ @Override - public void setCommonPartList(LoansinCommonList loaninList) { - this.loaninList = loaninList; + public void setCommonPartList(LoansinCommonList theLoaninList) { + this.loaninList = theLoaninList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public LoansinCommon extractCommonPart(DocumentWrapper 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(LoansinCommon loaninObject, DocumentWrapper 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 LoansinCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - DocumentModelList docList = wrapDoc.getWrappedObject(); - - LoansinCommonList coList = new LoansinCommonList(); + LoansinCommonList coList = extractPagingInfo(new LoansinCommonList(), wrapDoc); List list = coList.getLoaninListItem(); - - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - Iterator iter = docList.iterator(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); while(iter.hasNext()){ DocumentModel docModel = iter.next(); LoaninListItem ilistItem = new LoaninListItem(); diff --git a/services/loanout/jaxb/pom.xml b/services/loanout/jaxb/pom.xml index 6d5fd0293..601164f06 100644 --- a/services/loanout/jaxb/pom.xml +++ b/services/loanout/jaxb/pom.xml @@ -26,6 +26,11 @@ org.jvnet.jaxb2_commons runtime + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + diff --git a/services/loanout/jaxb/src/main/resources/loansout-common.xsd b/services/loanout/jaxb/src/main/resources/loansout-common.xsd index 6591ef4d0..2201fed2f 100644 --- a/services/loanout/jaxb/src/main/resources/loansout-common.xsd +++ b/services/loanout/jaxb/src/main/resources/loansout-common.xsd @@ -13,6 +13,8 @@ + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + 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 a14ce2a07..bbf1deb94 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 @@ -39,30 +39,25 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * LoanoutDocumentModelHandler - * - * $LastChangedRevision: $ - * $LastChangedDate: $ + * The Class LoanoutDocumentModelHandler. */ public class LoanoutDocumentModelHandler extends RemoteDocumentModelHandlerImpl { + /** The logger. */ private final Logger logger = LoggerFactory.getLogger(LoanoutDocumentModelHandler.class); - /** - * loanout is used to stash JAXB object to use when handle is called - * for Action.CREATE, Action.UPDATE or Action.GET - */ + + /** The loanout. */ private LoansoutCommon loanout; - /** - * loanoutList is stashed when handle is called - * for ACTION.GET_ALL - */ + + /** The loanout list. */ private LoansoutCommonList loanoutList; /** - * getCommonPart get associated loanout - * @return + * Gets the common part. + * + * @return the common part */ @Override public LoansoutCommon getCommonPart() { @@ -70,8 +65,9 @@ public class LoanoutDocumentModelHandler } /** - * setCommonPart set associated loanout - * @param loanout + * Sets the common part. + * + * @param loanout the new common part */ @Override public void setCommonPart(LoansoutCommon loanout) { @@ -79,40 +75,62 @@ public class LoanoutDocumentModelHandler } /** - * getCommonPartList get associated loanout (for index/GET_ALL) - * @return + * 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 { - DocumentModelList docList = wrapDoc.getWrappedObject(); - - LoansoutCommonList coList = new LoansoutCommonList(); + LoansoutCommonList coList = extractPagingInfo(new LoansoutCommonList(), wrapDoc); List list = coList.getLoanoutListItem(); - - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - Iterator iter = docList.iterator(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); while(iter.hasNext()){ DocumentModel docModel = iter.next(); LoanoutListItem ilistItem = new LoanoutListItem(); @@ -130,9 +148,10 @@ public class LoanoutDocumentModelHandler } /** - * getQProperty converts the given property to qualified schema property - * @param prop - * @return + * Gets the q property. + * + * @param prop the prop + * @return the q property */ @Override public String getQProperty(String prop) { diff --git a/services/organization/jaxb/pom.xml b/services/organization/jaxb/pom.xml index ca12bdb90..18ffc00e7 100644 --- a/services/organization/jaxb/pom.xml +++ b/services/organization/jaxb/pom.xml @@ -26,6 +26,11 @@ org.jvnet.jaxb2_commons runtime + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + diff --git a/services/organization/jaxb/src/main/resources/organization_common.xsd b/services/organization/jaxb/src/main/resources/organization_common.xsd index 9fd20e108..82caef84c 100644 --- a/services/organization/jaxb/src/main/resources/organization_common.xsd +++ b/services/organization/jaxb/src/main/resources/organization_common.xsd @@ -1,17 +1,18 @@ - + version="0.1"> + - + - + @@ -39,29 +40,39 @@ + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/services/organization/jaxb/src/main/resources/orgauthority_common.xsd b/services/organization/jaxb/src/main/resources/orgauthority_common.xsd index 42e179aa9..32eb77317 100644 --- a/services/organization/jaxb/src/main/resources/orgauthority_common.xsd +++ b/services/organization/jaxb/src/main/resources/orgauthority_common.xsd @@ -12,18 +12,19 @@ --> - - - + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" + jaxb:version="1.0" elementFormDefault="unqualified" + xmlns:ns="http://collectionspace.org/services/organization" + xmlns="http://collectionspace.org/services/organization" + targetNamespace="http://collectionspace.org/services/organization" + version="0.1"> + + + @@ -35,39 +36,48 @@ - - + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java index c4a4f346a..4e6dbabd0 100644 --- a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java +++ b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java @@ -50,6 +50,7 @@ import org.slf4j.LoggerFactory; public class OrgAuthorityDocumentModelHandler extends RemoteDocumentModelHandlerImpl { + /** The logger. */ private final Logger logger = LoggerFactory.getLogger(OrgAuthorityDocumentModelHandler.class); /** * orgAuthority is used to stash JAXB object to use when handle is called @@ -90,44 +91,40 @@ public class OrgAuthorityDocumentModelHandler return orgAuthorityList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object) + */ @Override public void setCommonPartList(OrgauthoritiesCommonList orgAuthorityList) { this.orgAuthorityList = orgAuthorityList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public OrgauthoritiesCommon extractCommonPart(DocumentWrapper 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(OrgauthoritiesCommon orgAuthorityObject, DocumentWrapper wrapDoc) throws Exception { + public void fillCommonPart(OrgauthoritiesCommon orgAuthorityObject, + DocumentWrapper 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 OrgauthoritiesCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - DocumentModelList docList = wrapDoc.getWrappedObject(); - - OrgauthoritiesCommonList coList = new OrgauthoritiesCommonList(); - List list = coList.getOrgauthorityListItem(); - - DocumentFilter filter = getDocumentFilter(); - long pageNum, pageSize; - if(filter==null) { - pageNum = 0; - pageSize = 0; - } else { - pageSize = filter.getPageSize(); - pageNum = filter.getOffset()/pageSize; - } - coList.setPageNum(pageNum); - coList.setPageSize(pageSize); - coList.setTotalItems(docList.totalSize()); - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - Iterator iter = docList.iterator(); + OrgauthoritiesCommonList coList = this.extractPagingInfo(new OrgauthoritiesCommonList(), wrapDoc); + List list = coList.getOrgauthorityListItem(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); while(iter.hasNext()){ DocumentModel docModel = iter.next(); OrgauthorityListItem ilistItem = new OrgauthorityListItem(); diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java index 0465abe3e..9977af8ad 100644 --- a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java +++ b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java @@ -51,6 +51,7 @@ import org.slf4j.LoggerFactory; public class OrganizationDocumentModelHandler extends RemoteDocumentModelHandlerImpl { + /** The logger. */ private final Logger logger = LoggerFactory.getLogger(OrganizationDocumentModelHandler.class); /** * Common part schema label @@ -72,15 +73,28 @@ public class OrganizationDocumentModelHandler */ private String inAuthority; + /** + * Gets the in authority. + * + * @return the in authority + */ public String getInAuthority() { return inAuthority; } + /** + * Sets the in authority. + * + * @param inAuthority the new in authority + */ public void setInAuthority(String inAuthority) { this.inAuthority = inAuthority; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public void handleCreate(DocumentWrapper wrapDoc) throws Exception { // first fill all the parts of the document @@ -88,6 +102,9 @@ public class OrganizationDocumentModelHandler handleDisplayName(wrapDoc.getWrappedObject()); } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleUpdate(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public void handleUpdate(DocumentWrapper wrapDoc) throws Exception { super.handleUpdate(wrapDoc); @@ -170,11 +187,17 @@ public class OrganizationDocumentModelHandler return organizationList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object) + */ @Override public void setCommonPartList(OrganizationsCommonList organizationList) { this.organizationList = organizationList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#extractPart(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, org.collectionspace.services.common.service.ObjectPartType) + */ @Override protected Map extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta) throws Exception { @@ -189,61 +212,46 @@ public class OrganizationDocumentModelHandler return unQObjectProperties; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public OrganizationsCommon extractCommonPart(DocumentWrapper 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(OrganizationsCommon organizationObject, DocumentWrapper wrapDoc) throws Exception { + public void fillCommonPart(OrganizationsCommon organizationObject, DocumentWrapper 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 OrganizationsCommonList extractCommonPartList(DocumentWrapper wrapDoc) - throws Exception { - OrganizationsCommonList coList = new OrganizationsCommonList(); - try{ - DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject(); - - List list = - coList.getOrganizationListItem(); - - DocumentFilter filter = getDocumentFilter(); - long pageNum, pageSize; - if(filter==null) { - pageNum = 0; - pageSize = 0; - } else { - pageSize = filter.getPageSize(); - pageNum = filter.getOffset()/pageSize; - } - coList.setPageNum(pageNum); - coList.setPageSize(pageSize); - coList.setTotalItems(docList.totalSize()); - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - Iterator iter = docList.iterator(); - String commonPartLabel = getServiceContext().getCommonPartLabel("organizations"); - while(iter.hasNext()){ - DocumentModel docModel = iter.next(); - OrganizationListItem ilistItem = new OrganizationListItem(); - ilistItem.setDisplayName((String) - docModel.getProperty(commonPartLabel,OrganizationJAXBSchema.DISPLAY_NAME )); - ilistItem.setRefName((String) - docModel.getProperty(commonPartLabel, OrganizationJAXBSchema.REF_NAME)); - String id = NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri("/orgauthorities/"+inAuthority+"/items/" + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - }catch(Exception e){ - if(logger.isDebugEnabled()){ - logger.debug("Caught exception in extractCommonPartList", e); - } - throw e; + public OrganizationsCommonList extractCommonPartList(DocumentWrapper wrapDoc) + throws Exception { + OrganizationsCommonList coList = this.extractPagingInfo(new OrganizationsCommonList(), wrapDoc); + List list = coList.getOrganizationListItem(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); + String commonPartLabel = getServiceContext().getCommonPartLabel("organizations"); + while(iter.hasNext()){ + DocumentModel docModel = iter.next(); + OrganizationListItem ilistItem = new OrganizationListItem(); + ilistItem.setDisplayName((String) + docModel.getProperty(commonPartLabel,OrganizationJAXBSchema.DISPLAY_NAME )); + ilistItem.setRefName((String) + docModel.getProperty(commonPartLabel, OrganizationJAXBSchema.REF_NAME)); + String id = NuxeoUtils.extractId(docModel.getPathAsString()); + ilistItem.setUri("/orgauthorities/" + this.inAuthority + "/items/" + id); + ilistItem.setCsid(id); + list.add(ilistItem); } + return coList; } diff --git a/services/person/jaxb/pom.xml b/services/person/jaxb/pom.xml index bfc4524cb..59ccc89d7 100644 --- a/services/person/jaxb/pom.xml +++ b/services/person/jaxb/pom.xml @@ -26,6 +26,11 @@ org.jvnet.jaxb2_commons runtime + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + diff --git a/services/person/jaxb/src/main/resources/person_common.xsd b/services/person/jaxb/src/main/resources/person_common.xsd index c2c52ba06..bb15d83ed 100644 --- a/services/person/jaxb/src/main/resources/person_common.xsd +++ b/services/person/jaxb/src/main/resources/person_common.xsd @@ -1,15 +1,17 @@ - - - - + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" + jaxb:version="1.0" elementFormDefault="unqualified" + xmlns:ns="http://collectionspace.org/services/person" + xmlns="http://collectionspace.org/services/person" + targetNamespace="http://collectionspace.org/services/person" + version="0.1" + > + + + + @@ -47,29 +49,39 @@ + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/services/person/jaxb/src/main/resources/personauthority_common.xsd b/services/person/jaxb/src/main/resources/personauthority_common.xsd index 69751b37e..7ff8dcd40 100644 --- a/services/person/jaxb/src/main/resources/personauthority_common.xsd +++ b/services/person/jaxb/src/main/resources/personauthority_common.xsd @@ -12,18 +12,20 @@ --> - - - + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" + jaxb:version="1.0" elementFormDefault="unqualified" + xmlns:ns="http://collectionspace.org/services/person" + xmlns="http://collectionspace.org/services/person" + targetNamespace="http://collectionspace.org/services/person" + version="0.1" + > + + + @@ -36,38 +38,49 @@ - + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + diff --git a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java index 09fb34fd1..533f38e32 100644 --- a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java +++ b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java @@ -108,26 +108,13 @@ public class PersonAuthorityDocumentModelHandler @Override public PersonauthoritiesCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - DocumentModelList docList = wrapDoc.getWrappedObject(); + PersonauthoritiesCommonList coList = extractPagingInfo(new PersonauthoritiesCommonList(), + wrapDoc); - PersonauthoritiesCommonList coList = new PersonauthoritiesCommonList(); - List list = coList.getPersonauthorityListItem(); - - DocumentFilter filter = getDocumentFilter(); - long pageNum, pageSize; - if(filter==null) { - pageNum = 0; - pageSize = 0; - } else { - pageSize = filter.getPageSize(); - pageNum = filter.getOffset()/pageSize; - } - coList.setPageNum(pageNum); - coList.setPageSize(pageSize); - coList.setTotalItems(docList.totalSize()); //FIXME: iterating over a long list of documents is not a long term //strategy...need to change to more efficient iterating in future - Iterator iter = docList.iterator(); + List list = coList.getPersonauthorityListItem(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); while(iter.hasNext()){ DocumentModel docModel = iter.next(); PersonauthorityListItem ilistItem = new PersonauthorityListItem(); diff --git a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java index e77d5de3f..67b1f3b98 100644 --- a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java +++ b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java @@ -56,6 +56,7 @@ import org.slf4j.LoggerFactory; public class PersonDocumentModelHandler extends RemoteDocumentModelHandlerImpl { + /** The logger. */ private final Logger logger = LoggerFactory.getLogger(PersonDocumentModelHandler.class); /** * Common part schema label @@ -78,15 +79,28 @@ public class PersonDocumentModelHandler */ private String inAuthority; + /** + * Gets the in authority. + * + * @return the in authority + */ public String getInAuthority() { return inAuthority; } + /** + * Sets the in authority. + * + * @param inAuthority the new in authority + */ public void setInAuthority(String inAuthority) { this.inAuthority = inAuthority; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public void handleCreate(DocumentWrapper wrapDoc) throws Exception { // first fill all the parts of the document @@ -94,12 +108,21 @@ public class PersonDocumentModelHandler handleDisplayName(wrapDoc.getWrappedObject()); } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleUpdate(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public void handleUpdate(DocumentWrapper wrapDoc) throws Exception { super.handleUpdate(wrapDoc); handleDisplayName(wrapDoc.getWrappedObject()); } + /** + * Handle display name. + * + * @param docModel the doc model + * @throws Exception the exception + */ private void handleDisplayName(DocumentModel docModel) throws Exception { String commonPartLabel = getServiceContext().getCommonPartLabel("persons"); Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel, @@ -197,11 +220,17 @@ public class PersonDocumentModelHandler return personList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object) + */ @Override public void setCommonPartList(PersonsCommonList personList) { this.personList = personList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#extractPart(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, org.collectionspace.services.common.service.ObjectPartType) + */ @Override protected Map extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta) throws Exception { @@ -216,63 +245,50 @@ public class PersonDocumentModelHandler return unQObjectProperties; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public PersonsCommon extractCommonPart(DocumentWrapper 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(PersonsCommon personObject, DocumentWrapper 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 PersonsCommonList extractCommonPartList(DocumentWrapper wrapDoc) - throws Exception { - PersonsCommonList coList = new PersonsCommonList(); - try{ - DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject(); - - List list = - coList.getPersonListItem(); - - DocumentFilter filter = getDocumentFilter(); - long pageNum, pageSize; - if(filter==null) { - pageNum = 0; - pageSize = 0; - } else { - pageSize = filter.getPageSize(); - pageNum = filter.getOffset()/pageSize; - } - coList.setPageNum(pageNum); - coList.setPageSize(pageSize); - coList.setTotalItems(docList.totalSize()); - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - Iterator iter = docList.iterator(); - String commonPartLabel = getServiceContext().getCommonPartLabel("persons"); - while(iter.hasNext()){ - DocumentModel docModel = iter.next(); - PersonListItem ilistItem = new PersonListItem(); - ilistItem.setDisplayName((String) - docModel.getProperty(commonPartLabel, PersonJAXBSchema.DISPLAY_NAME)); - ilistItem.setRefName((String) - docModel.getProperty(commonPartLabel, PersonJAXBSchema.REF_NAME)); - String id = NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri("/personauthorities/"+inAuthority+"/items/" + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - }catch(Exception e){ - if(logger.isDebugEnabled()){ - logger.debug("Caught exception in extractCommonPartList", e); - } - throw e; - } - return coList; - } + public PersonsCommonList extractCommonPartList( + DocumentWrapper wrapDoc) throws Exception { + PersonsCommonList coList = extractPagingInfo(new PersonsCommonList(), wrapDoc); + List list = coList.getPersonListItem(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); + String commonPartLabel = getServiceContext().getCommonPartLabel( + "persons"); + while (iter.hasNext()) { + DocumentModel docModel = iter.next(); + PersonListItem ilistItem = new PersonListItem(); + ilistItem.setDisplayName((String) docModel.getProperty( + commonPartLabel, PersonJAXBSchema.DISPLAY_NAME)); + ilistItem.setRefName((String) docModel.getProperty(commonPartLabel, + PersonJAXBSchema.REF_NAME)); + String id = NuxeoUtils.extractId(docModel.getPathAsString()); + ilistItem.setUri("/personauthorities/" + inAuthority + "/items/" + + id); + ilistItem.setCsid(id); + list.add(ilistItem); + } + + return coList; + } /** * getQProperty converts the given property to qualified schema property diff --git a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java index c1524552c..9f4f631b4 100644 --- a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java +++ b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java @@ -52,6 +52,7 @@ import org.slf4j.LoggerFactory; public class RelationDocumentModelHandler extends RemoteDocumentModelHandlerImpl { + /** The logger. */ private final Logger logger = LoggerFactory.getLogger(RelationDocumentModelHandler.class); /** * relation is used to stash JAXB object to use when handle is called @@ -92,40 +93,49 @@ public class RelationDocumentModelHandler return relationList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object) + */ @Override public void setCommonPartList(RelationsCommonList relationList) { this.relationList = relationList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public RelationsCommon extractCommonPart(DocumentWrapper 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(RelationsCommon relation, DocumentWrapper 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 RelationsCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - DocumentModelList docList = wrapDoc.getWrappedObject(); - Map propsFromResource = this.getProperties(); String subjectCsid = (String) propsFromResource.get(IRelationsManager.SUBJECT); String predicate = (String) propsFromResource.get(IRelationsManager.PREDICATE); String objectCsid = (String) propsFromResource.get(IRelationsManager.OBJECT); - RelationsCommonList relList = new RelationsCommonList(); + //FIXME - Need to change this into a NXQL on subject, predicate, object terms. Currently, + //FIXME - we're performing a post query filter which is far from ideal and not scalable. + RelationsCommonList relList = this.extractPagingInfo(new RelationsCommonList(), wrapDoc) ; List itemList = relList.getRelationListItem(); - - //FIXME: iterating over a long itemList of documents is not a long term - //strategy...need to change to more efficient iterating in future - Iterator iter = docList.iterator(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); while(iter.hasNext()){ DocumentModel docModel = iter.next(); - if(RelationsUtils.isQueryMatch(docModel, subjectCsid, + if (RelationsUtils.isQueryMatch(docModel, subjectCsid, predicate, objectCsid) == true){ RelationListItem relListItem = RelationsUtils.getRelationListItem(getServiceContext(), docModel, getServiceContextPath()); @@ -137,12 +147,21 @@ public class RelationDocumentModelHandler + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#fillAllParts(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public void fillAllParts(DocumentWrapper wrapDoc) throws Exception { super.fillAllParts(wrapDoc); fillDublinCoreObject(wrapDoc); //dublincore might not be needed in future } + /** + * Fill dublin core object. + * + * @param wrapDoc the wrap doc + * @throws Exception the exception + */ private void fillDublinCoreObject(DocumentWrapper wrapDoc) throws Exception { DocumentModel docModel = wrapDoc.getWrappedObject(); //FIXME property setter should be dynamically set using schema inspection @@ -152,6 +171,9 @@ public class RelationDocumentModelHandler } + /* (non-Javadoc) + * @see org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl#getQProperty(java.lang.String) + */ @Override public String getQProperty(String prop) { return "/" + RelationConstants.NUXEO_SCHEMA_ROOT_ELEMENT + "/" + prop; diff --git a/services/vocabulary/jaxb/.classpath b/services/vocabulary/jaxb/.classpath index fef07b28f..8eabc2491 100644 --- a/services/vocabulary/jaxb/.classpath +++ b/services/vocabulary/jaxb/.classpath @@ -5,5 +5,6 @@ + diff --git a/services/vocabulary/jaxb/pom.xml b/services/vocabulary/jaxb/pom.xml index b9bacd68c..d5939a6a3 100644 --- a/services/vocabulary/jaxb/pom.xml +++ b/services/vocabulary/jaxb/pom.xml @@ -26,6 +26,11 @@ org.jvnet.jaxb2_commons runtime + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + collectionspace-services-vocabulary-jaxb diff --git a/services/vocabulary/jaxb/src/main/resources/vocabulary_common.xsd b/services/vocabulary/jaxb/src/main/resources/vocabulary_common.xsd index b165863ee..a478cdd54 100644 --- a/services/vocabulary/jaxb/src/main/resources/vocabulary_common.xsd +++ b/services/vocabulary/jaxb/src/main/resources/vocabulary_common.xsd @@ -12,18 +12,20 @@ --> - - - + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" + jaxb:version="1.0" elementFormDefault="unqualified" + xmlns:ns="http://collectionspace.org/services/vocabulary" + xmlns="http://collectionspace.org/services/vocabulary" + targetNamespace="http://collectionspace.org/services/vocabulary" + version="0.1" + > + + + @@ -35,39 +37,48 @@ - - + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + diff --git a/services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd b/services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd index 8c01a3f27..fe732cace 100644 --- a/services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd +++ b/services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd @@ -1,6 +1,8 @@ + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java index 9aa292ba1..2b22d6bde 100644 --- a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java @@ -50,6 +50,7 @@ import org.slf4j.LoggerFactory; public class VocabularyDocumentModelHandler extends RemoteDocumentModelHandlerImpl { + /** The logger. */ private final Logger logger = LoggerFactory.getLogger(VocabularyDocumentModelHandler.class); /** * vocabulary is used to stash JAXB object to use when handle is called @@ -90,44 +91,40 @@ public class VocabularyDocumentModelHandler return vocabularyList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object) + */ @Override public void setCommonPartList(VocabulariesCommonList vocabularyList) { this.vocabularyList = vocabularyList; } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper) + */ @Override public VocabulariesCommon extractCommonPart(DocumentWrapper 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(VocabulariesCommon vocabularyObject, DocumentWrapper 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 VocabulariesCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - DocumentModelList docList = wrapDoc.getWrappedObject(); - - VocabulariesCommonList coList = new VocabulariesCommonList(); + public VocabulariesCommonList extractCommonPartList( + DocumentWrapper wrapDoc) throws Exception { + VocabulariesCommonList coList = extractPagingInfo(new VocabulariesCommonList(), wrapDoc); List list = coList.getVocabularyListItem(); - - DocumentFilter filter = getDocumentFilter(); - long pageNum, pageSize; - if(filter==null) { - pageNum = 0; - pageSize = 0; - } else { - pageSize = filter.getPageSize(); - pageNum = filter.getOffset()/pageSize; - } - coList.setPageNum(pageNum); - coList.setPageSize(pageSize); - coList.setTotalItems(docList.totalSize()); - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - Iterator iter = docList.iterator(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); while(iter.hasNext()){ DocumentModel docModel = iter.next(); VocabularyListItem ilistItem = new VocabularyListItem(); diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java index f163ac4be..9609083b3 100644 --- a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java @@ -118,51 +118,30 @@ public class VocabularyItemDocumentModelHandler } @Override - public VocabularyitemsCommonList extractCommonPartList(DocumentWrapper wrapDoc) - throws Exception { - VocabularyitemsCommonList coList = new VocabularyitemsCommonList(); - try{ - DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject(); - - List list = - coList.getVocabularyitemListItem(); - - DocumentFilter filter = getDocumentFilter(); - long pageNum, pageSize; - if(filter==null) { - pageNum = 0; - pageSize = 0; - } else { - pageSize = filter.getPageSize(); - pageNum = filter.getOffset()/pageSize; - } - coList.setPageNum(pageNum); - coList.setPageSize(pageSize); - coList.setTotalItems(docList.totalSize()); - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - Iterator iter = docList.iterator(); - while(iter.hasNext()){ - DocumentModel docModel = iter.next(); - VocabularyitemListItem ilistItem = new VocabularyitemListItem(); - ilistItem.setDisplayName( - (String) docModel.getProperty(getServiceContext().getCommonPartLabel("vocabularyItems"), - VocabularyItemJAXBSchema.DISPLAY_NAME)); - ilistItem.setRefName( - (String) docModel.getProperty(getServiceContext().getCommonPartLabel("vocabularyItems"), - VocabularyItemJAXBSchema.REF_NAME)); - String id = NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri("/vocabularies/"+inVocabulary+"/items/" + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - }catch(Exception e){ - if(logger.isDebugEnabled()){ - logger.debug("Caught exception in extractCommonPartList", e); - } - throw e; - } - return coList; + public VocabularyitemsCommonList extractCommonPartList( + DocumentWrapper wrapDoc) throws Exception { + VocabularyitemsCommonList coList = extractPagingInfo(new VocabularyitemsCommonList(), wrapDoc); + + // FIXME: iterating over a long list of documents is not a long term + // strategy...need to change to more efficient iterating in future + List list = coList.getVocabularyitemListItem(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); + while (iter.hasNext()) { + DocumentModel docModel = iter.next(); + VocabularyitemListItem ilistItem = new VocabularyitemListItem(); + ilistItem.setDisplayName((String) docModel.getProperty( + getServiceContext().getCommonPartLabel("vocabularyItems"), + VocabularyItemJAXBSchema.DISPLAY_NAME)); + ilistItem.setRefName((String) docModel.getProperty( + getServiceContext().getCommonPartLabel("vocabularyItems"), + VocabularyItemJAXBSchema.REF_NAME)); + String id = NuxeoUtils.extractId(docModel.getPathAsString()); + ilistItem.setUri("/vocabularies/" + inVocabulary + "/items/" + id); + ilistItem.setCsid(id); + list.add(ilistItem); + } + + return coList; } /** -- 2.47.3