Mercurial > hg > ismi-richfaces
diff src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/MisattributionTable.java @ 136:502ae5b1a07d
fixing bugs from re-use efforts. misc cleanups.
author | casties |
---|---|
date | Thu, 02 Mar 2017 19:48:58 +0100 |
parents | aef031e76278 |
children |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/MisattributionTable.java Fri Feb 24 20:27:44 2017 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/MisattributionTable.java Thu Mar 02 19:48:58 2017 +0100 @@ -101,7 +101,7 @@ } /** - * Save all misattributions. + * Save all misattributions on this text. * * Deletes removed misattributions. * @@ -112,26 +112,27 @@ public Entity saveMisattributions(Entity text) throws Exception { // remember old misattributions List<Relation> oldRels = text.getSourceRelations(Misattribution.HAS_AUTHOR_MISATT, Misattribution.MISATT); - // delete old relations - text.removeAllSourceRelationsByName(Misattribution.HAS_AUTHOR_MISATT); - // create new misattributions + List<Entity> misatts = new ArrayList<Entity>(); + // save new misattributions for (Misattribution misatt : this.getMisattList()) { - text = misatt.saveAndGetMisattribution(text); + misatt.saveMisattribution(text); + misatts.add(misatt.getMisatt()); } + // update relations + this.replaceMultipleSourceRelations(text, misatts, Misattribution.MISATT, Misattribution.HAS_AUTHOR_MISATT); // check for orphaned old misattributions for (Relation rel : oldRels) { - boolean match = false; - for (Misattribution mi : this.getMisattList()) { - Entity miEnt = mi.getMisatt(); + boolean found = false; + for (Entity miEnt : misatts) { if (miEnt != null && rel.getTargetId() == miEnt.getId()) { - match = true; + found = true; break; } } - if (!match) { - Entity ent = getWrapper().getEntityById(rel.getTargetId()); - logger.warn("Orphaned MISATTRIBUTION will be deleted: " + ent); - getWrapper().removeCurrentVersionEntity(ent, getUserName()); + if (!found) { + Entity miEnt = getWrapper().getEntityById(rel.getTargetId()); + logger.warn("Orphaned MISATTRIBUTION will be deleted: " + miEnt); + getWrapper().removeCurrentVersionEntity(miEnt, getUserName()); } } return text;