]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6935: Refactored authority resource and document handler classes for better...
authorremillet <remillet@yahoo.com>
Thu, 31 Mar 2016 17:31:23 +0000 (10:31 -0700)
committerremillet <remillet@yahoo.com>
Thu, 31 Mar 2016 17:31:23 +0000 (10:31 -0700)
25 files changed:
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java
services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationAuthorityDocumentModelHandler.java
services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationDocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/common/ServiceMessages.java
services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java
services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptAuthorityDocumentModelHandler.java
services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptDocumentModelHandler.java
services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java
services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java
services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialAuthorityDocumentModelHandler.java
services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialDocumentModelHandler.java
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java
services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java
services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java
services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceAuthorityDocumentModelHandler.java
services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceDocumentModelHandler.java
services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonDocumentModelHandler.java
services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonomyAuthorityDocumentModelHandler.java
services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java
services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkAuthorityDocumentModelHandler.java
services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkDocumentModelHandler.java

index 542d2bcc7e5a9c8e9e35b254b33de8f73b24a25e..cd67fd3aa0dd9dde841c9d0fce4743de7b65d51a 100644 (file)
@@ -267,7 +267,6 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
     }
 
     public static class CsidAndShortIdentifier {
-
         String CSID;
         String shortIdentifier;
     }
@@ -298,7 +297,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             parentShortIdentifier = FETCH_SHORT_ID;
         } else {
             parentShortIdentifier = parentSpec.value;
-            String whereClause = buildWhereForAuthByName(parentSpec.value);
+            String whereClause = RefNameServiceUtils.buildWhereForAuthByName(authorityCommonSchemaName, parentSpec.value);
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getServiceName(), uriInfo);
             parentcsid = getRepositoryClient(ctx).findDocCSID(null, ctx, whereClause); //FIXME: REM - If the parent has been soft-deleted, should we be looking for the item?
         }
@@ -314,7 +313,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         if (itemSpec.form == SpecifierForm.CSID) {
             itemcsid = itemSpec.value;
         } else {
-            String itemWhereClause = buildWhereForAuthItemByName(itemSpec.value, parentcsid);
+            String itemWhereClause = RefNameServiceUtils.buildWhereForAuthItemByName(authorityItemCommonSchemaName, itemSpec.value, parentcsid);
             itemcsid = getRepositoryClient(ctx).findDocCSID(null, ctx, itemWhereClause); //FIXME: REM - Should we be looking for the 'wf_deleted' query param and filtering on it?
         }
         return itemcsid;
@@ -331,7 +330,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
        if(item == null) {
                return null;
        }
-        String whereClause = buildWhereForAuthByName(item.getParentShortIdentifier());
+        String whereClause = RefNameServiceUtils.buildWhereForAuthByName(authorityCommonSchemaName, item.getParentShortIdentifier());
         // Ensure we have the right context.
         ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(item.inAuthority.resource);
         
@@ -339,7 +338,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         RepositoryClientImpl client = (RepositoryClientImpl)getRepositoryClient(ctx);
         String parentcsid = client.findDocCSID(repoSession, ctx, whereClause);
 
-        String itemWhereClause = buildWhereForAuthItemByName(item.getShortIdentifier(), parentcsid);
+        String itemWhereClause = RefNameServiceUtils.buildWhereForAuthItemByName(authorityItemCommonSchemaName, item.getShortIdentifier(), parentcsid);
         ctx = createServiceContext(getItemServiceName());
         DocumentWrapper<DocumentModel> docWrapper = client.findDoc(repoSession, ctx, itemWhereClause);
         DocumentModel docModel = docWrapper.getWrappedObject();
@@ -372,21 +371,44 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
        }
     }
 
-    protected String buildWhereForAuthByName(String name) {
-        return authorityCommonSchemaName
-                + ":" + AuthorityJAXBSchema.SHORT_IDENTIFIER
-                + "='" + name + "'";
-    }
 
-    protected String buildWhereForAuthItemByName(String name, String parentcsid) {
-        return authorityItemCommonSchemaName
-                + ":" + AuthorityItemJAXBSchema.SHORT_IDENTIFIER
-                + "='" + name + "' AND "
-                + authorityItemCommonSchemaName + ":"
-                + AuthorityItemJAXBSchema.IN_AUTHORITY + "="
-                + "'" + parentcsid + "'";
-    }
+    /**
+     * Synchronizes the authority and its terms with a Shared Authority Server.
+     * 
+     * @param specifier either a CSID or one of the urn forms
+     * 
+     * @return the authority
+     */
+    @GET
+    @Path("{csid}/sync")
+    public Response synchronize(
+            @Context Request request,
+            @Context UriInfo ui,
+            @PathParam("csid") String csid) {
+        boolean result = false;
+        Specifier specifier;
+        
+        try {
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);
+            AuthorityDocumentModelHandler handler = (AuthorityDocumentModelHandler)createDocumentHandler(ctx);
+            specifier = getSpecifier(csid, "getAuthority", "GET");
+            result = handler.synchronize(specifier);       
+        } catch (Exception e) {
+            throw bigReThrow(e, ServiceMessages.SYNC_FAILED, csid);
+        }
 
+        if (result == false) {
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    "Get failed, the requested Authority specifier:" + specifier + ": was not found.").type(
+                    "text/plain").build();
+            throw new CSWebApplicationException(response);
+        }
+
+        return Response.status(Response.Status.OK).entity(
+                "Synchronization completed, the requested Authority specifier:" + specifier.value + ": was synchronized.").type(
+                "text/plain").build();
+    }
+    
     /**
      * Gets the authority.
      * 
@@ -413,7 +435,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
                 }
                 getRepositoryClient(ctx).get(ctx, spec.value, handler);
             } else {
-                String whereClause = buildWhereForAuthByName(spec.value);
+                String whereClause = RefNameServiceUtils.buildWhereForAuthByName(authorityCommonSchemaName, spec.value);
                 DocumentFilter myFilter = new NuxeoDocumentFilter(whereClause, 0, 1);
                 handler.setDocumentFilter(myFilter);
                 getRepositoryClient(ctx).get(ctx, handler);
@@ -495,7 +517,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             if (spec.form == SpecifierForm.CSID) {
                 csid = spec.value;
             } else {
-                String whereClause = buildWhereForAuthByName(spec.value);
+                String whereClause = RefNameServiceUtils.buildWhereForAuthByName(authorityCommonSchemaName, spec.value);
                 csid = getRepositoryClient(ctx).findDocCSID(null, ctx, whereClause);
             }
             getRepositoryClient(ctx).update(ctx, csid, handler);
@@ -563,7 +585,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
                 if (logger.isDebugEnabled()) {
                     logger.debug("deleteAuthority with specifier=" + spec.value);
                 }              
-                String whereClause = buildWhereForAuthByName(spec.value);
+                String whereClause = RefNameServiceUtils.buildWhereForAuthByName(authorityCommonSchemaName, spec.value);
                 getRepositoryClient(ctx).deleteWithWhereClause(ctx, whereClause, handler);
             }
             
@@ -703,7 +725,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
                 getRepositoryClient(ctx).get(ctx, itemSpec.value, handler);
             } else {
                 String itemWhereClause =
-                        buildWhereForAuthItemByName(itemSpec.value, parentcsid);
+                               RefNameServiceUtils.buildWhereForAuthItemByName(authorityItemCommonSchemaName, itemSpec.value, parentcsid);
                 DocumentFilter myFilter = new NuxeoDocumentFilter(itemWhereClause, 0, 1); // start at page 0 and get 1 item
                 handler.setDocumentFilter(myFilter);
                 getRepositoryClient(ctx).get(ctx, handler);
index dbbe70f757444835644ffae02d0955d32d360cb6..fa0a03638567ddd18dc4bd547d2b914b1be6fa5e 100644 (file)
@@ -32,12 +32,17 @@ import org.collectionspace.services.common.api.RefName.Authority;
 import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.DocumentException;
+import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentNotFoundException;
 import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.document.DocumentHandler.Action;
 import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
 import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
+import org.collectionspace.services.common.vocabulary.AuthorityResource.Specifier;
+import org.collectionspace.services.common.vocabulary.AuthorityResource.SpecifierForm;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
 import org.collectionspace.services.config.service.ObjectPartType;
+import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentFilter;
 import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
 import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
@@ -56,10 +61,34 @@ public abstract class AuthorityDocumentModelHandler<AuthCommon>
         extends NuxeoDocumentModelHandler<AuthCommon> {
 
     private final Logger logger = LoggerFactory.getLogger(AuthorityDocumentModelHandler.class);        
-    private String authorityCommonSchemaName;
+    protected String authorityCommonSchemaName;
+    protected String authorityItemCommonSchemaName;
 
-    public AuthorityDocumentModelHandler(String authorityCommonSchemaName) {
+    public AuthorityDocumentModelHandler(String authorityCommonSchemaName, String authorityItemCommonSchemaName) {
         this.authorityCommonSchemaName = authorityCommonSchemaName;
+        this.authorityItemCommonSchemaName = authorityItemCommonSchemaName;
+    }
+    
+    
+    public boolean synchronize(Specifier specifier) throws DocumentNotFoundException, DocumentException {
+       boolean result = true;
+       
+       ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
+        if (specifier.form == SpecifierForm.CSID) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Synchronize Authority with csid=" + specifier.value);
+            }
+            getRepositoryClient(ctx).get(getServiceContext(), specifier.value, this);
+        } else {
+            String whereClause = RefNameServiceUtils.buildWhereForAuthByName(authorityCommonSchemaName, specifier.value);
+            DocumentFilter myFilter = new NuxeoDocumentFilter(whereClause, 0, 1);
+            this.setDocumentFilter(myFilter);
+            getRepositoryClient(ctx).get(ctx, this);
+        }
+        
+        PoxPayloadOut output = ctx.getOutput();
+        
+        return result;
     }
 
     /*
index a6460c08437325c41b30e993273defadefbdbdeb..e9fc586c2d2dd329b1744e0e5541cfbc3cf6bb42 100644 (file)
 package org.collectionspace.services.citation.nuxeo;
 
 import org.collectionspace.services.citation.CitationauthoritiesCommon;
+import org.collectionspace.services.client.CitationAuthorityClient;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
 
 /**
  * CitationAuthorityDocumentModelHandler
  *
- * $LastChangedRevision: $
- * $LastChangedDate: $
  */
 public class CitationAuthorityDocumentModelHandler
                extends AuthorityDocumentModelHandler<CitationauthoritiesCommon> {
-
-    /**
-     * Common part schema label
-     */
-    static final String COMMON_PART_LABEL = "citationauthorities_common";   
     
     public CitationAuthorityDocumentModelHandler() {
-       super(COMMON_PART_LABEL);
+       super(CitationAuthorityClient.SERVICE_COMMON_PART_NAME, CitationAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
        
     /**
index 21f09e73c84cbdcaf437ae822f8e53b2078f9406..13482dec3acc778c9296e428fe25d88175c2a367 100644 (file)
  */
 package org.collectionspace.services.citation.nuxeo;
 
-import java.util.Arrays;
-import java.util.List;
-
 import org.collectionspace.services.client.CitationAuthorityClient;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
-import org.collectionspace.services.CitationJAXBSchema;
 import org.collectionspace.services.citation.CitationsCommon;
-import org.nuxeo.ecm.core.api.DocumentModel;
 
 /**
  * CitationDocumentModelHandler
  *
- * $LastChangedRevision: $
- * $LastChangedDate: $
- */
-/**
- * @author pschmitz
- *
  */
 public class CitationDocumentModelHandler
-       extends AuthorityItemDocumentModelHandler<CitationsCommon> {
-
-    /** The logger. */
-    //private final Logger logger = LoggerFactory.getLogger(CitationDocumentModelHandler.class);
-    /**
-     * Common part schema label
-     */
-    private static final String COMMON_PART_LABEL = "citations_common";
+               extends AuthorityItemDocumentModelHandler<CitationsCommon> {
     
     public CitationDocumentModelHandler() {
-       super(COMMON_PART_LABEL);
+       super(CitationAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
 
     @Override
@@ -74,7 +56,7 @@ public class CitationDocumentModelHandler
        @Override
        public String getParentCommonSchemaName() {
                // TODO Auto-generated method stub
-               return CitationAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+               return CitationAuthorityClient.SERVICE_COMMON_PART_NAME;
        }
 }
 
index 001830049ba4c964394880e40ee1e1c54115dc59..bc167db96072ba890adffeb401104937ff3b6ad2 100644 (file)
@@ -60,6 +60,7 @@ public class ServiceMessages {
     public static final String VALIDATION_FAILURE = "Validation failure ";
     public static final String MISSING_CSID = "missing csid";
     public static final String MISSING_INVALID_CSID = "missing/invalid csid=";
+       public static final String SYNC_FAILED = "Synchonization failed.";
 
     public static String resourceNotFoundMsg(String csid) {
         return String.format("The resource identified by CSID '%s' was not found.", csid);
index 5513e472a6b90b1c2243c272acee17423b0c18d8..1ac6866b9be663fde06048ab197761329ebabb61 100644 (file)
@@ -36,10 +36,8 @@ import org.nuxeo.ecm.core.api.model.PropertyException;
 import org.nuxeo.ecm.core.api.model.PropertyNotFoundException;
 import org.nuxeo.ecm.core.api.model.impl.primitives.StringProperty;
 import org.nuxeo.ecm.core.api.CoreSession;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.IQueryManager;
 import org.collectionspace.services.client.IRelationsManager;
@@ -954,6 +952,21 @@ public class RefNameServiceUtils {
             logger.debug("PropertyException on: " + prop.getPath() + pe.getLocalizedMessage());
         }
     }
+    
+    public static String buildWhereForAuthByName(String authorityCommonSchemaName, String name) {
+        return authorityCommonSchemaName
+                + ":" + AuthorityJAXBSchema.SHORT_IDENTIFIER
+                + "='" + name + "'";
+    }
+
+    public static String buildWhereForAuthItemByName(String authorityItemCommonSchemaName, String name, String parentcsid) {
+        return authorityItemCommonSchemaName
+                + ":" + AuthorityItemJAXBSchema.SHORT_IDENTIFIER
+                + "='" + name + "' AND "
+                + authorityItemCommonSchemaName + ":"
+                + AuthorityItemJAXBSchema.IN_AUTHORITY + "="
+                + "'" + parentcsid + "'";
+    }    
 
     /*
      * Identifies whether the refName was found in the supplied field. If passed
index d0313fadafe8cdd9b6734ba61569dba590b53404..21c5032da5fbe1593dad970a0ba80ea8b856300d 100644 (file)
  */
 package org.collectionspace.services.concept.nuxeo;
 
+import org.collectionspace.services.client.ConceptAuthorityClient;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
 import org.collectionspace.services.concept.ConceptauthoritiesCommon;
 
 /**
  * ConceptAuthorityDocumentModelHandler
  *
- * $LastChangedRevision: $
- * $LastChangedDate: $
  */
 public class ConceptAuthorityDocumentModelHandler
         extends AuthorityDocumentModelHandler<ConceptauthoritiesCommon> {
-
-    /**
-     * Common part schema label
-     */
-    static final String COMMON_PART_LABEL = "conceptauthorities_common";   
     
     public ConceptAuthorityDocumentModelHandler() {
-       super(COMMON_PART_LABEL);
+       super(ConceptAuthorityClient.SERVICE_COMMON_PART_NAME, ConceptAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
        
     /**
index 842a97d36c6dfc9373b16d6b771f7b609a59b659..105dfc54695490e37eb02eefec6a205aab3e1acd 100644 (file)
@@ -30,12 +30,6 @@ import org.collectionspace.services.concept.ConceptsCommon;
 /**
  * ConceptDocumentModelHandler
  *
- * $LastChangedRevision: $
- * $LastChangedDate: $
- */
-/**
- * @author pschmitz
- *
  */
 public class ConceptDocumentModelHandler
         extends AuthorityItemDocumentModelHandler<ConceptsCommon> {
@@ -49,10 +43,6 @@ public class ConceptDocumentModelHandler
         return ConceptAuthorityClient.SERVICE_PATH_COMPONENT;    //  CSPACE-3932
     }
        
-    /**
-     * Note that Concept has no displayName computation support.
-     */
-       
     /**
      * getQProperty converts the given property to qualified schema property
      * @param prop
@@ -66,8 +56,7 @@ public class ConceptDocumentModelHandler
        @Override
        public String getParentCommonSchemaName() {
                // TODO Auto-generated method stub
-               return ConceptAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+               return ConceptAuthorityClient.SERVICE_COMMON_PART_NAME;
        }
-    
 }
 
index 817ebb9983a13c21be41df23d71db8da83557d2f..577d5902d92deddc75565b511d07df459e8f99ea 100644 (file)
  */
 package org.collectionspace.services.location.nuxeo;
 
+import org.collectionspace.services.client.LocationAuthorityClient;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
 import org.collectionspace.services.location.LocationauthoritiesCommon;
 
 /**
  * LocationAuthorityDocumentModelHandler
  *
- * $LastChangedRevision: $
- * $LastChangedDate: $
  */
 public class LocationAuthorityDocumentModelHandler
         extends AuthorityDocumentModelHandler<LocationauthoritiesCommon> {
-
-    /**
-     * Common part schema label
-     */
-    static final String COMMON_PART_LABEL = "locationauthorities_common";   
     
     public LocationAuthorityDocumentModelHandler() {
-       super(COMMON_PART_LABEL);
+       super(LocationAuthorityClient.SERVICE_COMMON_PART_NAME, LocationAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
        
     /**
index 176fc06286e34d0ea5bdd3b400c2ad8b764c82f5..c7cd1c91411b0686069b744ed7197804f441394d 100644 (file)
  */
 package org.collectionspace.services.location.nuxeo;
 
-import org.collectionspace.services.LocationJAXBSchema;
 import org.collectionspace.services.client.LocationAuthorityClient;
-import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
 import org.collectionspace.services.location.LocationsCommon;
-import org.nuxeo.ecm.core.api.DocumentModel;
 
 /**
  * LocationDocumentModelHandler
  *
- * $LastChangedRevision: $
- * $LastChangedDate: $
- */
-/**
- * @author pschmitz
- *
  */
 public class LocationDocumentModelHandler
         extends AuthorityItemDocumentModelHandler<LocationsCommon> {
-
-    /**
-     * Common part schema label
-     */
-    private static final String COMMON_PART_LABEL = "locations_common";
     
     public LocationDocumentModelHandler() {
-       super(COMMON_PART_LABEL);
+       super(LocationAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
 
     @Override
     public String getAuthorityServicePath(){
         return LocationAuthorityClient.SERVICE_PATH_COMPONENT;    //  CSPACE-3932
     }
-       
-    /**
-     * Handle display name.
-     *
-     * @param docModel the doc model
-     * @throws Exception the exception
-     */
-//    @Override
-//    protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception {
-//     String commonPartLabel = getServiceContext().getCommonPartLabel("locations");
-//     Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
-//                     LocationJAXBSchema.DISPLAY_NAME_COMPUTED);
-//     Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
-//                     LocationJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
-//     if(displayNameComputed==null)
-//             displayNameComputed = true;
-//     if(shortDisplayNameComputed==null)
-//             shortDisplayNameComputed = true;
-//     if (displayNameComputed || shortDisplayNameComputed) {
-//             String displayName = prepareDefaultDisplayName(
-//                     (String)docModel.getProperty(commonPartLabel, LocationJAXBSchema.NAME ));
-//             if (displayNameComputed) {
-//                     docModel.setProperty(commonPartLabel, LocationJAXBSchema.DISPLAY_NAME,
-//                                     displayName);
-//             }
-//             if (shortDisplayNameComputed) {
-//                     docModel.setProperty(commonPartLabel, LocationJAXBSchema.SHORT_DISPLAY_NAME,
-//                                     displayName);
-//             }
-//     }
-//    }
-       
-    /**
-     * Produces a default displayName from the basic name and dates fields.
-     * @see LocationAuthorityClientUtils.prepareDefaultDisplayName() which
-     * duplicates this logic, until we define a service-general utils package
-     * that is neither client nor service specific.
-     * @param foreName 
-     * @param middleName
-     * @param surName
-     * @param birthDate
-     * @param deathDate
-     * @return
-     * @throws Exception
-     */
-    private static String prepareDefaultDisplayName(
-               String name ) throws Exception {
-       StringBuilder newStr = new StringBuilder();
-                       newStr.append(name);
-                       return newStr.toString();
-    }
-    
+           
     /**
      * getQProperty converts the given property to qualified schema property
      * @param prop
@@ -121,8 +56,7 @@ public class LocationDocumentModelHandler
        @Override
        public String getParentCommonSchemaName() {
                // TODO Auto-generated method stub
-               return LocationAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+               return LocationAuthorityClient.SERVICE_COMMON_PART_NAME;
        }
-    
 }
 
index 366e3c3dd1f5eedb0bed5312e25806738a52c119..977e4cd7011b9b872ecb98af315dff37abc238a5 100644 (file)
@@ -23,6 +23,7 @@
  */
 package org.collectionspace.services.material.nuxeo;
 
+import org.collectionspace.services.client.MaterialAuthorityClient;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
 import org.collectionspace.services.material.MaterialauthoritiesCommon;
 
@@ -32,14 +33,9 @@ import org.collectionspace.services.material.MaterialauthoritiesCommon;
  */
 public class MaterialAuthorityDocumentModelHandler
         extends AuthorityDocumentModelHandler<MaterialauthoritiesCommon> {
-
-    /**
-     * Common part schema label
-     */
-    static final String COMMON_PART_LABEL = "materialauthorities_common";   
     
     public MaterialAuthorityDocumentModelHandler() {
-        super(COMMON_PART_LABEL);
+        super(MaterialAuthorityClient.SERVICE_COMMON_PART_NAME, MaterialAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
     
     /**
index 4422cd95811c0bee1dd1d2a5dd49711b88b5c5fe..a2c9e74b70dc7dd466a4fbe4e8fdc6fe9c56d15c 100644 (file)
  */
 package org.collectionspace.services.material.nuxeo;
 
-import org.collectionspace.services.MaterialJAXBSchema;
 import org.collectionspace.services.client.MaterialAuthorityClient;
-import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
 import org.collectionspace.services.material.MaterialsCommon;
-import org.nuxeo.ecm.core.api.DocumentModel;
 
 /**
  * MaterialDocumentModelHandler
@@ -37,69 +34,14 @@ import org.nuxeo.ecm.core.api.DocumentModel;
 public class MaterialDocumentModelHandler
         extends AuthorityItemDocumentModelHandler<MaterialsCommon> {
 
-    /**
-     * Common part schema label
-     */
-    private static final String COMMON_PART_LABEL = "materials_common";
-    
     public MaterialDocumentModelHandler() {
-        super(COMMON_PART_LABEL);
+        super(MaterialAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
 
     @Override
     public String getAuthorityServicePath(){
         return MaterialAuthorityClient.SERVICE_PATH_COMPONENT;    //  CSPACE-3932
     }
-
-        /**
-     * Handle display name.
-     *
-     * @param docModel the doc model
-     * @throws Exception the exception
-     */
-//    @Override
-//    protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception {
-//        String commonPartLabel = getServiceContext().getCommonPartLabel("materials");
-//      Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
-//              MaterialJAXBSchema.DISPLAY_NAME_COMPUTED);
-//      Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
-//              MaterialJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
-//      if(displayNameComputed==null)
-//          displayNameComputed = true;
-//      if(shortDisplayNameComputed==null)
-//          shortDisplayNameComputed = true;
-//      if (displayNameComputed || shortDisplayNameComputed) {
-//                // Obtain the primary material name from the list of material names, for computing the display name.
-//          String xpathToMaterialName = MaterialJAXBSchema.MATERIAL_TERM_NAME_GROUP_LIST 
-//                        + "/[0]/" + MaterialeJAXBSchema.MATERIAL_TERM_NAME;
-//          String materialName = getXPathStringValue(docModel, COMMON_PART_LABEL, xpathToMaterialName);
-//          String displayName = prepareDefaultDisplayName(materialName);
-//          if (displayNameComputed) {
-//              docModel.setProperty(commonPartLabel, MaterialJAXBSchema.DISPLAY_NAME,
-//                      displayName);
-//          }
-//          if (shortDisplayNameComputed) {
-//              docModel.setProperty(commonPartLabel, MaterialJAXBSchema.SHORT_DISPLAY_NAME,
-//                      displayName);
-//          }
-//      }
-//    }
-    
-    /**
-     * Produces a default displayName from one or more supplied fields.
-     * @see MaterialAuthorityClientUtils.prepareDefaultDisplayName() which
-     * duplicates this logic, until we define a service-general utils package
-     * that is neither client nor service specific.
-     * @param materialName
-     * @return the default display name
-     * @throws Exception
-     */
-    private static String prepareDefaultDisplayName(
-            String materialName ) throws Exception {
-        StringBuilder newStr = new StringBuilder();
-            newStr.append(materialName);
-            return newStr.toString();
-    }
     
     /**
      * getQProperty converts the given property to qualified schema property
@@ -114,8 +56,7 @@ public class MaterialDocumentModelHandler
        @Override
        public String getParentCommonSchemaName() {
                // TODO Auto-generated method stub
-               return MaterialAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+               return MaterialAuthorityClient.SERVICE_COMMON_PART_NAME;
        }
-    
 }
 
index 959d7ca3757ecd20c7176c13c8afd9d8b8ac4f7c..9f350736b725eddf112cef270e043262b85ffbff 100644 (file)
 package org.collectionspace.services.organization.nuxeo;
 
 import org.collectionspace.services.organization.OrgauthoritiesCommon;
+import org.collectionspace.services.client.OrgAuthorityClient;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
 
 /**
  * OrgAuthorityDocumentModelHandler
  *
- * $LastChangedRevision$
- * $LastChangedDate$
  */
 public class OrgAuthorityDocumentModelHandler
         extends AuthorityDocumentModelHandler<OrgauthoritiesCommon> {
-
-    /**
-     * Common part schema label
-     */
-    static final String COMMON_PART_LABEL = "orgauthorities_common";   
     
     public OrgAuthorityDocumentModelHandler() {
-       super(COMMON_PART_LABEL);
+       super(OrgAuthorityClient.SERVICE_COMMON_PART_NAME, OrgAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
        
     /**
index 3b87129b5bfcdbb13f492e6bf33030644be92b93..0c2ecb6db9e8bc866a418eecfdeacb075ab21333 100644 (file)
@@ -25,31 +25,17 @@ package org.collectionspace.services.organization.nuxeo;
 
 import org.collectionspace.services.client.OrgAuthorityClient;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
-import org.collectionspace.services.OrganizationJAXBSchema;
-import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.organization.OrganizationsCommon;
-import org.nuxeo.ecm.core.api.DocumentModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * OrganizationDocumentModelHandler
  *
- * $LastChangedRevision$
- * $LastChangedDate$
  */
 public class OrganizationDocumentModelHandler
                extends AuthorityItemDocumentModelHandler<OrganizationsCommon> {
 
-    /** The logger. */
-    private final Logger logger = LoggerFactory.getLogger(OrganizationDocumentModelHandler.class);
-    /**
-     * Common part schema label
-     */
-    private static final String COMMON_PART_LABEL = "organizations_common";   
-    
     public OrganizationDocumentModelHandler() {
-       super(COMMON_PART_LABEL);
+       super(OrgAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
 
     @Override
@@ -57,73 +43,6 @@ public class OrganizationDocumentModelHandler
         return OrgAuthorityClient.SERVICE_PATH_COMPONENT;    //  CSPACE-3932
     }
        
-    /**
-     * Check the logic around the computed displayName
-     * 
-     * @param docModel
-     * 
-     * @throws Exception the exception
-     */
-//    @Override
-//    protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception {
-//     String commonPartLabel = getServiceContext().getCommonPartLabel("organizations");
-//     Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
-//                     OrganizationJAXBSchema.DISPLAY_NAME_COMPUTED);
-//     Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
-//                     OrganizationJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
-//     if(displayNameComputed==null)
-//             displayNameComputed = Boolean.TRUE;
-//     if(shortDisplayNameComputed==null)
-//             shortDisplayNameComputed = Boolean.TRUE;
-//     if (displayNameComputed.booleanValue() || shortDisplayNameComputed.booleanValue()) {
-//             String shortName = getStringValueInPrimaryRepeatingComplexProperty(
-//                             docModel, commonPartLabel, OrganizationJAXBSchema.MAIN_BODY_GROUP_LIST, 
-//                             OrganizationJAXBSchema.SHORT_NAME);
-//            // FIXME: Determine how to handle cases where primary short name is null or empty.
-//             if(shortDisplayNameComputed.booleanValue()) {
-//                     String displayName = prepareDefaultDisplayName(shortName, null);
-//                     docModel.setProperty(commonPartLabel, OrganizationJAXBSchema.SHORT_DISPLAY_NAME,
-//                                     displayName);
-//             }
-//             if(displayNameComputed.booleanValue()) {
-//             String foundingPlace = (String) docModel.getProperty(commonPartLabel,
-//                                             OrganizationJAXBSchema.FOUNDING_PLACE);
-//                     String displayName = prepareDefaultDisplayName(shortName, foundingPlace);
-//                             docModel.setProperty(commonPartLabel, OrganizationJAXBSchema.DISPLAY_NAME,
-//                                                     displayName);
-//             }
-//     }
-//    }
-
-    /**
-     * Produces a default displayName from the basic name and foundingPlace fields.
-     * @see OrgAuthorityClientUtils.prepareDefaultDisplayName() which
-     * duplicates this logic, until we define a service-general utils package
-     * that is neither client nor service specific.
-     * @param shortName
-     * @param foundingPlace
-     * @return
-     * @throws Exception
-     */
-    private static String prepareDefaultDisplayName(
-               String shortName, String foundingPlace ) throws Exception {
-       StringBuilder newStr = new StringBuilder();
-               final String sep = " ";
-               boolean firstAdded = false;
-               if(null != shortName ) {
-                       newStr.append(shortName);
-                       firstAdded = true;
-               }
-       // Now we add the place
-               if(null != foundingPlace ) {
-                       if(firstAdded) {
-                               newStr.append(sep);
-                       }
-                       newStr.append(foundingPlace);
-               }
-               return newStr.toString();
-    }
-    
     /**
      * getQProperty converts the given property to qualified schema property
      * @param prop
@@ -137,8 +56,7 @@ public class OrganizationDocumentModelHandler
        @Override
        public String getParentCommonSchemaName() {
                // TODO Auto-generated method stub
-               return OrgAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+               return OrgAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME;
        }
-    
 }
 
index 2d9e3108cc7248b5c702714f528ee00c4891f446..dbef883777ea7bc0b325b0b8f2b95bc3f7736310 100644 (file)
 package org.collectionspace.services.person.nuxeo;
 
 import org.collectionspace.services.person.PersonauthoritiesCommon;
+import org.collectionspace.services.client.PersonAuthorityClient;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
 
 /**
  * PersonAuthorityDocumentModelHandler
  *
- * $LastChangedRevision: $
- * $LastChangedDate: $
  */
 public class PersonAuthorityDocumentModelHandler
                extends AuthorityDocumentModelHandler<PersonauthoritiesCommon> {
 
-    /**
-     * Common part schema label
-     */
-    static final String COMMON_PART_LABEL = "personauthorities_common";   
-    
     public PersonAuthorityDocumentModelHandler() {
-       super(COMMON_PART_LABEL);
+       super(PersonAuthorityClient.SERVICE_COMMON_PART_NAME, PersonAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
        
     /**
index ef44bc24a73efd12e0cc23ade75a822bc461af37..215975f19636f600ba5ec14a5d9c50b1614124c2 100644 (file)
  */
 package org.collectionspace.services.person.nuxeo;
 
-import java.util.Arrays;
-import java.util.List;
-
 import org.collectionspace.services.client.PersonAuthorityClient;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
-import org.collectionspace.services.PersonJAXBSchema;
 import org.collectionspace.services.person.PersonsCommon;
-import org.nuxeo.ecm.core.api.DocumentModel;
 
 /**
  * PersonDocumentModelHandler
  *
- * $LastChangedRevision: $
- * $LastChangedDate: $
- */
-/**
- * @author pschmitz
- *
  */
 public class PersonDocumentModelHandler
        extends AuthorityItemDocumentModelHandler<PersonsCommon> {
 
-    /** The logger. */
-    //private final Logger logger = LoggerFactory.getLogger(PersonDocumentModelHandler.class);
-    /**
-     * Common part schema label
-     */
-    private static final String COMMON_PART_LABEL = "persons_common";
-    
     public PersonDocumentModelHandler() {
-       super(COMMON_PART_LABEL);
+       super(PersonAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
 
     @Override
     public String getAuthorityServicePath(){
         return PersonAuthorityClient.SERVICE_PATH_COMPONENT;    // CSPACE-3932
     }
-       
-    /**
-     * Handle display names.
-     *
-     * @param docModel the doc model
-     * @throws Exception the exception
-     */
-    /*
-    @Override
-    protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception {
-       String commonPartLabel = getServiceContext().getCommonPartLabel("persons");
-       Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
-                       PersonJAXBSchema.DISPLAY_NAME_COMPUTED);
-       Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
-                       PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
-       if(displayNameComputed==null)
-               displayNameComputed = true;
-       if(shortDisplayNameComputed==null)
-               shortDisplayNameComputed = true;
-       if (displayNameComputed || shortDisplayNameComputed) {
-               String forename = 
-                               (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.FORE_NAME);
-               String lastname = 
-                               (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.SUR_NAME);
-               if(shortDisplayNameComputed) {
-                       String displayName = prepareDefaultDisplayName(forename, null, lastname,
-                                       null, null);
-                       docModel.setProperty(commonPartLabel, PersonJAXBSchema.SHORT_DISPLAY_NAME,
-                                       displayName);
-               }
-               if(displayNameComputed) {
-                       String midname = 
-                                       (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.MIDDLE_NAME);                            
-                       String birthdate = 
-                                       (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.BIRTH_DATE);
-                       String deathdate = 
-                                       (String)docModel.getProperty(commonPartLabel, PersonJAXBSchema.DEATH_DATE);
-                       String displayName = prepareDefaultDisplayName(forename, midname, lastname,
-                                       birthdate, deathdate);
-                       docModel.setProperty(commonPartLabel, PersonJAXBSchema.DISPLAY_NAME,
-                                       displayName);
-               }
-       }
-    }
-    * 
-    */
-       
-       
-    /**
-     * Produces a default displayName from the basic name and dates fields.
-     * see PersonAuthorityClientUtils.prepareDefaultDisplayName(String,String,String,String,String) which
-     * duplicates this logic, until we define a service-general utils package
-     * that is neither client nor service specific.
-     * @param foreName 
-     * @param middleName
-     * @param surName
-     * @param birthDate
-     * @param deathDate
-     * @return
-     * @throws Exception
-     */
-    /*
-    private static String prepareDefaultDisplayName(
-               String foreName, String middleName, String surName,
-               String birthDate, String deathDate ) throws Exception {
-               final String SEP = " ";
-               final String DATE_SEP = "-";
-
-               StringBuilder newStr = new StringBuilder();
-               List<String> nameStrings = 
-                       Arrays.asList(foreName, middleName, surName);
-               boolean firstAdded = false;
-       for (String partStr : nameStrings ){
-                       if (partStr != null) {
-                               if (firstAdded == true) {
-                                       newStr.append(SEP);
-                               }
-                               newStr.append(partStr);
-                               firstAdded = true;
-                       }
-       }
-       // Now we add the dates. In theory could have dates with no name, but that is their problem.
-       boolean foundBirth = false;
-               if (birthDate != null) {
-                       if (firstAdded) {
-                               newStr.append(SEP);
-                       }
-                       newStr.append(birthDate);
-               newStr.append(DATE_SEP);                // Put this in whether there is a death date or not
-                       foundBirth = true;
-               }
-               if (deathDate != null) {
-                       if (!foundBirth) {
-                               if (firstAdded == true) {
-                                       newStr.append(SEP);
-                               }
-                       newStr.append(DATE_SEP);
-                       }
-                       newStr.append(deathDate);
-               }
-               
-               return newStr.toString();
-    }
-    * 
-    */
-    
+           
     /**
      * getQProperty converts the given property to qualified schema property
      * @param prop
@@ -179,8 +56,7 @@ public class PersonDocumentModelHandler
        @Override
        public String getParentCommonSchemaName() {
                // TODO Auto-generated method stub
-               return PersonAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+               return PersonAuthorityClient.SERVICE_COMMON_PART_NAME;
        }
-    
 }
 
index d4debdfa24cfccca482307a83cde3d269c19bced..b6c7beefda8b4485d6e4fe6a9f0cc19385355210 100644 (file)
  */
 package org.collectionspace.services.place.nuxeo;
 
+import org.collectionspace.services.client.PlaceAuthorityClient;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
 import org.collectionspace.services.place.PlaceauthoritiesCommon;
 
 /**
  * PlaceAuthorityDocumentModelHandler
  *
- * $LastChangedRevision: $
- * $LastChangedDate: $
  */
 public class PlaceAuthorityDocumentModelHandler
         extends AuthorityDocumentModelHandler<PlaceauthoritiesCommon> {
 
-    /**
-     * Common part schema label
-     */
-    static final String COMMON_PART_LABEL = "placeauthorities_common";   
-    
     public PlaceAuthorityDocumentModelHandler() {
-       super(COMMON_PART_LABEL);
+       super(PlaceAuthorityClient.SERVICE_COMMON_PART_NAME, PlaceAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
        
     /**
index 865b534bd556b19e82b084988267dcd08d353e01..c60e5989918ac521b27ca7a16143776d2527f17b 100644 (file)
  */
 package org.collectionspace.services.place.nuxeo;
 
-import org.collectionspace.services.PlaceJAXBSchema;
 import org.collectionspace.services.client.PlaceAuthorityClient;
-import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
 import org.collectionspace.services.place.PlacesCommon;
-import org.nuxeo.ecm.core.api.DocumentModel;
 
 /**
  * PlaceDocumentModelHandler
  *
- * $LastChangedRevision: $
- * $LastChangedDate: $
- */
-/**
- * @author pschmitz
- *
  */
 public class PlaceDocumentModelHandler
         extends AuthorityItemDocumentModelHandler<PlacesCommon> {
 
-    /**
-     * Common part schema label
-     */
-    private static final String COMMON_PART_LABEL = "places_common";
-    
     public PlaceDocumentModelHandler() {
-       super(COMMON_PART_LABEL);
+       super(PlaceAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
 
     @Override
@@ -57,56 +43,6 @@ public class PlaceDocumentModelHandler
         return PlaceAuthorityClient.SERVICE_PATH_COMPONENT;    //  CSPACE-3932
     }
 
-        /**
-     * Handle display name.
-     *
-     * @param docModel the doc model
-     * @throws Exception the exception
-     */
-//    @Override
-//    protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception {
-//        String commonPartLabel = getServiceContext().getCommonPartLabel("places");
-//     Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
-//                     PlaceJAXBSchema.DISPLAY_NAME_COMPUTED);
-//     Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
-//                     PlaceJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
-//     if(displayNameComputed==null)
-//             displayNameComputed = true;
-//     if(shortDisplayNameComputed==null)
-//             shortDisplayNameComputed = true;
-//     if (displayNameComputed || shortDisplayNameComputed) {
-//                // Obtain the primary place name from the list of place names, for computing the display name.
-//             String xpathToPlaceName = PlaceJAXBSchema.PLACE_NAME_GROUP_LIST 
-//                        + "/[0]/" + PlaceJAXBSchema.PLACE_NAME;
-//             String placeName = getXPathStringValue(docModel, COMMON_PART_LABEL, xpathToPlaceName);
-//             String displayName = prepareDefaultDisplayName(placeName);
-//             if (displayNameComputed) {
-//                     docModel.setProperty(commonPartLabel, PlaceJAXBSchema.DISPLAY_NAME,
-//                                     displayName);
-//             }
-//             if (shortDisplayNameComputed) {
-//                     docModel.setProperty(commonPartLabel, PlaceJAXBSchema.SHORT_DISPLAY_NAME,
-//                                     displayName);
-//             }
-//     }
-//    }
-       
-    /**
-     * Produces a default displayName from one or more supplied fields.
-     * @see PlaceAuthorityClientUtils.prepareDefaultDisplayName() which
-     * duplicates this logic, until we define a service-general utils package
-     * that is neither client nor service specific.
-     * @param placeName
-     * @return the default display name
-     * @throws Exception
-     */
-    private static String prepareDefaultDisplayName(
-               String placeName ) throws Exception {
-       StringBuilder newStr = new StringBuilder();
-                       newStr.append(placeName);
-                       return newStr.toString();
-    }
-    
     /**
      * getQProperty converts the given property to qualified schema property
      * @param prop
@@ -120,7 +56,7 @@ public class PlaceDocumentModelHandler
        @Override
        public String getParentCommonSchemaName() {
                // TODO Auto-generated method stub
-               return PlaceAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+               return PlaceAuthorityClient.SERVICE_COMMON_PART_NAME;
        }
 }
 
index 75ab29bf91ac34c484139c3e94963767fec0afa0..6a73471d52ea725f4bb70803d54c2a3591c7c2b8 100644 (file)
 package org.collectionspace.services.taxonomy.nuxeo;
 
 import org.collectionspace.services.client.TaxonomyAuthorityClient;
-import org.collectionspace.services.TaxonJAXBSchema;
-import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
 import org.collectionspace.services.taxonomy.TaxonCommon;
-import org.nuxeo.ecm.core.api.DocumentModel;
 
 /**
  * TaxonomyDocumentModelHandler
  *
- * $LastChangedRevision$
- * $LastChangedDate$
- */
-/**
- * @author pschmitz
- *
  */
 public class TaxonDocumentModelHandler
         extends AuthorityItemDocumentModelHandler<TaxonCommon> {
 
-    /**
-     * Common part schema label
-     */
-    private static final String COMMON_PART_LABEL = "taxon_common";
-
     public TaxonDocumentModelHandler() {
-        super(COMMON_PART_LABEL);
+        super(TaxonomyAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
     
+    @Override
     public String getAuthorityServicePath(){
         return TaxonomyAuthorityClient.SERVICE_PATH_COMPONENT;
     }
 
-    /**
-     * Handle display name.
-     *
-     * @param docModel the doc model
-     * @throws Exception the exception
-     */
-//    @Override
-//    protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception {
-//        String commonPartLabel = getServiceContext().getCommonPartLabel("taxon");
-//        Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
-//                TaxonJAXBSchema.DISPLAY_NAME_COMPUTED);
-//        Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
-//                TaxonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
-//        if (displayNameComputed == null) {
-//            displayNameComputed = true;
-//        }
-//        if (shortDisplayNameComputed == null) {
-//            shortDisplayNameComputed = true;
-//        }
-//        if (displayNameComputed || shortDisplayNameComputed) {
-//            String displayName = prepareDefaultDisplayName(
-//                    (String) docModel.getProperty(commonPartLabel, TaxonJAXBSchema.NAME));
-//            if (displayNameComputed) {
-//                docModel.setProperty(commonPartLabel, TaxonJAXBSchema.DISPLAY_NAME,
-//                        displayName);
-//            }
-//            if (shortDisplayNameComputed) {
-//                docModel.setProperty(commonPartLabel, TaxonJAXBSchema.SHORT_DISPLAY_NAME,
-//                        displayName);
-//            }
-//        }
-//    }
-
-    /**
-     * Produces a default displayName from the basic name and dates fields.
-     * @see TaxonomyAuthorityClientUtils.prepareDefaultDisplayName() which
-     * duplicates this logic, until we define a service-general utils package
-     * that is neither client nor service specific.
-     * @param name
-     * @return
-     * @throws Exception
-     */
-    private static String prepareDefaultDisplayName(
-            String name) throws Exception {
-        StringBuilder newStr = new StringBuilder();
-        newStr.append(name);
-        return newStr.toString();
-    }
-
     /**
      * getQProperty converts the given property to qualified schema property
      * @param prop
@@ -118,7 +56,7 @@ public class TaxonDocumentModelHandler
        @Override
        public String getParentCommonSchemaName() {
                // TODO Auto-generated method stub
-               return TaxonomyAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+               return TaxonomyAuthorityClient.SERVICE_COMMON_PART_NAME;
        }
 }
 
index f59073e0da740033814ee124d03d8d05eb556579..f6daae2e03eb13a36bf1b66e0e732dba8317e214 100644 (file)
  */
 package org.collectionspace.services.taxonomy.nuxeo;
 
+import org.collectionspace.services.client.TaxonomyAuthorityClient;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
 import org.collectionspace.services.taxonomy.TaxonomyauthorityCommon;
 
 /**
  * TaxonomyAuthorityDocumentModelHandler
  *
- * $LastChangedRevision$
- * $LastChangedDate$
  */
 public class TaxonomyAuthorityDocumentModelHandler
         extends AuthorityDocumentModelHandler<TaxonomyauthorityCommon> {
 
-    /**
-     * Common part schema label
-     */
-    static final String COMMON_PART_LABEL = "taxonomyauthority_common";   
-    
     public TaxonomyAuthorityDocumentModelHandler() {
-       super(COMMON_PART_LABEL);
+       super(TaxonomyAuthorityClient.SERVICE_COMMON_PART_NAME, TaxonomyAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
     
-    public String getCommonPartLabel() {
-        return COMMON_PART_LABEL;
+    /**
+     * getQProperty converts the given property to qualified schema property
+     * @param prop
+     * @return
+     */
+    @Override
+    public String getQProperty(String prop) {
+        return TaxonomyAuthorityConstants.NUXEO_SCHEMA_NAME + ":" + prop;
     }
-       
 }
 
index 704030d103bd7750361f390374143b9f2bdf1788..bfbc7ad019731ad6d3482b612afa37ebe6496d01 100644 (file)
@@ -43,6 +43,12 @@ public class VocabularyClient extends AuthorityClientImpl<VocabularyitemsCommon,
        public static final String SERVICE_ITEM_NAME = "vocabularyitems";
        public static final String SERVICE_ITEM_PAYLOAD_NAME = SERVICE_ITEM_NAME;
        
+    public static final String SERVICE_COMMON_PART_NAME = SERVICE_NAME
+            + PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
+    public static final String SERVICE_ITEM_COMMON_PART_NAME = SERVICE_ITEM_NAME
+            + PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
+       
+       
        @Override
        public String getServiceName() {
                return SERVICE_NAME;
index 53ebe2eadf85d07bd47913c505da9ce5bffbedd6..8f10f82f0aff7baff52189c80ee51fe1fe1b69d9 100644 (file)
  */
 package org.collectionspace.services.vocabulary.nuxeo;
 
+import org.collectionspace.services.client.VocabularyClient;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
 import org.collectionspace.services.vocabulary.VocabulariesCommon;
 
 /**
  * VocabularyDocumentModelHandler
  *
- * $LastChangedRevision: $
- * $LastChangedDate: $
  */
 public class VocabularyDocumentModelHandler
                extends AuthorityDocumentModelHandler<VocabulariesCommon> {
-
-    /**
-     * Common part schema label
-     */
-    static final String COMMON_PART_LABEL = "vocabularies_common";   
     
     public VocabularyDocumentModelHandler() {
-       super(COMMON_PART_LABEL);
+       super(VocabularyClient.SERVICE_COMMON_PART_NAME, VocabularyClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
 
     /**
index f19cc3572f26238dd2525bef6d46f6af12f142c1..591442e5d3e5fe89166137f1f92992a9acd1e5ad 100644 (file)
@@ -35,16 +35,12 @@ import org.nuxeo.ecm.core.api.DocumentModel;
 /**
  * VocabularyItemDocumentModelHandler
  *
- * $LastChangedRevision: $
- * $LastChangedDate: $
  */
 public class VocabularyItemDocumentModelHandler
                extends AuthorityItemDocumentModelHandler<VocabularyitemsCommon> {
 
-    private static final String COMMON_PART_LABEL = "vocabularyitems_common";   
-    
     public VocabularyItemDocumentModelHandler() {
-       super(COMMON_PART_LABEL);
+       super(VocabularyClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
 
     @Override
@@ -100,6 +96,7 @@ public class VocabularyItemDocumentModelHandler
                return result;
        }
     
+    @Override
     protected ListResultField getListResultsTermStatusField() {
                ListResultField result = new ListResultField();
 
@@ -112,7 +109,7 @@ public class VocabularyItemDocumentModelHandler
        @Override
        public String getParentCommonSchemaName() {
                // TODO Auto-generated method stub
-               return VocabularyDocumentModelHandler.COMMON_PART_LABEL;
+               return VocabularyClient.SERVICE_COMMON_PART_NAME;
        }
     
 }
index 110016ae8570e2cdf546db7b8635cfeeeddff895..17e0fe95580777ee0f78b036aa7d370a18b46a91 100644 (file)
@@ -23,6 +23,7 @@
  */
 package org.collectionspace.services.work.nuxeo;
 
+import org.collectionspace.services.client.WorkAuthorityClient;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
 import org.collectionspace.services.work.WorkauthoritiesCommon;
 
@@ -33,13 +34,8 @@ import org.collectionspace.services.work.WorkauthoritiesCommon;
 public class WorkAuthorityDocumentModelHandler
         extends AuthorityDocumentModelHandler<WorkauthoritiesCommon> {
 
-    /**
-     * Common part schema label
-     */
-    static final String COMMON_PART_LABEL = "workauthorities_common";   
-    
     public WorkAuthorityDocumentModelHandler() {
-        super(COMMON_PART_LABEL);
+        super(WorkAuthorityClient.SERVICE_COMMON_PART_NAME, WorkAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
     
     /**
index 9cf41089e24cb57025c7335ba462f3dd9e8d251b..24507afe097b91e5b6160d5657e2958096e98c6c 100644 (file)
  */
 package org.collectionspace.services.work.nuxeo;
 
-import org.collectionspace.services.WorkJAXBSchema;
 import org.collectionspace.services.client.WorkAuthorityClient;
-import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
 import org.collectionspace.services.work.WorksCommon;
-import org.nuxeo.ecm.core.api.DocumentModel;
 
 /**
  * WorkDocumentModelHandler
@@ -37,69 +34,14 @@ import org.nuxeo.ecm.core.api.DocumentModel;
 public class WorkDocumentModelHandler
         extends AuthorityItemDocumentModelHandler<WorksCommon> {
 
-    /**
-     * Common part schema label
-     */
-    private static final String COMMON_PART_LABEL = "works_common";
-    
     public WorkDocumentModelHandler() {
-        super(COMMON_PART_LABEL);
+        super(WorkAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME);
     }
 
     @Override
     public String getAuthorityServicePath(){
         return WorkAuthorityClient.SERVICE_PATH_COMPONENT;    //  CSPACE-3932
     }
-
-        /**
-     * Handle display name.
-     *
-     * @param docModel the doc model
-     * @throws Exception the exception
-     */
-//    @Override
-//    protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception {
-//        String commonPartLabel = getServiceContext().getCommonPartLabel("works");
-//      Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
-//              WorkJAXBSchema.DISPLAY_NAME_COMPUTED);
-//      Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
-//              WorkJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
-//      if(displayNameComputed==null)
-//          displayNameComputed = true;
-//      if(shortDisplayNameComputed==null)
-//          shortDisplayNameComputed = true;
-//      if (displayNameComputed || shortDisplayNameComputed) {
-//                // Obtain the primary work name from the list of work names, for computing the display name.
-//          String xpathToWorkName = WorkJAXBSchema.WORK_TERM_NAME_GROUP_LIST 
-//                        + "/[0]/" + WorkeJAXBSchema.WORK_TERM_NAME;
-//          String workName = getXPathStringValue(docModel, COMMON_PART_LABEL, xpathToWorkName);
-//          String displayName = prepareDefaultDisplayName(workName);
-//          if (displayNameComputed) {
-//              docModel.setProperty(commonPartLabel, WorkJAXBSchema.DISPLAY_NAME,
-//                      displayName);
-//          }
-//          if (shortDisplayNameComputed) {
-//              docModel.setProperty(commonPartLabel, WorkJAXBSchema.SHORT_DISPLAY_NAME,
-//                      displayName);
-//          }
-//      }
-//    }
-    
-    /**
-     * Produces a default displayName from one or more supplied fields.
-     * @see WorkAuthorityClientUtils.prepareDefaultDisplayName() which
-     * duplicates this logic, until we define a service-general utils package
-     * that is neither client nor service specific.
-     * @param workName
-     * @return the default display name
-     * @throws Exception
-     */
-    private static String prepareDefaultDisplayName(
-            String workName ) throws Exception {
-        StringBuilder newStr = new StringBuilder();
-            newStr.append(workName);
-            return newStr.toString();
-    }
     
     /**
      * getQProperty converts the given property to qualified schema property
@@ -114,7 +56,7 @@ public class WorkDocumentModelHandler
        @Override
        public String getParentCommonSchemaName() {
                // TODO Auto-generated method stub
-               return WorkAuthorityDocumentModelHandler.COMMON_PART_LABEL;
+               return WorkAuthorityClient.SERVICE_COMMON_PART_NAME;
        }
 }