Passes *ALL* current tests and merged with the latest set of sources.
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>runtime</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<xs:schema
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/acquisition"
xmlns="http://collectionspace.org/services/acquisition"
targetNamespace="http://collectionspace.org/services/acquisition"
- version="0.1"
->
+ version="0.1">
<!--
</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>
+
<!-- acquisition records, as in nuxeo repository -->
<xs:element name="acquisitions-common-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="acquisition-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="acquisitionReferenceNumber" type="xs:string"
- minOccurs="1" />
- <xs:element name="acquisitionSources" type="acquisitionSourceList"
- minOccurs="1" />
- <!-- uri to retrive acquisition 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:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="acquisition-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="acquisitionReferenceNumber" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="acquisitionSources" type="acquisitionSourceList"
+ minOccurs="1" />
+ <!-- uri to retrive acquisition 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>
@Override
public AcquisitionsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- DocumentModelList docList = wrapDoc.getWrappedObject();
- AcquisitionsCommonList coList = new AcquisitionsCommonList();
+ AcquisitionsCommonList coList = this.extractPagingInfo(new AcquisitionsCommonList(), wrapDoc);
List<AcquisitionsCommonList.AcquisitionListItem> 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<DocumentModel> iter = docList.iterator();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
while (iter.hasNext()) {
DocumentModel docModel = iter.next();
AcquisitionListItem listItem = new AcquisitionListItem();
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>\r
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/org.collectionspace.services.jaxb"/>\r
<classpathentry kind="output" path="target/classes"/>\r
</classpath>\r
<name>org.collectionspace.services.collectionobject.jaxb</name>\r
<comment></comment>\r
<projects>\r
+ <project>org.collectionspace.services.jaxb</project>\r
</projects>\r
<buildSpec>\r
<buildCommand>\r
-#Wed Feb 10 17:35:27 PST 2010\r
+#Tue Apr 27 13:04:23 PDT 2010\r
eclipse.preferences.version=1\r
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning\r
org.eclipse.jdt.core.compiler.source=1.6\r
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>runtime</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<xs:schema
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/collectionobject"
xmlns="http://collectionspace.org/services/collectionobject"
targetNamespace="http://collectionspace.org/services/collectionobject"
- version="0.1"
->
-
+ version="0.1">
+
<!--
Avoid XmlRootElement nightmare:
See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
</xs:sequence>
</xs:complexType>
- <!-- collection objects as in nuxeo repository -->
+ <!-- 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>
+
<xs:element name="collectionobjects-common-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="collection-object-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="objectNumber" type="xs:string"
- minOccurs="1" />
- <xs:element name="title" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrive collection object 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:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="collection-object-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="objectNumber" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="title" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrive collection object 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>
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;
public class CollectionObjectDocumentModelHandler
extends RemoteDocumentModelHandlerImpl<CollectionobjectsCommon, CollectionobjectsCommonList> {
+ /** The logger. */
private final Logger logger = LoggerFactory.getLogger(CollectionObjectDocumentModelHandler.class);
/**
* collectionObject is used to stash JAXB object to use when handle is called
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<DocumentModel> 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<DocumentModel> 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<DocumentModelList> wrapDoc) throws Exception {
- DocumentModelList docList = wrapDoc.getWrappedObject();
-
- CollectionobjectsCommonList coList = new CollectionobjectsCommonList();
+ CollectionobjectsCommonList coList = this.extractPagingInfo(new CollectionobjectsCommonList(),
+ wrapDoc);
List<CollectionobjectsCommonList.CollectionObjectListItem> 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<DocumentModel> iter = docList.iterator();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
while(iter.hasNext()){
DocumentModel docModel = iter.next();
CollectionObjectListItem coListItem = new CollectionObjectListItem();
return coList;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#fillAllParts(org.collectionspace.services.common.document.DocumentWrapper)
+ */
@Override
public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
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<DocumentModel> wrapDoc) throws Exception {
DocumentModel docModel = wrapDoc.getWrappedObject();
//FIXME property setter should be dynamically set using schema inspection
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;
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;
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<DocumentModelList> 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<DocumentModel> wrapDoc)
throws Exception {
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>runtime</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<xs:schema
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/contact"
xmlns="http://collectionspace.org/services/contact"
targetNamespace="http://collectionspace.org/services/contact"
</xs:complexType>
</xs:element>
- <!-- contact records, as in nuxeo repository -->
+ <!-- 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>
+
+ <!-- contact records, as in Nuxeo repository -->
<xs:element name="contacts-common-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="contact-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="addressPlace" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrive contact 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:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="contact-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="addressPlace" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrive contact 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>
import org.slf4j.LoggerFactory;
/**
- * ContactDocumentModelHandler
- *
- * $LastChangedRevision: $
- * $LastChangedDate: $
+ * The Class ContactDocumentModelHandler.
*/
public class ContactDocumentModelHandler
extends RemoteDocumentModelHandlerImpl<ContactsCommon, ContactsCommonList> {
+ /** 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<DocumentModel> 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<DocumentModel> 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<DocumentModelList> wrapDoc) throws Exception {
- DocumentModelList docList = wrapDoc.getWrappedObject();
-
- ContactsCommonList coList = new ContactsCommonList();
+ ContactsCommonList coList = extractPagingInfo(new ContactsCommonList(), wrapDoc);
List<ContactsCommonList.ContactListItem> 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<DocumentModel> iter = docList.iterator();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
while(iter.hasNext()){
DocumentModel docModel = iter.next();
ContactListItem clistItem = new ContactListItem();
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) {
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>runtime</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<xs:schema
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/dimension"
xmlns="http://collectionspace.org/services/dimension"
targetNamespace="http://collectionspace.org/services/dimension"
- version="0.1"
->
+ version="0.1">
<!--
Avoid XmlRootElement nightmare:
</xs:complexType>
</xs:element>
+ <!-- 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>
+
<!-- dimension records, as in nuxeo repository -->
<xs:element name="dimensions-common-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="dimension-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="dimension" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrive dimension 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:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="dimension-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="dimension" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrive dimension 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>
@Override
public DimensionsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- DocumentModelList docList = wrapDoc.getWrappedObject();
-
- DimensionsCommonList coList = new DimensionsCommonList();
+ DimensionsCommonList coList = extractPagingInfo(new DimensionsCommonList(), wrapDoc) ;
List<DimensionsCommonList.DimensionListItem> 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<DocumentModel> iter = docList.iterator();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
while(iter.hasNext()){
DocumentModel docModel = iter.next();
DimensionListItem ilistItem = new DimensionListItem();
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>runtime</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<xs:schema
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/intake"
xmlns="http://collectionspace.org/services/intake"
targetNamespace="http://collectionspace.org/services/intake"
</xs:complexType>
</xs:element>
+ <!-- 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>
+
<!-- intake records, as in nuxeo repository -->
<xs:element name="intakes-common-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="intake-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="entryNumber" type="xs:string"
- minOccurs="1" />
- <xs:element name="depositor" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrive intake 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:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="intake-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="entryNumber" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="depositor" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrive intake 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>
public class IntakeDocumentModelHandler
extends RemoteDocumentModelHandlerImpl<IntakesCommon, IntakesCommonList> {
+ /** The logger. */
private final Logger logger = LoggerFactory.getLogger(IntakeDocumentModelHandler.class);
/**
* intake is used to stash JAXB object to use when handle is called
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<DocumentModel> 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<DocumentModel> 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<DocumentModelList> wrapDoc) throws Exception {
- DocumentModelList docList = wrapDoc.getWrappedObject();
-
- IntakesCommonList coList = new IntakesCommonList();
+ IntakesCommonList coList = this.extractPagingInfo(new IntakesCommonList(), wrapDoc);
List<IntakesCommonList.IntakeListItem> 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<DocumentModel> iter = docList.iterator();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
while(iter.hasNext()){
DocumentModel docModel = iter.next();
IntakeListItem ilistItem = new IntakeListItem();
\r
<xs:schema\r
xmlns:xs="http://www.w3.org/2001/XMLSchema"\r
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"\r
+ jaxb:version="1.0" elementFormDefault="unqualified"\r
xmlns="http://collectionspace.org/services/relation"\r
xmlns:rel="http://collectionspace.org/services/relation"\r
- targetNamespace="http://collectionspace.org/services/relation"\r
- >\r
+ targetNamespace="http://collectionspace.org/services/relation">\r
\r
<!-- Relation -->\r
<xs:element name="relations_common">\r
</xs:restriction>\r
</xs:simpleType>\r
\r
+ <!-- This is the base class for paginated lists -->\r
+ <xs:complexType name="abstractCommonList">\r
+ <xs:annotation>\r
+ <xs:appinfo>\r
+ <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>\r
+ </xs:appinfo>\r
+ </xs:annotation>\r
+ </xs:complexType>\r
+ \r
<!-- collection objects as in nuxeo repository -->\r
<xs:element name="relations-common-list">\r
<xs:complexType>\r
- <xs:sequence>\r
- <xs:element name="relation-list-item" maxOccurs="unbounded">\r
- <xs:complexType>\r
- <xs:sequence>\r
- <!-- uri to retrive collection object details -->\r
- <xs:element name="uri" type="xs:anyURI" minOccurs="1"/>\r
- <xs:element name="csid" type="xs:string" minOccurs="1"/>\r
- <xs:element name="subjectCsid" type="xs:string" minOccurs="1"/>\r
- <xs:element name="objectCsid" type="xs:string" minOccurs="1"/>\r
- </xs:sequence>\r
- </xs:complexType>\r
- </xs:element>\r
- </xs:sequence>\r
+ <xs:complexContent>\r
+ <xs:extension base="abstractCommonList"> \r
+ <xs:sequence>\r
+ <xs:element name="relation-list-item" maxOccurs="unbounded">\r
+ <xs:complexType>\r
+ <xs:sequence>\r
+ <!-- uri to retrive collection object details -->\r
+ <xs:element name="uri" type="xs:anyURI" minOccurs="1"/>\r
+ <xs:element name="csid" type="xs:string" minOccurs="1"/>\r
+ <xs:element name="subjectCsid" type="xs:string" minOccurs="1"/>\r
+ <xs:element name="objectCsid" type="xs:string" minOccurs="1"/>\r
+ </xs:sequence>\r
+ </xs:complexType>\r
+ </xs:element>\r
+ </xs:sequence>\r
+ </xs:extension>\r
+ </xs:complexContent> \r
</xs:complexType>\r
</xs:element>\r
-\r
+ \r
</xs:schema>\r
\r
\r
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>runtime</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<xs:schema
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/loanin"
xmlns="http://collectionspace.org/services/loanin"
targetNamespace="http://collectionspace.org/services/loanin"
</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>
+
<!-- loansin records, as in nuxeo repository -->
<xs:element name="loansin-common-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="loanin-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="loanInNumber" type="xs:string"
- minOccurs="1" />
- <xs:element name="loanReturnDate" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrive details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="loanin-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="loanInNumber" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="loanReturnDate" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrive details -->
+ <xs:element name="uri" type="xs:anyURI"
+ minOccurs="1" />
+ <xs:element name="csid" type="xs:string"
+ minOccurs="1" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
</xs:complexType>
</xs:element>
public class LoaninDocumentModelHandler
extends RemoteDocumentModelHandlerImpl<LoansinCommon, LoansinCommonList> {
+ /** The logger. */
private final Logger logger = LoggerFactory.getLogger(LoaninDocumentModelHandler.class);
/**
* loanin is used to stash JAXB object to use when handle is called
*/
private LoansinCommonList loaninList;
-
/**
* getCommonPart get associated loanin
* @return
*/
@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<DocumentModel> 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<DocumentModel> 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<DocumentModelList> wrapDoc) throws Exception {
- DocumentModelList docList = wrapDoc.getWrappedObject();
-
- LoansinCommonList coList = new LoansinCommonList();
+ LoansinCommonList coList = extractPagingInfo(new LoansinCommonList(), wrapDoc);
List<LoansinCommonList.LoaninListItem> 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<DocumentModel> iter = docList.iterator();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
while(iter.hasNext()){
DocumentModel docModel = iter.next();
LoaninListItem ilistItem = new LoaninListItem();
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>runtime</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<xs:schema
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/loanout"
xmlns="http://collectionspace.org/services/loanout"
targetNamespace="http://collectionspace.org/services/loanout"
</xs:complexType>
</xs:element>
+ <!-- This is the base class for paginated lists -->
+ <xs:complexType name="abstractCommonList">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:complexType>
+
<!-- loansout records, as in nuxeo repository -->
<xs:element name="loansout-common-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="loanout-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="loanOutNumber" type="xs:string"
- minOccurs="1" />
- <xs:element name="loanReturnDate" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrive details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="loanout-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="loanOutNumber" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="loanReturnDate" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrive details -->
+ <xs:element name="uri" type="xs:anyURI"
+ minOccurs="1" />
+ <xs:element name="csid" type="xs:string"
+ minOccurs="1" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
</xs:complexType>
</xs:element>
import org.slf4j.LoggerFactory;
/**
- * LoanoutDocumentModelHandler
- *
- * $LastChangedRevision: $
- * $LastChangedDate: $
+ * The Class LoanoutDocumentModelHandler.
*/
public class LoanoutDocumentModelHandler
extends RemoteDocumentModelHandlerImpl<LoansoutCommon, LoansoutCommonList> {
+ /** 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() {
}
/**
- * setCommonPart set associated loanout
- * @param loanout
+ * Sets the common part.
+ *
+ * @param loanout the new common part
*/
@Override
public void setCommonPart(LoansoutCommon loanout) {
}
/**
- * 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<DocumentModel> wrapDoc)
throws Exception {
throw new UnsupportedOperationException();
}
+ /**
+ * Fill common part.
+ *
+ * @param loanoutObject the loanout object
+ * @param wrapDoc the wrap doc
+ * @throws Exception the exception
+ */
@Override
public void fillCommonPart(LoansoutCommon loanoutObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
throw new UnsupportedOperationException();
}
+ /**
+ * Extract common part list.
+ *
+ * @param wrapDoc the wrap doc
+ * @return the loansout common list
+ * @throws Exception the exception
+ */
@Override
public LoansoutCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- DocumentModelList docList = wrapDoc.getWrappedObject();
-
- LoansoutCommonList coList = new LoansoutCommonList();
+ LoansoutCommonList coList = extractPagingInfo(new LoansoutCommonList(), wrapDoc);
List<LoansoutCommonList.LoanoutListItem> 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<DocumentModel> iter = docList.iterator();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
while(iter.hasNext()){
DocumentModel docModel = iter.next();
LoanoutListItem ilistItem = new LoanoutListItem();
}
/**
- * 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) {
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>runtime</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema
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"
- >
-
+ version="0.1">
+
<!-- avoid XmlRootElement nightnmare, see http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html-->
-
+
<!-- See http://wiki.collectionspace.org/display/collectionspace/Name+Authority+Schema -->
<!-- See http://wiki.collectionspace.org/display/collectionspace/Organization+Service+Home -->
-
+
<!-- Organization -->
<xs:element name="organizations_common">
<xs:complexType>
</xs:complexType>
</xs:element>
+ <!-- This is the base class for paginated lists -->
+ <xs:complexType name="abstractCommonListItem">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:complexType>
+
<!-- Organization instances, as in nuxeo repository -->
<xs:element name="organizations-common-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="pageNum" type="xs:unsignedInt" />
- <xs:element name="pageSize" type="xs:unsignedInt" />
- <xs:element name="totalItems" type="xs:unsignedInt" />
- <xs:element name="organization_list_item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve organization details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonListItem">
+ <xs:sequence>
+ <xs:element name="organization_list_item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="displayName" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrieve organization details -->
+ <xs:element name="uri" type="xs:anyURI"
+ minOccurs="1" />
+ <xs:element name="refName" type="xs:string"
+ 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
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:ns="http://collectionspace.org/services/organization"
- xmlns="http://collectionspace.org/services/organization"
- targetNamespace="http://collectionspace.org/services/organization"
- version="0.1"
->
-
-<!--
- Avoid XmlRootElement nightmare:
- See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
--->
-<!-- See http://wiki.collectionspace.org/display/collectionspace/Organization+Service+Home -->
+ 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">
+
+ <!--
+ Avoid XmlRootElement nightmare:
+ See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+ -->
+ <!-- See http://wiki.collectionspace.org/display/collectionspace/Organization+Service+Home -->
<!-- OrgAuthority -->
<xs:element name="orgauthorities_common">
<!-- OrgAuthority Information Group -->
<xs:element name="displayName" type="xs:string"/>
<xs:element name="refName" type="xs:string"/>
- <xs:element name="vocabType" type="xs:string"/>
-
+ <xs:element name="vocabType" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
+ <!-- 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>
+
<!-- OrgAuthority instances, as in nuxeo repository -->
<xs:element name="orgauthorities-common-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="pageNum" type="xs:unsignedInt" />
- <xs:element name="pageSize" type="xs:unsignedInt" />
- <xs:element name="totalItems" type="xs:unsignedInt" />
- <xs:element name="orgauthority-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="vocabType" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve orgauthority 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:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="orgauthority-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="displayName" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="refName" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="vocabType" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrieve orgauthority 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>
public class OrgAuthorityDocumentModelHandler
extends RemoteDocumentModelHandlerImpl<OrgauthoritiesCommon, OrgauthoritiesCommonList> {
+ /** The logger. */
private final Logger logger = LoggerFactory.getLogger(OrgAuthorityDocumentModelHandler.class);
/**
* orgAuthority is used to stash JAXB object to use when handle is called
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<DocumentModel> 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<DocumentModel> wrapDoc) throws Exception {
+ public void fillCommonPart(OrgauthoritiesCommon orgAuthorityObject,
+ DocumentWrapper<DocumentModel> 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<DocumentModelList> wrapDoc) throws Exception {
- DocumentModelList docList = wrapDoc.getWrappedObject();
-
- OrgauthoritiesCommonList coList = new OrgauthoritiesCommonList();
- List<OrgauthoritiesCommonList.OrgauthorityListItem> 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<DocumentModel> iter = docList.iterator();
+ OrgauthoritiesCommonList coList = this.extractPagingInfo(new OrgauthoritiesCommonList(), wrapDoc);
+ List<OrgauthoritiesCommonList.OrgauthorityListItem> list = coList.getOrgauthorityListItem();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
while(iter.hasNext()){
DocumentModel docModel = iter.next();
OrgauthorityListItem ilistItem = new OrgauthorityListItem();
public class OrganizationDocumentModelHandler
extends RemoteDocumentModelHandlerImpl<OrganizationsCommon, OrganizationsCommonList> {
+ /** The logger. */
private final Logger logger = LoggerFactory.getLogger(OrganizationDocumentModelHandler.class);
/**
* Common part schema label
*/
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<DocumentModel> wrapDoc) throws Exception {
// first fill all the parts of the document
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<DocumentModel> wrapDoc) throws Exception {
super.handleUpdate(wrapDoc);
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<String, Object> extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta)
throws Exception {
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<DocumentModel> 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<OrganizationsCommonList.OrganizationListItem> 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<DocumentModel> 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<DocumentModelList> wrapDoc)
+ throws Exception {
+ OrganizationsCommonList coList = this.extractPagingInfo(new OrganizationsCommonList(), wrapDoc);
+ List<OrganizationsCommonList.OrganizationListItem> list = coList.getOrganizationListItem();
+ Iterator<DocumentModel> 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;
}
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>runtime</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:ns="http://collectionspace.org/services/person"
- xmlns="http://collectionspace.org/services/person"
- targetNamespace="http://collectionspace.org/services/person"
- version="0.1"
->
-
-
-<!-- avoid XmlRootElement nightnmare, see http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html-->
-<!-- See http://wiki.collectionspace.org/display/collectionspace/Person+Service+Home -->
+ 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"
+ >
+
+
+ <!-- avoid XmlRootElement nightnmare, see http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html-->
+ <!-- See http://wiki.collectionspace.org/display/collectionspace/Person+Service+Home -->
<!-- Person -->
<xs:element name="persons_common">
</xs:complexType>
</xs:element>
+ <!-- This is the base class for paginated lists -->
+ <xs:complexType name="abstractCommonListItem">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:complexType>
+
<!-- Person instances, as in nuxeo repository -->
<xs:element name="persons-common-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="pageNum" type="xs:unsignedInt" />
- <xs:element name="pageSize" type="xs:unsignedInt" />
- <xs:element name="totalItems" type="xs:unsignedInt" />
- <xs:element name="person_list_item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve person details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonListItem">
+ <xs:sequence>
+ <xs:element name="person_list_item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="displayName" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrieve person details -->
+ <xs:element name="uri" type="xs:anyURI"
+ minOccurs="1" />
+ <xs:element name="refName" type="xs:string"
+ 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
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:ns="http://collectionspace.org/services/person"
- xmlns="http://collectionspace.org/services/person"
- targetNamespace="http://collectionspace.org/services/person"
- version="0.1"
->
-
-<!--
- Avoid XmlRootElement nightmare:
- See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
--->
-<!-- See http://wiki.collectionspace.org/display/collectionspace/Person+Service+Home -->
+ 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"
+ >
+
+ <!--
+ Avoid XmlRootElement nightmare:
+ See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+ -->
+ <!-- See http://wiki.collectionspace.org/display/collectionspace/Person+Service+Home -->
<!-- PersonAuthority -->
<xs:element name="personauthorities_common">
<xs:element name="displayName" type="xs:string"/>
<xs:element name="refName" type="xs:string"/>
<xs:element name="vocabType" type="xs:string"/>
-
+
</xs:sequence>
</xs:complexType>
</xs:element>
+ <!-- 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>
+
+
<!-- PersonAuthority instances, as in nuxeo repository -->
<xs:element name="personauthorities-common-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="pageNum" type="xs:unsignedInt" />
- <xs:element name="pageSize" type="xs:unsignedInt" />
- <xs:element name="totalItems" type="xs:unsignedInt" />
- <xs:element name="personauthority-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="vocabType" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve personauthority 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:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="personauthority-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="displayName" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="refName" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="vocabType" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrieve personauthority 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>
@Override
public PersonauthoritiesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- DocumentModelList docList = wrapDoc.getWrappedObject();
+ PersonauthoritiesCommonList coList = extractPagingInfo(new PersonauthoritiesCommonList(),
+ wrapDoc);
- PersonauthoritiesCommonList coList = new PersonauthoritiesCommonList();
- List<PersonauthoritiesCommonList.PersonauthorityListItem> 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<DocumentModel> iter = docList.iterator();
+ List<PersonauthoritiesCommonList.PersonauthorityListItem> list = coList.getPersonauthorityListItem();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
while(iter.hasNext()){
DocumentModel docModel = iter.next();
PersonauthorityListItem ilistItem = new PersonauthorityListItem();
public class PersonDocumentModelHandler
extends RemoteDocumentModelHandlerImpl<PersonsCommon, PersonsCommonList> {
+ /** The logger. */
private final Logger logger = LoggerFactory.getLogger(PersonDocumentModelHandler.class);
/**
* Common part schema label
*/
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<DocumentModel> wrapDoc) throws Exception {
// first fill all the parts of the document
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<DocumentModel> 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,
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<String, Object> extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta)
throws Exception {
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<PersonsCommonList.PersonListItem> 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<DocumentModel> 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<DocumentModelList> wrapDoc) throws Exception {
+ PersonsCommonList coList = extractPagingInfo(new PersonsCommonList(), wrapDoc);
+ List<PersonsCommonList.PersonListItem> list = coList.getPersonListItem();
+ Iterator<DocumentModel> 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
public class RelationDocumentModelHandler
extends RemoteDocumentModelHandlerImpl<RelationsCommon, RelationsCommonList> {
+ /** The logger. */
private final Logger logger = LoggerFactory.getLogger(RelationDocumentModelHandler.class);
/**
* relation is used to stash JAXB object to use when handle is called
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<DocumentModel> 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<DocumentModel> 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<DocumentModelList> 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<RelationsCommonList.RelationListItem> 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<DocumentModel> iter = docList.iterator();
+ Iterator<DocumentModel> 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());
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#fillAllParts(org.collectionspace.services.common.document.DocumentWrapper)
+ */
@Override
public void fillAllParts(DocumentWrapper<DocumentModel> 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<DocumentModel> wrapDoc) throws Exception {
DocumentModel docModel = wrapDoc.getWrappedObject();
//FIXME property setter should be dynamically set using schema inspection
}
+ /* (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;
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/org.collectionspace.services.jaxb"/>\r
<classpathentry kind="output" path="target/classes"/>\r
</classpath>\r
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>runtime</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<finalName>collectionspace-services-vocabulary-jaxb</finalName>
-->
<xs:schema
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:ns="http://collectionspace.org/services/vocabulary"
- xmlns="http://collectionspace.org/services/vocabulary"
- targetNamespace="http://collectionspace.org/services/vocabulary"
- version="0.1"
->
-
-<!--
- Avoid XmlRootElement nightmare:
- See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
--->
-<!-- See http://wiki.collectionspace.org/display/collectionspace/Vocabulary+Schema -->
+ 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"
+ >
+
+ <!--
+ Avoid XmlRootElement nightmare:
+ See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+ -->
+ <!-- See http://wiki.collectionspace.org/display/collectionspace/Vocabulary+Schema -->
<!-- Vocabulary -->
<xs:element name="vocabularies_common">
<!-- Vocabulary Information Group -->
<xs:element name="displayName" type="xs:string"/>
<xs:element name="refName" type="xs:string"/>
- <xs:element name="vocabType" type="xs:string"/>
-
+ <xs:element name="vocabType" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
+ <!-- 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>
+
<!-- Vocabulary instances, as in nuxeo repository -->
<xs:element name="vocabularies-common-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="pageNum" type="xs:unsignedInt" />
- <xs:element name="pageSize" type="xs:unsignedInt" />
- <xs:element name="totalItems" type="xs:unsignedInt" />
- <xs:element name="vocabulary-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="vocabType" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve vocabulary 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:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="vocabulary-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="displayName" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="refName" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="vocabType" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrieve vocabulary 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>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema
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"
</xs:complexType>
</xs:element>
+ <!-- This is the base class for paginated lists -->
+ <xs:complexType name="abstractCommonListItem">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:complexType>
+
<!-- Vocabularyitem instances, as in nuxeo repository -->
<xs:element name="vocabularyitems-common-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="pageNum" type="xs:unsignedInt" />
- <xs:element name="pageSize" type="xs:unsignedInt" />
- <xs:element name="totalItems" type="xs:unsignedInt" />
- <xs:element name="vocabularyitem_list_item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve vocabularyitem details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonListItem">
+ <xs:sequence>
+ <xs:element name="vocabularyitem_list_item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="displayName" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrieve vocabularyitem details -->
+ <xs:element name="uri" type="xs:anyURI"
+ minOccurs="1" />
+ <xs:element name="refName" type="xs:string"
+ 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>
public class VocabularyDocumentModelHandler
extends RemoteDocumentModelHandlerImpl<VocabulariesCommon, VocabulariesCommonList> {
+ /** The logger. */
private final Logger logger = LoggerFactory.getLogger(VocabularyDocumentModelHandler.class);
/**
* vocabulary is used to stash JAXB object to use when handle is called
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<DocumentModel> 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<DocumentModel> 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<DocumentModelList> wrapDoc) throws Exception {
- DocumentModelList docList = wrapDoc.getWrappedObject();
-
- VocabulariesCommonList coList = new VocabulariesCommonList();
+ public VocabulariesCommonList extractCommonPartList(
+ DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+ VocabulariesCommonList coList = extractPagingInfo(new VocabulariesCommonList(), wrapDoc);
List<VocabulariesCommonList.VocabularyListItem> 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<DocumentModel> iter = docList.iterator();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
while(iter.hasNext()){
DocumentModel docModel = iter.next();
VocabularyListItem ilistItem = new VocabularyListItem();
}
@Override
- public VocabularyitemsCommonList extractCommonPartList(DocumentWrapper wrapDoc)
- throws Exception {
- VocabularyitemsCommonList coList = new VocabularyitemsCommonList();
- try{
- DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject();
-
- List<VocabularyitemsCommonList.VocabularyitemListItem> 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<DocumentModel> 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<DocumentModelList> 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<VocabularyitemsCommonList.VocabularyitemListItem> list = coList.getVocabularyitemListItem();
+ Iterator<DocumentModel> 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;
}
/**