]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
591442e5d3e5fe89166137f1f92992a9acd1e5ad
[tmp/jakarta-migration.git] /
1 /**
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:
5
6  *  http://www.collectionspace.org
7  *  http://wiki.collectionspace.org
8
9  *  Copyright 2009 University of California at Berkeley
10
11  *  Licensed under the Educational Community License (ECL), Version 2.0.
12  *  You may not use this file except in compliance with this License.
13
14  *  You may obtain a copy of the ECL 2.0 License at
15
16  *  https://source.collectionspace.org/collection-space/LICENSE.txt
17
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.
23  */
24 package org.collectionspace.services.vocabulary.nuxeo;
25
26 import org.collectionspace.services.client.VocabularyClient;
27 import org.collectionspace.services.common.context.ServiceBindingUtils;
28 import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
29 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
30 import org.collectionspace.services.config.service.ListResultField;
31 import org.collectionspace.services.vocabulary.VocabularyItemJAXBSchema;
32 import org.collectionspace.services.vocabulary.VocabularyitemsCommon;
33 import org.nuxeo.ecm.core.api.DocumentModel;
34
35 /**
36  * VocabularyItemDocumentModelHandler
37  *
38  */
39 public class VocabularyItemDocumentModelHandler
40                 extends AuthorityItemDocumentModelHandler<VocabularyitemsCommon> {
41
42     public VocabularyItemDocumentModelHandler() {
43         super(VocabularyClient.SERVICE_ITEM_COMMON_PART_NAME);
44     }
45
46     @Override
47     public String getAuthorityServicePath(){
48         return VocabularyClient.SERVICE_PATH_COMPONENT;    // CSPACE-3932
49     }
50     
51     @Override
52     protected String getRefPropName() {
53         return ServiceBindingUtils.TERM_REF_PROP;
54     }
55
56     /**
57      * getQProperty converts the given property to qualified schema property
58      * @param prop
59      * @return
60      */
61     @Override
62     public String getQProperty(String prop) {
63         return VocabularyItemConstants.NUXEO_SCHEMA_NAME + ":" + prop;
64     }
65     
66     /*
67      * Because the Vocabulary service's item schema is not standard, we need to override the default authority item schema behavior.
68      * (non-Javadoc)
69      * @see org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler#getPrimaryDisplayName(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, java.lang.String, java.lang.String)
70      */
71         @Override
72         protected String getPrimaryDisplayName(DocumentModel docModel,
73                         String schema, String complexPropertyName, String fieldName) { // ignore 'complexPropertyName', and 'fieldName' -use VocabularyItem specific alternatives instead.
74                 String result = null;
75
76                 try {
77                         result = (String) docModel.getProperty(schema, VocabularyItemJAXBSchema.DISPLAY_NAME);
78                 } catch (Exception e) {
79                         throw new RuntimeException("Unknown problem retrieving property {"
80                                         + schema + ":" + fieldName + "}." + e.getLocalizedMessage());
81                 }
82
83                 return result;
84         }
85     
86     /*
87      * Because the Vocabulary service's item schema is not standard, we need to override this method.
88      */
89     @Override
90         protected ListResultField getListResultsDisplayNameField() {
91                 ListResultField result = new ListResultField();
92
93                 result.setElement(VocabularyItemJAXBSchema.DISPLAY_NAME);
94                 result.setXpath(VocabularyItemJAXBSchema.DISPLAY_NAME);
95
96                 return result;
97         }
98     
99     @Override
100     protected ListResultField getListResultsTermStatusField() {
101                 ListResultField result = new ListResultField();
102
103                 result.setElement(AuthorityItemJAXBSchema.TERM_STATUS);
104                 result.setXpath(AuthorityItemJAXBSchema.TERM_STATUS);
105
106                 return result;
107     }    
108
109         @Override
110         public String getParentCommonSchemaName() {
111                 // TODO Auto-generated method stub
112                 return VocabularyClient.SERVICE_COMMON_PART_NAME;
113         }
114     
115 }
116