1
|
/**
|
2
|
* Copyright (C) 2014 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.molecular.editor;
|
10
|
|
11
|
import java.util.Arrays;
|
12
|
import java.util.List;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
|
16
|
import eu.etaxonomy.cdm.model.molecular.Sequence;
|
17
|
import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput;
|
18
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
19
|
|
20
|
/**
|
21
|
* @author pplitzner
|
22
|
* @author Ben Stöver
|
23
|
* @date 04.08.2014
|
24
|
*/
|
25
|
public class AlignmentEditorInput extends CdmEntitySessionInput {
|
26
|
|
27
|
private final UUID sequenceNodeUuid;
|
28
|
private Sequence sequenceNode;
|
29
|
|
30
|
public AlignmentEditorInput(UUID sequenceNodeUuid) {
|
31
|
super(false);
|
32
|
this.sequenceNodeUuid = sequenceNodeUuid;
|
33
|
initSession();
|
34
|
}
|
35
|
|
36
|
/**
|
37
|
* Returns the {@link UUID} of the sequence CDM node that should be edited by the {@link AlignmentEditor} this object
|
38
|
* is used with.
|
39
|
*
|
40
|
* @return the uuid of the CDM node to work on
|
41
|
*/
|
42
|
public UUID getSequenceNodeUuid() {
|
43
|
return sequenceNodeUuid;
|
44
|
}
|
45
|
|
46
|
@Override
|
47
|
public int hashCode() {
|
48
|
final int prime = 31;
|
49
|
int result = 1;
|
50
|
result = prime * result
|
51
|
+ ((sequenceNodeUuid == null) ? 0 : sequenceNodeUuid.hashCode());
|
52
|
return result;
|
53
|
}
|
54
|
|
55
|
@Override
|
56
|
public boolean equals(Object obj) {
|
57
|
if (this == obj) {
|
58
|
return true;
|
59
|
}
|
60
|
if (obj == null) {
|
61
|
return false;
|
62
|
}
|
63
|
if (getClass() != obj.getClass()) {
|
64
|
return false;
|
65
|
}
|
66
|
AlignmentEditorInput other = (AlignmentEditorInput) obj;
|
67
|
if (sequenceNodeUuid == null) {
|
68
|
if (other.sequenceNodeUuid != null) {
|
69
|
return false;
|
70
|
}
|
71
|
} else if (!sequenceNodeUuid.equals(other.sequenceNodeUuid)) {
|
72
|
return false;
|
73
|
}
|
74
|
return true;
|
75
|
}
|
76
|
|
77
|
public void setSequenceNode(Sequence sequenceNode) {
|
78
|
this.sequenceNode = sequenceNode;
|
79
|
}
|
80
|
|
81
|
@Override
|
82
|
public List<Sequence> getRootEntities() {
|
83
|
return Arrays.asList(sequenceNode);
|
84
|
}
|
85
|
|
86
|
@Override
|
87
|
public void merge() {
|
88
|
CdmStore.getService(ISequenceService.class).merge(sequenceNode, true);
|
89
|
}
|
90
|
}
|