From 419d83cc29605c84dfb9f05b80a3172d3625b811 Mon Sep 17 00:00:00 2001 From: remillet Date: Thu, 31 Mar 2016 10:31:23 -0700 Subject: [PATCH] CSPACE-6935: Refactored authority resource and document handler classes for better naming consistency. --- .../common/vocabulary/AuthorityResource.java | 66 ++++++--- .../nuxeo/AuthorityDocumentModelHandler.java | 33 ++++- ...CitationAuthorityDocumentModelHandler.java | 10 +- .../nuxeo/CitationDocumentModelHandler.java | 24 +--- .../services/common/ServiceMessages.java | 1 + .../vocabulary/RefNameServiceUtils.java | 17 ++- .../ConceptAuthorityDocumentModelHandler.java | 10 +- .../nuxeo/ConceptDocumentModelHandler.java | 13 +- ...LocationAuthorityDocumentModelHandler.java | 10 +- .../nuxeo/LocationDocumentModelHandler.java | 72 +--------- ...MaterialAuthorityDocumentModelHandler.java | 8 +- .../nuxeo/MaterialDocumentModelHandler.java | 63 +-------- .../OrgAuthorityDocumentModelHandler.java | 10 +- .../OrganizationDocumentModelHandler.java | 86 +----------- .../PersonAuthorityDocumentModelHandler.java | 10 +- .../nuxeo/PersonDocumentModelHandler.java | 130 +----------------- .../PlaceAuthorityDocumentModelHandler.java | 10 +- .../nuxeo/PlaceDocumentModelHandler.java | 68 +-------- .../nuxeo/TaxonDocumentModelHandler.java | 68 +-------- ...TaxonomyAuthorityDocumentModelHandler.java | 21 ++- .../services/client/VocabularyClient.java | 6 + .../nuxeo/VocabularyDocumentModelHandler.java | 10 +- .../VocabularyItemDocumentModelHandler.java | 9 +- .../WorkAuthorityDocumentModelHandler.java | 8 +- .../work/nuxeo/WorkDocumentModelHandler.java | 62 +-------- 25 files changed, 149 insertions(+), 676 deletions(-) diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java index 542d2bcc7..cd67fd3aa 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java @@ -267,7 +267,6 @@ public abstract class AuthorityResource } public static class CsidAndShortIdentifier { - String CSID; String shortIdentifier; } @@ -298,7 +297,7 @@ public abstract class AuthorityResource parentShortIdentifier = FETCH_SHORT_ID; } else { parentShortIdentifier = parentSpec.value; - String whereClause = buildWhereForAuthByName(parentSpec.value); + String whereClause = RefNameServiceUtils.buildWhereForAuthByName(authorityCommonSchemaName, parentSpec.value); ServiceContext 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 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 if(item == null) { return null; } - String whereClause = buildWhereForAuthByName(item.getParentShortIdentifier()); + String whereClause = RefNameServiceUtils.buildWhereForAuthByName(authorityCommonSchemaName, item.getParentShortIdentifier()); // Ensure we have the right context. ServiceContext ctx = createServiceContext(item.inAuthority.resource); @@ -339,7 +338,7 @@ public abstract class AuthorityResource 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 docWrapper = client.findDoc(repoSession, ctx, itemWhereClause); DocumentModel docModel = docWrapper.getWrappedObject(); @@ -372,21 +371,44 @@ public abstract class AuthorityResource } } - 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 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 } 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 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 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 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); diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java index dbbe70f75..fa0a03638 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java @@ -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 extends NuxeoDocumentModelHandler { 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 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; } /* diff --git a/services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationAuthorityDocumentModelHandler.java b/services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationAuthorityDocumentModelHandler.java index a6460c084..e9fc586c2 100644 --- a/services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationAuthorityDocumentModelHandler.java +++ b/services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationAuthorityDocumentModelHandler.java @@ -24,24 +24,18 @@ 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 { - - /** - * 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); } /** diff --git a/services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationDocumentModelHandler.java b/services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationDocumentModelHandler.java index 21f09e73c..13482dec3 100644 --- a/services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationDocumentModelHandler.java +++ b/services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationDocumentModelHandler.java @@ -23,37 +23,19 @@ */ 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 { - - /** 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 { 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; } } diff --git a/services/common/src/main/java/org/collectionspace/services/common/ServiceMessages.java b/services/common/src/main/java/org/collectionspace/services/common/ServiceMessages.java index 001830049..bc167db96 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ServiceMessages.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ServiceMessages.java @@ -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); diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java index 5513e472a..1ac6866b9 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java @@ -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 diff --git a/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptAuthorityDocumentModelHandler.java b/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptAuthorityDocumentModelHandler.java index d0313fada..21c5032da 100644 --- a/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptAuthorityDocumentModelHandler.java +++ b/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptAuthorityDocumentModelHandler.java @@ -23,25 +23,19 @@ */ 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 { - - /** - * 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); } /** diff --git a/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptDocumentModelHandler.java b/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptDocumentModelHandler.java index 842a97d36..105dfc546 100644 --- a/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptDocumentModelHandler.java +++ b/services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptDocumentModelHandler.java @@ -30,12 +30,6 @@ import org.collectionspace.services.concept.ConceptsCommon; /** * ConceptDocumentModelHandler * - * $LastChangedRevision: $ - * $LastChangedDate: $ - */ -/** - * @author pschmitz - * */ public class ConceptDocumentModelHandler extends AuthorityItemDocumentModelHandler { @@ -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; } - } diff --git a/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java b/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java index 817ebb998..577d5902d 100644 --- a/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java +++ b/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java @@ -23,25 +23,19 @@ */ 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 { - - /** - * 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); } /** diff --git a/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java b/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java index 176fc0628..c7cd1c914 100644 --- a/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java +++ b/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java @@ -23,91 +23,26 @@ */ 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 { - - /** - * 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; } - } diff --git a/services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialAuthorityDocumentModelHandler.java b/services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialAuthorityDocumentModelHandler.java index 366e3c3dd..977e4cd70 100644 --- a/services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialAuthorityDocumentModelHandler.java +++ b/services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialAuthorityDocumentModelHandler.java @@ -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 { - - /** - * 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); } /** diff --git a/services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialDocumentModelHandler.java b/services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialDocumentModelHandler.java index 4422cd958..a2c9e74b7 100644 --- a/services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialDocumentModelHandler.java +++ b/services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialDocumentModelHandler.java @@ -23,12 +23,9 @@ */ 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 { - /** - * 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; } - } diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java index 959d7ca37..9f350736b 100644 --- a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java +++ b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java @@ -24,24 +24,18 @@ 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 { - - /** - * 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); } /** diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java index 3b87129b5..0c2ecb6db 100644 --- a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java +++ b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java @@ -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 { - /** 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; } - } diff --git a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java index 2d9e3108c..dbef88377 100644 --- a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java +++ b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java @@ -24,24 +24,18 @@ 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 { - /** - * 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); } /** diff --git a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java index ef44bc24a..215975f19 100644 --- a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java +++ b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java @@ -23,149 +23,26 @@ */ 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 { - /** 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 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; } - } diff --git a/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceAuthorityDocumentModelHandler.java b/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceAuthorityDocumentModelHandler.java index d4debdfa2..b6c7beefd 100644 --- a/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceAuthorityDocumentModelHandler.java +++ b/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceAuthorityDocumentModelHandler.java @@ -23,25 +23,19 @@ */ 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 { - /** - * 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); } /** diff --git a/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceDocumentModelHandler.java b/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceDocumentModelHandler.java index 865b534bd..c60e59899 100644 --- a/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceDocumentModelHandler.java +++ b/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceDocumentModelHandler.java @@ -23,33 +23,19 @@ */ 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 { - /** - * 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; } } diff --git a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonDocumentModelHandler.java b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonDocumentModelHandler.java index 75ab29bf9..6a73471d5 100644 --- a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonDocumentModelHandler.java +++ b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonDocumentModelHandler.java @@ -24,87 +24,25 @@ 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 { - /** - * 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; } } diff --git a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonomyAuthorityDocumentModelHandler.java b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonomyAuthorityDocumentModelHandler.java index f59073e0d..f6daae2e0 100644 --- a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonomyAuthorityDocumentModelHandler.java +++ b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonomyAuthorityDocumentModelHandler.java @@ -23,30 +23,29 @@ */ 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 { - /** - * 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; } - } diff --git a/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java b/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java index 704030d10..bfbc7ad01 100644 --- a/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java +++ b/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java @@ -43,6 +43,12 @@ public class VocabularyClient extends AuthorityClientImpl { - - /** - * 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); } /** diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java index f19cc3572..591442e5d 100644 --- a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java @@ -35,16 +35,12 @@ import org.nuxeo.ecm.core.api.DocumentModel; /** * VocabularyItemDocumentModelHandler * - * $LastChangedRevision: $ - * $LastChangedDate: $ */ public class VocabularyItemDocumentModelHandler extends AuthorityItemDocumentModelHandler { - 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; } } diff --git a/services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkAuthorityDocumentModelHandler.java b/services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkAuthorityDocumentModelHandler.java index 110016ae8..17e0fe955 100644 --- a/services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkAuthorityDocumentModelHandler.java +++ b/services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkAuthorityDocumentModelHandler.java @@ -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 { - /** - * 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); } /** diff --git a/services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkDocumentModelHandler.java b/services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkDocumentModelHandler.java index 9cf41089e..24507afe0 100644 --- a/services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkDocumentModelHandler.java +++ b/services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkDocumentModelHandler.java @@ -23,12 +23,9 @@ */ 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 { - /** - * 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; } } -- 2.47.3