Mercurial > hg > ismi-richfaces
comparison src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractISMIBean.java @ 136:502ae5b1a07d
fixing bugs from re-use efforts. misc cleanups.
author | casties |
---|---|
date | Thu, 02 Mar 2017 19:48:58 +0100 |
parents | 25bfcc9d757c |
children | df6ca03c4bf9 62d5276ed785 |
comparison
equal
deleted
inserted
replaced
135:0183b8a09717 | 136:502ae5b1a07d |
---|---|
288 return rs; | 288 return rs; |
289 } | 289 } |
290 | 290 |
291 | 291 |
292 /** | 292 /** |
293 * Save references and set relations. | 293 * Save references from this.endNoteRefTable and update relations. |
294 * | 294 * |
295 * @throws Exception | 295 * @throws Exception |
296 */ | 296 */ |
297 protected void prepareEndNoteRefs2Save() throws Exception { | 297 protected void saveReferences() throws Exception { |
298 //REFERENCE -> is_reference_of -> WITNESS | 298 //REFERENCE -> is_reference_of -> WITNESS |
299 List<Entity> refs = new ArrayList<Entity>(); | 299 List<Entity> refs = new ArrayList<Entity>(); |
300 this.entity.removeAllTargetRelationsByName(rel_is_reference_of); | |
301 for (SelectableObject<Reference> so : this.endNoteRefTable.list) { | 300 for (SelectableObject<Reference> so : this.endNoteRefTable.list) { |
302 Reference ref = so.getObj(); | 301 Reference ref = so.getObj(); |
303 Entity ent = ref.getEnt(); | 302 Entity ent = ref.getEnt(); |
304 if (!ent.isPersistent()) { | 303 // save reference Entity |
305 // persist reference Entity | 304 getWrapper().saveEntity(ent, getUserName(), Reference.editReferenceIntent); |
306 getWrapper().saveEntity(ent, getUserName(), Reference.editReferenceIntent); | |
307 } | |
308 refs.add(ent); | 305 refs.add(ent); |
309 } | 306 } |
310 // update relations | 307 // update relations |
311 this.replaceMultipleTargetRelations(entity, refs, REFERENCE, rel_is_reference_of); | 308 this.replaceMultipleTargetRelations(entity, refs, REFERENCE, rel_is_reference_of); |
312 } | 309 } |
1088 * @param lo | 1085 * @param lo |
1089 * @param targetClass | 1086 * @param targetClass |
1090 * @param relName | 1087 * @param relName |
1091 * @param aliasRelName | 1088 * @param aliasRelName |
1092 */ | 1089 */ |
1093 protected void replaceUniqueAliasSourceRelation(Entity ent, AliasListenerObject lo, String targetClass, String relName, String aliasRelName) { | 1090 public void replaceUniqueAliasSourceRelation(Entity ent, AliasListenerObject lo, String targetClass, String relName, String aliasRelName) { |
1094 Entity target = lo.entity; | 1091 Entity target = lo.entity; |
1095 if (target == null || target.getObjectClass() == null) { | 1092 if (target == null || target.getObjectClass() == null) { |
1096 return; | 1093 return; |
1097 } | 1094 } |
1098 if (target.getObjectClass().equals(targetClass)) { | 1095 if (target.getObjectClass().equals(targetClass)) { |
1099 // regular target entity e.g. PLACE | 1096 // regular target entity e.g. PLACE |
1100 ent.replaceUniqueSourceRelation(target, targetClass, relName); | 1097 ent.replaceUniqueSourceRelation(target, targetClass, relName); |
1098 // should not have alias relation | |
1101 ent.removeAllSourceRelationsByName(aliasRelName); | 1099 ent.removeAllSourceRelationsByName(aliasRelName); |
1102 } else if (target.getObjectClass().equals(ALIAS)) { | 1100 } else if (target.getObjectClass().equals(ALIAS)) { |
1103 // e.g. WITNESS -> was_created_in_as -> ALIAS | 1101 // e.g. WITNESS -> was_created_in_as -> ALIAS |
1104 ent.replaceUniqueSourceRelation(target, ALIAS, aliasRelName); | 1102 ent.replaceUniqueSourceRelation(target, ALIAS, aliasRelName); |
1105 // ALIAS -> is_alias_name_of -> PLACE | 1103 // ALIAS -> is_alias_name_of -> PLACE |
1152 Long tarId = oldRel.getTargetId(); | 1150 Long tarId = oldRel.getTargetId(); |
1153 if (newTarIds.contains(tarId)) { | 1151 if (newTarIds.contains(tarId)) { |
1154 // this should not happen | 1152 // this should not happen |
1155 logger.error("Old relation to new target ID:"+oldRel); | 1153 logger.error("Old relation to new target ID:"+oldRel); |
1156 } else { | 1154 } else { |
1157 ent.removeSourceRelation(relName, oldRel.getTargetId()); | 1155 ent.removeSourceRelation(relName, tarId); |
1158 } | 1156 } |
1159 } | 1157 } |
1160 } | 1158 } |
1161 | 1159 |
1162 /** | 1160 /** |
1200 Long srcId = oldRel.getSourceId(); | 1198 Long srcId = oldRel.getSourceId(); |
1201 if (newSrcIds.contains(srcId)) { | 1199 if (newSrcIds.contains(srcId)) { |
1202 // this should not happen | 1200 // this should not happen |
1203 logger.error("Old relation to new source ID:"+oldRel); | 1201 logger.error("Old relation to new source ID:"+oldRel); |
1204 } else { | 1202 } else { |
1205 ent.removeTargetRelation(relName, oldRel.getTargetId()); | 1203 ent.removeTargetRelation(relName, srcId); |
1206 } | 1204 } |
1207 } | 1205 } |
1208 } | 1206 } |
1209 | 1207 |
1210 } | 1208 } |