Skip to content

Commit

Permalink
memory consumption, increase performance on process check
Browse files Browse the repository at this point in the history
  • Loading branch information
rsehr committed Oct 7, 2024
1 parent 991d9c7 commit 610957e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ public void parseEadFile(Document document, Integer recordGroupId) {
} else {
eadElement = collection;
}
rootElement = parseElement(0, 0, eadElement, recordGroupId);
rootElement = parseElement(0, 0, eadElement, recordGroupId, null);
INodeType rootType = new NodeType("root", null, "fa fa-home", 0);
rootElement.setNodeType(rootType);
rootElement.setDisplayChildren(true);
Expand All @@ -550,7 +550,7 @@ public void parseEadFile(Document document) {
* read the metadata for the current xml node. - create an {@link EadEntry} - execute the configured xpaths on the current node - add the metadata
* to one of the 7 levels - check if the node has sub nodes - call the method recursively for all sub nodes
*/
private IEadEntry parseElement(int order, int hierarchy, Element element, Integer recordGroupId) {
private IEadEntry parseElement(int order, int hierarchy, Element element, Integer recordGroupId, IEadEntry parent) {
IEadEntry entry = new EadEntry(order, hierarchy);

for (IMetadataField emf : configuredFields) {
Expand Down Expand Up @@ -647,6 +647,10 @@ private IEadEntry parseElement(int order, int hierarchy, Element element, Intege
}
entry.calculateFingerprint();

if (parent != null) {
entry.setParentNode(parent);
}

if (recordGroupId != null) {
// save current node
ArchiveManagementManager.saveNode(recordGroupId, entry);
Expand All @@ -668,9 +672,8 @@ private IEadEntry parseElement(int order, int hierarchy, Element element, Intege
int subHierarchy = hierarchy + 1;
for (Element c : clist) {

IEadEntry child = parseElement(subOrder, subHierarchy, c, recordGroupId);
IEadEntry child = parseElement(subOrder, subHierarchy, c, recordGroupId, entry);
entry.addSubEntry(child);
child.setParentNode(entry);
subOrder++;
}
}
Expand Down Expand Up @@ -2607,7 +2610,7 @@ private List<String> removeInvalidProcessIdsForChildren(IEadEntry currentEntry)
if (ProcessManager.countProcessTitle(strProcessTitle, null) == 0) {
currentEntry.setGoobiProcessTitle(null);
lstNodesWithoutIds.add(currentEntry.getId());
ArchiveManagementManager.saveNode(recordGroup.getId(), currentEntry);
ArchiveManagementManager.updateProcessLink(currentEntry);
Helper.setMeldung("Removing " + strProcessTitle + " from " + currentEntry.getLabel());
}
} catch (Exception e) {
Expand Down Expand Up @@ -2656,7 +2659,7 @@ private List<String> checkGoobiProcessesForArchiveRefs(List<String> lstNodesWith
node.setGoobiProcessTitle(strProcessTitle);
lstNodesWithNewIds.add(node.getLabel());
Helper.setMeldung("Node '" + node.getLabel() + "' has been given Goobi process ID: " + strProcessTitle);
ArchiveManagementManager.saveNode(recordGroup.getId(), node);
ArchiveManagementManager.updateProcessLink(node);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ public static void saveNode(Integer archiveId, IEadEntry node) {
saveNodes(archiveId, list);
}

public static void updateProcessLink(IEadEntry node) {
String sql = "update archive_record_node set processtitle = ? where id = ?";
try (Connection connection = MySQLHelper.getInstance().getConnection()) {
QueryRunner run = new QueryRunner();
run.update(connection, sql, node.getGoobiProcessTitle(), node.getDatabaseId());
} catch (SQLException e) {
log.error(e);
}
}

public static synchronized void saveNodes(Integer archiveId, List<IEadEntry> nodes) {
String insertSql =
"INSERT INTO archive_record_node (id, uuid, archive_record_group_id, hierarchy, order_number, node_type, sequence, processtitle, parent_id,label, data) VALUES ";
Expand Down

0 comments on commit 610957e

Please sign in to comment.