Allow rda keywords with text fields to be stored to the elastic as regular tags

This commit is contained in:
George Kalampokis 2020-06-12 18:19:32 +03:00
parent c7892f45df
commit 4cf46aea14
1 changed files with 16 additions and 10 deletions

View File

@ -997,23 +997,29 @@ public class DatasetManager {
value.elements().forEachRemaining(element -> {
try {
Map<String, String> data = mapper.readValue(element.asText(), HashMap.class);
Tag tag = new Tag();
if(tags.stream().anyMatch(intag -> intag.getName().equals(data.get("name")))) {
tag = tags.stream().filter(intag -> intag.getName().equals(data.get("name"))).findFirst().get();
} else {
tag.setName(data.get("name"));
tag.setId(data.get("id"));
}
if (wizardModel.getTags().stream().noneMatch(intag -> intag.getName().equals(data.get("name")))) {
wizardModel.getTags().add(tag);
}
this.addTag(tags, wizardModel.getTags(), data.get("id"), data.get("name"));
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
});
} else {
this.addTag(tags, wizardModel.getTags(), "", value.asText());
}
});
}
}
private void addTag(List<Tag> srcTags, List<Tag> dstTags, String id, String name) {
Tag tag = new Tag();
if(srcTags.stream().anyMatch(intag -> intag.getName().equals(name))) {
tag = srcTags.stream().filter(intag -> intag.getName().equals(name)).findFirst().get();
} else {
tag.setName(name);
tag.setId(id);
}
if (dstTags.stream().noneMatch(intag -> intag.getName().equals(name))) {
dstTags.add(tag);
}
}
}