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