Skip to content

Commit

Permalink
DRYD-1393: Tag attribute for procedures (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejritter authored Sep 27, 2024
1 parent a746b32 commit 0e23e08
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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., <tenant:serviceBindings name="CollectionObjects" type="object" version="0.1">
serviceBindingsElement = ele.addElement(new QName("serviceBindings", nstenant));
Expand All @@ -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., <tenant:serviceBindings id="Persons" name="Persons" type="authority" version="0.1">
Expand All @@ -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);
Expand Down Expand Up @@ -977,6 +978,15 @@ private void addServiceBinding(Record r, Element el, Namespace nameSpace, Boolea
//<service:object>
doServiceObject(r, el, this.nsservices, isAuthority, serviceBindingVersion);

Set<String> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down Expand Up @@ -602,6 +603,10 @@ public Set<String> getServicesPrefetchFields() {
return utils.getSet("@services-prefetch-fields");
}

public Set<String> getTags() {
return utils.getSet("@tag");
}

public Spec getSpec() {
return spec;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<record id="consultation" in-findedit="yes" type="record,procedure" cms-type="default" generate-services-schema="true" >
<record id="consultation" in-findedit="yes" type="record,procedure" tag="nagpra" cms-type="default" generate-services-schema="true" >
<services-url>consultations</services-url>
<services-tenant-plural>Consultations</services-tenant-plural>
<services-tenant-singular>Consultation</services-tenant-singular>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<record id="dutyofcare" in-findedit="yes" type="record,procedure" cms-type="default" generate-services-schema="true" >
<record id="dutyofcare" in-findedit="yes" type="record,procedure" tag="nagpra" cms-type="default" generate-services-schema="true" >
<services-url>dutiesofcare</services-url>
<services-tenant-plural>Dutiesofcare</services-tenant-plural>
<services-tenant-singular>Dutyofcare</services-tenant-singular>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<record id="nagprainventory" in-findedit="yes" type="record,procedure" cms-type="default" generate-services-schema="true" >
<record id="nagprainventory" in-findedit="yes" type="record,procedure" tag="nagpra" cms-type="default" generate-services-schema="true" >
<services-url>nagprainventories</services-url>
<services-tenant-plural>NagpraInventories</services-tenant-plural>
<services-tenant-singular>NagpraInventory</services-tenant-singular>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<record id="repatriationclaim" in-findedit="yes" type="record,procedure" cms-type="default" generate-services-schema="true" >
<record id="repatriationclaim" in-findedit="yes" type="record,procedure" tag="nagpra" cms-type="default" generate-services-schema="true" >
<services-url>repatriationclaims</services-url>
<services-tenant-plural>RepatriationClaims</services-tenant-plural>
<services-tenant-singular>RepatriationClaim</services-tenant-singular>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<record id="summarydocumentation" in-findedit="yes" type="record,procedure" cms-type="default"
<record id="summarydocumentation" in-findedit="yes" type="record,procedure" tag="nagpra" cms-type="default"
generate-services-schema="true">
<services-url>summarydocumentations</services-url>
<services-tenant-plural>SummaryDocumentations</services-tenant-plural>
Expand Down

0 comments on commit 0e23e08

Please sign in to comment.