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
|
|
12
|
import java.util.Arrays;
|
13
|
import java.util.List;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
|
17
|
import eu.etaxonomy.cdm.model.molecular.Sequence;
|
18
|
import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput;
|
19
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
20
|
|
21
|
|
22
|
|
23
|
/**
|
24
|
* @author pplitzner
|
25
|
* @author Ben Stöver
|
26
|
* @date 04.08.2014
|
27
|
*/
|
28
|
public class AlignmentEditorInput extends CdmEntitySessionInput {
|
29
|
|
30
|
private final UUID sequenceNodeUuid;
|
31
|
private Sequence sequenceNode;
|
32
|
|
33
|
public AlignmentEditorInput(UUID sequenceNodeUuid) {
|
34
|
super(false);
|
35
|
this.sequenceNodeUuid = sequenceNodeUuid;
|
36
|
initSession();
|
37
|
}
|
38
|
|
39
|
|
40
|
/**
|
41
|
* Returns the {@link UUID} of the sequence CDM node that should be edited by the {@link AlignmentEditor} this object
|
42
|
* is used with.
|
43
|
*
|
44
|
* @return the uuid of the CDM node to work on
|
45
|
*/
|
46
|
public UUID getSequenceNodeUuid() {
|
47
|
return sequenceNodeUuid;
|
48
|
}
|
49
|
|
50
|
|
51
|
@Override
|
52
|
public int hashCode() {
|
53
|
final int prime = 31;
|
54
|
int result = 1;
|
55
|
result = prime * result
|
56
|
+ ((sequenceNodeUuid == null) ? 0 : sequenceNodeUuid.hashCode());
|
57
|
return result;
|
58
|
}
|
59
|
|
60
|
|
61
|
@Override
|
62
|
public boolean equals(Object obj) {
|
63
|
if (this == obj) {
|
64
|
return true;
|
65
|
}
|
66
|
if (obj == null) {
|
67
|
return false;
|
68
|
}
|
69
|
if (getClass() != obj.getClass()) {
|
70
|
return false;
|
71
|
}
|
72
|
AlignmentEditorInput other = (AlignmentEditorInput) obj;
|
73
|
if (sequenceNodeUuid == null) {
|
74
|
if (other.sequenceNodeUuid != null) {
|
75
|
return false;
|
76
|
}
|
77
|
} else if (!sequenceNodeUuid.equals(other.sequenceNodeUuid)) {
|
78
|
return false;
|
79
|
}
|
80
|
return true;
|
81
|
}
|
82
|
|
83
|
|
84
|
public void setSequenceNode(Sequence sequenceNode) {
|
85
|
this.sequenceNode = sequenceNode;
|
86
|
}
|
87
|
|
88
|
/* (non-Javadoc)
|
89
|
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
|
90
|
*/
|
91
|
@Override
|
92
|
public List<Sequence> getRootEntities() {
|
93
|
return Arrays.asList(sequenceNode);
|
94
|
}
|
95
|
|
96
|
|
97
|
/* (non-Javadoc)
|
98
|
* @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
|
99
|
*/
|
100
|
@Override
|
101
|
public void merge() {
|
102
|
CdmStore.getService(ISequenceService.class).merge(sequenceNode, true);
|
103
|
|
104
|
}
|
105
|
}
|