]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
de974099d7ff51a5f84e6220bbd498210957ecad
[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.material.nuxeo;
25
26 import org.collectionspace.services.MaterialJAXBSchema;
27 import org.collectionspace.services.client.MaterialAuthorityClient;
28 import org.collectionspace.services.common.document.DocumentWrapper;
29 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
30 import org.collectionspace.services.material.MaterialsCommon;
31 import org.nuxeo.ecm.core.api.DocumentModel;
32
33 /**
34  * MaterialDocumentModelHandler
35  *
36  */
37 public class MaterialDocumentModelHandler
38         extends AuthorityItemDocumentModelHandler<MaterialsCommon> {
39
40     /**
41      * Common part schema label
42      */
43     private static final String COMMON_PART_LABEL = "materials_common";
44     
45     public MaterialDocumentModelHandler() {
46         super(COMMON_PART_LABEL);
47     }
48
49     @Override
50     public String getAuthorityServicePath(){
51         return MaterialAuthorityClient.SERVICE_PATH_COMPONENT;    //  CSPACE-3932
52     }
53
54         /**
55      * Handle display name.
56      *
57      * @param docModel the doc model
58      * @throws Exception the exception
59      */
60 //    @Override
61 //    protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception {
62 //        String commonPartLabel = getServiceContext().getCommonPartLabel("materials");
63 //      Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
64 //              MaterialJAXBSchema.DISPLAY_NAME_COMPUTED);
65 //      Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
66 //              MaterialJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
67 //      if(displayNameComputed==null)
68 //          displayNameComputed = true;
69 //      if(shortDisplayNameComputed==null)
70 //          shortDisplayNameComputed = true;
71 //      if (displayNameComputed || shortDisplayNameComputed) {
72 //                // Obtain the primary material name from the list of material names, for computing the display name.
73 //          String xpathToMaterialName = MaterialJAXBSchema.MATERIAL_TERM_NAME_GROUP_LIST 
74 //                        + "/[0]/" + MaterialeJAXBSchema.MATERIAL_TERM_NAME;
75 //          String materialName = getXPathStringValue(docModel, COMMON_PART_LABEL, xpathToMaterialName);
76 //          String displayName = prepareDefaultDisplayName(materialName);
77 //          if (displayNameComputed) {
78 //              docModel.setProperty(commonPartLabel, MaterialJAXBSchema.DISPLAY_NAME,
79 //                      displayName);
80 //          }
81 //          if (shortDisplayNameComputed) {
82 //              docModel.setProperty(commonPartLabel, MaterialJAXBSchema.SHORT_DISPLAY_NAME,
83 //                      displayName);
84 //          }
85 //      }
86 //    }
87     
88     /**
89      * Produces a default displayName from one or more supplied fields.
90      * @see MaterialAuthorityClientUtils.prepareDefaultDisplayName() which
91      * duplicates this logic, until we define a service-general utils package
92      * that is neither client nor service specific.
93      * @param materialName
94      * @return the default display name
95      * @throws Exception
96      */
97     private static String prepareDefaultDisplayName(
98             String materialName ) throws Exception {
99         StringBuilder newStr = new StringBuilder();
100             newStr.append(materialName);
101             return newStr.toString();
102     }
103     
104     /**
105      * getQProperty converts the given property to qualified schema property
106      * @param prop
107      * @return
108      */
109     @Override
110     public String getQProperty(String prop) {
111         return MaterialConstants.NUXEO_SCHEMA_NAME + ":" + prop;
112     }
113 }
114