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