comparison src/main/java/de/mpiwg/itgroup/ismi/merge/ImportMerge.java @ 134:25bfcc9d757c

effort to re-use more relations when saving entities. new replaceMultipleSourceRelations() and changes to use it. changes for renamed replaceUniqueSourceRelation().
author casties
date Fri, 24 Feb 2017 20:25:33 +0100
parents 28a0c2726466
children 3c585df9f874
comparison
equal deleted inserted replaced
133:5ccd6e709f95 134:25bfcc9d757c
217 return; 217 return;
218 } 218 }
219 Long source_id = rel.getSourceId(); 219 Long source_id = rel.getSourceId();
220 Long target_id = rel.getTargetId(); 220 Long target_id = rel.getTargetId();
221 if (source_id == null) { 221 if (source_id == null) {
222 // no source id
222 importNodeMsg = "Relation has no source_id!"; 223 importNodeMsg = "Relation has no source_id!";
223 return; 224 return;
224 } else if (target_id == null) { 225 } else if (target_id == null) {
226 // no target id
225 importNodeMsg = "Relation has no target_id!"; 227 importNodeMsg = "Relation has no target_id!";
226 return; 228 return;
227 } else { 229 } else {
230 // get source and target Entities
228 Entity sourceEnt = getWrapper().getEntityById(source_id); 231 Entity sourceEnt = getWrapper().getEntityById(source_id);
229 Entity targetEnt = getWrapper().getEntityById(target_id); 232 Entity targetEnt = getWrapper().getEntityById(target_id);
230 if (sourceEnt == null) { 233 if (sourceEnt == null) {
231 importNodeMsg = "Relation source does not exist!"; 234 importNodeMsg = "Relation source does not exist!";
232 } else if (targetEnt == null) { 235 } else if (targetEnt == null) {
233 importNodeMsg = "Relation target does not exist!"; 236 importNodeMsg = "Relation target does not exist!";
234 } else { 237 } else {
235 if (sourceEnt.isLightweight()) { 238 if (sourceEnt.isLightweight()) {
236 sourceEnt = getWrapper().getEntityContent(sourceEnt); 239 sourceEnt = getWrapper().getEntityContent(sourceEnt);
237 } 240 }
241 // get existing Relation
238 Relation systemRel = sourceEnt.getSourceRelation(relName, target_id); 242 Relation systemRel = sourceEnt.getSourceRelation(relName, target_id);
239 if ((systemRel != null) && (systemRel.getObjectClass().equals(rel.getObjectClass()))) { 243 if ((systemRel != null) && (systemRel.getObjectClass().equals(rel.getObjectClass()))) {
240 // TODO: also check Relation attributes 244 // TODO: also check Relation attributes
241 importNodeMsg = "Same Relation exists already!"; 245 importNodeMsg = "Same Relation exists already!";
242 return; 246 return;