<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>
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;
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);
<module>updaterelationsondelete</module>
<module>updateimagederivatives</module>
<module>naturalhistory</module>
- <module>botgarden</module>
+ <module>tenants</module>
</modules>
<dependencies>
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 -->
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>
</dependency>
</dependencies>
-
<build>
<resources>
<resource>
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;
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)) {
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;
* 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
*
*/
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];
// 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);
}
// 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 = "";
}
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>();
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;
}
/*
- * 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) {
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 {
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;
* 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);
/*
}
}
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);
}
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);
}
}
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;
* 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
*
*/
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];
// 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);
}
// 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 = "";
}
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;
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;
--- /dev/null
+<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>
--- /dev/null
+<?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>
<!-- 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.">
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
import java.net.URISyntaxException;
import java.util.ArrayList;
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;
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
import java.net.URISyntaxException;
import java.util.ArrayList;
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;
clearLabelRequest(potTagCsid);
numAffected = numAffected + 1;
}
-
+
results.setNumAffected(numAffected);
results.setUserNote("Removed " + numAffected + " label " + (numAffected == 1 ? "request" : "requests"));
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
import java.net.URISyntaxException;
import java.util.ArrayList;
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;
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
import java.net.URISyntaxException;
import java.util.Arrays;
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;
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)) {
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;
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;
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;
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
import java.net.URISyntaxException;
import java.util.ArrayList;
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;
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)));
-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;
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() {
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);
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) {
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);
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;
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;
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);
// 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;
*/
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);
}
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);
"<?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>";
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
import java.net.URISyntaxException;
import java.util.ArrayList;
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;
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);
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);
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.
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,
--- /dev/null
+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
--- /dev/null
+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;
+ }
+}
-package org.collectionspace.services.batch.nuxeo;
+package org.collectionspace.services.batch.nuxeo.botgarden;
import java.net.URISyntaxException;
import java.util.Arrays;
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;
// 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() {
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;
// 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++;
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 = "";
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";
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";
* @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.
//
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";
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";
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";
}
--- /dev/null
+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";
+
+}
-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 {
--- /dev/null
+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.
+
+ }
+}
--- /dev/null
+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.
+
+ }
+}
}
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
</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">
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";
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";
}
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;
*/
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";
}