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.taxonomy.nuxeo;
26 import java.util.Iterator;
27 import java.util.List;
29 import org.collectionspace.services.common.document.DocumentHandler.Action;
30 import org.collectionspace.services.common.document.DocumentFilter;
31 import org.collectionspace.services.common.document.DocumentWrapper;
32 import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
33 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
34 import org.collectionspace.services.jaxb.AbstractCommonList;
35 import org.collectionspace.services.taxonomy.TaxonomyauthorityCommon;
36 import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList;
37 import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList.TaxonomyauthorityListItem;
39 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
40 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
41 import org.nuxeo.ecm.core.api.DocumentModel;
42 import org.nuxeo.ecm.core.api.DocumentModelList;
43 import org.slf4j.Logger;
44 import org.slf4j.LoggerFactory;
47 * TaxonomyAuthorityDocumentModelHandler
49 * $LastChangedRevision$
52 public class TaxonomyAuthorityDocumentModelHandler
53 extends AuthorityDocumentModelHandler<TaxonomyauthorityCommon, TaxonomyauthorityCommonList> {
56 * Common part schema label
58 private static final String COMMON_PART_LABEL = "taxonomyauthority_common";
60 public TaxonomyAuthorityDocumentModelHandler() {
61 super(COMMON_PART_LABEL);
65 public TaxonomyauthorityCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
66 TaxonomyauthorityCommonList coList = extractPagingInfo(new TaxonomyauthorityCommonList(),
68 AbstractCommonList commonList = (AbstractCommonList) coList;
69 commonList.setFieldsReturned("displayName|refName|shortIdentifier|vocabType|uri|csid");
71 //FIXME: iterating over a long list of documents is not a long term
72 //strategy...need to change to more efficient iterating in future
73 List<TaxonomyauthorityCommonList.TaxonomyauthorityListItem> list = coList.getTaxonomyauthorityListItem();
74 String label = getServiceContext().getCommonPartLabel();
75 Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
76 while(iter.hasNext()){
77 DocumentModel docModel = iter.next();
78 TaxonomyauthorityListItem ilistItem = new TaxonomyauthorityListItem();
79 ilistItem.setDisplayName((String) docModel.getProperty(label,
80 AuthorityJAXBSchema.DISPLAY_NAME));
81 ilistItem.setRefName((String) docModel.getProperty(label,
82 AuthorityJAXBSchema.REF_NAME));
83 ilistItem.setShortIdentifier((String) docModel.getProperty(label,
84 AuthorityJAXBSchema.SHORT_IDENTIFIER));
85 ilistItem.setVocabType((String) docModel.getProperty(label,
86 AuthorityJAXBSchema.VOCAB_TYPE));
87 String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
88 ilistItem.setUri(getServiceContextPath() + id);
89 ilistItem.setCsid(id);
97 * getQProperty converts the given property to qualified schema property
102 public String getQProperty(String prop) {
103 return TaxonomyAuthorityConstants.NUXEO_SCHEMA_NAME + ":" + prop;