Skip to content

Commit

Permalink
added new method to get all occurrences of a metadata field in variable
Browse files Browse the repository at this point in the history
replacer
  • Loading branch information
rsehr committed Jan 16, 2019
1 parent c656fce commit 0314dfc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Goobi/src/de/sub/goobi/helper/VariableReplacer.java
Expand Up @@ -315,7 +315,7 @@ public String replace(String inString) {

for (MatchResult r : findRegexMatches("\\$?(?:\\(|\\{)db_meta\\.([^)]+)(?:\\}|\\))", inString)) {
String metadataName = r.group(1);
String value = MetadataManager.getMetadataValue(process.getId(), metadataName);
String value = MetadataManager.getAllValuesForMetadata(process.getId(), metadataName);
inString = inString.replace(r.group(), value);
}

Expand Down
11 changes: 10 additions & 1 deletion Goobi/src/de/sub/goobi/persistence/managers/MetadataManager.java
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of the Goobi Application - a Workflow tool for the support of mass digitization.
*
* Visit the websites for more information.
* Visit the websites for more information.
* - https://goobi.io
* - https://www.intranda.com
* - https://github.com/intranda/goobi
Expand Down Expand Up @@ -117,6 +117,15 @@ public static String getMetadataValue(int processId, String metadataName) {
return "";
}

public static String getAllValuesForMetadata(int processId, String metadataName) {
try {
return MetadataMysqlHelper.getAllValuesForMetadata(processId, metadataName);
} catch (SQLException e) {
logger.error(e);
}
return "";
}


public static List<String> getAllMetadataValues(int processId, String metadataName) {
try {
Expand Down
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of the Goobi Application - a Workflow tool for the support of mass digitization.
*
* Visit the websites for more information.
* Visit the websites for more information.
* - https://goobi.io
* - https://www.intranda.com
* - https://github.com/intranda/goobi
Expand Down Expand Up @@ -197,6 +197,20 @@ public static String getMetadataValue(int processId, String metadataName) throws
}


public static String getAllValuesForMetadata(int processId, String metadataName) throws SQLException {
String sql = "SELECT print FROM metadata WHERE processid = ? and name = ?";
Connection connection = null;
try {
connection = MySQLHelper.getInstance().getConnection();
return new QueryRunner().query(connection, sql, MySQLHelper.resultSetToStringHandler, processId, metadataName);
} finally {
if (connection != null) {
MySQLHelper.closeConnection(connection);
}
}
}


public static List<String> getAllMetadataValues(int processId, String metadataName) throws SQLException {
String sql = "SELECT value FROM metadata WHERE processid = ? and name = ?";
Connection connection = null;
Expand Down

0 comments on commit 0314dfc

Please sign in to comment.