Skip to content

Commit

Permalink
create link between node and process
Browse files Browse the repository at this point in the history
  • Loading branch information
rsehr committed Nov 5, 2024
1 parent ab78beb commit 4b01413
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2669,26 +2669,78 @@ private List<String> removeInvalidProcessIdsForChildren(IEadEntry currentEntry)

String goobiProcessTitle = currentEntry.getGoobiProcessTitle();

// check if process exists, otherwise remove link
if (!currentEntry.isHasChildren() && goobiProcessTitle != null) {
try {
String strProcessTitle = currentEntry.getGoobiProcessTitle();
if (ProcessManager.countProcessTitle(strProcessTitle, null) == 0) {
currentEntry.setGoobiProcessTitle(null);
lstNodesWithoutIds.add(currentEntry.getId());
ArchiveManagementManager.updateProcessLink(currentEntry);
Helper.setMeldung("Removing " + strProcessTitle + " from " + currentEntry.getLabel());
}
} catch (Exception e) {
Helper.setFehlerMeldung(e.getMessage());
log.error(e);
}
} else if (currentEntry.isHasChildren()) {
}

if (currentEntry.isHasChildren()) {

for (IEadEntry childEntry : currentEntry.getSubEntryList()) {
lstNodesWithoutIds.addAll(removeInvalidProcessIdsForChildren(childEntry));
}
} else if (goobiProcessTitle == null) {
lstNodesWithoutIds.add(currentEntry.getId());
// default option, use id to match nodes
if ("id".equalsIgnoreCase(identifierNodeName)) {
lstNodesWithoutIds.add(currentEntry.getId());
} else {
// otherwise find configured metadata
String value = ArchiveManagementManager.getMetadataValue(identifierNodeName, recordGroup.getId(), currentEntry.getId());
if (StringUtils.isNotBlank(value)) {
lstNodesWithoutIds.add(value);

}
// IMetadataField metadataField = null;
// for (IMetadataField field : currentEntry.getIdentityStatementAreaList()) {
// if (field.getName().equals(identifierNodeName)) {
// metadataField = field;
// }
// }
//
// for (IMetadataField field : currentEntry.getContextAreaList()) {
// if (field.getName().equals(identifierNodeName)) {
// metadataField = field;
// }
// }
// for (IMetadataField field : currentEntry.getContentAndStructureAreaAreaList()) {
// if (field.getName().equals(identifierNodeName)) {
// metadataField = field;
// }
// }
// for (IMetadataField field : currentEntry.getAccessAndUseAreaList()) {
// if (field.getName().equals(identifierNodeName)) {
// metadataField = field;
// }
// }
// for (IMetadataField field : currentEntry.getAlliedMaterialsAreaList()) {
// if (field.getName().equals(identifierNodeName)) {
// metadataField = field;
// }
// }
// for (IMetadataField field : currentEntry.getNotesAreaList()) {
// if (field.getName().equals(identifierNodeName)) {
// metadataField = field;
// }
// }
// for (IMetadataField field : currentEntry.getDescriptionControlAreaList()) {
// if (field.getName().equals(identifierNodeName)) {
// metadataField = field;
// }
// }
// if (metadataField != null) {
// lstNodesWithoutIds.add(metadataField.getValues().get(0).getValue());
// }
}
}

return lstNodesWithoutIds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,4 +571,20 @@ public static void deleteRecordGroup(String recordGroupName) {
}

}

public static String getMetadataValue(String metadataName, Integer recordGroupId, String nodeId) {
StringBuilder sql = new StringBuilder();

sql.append("select ExtractValue(data, '/xml/");
sql.append(metadataName);
sql.append("') from archive_record_node where archive_record_group_id= ? and uuid = ? ");
try (Connection connection = MySQLHelper.getInstance().getConnection()) {
QueryRunner run = new QueryRunner();
return run.query(connection, sql.toString(), MySQLHelper.resultSetToStringHandler, recordGroupId, nodeId);

} catch (SQLException e) {
log.error(e);
}
return null;
}
}

0 comments on commit 4b01413

Please sign in to comment.