From c10aa9143babe46f066a1d0f219109e8f1dd5ed8 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 29 Apr 2024 13:19:48 -0500 Subject: [PATCH 1/5] Make the Embargo Type and Submission Type `None` values configurable. The behavior of the case of `None` is treated as as synonymous with a NULL value for that field in the database. I've looked over the different use cases and have found that in some cases `Unknown` and `Unassigned` are used. Make this `None` filter value customizable rather than hard-coding the opinion of `None` being NULL. The `app.filter.embargoTypeNone` and `app.filter.submissionTypeNone` may now be changed to something other than `None`. The default remains set to `None`. --- .../org/tdl/vireo/config/AppFilterConfig.java | 30 +++++++++++++++++++ .../model/repo/impl/SubmissionRepoImpl.java | 8 +++-- src/main/resources/application.yml | 7 +++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/tdl/vireo/config/AppFilterConfig.java diff --git a/src/main/java/org/tdl/vireo/config/AppFilterConfig.java b/src/main/java/org/tdl/vireo/config/AppFilterConfig.java new file mode 100644 index 000000000..2af0c013a --- /dev/null +++ b/src/main/java/org/tdl/vireo/config/AppFilterConfig.java @@ -0,0 +1,30 @@ +package org.tdl.vireo.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ConfigurationProperties(prefix = "app.filter") +public class AppFilterConfig { + + private String embargoTypeNone; + + private String submissionTypeNone; + + public String getEmbargoTypeNone() { + return embargoTypeNone; + } + + public void setEmbargoTypeNone(String embargoTypeNone) { + this.embargoTypeNone = embargoTypeNone; + } + + public String getSubmissionTypeNone() { + return submissionTypeNone; + } + + public void setSubmissionTypeNone(String submissionTypeNone) { + this.submissionTypeNone = submissionTypeNone; + } + +} diff --git a/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java b/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java index 082abdb5e..36d5d74b1 100644 --- a/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java +++ b/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java @@ -36,6 +36,7 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.transaction.annotation.Transactional; +import org.tdl.vireo.config.AppFilterConfig; import org.tdl.vireo.config.VireoDatabaseConfig; import org.tdl.vireo.exception.OrganizationDoesNotAcceptSubmissionsException; import org.tdl.vireo.model.Configuration; @@ -101,6 +102,9 @@ public class SubmissionRepoImpl extends AbstractWeaverRepoImpl Date: Mon, 13 May 2024 09:31:30 -0500 Subject: [PATCH 2/5] Fix bad merge where embargoTypes filter code ended up with submissionTypes filter code. --- .../org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java b/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java index f75c53415..500aa22dd 100644 --- a/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java +++ b/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java @@ -749,16 +749,16 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { // This is not a select column but is instead only a custom filter. if (submissionListColumn.getFilters().size() > 0) { sqlBuilder = new StringBuilder(); - sqlBuilder.append("s.id IN (SELECT submission_id FROM submission_field_values WHERE field_values_id IN (select id FROM field_value WHERE field_predicate_id IN (SELECT id FROM field_predicate WHERE value = 'submission_type') and ("); + sqlBuilder.append("s.id IN (SELECT submission_id FROM submission_field_values WHERE field_values_id IN (select id FROM field_value WHERE field_predicate_id IN (SELECT id FROM field_predicate WHERE value IN ('default_embargos', 'proquest_embargos')) and ("); - // Note that the OR query is used inside the column, represented by submission_type. + // Note that the OR query is used inside the column, represented by both default_embargos and proquest_embargos. boolean hasNone = false; for (String filterString : submissionListColumn.getFilters()) { if (filterString != null) { sqlBuilder.append(" value = '").append(escapeString(filterString, false, true)).append("' OR"); } - if (appFilterConfig.getSubmissionTypeNone().equalsIgnoreCase(filterString)) { + if (appFilterConfig.getEmbargoTypeNone().equalsIgnoreCase(filterString)) { hasNone = true; } } From 8ad36eb114b66f4e3ad5fa4f1aa01e486dd4dcd2 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 28 May 2024 09:38:18 -0500 Subject: [PATCH 3/5] The "None" filters should handle NULL case when not configured. If the `EmbargoType` and `SubmissionType` `None` settings are not specified in the `application.yml` or via an environment variable then a `NULL` pointer exception no longer is thrown. When not configured, then the `None` settings are ignored entirely. When not configured, then the `None` searches do not match `NULL` but do match the string. --- .../vireo/model/repo/impl/SubmissionRepoImpl.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java b/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java index 500aa22dd..ec4894c22 100644 --- a/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java +++ b/src/main/java/org/tdl/vireo/model/repo/impl/SubmissionRepoImpl.java @@ -758,8 +758,10 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { sqlBuilder.append(" value = '").append(escapeString(filterString, false, true)).append("' OR"); } - if (appFilterConfig.getEmbargoTypeNone().equalsIgnoreCase(filterString)) { - hasNone = true; + if (appFilterConfig.getEmbargoTypeNone() != null) { + if (appFilterConfig.getEmbargoTypeNone().equalsIgnoreCase(filterString)) { + hasNone = true; + } } } sqlBuilder.setLength(sqlBuilder.length() - 3); @@ -788,8 +790,10 @@ public int compare(SubmissionListColumn svc1, SubmissionListColumn svc2) { sqlBuilder.append(" value = '").append(escapeString(filterString, false, true)).append("' OR"); } - if (appFilterConfig.getSubmissionTypeNone().equalsIgnoreCase(filterString)) { - hasNone = true; + if (appFilterConfig.getSubmissionTypeNone() != null) { + if (appFilterConfig.getSubmissionTypeNone().equalsIgnoreCase(filterString)) { + hasNone = true; + } } } sqlBuilder.setLength(sqlBuilder.length() - 3); From 7c902e22ea573a8e510cd92acebd99f6ca6eb43b Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 28 May 2024 09:43:40 -0500 Subject: [PATCH 4/5] Do not display the "Embargo Type" in the Submission List filters. --- .../app/controllers/submission/submissionListController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/app/controllers/submission/submissionListController.js b/src/main/webapp/app/controllers/submission/submissionListController.js index a1b9860bc..f1407b176 100644 --- a/src/main/webapp/app/controllers/submission/submissionListController.js +++ b/src/main/webapp/app/controllers/submission/submissionListController.js @@ -164,7 +164,7 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle if (!!allSubmissionListFilters) { submissionListColumns = allSubmissionListFilters.filter(function excludeCustomFilters(slc) { - return slc.title !== 'Search Box' && slc.title !== "Submission Type (List)"; + return slc.title !== 'Search Box' && slc.title !== "Submission Type (List)" && slc.title != "Embargo Type"; }); submissionListColumnsForManage = allSubmissionListFilters.filter(function excludeSearchBox(slc) { From b020a561c4e53a0cef5a4d97e07b748fb1e1944e Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 28 May 2024 09:47:29 -0500 Subject: [PATCH 5/5] Use double-equals for the filter. --- .../app/controllers/submission/submissionListController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/app/controllers/submission/submissionListController.js b/src/main/webapp/app/controllers/submission/submissionListController.js index f1407b176..06fc7008f 100644 --- a/src/main/webapp/app/controllers/submission/submissionListController.js +++ b/src/main/webapp/app/controllers/submission/submissionListController.js @@ -164,7 +164,7 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle if (!!allSubmissionListFilters) { submissionListColumns = allSubmissionListFilters.filter(function excludeCustomFilters(slc) { - return slc.title !== 'Search Box' && slc.title !== "Submission Type (List)" && slc.title != "Embargo Type"; + return slc.title !== 'Search Box' && slc.title !== "Submission Type (List)" && slc.title !== "Embargo Type"; }); submissionListColumnsForManage = allSubmissionListFilters.filter(function excludeSearchBox(slc) {