]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6935:Added logic to inc rev number for authority and vocab terms.
authorremillet <remillet@yahoo.com>
Thu, 31 Mar 2016 11:59:24 +0000 (04:59 -0700)
committerremillet <remillet@yahoo.com>
Thu, 31 Mar 2016 11:59:24 +0000 (04:59 -0700)
23 files changed:
services/authority/jaxb/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java
services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationAuthorityDocumentModelHandler.java
services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationDocumentModelHandler.java
services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptAuthorityDocumentModelHandler.java
services/concept/service/src/main/java/org/collectionspace/services/concept/nuxeo/ConceptDocumentModelHandler.java
services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java
services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java
services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialAuthorityDocumentModelHandler.java
services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialDocumentModelHandler.java
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java
services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java
services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java
services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceAuthorityDocumentModelHandler.java
services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceDocumentModelHandler.java
services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonDocumentModelHandler.java
services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonomyAuthorityDocumentModelHandler.java
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java
services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkAuthorityDocumentModelHandler.java
services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkDocumentModelHandler.java

index adecfe1ec1e8a8b0f52ec3fb06ac0ffdcb59e204..77bea46367c9776f6c5e0219b3d1c1dd55ceae6e 100644 (file)
@@ -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";
 }
 
 
index be07bd4c608dd166293751efc5726b43774070d0..dbbe70f757444835644ffae02d0955d32d360cb6 100644 (file)
@@ -86,17 +86,20 @@ public abstract class AuthorityDocumentModelHandler<AuthCommon>
        //
        // Update the record's revision number on both CREATE and UPDATE actions
        //
+       updateRevNumbers(wrapDoc);
+    }
+    
+    protected void updateRevNumbers(DocumentWrapper<DocumentModel> 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<DocumentModel> wrapDoc) throws Exception {
         super.handleCreate(wrapDoc);
index f07dfaa9d8ecce97efc74299a4fd19f47317e833..99b6865b633f3354f1aa99bc752586a5eae8dc72 100644 (file)
@@ -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<AICommon>
     public AuthorityItemDocumentModelHandler(String authorityItemCommonSchemaName) {
         this.authorityItemCommonSchemaName = authorityItemCommonSchemaName;
     }
+    
+    abstract public String getParentCommonSchemaName();
 
     @Override
     protected String getRefnameDisplayName(DocumentWrapper<DocumentModel> docWrapper) {
@@ -395,6 +398,33 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         }
     }
     
+    public void fillAllParts(DocumentWrapper<DocumentModel> 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<DocumentModel> 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<AICommon>
         super.extractAllParts(wrapDoc);
     }
 
-    @Override
-    public void fillAllParts(DocumentWrapper<DocumentModel> 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<RelationsCommonList.RelationListItem> cloneList(List<RelationsCommonList.RelationListItem> inboundList) {
         List<RelationsCommonList.RelationListItem> result = newRelationsCommonList();
         for (RelationsCommonList.RelationListItem item : inboundList) {
index a78cdd0b2aa9111610a22aa24277e6d1a81a8ad4..a6460c08437325c41b30e993273defadefbdbdeb 100644 (file)
@@ -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);
index 1ac55ec9a266be4d9b34ae557a598a9c6aef94d5..21f09e73c84cbdcaf437ae822f8e53b2078f9406 100644 (file)
@@ -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;
+       }
 }
 
index 5b971bd968878d217195bd7116e16b40d24be36c..d0313fadafe8cdd9b6734ba61569dba590b53404 100644 (file)
@@ -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);
index b67e02b274f22c36291943aa6dd9120c0b7c5833..842a97d36c6dfc9373b16d6b771f7b609a59b659 100644 (file)
@@ -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;
+       }
+    
 }
 
index 62371f6abff8b7738bc95fdca6653132bf35bcfb..817ebb9983a13c21be41df23d71db8da83557d2f 100644 (file)
@@ -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);
index d9f9eb3568d4079ab5deb1ae27f1747182695607..176fc06286e34d0ea5bdd3b400c2ad8b764c82f5 100644 (file)
@@ -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;
+       }
+    
 }
 
index dd50b2271aa0895cfae7a8253cf667fbf9827f76..366e3c3dd1f5eedb0bed5312e25806738a52c119 100644 (file)
@@ -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);
index de974099d7ff51a5f84e6220bbd498210957ecad..4422cd95811c0bee1dd1d2a5dd49711b88b5c5fe 100644 (file)
@@ -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;
+       }
+    
 }
 
index 42a878740753dde1cbb8a8bc626cc75815635f8b..959d7ca3757ecd20c7176c13c8afd9d8b8ac4f7c 100644 (file)
@@ -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);
index ae52e63736331880d5d1a5f8c606e12cec434a6f..3b87129b5bfcdbb13f492e6bf33030644be92b93 100644 (file)
@@ -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;
+       }
+    
 }
 
index 3a15f1bfdf957891bb9cacbca453c5832282d617..2d9e3108cc7248b5c702714f528ee00c4891f446 100644 (file)
@@ -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);
index 8b703b12540886d7b4ddebf9ad700eb39f39ddd6..ef44bc24a73efd12e0cc23ade75a822bc461af37 100644 (file)
@@ -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;
+       }
+    
 }
 
index bd945979914e7e7f4dbadaadaed1119135ca2d88..d4debdfa24cfccca482307a83cde3d269c19bced 100644 (file)
@@ -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);
index e3ef851cb9d867ec865809068406c6a67c7ab2f7..865b534bd556b19e82b084988267dcd08d353e01 100644 (file)
@@ -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;
+       }
 }
 
index 83ef981005911512fdb0d8b1f449966a0f2a68cf..75ab29bf91ac34c484139c3e94963767fec0afa0 100644 (file)
@@ -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;
+       }
 }
 
index 554f0b285b7ee4ac2bc30b540d5caaf9e77c5f74..f59073e0da740033814ee124d03d8d05eb556579 100644 (file)
@@ -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);
index ae145b1d53345310f4d78dcb3ea00eb90bfeae71..53ebe2eadf85d07bd47913c505da9ce5bffbedd6 100644 (file)
@@ -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);
index b59bf2dcad6ff670276341a99567aad8dcc24713..f19cc3572f26238dd2525bef6d46f6af12f142c1 100644 (file)
@@ -108,6 +108,12 @@ public class VocabularyItemDocumentModelHandler
 
                return result;
     }    
+
+       @Override
+       public String getParentCommonSchemaName() {
+               // TODO Auto-generated method stub
+               return VocabularyDocumentModelHandler.COMMON_PART_LABEL;
+       }
     
 }
 
index f295d71d0d35027aef18640884c86a0eff02913f..110016ae8570e2cdf546db7b8635cfeeeddff895 100644 (file)
@@ -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);
index 8e175b76e9ae04774876838c4d4de4b784d569d2..9cf41089e24cb57025c7335ba462f3dd9e8d251b 100644 (file)
@@ -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;
+       }
 }