]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-1253: UCB Botgarden Contributions (#362)
authorMichael Ritter <mikejritter@users.noreply.github.com>
Fri, 15 Dec 2023 18:13:21 +0000 (13:13 -0500)
committerGitHub <noreply@github.com>
Fri, 15 Dec 2023 18:13:21 +0000 (13:13 -0500)
Co-authored-by: Richard Millet <richard.millet@berkeley.edu>
Co-authored-by: Ray Lee <ray.lee@lyrasis.org>
45 files changed:
3rdparty/nuxeo/nuxeo-platform-listener/build.xml
3rdparty/nuxeo/nuxeo-platform-listener/naturalhistory/src/main/java/org/collectionspace/services/listener/naturalhistory/UpdateFormattedDisplayNameListener.java
3rdparty/nuxeo/nuxeo-platform-listener/pom.xml
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/build.properties [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/build.properties with 100% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/build.xml [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/build.xml with 98% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/pom.xml [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/pom.xml with 97% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/CreateVersionListener.java [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/CreateVersionListener.java with 100% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/DeleteDeadLocationListener.java [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/DeleteDeadLocationListener.java with 92% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateAccessCodeListener.java [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateAccessCodeListener.java with 94% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateDeadFlagListener.java [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateDeadFlagListener.java with 92% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateLocationListener.java [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateLocationListener.java with 88% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateRareFlagListener.java [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateRareFlagListener.java with 92% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateStyledNameListener.java [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/java/org/collectionspace/services/listener/botgarden/UpdateStyledNameListener.java with 98% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/src/main/resources/META-INF/MANIFEST.MF [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/resources/META-INF/MANIFEST.MF with 100% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/src/main/resources/OSGI-INF/core-types-contrib.xml [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/resources/OSGI-INF/core-types-contrib.xml with 100% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/src/main/resources/OSGI-INF/default-life-cycle-contrib.xml [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/resources/OSGI-INF/default-life-cycle-contrib.xml with 100% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/src/main/resources/OSGI-INF/deployment-fragment.xml [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/resources/OSGI-INF/deployment-fragment.xml with 100% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/src/main/resources/OSGI-INF/ecm-types-contrib.xml [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/resources/OSGI-INF/ecm-types-contrib.xml with 100% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/src/main/resources/OSGI-INF/layouts-contrib.xml [moved from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/src/main/resources/OSGI-INF/layouts-contrib.xml with 100% similarity]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/build.xml [new file with mode: 0644]
3rdparty/nuxeo/nuxeo-platform-listener/tenants/pom.xml [new file with mode: 0644]
cspace-ui/build.xml
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/ClearLocationLabelRequestBatchJob.java [moved from services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearLocationLabelRequestBatchJob.java with 97% similarity]
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/ClearPotTagLabelRequestBatchJob.java [moved from services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearPotTagLabelRequestBatchJob.java with 96% similarity]
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/ClearVoucherLabelRequestBatchJob.java [moved from services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/ClearVoucherLabelRequestBatchJob.java with 96% similarity]
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/CreateVoucherBatchJob.java [moved from services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateVoucherBatchJob.java with 88% similarity]
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/FormatVoucherNameBatchJob.java [moved from services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/FormatVoucherNameBatchJob.java with 88% similarity]
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/UpdateAccessCodeBatchJob.java [moved from services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateAccessCodeBatchJob.java with 91% similarity]
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/UpdateDeadFlagBatchJob.java [moved from services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateDeadFlagBatchJob.java with 92% similarity]
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/UpdateHybridNameBatchJob.java [new file with mode: 0644]
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/UpdateObjectFieldsBatchJob.java [new file with mode: 0644]
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/UpdateRareFlagBatchJob.java [moved from services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateRareFlagBatchJob.java with 92% similarity]
services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClient.java
services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java
services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectBotGardenConstants.java
services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectNaturalHistoryConstants.java [new file with mode: 0644]
services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/validators/BotGardenCollectionObjectValidatorHandler.java [moved from services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/BotGardenCollectionObjectValidatorHandler.java with 69% similarity]
services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/validators/PahmaCollectionObjectValidatorHandler.java [new file with mode: 0644]
services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/validators/UCJepsCollectionObjectValidatorHandler.java [new file with mode: 0644]
services/common-api/src/main/java/org/collectionspace/services/common/api/RefNameUtils.java
services/common/src/main/cspace/config/services/tenants/botgarden/botgarden-tenant-bindings.delta.xml
services/movement/service/src/main/java/org/collectionspace/services/movement/nuxeo/MovementBotGardenConstants.java
services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonConstants.java
services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonNaturalHistoryConstants.java [moved from services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonBotGardenConstants.java with 95% similarity]
services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonomyAuthorityConstants.java

index 87dd0d928fe8beff353ed13d4e6dd8ee3160550a..b2653f941935ab162a87a1321383fd6f5c4363c9 100644 (file)
         <ant antfile="updaterelationsondelete/build.xml" target="deploy" inheritall="false"/>
         <ant antfile="updateimagederivatives/build.xml" target="deploy" inheritall="false"/>
         <ant antfile="naturalhistory/build.xml" target="deploy" inheritall="false"/>
-        <ant antfile="botgarden/build.xml" target="deploy" inheritall="false"/>
+        <ant antfile="tenants/build.xml" target="deploy" inheritall="false"/>
     </target>
 
     <target name="undeploy"
         <ant antfile="updaterelationsondelete/build.xml" target="undeploy" inheritall="false"/>
         <ant antfile="updateimagederivatives/build.xml" target="undeploy" inheritall="false"/>
         <ant antfile="naturalhistory/build.xml" target="undeploy" inheritall="false"/>
-        <ant antfile="botgarden/build.xml" target="undeploy" inheritall="false"/>
+        <ant antfile="tenants/build.xml" target="undeploy" inheritall="false"/>
     </target>
 
     <target name="dist"
         <ant antfile="updaterelationsondelete/build.xml" target="dist" inheritall="false"/>
         <ant antfile="updateimagederivatives/build.xml" target="dist" inheritall="false"/>
         <ant antfile="naturalhistory/build.xml" target="dist" inheritall="false"/>
-        <ant antfile="botgarden/build.xml" target="dist" inheritall="false"/>
+        <ant antfile="tenants/build.xml" target="dist" inheritall="false"/>
     </target>
 
 </project>
index fdacc758569b9d8a1bd530e9ee59b7977d5fae21..5416b4480fd6d8f0e7110e5aa7fc8896ef5705fd 100644 (file)
@@ -13,7 +13,7 @@ import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.common.api.RefName;
 import org.collectionspace.services.common.api.TaxonFormatter;
 import org.collectionspace.services.nuxeo.listener.AbstractCSEventSyncListenerImpl;
-import org.collectionspace.services.taxonomy.nuxeo.TaxonBotGardenConstants;
+import org.collectionspace.services.taxonomy.nuxeo.TaxonNaturalHistoryConstants;
 import org.collectionspace.services.taxonomy.nuxeo.TaxonConstants;
 import org.collectionspace.services.taxonomy.nuxeo.TaxonomyAuthorityConstants;
 
@@ -74,7 +74,7 @@ public class UpdateFormattedDisplayNameListener extends AbstractCSEventSyncListe
 
                logger.debug("parentShortId=" + parentShortId);
 
-               if (!parentShortId.equals(TaxonBotGardenConstants.COMMON_VOCABULARY_SHORTID)) {
+               if (!parentShortId.equals(TaxonNaturalHistoryConstants.COMMON_VOCABULARY_SHORTID)) {
                        if (event.getName().equals(DocumentEventTypes.DOCUMENT_CREATED)) {
                                // Save the document, to get the BEFORE_DOC_UPDATE branch to run.
                                doc.getCoreSession().saveDocument(doc);
index ef2bea300911a4670d60134a02688a5afa83c091..4d32c0ddf3f6188bfa7a9c6e2999b4d6781487b1 100644 (file)
@@ -18,7 +18,7 @@
         <module>updaterelationsondelete</module>
         <module>updateimagederivatives</module>
         <module>naturalhistory</module>
-        <module>botgarden</module>
+        <module>tenants</module>
     </modules>
 
     <dependencies>
similarity index 98%
rename from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/build.xml
rename to 3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/build.xml
index b8d2e30036eb43487fa5804bafbe200e890b7046..84fef484b84d944661d06c20d9cdcb4480b6e7a4 100644 (file)
@@ -3,7 +3,7 @@
     CollectionSpace Nuxeo listener component type
   </description>
   <!-- Set global properties for this build -->
-  <property name="services.trunk" value="../../../.."/>
+  <property name="services.trunk" value="../../../../.."/>
   <!-- Environment should be declared before reading build.properties -->
   <property environment="env" />
   <!-- Set global properties for this build -->
similarity index 97%
rename from 3rdparty/nuxeo/nuxeo-platform-listener/botgarden/pom.xml
rename to 3rdparty/nuxeo/nuxeo-platform-listener/tenants/botgarden/pom.xml
index db79e6b9bfbab822b12dea382efefb3091ecf963..d632e1e6041174565355a1be8f9b917f06cb40f7 100644 (file)
@@ -4,18 +4,19 @@
     xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <modelVersion>4.0.0</modelVersion>
     <parent>
-        <artifactId>org.collectionspace.services.3rdparty.nuxeo.listener</artifactId>
+        <artifactId>org.collectionspace.services.3rdparty.nuxeo.listener.tenants</artifactId>
         <groupId>org.collectionspace.services</groupId>
-        <version>${revision}</version>        
+        <version>${revision}</version>
     </parent>
+
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     </properties>
+
     <artifactId>org.collectionspace.services.listener.botgarden</artifactId>
     <name>org.collectionspace.services.listener.botgarden</name>
     <url>http://maven.apache.org</url>
 
-        
        <dependencies>
         <dependency>
             <groupId>org.nuxeo.ecm.core</groupId>
@@ -44,7 +45,6 @@
         </dependency>
        </dependencies>
 
-       
     <build>
         <resources>
             <resource>
@@ -4,6 +4,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.collectionspace.services.client.workflow.WorkflowClient;
+import org.collectionspace.services.common.api.RefNameUtils;
 import org.collectionspace.services.movement.nuxeo.MovementBotGardenConstants;
 import org.collectionspace.services.movement.nuxeo.MovementConstants;
 import org.collectionspace.services.nuxeo.listener.AbstractCSEventSyncListenerImpl;
@@ -49,8 +50,8 @@ public class DeleteDeadLocationListener extends AbstractCSEventSyncListenerImpl
                        MovementBotGardenConstants.ACTION_CODE_FIELD_NAME);
        
        logger.debug("actionCode=" + actionCode);
-       
-       if (actionCode != null && actionCode.equals(MovementBotGardenConstants.DEAD_ACTION_CODE)) {
+
+       if (actionCode != null && RefNameUtils.doShortIDsMatch(actionCode, MovementBotGardenConstants.DEAD_ACTION_CODE)) {
                CoreSession session = context.getCoreSession();
                
                if (session.getAllowedStateTransitions(doc.getRef()).contains(WorkflowClient.WORKFLOWTRANSITION_DELETE)) {
@@ -13,21 +13,22 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.collectionspace.services.batch.BatchResource;
-import org.collectionspace.services.batch.nuxeo.UpdateAccessCodeBatchJob;
-import org.collectionspace.services.batch.nuxeo.UpdateAccessCodeBatchJob.UpdateAccessCodeResults;
+import org.collectionspace.services.batch.nuxeo.botgarden.UpdateAccessCodeBatchJob;
+import org.collectionspace.services.batch.nuxeo.botgarden.UpdateAccessCodeBatchJob.UpdateAccessCodeResults;
 import org.collectionspace.services.client.BatchClient;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectBotGardenConstants;
 import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectConstants;
+import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectNaturalHistoryConstants;
 import org.collectionspace.services.common.ResourceMap;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.invocable.InvocationResults;
 import org.collectionspace.services.common.relation.nuxeo.RelationConstants;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionWrapper;
 import org.collectionspace.services.nuxeo.listener.AbstractCSEventSyncListenerImpl;
-import org.collectionspace.services.taxonomy.nuxeo.TaxonBotGardenConstants;
+import org.collectionspace.services.taxonomy.nuxeo.TaxonNaturalHistoryConstants;
 import org.collectionspace.services.taxonomy.nuxeo.TaxonConstants;
 import org.collectionspace.services.taxonomy.nuxeo.TaxonomyAuthorityConstants;
 
@@ -44,7 +45,7 @@ import org.nuxeo.ecm.core.event.impl.DocumentEventContext;
  * A listener that updates the access code on taxon records when collectionobjects
  * or taxon records are created or modified.
  *
- * @see org.collectionspace.services.batch.nuxeo.UpdateAccessCodeBatchJob
+ * @see org.collectionspace.services.batch.nuxeo.botgarden.UpdateAccessCodeBatchJob
  * @author ray
  *
  */
@@ -56,7 +57,7 @@ public class UpdateAccessCodeListener extends AbstractCSEventSyncListenerImpl {
        public static final String PREVIOUS_ACCESS_CODE_PROPERTY_NAME = "UpdateAccessCodeListener.previousAccessCode";
        public static final String DELETED_RELATION_PARENT_CSID_PROPERTY_NAME = "UpdateAccessCodeListener.deletedRelationParentCsid";
 
-       private static final String[] TAXON_PATH_ELEMENTS = CollectionObjectBotGardenConstants.TAXON_FIELD_NAME.split("/");
+       private static final String[] TAXON_PATH_ELEMENTS = CollectionObjectNaturalHistoryConstants.TAXON_FIELD_NAME.split("/");
        private static final String TAXONOMIC_IDENT_GROUP_LIST_FIELD_NAME = TAXON_PATH_ELEMENTS[0];
        private static final String TAXON_FIELD_NAME = TAXON_PATH_ELEMENTS[2];
 
@@ -205,7 +206,7 @@ public class UpdateAccessCodeListener extends AbstractCSEventSyncListenerImpl {
                                // Stash the previous access code value, so it can be retrieved in the documentModified handler.
 
                                DocumentModel previousDoc = (DocumentModel) context.getProperty(CoreEventConstants.PREVIOUS_DOCUMENT_MODEL);
-                               String previousAccessCode = (String) previousDoc.getProperty(TaxonBotGardenConstants.ACCESS_CODE_SCHEMA_NAME, TaxonBotGardenConstants.ACCESS_CODE_FIELD_NAME);
+                               String previousAccessCode = (String) previousDoc.getProperty(TaxonNaturalHistoryConstants.ACCESS_CODE_SCHEMA_NAME, TaxonNaturalHistoryConstants.ACCESS_CODE_FIELD_NAME);
 
                                context.setProperty(PREVIOUS_ACCESS_CODE_PROPERTY_NAME, previousAccessCode);
                        }
@@ -218,7 +219,7 @@ public class UpdateAccessCodeListener extends AbstractCSEventSyncListenerImpl {
                                        // record if it has.
 
                                        String previousAccessCode = (String) context.getProperty(PREVIOUS_ACCESS_CODE_PROPERTY_NAME);
-                                       String currentAccessCode = (String) doc.getProperty(TaxonBotGardenConstants.ACCESS_CODE_SCHEMA_NAME, TaxonBotGardenConstants.ACCESS_CODE_FIELD_NAME);
+                                       String currentAccessCode = (String) doc.getProperty(TaxonNaturalHistoryConstants.ACCESS_CODE_SCHEMA_NAME, TaxonNaturalHistoryConstants.ACCESS_CODE_FIELD_NAME);
 
                                        if (previousAccessCode == null) {
                                                previousAccessCode = "";
@@ -321,7 +322,7 @@ public class UpdateAccessCodeListener extends AbstractCSEventSyncListenerImpl {
        }
 
        private List<String> getTaxonNames(DocumentModel doc) {
-               List<Map<String, Object>> taxonomicIdentGroupList = (List<Map<String, Object>>) doc.getProperty(CollectionObjectBotGardenConstants.TAXON_SCHEMA_NAME,
+               List<Map<String, Object>> taxonomicIdentGroupList = (List<Map<String, Object>>) doc.getProperty(CollectionObjectNaturalHistoryConstants.TAXON_SCHEMA_NAME,
                                TAXONOMIC_IDENT_GROUP_LIST_FIELD_NAME);
                List<String> taxonNames = new ArrayList<String>();
 
@@ -4,13 +4,14 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.collectionspace.services.batch.BatchResource;
-import org.collectionspace.services.batch.nuxeo.UpdateDeadFlagBatchJob;
+import org.collectionspace.services.batch.nuxeo.botgarden.UpdateDeadFlagBatchJob;
 import org.collectionspace.services.client.BatchClient;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectConstants;
 import org.collectionspace.services.common.ResourceMap;
+import org.collectionspace.services.common.api.RefNameUtils;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.invocable.InvocationResults;
 import org.collectionspace.services.common.relation.nuxeo.RelationConstants;
@@ -36,7 +37,7 @@ public class UpdateDeadFlagListener extends AbstractCSEventSyncListenerImpl {
     }
 
        /*
-        * Set the dead flag and dead date on collectionobjects related to a new or modified movement record.
+        * Set the dead flag and dead date on CollectionObjects related to a new or modified movement record.
         */
        @Override
        public void handleCSEvent(Event event) {
@@ -89,7 +90,9 @@ public class UpdateDeadFlagListener extends AbstractCSEventSyncListenerImpl {
 
                                logger.debug("actionCode=" + actionCode);
 
-                               if (actionCode != null && (actionCode.equals(MovementBotGardenConstants.DEAD_ACTION_CODE) || actionCode.equals(MovementBotGardenConstants.REVIVED_ACTION_CODE))) {
+                               if (actionCode != null &&
+                                               (RefNameUtils.doShortIDsMatch(actionCode, MovementBotGardenConstants.DEAD_ACTION_CODE) ||
+                                                RefNameUtils.doShortIDsMatch(actionCode, MovementBotGardenConstants.REVIVED_ACTION_CODE))) {
                                        String movementCsid = doc.getName();
 
                                        try {
@@ -4,6 +4,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.collectionspace.services.client.workflow.WorkflowClient;
+import org.collectionspace.services.common.api.RefNameUtils;
 import org.collectionspace.services.movement.nuxeo.MovementBotGardenConstants;
 import org.collectionspace.services.movement.nuxeo.MovementConstants;
 import org.collectionspace.services.nuxeo.listener.AbstractCSEventSyncListenerImpl;
@@ -66,7 +67,7 @@ public class UpdateLocationListener extends AbstractCSEventSyncListenerImpl {
                         * event to fire, taking us into the other branch of this code, with the current document
                         * becoming the previous document.
                         */
-                       if (actionCode != null && actionCode.equals(MovementBotGardenConstants.DEAD_ACTION_CODE)) {
+                       if (actionCode != null && RefNameUtils.doShortIDsMatch(actionCode, MovementBotGardenConstants.DEAD_ACTION_CODE)) {
                                context.getCoreSession().saveDocument(doc);
 
                                /*
@@ -77,7 +78,7 @@ public class UpdateLocationListener extends AbstractCSEventSyncListenerImpl {
                        }
                }
                else {
-                       if (actionCode != null && actionCode.equals(MovementBotGardenConstants.DEAD_ACTION_CODE)) {
+                       if (actionCode != null && RefNameUtils.doShortIDsMatch(actionCode, MovementBotGardenConstants.DEAD_ACTION_CODE)) {
                                doc.setProperty(MovementConstants.CURRENT_LOCATION_SCHEMA_NAME, MovementConstants.CURRENT_LOCATION_FIELD_NAME, MovementConstants.NONE_LOCATION);
                        }
 
@@ -86,7 +87,7 @@ public class UpdateLocationListener extends AbstractCSEventSyncListenerImpl {
 
                        logger.debug("previousLocation=" + previousLocation);
 
-                       doc.setProperty(MovementConstants.PREVIOUS_LOCATION_SCHEMA_NAME, MovementConstants.PREVIOUS_LOCATION_FIELD_NAME, previousLocation);
+                       doc.setProperty(MovementBotGardenConstants.PREVIOUS_LOCATION_SCHEMA_NAME, MovementBotGardenConstants.PREVIOUS_LOCATION_FIELD_NAME, previousLocation);
                }
        }
        
@@ -7,19 +7,19 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.collectionspace.services.batch.BatchResource;
-import org.collectionspace.services.batch.nuxeo.UpdateRareFlagBatchJob;
+import org.collectionspace.services.batch.nuxeo.botgarden.UpdateRareFlagBatchJob;
 import org.collectionspace.services.client.BatchClient;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.workflow.WorkflowClient;
-import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectBotGardenConstants;
 import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectConstants;
+import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectNaturalHistoryConstants;
 import org.collectionspace.services.common.ResourceMap;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.invocable.InvocationResults;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionWrapper;
 import org.collectionspace.services.nuxeo.listener.AbstractCSEventSyncListenerImpl;
-import org.collectionspace.services.taxonomy.nuxeo.TaxonBotGardenConstants;
+import org.collectionspace.services.taxonomy.nuxeo.TaxonNaturalHistoryConstants;
 import org.collectionspace.services.taxonomy.nuxeo.TaxonConstants;
 import org.collectionspace.services.taxonomy.nuxeo.TaxonomyAuthorityConstants;
 
@@ -36,7 +36,7 @@ import org.nuxeo.ecm.core.event.impl.DocumentEventContext;
  * A listener that updates the rare flag on collectionobjects when collectionobjects
  * are created or modified, and when taxon records are modified.
  *
- * @see org.collectionspace.services.batch.nuxeo.UpdateRareFlagBatchJob
+ * @see org.collectionspace.services.batch.nuxeo.botgarden.UpdateRareFlagBatchJob
  * @author ray
  *
  */
@@ -46,7 +46,7 @@ public class UpdateRareFlagListener extends AbstractCSEventSyncListenerImpl {
        public static final String PREVIOUS_TAXON_PROPERTY_NAME = "UpdateRareFlagListener.previousTaxon";
        public static final String PREVIOUS_HAS_RARE_CONSERVATION_CATEGORY_PROPERTY_NAME = "UpdateRareFlagListener.previousHasRareConservationCategory";
 
-       private static final String[] CONSERVATION_CATEGORY_PATH_ELEMENTS = TaxonBotGardenConstants.CONSERVATION_CATEGORY_FIELD_NAME.split("/");
+       private static final String[] CONSERVATION_CATEGORY_PATH_ELEMENTS = TaxonNaturalHistoryConstants.CONSERVATION_CATEGORY_FIELD_NAME.split("/");
        private static final String PLANT_ATTRIBUTES_GROUP_LIST_FIELD_NAME = CONSERVATION_CATEGORY_PATH_ELEMENTS[0];
        private static final String CONSERVATION_CATEGORY_FIELD_NAME = CONSERVATION_CATEGORY_PATH_ELEMENTS[2];
 
@@ -73,8 +73,8 @@ public class UpdateRareFlagListener extends AbstractCSEventSyncListenerImpl {
                                // Stash the previous primary taxonomic ident, so it can be retrieved in the documentModified handler.
 
                                DocumentModel previousDoc = (DocumentModel) context.getProperty(CoreEventConstants.PREVIOUS_DOCUMENT_MODEL);
-                               String previousTaxon = (String) previousDoc.getProperty(CollectionObjectBotGardenConstants.TAXON_SCHEMA_NAME,
-                                               CollectionObjectBotGardenConstants.PRIMARY_TAXON_FIELD_NAME);
+                               String previousTaxon = (String) previousDoc.getProperty(CollectionObjectNaturalHistoryConstants.TAXON_SCHEMA_NAME,
+                                               CollectionObjectNaturalHistoryConstants.PRIMARY_TAXON_FIELD_NAME);
 
                                context.setProperty(PREVIOUS_TAXON_PROPERTY_NAME, previousTaxon);
                        }
@@ -86,8 +86,8 @@ public class UpdateRareFlagListener extends AbstractCSEventSyncListenerImpl {
                                        // of the collectionobject has changed. We only need to update the rare flag if it has.
 
                                        String previousTaxon = (String) context.getProperty(PREVIOUS_TAXON_PROPERTY_NAME);
-                                       String currentTaxon = (String) doc.getProperty(CollectionObjectBotGardenConstants.TAXON_SCHEMA_NAME,
-                                                       CollectionObjectBotGardenConstants.PRIMARY_TAXON_FIELD_NAME);
+                                       String currentTaxon = (String) doc.getProperty(CollectionObjectNaturalHistoryConstants.TAXON_SCHEMA_NAME,
+                                                       CollectionObjectNaturalHistoryConstants.PRIMARY_TAXON_FIELD_NAME);
 
                                        if (previousTaxon == null) {
                                                previousTaxon = "";
@@ -177,7 +177,7 @@ public class UpdateRareFlagListener extends AbstractCSEventSyncListenerImpl {
        }
 
        private boolean hasRareConservationCategory(DocumentModel doc) {
-               List<Map<String, Object>> plantAttributesGroupList = (List<Map<String, Object>>) doc.getProperty(TaxonBotGardenConstants.CONSERVATION_CATEGORY_SCHEMA_NAME,
+               List<Map<String, Object>> plantAttributesGroupList = (List<Map<String, Object>>) doc.getProperty(TaxonNaturalHistoryConstants.CONSERVATION_CATEGORY_SCHEMA_NAME,
                                PLANT_ATTRIBUTES_GROUP_LIST_FIELD_NAME);
                boolean hasRareConservationCategory = false;
 
@@ -6,7 +6,7 @@ import org.slf4j.LoggerFactory;
 import org.jboss.resteasy.spi.ResteasyProviderFactory;
 
 import org.collectionspace.services.batch.BatchResource;
-import org.collectionspace.services.batch.nuxeo.FormatVoucherNameBatchJob;
+import org.collectionspace.services.batch.nuxeo.botgarden.FormatVoucherNameBatchJob;
 import org.collectionspace.services.client.BatchClient;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/tenants/build.xml b/3rdparty/nuxeo/nuxeo-platform-listener/tenants/build.xml
new file mode 100644 (file)
index 0000000..7257de3
--- /dev/null
@@ -0,0 +1,45 @@
+<project name="cspace.ui" default="package" xmlns:if="ant:if" xmlns:unless="ant:unless">
+       <description>
+               Deploy Nuxeo event listeners
+       </description>
+
+       <!-- set global properties for this build -->
+       <property name="services.trunk" value="../../../.."/>
+       <echo>CSpace Release is ${cspace.release}</echo>
+
+       <!-- Environment should be declared before reading build.properties -->
+       <property environment="env" />
+       <property file="${services.trunk}/build.properties" />
+
+       <target name="deploy_tenants">
+               <subant target="deploy_tenant" genericantfile="${ant.file}" inheritall="true">
+                       <dirset dir="." includes="*" excludes=".*,target" />
+               </subant>
+       </target>
+
+       <target name="deploy_tenant">
+               <basename property="tenant.shortname" file="${basedir}" />
+               <echo>Deploy tenant listeners for ${tenant.shortname}</echo>
+               <ant antfile="build.xml" target="deploy" inheritall="false"/>
+       </target>
+
+       <target name="undeploy_tenants">
+               <subant target="undeploy_tenant" genericantfile="${ant.file}" inheritall="true">
+                       <dirset dir="." includes="*" excludes=".*,target" />
+               </subant>
+       </target>
+
+       <target name="undeploy_tenant">
+               <basename property="tenant.shortname" file="${basedir}" />
+               <echo>Undeploy tenant listeners for ${tenant.shortname}</echo>
+               <ant antfile="build.xml" target="undeploy" inheritall="false"/>
+       </target>
+
+       <target name="undeploy_js">
+               <delete dir="${jee.deploy.cspace.ui.shared}" />
+       </target>
+
+       <target name="deploy" depends="deploy_tenants" description="deploy event listeners ${jee.server.cspace}" />
+
+       <target name="undeploy" depends="undeploy_tenants" description="undeploy event listeners ${jee.server.cspace}" />
+</project>
diff --git a/3rdparty/nuxeo/nuxeo-platform-listener/tenants/pom.xml b/3rdparty/nuxeo/nuxeo-platform-listener/tenants/pom.xml
new file mode 100644 (file)
index 0000000..3d7de3c
--- /dev/null
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <parent>
+        <groupId>org.collectionspace.services</groupId>
+        <artifactId>org.collectionspace.services.3rdparty.nuxeo.listener</artifactId>
+        <version>${revision}</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.collectionspace.services.3rdparty.nuxeo.listener.tenants</artifactId>
+    <packaging>pom</packaging>
+    <name>services.3rdparty.nuxeo.listener.tenants</name>
+
+    <modules>
+        <module>botgarden</module>
+    </modules>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.nuxeo.ecm.core</groupId>
+            <artifactId>nuxeo-core-storage-sql</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.nuxeo.ecm.platform</groupId>
+            <artifactId>nuxeo-platform-filemanager-api</artifactId>
+            <version>${nuxeo.platform.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.nuxeo.ecm.platform</groupId>
+            <artifactId>nuxeo-platform-imaging-api</artifactId>
+            <version>${nuxeo.platform.version}</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+</project>
index 3fceeabe6a25ac3f0a85b22f010558dd5b219880..08ec1076d0d29522669cb7418dcb45abdaacea63 100644 (file)
 
                <!-- Get the configured tenant ID from tenant bindings. This will be in the property tenant:tenantBinding.id. -->
                <xmlproperty keepRoot="false" collapseAttributes="true" file="../../services/common/src/main/cspace/config/services/tenants/${tenant.shortname}/${tenant.shortname}-tenant-bindings.delta.xml" />
+               <echo>Binding file here: ../../services/common/src/main/cspace/config/services/tenants/${tenant.shortname}/${tenant.shortname}-tenant-bindings.delta.xml</echo>
 
                <!-- A tenant ID must either exist tenant bindings, or be specified in the tenant.id property. -->
                <fail message="Tenant ID not found for ${tenant.shortname}. Configure the tenantBinding id in ${tenant.shortname}-tenant-bindings.delta.xml, or set the tenant.id property in ${basedir}/build.properties.">
@@ -1,4 +1,4 @@
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
 
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -7,6 +7,7 @@ import java.util.List;
 
 import javax.ws.rs.core.UriInfo;
 
+import org.collectionspace.services.batch.nuxeo.AbstractBatchJob;
 import org.collectionspace.services.client.MovementClient;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.VocabularyClient;
@@ -1,4 +1,4 @@
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
 
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -7,6 +7,7 @@ import java.util.List;
 
 import javax.ws.rs.core.UriInfo;
 
+import org.collectionspace.services.batch.nuxeo.AbstractBatchJob;
 import org.collectionspace.services.client.PottagClient;
 import org.collectionspace.services.common.NuxeoBasedResource;
 import org.collectionspace.services.common.invocable.InvocationResults;
@@ -68,7 +69,7 @@ public class ClearPotTagLabelRequestBatchJob extends AbstractBatchJob {
                        clearLabelRequest(potTagCsid);
                        numAffected = numAffected + 1;
                }
-               
+
                results.setNumAffected(numAffected);
                results.setUserNote("Removed " + numAffected + " label " + (numAffected == 1 ? "request" : "requests"));
 
@@ -1,4 +1,4 @@
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
 
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -7,6 +7,7 @@ import java.util.List;
 
 import javax.ws.rs.core.UriInfo;
 
+import org.collectionspace.services.batch.nuxeo.AbstractBatchJob;
 import org.collectionspace.services.client.LoanoutClient;
 import org.collectionspace.services.common.NuxeoBasedResource;
 import org.collectionspace.services.common.invocable.InvocationResults;
similarity index 88%
rename from services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateVoucherBatchJob.java
rename to services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/CreateVoucherBatchJob.java
index 30c39a37dda992d74a939c91f7bae4ab4127ac70..1429313b61814a751c86a94e2a7525e9ad76c8e7 100644 (file)
@@ -1,4 +1,4 @@
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
 
 import java.net.URISyntaxException;
 import java.util.Arrays;
@@ -10,12 +10,14 @@ import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Response;
 
 import org.apache.commons.lang.StringUtils;
+import org.collectionspace.services.batch.nuxeo.AbstractBatchJob;
 import org.collectionspace.services.client.CollectionSpaceClientUtils;
 import org.collectionspace.services.client.LoanoutClient;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectBotGardenConstants;
 import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectConstants;
+import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectNaturalHistoryConstants;
 import org.collectionspace.services.common.NuxeoBasedResource;
 import org.collectionspace.services.common.invocable.InvocationResults;
 import org.collectionspace.services.common.relation.nuxeo.RelationConstants;
@@ -80,7 +82,7 @@ public class CreateVoucherBatchJob extends AbstractBatchJob {
                InvocationResults results = new InvocationResults();
 
                PoxPayloadOut collectionObjectPayload = findCollectionObjectByCsid(collectionObjectCsid);
-               String collectionObjectWorkflowState = getFieldValue(collectionObjectPayload, CollectionObjectBotGardenConstants.WORKFLOW_STATE_SCHEMA_NAME, 
+               String collectionObjectWorkflowState = getFieldValue(collectionObjectPayload, CollectionObjectBotGardenConstants.WORKFLOW_STATE_SCHEMA_NAME,
                                CollectionObjectBotGardenConstants.WORKFLOW_STATE_FIELD_NAME);
                
                if (collectionObjectWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED)) {
@@ -134,8 +136,8 @@ public class CreateVoucherBatchJob extends AbstractBatchJob {
                        placeNote = reverseFieldCollectionPlace;
                }
                else {
-                       String taxonomicRange = this.getFieldValue(collectionObjectPayload, CollectionObjectBotGardenConstants.TAXONOMIC_RANGE_SCHEMA_NAME,
-                                       CollectionObjectBotGardenConstants.TAXONOMIC_RANGE_FIELD_NAME);
+                       String taxonomicRange = this.getFieldValue(collectionObjectPayload, CollectionObjectNaturalHistoryConstants.TAXONOMIC_RANGE_SCHEMA_NAME,
+                                       CollectionObjectNaturalHistoryConstants.TAXONOMIC_RANGE_FIELD_NAME);
 
                        if (StringUtils.isNotBlank(taxonomicRange)) {
                                placeNote = "Geographic range " + taxonomicRange;
@@ -161,8 +163,8 @@ public class CreateVoucherBatchJob extends AbstractBatchJob {
        
        private String getReverseFieldCollectionPlace(PoxPayloadOut collectionObjectPayload) throws URISyntaxException, DocumentException, Exception {
                String reverseDisplayName = null;
-               String fieldCollectionPlaceRefName = getFieldValue(collectionObjectPayload, CollectionObjectBotGardenConstants.FIELD_COLLECTION_PLACE_SCHEMA_NAME, 
-                               CollectionObjectBotGardenConstants.FIELD_COLLECTION_PLACE_FIELD_NAME);          
+               String fieldCollectionPlaceRefName = getFieldValue(collectionObjectPayload, CollectionObjectNaturalHistoryConstants.FIELD_COLLECTION_PLACE_SCHEMA_NAME,
+                               CollectionObjectNaturalHistoryConstants.FIELD_COLLECTION_PLACE_FIELD_NAME);
 
                if (StringUtils.isNotBlank(fieldCollectionPlaceRefName)) {                      
                        PoxPayloadOut placePayload = null;
@@ -202,20 +204,20 @@ public class CreateVoucherBatchJob extends AbstractBatchJob {
        
        private String getAnnotation(PoxPayloadOut collectionObjectPayload) {
                String annotation = "";
-               String determinationKind = getFieldValue(collectionObjectPayload, CollectionObjectBotGardenConstants.DETERMINATION_KIND_SCHEMA_NAME, 
-                               CollectionObjectBotGardenConstants.DETERMINATION_KIND_FIELD_NAME);
+               String determinationKind = getFieldValue(collectionObjectPayload, CollectionObjectNaturalHistoryConstants.DETERMINATION_KIND_SCHEMA_NAME,
+                               CollectionObjectNaturalHistoryConstants.DETERMINATION_KIND_FIELD_NAME);
 
-               if (determinationKind.equals(CollectionObjectBotGardenConstants.DETERMINATION_KIND_DETERMINATION_VALUE)) {
-                       String determinationBy = getDisplayNameFromRefName(getFieldValue(collectionObjectPayload, CollectionObjectBotGardenConstants.DETERMINATION_BY_SCHEMA_NAME, 
-                                       CollectionObjectBotGardenConstants.DETERMINATION_BY_FIELD_NAME));
+               if (determinationKind.equals(CollectionObjectNaturalHistoryConstants.DETERMINATION_KIND_DETERMINATION_VALUE)) {
+                       String determinationBy = getDisplayNameFromRefName(getFieldValue(collectionObjectPayload, CollectionObjectNaturalHistoryConstants.DETERMINATION_BY_SCHEMA_NAME,
+                                       CollectionObjectNaturalHistoryConstants.DETERMINATION_BY_FIELD_NAME));
                        
                        if (StringUtils.isNotBlank(determinationBy)) {
                                annotation += "det. by " + determinationBy;
 
-                               String determinationInstitution = getDisplayNameFromRefName(getFieldValue(collectionObjectPayload, CollectionObjectBotGardenConstants.DETERMINATION_INSTITUTION_SCHEMA_NAME, 
-                                               CollectionObjectBotGardenConstants.DETERMINATION_INSTITUTION_FIELD_NAME));
-                               String determinationDate = getFieldValue(collectionObjectPayload, CollectionObjectBotGardenConstants.DETERMINATION_DATE_SCHEMA_NAME, 
-                                               CollectionObjectBotGardenConstants.DETERMINATION_DATE_FIELD_NAME);
+                               String determinationInstitution = getDisplayNameFromRefName(getFieldValue(collectionObjectPayload, CollectionObjectNaturalHistoryConstants.DETERMINATION_INSTITUTION_SCHEMA_NAME,
+                                               CollectionObjectNaturalHistoryConstants.DETERMINATION_INSTITUTION_FIELD_NAME));
+                               String determinationDate = getFieldValue(collectionObjectPayload, CollectionObjectNaturalHistoryConstants.DETERMINATION_DATE_SCHEMA_NAME,
+                                               CollectionObjectNaturalHistoryConstants.DETERMINATION_DATE_FIELD_NAME);
 
                                if (StringUtils.isNotBlank(determinationInstitution)) {
                                        annotation += ", " + determinationInstitution;
@@ -1,4 +1,4 @@
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
 
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -8,11 +8,12 @@ import java.util.List;
 import javax.ws.rs.core.UriInfo;
 
 import org.apache.commons.lang.StringUtils;
+import org.collectionspace.services.batch.nuxeo.AbstractBatchJob;
 import org.collectionspace.services.client.LoanoutClient;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.workflow.WorkflowClient;
-import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectBotGardenConstants;
 import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectConstants;
+import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectNaturalHistoryConstants;
 import org.collectionspace.services.common.NuxeoBasedResource;
 import org.collectionspace.services.common.api.TaxonFormatter;
 import org.collectionspace.services.common.invocable.InvocationResults;
@@ -135,19 +136,19 @@ public class FormatVoucherNameBatchJob extends AbstractBatchJob {
                if (collectionObjectPayload != null) {
                        name = new VoucherName();
                        
-                       name.setName(getDisplayNameFromRefName(getFieldValue(collectionObjectPayload, CollectionObjectBotGardenConstants.TAXON_SCHEMA_NAME,
-                                       CollectionObjectBotGardenConstants.TAXON_FIELD_NAME)));
-                       name.setHybrid(getBooleanFieldValue(collectionObjectPayload, CollectionObjectBotGardenConstants.HYBRID_FLAG_SCHEMA_NAME, 
-                                       CollectionObjectBotGardenConstants.HYBRID_FLAG_FIELD_NAME));
+                       name.setName(getDisplayNameFromRefName(getFieldValue(collectionObjectPayload, CollectionObjectNaturalHistoryConstants.TAXON_SCHEMA_NAME,
+                                       CollectionObjectNaturalHistoryConstants.TAXON_FIELD_NAME)));
+                       name.setHybrid(getBooleanFieldValue(collectionObjectPayload, CollectionObjectNaturalHistoryConstants.HYBRID_FLAG_SCHEMA_NAME,
+                                       CollectionObjectNaturalHistoryConstants.HYBRID_FLAG_FIELD_NAME));
 
                        if (name.isHybrid()) {
-                               List<String> hybridParents = this.getFieldValues(collectionObjectPayload, CollectionObjectBotGardenConstants.HYBRID_PARENT_SCHEMA_NAME, 
-                                               CollectionObjectBotGardenConstants.HYBRID_PARENT_FIELD_NAME);
-                               List<String> hybridQualifiers = this.getFieldValues(collectionObjectPayload, CollectionObjectBotGardenConstants.HYBRID_QUALIFIER_SCHEMA_NAME, 
-                                               CollectionObjectBotGardenConstants.HYBRID_QUALIFIER_FIELD_NAME);
+                               List<String> hybridParents = this.getFieldValues(collectionObjectPayload, CollectionObjectNaturalHistoryConstants.HYBRID_PARENT_SCHEMA_NAME,
+                                               CollectionObjectNaturalHistoryConstants.HYBRID_PARENT_FIELD_NAME);
+                               List<String> hybridQualifiers = this.getFieldValues(collectionObjectPayload, CollectionObjectNaturalHistoryConstants.HYBRID_QUALIFIER_SCHEMA_NAME,
+                                               CollectionObjectNaturalHistoryConstants.HYBRID_QUALIFIER_FIELD_NAME);
 
-                               int femaleIndex = hybridQualifiers.indexOf(CollectionObjectBotGardenConstants.HYBRID_QUALIFIER_FEMALE_VALUE);
-                               int maleIndex = hybridQualifiers.indexOf(CollectionObjectBotGardenConstants.HYBRID_QUALIFIER_MALE_VALUE);
+                               int femaleIndex = hybridQualifiers.indexOf(CollectionObjectNaturalHistoryConstants.HYBRID_QUALIFIER_FEMALE_VALUE);
+                               int maleIndex = hybridQualifiers.indexOf(CollectionObjectNaturalHistoryConstants.HYBRID_QUALIFIER_MALE_VALUE);
                                
                                if (femaleIndex >= 0) {
                                        name.setFemaleParentName(getDisplayNameFromRefName(hybridParents.get(femaleIndex)));
@@ -1,19 +1,21 @@
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
 
 import java.net.URISyntaxException;
 import java.util.Arrays;
 import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
+import org.collectionspace.services.batch.nuxeo.AbstractBatchJob;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.TaxonomyAuthorityClient;
 import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectBotGardenConstants;
 import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectConstants;
+import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectNaturalHistoryConstants;
 import org.collectionspace.services.common.api.RefName;
 import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.common.invocable.InvocationResults;
 import org.collectionspace.services.common.vocabulary.AuthorityResource;
-import org.collectionspace.services.taxonomy.nuxeo.TaxonBotGardenConstants;
+import org.collectionspace.services.taxonomy.nuxeo.TaxonNaturalHistoryConstants;
 import org.collectionspace.services.taxonomy.nuxeo.TaxonConstants;
 import org.dom4j.DocumentException;
 import org.slf4j.Logger;
@@ -35,7 +37,7 @@ import org.slf4j.LoggerFactory;
 public class UpdateAccessCodeBatchJob extends AbstractBatchJob {
        final Logger logger = LoggerFactory.getLogger(UpdateAccessCodeBatchJob.class);
 
-       private final String[] TAXON_FIELD_NAME_PARTS = CollectionObjectBotGardenConstants.TAXON_FIELD_NAME.split("\\/");
+       private final String[] TAXON_FIELD_NAME_PARTS = CollectionObjectNaturalHistoryConstants.TAXON_FIELD_NAME.split("\\/");
        private final String TAXON_FIELD_NAME_WITHOUT_PATH = TAXON_FIELD_NAME_PARTS[TAXON_FIELD_NAME_PARTS.length - 1];
 
        public UpdateAccessCodeBatchJob() {
@@ -124,7 +126,7 @@ public class UpdateAccessCodeBatchJob extends AbstractBatchJob {
        public InvocationResults updateParentAccessCode(String taxonCsid, boolean propagate) throws URISyntaxException, DocumentException, Exception {
                PoxPayloadOut taxonPayload = findTaxonByCsid(taxonCsid);
                String taxonRefName = getFieldValue(taxonPayload, TaxonConstants.REFNAME_SCHEMA_NAME, TaxonConstants.REFNAME_FIELD_NAME);
-               String accessCode = getFieldValue(taxonPayload, TaxonBotGardenConstants.ACCESS_CODE_SCHEMA_NAME, TaxonBotGardenConstants.ACCESS_CODE_FIELD_NAME);
+               String accessCode = getFieldValue(taxonPayload, TaxonNaturalHistoryConstants.ACCESS_CODE_SCHEMA_NAME, TaxonNaturalHistoryConstants.ACCESS_CODE_FIELD_NAME);
 
                logger.debug("updating parent access code: taxonRefName=" + taxonRefName + " propagate=" + propagate + " accessCode=" + accessCode);
 
@@ -162,8 +164,8 @@ public class UpdateAccessCodeBatchJob extends AbstractBatchJob {
 
                logger.debug("updating referenced access codes: collectionObjectCsid=" + collectionObjectCsid + " propagate=" + propagate + " isAlive=" + isAlive);
 
-               List<String> taxonRefNames = getFieldValues(collectionObjectPayload, CollectionObjectBotGardenConstants.TAXON_SCHEMA_NAME,
-                               CollectionObjectBotGardenConstants.TAXON_FIELD_NAME);
+               List<String> taxonRefNames = getFieldValues(collectionObjectPayload, CollectionObjectNaturalHistoryConstants.TAXON_SCHEMA_NAME,
+                               CollectionObjectNaturalHistoryConstants.TAXON_FIELD_NAME);
                long numAffected = 0;
 
                for (String taxonRefName : taxonRefNames) {
@@ -232,7 +234,7 @@ public class UpdateAccessCodeBatchJob extends AbstractBatchJob {
 
                String taxonCsid = getCsid(taxonPayload);
                String taxonRefName = getFieldValue(taxonPayload, TaxonConstants.REFNAME_SCHEMA_NAME, TaxonConstants.REFNAME_FIELD_NAME);
-               String accessCode = getFieldValue(taxonPayload, TaxonBotGardenConstants.ACCESS_CODE_SCHEMA_NAME, TaxonBotGardenConstants.ACCESS_CODE_FIELD_NAME);
+               String accessCode = getFieldValue(taxonPayload, TaxonNaturalHistoryConstants.ACCESS_CODE_SCHEMA_NAME, TaxonNaturalHistoryConstants.ACCESS_CODE_FIELD_NAME);
 
                logger.debug("updating access code: taxonRefName=" + taxonRefName + " deep=" + deep + " knownAlive=" + knownAlive);
 
@@ -252,7 +254,7 @@ public class UpdateAccessCodeBatchJob extends AbstractBatchJob {
 
                                if (!childResults.isSoftDeleted()) {
                                        String childAccessCode = childResults.getAccessCode();
-                                       boolean isChildAlive = !childAccessCode.equals(TaxonBotGardenConstants.ACCESS_CODE_DEAD_VALUE);
+                                       boolean isChildAlive = !childAccessCode.equals(TaxonNaturalHistoryConstants.ACCESS_CODE_DEAD_VALUE);
 
                                        if (isChildAlive) {
                                                foundAlive = true;
@@ -273,9 +275,9 @@ public class UpdateAccessCodeBatchJob extends AbstractBatchJob {
                                for (String childTaxonCsid : childTaxonCsids) {
                                        PoxPayloadOut childTaxonPayload = findTaxonByCsid(childTaxonCsid);
 
-                                       String childAccessCode = getFieldValue(childTaxonPayload, TaxonBotGardenConstants.ACCESS_CODE_SCHEMA_NAME,
-                                                       TaxonBotGardenConstants.ACCESS_CODE_FIELD_NAME);
-                                       boolean isChildAlive = !childAccessCode.equals(TaxonBotGardenConstants.ACCESS_CODE_DEAD_VALUE);
+                                       String childAccessCode = getFieldValue(childTaxonPayload, TaxonNaturalHistoryConstants.ACCESS_CODE_SCHEMA_NAME,
+                                                       TaxonNaturalHistoryConstants.ACCESS_CODE_FIELD_NAME);
+                                       boolean isChildAlive = !childAccessCode.equals(TaxonNaturalHistoryConstants.ACCESS_CODE_DEAD_VALUE);
 
                                        if (isChildAlive) {
                                                foundAlive = true;
@@ -292,7 +294,7 @@ public class UpdateAccessCodeBatchJob extends AbstractBatchJob {
                        String vocabularyShortId = item.getParentShortIdentifier();
 
                        List<String> collectionObjectCsids = findReferencingCollectionObjects(TaxonomyAuthorityClient.SERVICE_NAME, vocabularyShortId, taxonCsid,
-                                       CollectionObjectBotGardenConstants.TAXON_SCHEMA_NAME + ":" + TAXON_FIELD_NAME_WITHOUT_PATH);
+                                       CollectionObjectNaturalHistoryConstants.TAXON_SCHEMA_NAME + ":" + TAXON_FIELD_NAME_WITHOUT_PATH);
 
                        for (String collectionObjectCsid : collectionObjectCsids) {
                                PoxPayloadOut collectionObjectPayload = findCollectionObjectByCsid(collectionObjectCsid);
@@ -319,11 +321,11 @@ public class UpdateAccessCodeBatchJob extends AbstractBatchJob {
                // living example, and the access code is not dead, the current value of unrestricted
                // or restricted should be retained.
 
-               if (foundAlive && (StringUtils.isEmpty(accessCode) || accessCode.equals(TaxonBotGardenConstants.ACCESS_CODE_DEAD_VALUE))) {
-                       newAccessCode = TaxonBotGardenConstants.ACCESS_CODE_UNRESTRICTED_VALUE;
+               if (foundAlive && (StringUtils.isEmpty(accessCode) || accessCode.equals(TaxonNaturalHistoryConstants.ACCESS_CODE_DEAD_VALUE))) {
+                       newAccessCode = TaxonNaturalHistoryConstants.ACCESS_CODE_UNRESTRICTED_VALUE;
                }
                else if (!foundAlive) {
-                       newAccessCode = TaxonBotGardenConstants.ACCESS_CODE_DEAD_VALUE;
+                       newAccessCode = TaxonNaturalHistoryConstants.ACCESS_CODE_DEAD_VALUE;
                }
                else {
                        newAccessCode = accessCode;
@@ -379,13 +381,13 @@ public class UpdateAccessCodeBatchJob extends AbstractBatchJob {
         */
        public UpdateAccessCodeResults updateAccessCode(String taxonRefNameOrCsid, boolean deep, String newChildTaxonCsid) throws URISyntaxException, DocumentException, Exception {
                PoxPayloadOut newChildTaxonPayload = findTaxonByCsid(newChildTaxonCsid);
-               String newChildTaxonAccessCode = getFieldValue(newChildTaxonPayload, TaxonBotGardenConstants.ACCESS_CODE_SCHEMA_NAME, TaxonBotGardenConstants.ACCESS_CODE_FIELD_NAME);
+               String newChildTaxonAccessCode = getFieldValue(newChildTaxonPayload, TaxonNaturalHistoryConstants.ACCESS_CODE_SCHEMA_NAME, TaxonNaturalHistoryConstants.ACCESS_CODE_FIELD_NAME);
 
                if (newChildTaxonAccessCode == null) {
                        newChildTaxonAccessCode = "";
                }
 
-               boolean knownAlive = !newChildTaxonAccessCode.equals(TaxonBotGardenConstants.ACCESS_CODE_DEAD_VALUE);
+               boolean knownAlive = !newChildTaxonAccessCode.equals(TaxonNaturalHistoryConstants.ACCESS_CODE_DEAD_VALUE);
 
                return updateAccessCode(taxonRefNameOrCsid, deep, knownAlive);
        }
@@ -414,7 +416,7 @@ public class UpdateAccessCodeBatchJob extends AbstractBatchJob {
                logger.debug("updating parent access code: taxonCsid=" + taxonCsid + " accessCode=" + accessCode + " propagate=" + propagate);
 
                if (parentTaxonCsid != null) {
-                       boolean isAlive = (accessCode == null) || !accessCode.equals(TaxonBotGardenConstants.ACCESS_CODE_DEAD_VALUE);
+                       boolean isAlive = (accessCode == null) || !accessCode.equals(TaxonNaturalHistoryConstants.ACCESS_CODE_DEAD_VALUE);
 
                        UpdateAccessCodeResults parentUpdateResults = updateAccessCode(parentTaxonCsid, false, isAlive);
 
@@ -453,7 +455,7 @@ public class UpdateAccessCodeBatchJob extends AbstractBatchJob {
                                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                                "<document name=\"taxon\">" +
                                        "<ns2:taxon_naturalhistory xmlns:ns2=\"http://collectionspace.org/services/taxonomy/domain/naturalhistory\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
-                                               getFieldXml(TaxonBotGardenConstants.ACCESS_CODE_FIELD_NAME, accessCode) +
+                                               getFieldXml(TaxonNaturalHistoryConstants.ACCESS_CODE_FIELD_NAME, accessCode) +
                                        "</ns2:taxon_naturalhistory>" +
                                "</document>";
 
similarity index 92%
rename from services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateDeadFlagBatchJob.java
rename to services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/UpdateDeadFlagBatchJob.java
index 34c8e434d7f3e8a893c4e21a4a6524e69d08578c..3e1615d54f7623bed45001750dc2cdbf081dffdc 100644 (file)
@@ -1,4 +1,4 @@
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
 
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -6,12 +6,14 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
+import org.collectionspace.services.batch.nuxeo.AbstractBatchJob;
 import org.collectionspace.services.client.CollectionObjectClient;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectBotGardenConstants;
 import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectConstants;
 import org.collectionspace.services.common.NuxeoBasedResource;
+import org.collectionspace.services.common.api.RefNameUtils;
 import org.collectionspace.services.common.invocable.InvocationResults;
 import org.collectionspace.services.movement.nuxeo.MovementBotGardenConstants;
 import org.collectionspace.services.movement.nuxeo.MovementConstants;
@@ -71,7 +73,8 @@ public class UpdateDeadFlagBatchJob extends AbstractBatchJob {
                String actionCode = getFieldValue(payload, MovementBotGardenConstants.ACTION_CODE_SCHEMA_NAME, MovementBotGardenConstants.ACTION_CODE_FIELD_NAME);
                logger.debug("actionCode=" + actionCode);
                
-               if (actionCode.equals(MovementBotGardenConstants.DEAD_ACTION_CODE) || actionCode.equals(MovementBotGardenConstants.REVIVED_ACTION_CODE)) {
+               if (RefNameUtils.doShortIDsMatch(actionCode, MovementBotGardenConstants.DEAD_ACTION_CODE) ||
+                               RefNameUtils.doShortIDsMatch(actionCode, MovementBotGardenConstants.REVIVED_ACTION_CODE)) {
                        String actionDate = getFieldValue(payload, MovementBotGardenConstants.ACTION_DATE_SCHEMA_NAME, 
                                        MovementBotGardenConstants.ACTION_DATE_FIELD_NAME);
                        logger.debug("actionDate=" + actionDate);
@@ -117,7 +120,8 @@ public class UpdateDeadFlagBatchJob extends AbstractBatchJob {
                                MovementBotGardenConstants.ACTION_CODE_FIELD_NAME);
                logger.debug("actionCode=" + actionCode);
                
-               if (actionCode.equals(MovementBotGardenConstants.DEAD_ACTION_CODE) || actionCode.equals(MovementBotGardenConstants.REVIVED_ACTION_CODE)) {
+               if (RefNameUtils.doShortIDsMatch(actionCode, MovementBotGardenConstants.DEAD_ACTION_CODE) ||
+                               RefNameUtils.doShortIDsMatch(actionCode, MovementBotGardenConstants.REVIVED_ACTION_CODE)) {
                        String actionDate = getFieldValue(payload, MovementBotGardenConstants.ACTION_DATE_SCHEMA_NAME, 
                                        MovementBotGardenConstants.ACTION_DATE_FIELD_NAME);
                        logger.debug("actionDate=" + actionDate);
@@ -157,7 +161,7 @@ public class UpdateDeadFlagBatchJob extends AbstractBatchJob {
 
                        logger.debug("updating dead flag: collectionObjectCsid=" + collectionObjectCsid + " actionCode=" + actionCode + " isDead=" + isDead);
 
-                       if (actionCode.equals(MovementBotGardenConstants.REVIVED_ACTION_CODE)) {
+                       if (RefNameUtils.doShortIDsMatch(actionCode, MovementBotGardenConstants.REVIVED_ACTION_CODE)) {
                                if (isDead) {
                                        /*
                                         * The object is dead, but a location was revived. Unset the dead flag and date on the object.
@@ -168,7 +172,7 @@ public class UpdateDeadFlagBatchJob extends AbstractBatchJob {
                                        results.setUserNote(collectionObjectCsid + " set to alive");
                                }
                        }
-                       else if (actionCode.equals(MovementBotGardenConstants.DEAD_ACTION_CODE)) {
+                       else if (RefNameUtils.doShortIDsMatch(actionCode, MovementBotGardenConstants.DEAD_ACTION_CODE)) {
                                if (!isDead) {
                                        /*
                                         * The object is not dead, but a location was marked dead. If there are no remaining live locations,
diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/UpdateHybridNameBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/UpdateHybridNameBatchJob.java
new file mode 100644 (file)
index 0000000..f226f44
--- /dev/null
@@ -0,0 +1,187 @@
+package org.collectionspace.services.batch.nuxeo.botgarden;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Iterator;
+
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.collectionspace.services.batch.nuxeo.AbstractBatchJob;
+import org.collectionspace.services.client.CollectionObjectClient;
+import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.api.RefNameUtils;
+import org.collectionspace.services.common.invocable.InvocationResults;
+import org.collectionspace.services.common.NuxeoBasedResource;
+import org.collectionspace.services.common.ResourceMap;
+import org.collectionspace.services.taxonomy.nuxeo.TaxonConstants;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class UpdateHybridNameBatchJob extends AbstractBatchJob {
+    final Logger logger = LoggerFactory.getLogger(UpdateHybridNameBatchJob.class);
+
+    public UpdateHybridNameBatchJob() {
+        setSupportedInvocationModes(Collections.singletonList(INVOCATION_MODE_LIST));
+    }
+
+    @Override
+    public void run() {
+        setCompletionStatus(0);
+
+        try {
+            String mode = getInvocationContext().getMode();
+
+            if (mode.equalsIgnoreCase(INVOCATION_MODE_LIST)) {
+                List<String> csids = getInvocationContext().getListCSIDs().getCsid();
+                setResults(updateHybridNames(csids));
+            } else {
+                throw new Exception("Unsupported invocation mode: " + mode);
+            }
+
+        } catch (Exception e) {
+            setCompletionStatus(STATUS_ERROR);
+            setErrorInfo(new InvocationError(INT_ERROR_STATUS, e.getMessage()));
+        }
+    }
+
+    private InvocationResults updateHybridNames(List<String> csids) throws Exception {
+        InvocationResults results = new InvocationResults();
+        int numAffected = 0;
+
+        for (String csid : csids) {
+            updateRecord(csid);
+
+            numAffected += 1;
+        }
+
+        results.setNumAffected(numAffected);
+        return results;
+    }
+
+    private void updateRecord(String csid) throws Exception {
+        PoxPayloadOut currentRecord = findCollectionObjectByCsid(csid);
+
+        // Get the GroupList element
+        Element naturalHistoryElement = currentRecord.getPart("collectionobjects_naturalhistory").asElement();
+        Element taxonIdentGroupList = null;
+        Iterator<Element> childIterator = naturalHistoryElement.elementIterator();
+
+        // so now we have  our termGroupList element
+        while (childIterator.hasNext()) {
+            Element candidateElement = childIterator.next();
+
+            // note: the candidateElement at some point is the "hybridParentGroupList"
+            if (candidateElement.getName().contains("taxonomicIdentGroupList")) {
+                taxonIdentGroupList = candidateElement;
+            }
+        }
+
+        if (taxonIdentGroupList == null) {
+            throw new Exception("No lists to update on record with csid " + csid);
+        }
+
+        ArrayList<Element> updatedTermGroups = new ArrayList<Element>();
+        childIterator = taxonIdentGroupList.elementIterator();
+
+        // now to iterate through each term group, and key and prepare the payload, put it in a list
+        while (childIterator.hasNext()) {
+            Element termGroupElement = childIterator.next();
+            updateElement(termGroupElement);
+        }
+        String payload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+                            "<document name=\"collectionobjects\">" +
+                                "<ns2:collectionobjects_naturalhistory xmlns:ns2=\"http://collectionspace.org/services/collectionobject/domain/naturalhistory\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
+                                    taxonIdentGroupList.asXML() +
+                                "</ns2:collectionobjects_naturalhistory>" +
+                            "</document>";
+
+        ResourceMap resource = getResourceMap();
+        NuxeoBasedResource collectionObjectResource = (NuxeoBasedResource) resource.get(CollectionObjectClient.SERVICE_NAME);
+        byte[] responseBytes = collectionObjectResource.update(getServiceContext(), resource, createUriInfo(), csid, payload);
+
+        logger.debug("Batch resource: Response from CollectionObject (cataloging record) update: {}",
+                     new String(responseBytes));
+    }
+
+    public void updateElement(Element termGroupElement) {
+        String taxonomicIdentHybridName = "";
+
+        Node hybridFlagNode = termGroupElement.selectSingleNode(TaxonConstants.HYBRID_FLAG);
+        String affinityTaxon = termGroupElement.selectSingleNode(TaxonConstants.AFF_TAXON).getText();
+        affinityTaxon = affinityTaxon.isEmpty() ? "" : RefNameUtils.getDisplayName(affinityTaxon);
+
+        String taxon = termGroupElement.selectSingleNode(TaxonConstants.TAXON_NAME).getText();
+        taxon = taxon.isEmpty() ? "" : RefNameUtils.getDisplayName(taxon);
+
+
+        if (!hybridFlagNode.getText().equals("true")) {
+            if (affinityTaxon == null) {
+                taxonomicIdentHybridName = taxon;
+            } if (affinityTaxon != null) {
+                taxonomicIdentHybridName = affinityTaxon;
+            }
+        } else {
+            Iterator<Element> hybridParentGroupListIterator = termGroupElement.elementIterator();
+            Element hybridParentGroupList = null;
+
+            // get the hybrid parent group list
+            while (hybridParentGroupListIterator.hasNext()) {
+                Element candidateElement = hybridParentGroupListIterator.next();
+
+                if (candidateElement.getName().contains(TaxonConstants.TAXON_HYBRID_PARENT_GROUP_LIST)) {
+                    hybridParentGroupList = candidateElement;
+                }
+            }
+
+            List<Node> hybridParentGroup = hybridParentGroupList.selectNodes(TaxonConstants.TAXON_HYBRID_PARENT_GROUP);
+
+            if (hybridParentGroup.size() != 2) {
+                return;
+            }
+
+            Node firstParentNode = hybridParentGroup.get(0);
+            Node secondParentNode =hybridParentGroup.get(1);
+
+            String firstParentSex = firstParentNode.selectSingleNode(TaxonConstants.TAXON_HYBRID_PARENT_QUALIF).getText();
+
+            Node maleParentNode = firstParentSex.equals("male") ? firstParentNode : secondParentNode;
+            Node femaleParentNode = firstParentSex.equals("female") ? firstParentNode : secondParentNode;
+
+
+            String maleParentName = RefNameUtils.getDisplayName(maleParentNode.selectSingleNode(TaxonConstants.TAXON_HYBRID_PARENT).getText());
+            String femaleParentName = RefNameUtils.getDisplayName(femaleParentNode.selectSingleNode(TaxonConstants.TAXON_HYBRID_PARENT).getText());
+
+            int maleParentGenusIndex = maleParentName.indexOf(' ');
+
+            String maleParentGenus = maleParentGenusIndex != -1 ? maleParentName.substring(0, maleParentGenusIndex) : maleParentName;
+            String femaleParentGenus = femaleParentName.indexOf(' ') != -1 ? femaleParentName.substring(0, femaleParentName.indexOf(' ')) : femaleParentName;
+
+            String maleParentRest = maleParentGenusIndex != -1 ? maleParentName.substring(maleParentGenusIndex + 1) : maleParentName;
+
+            if (affinityTaxon == null || affinityTaxon.isEmpty()) {
+                if (femaleParentName.isEmpty()) {
+                    taxonomicIdentHybridName = "";
+                } else if (maleParentName.isEmpty()) {
+                    taxonomicIdentHybridName = "";
+                } else if (femaleParentGenus.equals(maleParentGenus)) {
+                    taxonomicIdentHybridName = femaleParentName + " Ã— " + maleParentGenus.charAt(0) + ". " + maleParentRest;
+                } else {
+                    taxonomicIdentHybridName = femaleParentName + " Ã— " + maleParentName;
+                }
+            } else {
+                if (maleParentName.isEmpty()) {
+                    taxonomicIdentHybridName = "";
+                } else if (femaleParentGenus.equals(maleParentGenus)) {
+                    taxonomicIdentHybridName = affinityTaxon + " Ã— " + maleParentGenus.charAt(0) + ". " + maleParentRest;
+                } else {
+                    taxonomicIdentHybridName = affinityTaxon + " Ã— " + maleParentName;
+                }
+            }
+        }
+
+        Node hybridNameNode = termGroupElement.selectSingleNode(TaxonConstants.TAXON_HYBRID_NAME);
+        hybridNameNode.setText(taxonomicIdentHybridName) ;
+    }
+}
\ No newline at end of file
diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/UpdateObjectFieldsBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/UpdateObjectFieldsBatchJob.java
new file mode 100644 (file)
index 0000000..9c7f7b3
--- /dev/null
@@ -0,0 +1,136 @@
+package org.collectionspace.services.batch.nuxeo.botgarden;
+
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.HashMap;
+import java.util.ArrayList;
+
+import org.collectionspace.services.batch.nuxeo.AbstractBatchJob;
+import org.collectionspace.services.client.CollectionObjectClient;
+import org.collectionspace.services.common.NuxeoBasedResource;
+import org.collectionspace.services.common.invocable.InvocationContext;
+import org.collectionspace.services.common.invocable.InvocationResults;
+import org.collectionspace.services.common.invocable.InvocationContext.Params.Param;
+import org.collectionspace.services.common.ResourceMap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This batch job updates certain fields in collectionobject records, specified as invocation
+ * parameters. Supported fields include: sex in collectionobjects_common, and any top-level
+ * (non-repeating) field in collectionobjects_botgarden.
+ *
+ * It can be invoked in either list or single mode.
+ * @author Cesar Villalobos
+ *
+ */
+public class UpdateObjectFieldsBatchJob extends AbstractBatchJob {
+    final Logger logger = LoggerFactory.getLogger(UpdateObjectFieldsBatchJob.class);
+
+    public UpdateObjectFieldsBatchJob() {
+        this.setSupportedInvocationModes(Arrays.asList(INVOCATION_MODE_SINGLE, INVOCATION_MODE_LIST));
+    }
+
+    @Override
+    public void run() {
+        setCompletionStatus(STATUS_MIN_PROGRESS);
+
+        try {
+            InvocationContext ctx = getInvocationContext();
+            String mode = ctx.getMode();
+
+            ArrayList<String> csids = new ArrayList<String>();
+
+            if (mode.equalsIgnoreCase(INVOCATION_MODE_SINGLE)) {
+                String csid = ctx.getSingleCSID();
+                csids.add(csid);
+            } else if (mode.equalsIgnoreCase(INVOCATION_MODE_LIST)) {
+                csids.addAll(ctx.getListCSIDs().getCsid());
+            } else {
+                throw new Exception("Unsupported invocation mode: " + mode);
+            }
+
+            HashMap<String, String> fieldsToValues = this.getValues();
+
+            if (fieldsToValues.isEmpty()) {
+                throw new Exception("There is nothing to update. Aborting...");
+            }
+
+            setResults(updateRecords(csids, fieldsToValues));
+            setCompletionStatus(STATUS_COMPLETE);
+        } catch (Exception e) {
+            setCompletionStatus(STATUS_ERROR);
+            setErrorInfo(new InvocationError(INT_ERROR_STATUS, e.getMessage()));
+        }
+    }
+
+    public InvocationResults updateRecords(List<String> csids, HashMap<String, String> values) {
+        InvocationResults results = new InvocationResults();
+        int numAffected = 0;
+
+        try {
+            for (String csid : csids) {
+                updateRecord(csid, values);
+                numAffected += 1;
+            }
+        } catch (Exception e) {
+            setErrorInfo(new InvocationError(INT_ERROR_STATUS, e.getMessage()));
+        }
+
+        String userNote = "";
+
+        results.setNumAffected(numAffected);
+        results.setUserNote(userNote);
+
+        return results;
+    }
+
+    public void updateRecord(String csid, HashMap<String, String> values) throws URISyntaxException {
+        StringBuilder valuesToUpdate = new StringBuilder();
+        String sex = "";
+
+        for (String key : values.keySet()) {
+            if (key.equals("sex")) {
+                sex = getFieldXml(key, values.get(key));
+            } else {
+                valuesToUpdate.append(getFieldXml(key, values.get(key)));
+            }
+        }
+
+        String payload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+                         "<document name=\"collectionobjects\">" +
+                         "<ns2:collectionobjects_common " +
+                         "xmlns:ns2=\"http://collectionspace.org/services/collectionobject\" " +
+                         "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"  +
+                         sex + "</ns2:collectionobjects_common>" +
+                         "<ns2:collectionobjects_botgarden " +
+                         "xmlns:ns2=\"http://collectionspace.org/services/collectionobject/local/botgarden\" " +
+                         "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
+                         valuesToUpdate +
+                         "</ns2:collectionobjects_botgarden>" +
+                         "</document>";
+
+
+        ResourceMap resource = getResourceMap();
+        NuxeoBasedResource collectionObjectResource = (NuxeoBasedResource) resource.get(CollectionObjectClient.SERVICE_NAME);
+        byte[] responseBytes = collectionObjectResource.update(getServiceContext(), resource, createUriInfo(), csid, payload);
+
+        logger.debug("Batch resource: Response from CollectionObject (cataloging record) update: {}",
+                     new String(responseBytes));
+    }
+
+    public HashMap<String, String> getValues() {
+        HashMap<String, String> results = new  HashMap<String, String>();
+        for (Param param : this.getParams()) {
+            if (param.getKey() != null) {
+                String value = param.getValue();
+                if (value != null && !value.isEmpty()) {
+                    results.put(param.getKey(), param.getValue());
+                }
+            }
+        }
+        return results;
+    }
+}
similarity index 92%
rename from services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateRareFlagBatchJob.java
rename to services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/botgarden/UpdateRareFlagBatchJob.java
index c91f32f11c4e6198ba8288c9e531ac7468297d38..0fb530678745474d4445bdd09cf83c8393754307 100644 (file)
@@ -1,4 +1,4 @@
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
 
 import java.net.URISyntaxException;
 import java.util.Arrays;
@@ -8,18 +8,21 @@ import java.util.List;
 import javax.ws.rs.WebApplicationException;
 
 import org.apache.commons.lang.StringUtils;
+import org.collectionspace.services.batch.nuxeo.AbstractBatchJob;
 import org.collectionspace.services.client.CollectionObjectClient;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.TaxonomyAuthorityClient;
 import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectBotGardenConstants;
 import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectConstants;
+import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectNaturalHistoryConstants;
 import org.collectionspace.services.common.NuxeoBasedResource;
 import org.collectionspace.services.common.api.RefName;
 import org.collectionspace.services.common.invocable.InvocationContext.ListCSIDs;
 import org.collectionspace.services.common.invocable.InvocationResults;
-import org.collectionspace.services.taxonomy.nuxeo.TaxonBotGardenConstants;
+import org.collectionspace.services.taxonomy.nuxeo.TaxonNaturalHistoryConstants;
 import org.collectionspace.services.taxonomy.nuxeo.TaxonConstants;
+
 import org.dom4j.DocumentException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -30,7 +33,7 @@ public class UpdateRareFlagBatchJob extends AbstractBatchJob {
        // All conservation categories are considered rare, except for ones that start with the following prefixes.
        public static final List<String> NON_RARE_CONSERVATION_CATEGORY_PREFIXES = Arrays.asList("none", "DD ", "LC ", "LR (lc) ");
 
-       private static final String[] TAXON_FIELD_NAME_PARTS = CollectionObjectBotGardenConstants.TAXON_FIELD_NAME.split("\\/");
+       private static final String[] TAXON_FIELD_NAME_PARTS = CollectionObjectNaturalHistoryConstants.TAXON_FIELD_NAME.split("\\/");
        private static final String TAXON_FIELD_NAME_WITHOUT_PATH = TAXON_FIELD_NAME_PARTS[TAXON_FIELD_NAME_PARTS.length - 1];
        
        public UpdateRareFlagBatchJob() {
@@ -120,7 +123,7 @@ public class UpdateRareFlagBatchJob extends AbstractBatchJob {
                String vocabularyShortId = item.getParentShortIdentifier();
 
                List<String> collectionObjectCsids = findReferencingCollectionObjects(TaxonomyAuthorityClient.SERVICE_NAME, vocabularyShortId, taxonCsid, 
-                               CollectionObjectBotGardenConstants.TAXON_SCHEMA_NAME + ":" + TAXON_FIELD_NAME_WITHOUT_PATH);
+                               CollectionObjectNaturalHistoryConstants.TAXON_SCHEMA_NAME + ":" + TAXON_FIELD_NAME_WITHOUT_PATH);
                long numFound = 0;
                long numAffected = 0;
                
@@ -128,8 +131,8 @@ public class UpdateRareFlagBatchJob extends AbstractBatchJob {
                        // Filter out results where the taxon is referenced in the correct field, but isn't the primary value.
                        
                        PoxPayloadOut collectionObjectPayload = findCollectionObjectByCsid(collectionObjectCsid);
-                       String primaryTaxonRefName = getFieldValue(collectionObjectPayload, CollectionObjectBotGardenConstants.TAXON_SCHEMA_NAME, 
-                                       CollectionObjectBotGardenConstants.TAXON_FIELD_NAME);
+                       String primaryTaxonRefName = getFieldValue(collectionObjectPayload, CollectionObjectNaturalHistoryConstants.TAXON_SCHEMA_NAME,
+                                       CollectionObjectNaturalHistoryConstants.TAXON_FIELD_NAME);
                                                
                        if (primaryTaxonRefName.equals(taxonRefName)) { 
                                numFound++;
@@ -190,10 +193,10 @@ public class UpdateRareFlagBatchJob extends AbstractBatchJob {
                        logger.debug("skipping deleted collectionobject: " + collectionObjectCsid);
                }
                else {
-                       String taxonRefName = getFieldValue(collectionObjectPayload, CollectionObjectBotGardenConstants.TAXON_SCHEMA_NAME, 
-                                       CollectionObjectBotGardenConstants.TAXON_FIELD_NAME);
-                       String oldIsRare = getFieldValue(collectionObjectPayload, CollectionObjectBotGardenConstants.RARE_FLAG_SCHEMA_NAME, 
-                                       CollectionObjectBotGardenConstants.RARE_FLAG_FIELD_NAME);
+                       String taxonRefName = getFieldValue(collectionObjectPayload, CollectionObjectNaturalHistoryConstants.TAXON_SCHEMA_NAME,
+                                       CollectionObjectNaturalHistoryConstants.TAXON_FIELD_NAME);
+                       String oldIsRare = getFieldValue(collectionObjectPayload, CollectionObjectNaturalHistoryConstants.RARE_FLAG_SCHEMA_NAME,
+                                       CollectionObjectNaturalHistoryConstants.RARE_FLAG_FIELD_NAME);
                        
                        if (oldIsRare == null) {
                                oldIsRare = "";
@@ -214,8 +217,8 @@ public class UpdateRareFlagBatchJob extends AbstractBatchJob {
                                if (taxonPayload != null) {
                                        // UCBG-369: Changing this so that it only checks the primary conservation category.
                                        
-                                       String conservationCategory = getFieldValue(taxonPayload, TaxonBotGardenConstants.CONSERVATION_CATEGORY_SCHEMA_NAME, 
-                                                       TaxonBotGardenConstants.CONSERVATION_CATEGORY_FIELD_NAME);
+                                       String conservationCategory = getFieldValue(taxonPayload, TaxonNaturalHistoryConstants.CONSERVATION_CATEGORY_SCHEMA_NAME,
+                                                       TaxonNaturalHistoryConstants.CONSERVATION_CATEGORY_FIELD_NAME);
 
                                        if (isRare(conservationCategory)) {
                                                newIsRare = "true";
index 5bd08415a9d5aea8b26a61f19c9ca23c01ebb532..8324310e871de557336c60d4ae52752b6ced571d 100644 (file)
@@ -76,6 +76,7 @@ public interface CollectionSpaceClient<CLT, REQUEST_TYPE, RESPONSE_TYPE, P exten
     public static final String AUTH_PROPERTY = "cspace.auth";
     public static final String TENANT_NAME_PROPERTY = "cspace.tenant";
     public static final String TENANT_ID_PROPERTY = "cspace.tenantID";
+    public static final String TEST_SAS_PROPERTY = "cspace.testSAS";
     
     // JAX-RS path for getting service description meta information
        public static final String SERVICE_DESCRIPTION_PATH = "description";
index 13493d78ea25ee2939ac3e6861d1aec00097106e..559e4ee943a83c9f079c8d6bfcb0f14f53901f56 100644 (file)
@@ -387,14 +387,28 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
      * @throws Exception 
      */
        private void assertSupportsSync() throws Exception {
+               AuthorityClient client = (AuthorityClient) this.getClientInstance();
+
+               //
+               // Test to see if we should run SAS-related tests
+               //
+               String testSASPropertyValue = System.getProperty(CollectionSpaceClient.TEST_SAS_PROPERTY);
+               if (testSASPropertyValue != null) {
+                       boolean shouldTestSAS = Boolean.parseBoolean(testSASPropertyValue);
+                       if (!shouldTestSAS) {
+                               throw new SkipException(String.format("Skipped the test system property '%s' has a value of false.",
+                                               CollectionSpaceClient.TEST_SAS_PROPERTY));
+                       }
+               }
+
        //
        // Test to see if the authority on our locally tenant supports sync
        //
-       AuthorityClient client = (AuthorityClient) this.getClientInstance();
        if (client.supportsSync() == false) {
                throw new SkipException(String.format("Skipped the test since this authority '%s' doesn't support synchronization.",
                                client.getServiceName()));
        }
+
        //
        // Test to see if the test tenancy's authority supports synchronization.
        // 
index ace4a1eb226f6c42b3432f31c05582722f1c970d..426327f3e11a8ec4ce4621840b205b1a6204d33f 100644 (file)
@@ -9,7 +9,6 @@ public class CollectionObjectBotGardenConstants {
     
        public static final String BOTGARDEN_PROFILE_NAME = CollectionSpaceClient.BOTGARDEN_PROFILE_NAME;
     public static final String BOTGARDEN_SCHEMA_NAME = CollectionObjectClient.SERVICE_NAME + CollectionObjectClient.PART_LABEL_SEPARATOR + BOTGARDEN_PROFILE_NAME;
-    public final static String NATURALHISTORY_SCHEMA_NAME = CollectionObjectClient.SERVICE_NAME + CollectionObjectClient.PART_LABEL_SEPARATOR + CollectionSpaceClient.NATURALHISTORY_EXTENSION_NAME;
 
     public final static String URI_SCHEMA_NAME = CORE_SCHEMA_NAME;
     public final static String URI_FIELD_NAME = CollectionSpaceClient.COLLECTIONSPACE_CORE_URI; //"uri";
@@ -17,12 +16,6 @@ public class CollectionObjectBotGardenConstants {
     public final static String WORKFLOW_STATE_SCHEMA_NAME = CORE_SCHEMA_NAME;
     public final static String WORKFLOW_STATE_FIELD_NAME = CollectionSpaceClient.COLLECTIONSPACE_CORE_WORKFLOWSTATE;
 
-    public final static String FIELD_COLLECTION_PLACE_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
-    public final static String FIELD_COLLECTION_PLACE_FIELD_NAME = "localityGroupList/localityGroup/fieldLocPlace";
-
-    public final static String TAXONOMIC_RANGE_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
-    public final static String TAXONOMIC_RANGE_FIELD_NAME = "localityGroupList/localityGroup/taxonomicRange";
-
     public final static String COMMENT_SCHEMA_NAME = COMMON_SCHEMA_NAME;
     public final static String COMMENT_FIELD_NAME = "comments/comment";
 
@@ -32,35 +25,4 @@ public class CollectionObjectBotGardenConstants {
     public final static String DEAD_DATE_SCHEMA_NAME = BOTGARDEN_SCHEMA_NAME;
     public final static String DEAD_DATE_FIELD_NAME = "deadDate";
 
-    public final static String TAXON_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
-    public final static String TAXON_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/taxon";
-    public final static String PRIMARY_TAXON_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup[0]/taxon";
-
-    public final static String DETERMINATION_BY_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
-    public final static String DETERMINATION_BY_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/identBy";
-
-    public final static String DETERMINATION_DATE_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
-    public final static String DETERMINATION_DATE_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/identDateGroup/dateDisplayDate";
-
-    public final static String DETERMINATION_INSTITUTION_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
-    public final static String DETERMINATION_INSTITUTION_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/institution";
-
-    public final static String DETERMINATION_KIND_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
-    public final static String DETERMINATION_KIND_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/identKind";
-    public final static String DETERMINATION_KIND_DETERMINATION_VALUE = "determination";
-
-    public final static String HYBRID_FLAG_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
-    public final static String HYBRID_FLAG_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/hybridFlag";
-
-    public final static String RARE_FLAG_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
-    public final static String RARE_FLAG_FIELD_NAME = "rare";
-
-    public final static String HYBRID_PARENT_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
-    public final static String HYBRID_PARENT_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/taxonomicIdentHybridParentGroupList/taxonomicIdentHybridParentGroup/taxonomicIdentHybridParent";
-
-    public final static String HYBRID_QUALIFIER_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
-    public final static String HYBRID_QUALIFIER_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/taxonomicIdentHybridParentGroupList/taxonomicIdentHybridParentGroup/taxonomicIdentHybridParentQualifier";
-
-    public final static String HYBRID_QUALIFIER_FEMALE_VALUE = "female";
-    public final static String HYBRID_QUALIFIER_MALE_VALUE = "male";
 }
diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectNaturalHistoryConstants.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectNaturalHistoryConstants.java
new file mode 100644 (file)
index 0000000..f55982f
--- /dev/null
@@ -0,0 +1,47 @@
+package org.collectionspace.services.collectionobject.nuxeo;
+
+import org.collectionspace.services.client.CollectionObjectClient;
+import org.collectionspace.services.client.CollectionSpaceClient;
+
+public class CollectionObjectNaturalHistoryConstants {
+    public final static String NATURALHISTORY_SCHEMA_NAME = CollectionObjectClient.SERVICE_NAME + CollectionObjectClient.PART_LABEL_SEPARATOR + CollectionSpaceClient.NATURALHISTORY_EXTENSION_NAME;
+
+    public final static String FIELD_COLLECTION_PLACE_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
+    public final static String FIELD_COLLECTION_PLACE_FIELD_NAME = "localityGroupList/localityGroup/fieldLocPlace";
+
+    public final static String TAXONOMIC_RANGE_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
+    public final static String TAXONOMIC_RANGE_FIELD_NAME = "localityGroupList/localityGroup/taxonomicRange";
+
+    public final static String TAXON_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
+    public final static String TAXON_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/taxon";
+    public final static String PRIMARY_TAXON_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup[0]/taxon";
+
+    public final static String DETERMINATION_BY_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
+    public final static String DETERMINATION_BY_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/identBy";
+
+    public final static String DETERMINATION_DATE_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
+    public final static String DETERMINATION_DATE_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/identDateGroup/dateDisplayDate";
+
+    public final static String DETERMINATION_INSTITUTION_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
+    public final static String DETERMINATION_INSTITUTION_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/institution";
+
+    public final static String DETERMINATION_KIND_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
+    public final static String DETERMINATION_KIND_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/identKind";
+    public final static String DETERMINATION_KIND_DETERMINATION_VALUE = "determination";
+
+    public final static String HYBRID_FLAG_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
+    public final static String HYBRID_FLAG_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/hybridFlag";
+
+    public final static String RARE_FLAG_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
+    public final static String RARE_FLAG_FIELD_NAME = "rare";
+
+    public final static String HYBRID_PARENT_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
+    public final static String HYBRID_PARENT_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/taxonomicIdentHybridParentGroupList/taxonomicIdentHybridParentGroup/taxonomicIdentHybridParent";
+
+    public final static String HYBRID_QUALIFIER_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
+    public final static String HYBRID_QUALIFIER_FIELD_NAME = "taxonomicIdentGroupList/taxonomicIdentGroup/taxonomicIdentHybridParentGroupList/taxonomicIdentHybridParentGroup/taxonomicIdentHybridParentQualifier";
+
+    public final static String HYBRID_QUALIFIER_FEMALE_VALUE = "female";
+    public final static String HYBRID_QUALIFIER_MALE_VALUE = "male";
+
+}
@@ -1,5 +1,6 @@
-package org.collectionspace.services.collectionobject.nuxeo;
+package org.collectionspace.services.collectionobject.nuxeo.validators;
 
+import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectValidatorHandler;
 import org.collectionspace.services.common.document.InvalidDocumentException;
 
 public class BotGardenCollectionObjectValidatorHandler extends CollectionObjectValidatorHandler {
diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/validators/PahmaCollectionObjectValidatorHandler.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/validators/PahmaCollectionObjectValidatorHandler.java
new file mode 100644 (file)
index 0000000..7c66367
--- /dev/null
@@ -0,0 +1,13 @@
+package org.collectionspace.services.collectionobject.nuxeo.validators;
+
+import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectValidatorHandler;
+import org.collectionspace.services.common.document.InvalidDocumentException;
+
+public class PahmaCollectionObjectValidatorHandler extends CollectionObjectValidatorHandler {
+
+       @Override
+       protected void handleUpdate() throws InvalidDocumentException {
+                               // PAHMA-473: Disable non-empty objectNumber requirement, so that updates don't need to retrieve the current objectNumber.
+
+       }
+}
diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/validators/UCJepsCollectionObjectValidatorHandler.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/validators/UCJepsCollectionObjectValidatorHandler.java
new file mode 100644 (file)
index 0000000..aa8cfd1
--- /dev/null
@@ -0,0 +1,19 @@
+package org.collectionspace.services.collectionobject.nuxeo.validators;
+
+import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectValidatorHandler;
+import org.collectionspace.services.common.document.InvalidDocumentException;
+
+public class UCJepsCollectionObjectValidatorHandler extends CollectionObjectValidatorHandler {
+
+       @Override
+       protected void handleUpdate() throws InvalidDocumentException {
+               // Allow an empty object number.
+
+       }
+
+       @Override
+       protected void handleCreate() throws InvalidDocumentException {
+               // Allow an empty object number.
+
+       }
+}
index 7d5909d2bc73ce2f45c6d33583f85f1bbb7be414..add4ae3038bd2e5945e1fbed230d221089bfb743 100644 (file)
@@ -301,6 +301,40 @@ public class RefNameUtils {
        }
        
        return displayName;
-    }    
-}
+    }
+
+    /**
+     * Compare two refname strings.  They're considered equal if the short IDs match
+     *
+     * @param refname1
+     * @param refname2
+     * @return
+     */
+    public static boolean doShortIDsMatch(String refname1, String refname2) {
+        boolean result = false;
+
+        if (refname1 != null && refname2 != null) {
 
+            try {
+                String[] refNameTokens1 = refname1.substring(URN_PREFIX_LEN).split(SEPARATOR, AUTH_ITEM_REFNAME_TOKENS);
+                AuthorityTermInfo authTermInfo1 = new AuthorityTermInfo(refNameTokens1);
+                String inAuthority1 = authTermInfo1.inAuthority.name;
+                String shortID1 = authTermInfo1.name;
+
+                String[] refNameTokens2 = refname2.substring(URN_PREFIX_LEN).split(SEPARATOR, AUTH_ITEM_REFNAME_TOKENS);
+                AuthorityTermInfo authTermInfo2 = new AuthorityTermInfo(refNameTokens2);
+                String inAuthority2 = authTermInfo2.inAuthority.name;
+                String shortID2 = authTermInfo2.name;
+
+                if (shortID1.equals(shortID2) && inAuthority1.equals(inAuthority2)) {
+                    result = true;
+                }
+            } catch (Exception e) {
+                // do nothing
+            }
+
+        }
+
+        return result;
+    }
+}
\ No newline at end of file
index 06028f4ed94e2e6670152488b5a98f456785eb7e..de2622e3f741a4a6153126e8242e7895d5b46f9c 100644 (file)
@@ -26,7 +26,7 @@
         </tenant:properties>
 
         <tenant:serviceBindings merge:matcher="id" id="CollectionObjects">
-            <service:validatorHandler xmlns:service="http://collectionspace.org/services/config/service" merge:matcher="tag" merge:action="replace">org.collectionspace.services.collectionobject.nuxeo.BotGardenCollectionObjectValidatorHandler</service:validatorHandler>
+            <service:validatorHandler xmlns:service="http://collectionspace.org/services/config/service" merge:matcher="tag" merge:action="replace">org.collectionspace.services.collectionobject.nuxeo.validators.BotGardenCollectionObjectValidatorHandler</service:validatorHandler>
         </tenant:serviceBindings>
 
         <tenant:serviceBindings merge:matcher="id" id="idgenerators">
index 0aea05b37237a5ebdcbd99cad8c513b1bc344fd9..8468ac89fe615297aabc643562bb6f0a8145c641 100644 (file)
@@ -12,15 +12,20 @@ public class MovementBotGardenConstants {
        public static final String BOTGARDEN_PROFILE_NAME = MovementClient.BOTGARDEN_PROFILE_NAME;
        public static final String BOTGARDEN_SCHEMA_NAME = MovementClient.SERVICE_NAME + CollectionSpaceClient.PART_LABEL_SEPARATOR + BOTGARDEN_PROFILE_NAME;
        
+       public static final String PREVIOUS_LOCATION_SCHEMA_NAME = BOTGARDEN_SCHEMA_NAME;
+       public static final String PREVIOUS_LOCATION_FIELD_NAME = "previousLocation";
+
        public static final String ACTION_CODE_SCHEMA_NAME = MovementConstants.COMMON_SCHEMA_NAME;
        public static final String ACTION_CODE_FIELD_NAME = "reasonForMove";
 
        public static final String ACTION_DATE_SCHEMA_NAME = MovementConstants.COMMON_SCHEMA_NAME;
        public static final String ACTION_DATE_FIELD_NAME = "locationDate";
-                       
-       public static final String DEAD_ACTION_CODE = "Dead";
-       public static final String REVIVED_ACTION_CODE = "Revived";
-       public static final String OTHER_ACTION_CODE = "Other";
+
+       // See CollectionSpace wiki documentation for "RefName" values
+    // https://collectionspace.atlassian.net/wiki/spaces/DOC/pages/2754224504/RefName
+       public static final String DEAD_ACTION_CODE = "urn:NID:NAMESPACE:vocabularies:name(actionCode):item:name(actCode00)";
+       public static final String REVIVED_ACTION_CODE = "urn:NID:NAMESPACE:vocabularies:name(actionCode):item:name(actCode06)";
+       public static final String OTHER_ACTION_CODE = "urn:NID:NAMESPACE:vocabularies:name(actionCode):item:name(actCode05)";
                
        public static final String LABEL_REQUESTED_SCHEMA_NAME = BOTGARDEN_SCHEMA_NAME;
        public static final String LABEL_REQUESTED_FIELD_NAME = "labelRequested";
index ed2ac881f12ed9c8872edcc6b9aae072194220e9..1bf8f2b70889bafeee1a22cb58928239903561eb 100644 (file)
@@ -52,5 +52,14 @@ public class TaxonConstants {
     public final static String REFNAME_FIELD_NAME = "refName";    
     
        public static final String WORKFLOW_STATE_SCHEMA_NAME = CORE_SCHEMA_NAME;
-       public static final String WORKFLOW_STATE_FIELD_NAME = CollectionSpaceClient.COLLECTIONSPACE_CORE_WORKFLOWSTATE; //"workflowState";    
+       public static final String WORKFLOW_STATE_FIELD_NAME = CollectionSpaceClient.COLLECTIONSPACE_CORE_WORKFLOWSTATE; //"workflowState";
+
+    public static final String TAXON_NAME = "taxon";
+    public static final String TAXON_HYBRID_PARENT_GROUP_LIST = "taxonomicIdentHybridParentGroupList";
+    public static final String TAXON_HYBRID_PARENT_GROUP = "taxonomicIdentHybridParentGroup";
+    public static final String TAXON_HYBRID_PARENT_QUALIF = "taxonomicIdentHybridParentQualifier";
+    public static final String TAXON_HYBRID_PARENT = "taxonomicIdentHybridParent";
+    public static final String TAXON_HYBRID_NAME = "taxonomicIdentHybridName";
+    public static final String HYBRID_FLAG = "hybridFlag";
+    public static final String AFF_TAXON = "affinityTaxon";
 }
@@ -3,7 +3,7 @@ package org.collectionspace.services.taxonomy.nuxeo;
 import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.TaxonomyAuthorityClient;
 
-public class TaxonBotGardenConstants {
+public class TaxonNaturalHistoryConstants {
        public static final String NATURALHISTORY_SCHEMA_NAME = TaxonomyAuthorityClient.SERVICE_ITEM_NAME + CollectionSpaceClient.PART_LABEL_SEPARATOR + CollectionSpaceClient.NATURALHISTORY_EXTENSION_NAME;
 
     public final static String CONSERVATION_CATEGORY_SCHEMA_NAME = NATURALHISTORY_SCHEMA_NAME;
index 15f8b9108d404f402ba3390b2542b4d94c450e5a..8a194aa7b0c57d9078ad19c1da6f137508f5b38c 100644 (file)
@@ -28,7 +28,7 @@ package org.collectionspace.services.taxonomy.nuxeo;
  */
 public class TaxonomyAuthorityConstants {
 
-    public final static String NUXEO_DOCTYPE = "TaxonomyAuthority";
+    public final static String NUXEO_DOCTYPE = "Taxonomyauthority";
     public final static String NUXEO_SCHEMA_NAME = "taxonomyauthority";
     public final static String NUXEO_DC_TITLE = "CollectionSpace-TaxonomyAuthority";
 }