Skip to content

Commit

Permalink
issue #199: Group results in completeness
Browse files Browse the repository at this point in the history
  • Loading branch information
pkiraly committed Dec 19, 2022
1 parent c8d717b commit 5224ef8
Showing 1 changed file with 30 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@ private void processLeader() {
if (bibliographicRecord.getLeader() != null) {
for (ControlValue position : bibliographicRecord.getLeader().getValuesList()) {
String marcPath = position.getDefinition().getId();
count(marcPath, completenessDAO.getElementCardinality().get(documentType));
count(marcPath, completenessDAO.getElementCardinality().get("all"));
if (hasGroupBy()) {
for (String groupId : groupIds)
addGrouppedElementCardinality(marcPath, groupId);
} else {
count(marcPath, completenessDAO.getElementCardinality().get(documentType));
count(marcPath, completenessDAO.getElementCardinality().get("all"));
}
count(marcPath, recordFrequency);
count(TagCategory.TAGS_00X.getPackageName(), recordPackageCounter);
}
Expand All @@ -91,8 +96,13 @@ private void processSimpleControlfields() {
for (MarcControlField field : bibliographicRecord.getSimpleControlfields()) {
if (field != null) {
String marcPath = field.getDefinition().getTag();
count(marcPath, completenessDAO.getElementCardinality().get(documentType));
count(marcPath, completenessDAO.getElementCardinality().get("all"));
if (hasGroupBy()) {
for (String groupId : groupIds)
addGrouppedElementCardinality(marcPath, groupId);
} else {
count(marcPath, completenessDAO.getElementCardinality().get(documentType));
count(marcPath, completenessDAO.getElementCardinality().get("all"));
}
count(marcPath, recordFrequency);
count(TagCategory.TAGS_00X.getPackageName(), recordPackageCounter);
}
Expand All @@ -104,8 +114,13 @@ private void processPositionalControlFields() {
if (field != null) {
for (ControlValue position : field.getValuesList()) {
String marcPath = position.getDefinition().getId();
count(marcPath, completenessDAO.getElementCardinality().get(documentType));
count(marcPath, completenessDAO.getElementCardinality().get("all"));
if (hasGroupBy()) {
for (String groupId : groupIds)
addGrouppedElementCardinality(marcPath, groupId);
} else {
count(marcPath, completenessDAO.getElementCardinality().get(documentType));
count(marcPath, completenessDAO.getElementCardinality().get("all"));
}
count(marcPath, recordFrequency);
count(TagCategory.TAGS_00X.getPackageName(), recordPackageCounter);
}
Expand Down Expand Up @@ -143,12 +158,7 @@ private void processDataField(DataField field) {
}

private void processGrouppedDataField(DataField field, String groupId) {
completenessDAO.getGrouppedElementCardinality().computeIfAbsent(groupId, s -> new TreeMap<>());
completenessDAO.getGrouppedElementCardinality().get(groupId).computeIfAbsent(documentType, s -> new TreeMap<>());
completenessDAO.getGrouppedElementCardinality().get(groupId).computeIfAbsent("all", s -> new TreeMap<>());
count(field.getTag(), completenessDAO.getGrouppedElementCardinality().get(groupId).get(documentType));
count(field.getTag(), completenessDAO.getGrouppedElementCardinality().get(groupId).get("all"));
count(field.getTag(), recordFrequency);
addGrouppedElementCardinality(field.getTag(), groupId);

List<String> marcPaths = getMarcPaths(field);
for (String marcPath : marcPaths) {
Expand Down Expand Up @@ -253,4 +263,12 @@ private List<String> getMarcPaths(DataField field) {

return marcPaths;
}

private void addGrouppedElementCardinality(String marcPath, String groupId) {
completenessDAO.getGrouppedElementCardinality().computeIfAbsent(groupId, s -> new TreeMap<>());
completenessDAO.getGrouppedElementCardinality().get(groupId).computeIfAbsent(documentType, s -> new TreeMap<>());
completenessDAO.getGrouppedElementCardinality().get(groupId).computeIfAbsent("all", s -> new TreeMap<>());
count(marcPath, completenessDAO.getGrouppedElementCardinality().get(groupId).get(documentType));
count(marcPath, completenessDAO.getGrouppedElementCardinality().get(groupId).get("all"));
}
}

0 comments on commit 5224ef8

Please sign in to comment.