2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright 2009 University of California at Berkeley
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
16 * https://source.collectionspace.org/collection-space/LICENSE.txt
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
24 package org.collectionspace.services.movement.nuxeo;
26 import java.util.Iterator;
27 import java.util.List;
29 import org.collectionspace.services.MovementJAXBSchema;
30 import org.collectionspace.services.common.document.DocumentWrapper;
31 import org.collectionspace.services.movement.MovementsCommon;
32 import org.collectionspace.services.movement.MovementsCommonList;
33 import org.collectionspace.services.movement.MovementsCommonList.MovementListItem;
34 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
35 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
36 import org.nuxeo.ecm.core.api.DocumentModel;
37 import org.nuxeo.ecm.core.api.DocumentModelList;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
42 * The Class MovementDocumentModelHandler.
44 public class MovementDocumentModelHandler
45 extends RemoteDocumentModelHandlerImpl<MovementsCommon, MovementsCommonList> {
48 private final Logger logger = LoggerFactory.getLogger(MovementDocumentModelHandler.class);
51 private MovementsCommon Movement;
53 /** The Movement list. */
54 private MovementsCommonList MovementList;
58 * Gets the common part.
60 * @return the common part
63 public MovementsCommon getCommonPart() {
68 * Sets the common part.
70 * @param Movement the new common part
73 public void setCommonPart(MovementsCommon Movement) {
74 this.Movement = Movement;
78 * Gets the common part list.
80 * @return the common part list
83 public MovementsCommonList getCommonPartList() {
88 * Sets the common part list.
90 * @param MovementList the new common part list
93 public void setCommonPartList(MovementsCommonList MovementList) {
94 this.MovementList = MovementList;
98 * Extract common part.
100 * @param wrapDoc the wrap doc
101 * @return the Movements common
102 * @throws Exception the exception
105 public MovementsCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
107 throw new UnsupportedOperationException();
113 * @param MovementObject the Movement object
114 * @param wrapDoc the wrap doc
115 * @throws Exception the exception
118 public void fillCommonPart(MovementsCommon MovementObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
119 throw new UnsupportedOperationException();
123 * Extract common part list.
125 * @param wrapDoc the wrap doc
126 * @return the Movements common list
127 * @throws Exception the exception
130 public MovementsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
131 MovementsCommonList coList = extractPagingInfo(new MovementsCommonList(), wrapDoc);
132 List<MovementsCommonList.MovementListItem> list = coList.getMovementListItem();
133 Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
134 while(iter.hasNext()){
135 DocumentModel docModel = iter.next();
136 MovementListItem ilistItem = new MovementListItem();
137 ilistItem.setMovementReferenceNumber((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
138 MovementJAXBSchema.MOVEMENT_REFERENCE_NUMBER));
139 ilistItem.setLocationDate((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
140 MovementJAXBSchema.LOCATION_DATE));
141 String id = NuxeoUtils.extractId(docModel.getPathAsString());
142 ilistItem.setUri(getServiceContextPath() + id);
143 ilistItem.setCsid(id);
151 * Gets the q property.
153 * @param prop the prop
154 * @return the q property
157 public String getQProperty(String prop) {
158 return MovementConstants.NUXEO_SCHEMA_NAME + ":" + prop;