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.location.nuxeo;
26 import org.collectionspace.services.LocationJAXBSchema;
27 import org.collectionspace.services.client.LocationAuthorityClient;
28 import org.collectionspace.services.common.document.DocumentWrapper;
29 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
30 import org.collectionspace.services.location.LocationsCommon;
31 import org.nuxeo.ecm.core.api.DocumentModel;
34 * LocationDocumentModelHandler
36 * $LastChangedRevision: $
43 public class LocationDocumentModelHandler
44 extends AuthorityItemDocumentModelHandler<LocationsCommon> {
47 * Common part schema label
49 private static final String COMMON_PART_LABEL = "locations_common";
51 public LocationDocumentModelHandler() {
52 super(COMMON_PART_LABEL);
56 public String getAuthorityServicePath(){
57 return LocationAuthorityClient.SERVICE_PATH_COMPONENT; // CSPACE-3932
61 * Handle display name.
63 * @param docModel the doc model
64 * @throws Exception the exception
67 // protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception {
68 // String commonPartLabel = getServiceContext().getCommonPartLabel("locations");
69 // Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
70 // LocationJAXBSchema.DISPLAY_NAME_COMPUTED);
71 // Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
72 // LocationJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
73 // if(displayNameComputed==null)
74 // displayNameComputed = true;
75 // if(shortDisplayNameComputed==null)
76 // shortDisplayNameComputed = true;
77 // if (displayNameComputed || shortDisplayNameComputed) {
78 // String displayName = prepareDefaultDisplayName(
79 // (String)docModel.getProperty(commonPartLabel, LocationJAXBSchema.NAME ));
80 // if (displayNameComputed) {
81 // docModel.setProperty(commonPartLabel, LocationJAXBSchema.DISPLAY_NAME,
84 // if (shortDisplayNameComputed) {
85 // docModel.setProperty(commonPartLabel, LocationJAXBSchema.SHORT_DISPLAY_NAME,
92 * Produces a default displayName from the basic name and dates fields.
93 * @see LocationAuthorityClientUtils.prepareDefaultDisplayName() which
94 * duplicates this logic, until we define a service-general utils package
95 * that is neither client nor service specific.
104 private static String prepareDefaultDisplayName(
105 String name ) throws Exception {
106 StringBuilder newStr = new StringBuilder();
108 return newStr.toString();
112 * getQProperty converts the given property to qualified schema property
117 public String getQProperty(String prop) {
118 return LocationConstants.NUXEO_SCHEMA_NAME + ":" + prop;