forked from binfalse/BiVeS-Core
/
ReactionNetworkEntity.java
169 lines (150 loc) · 3.13 KB
/
ReactionNetworkEntity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/**
*
*/
package de.unirostock.sems.bives.ds.rn;
import de.unirostock.sems.bives.ds.GraphEntity;
import de.unirostock.sems.xmlutils.ds.DocumentNode;
import de.unirostock.sems.xmlutils.ds.TreeNode;
/**
* The Class ReactionNetworkEntity representing an entity in a reaction network.
*
* @author Martin Scharm
*/
public abstract class ReactionNetworkEntity
implements GraphEntity
{
/** The id of this entity. */
protected String id;
/** The labels in original doc. */
protected String labelA;
/** The labels in modified doc. */
protected String labelB;
/** The original document. */
protected DocumentNode docA;
/** The modified document. */
protected DocumentNode docB;
/** The single doc flag if in single-doc-operation-mode. */
protected boolean singleDoc;
/**
* Instantiates a new entity.
*
* @param entityId the entity id
* @param labelA the label of that entity in the original document
* @param labelB the label of that entity in the modified document
* @param docA the original document
* @param docB the modified document
*/
public ReactionNetworkEntity (String entityId, String labelA, String labelB, DocumentNode docA, DocumentNode docB)
{
this.id = entityId;
this.labelA = labelA;
this.labelB = labelB;
this.docA = docA;
this.docB = docB;
singleDoc = false;
}
/**
* Sets the original document node.
*
* @param docA the original document node
*/
public void setDocA (DocumentNode docA)
{
this.docA = docA;
}
/**
* Sets the original label.
*
* @param labelA the label in the original document
*/
public void setLabelA (String labelA)
{
this.labelA = labelA;
}
/**
* Sets the modified document node.
*
* @param docB the modified document node
*/
public void setDocB (DocumentNode docB)
{
this.docB = docB;
}
/**
* Sets the modified label.
*
* @param labelB the label in the modified document
*/
public void setLabelB (String labelB)
{
this.labelB = labelB;
}
/**
* Gets the original document node.
*
* @return the original document node
*/
public DocumentNode getA ()
{
return docA;
}
/**
* Gets the modified document node.
*
* @return the modified document node
*/
public DocumentNode getB ()
{
return docB;
}
/**
* Gets the id of the entity.
*
* @return the id
*/
public String getId ()
{
return id;
}
/**
* Gets the label.
*
* @return the label
*/
public String getLabel ()
{
if (labelA == null)
return labelB;
if (labelB == null)
return labelA;
if (labelA.equals (labelB))
return labelA;
return labelA + " -> " + labelB;
}
/**
* Gets the modification of this entity.
*
* @return the modification
*/
public int getModification ()
{
if (singleDoc)
return UNMODIFIED;
if (labelA == null)
return INSERT;
if (labelB == null)
return DELETE;
if (!labelA.equals (labelB)
|| docA.hasModification (TreeNode.MODIFIED|TreeNode.SUB_MODIFIED)
|| docB.hasModification (TreeNode.MODIFIED|TreeNode.SUB_MODIFIED))
return MODIFIED;
return UNMODIFIED;
}
/**
* Sets the single document flag.
*/
public void setSingleDocument ()
{
singleDoc = true;
}
}