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.vocabulary.nuxeo;
26 import java.util.Iterator;
27 import java.util.List;
29 import org.collectionspace.services.client.VocabularyClient;
30 import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
31 import org.collectionspace.services.common.document.DocumentWrapper;
32 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
33 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
34 import org.collectionspace.services.jaxb.AbstractCommonList;
35 import org.collectionspace.services.vocabulary.VocabularyitemsCommon;
36 import org.collectionspace.services.vocabulary.VocabularyitemsCommonList;
37 import org.collectionspace.services.vocabulary.VocabularyitemsCommonList.VocabularyitemListItem;
38 import org.nuxeo.ecm.core.api.DocumentModel;
39 import org.nuxeo.ecm.core.api.DocumentModelList;
40 import org.slf4j.Logger;
41 import org.slf4j.LoggerFactory;
44 * VocabularyItemDocumentModelHandler
46 * $LastChangedRevision: $
49 public class VocabularyItemDocumentModelHandler
50 extends AuthorityItemDocumentModelHandler<VocabularyitemsCommon, VocabularyitemsCommonList> {
52 private final Logger logger = LoggerFactory.getLogger(VocabularyItemDocumentModelHandler.class);
54 private static final String COMMON_PART_LABEL = "vocabularyitems_common";
56 public VocabularyItemDocumentModelHandler() {
57 super(COMMON_PART_LABEL);
61 public String getAuthorityServicePath(){
62 return VocabularyClient.SERVICE_PATH_COMPONENT; // CSPACE-3932
67 public VocabularyitemsCommonList extractCommonPartList(
68 DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
69 VocabularyitemsCommonList coList = extractPagingInfo(new VocabularyitemsCommonList(), wrapDoc);
70 AbstractCommonList commonList = (AbstractCommonList) coList;
71 commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid");
73 List<VocabularyitemsCommonList.VocabularyitemListItem> list = coList.getVocabularyitemListItem();
74 Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
75 String commonPartLabel = getServiceContext().getCommonPartLabel("vocabularyItems");
76 while (iter.hasNext()) {
77 DocumentModel docModel = iter.next();
78 VocabularyitemListItem ilistItem = new VocabularyitemListItem();
79 ilistItem.setDisplayName((String) docModel.getProperty(commonPartLabel,
80 AuthorityItemJAXBSchema.DISPLAY_NAME));
81 ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel,
82 AuthorityItemJAXBSchema.SHORT_IDENTIFIER));
83 ilistItem.setRefName((String) docModel.getProperty(commonPartLabel,
84 AuthorityItemJAXBSchema.REF_NAME));
85 String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
86 ilistItem.setUri("/vocabularies/" + inAuthority + "/items/" + id);
87 ilistItem.setCsid(id);
95 * getQProperty converts the given property to qualified schema property
100 public String getQProperty(String prop) {
101 return VocabularyItemConstants.NUXEO_SCHEMA_NAME + ":" + prop;