import org.collectionspace.services.common.document.DocumentWrapper;\r
import org.collectionspace.services.common.repository.RepositoryClient;\r
import org.collectionspace.services.common.service.ServiceBindingType;\r
+import org.collectionspace.services.jaxb.AbstractCommonList;\r
import org.collectionspace.services.nuxeo.util.NuxeoUtils;\r
\r
/**\r
String refName,\r
int pageSize, int pageNum, boolean computeTotal) throws DocumentException, DocumentNotFoundException {\r
AuthorityRefDocList wrapperList = new AuthorityRefDocList();\r
+ AbstractCommonList commonList = (AbstractCommonList) wrapperList;\r
+ commonList.setPageNum(pageNum);\r
+ commonList.setPageSize(pageSize);\r
+ \r
List<AuthorityRefDocList.AuthorityRefDocItem> list =\r
wrapperList.getAuthorityRefDocItem();\r
TenantBindingConfigReaderImpl tReader =\r
docTypes, whereClause.toString(), pageSize, pageNum, computeTotal);\r
// Now we gather the info for each document into the list and return\r
DocumentModelList docList = docListWrapper.getWrappedObject();\r
+ // Set num of items in list. this is useful to our testing framework.\r
+ commonList.setItemsInPage(docList.size());\r
+ // set the total result size\r
+ commonList.setTotalItems(docList.totalSize());\r
Iterator<DocumentModel> iter = docList.iterator();\r
while (iter.hasNext()) {\r
DocumentModel docModel = iter.next();\r
List<String> authRefFieldNames) throws PropertyException {
AuthorityRefList authRefList = new AuthorityRefList();
+ AbstractCommonList commonList = (AbstractCommonList) authRefList;
+
+ DocumentFilter docFilter = this.getDocumentFilter();
+ long pageSize = docFilter.getPageSize();
+ long pageNum = pageSize != 0 ? docFilter.getOffset() / pageSize : pageSize;
+ // set the page size and page number
+ commonList.setPageNum(pageNum);
+ commonList.setPageSize(pageSize);
+
List<AuthorityRefList.AuthorityRefItem> list = authRefList.getAuthorityRefItem();
DocumentModel docModel = docWrapper.getWrappedObject();
try {
+ int iFirstToUse = (int)(pageSize*pageNum);
+ int nFoundInPage = 0;
+ int nFoundTotal = 0;
for (String authRefFieldName : authRefFieldNames) {
// FIXME: Can use the schema to validate field existence,
// If this is a single scalar field, with no children,
// add an item with its values to the authRefs list.
if (DocumentUtils.isSimpleType(prop)) {
- appendToAuthRefsList(prop.getValue(String.class), schemaName, authRefFieldName, list);
+ String refName = prop.getValue(String.class);
+ if (refName == null) {
+ continue;
+ }
+ refName = refName.trim();
+ if (refName.isEmpty()) {
+ continue;
+ }
+ if((nFoundTotal < iFirstToUse)
+ || (nFoundInPage >= pageSize)) {
+ nFoundTotal++;
+ continue;
+ }
+ nFoundTotal++;
+ nFoundInPage++;
+ appendToAuthRefsList(refName, schemaName, authRefFieldName, list);
// Otherwise, if this field has children, cycle through each child.
//
Collection<Property> childProp = prop.getChildren();
for (Property cProp : childProp) {
if (DocumentUtils.isSimpleType(cProp) && cProp.getName().equals(descendantAuthRefFieldName)) {
- appendToAuthRefsList(cProp.getValue(String.class), schemaName, descendantAuthRefFieldName, list);
+ String refName = cProp.getValue(String.class);
+ if (refName == null) {
+ continue;
+ }
+ refName = refName.trim();
+ if (refName.isEmpty()) {
+ continue;
+ }
+ if((nFoundTotal < iFirstToUse)
+ || (nFoundInPage >= pageSize)) {
+ nFoundTotal++;
+ continue;
+ }
+ nFoundTotal++;
+ nFoundInPage++;
+ appendToAuthRefsList(refName, schemaName, descendantAuthRefFieldName, list);
} else if ((DocumentUtils.isListType(cProp) || DocumentUtils.isComplexType(cProp))
&& prop.size() > 0) {
Collection<Property> grandChildProp = cProp.getChildren();
for (Property gProp : grandChildProp) {
if (DocumentUtils.isSimpleType(gProp) && gProp.getName().equals(descendantAuthRefFieldName)) {
- appendToAuthRefsList(gProp.getValue(String.class), schemaName, descendantAuthRefFieldName, list);
+ String refName = gProp.getValue(String.class);
+ if (refName == null) {
+ continue;
+ }
+ refName = refName.trim();
+ if (refName.isEmpty()) {
+ continue;
+ }
+ if((nFoundTotal < iFirstToUse)
+ || (nFoundInPage >= pageSize)) {
+ nFoundTotal++;
+ continue;
+ }
+ nFoundTotal++;
+ nFoundInPage++;
+ appendToAuthRefsList(refName, schemaName, descendantAuthRefFieldName, list);
}
}
}
}
-
}
-
}
-
+ // Set num of items in list. this is useful to our testing framework.
+ commonList.setItemsInPage(nFoundInPage);
+ // set the total result size
+ commonList.setTotalItems(nFoundTotal);
} catch (PropertyException pe) {
String msg = "Attempted to retrieve value for invalid or missing authority field. "
private void appendToAuthRefsList(String refName, String schemaName,
String fieldName, List<AuthorityRefList.AuthorityRefItem> list)
throws Exception {
- if (refName == null || refName.trim().isEmpty()) {
- return;
- }
if (DocumentUtils.getSchemaNamePart(fieldName).isEmpty()) {
fieldName = DocumentUtils.appendSchemaName(schemaName, fieldName);
}
-->
<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="http://collectionspace.org/services/common/authorityref"
targetNamespace="http://collectionspace.org/services/common/authorityref"
version="0.1"
>
+ <!-- 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="authority-ref-doc-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="authority-ref-doc-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="docType" type="xs:string" minOccurs="1" />
- <xs:element name="docId" type="xs:string" minOccurs="1" />
- <xs:element name="docNumber" type="xs:string" minOccurs="0" />
- <xs:element name="docName" type="xs:string" minOccurs="0" />
- <xs:element name="sourceField" type="xs:string" minOccurs="1" />
- <xs:element name="uri" type="xs:anyURI" minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="authority-ref-doc-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="docType" type="xs:string" minOccurs="1" />
+ <xs:element name="docId" type="xs:string" minOccurs="1" />
+ <xs:element name="docNumber" type="xs:string" minOccurs="0" />
+ <xs:element name="docName" type="xs:string" minOccurs="0" />
+ <xs:element name="sourceField" type="xs:string" minOccurs="1" />
+ <xs:element name="uri" type="xs:anyURI" 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:jaxb="http://java.sun.com/xml/ns/jaxb"
+ jaxb:version="1.0" elementFormDefault="unqualified"
xmlns="http://collectionspace.org/services/common/authorityref"
targetNamespace="http://collectionspace.org/services/common/authorityref"
version="0.1"
>
+ <!-- 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="authority-ref-list">
<xs:complexType>
- <xs:sequence>
- <xs:element name="authority-ref-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="sourceField" type="xs:string" minOccurs="1" />
- <xs:element name="refName" type="xs:string" minOccurs="1" />
- <xs:element name="authDisplayName" type="xs:string" minOccurs="1" />
- <xs:element name="itemDisplayName" type="xs:string" minOccurs="1" />
- <xs:element name="uri" type="xs:anyURI" minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="authority-ref-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="sourceField" type="xs:string" minOccurs="1" />
+ <xs:element name="refName" type="xs:string" minOccurs="1" />
+ <xs:element name="authDisplayName" type="xs:string" minOccurs="1" />
+ <xs:element name="itemDisplayName" type="xs:string" minOccurs="1" />
+ <xs:element name="uri" type="xs:anyURI" minOccurs="1" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
</xs:complexType>
</xs:element>