]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
b59bf2dcad6ff670276341a99567aad8dcc24713
[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  * $LastChangedRevision: $
39  * $LastChangedDate: $
40  */
41 public class VocabularyItemDocumentModelHandler
42                 extends AuthorityItemDocumentModelHandler<VocabularyitemsCommon> {
43
44     private static final String COMMON_PART_LABEL = "vocabularyitems_common";   
45     
46     public VocabularyItemDocumentModelHandler() {
47         super(COMMON_PART_LABEL);
48     }
49
50     @Override
51     public String getAuthorityServicePath(){
52         return VocabularyClient.SERVICE_PATH_COMPONENT;    // CSPACE-3932
53     }
54     
55     @Override
56     protected String getRefPropName() {
57         return ServiceBindingUtils.TERM_REF_PROP;
58     }
59
60     /**
61      * getQProperty converts the given property to qualified schema property
62      * @param prop
63      * @return
64      */
65     @Override
66     public String getQProperty(String prop) {
67         return VocabularyItemConstants.NUXEO_SCHEMA_NAME + ":" + prop;
68     }
69     
70     /*
71      * Because the Vocabulary service's item schema is not standard, we need to override the default authority item schema behavior.
72      * (non-Javadoc)
73      * @see org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler#getPrimaryDisplayName(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, java.lang.String, java.lang.String)
74      */
75         @Override
76         protected String getPrimaryDisplayName(DocumentModel docModel,
77                         String schema, String complexPropertyName, String fieldName) { // ignore 'complexPropertyName', and 'fieldName' -use VocabularyItem specific alternatives instead.
78                 String result = null;
79
80                 try {
81                         result = (String) docModel.getProperty(schema, VocabularyItemJAXBSchema.DISPLAY_NAME);
82                 } catch (Exception e) {
83                         throw new RuntimeException("Unknown problem retrieving property {"
84                                         + schema + ":" + fieldName + "}." + e.getLocalizedMessage());
85                 }
86
87                 return result;
88         }
89     
90     /*
91      * Because the Vocabulary service's item schema is not standard, we need to override this method.
92      */
93     @Override
94         protected ListResultField getListResultsDisplayNameField() {
95                 ListResultField result = new ListResultField();
96
97                 result.setElement(VocabularyItemJAXBSchema.DISPLAY_NAME);
98                 result.setXpath(VocabularyItemJAXBSchema.DISPLAY_NAME);
99
100                 return result;
101         }
102     
103     protected ListResultField getListResultsTermStatusField() {
104                 ListResultField result = new ListResultField();
105
106                 result.setElement(AuthorityItemJAXBSchema.TERM_STATUS);
107                 result.setXpath(AuthorityItemJAXBSchema.TERM_STATUS);
108
109                 return result;
110     }    
111     
112 }
113