From: Patrick Schmitz Date: Fri, 7 Oct 2011 17:02:06 +0000 (+0000) Subject: CSPACE-1927 - Refactored how displayName computation is done in prep for handling... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=1fe6919031285211d0b8c676fdd98a0ae8117d99;p=tmp%2Fjakarta-migration.git CSPACE-1927 - Refactored how displayName computation is done in prep for handling them better on update. --- diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java b/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java index 8696ea6f0..a0fe1b802 100644 --- a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java +++ b/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java @@ -120,12 +120,32 @@ public abstract class AuthorityItemDocumentModelHandler // first fill all the parts of the document super.handleCreate(wrapDoc); handleInAuthority(wrapDoc.getWrappedObject()); + handleComputedDisplayNames(wrapDoc.getWrappedObject()); // CSPACE-3178: // Uncomment once debugged and App layer is read to integrate // Experimenting with these uncommented now ... handleDisplayNameAsShortIdentifier(wrapDoc.getWrappedObject(), authorityItemCommonSchemaName); updateRefnameForAuthorityItem(wrapDoc, authorityItemCommonSchemaName, getAuthorityRefNameBase()); } + + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleUpdate(org.collectionspace.services.common.document.DocumentWrapper) + */ + @Override + public void handleUpdate(DocumentWrapper wrapDoc) throws Exception { + super.handleUpdate(wrapDoc); + handleComputedDisplayNames(wrapDoc.getWrappedObject()); + } + + /** + * Handle display name. + * + * @param docModel the doc model + * @throws Exception the exception + */ + protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception { + // Do nothing by default. + } private void handleDisplayNameAsShortIdentifier(DocumentModel docModel, String schemaName) throws Exception { String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER); 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 2f0c03268..b761b6de9 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 @@ -57,32 +57,14 @@ public class LocationDocumentModelHandler return LocationAuthorityClient.SERVICE_PATH_COMPONENT; // CSPACE-3932 } - /* (non-Javadoc) - * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper) - */ - @Override - public void handleCreate(DocumentWrapper wrapDoc) throws Exception { - // first fill all the parts of the document - super.handleCreate(wrapDoc); - handleDisplayNames(wrapDoc.getWrappedObject()); - } - - /* (non-Javadoc) - * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleUpdate(org.collectionspace.services.common.document.DocumentWrapper) - */ - @Override - public void handleUpdate(DocumentWrapper wrapDoc) throws Exception { - super.handleUpdate(wrapDoc); - handleDisplayNames(wrapDoc.getWrappedObject()); - } - /** * Handle display name. * * @param docModel the doc model * @throws Exception the exception */ - private void handleDisplayNames(DocumentModel docModel) throws Exception { + @Override + protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception { String commonPartLabel = getServiceContext().getCommonPartLabel("locations"); Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel, LocationJAXBSchema.DISPLAY_NAME_COMPUTED); 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 e95ff1bc3..f14fefddf 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 @@ -57,25 +57,6 @@ public class OrganizationDocumentModelHandler return OrgAuthorityClient.SERVICE_PATH_COMPONENT; // CSPACE-3932 } - /* (non-Javadoc) - * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper) - */ - @Override - public void handleCreate(DocumentWrapper wrapDoc) throws Exception { - // first fill all the parts of the document - super.handleCreate(wrapDoc); - handleDisplayNames(wrapDoc.getWrappedObject()); - } - - /* (non-Javadoc) - * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleUpdate(org.collectionspace.services.common.document.DocumentWrapper) - */ - @Override - public void handleUpdate(DocumentWrapper wrapDoc) throws Exception { - super.handleUpdate(wrapDoc); - handleDisplayNames(wrapDoc.getWrappedObject()); - } - /** * Check the logic around the computed displayName * @@ -83,7 +64,8 @@ public class OrganizationDocumentModelHandler * * @throws Exception the exception */ - private void handleDisplayNames(DocumentModel docModel) throws Exception { + @Override + protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception { String commonPartLabel = getServiceContext().getCommonPartLabel("organizations"); Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel, OrganizationJAXBSchema.DISPLAY_NAME_COMPUTED); 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 a3e076a47..491d7a697 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 @@ -64,32 +64,14 @@ public class PersonDocumentModelHandler return PersonAuthorityClient.SERVICE_PATH_COMPONENT; // CSPACE-3932 } - /* (non-Javadoc) - * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper) - */ - @Override - public void handleCreate(DocumentWrapper wrapDoc) throws Exception { - // first fill all the parts of the document - super.handleCreate(wrapDoc); - handleDisplayNames(wrapDoc.getWrappedObject()); - } - - /* (non-Javadoc) - * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleUpdate(org.collectionspace.services.common.document.DocumentWrapper) - */ - @Override - public void handleUpdate(DocumentWrapper wrapDoc) throws Exception { - super.handleUpdate(wrapDoc); - handleDisplayNames(wrapDoc.getWrappedObject()); - } - /** * Handle display names. * * @param docModel the doc model * @throws Exception the exception */ - private void handleDisplayNames(DocumentModel docModel) throws Exception { + @Override + protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception { String commonPartLabel = getServiceContext().getCommonPartLabel("persons"); Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel, PersonJAXBSchema.DISPLAY_NAME_COMPUTED); 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 95b1688f4..886b7ba32 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 @@ -51,32 +51,14 @@ public class TaxonDocumentModelHandler super(COMMON_PART_LABEL); } - /* (non-Javadoc) - * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper) - */ - @Override - public void handleCreate(DocumentWrapper wrapDoc) throws Exception { - // first fill all the parts of the document - super.handleCreate(wrapDoc); - handleDisplayNames(wrapDoc.getWrappedObject()); - } - - /* (non-Javadoc) - * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleUpdate(org.collectionspace.services.common.document.DocumentWrapper) - */ - @Override - public void handleUpdate(DocumentWrapper wrapDoc) throws Exception { - super.handleUpdate(wrapDoc); - handleDisplayNames(wrapDoc.getWrappedObject()); - } - /** * Handle display name. * * @param docModel the doc model * @throws Exception the exception */ - private void handleDisplayNames(DocumentModel docModel) throws Exception { + @Override + protected void handleComputedDisplayNames(DocumentModel docModel) throws Exception { String commonPartLabel = getServiceContext().getCommonPartLabel("taxon"); Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel, TaxonJAXBSchema.DISPLAY_NAME_COMPUTED);