From: remillet Date: Thu, 31 Mar 2016 11:59:24 +0000 (-0700) Subject: CSPACE-6935:Added logic to inc rev number for authority and vocab terms. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=6d4fed72508dafec5f3074ae39aa925311008a12;p=tmp%2Fjakarta-migration.git CSPACE-6935:Added logic to inc rev number for authority and vocab terms. --- diff --git a/services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java b/services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java index adecfe1ec..77bea4636 100644 --- a/services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java +++ b/services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java @@ -33,6 +33,7 @@ public interface AuthorityJAXBSchema { final static String REF_NAME = "refName"; final static String VOCAB_TYPE = "vocabType"; final static String CSID = "csid"; + final static String REV = "rev"; } 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 be07bd4c6..dbbe70f75 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 @@ -86,17 +86,20 @@ public abstract class AuthorityDocumentModelHandler // // Update the record's revision number on both CREATE and UPDATE actions // + updateRevNumbers(wrapDoc); + } + + protected void updateRevNumbers(DocumentWrapper wrapDoc) { DocumentModel documentModel = wrapDoc.getWrappedObject(); - Integer rev = (Integer)documentModel.getProperty(authorityCommonSchemaName, AuthorityItemJAXBSchema.REV); + Long rev = (Long)documentModel.getProperty(authorityCommonSchemaName, AuthorityJAXBSchema.REV); if (rev == null) { - rev = 0; + rev = (long)0; } else { rev++; } - documentModel.setProperty(authorityCommonSchemaName, AuthorityItemJAXBSchema.REV, rev); + documentModel.setProperty(authorityCommonSchemaName, AuthorityJAXBSchema.REV, rev); } - @Override public void handleCreate(DocumentWrapper wrapDoc) throws Exception { super.handleCreate(wrapDoc); diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java index f07dfaa9d..99b6865b6 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java @@ -36,6 +36,7 @@ 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.DocumentWrapper; +import org.collectionspace.services.common.document.DocumentHandler.Action; import org.collectionspace.services.common.repository.RepositoryClient; import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; @@ -93,6 +94,8 @@ public abstract class AuthorityItemDocumentModelHandler public AuthorityItemDocumentModelHandler(String authorityItemCommonSchemaName) { this.authorityItemCommonSchemaName = authorityItemCommonSchemaName; } + + abstract public String getParentCommonSchemaName(); @Override protected String getRefnameDisplayName(DocumentWrapper docWrapper) { @@ -395,6 +398,33 @@ public abstract class AuthorityItemDocumentModelHandler } } + public void fillAllParts(DocumentWrapper wrapDoc, Action action) throws Exception { + super.fillAllParts(wrapDoc, action); + // + // Update the record's revision number on both CREATE and UPDATE actions + // + updateRevNumbers(wrapDoc); + } + + protected void updateRevNumbers(DocumentWrapper wrapDoc) throws Exception { + DocumentModel documentModel = wrapDoc.getWrappedObject(); + Long rev = (Long)documentModel.getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.REV); + if (rev == null) { + rev = (long)0; + } else { + rev++; + } + documentModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.REV, rev); + // + // Next, update the inAuthority (the parent's) rev number + // + DocumentModel inAuthorityDocModel = NuxeoUtils.getDocFromCsid(getServiceContext(), getRepositorySession(), getInAuthority()); + Long parentRev = (Long)inAuthorityDocModel.getProperty(getParentCommonSchemaName(), AuthorityJAXBSchema.REV); + parentRev++; + inAuthorityDocModel.setProperty(getParentCommonSchemaName(), AuthorityJAXBSchema.REV, parentRev); + getRepositorySession().saveDocument(inAuthorityDocModel); + } + /** * If no short identifier was provided in the input payload, generate a * short identifier from the preferred term display name or term name. @@ -732,15 +762,6 @@ public abstract class AuthorityItemDocumentModelHandler super.extractAllParts(wrapDoc); } - @Override - public void fillAllParts(DocumentWrapper wrapDoc, Action action) throws Exception { - // - // We currently don't override this method with any AuthorityItemDocumentModelHandler specific functionality, so - // we could remove this method. - // - super.fillAllParts(wrapDoc, action); - } - protected List cloneList(List inboundList) { List result = newRelationsCommonList(); for (RelationsCommonList.RelationListItem item : inboundList) { 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 a78cdd0b2..a6460c084 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 @@ -38,7 +38,7 @@ public class CitationAuthorityDocumentModelHandler /** * Common part schema label */ - private static final String COMMON_PART_LABEL = "citationauthorities_common"; + static final String COMMON_PART_LABEL = "citationauthorities_common"; public CitationAuthorityDocumentModelHandler() { super(COMMON_PART_LABEL); 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 1ac55ec9a..21f09e73c 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 @@ -70,5 +70,11 @@ public class CitationDocumentModelHandler public String getQProperty(String prop) { return CitationConstants.NUXEO_SCHEMA_NAME + ":" + prop; } + + @Override + public String getParentCommonSchemaName() { + // TODO Auto-generated method stub + return CitationAuthorityDocumentModelHandler.COMMON_PART_LABEL; + } } 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 5b971bd96..d0313fada 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 @@ -38,7 +38,7 @@ public class ConceptAuthorityDocumentModelHandler /** * Common part schema label */ - private static final String COMMON_PART_LABEL = "conceptauthorities_common"; + static final String COMMON_PART_LABEL = "conceptauthorities_common"; public ConceptAuthorityDocumentModelHandler() { super(COMMON_PART_LABEL); 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 b67e02b27..842a97d36 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 @@ -62,5 +62,12 @@ public class ConceptDocumentModelHandler public String getQProperty(String prop) { return ConceptConstants.NUXEO_SCHEMA_NAME + ":" + prop; } + + @Override + public String getParentCommonSchemaName() { + // TODO Auto-generated method stub + return ConceptAuthorityDocumentModelHandler.COMMON_PART_LABEL; + } + } 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 62371f6ab..817ebb998 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 @@ -38,7 +38,7 @@ public class LocationAuthorityDocumentModelHandler /** * Common part schema label */ - private static final String COMMON_PART_LABEL = "locationauthorities_common"; + static final String COMMON_PART_LABEL = "locationauthorities_common"; public LocationAuthorityDocumentModelHandler() { super(COMMON_PART_LABEL); 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 d9f9eb356..176fc0628 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 @@ -117,5 +117,12 @@ public class LocationDocumentModelHandler public String getQProperty(String prop) { return LocationConstants.NUXEO_SCHEMA_NAME + ":" + prop; } + + @Override + public String getParentCommonSchemaName() { + // TODO Auto-generated method stub + return LocationAuthorityDocumentModelHandler.COMMON_PART_LABEL; + } + } 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 dd50b2271..366e3c3dd 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 @@ -36,7 +36,7 @@ public class MaterialAuthorityDocumentModelHandler /** * Common part schema label */ - private static final String COMMON_PART_LABEL = "materialauthorities_common"; + static final String COMMON_PART_LABEL = "materialauthorities_common"; public MaterialAuthorityDocumentModelHandler() { super(COMMON_PART_LABEL); 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 de974099d..4422cd958 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 @@ -110,5 +110,12 @@ public class MaterialDocumentModelHandler public String getQProperty(String prop) { return MaterialConstants.NUXEO_SCHEMA_NAME + ":" + prop; } + + @Override + public String getParentCommonSchemaName() { + // TODO Auto-generated method stub + return MaterialAuthorityDocumentModelHandler.COMMON_PART_LABEL; + } + } 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 42a878740..959d7ca37 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 @@ -38,7 +38,7 @@ public class OrgAuthorityDocumentModelHandler /** * Common part schema label */ - private static final String COMMON_PART_LABEL = "orgauthorities_common"; + static final String COMMON_PART_LABEL = "orgauthorities_common"; public OrgAuthorityDocumentModelHandler() { super(COMMON_PART_LABEL); 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 ae52e6373..3b87129b5 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 @@ -134,5 +134,11 @@ public class OrganizationDocumentModelHandler return OrganizationConstants.NUXEO_SCHEMA_NAME + ":" + prop; } + @Override + public String getParentCommonSchemaName() { + // TODO Auto-generated method stub + return OrgAuthorityDocumentModelHandler.COMMON_PART_LABEL; + } + } 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 3a15f1bfd..2d9e3108c 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 @@ -38,7 +38,7 @@ public class PersonAuthorityDocumentModelHandler /** * Common part schema label */ - private static final String COMMON_PART_LABEL = "personauthorities_common"; + static final String COMMON_PART_LABEL = "personauthorities_common"; public PersonAuthorityDocumentModelHandler() { super(COMMON_PART_LABEL); 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 8b703b125..ef44bc24a 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 @@ -175,5 +175,12 @@ public class PersonDocumentModelHandler public String getQProperty(String prop) { return PersonConstants.NUXEO_SCHEMA_NAME + ":" + prop; } + + @Override + public String getParentCommonSchemaName() { + // TODO Auto-generated method stub + return PersonAuthorityDocumentModelHandler.COMMON_PART_LABEL; + } + } 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 bd9459799..d4debdfa2 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 @@ -38,7 +38,7 @@ public class PlaceAuthorityDocumentModelHandler /** * Common part schema label */ - private static final String COMMON_PART_LABEL = "placeauthorities_common"; + static final String COMMON_PART_LABEL = "placeauthorities_common"; public PlaceAuthorityDocumentModelHandler() { super(COMMON_PART_LABEL); 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 e3ef851cb..865b534bd 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 @@ -116,5 +116,11 @@ public class PlaceDocumentModelHandler public String getQProperty(String prop) { return PlaceConstants.NUXEO_SCHEMA_NAME + ":" + prop; } + + @Override + public String getParentCommonSchemaName() { + // TODO Auto-generated method stub + return PlaceAuthorityDocumentModelHandler.COMMON_PART_LABEL; + } } 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 83ef98100..75ab29bf9 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 @@ -114,5 +114,11 @@ public class TaxonDocumentModelHandler public String getQProperty(String prop) { return TaxonConstants.NUXEO_SCHEMA_NAME + ":" + prop; } + + @Override + public String getParentCommonSchemaName() { + // TODO Auto-generated method stub + return TaxonomyAuthorityDocumentModelHandler.COMMON_PART_LABEL; + } } 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 554f0b285..f59073e0d 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 @@ -38,7 +38,7 @@ public class TaxonomyAuthorityDocumentModelHandler /** * Common part schema label */ - private static final String COMMON_PART_LABEL = "taxonomyauthority_common"; + static final String COMMON_PART_LABEL = "taxonomyauthority_common"; public TaxonomyAuthorityDocumentModelHandler() { super(COMMON_PART_LABEL); diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java index ae145b1d5..53ebe2ead 100644 --- a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java @@ -38,7 +38,7 @@ public class VocabularyDocumentModelHandler /** * Common part schema label */ - private static final String COMMON_PART_LABEL = "vocabularies_common"; + static final String COMMON_PART_LABEL = "vocabularies_common"; public VocabularyDocumentModelHandler() { super(COMMON_PART_LABEL); 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 b59bf2dca..f19cc3572 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 @@ -108,6 +108,12 @@ public class VocabularyItemDocumentModelHandler return result; } + + @Override + public String getParentCommonSchemaName() { + // TODO Auto-generated method stub + return VocabularyDocumentModelHandler.COMMON_PART_LABEL; + } } 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 f295d71d0..110016ae8 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 @@ -36,7 +36,7 @@ public class WorkAuthorityDocumentModelHandler /** * Common part schema label */ - private static final String COMMON_PART_LABEL = "workauthorities_common"; + static final String COMMON_PART_LABEL = "workauthorities_common"; public WorkAuthorityDocumentModelHandler() { super(COMMON_PART_LABEL); 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 8e175b76e..9cf41089e 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 @@ -110,5 +110,11 @@ public class WorkDocumentModelHandler public String getQProperty(String prop) { return WorkConstants.NUXEO_SCHEMA_NAME + ":" + prop; } + + @Override + public String getParentCommonSchemaName() { + // TODO Auto-generated method stub + return WorkAuthorityDocumentModelHandler.COMMON_PART_LABEL; + } }