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.GregorianCalendar;
27 import java.util.Iterator;
28 import java.util.List;
30 import org.collectionspace.services.MovementJAXBSchema;
31 import org.collectionspace.services.common.datetime.DateTimeFormatUtils;
32 import org.collectionspace.services.common.document.DocumentWrapper;
33 import org.collectionspace.services.jaxb.AbstractCommonList;
34 import org.collectionspace.services.movement.MovementsCommon;
35 import org.collectionspace.services.movement.MovementsCommonList;
36 import org.collectionspace.services.movement.MovementsCommonList.MovementListItem;
37 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
38 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
39 import org.nuxeo.ecm.core.api.DocumentModel;
40 import org.nuxeo.ecm.core.api.DocumentModelList;
41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory;
45 * The Class MovementDocumentModelHandler.
47 * $LastChangedRevision$
50 public class MovementDocumentModelHandler
51 extends RemoteDocumentModelHandlerImpl<MovementsCommon, MovementsCommonList> {
54 private final Logger logger = LoggerFactory.getLogger(MovementDocumentModelHandler.class);
57 private MovementsCommon Movement;
59 /** The Movement list. */
60 private MovementsCommonList MovementList;
63 * Gets the common part.
65 * @return the common part
68 public MovementsCommon getCommonPart() {
73 * Sets the common part.
75 * @param Movement the new common part
78 public void setCommonPart(MovementsCommon Movement) {
79 this.Movement = Movement;
83 * Gets the common part list.
85 * @return the common part list
88 public MovementsCommonList getCommonPartList() {
93 * Sets the common part list.
95 * @param MovementList the new common part list
98 public void setCommonPartList(MovementsCommonList MovementList) {
99 this.MovementList = MovementList;
103 * Extract common part.
105 * @param wrapDoc the wrap doc
106 * @return the Movements common
107 * @throws Exception the exception
110 public MovementsCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
112 throw new UnsupportedOperationException();
118 * @param MovementObject the Movement object
119 * @param wrapDoc the wrap doc
120 * @throws Exception the exception
123 public void fillCommonPart(MovementsCommon MovementObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
124 throw new UnsupportedOperationException();
128 * Extract common part list.
130 * @param wrapDoc the wrap doc
131 * @return the Movements common list
132 * @throws Exception the exception
135 public MovementsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
136 MovementsCommonList coList = extractPagingInfo(new MovementsCommonList(), wrapDoc);
137 AbstractCommonList commonList = (AbstractCommonList) coList;
138 commonList.setFieldsReturned("movementReferenceNumber|currentLocation|locationDate|uri|csid");
139 List<MovementsCommonList.MovementListItem> list = coList.getMovementListItem();
140 Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
141 String label = getServiceContext().getCommonPartLabel();
142 while(iter.hasNext()){
143 DocumentModel docModel = iter.next();
144 MovementListItem ilistItem = new MovementListItem();
145 ilistItem.setMovementReferenceNumber((String) docModel.getProperty(label,
146 MovementJAXBSchema.MOVEMENT_REFERENCE_NUMBER));
147 ilistItem.setCurrentLocation((String) docModel.getProperty(label,
148 MovementJAXBSchema.CURRENT_LOCATION));
149 GregorianCalendar gcal = (GregorianCalendar) docModel.getProperty(label,
150 MovementJAXBSchema.LOCATION_DATE);
151 ilistItem.setLocationDate(DateTimeFormatUtils.formatAsISO8601Timestamp(gcal));
152 String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
153 ilistItem.setUri(getServiceContextPath() + id);
154 ilistItem.setCsid(id);
162 * Gets the q property.
164 * @param prop the prop
165 * @return the q property
168 public String getQProperty(String prop) {
169 return MovementConstants.NUXEO_SCHEMA_NAME + ":" + prop;