Mercurial > hg > ismi-richfaces
comparison src/main/java/de/mpiwg/itgroup/ismi/merge/ImportMerge.java @ 96:895bf7494d17
first version of new import-merge.
author | casties |
---|---|
date | Thu, 27 Oct 2016 20:19:57 +0200 |
parents | |
children | 13b313ae1af8 |
comparison
equal
deleted
inserted
replaced
95:12af756065b5 | 96:895bf7494d17 |
---|---|
1 package de.mpiwg.itgroup.ismi.merge; | |
2 | |
3 import java.io.File; | |
4 import java.io.FileInputStream; | |
5 import java.io.InputStreamReader; | |
6 import java.io.Reader; | |
7 import java.io.Serializable; | |
8 import java.util.ArrayList; | |
9 import java.util.HashMap; | |
10 import java.util.List; | |
11 import java.util.Map; | |
12 | |
13 import javax.faces.event.ActionEvent; | |
14 import javax.faces.model.SelectItem; | |
15 | |
16 import org.apache.commons.lang.StringUtils; | |
17 import org.apache.log4j.Logger; | |
18 import org.mpi.openmind.repository.bo.Attribute; | |
19 import org.mpi.openmind.repository.bo.Entity; | |
20 import org.mpi.openmind.repository.bo.Node; | |
21 import org.mpi.openmind.repository.bo.Relation; | |
22 import org.mpi.openmind.repository.utils.CsvNodeListReader; | |
23 | |
24 import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean; | |
25 | |
26 public class ImportMerge extends AbstractISMIBean implements Serializable { | |
27 | |
28 private static Logger logger = Logger.getLogger(ImportMerge.class); | |
29 | |
30 private static final long serialVersionUID = 1L; | |
31 | |
32 private String importFilename = "/var/tmp/ismi-import.csv"; | |
33 private String importFileMsg = null; | |
34 | |
35 private List<Node> importNodeList; | |
36 private int importNodeIdx; | |
37 private int importNodeListLength = 0; | |
38 private Node importNode; | |
39 private String importNodeMsg; | |
40 | |
41 public static String FIRST_VALUE = "old value"; | |
42 public static String SECOND_VALUE = "new value"; | |
43 public static String IGNORE = "ignore"; | |
44 public static String TAKE = "take"; | |
45 | |
46 private boolean showAttributeMapping = false; | |
47 private boolean showSrcRelationMapping = false; | |
48 private boolean showTarRelationMapping = false; | |
49 | |
50 private boolean entitiesLoaded = false; | |
51 | |
52 private Map<String, String> firstAttMap = new HashMap<String, String>(); | |
53 private Map<String, String> secondAttMap = new HashMap<String, String>(); | |
54 | |
55 private Entity firstEntity; | |
56 private Entity secondEntity; | |
57 | |
58 private String firstId; | |
59 private String secondId; | |
60 | |
61 private Entity entResult; | |
62 private List<Attribute> resultAtts; | |
63 private List<Relation> resultSrcRels; | |
64 private List<Relation> resultTarRels; | |
65 | |
66 private List<String> attLabels; | |
67 private Map<String, String> selectedAtts; | |
68 | |
69 Map<Long, String> selectedFirstSrcRelations; | |
70 Map<Long, String> selectedSecondSrcRelations; | |
71 Map<Long, String> selectedFirstTarRelations; | |
72 Map<Long, String> selectedSecondTarRelations; | |
73 | |
74 | |
75 public ImportMerge() { | |
76 } | |
77 | |
78 public void loadImportFile(ActionEvent event) { | |
79 reset(); | |
80 try { | |
81 File importFile = new File(this.importFilename); | |
82 if (!importFile.canRead()) { | |
83 this.importFileMsg = "File missing!"; | |
84 return; | |
85 } | |
86 Reader importReader = new InputStreamReader(new FileInputStream(importFile), "UTF-8"); | |
87 importNodeList = CsvNodeListReader.readCsv(importReader); | |
88 | |
89 this.importNodeListLength = importNodeList.size(); | |
90 this.importFileMsg = importNodeListLength + " Nodes"; | |
91 this.importNodeIdx = 0; | |
92 loadImportNode(null); | |
93 //this.reset(); | |
94 //this.firstEntity = (Entity) importNodeList.get(importNodeIdx); | |
95 | |
96 } catch (Exception e) { | |
97 addErrorMsg("The import file could no be loaded."); | |
98 addErrorMsg("Error: "+e); | |
99 } | |
100 } | |
101 | |
102 public void loadImportNode(ActionEvent event) { | |
103 reset(); | |
104 try { | |
105 importNode = importNodeList.get(importNodeIdx); | |
106 importNodeMsg = null; | |
107 firstEntity = null; | |
108 secondEntity = null; | |
109 | |
110 if (importNode.getNodeType().equals("ATTRIBUTE")) { | |
111 Attribute att = (Attribute) importNode; | |
112 String attName = att.getName(); | |
113 if (attName == null) { | |
114 importNodeMsg = "Attribute has no name!"; | |
115 return; | |
116 } | |
117 Long source_id = att.getSourceId(); | |
118 if (source_id == null) { | |
119 importNodeMsg = "Attribute has no source_id to attach to!"; | |
120 return; | |
121 } else { | |
122 Entity systemEnt = getWrapper().getEntityById(source_id); | |
123 if (systemEnt != null) { | |
124 if (systemEnt.isLightweight()) { | |
125 systemEnt = getWrapper().getEntityContent(systemEnt); | |
126 } | |
127 Attribute systemAtt = systemEnt.getAttributeByName(attName); | |
128 if ((systemAtt != null) && (systemAtt.getOwnValue().equals(att.getOwnValue()))) { | |
129 importNodeMsg = "Same attribute exists already!"; | |
130 return; | |
131 } | |
132 // create new Entity with this Attribute | |
133 Entity newEnt = (Entity) systemEnt.clone(); | |
134 newEnt.addAttribute(att); | |
135 this.secondEntity = newEnt; | |
136 // compare with old version | |
137 this.firstEntity = systemEnt; | |
138 } else { | |
139 importNodeMsg = "Entity for Attribute does not exist!"; | |
140 return; | |
141 } | |
142 } | |
143 } else if (importNode.getNodeType().equals("ENTITY")) { | |
144 Entity ent = (Entity) importNode; | |
145 Long id = ent.getId(); | |
146 if (id == null) { | |
147 // new Entity | |
148 this.secondEntity = ent; | |
149 // what to use to compare? | |
150 this.firstEntity = new Entity(); | |
151 deployDifferences(); | |
152 | |
153 } else { | |
154 // entity exists | |
155 Entity systemEnt = getWrapper().getEntityById(id); | |
156 if (systemEnt != null) { | |
157 if (systemEnt.isLightweight()) { | |
158 systemEnt = getWrapper().getEntityContent(systemEnt); | |
159 } | |
160 importNodeMsg = "Entity exists (but may be different)."; | |
161 // TODO: does it make sense to check for equality? | |
162 this.secondEntity = ent; | |
163 // compare with old version | |
164 this.firstEntity = systemEnt; | |
165 } else { | |
166 importNodeMsg = "Entity does no longer exist!"; | |
167 // TODO: try to undelete? | |
168 this.firstEntity = new Entity(); | |
169 this.secondEntity = ent; | |
170 } | |
171 } | |
172 } else if (importNode.getNodeType().equals("RELATION")) { | |
173 Relation rel = (Relation) importNode; | |
174 String relName = rel.getObjectClass(); | |
175 if (relName == null) { | |
176 importNodeMsg = "Relation has no name!"; | |
177 return; | |
178 } | |
179 Long source_id = rel.getSourceId(); | |
180 Long target_id = rel.getTargetId(); | |
181 if (source_id == null) { | |
182 importNodeMsg = "Relation has no source_id!"; | |
183 return; | |
184 } else if (target_id == null) { | |
185 importNodeMsg = "Relation has no target_id!"; | |
186 return; | |
187 } else { | |
188 Entity sourceEnt = getWrapper().getEntityById(source_id); | |
189 Entity targetEnt = getWrapper().getEntityById(target_id); | |
190 if (sourceEnt == null) { | |
191 importNodeMsg = "Relation source does not exist!"; | |
192 } else if (targetEnt == null) { | |
193 importNodeMsg = "Relation target does not exist!"; | |
194 } else { | |
195 if (sourceEnt.isLightweight()) { | |
196 sourceEnt = getWrapper().getEntityContent(sourceEnt); | |
197 } | |
198 Relation systemRel = sourceEnt.getSourceRelation(relName, target_id); | |
199 if ((systemRel != null) && (systemRel.getObjectClass().equals(rel.getObjectClass()))) { | |
200 // TODO: also check Relation attributes | |
201 importNodeMsg = "Same Relation exists already!"; | |
202 return; | |
203 } | |
204 // create new Entity with this Relation | |
205 Entity newEnt = (Entity) sourceEnt.clone(); | |
206 newEnt.addSourceRelation(rel); | |
207 this.secondEntity = newEnt; | |
208 // compare with old version | |
209 this.firstEntity = sourceEnt; | |
210 } | |
211 } | |
212 } | |
213 } catch (Exception e) { | |
214 addErrorMsg("The import Node could no be loaded."); | |
215 } | |
216 } | |
217 | |
218 public void skipCurrentNode(ActionEvent event) { | |
219 importNodeIdx += 1; | |
220 if (importNodeIdx >= importNodeList.size()) { | |
221 importNodeIdx = importNodeList.size() - 1; | |
222 } | |
223 if (importNodeIdx < 0) { | |
224 importNodeIdx = 0; | |
225 } | |
226 loadImportNode(null); | |
227 } | |
228 | |
229 public void loadFirstEntity(ActionEvent event) { | |
230 reset(); | |
231 try { | |
232 if (firstEntity != null && secondEntity != null) { | |
233 deployDifferences(); | |
234 } else { | |
235 if (importNodeMsg != null) { | |
236 addErrorMsg(importNodeMsg); | |
237 } | |
238 } | |
239 } catch (Exception e) { | |
240 addErrorMsg("The first entity could no be loaded."); | |
241 } | |
242 } | |
243 | |
244 @Override | |
245 public void reset() { | |
246 this.attLabels = new ArrayList<String>(); | |
247 this.selectedAtts = new HashMap<String, String>(); | |
248 this.selectedFirstSrcRelations = new HashMap<Long, String>(); | |
249 this.selectedSecondSrcRelations = new HashMap<Long, String>(); | |
250 this.selectedFirstTarRelations = new HashMap<Long, String>(); | |
251 this.selectedSecondTarRelations = new HashMap<Long, String>(); | |
252 this.entResult = null; | |
253 | |
254 this.entitiesLoaded = false; | |
255 this.showAttributeMapping = false; | |
256 this.showSrcRelationMapping = false; | |
257 this.showTarRelationMapping = false; | |
258 } | |
259 | |
260 public void listenerExecuteMerge() { | |
261 this.executeMerge(); | |
262 getAppBean().getSimpleSearchCache().setMapDirty(true); | |
263 } | |
264 | |
265 private void deployDifferences() { | |
266 this.showAttributeMapping = true; | |
267 this.showSrcRelationMapping = true; | |
268 this.showTarRelationMapping = true; | |
269 this.entitiesLoaded = true; | |
270 if (this.firstEntity != null && this.secondEntity != null) { | |
271 /* | |
272 if (firstEntity.isLightweight()) { | |
273 this.firstEntity = getWrapper().getEntityContent(this.firstEntity); | |
274 } | |
275 if (secondEntity.isLightweight()) { | |
276 this.secondEntity = getWrapper().getEntityContent(this.secondEntity); | |
277 } | |
278 | |
279 this.firstEntity = (Entity) firstEntity.clone(); | |
280 this.secondEntity = (Entity) secondEntity.clone(); | |
281 */ | |
282 | |
283 // attributes | |
284 this.attLabels = new ArrayList<String>(); | |
285 this.selectedAtts = new HashMap<String, String>(); | |
286 this.firstAttMap = new HashMap<String, String>(); | |
287 this.secondAttMap = new HashMap<String, String>(); | |
288 | |
289 for (Attribute att : this.firstEntity.getAttributes()) { | |
290 firstAttMap.put(att.getName(), att.getValue()); | |
291 if (!attLabels.contains(att.getName())) { | |
292 attLabels.add(att.getName()); | |
293 selectedAtts.put(att.getName(), FIRST_VALUE); | |
294 } | |
295 } | |
296 | |
297 for (Attribute att : this.secondEntity.getAttributes()) { | |
298 secondAttMap.put(att.getName(), att.getValue()); | |
299 if (!attLabels.contains(att.getName())) { | |
300 attLabels.add(att.getName()); | |
301 selectedAtts.put(att.getName(), FIRST_VALUE); | |
302 } | |
303 } | |
304 | |
305 // source relations | |
306 this.selectedFirstSrcRelations = new HashMap<Long, String>(); | |
307 this.selectedSecondSrcRelations = new HashMap<Long, String>(); | |
308 | |
309 for (Relation rel : this.firstEntity.getSourceRelations()) { | |
310 rel.setTarget(getWrapper().getEntityById(rel.getTargetId())); | |
311 selectedFirstSrcRelations.put(rel.getId(), TAKE); | |
312 } | |
313 | |
314 for (Relation rel : this.secondEntity.getSourceRelations()) { | |
315 rel.setTarget(getWrapper().getEntityById(rel.getTargetId())); | |
316 selectedSecondSrcRelations.put(rel.getId(), TAKE); | |
317 } | |
318 | |
319 // target relations | |
320 this.selectedFirstTarRelations = new HashMap<Long, String>(); | |
321 this.selectedSecondTarRelations = new HashMap<Long, String>(); | |
322 | |
323 for (Relation rel : this.firstEntity.getTargetRelations()) { | |
324 rel.setSource(getWrapper().getEntityById(rel.getSourceId())); | |
325 selectedFirstTarRelations.put(rel.getId(), TAKE); | |
326 } | |
327 | |
328 for (Relation rel : this.secondEntity.getTargetRelations()) { | |
329 rel.setSource(getWrapper().getEntityById(rel.getSourceId())); | |
330 selectedSecondTarRelations.put(rel.getId(), TAKE); | |
331 } | |
332 | |
333 } | |
334 } | |
335 | |
336 public void preview(ActionEvent event) { | |
337 this.generateResultEntity(); | |
338 } | |
339 | |
340 private void executeMerge() { | |
341 | |
342 logger.info("Starting merge execution " + firstEntity.getObjectClass() + " [" + getUserName() + "]" | |
343 + "[firstEntity=" + firstEntity.getId() + ", secondEntity=" + secondEntity.getId() + "]"); | |
344 | |
345 try { | |
346 this.generateResultEntity(); | |
347 if (this.entResult != null) { | |
348 | |
349 this.printMergeInfo(entResult); | |
350 | |
351 this.getWrapper().saveEntity(this.entResult, getSessionUser().getEmail() + "_merge"); | |
352 | |
353 this.getWrapper().removeCurrentVersionEntity(this.firstEntity); | |
354 this.getWrapper().removeCurrentVersionEntity(this.secondEntity); | |
355 | |
356 // the old relations should be removed, before... | |
357 this.updateRelatedOW(this.entResult, getSessionUser().getEmail() + "_merge"); | |
358 | |
359 this.printMergeInfo(entResult); | |
360 | |
361 logger.info("Merge execution 'successful' " + firstEntity.getObjectClass() + " [" + getUserName() + "]" | |
362 + "[firstEntity=" + firstEntity.getId() + ", secondEntity=" + secondEntity.getId() | |
363 + ", generatedEntity=" + entResult.getId() + "]"); | |
364 | |
365 this.firstEntity = null; | |
366 this.secondEntity = null; | |
367 | |
368 addGeneralMsg("The entities were merged successfully"); | |
369 addGeneralMsg("The new entity has the id " + this.entResult.getId()); | |
370 this.reset(); | |
371 } | |
372 } catch (Exception e) { | |
373 printInternalError(e); | |
374 logger.error("[" + getUserName() + "] " + e.getMessage(), e); | |
375 } | |
376 } | |
377 | |
378 private void printMergeInfo(Entity ent) { | |
379 StringBuilder sb = new StringBuilder("\n\n"); | |
380 | |
381 sb.append("-------------------------------------------"); | |
382 sb.append("-----------------------------------------\n"); | |
383 sb.append("Merging result [" + getUserName() + "]\n"); | |
384 sb.append(ent.toString() + "\n"); | |
385 sb.append("Attributes:\n"); | |
386 for (Attribute att : ent.getAttributes()) { | |
387 sb.append("\t" + att.toString() + "\n"); | |
388 } | |
389 | |
390 sb.append("Src Relations:\n"); | |
391 for (Relation src : ent.getSourceRelations()) { | |
392 sb.append("\t" + src.toString() + "\n"); | |
393 } | |
394 | |
395 sb.append("Tar Relations:\n"); | |
396 for (Relation tar : ent.getTargetRelations()) { | |
397 sb.append("\t" + tar.toString() + "\n"); | |
398 } | |
399 | |
400 sb.append("-------------------------------------------"); | |
401 sb.append("-----------------------------------------\n"); | |
402 logger.info(sb.toString()); | |
403 } | |
404 | |
405 public void actionShowTarRelationMapping(ActionEvent event) { | |
406 this.showTarRelationMapping = true; | |
407 } | |
408 | |
409 public void actionHideTarRelationMapping(ActionEvent event) { | |
410 this.showTarRelationMapping = false; | |
411 } | |
412 | |
413 public void actionShowSrcRelationMapping(ActionEvent event) { | |
414 this.showSrcRelationMapping = true; | |
415 } | |
416 | |
417 public void actionHideSrcRelationMapping(ActionEvent event) { | |
418 this.showSrcRelationMapping = false; | |
419 } | |
420 | |
421 public void actionShowAttributeMapping(ActionEvent event) { | |
422 this.showAttributeMapping = true; | |
423 } | |
424 | |
425 public void actionHideAttributeMapping(ActionEvent event) { | |
426 this.showAttributeMapping = false; | |
427 } | |
428 | |
429 private void generateResultEntity() { | |
430 this.entResult = new Entity(); | |
431 this.entResult.setLightweight(false); | |
432 this.entResult.setObjectClass(this.firstEntity.getObjectClass()); | |
433 | |
434 // generating attributes | |
435 try { | |
436 for (String attName : this.selectedAtts.keySet()) { | |
437 String selected = this.selectedAtts.get(attName); | |
438 String value = ""; | |
439 if (selected.equals(FIRST_VALUE)) { | |
440 value = (firstEntity.getAttributeByName(attName) == null) ? "" | |
441 : firstEntity.getAttributeByName(attName).getOwnValue(); | |
442 } else if (selected.equals(SECOND_VALUE)) { | |
443 value = (secondEntity.getAttributeByName(attName) == null) ? "" | |
444 : secondEntity.getAttributeByName(attName).getOwnValue(); | |
445 } | |
446 this.entResult.addAttribute(new Attribute(attName, "text", value)); | |
447 } | |
448 } catch (Exception e) { | |
449 e.printStackTrace(); | |
450 addErrorMsg("Please inform support of this exception: " + e.getMessage()); | |
451 } | |
452 | |
453 // generating source relations | |
454 for (Relation rel : firstEntity.getSourceRelations()) { | |
455 String selectedValue = this.selectedFirstSrcRelations.get(rel.getId()); | |
456 if (StringUtils.isNotEmpty(selectedValue) && selectedValue.equals(TAKE)) { | |
457 if (!this.entResult.containsSourceRelation(rel.getOwnValue(), rel.getTargetId())) { | |
458 this.entResult.addSourceRelation(generateSrcRelation(rel)); | |
459 } | |
460 } | |
461 } | |
462 | |
463 for (Relation rel : secondEntity.getSourceRelations()) { | |
464 String selectedValue = this.selectedSecondSrcRelations.get(rel.getId()); | |
465 if (StringUtils.isNotEmpty(selectedValue) && selectedValue.equals(TAKE)) { | |
466 if (!this.entResult.containsSourceRelation(rel.getOwnValue(), rel.getTargetId())) { | |
467 this.entResult.addSourceRelation(generateSrcRelation(rel)); | |
468 } | |
469 } | |
470 } | |
471 | |
472 // generating target relations | |
473 for (Relation rel : firstEntity.getTargetRelations()) { | |
474 String selectedValue = this.selectedFirstTarRelations.get(rel.getId()); | |
475 if (StringUtils.isNotEmpty(selectedValue) && selectedValue.equals(TAKE)) { | |
476 // ensuring that there is no two equals relations. | |
477 if (!this.entResult.containsTargetRelation(rel.getOwnValue(), rel.getSourceId())) { | |
478 this.entResult.addTargetRelation(generateTarRelation(rel)); | |
479 } | |
480 } | |
481 } | |
482 | |
483 for (Relation rel : secondEntity.getTargetRelations()) { | |
484 String selectedValue = this.selectedSecondTarRelations.get(rel.getId()); | |
485 if (StringUtils.isNotEmpty(selectedValue) && selectedValue.equals(TAKE)) { | |
486 if (!this.entResult.containsTargetRelation(rel.getOwnValue(), rel.getSourceId())) { | |
487 this.entResult.addTargetRelation(generateTarRelation(rel)); | |
488 } | |
489 } | |
490 } | |
491 } | |
492 | |
493 private Relation generateSrcRelation(Relation rel) { | |
494 | |
495 Relation newRel = new Relation(); | |
496 newRel.setOwnValue(rel.getOwnValue()); | |
497 newRel.setTarget(getWrapper().getEntityById(rel.getTargetId())); | |
498 | |
499 return newRel; | |
500 } | |
501 | |
502 private Relation generateTarRelation(Relation rel) { | |
503 Relation newRel = new Relation(); | |
504 newRel.setOwnValue(rel.getOwnValue()); | |
505 newRel.setSource(getWrapper().getEntityById(rel.getSourceId())); | |
506 return newRel; | |
507 } | |
508 | |
509 public List<SelectItem> getAttSelectItems() { | |
510 List<SelectItem> items = new ArrayList<SelectItem>(); | |
511 items.add(new SelectItem(FIRST_VALUE)); | |
512 items.add(new SelectItem(SECOND_VALUE)); | |
513 items.add(new SelectItem(IGNORE)); | |
514 return items; | |
515 } | |
516 | |
517 public List<SelectItem> getRelSelectItems() { | |
518 List<SelectItem> items = new ArrayList<SelectItem>(); | |
519 items.add(new SelectItem(TAKE)); | |
520 items.add(new SelectItem(IGNORE)); | |
521 return items; | |
522 } | |
523 | |
524 public Entity getEntResult() { | |
525 return entResult; | |
526 } | |
527 | |
528 public void setEntResult(Entity entResult) { | |
529 this.entResult = entResult; | |
530 } | |
531 | |
532 public List<Attribute> getResultAtts() { | |
533 return resultAtts; | |
534 } | |
535 | |
536 public void setResultAtts(List<Attribute> resultAtts) { | |
537 this.resultAtts = resultAtts; | |
538 } | |
539 | |
540 public List<Relation> getResultSrcRels() { | |
541 return resultSrcRels; | |
542 } | |
543 | |
544 public void setResultSrcRels(List<Relation> resultSrcRels) { | |
545 this.resultSrcRels = resultSrcRels; | |
546 } | |
547 | |
548 public List<Relation> getResultTarRels() { | |
549 return resultTarRels; | |
550 } | |
551 | |
552 public void setResultTarRels(List<Relation> resultTarRels) { | |
553 this.resultTarRels = resultTarRels; | |
554 } | |
555 | |
556 public Entity getFirstEntity() { | |
557 return firstEntity; | |
558 } | |
559 | |
560 public void setFirstEntity(Entity firstEntity) { | |
561 this.firstEntity = firstEntity; | |
562 } | |
563 | |
564 public Entity getSecondEntity() { | |
565 return secondEntity; | |
566 } | |
567 | |
568 public void setSecondEntity(Entity secondEntity) { | |
569 this.secondEntity = secondEntity; | |
570 } | |
571 | |
572 public String getFirstId() { | |
573 return firstId; | |
574 } | |
575 | |
576 public void setFirstId(String firstId) { | |
577 this.firstId = firstId; | |
578 } | |
579 | |
580 public String getSecondId() { | |
581 return secondId; | |
582 } | |
583 | |
584 public void setSecondId(String secondId) { | |
585 this.secondId = secondId; | |
586 } | |
587 | |
588 public List<String> getAttLabels() { | |
589 return attLabels; | |
590 } | |
591 | |
592 public void setAttLabels(List<String> attLabels) { | |
593 this.attLabels = attLabels; | |
594 } | |
595 | |
596 public Map<String, String> getFirstAttMap() { | |
597 return firstAttMap; | |
598 } | |
599 | |
600 public void setFirstAttMap(Map<String, String> firstAttMap) { | |
601 this.firstAttMap = firstAttMap; | |
602 } | |
603 | |
604 public Map<String, String> getSecondAttMap() { | |
605 return secondAttMap; | |
606 } | |
607 | |
608 public void setSecondAttMap(Map<String, String> secondAttMap) { | |
609 this.secondAttMap = secondAttMap; | |
610 } | |
611 | |
612 public Map<String, String> getSelectedAtts() { | |
613 return selectedAtts; | |
614 } | |
615 | |
616 public void setSelectedAtts(Map<String, String> selectedAtts) { | |
617 this.selectedAtts = selectedAtts; | |
618 } | |
619 | |
620 public boolean isShowAttributeMapping() { | |
621 return showAttributeMapping; | |
622 } | |
623 | |
624 public void setShowAttributeMapping(boolean showAttributeMapping) { | |
625 this.showAttributeMapping = showAttributeMapping; | |
626 } | |
627 | |
628 public boolean isEntitiesLoaded() { | |
629 return entitiesLoaded; | |
630 } | |
631 | |
632 public void setEntitiesLoaded(boolean entitiesLoaded) { | |
633 this.entitiesLoaded = entitiesLoaded; | |
634 } | |
635 | |
636 public Map<Long, String> getSelectedFirstSrcRelations() { | |
637 return selectedFirstSrcRelations; | |
638 } | |
639 | |
640 public void setSelectedFirstSrcRelations(Map<Long, String> selectedFirstSrcRelations) { | |
641 this.selectedFirstSrcRelations = selectedFirstSrcRelations; | |
642 } | |
643 | |
644 public Map<Long, String> getSelectedSecondSrcRelations() { | |
645 return selectedSecondSrcRelations; | |
646 } | |
647 | |
648 public void setSelectedSecondSrcRelations(Map<Long, String> selectedSecondSrcRelations) { | |
649 this.selectedSecondSrcRelations = selectedSecondSrcRelations; | |
650 } | |
651 | |
652 public boolean isShowSrcRelationMapping() { | |
653 return showSrcRelationMapping; | |
654 } | |
655 | |
656 public void setShowSrcRelationMapping(boolean showSrcRelationMapping) { | |
657 this.showSrcRelationMapping = showSrcRelationMapping; | |
658 } | |
659 | |
660 public boolean isShowTarRelationMapping() { | |
661 return showTarRelationMapping; | |
662 } | |
663 | |
664 public void setShowTarRelationMapping(boolean showTarRelationMapping) { | |
665 this.showTarRelationMapping = showTarRelationMapping; | |
666 } | |
667 | |
668 public Map<Long, String> getSelectedFirstTarRelations() { | |
669 return selectedFirstTarRelations; | |
670 } | |
671 | |
672 public void setSelectedFirstTarRelations(Map<Long, String> selectedFirstTarRelations) { | |
673 this.selectedFirstTarRelations = selectedFirstTarRelations; | |
674 } | |
675 | |
676 public Map<Long, String> getSelectedSecondTarRelations() { | |
677 return selectedSecondTarRelations; | |
678 } | |
679 | |
680 public void setSelectedSecondTarRelations(Map<Long, String> selectedSecondTarRelations) { | |
681 this.selectedSecondTarRelations = selectedSecondTarRelations; | |
682 } | |
683 | |
684 /** | |
685 * @return the importFilename | |
686 */ | |
687 public String getImportFilename() { | |
688 return importFilename; | |
689 } | |
690 | |
691 /** | |
692 * @param importFilename | |
693 * the importFilename to set | |
694 */ | |
695 public void setImportFilename(String importFilename) { | |
696 this.importFilename = importFilename; | |
697 } | |
698 | |
699 /** | |
700 * @return the importFileMsg | |
701 */ | |
702 public String getImportFileMsg() { | |
703 return importFileMsg; | |
704 } | |
705 | |
706 /** | |
707 * @param importFileMsg | |
708 * the importFileMsg to set | |
709 */ | |
710 public void setImportFileMsg(String importFileMsg) { | |
711 this.importFileMsg = importFileMsg; | |
712 } | |
713 | |
714 /** | |
715 * @return the importNode | |
716 */ | |
717 public Node getImportNode() { | |
718 return importNode; | |
719 } | |
720 | |
721 public String getImportNodeAsText() { | |
722 String s = ""; | |
723 try { | |
724 String nt = importNode.getNodeType(); | |
725 if (nt.equals("ATTRIBUTE")) { | |
726 Attribute att = (Attribute) importNode; | |
727 s = "ATTRIBUTE " + att.getName() + " [on " + att.getSourceObjectClass() + " " + att.getSourceId() + "] = " + att.getOwnValue(); | |
728 } else if (nt.equals("ENTITY")) { | |
729 Entity ent = (Entity) importNode; | |
730 s = "ENTITY " + ent.getObjectClass() + " [" + ent.getId() + "] = " + ent.getOwnValue(); | |
731 } else if (nt.equals("RELATION")) { | |
732 Relation rel = (Relation) importNode; | |
733 s = "RELATION " + rel.getObjectClass() + " [" + rel.getId() + "] " | |
734 + "source=[" + rel.getSourceObjectClass() + " " + rel.getSourceId() + "] " | |
735 + "target=[" + rel.getTargetObjectClass() + " " + rel.getTargetId() + "]"; | |
736 } else { | |
737 s = importNode.toString(); | |
738 } | |
739 } catch (Exception e) { | |
740 logger.error(e); | |
741 } | |
742 return s; | |
743 } | |
744 | |
745 /** | |
746 * @param importNode the importNode to set | |
747 */ | |
748 public void setImportNode(Node importNode) { | |
749 this.importNode = importNode; | |
750 } | |
751 | |
752 /** | |
753 * @return the importNodeListLength | |
754 */ | |
755 public int getImportNodeListLength() { | |
756 return importNodeListLength; | |
757 } | |
758 | |
759 /** | |
760 * @return the importNodeIdx | |
761 */ | |
762 public int getImportNodeIdx() { | |
763 return importNodeIdx; | |
764 } | |
765 | |
766 /** | |
767 * @param importNodeIdx the importNodeIdx to set | |
768 */ | |
769 public void setImportNodeIdx(int importNodeIdx) { | |
770 this.importNodeIdx = importNodeIdx; | |
771 } | |
772 | |
773 /** | |
774 * @return the importNodeMsg | |
775 */ | |
776 public String getImportNodeMsg() { | |
777 return importNodeMsg; | |
778 } | |
779 | |
780 /** | |
781 * @param importNodeMsg the importNodeMsg to set | |
782 */ | |
783 public void setImportNodeMsg(String importNodeMsg) { | |
784 this.importNodeMsg = importNodeMsg; | |
785 } | |
786 | |
787 } |