From 0e23e08e242e0aade9e12af2fb598b68b12a48d0 Mon Sep 17 00:00:00 2001 From: Michael Ritter Date: Thu, 26 Sep 2024 18:22:07 -0600 Subject: [PATCH] DRYD-1393: Tag attribute for procedures (#299) --- .../ServiceBindingsGeneration.java | 28 +++++++++++++------ .../chain/csp/schema/Record.java | 5 ++++ .../defaults/base-procedure-consultation.xml | 2 +- .../defaults/base-procedure-dutyofcare.xml | 2 +- .../base-procedure-nagprainventory.xml | 2 +- .../base-procedure-repatriationclaim.xml | 2 +- .../base-procedure-summarydocumentation.xml | 2 +- 7 files changed, 29 insertions(+), 14 deletions(-) diff --git a/cspi-installation/src/main/java/org/collectionspace/chain/installation/ServiceBindingsGeneration.java b/cspi-installation/src/main/java/org/collectionspace/chain/installation/ServiceBindingsGeneration.java index 77720b02b..e8d94edf6 100644 --- a/cspi-installation/src/main/java/org/collectionspace/chain/installation/ServiceBindingsGeneration.java +++ b/cspi-installation/src/main/java/org/collectionspace/chain/installation/ServiceBindingsGeneration.java @@ -5,6 +5,7 @@ import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; +import java.util.Set; import org.collectionspace.chain.csp.persistence.services.TenantSpec; import org.collectionspace.chain.csp.persistence.services.TenantSpec.RemoteClient; @@ -21,7 +22,6 @@ import org.collectionspace.chain.csp.schema.UiData; import org.collectionspace.services.common.api.FileTools; import org.collectionspace.services.common.api.Tools; -import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.DocumentFactory; import org.dom4j.Element; @@ -189,9 +189,9 @@ private String doServiceBindingsCommon(String serviceBindingVersion) { Element rele = ele.addElement(new QName("repositoryDomain", nstenant)); rele.addAttribute("name", this.tenantSpec.getRepositoryDomain()); rele.addAttribute("storageName", this.tenantSpec.getStorageName()); - if (Tools.notEmpty(this.tenantSpec.getRepositoryName())) { - rele.addAttribute("repositoryName", this.tenantSpec.getRepositoryName()); - } + if (Tools.notEmpty(this.tenantSpec.getRepositoryName())) { + rele.addAttribute("repositoryName", this.tenantSpec.getRepositoryName()); + } rele.addAttribute("repositoryClient", this.tenantSpec.getRepositoryClient()); // Set remote clients @@ -216,9 +216,9 @@ private String doServiceBindingsCommon(String serviceBindingVersion) { getConfigFile().getName(), recordName)); } - if (shouldGenerateServiceBinding(r) == true) { + if (shouldGenerateServiceBinding(r)) { Element serviceBindingsElement = null; - if (r.isType(RECORD_TYPE_RECORD) == true) { // Records can be of several types -i.e., can be both a "record" type and a "vocabulary" type + if (r.isType(RECORD_TYPE_RECORD)) { // Records can be of several types -i.e., can be both a "record" type and a "vocabulary" type String rtype = getServiceBindingType(r); // e.g., serviceBindingsElement = ele.addElement(new QName("serviceBindings", nstenant)); @@ -227,14 +227,15 @@ private String doServiceBindingsCommon(String serviceBindingVersion) { serviceBindingsElement.addAttribute("type", rtype); serviceBindingsElement.addAttribute("version", serviceBindingVersion); serviceBindingsElement.addAttribute("elasticsearchIndexed", Boolean.toString(r.isElasticsearchIndexed())); - if (r.isType(RECORD_TYPE_VOCABULARY) == true) { + if (r.isType(RECORD_TYPE_VOCABULARY)) { serviceBindingsElement.addAttribute(Record.REQUIRES_UNIQUE_SHORTID, Boolean.TRUE.toString()); // Vocabularies need unique short IDs serviceBindingsElement.addAttribute(Record.SUPPORTS_REPLICATING, Boolean.toString(r.supportsReplicating())); // they also need to support replication String remoteClientConfigName = r.getRemoteClientConfigName(); - if (remoteClientConfigName != null && remoteClientConfigName.isEmpty() == false) { + if (remoteClientConfigName != null && !remoteClientConfigName.isEmpty()) { serviceBindingsElement.addAttribute(Record.REMOTECLIENT_CONFIG_NAME, remoteClientConfigName); } } + addServiceBinding(r, serviceBindingsElement, nsservices, false, serviceBindingVersion); } else if (r.isType(RECORD_TYPE_AUTHORITY)) { // e.g., @@ -259,7 +260,7 @@ private String doServiceBindingsCommon(String serviceBindingVersion) { // // Debug-log the generated Service bindings for this App layer record // - if (log.isDebugEnabled() == true) { + if (log.isDebugEnabled()) { Element bindingsForRecord = serviceBindingsElement; if (bindingsForRecord != null && !r.isType(RECORD_TYPE_AUTHORITY)) { this.debugWriteToFile(r, bindingsForRecord, false); @@ -977,6 +978,15 @@ private void addServiceBinding(Record r, Element el, Namespace nameSpace, Boolea // doServiceObject(r, el, this.nsservices, isAuthority, serviceBindingVersion); + Set tags = r.getTags(); + if (tags != null && !tags.isEmpty()) { + log.debug("{} tags => {}", r.getRecordName(), tags); + Element tagElement = el.addElement(new QName("tags", nameSpace)); + for (String tag : tags) { + tagElement.addElement(new QName("tag", nameSpace)).addText(tag); + } + } + if (log.isTraceEnabled()) { String msg = String.format("Config Generation: '%s' - Created service bindings for record type '%s'.", this.getConfigFile().getName(), r.getRecordName()); diff --git a/cspi-schema/src/main/java/org/collectionspace/chain/csp/schema/Record.java b/cspi-schema/src/main/java/org/collectionspace/chain/csp/schema/Record.java index 2156e3950..1f91c87cd 100644 --- a/cspi-schema/src/main/java/org/collectionspace/chain/csp/schema/Record.java +++ b/cspi-schema/src/main/java/org/collectionspace/chain/csp/schema/Record.java @@ -145,6 +145,7 @@ public void setLastAuthorityProxy(Record lastAuthoriyProxy) { // record,authority,compute-displayname can have multiple types using // commas utils.initSet(section, "@type", new String[] { "record" }); + utils.initSet(section, "@tag", new String[] {}); // // Service specific config for Nuxeo ECM platform - things added to the "doctype" definitions // @@ -602,6 +603,10 @@ public Set getServicesPrefetchFields() { return utils.getSet("@services-prefetch-fields"); } + public Set getTags() { + return utils.getSet("@tag"); + } + public Spec getSpec() { return spec; } diff --git a/tomcat-main/src/main/resources/defaults/base-procedure-consultation.xml b/tomcat-main/src/main/resources/defaults/base-procedure-consultation.xml index 2a2e7750a..59de77f46 100644 --- a/tomcat-main/src/main/resources/defaults/base-procedure-consultation.xml +++ b/tomcat-main/src/main/resources/defaults/base-procedure-consultation.xml @@ -1,4 +1,4 @@ - + consultations Consultations Consultation diff --git a/tomcat-main/src/main/resources/defaults/base-procedure-dutyofcare.xml b/tomcat-main/src/main/resources/defaults/base-procedure-dutyofcare.xml index 2a2999091..4bdd36d4f 100644 --- a/tomcat-main/src/main/resources/defaults/base-procedure-dutyofcare.xml +++ b/tomcat-main/src/main/resources/defaults/base-procedure-dutyofcare.xml @@ -1,4 +1,4 @@ - + dutiesofcare Dutiesofcare Dutyofcare diff --git a/tomcat-main/src/main/resources/defaults/base-procedure-nagprainventory.xml b/tomcat-main/src/main/resources/defaults/base-procedure-nagprainventory.xml index 4836f8270..e6d7f1335 100644 --- a/tomcat-main/src/main/resources/defaults/base-procedure-nagprainventory.xml +++ b/tomcat-main/src/main/resources/defaults/base-procedure-nagprainventory.xml @@ -1,4 +1,4 @@ - + nagprainventories NagpraInventories NagpraInventory diff --git a/tomcat-main/src/main/resources/defaults/base-procedure-repatriationclaim.xml b/tomcat-main/src/main/resources/defaults/base-procedure-repatriationclaim.xml index 303993d87..caaa3cea8 100644 --- a/tomcat-main/src/main/resources/defaults/base-procedure-repatriationclaim.xml +++ b/tomcat-main/src/main/resources/defaults/base-procedure-repatriationclaim.xml @@ -1,4 +1,4 @@ - + repatriationclaims RepatriationClaims RepatriationClaim diff --git a/tomcat-main/src/main/resources/defaults/base-procedure-summarydocumentation.xml b/tomcat-main/src/main/resources/defaults/base-procedure-summarydocumentation.xml index c8c0406d4..d706a50b9 100644 --- a/tomcat-main/src/main/resources/defaults/base-procedure-summarydocumentation.xml +++ b/tomcat-main/src/main/resources/defaults/base-procedure-summarydocumentation.xml @@ -1,4 +1,4 @@ - summarydocumentations SummaryDocumentations