1 |
388
|
jones
|
/**
|
2 |
|
|
* '$RCSfile$'
|
3 |
|
|
* Purpose: A Class that represents all node info from the database
|
4 |
|
|
* Copyright: 2000 Regents of the University of California and the
|
5 |
|
|
* National Center for Ecological Analysis and Synthesis
|
6 |
|
|
* Authors: Matt Jones
|
7 |
|
|
*
|
8 |
|
|
* '$Author$'
|
9 |
|
|
* '$Date$'
|
10 |
|
|
* '$Revision$'
|
11 |
669
|
jones
|
*
|
12 |
|
|
* This program is free software; you can redistribute it and/or modify
|
13 |
|
|
* it under the terms of the GNU General Public License as published by
|
14 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
15 |
|
|
* (at your option) any later version.
|
16 |
|
|
*
|
17 |
|
|
* This program is distributed in the hope that it will be useful,
|
18 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
|
|
* GNU General Public License for more details.
|
21 |
|
|
*
|
22 |
|
|
* You should have received a copy of the GNU General Public License
|
23 |
|
|
* along with this program; if not, write to the Free Software
|
24 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
25 |
388
|
jones
|
*/
|
26 |
|
|
|
27 |
|
|
package edu.ucsb.nceas.metacat;
|
28 |
|
|
|
29 |
2663
|
sgarg
|
import org.apache.log4j.Logger;
|
30 |
|
|
|
31 |
388
|
jones
|
/**
|
32 |
|
|
* A utility class that encapsulates a node and its data
|
33 |
|
|
*/
|
34 |
|
|
public class NodeRecord {
|
35 |
2762
|
sgarg
|
private long nodeid = -1;
|
36 |
|
|
private long parentnodeid = -1;
|
37 |
|
|
private long nodeindex = -1;
|
38 |
|
|
private String nodename = null;
|
39 |
|
|
private String nodeprefix = null;
|
40 |
|
|
private String nodetype = null;
|
41 |
|
|
private String nodedata = null;
|
42 |
|
|
private float nodedatanumerical = -1;
|
43 |
2663
|
sgarg
|
private Logger logMetacat = Logger.getLogger(NodeRecord.class);
|
44 |
388
|
jones
|
|
45 |
|
|
/**
|
46 |
|
|
* Constructor
|
47 |
|
|
*/
|
48 |
|
|
public NodeRecord(long nodeid, long parentnodeid, long nodeindex,
|
49 |
826
|
bojilova
|
String nodetype, String nodename, String nodeprefix,
|
50 |
|
|
String nodedata) {
|
51 |
388
|
jones
|
this.nodeid = nodeid;
|
52 |
|
|
this.parentnodeid = parentnodeid;
|
53 |
|
|
this.nodeindex = nodeindex;
|
54 |
|
|
this.nodename = nodename;
|
55 |
826
|
bojilova
|
this.nodeprefix = nodeprefix;
|
56 |
388
|
jones
|
this.nodetype = nodetype;
|
57 |
|
|
this.nodedata = nodedata;
|
58 |
|
|
}
|
59 |
1501
|
tao
|
|
60 |
2762
|
sgarg
|
|
61 |
|
|
public NodeRecord(long nodeid, long parentnodeid, long nodeindex,
|
62 |
|
|
String nodetype, String nodename, String nodeprefix,
|
63 |
|
|
String nodedata, float nodedatanumerical) {
|
64 |
|
|
this.nodeid = nodeid;
|
65 |
|
|
this.parentnodeid = parentnodeid;
|
66 |
|
|
this.nodeindex = nodeindex;
|
67 |
|
|
this.nodename = nodename;
|
68 |
|
|
this.nodeprefix = nodeprefix;
|
69 |
|
|
this.nodetype = nodetype;
|
70 |
|
|
this.nodedata = nodedata;
|
71 |
|
|
this.nodedatanumerical = nodedatanumerical;
|
72 |
|
|
}
|
73 |
|
|
|
74 |
1501
|
tao
|
/** Get functions*/
|
75 |
|
|
public long getNodeId()
|
76 |
|
|
{
|
77 |
|
|
return nodeid;
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
public long getParentNodeId()
|
81 |
|
|
{
|
82 |
|
|
return parentnodeid;
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
public long getNodeIndex()
|
86 |
|
|
{
|
87 |
|
|
return nodeindex;
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
public String getNodeName()
|
91 |
|
|
{
|
92 |
|
|
return nodename;
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
public String getNodeType()
|
96 |
|
|
{
|
97 |
|
|
return nodetype;
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
public String getNodePrefix()
|
101 |
|
|
{
|
102 |
|
|
return nodeprefix;
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
public String getNodeData()
|
106 |
|
|
{
|
107 |
|
|
return nodedata;
|
108 |
|
|
}
|
109 |
2762
|
sgarg
|
|
110 |
|
|
public float getNodeDataNumerical()
|
111 |
|
|
{
|
112 |
|
|
return nodedatanumerical;
|
113 |
|
|
}
|
114 |
3144
|
cjones
|
|
115 |
|
|
/** Setter methods **/
|
116 |
|
|
|
117 |
|
|
/**
|
118 |
|
|
* A method used to set the node id of the current node
|
119 |
|
|
*
|
120 |
|
|
* @param id the new value of the id
|
121 |
|
|
*/
|
122 |
|
|
public void setNodeId (long id){
|
123 |
|
|
this.nodeid = id;
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
/**
|
127 |
|
|
* A method used to set the node parent id of the current node
|
128 |
|
|
*
|
129 |
|
|
* @param parentid the new value of the parent id
|
130 |
|
|
*/
|
131 |
|
|
public void setParentNodeId (long parentid){
|
132 |
|
|
this.parentnodeid = parentid;
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
/**
|
136 |
|
|
* A method used to set the node name of the current node
|
137 |
|
|
*
|
138 |
|
|
* @param name the new value of the node name
|
139 |
|
|
*/
|
140 |
|
|
public void setNodeName (String name){
|
141 |
|
|
this.nodename = name;
|
142 |
|
|
}
|
143 |
|
|
|
144 |
|
|
/**
|
145 |
|
|
* A method used to set the node prefix of the current node
|
146 |
|
|
*
|
147 |
|
|
* @param prefix the new value of the node prefix
|
148 |
|
|
*/
|
149 |
|
|
public void setNodePrefix (String prefix){
|
150 |
|
|
this.nodeprefix = prefix;
|
151 |
|
|
}
|
152 |
|
|
|
153 |
|
|
/**
|
154 |
|
|
* A method used to set the node index of the current node
|
155 |
|
|
*
|
156 |
|
|
* @param index the new value of the node index
|
157 |
|
|
*/
|
158 |
|
|
public void setNodeIndex (long index){
|
159 |
|
|
this.nodeindex = index;
|
160 |
|
|
}
|
161 |
|
|
|
162 |
|
|
/**
|
163 |
|
|
* A method used to set the node type of the current node
|
164 |
|
|
*
|
165 |
|
|
* @param type the new value of the node type
|
166 |
|
|
*/
|
167 |
|
|
public void setNodeType (String type){
|
168 |
|
|
this.nodetype = type;
|
169 |
|
|
}
|
170 |
|
|
|
171 |
|
|
/**
|
172 |
|
|
* A method used to set the node data of the current node
|
173 |
|
|
*
|
174 |
|
|
* @param data the new value of the node data
|
175 |
|
|
*/
|
176 |
|
|
public void setNodeData (String data){
|
177 |
|
|
this.nodedata = data;
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
/**
|
181 |
|
|
* A method used to set the numerical node data of the current node
|
182 |
|
|
*
|
183 |
|
|
* @param datanumerical the new value of the numerical node data
|
184 |
|
|
*/
|
185 |
|
|
public void setNodeDataNumerical (float datanumerical){
|
186 |
|
|
this.nodedatanumerical = datanumerical;
|
187 |
|
|
}
|
188 |
|
|
|
189 |
1546
|
tao
|
/** Method compare two records */
|
190 |
|
|
public boolean contentEquals(NodeRecord record)
|
191 |
|
|
{
|
192 |
|
|
boolean flag = true;
|
193 |
2663
|
sgarg
|
logMetacat.info("First nodetype: "+this.nodetype);
|
194 |
|
|
logMetacat.info("Second nodetype: "+record.getNodeType());
|
195 |
|
|
logMetacat.info("First nodename: "+this.nodename);
|
196 |
|
|
logMetacat.info("Second nodename: "+record.getNodeName());
|
197 |
|
|
logMetacat.info("First nodeprefix: "+this.nodeprefix);
|
198 |
|
|
logMetacat.info("Second nodeprefix: "+record.getNodePrefix());
|
199 |
|
|
logMetacat.info("First nodedata: "+this.nodedata);
|
200 |
|
|
logMetacat.info("Second nodedata: "+record.getNodeData());
|
201 |
1546
|
tao
|
if ((this.nodename == null && record.getNodeName() != null) ||
|
202 |
|
|
(this.nodename != null && record.getNodeName() == null) ||
|
203 |
|
|
(this.nodename != null && record.getNodeName() != null &&
|
204 |
|
|
!(this.nodename).equals(record.getNodeName())))
|
205 |
|
|
{
|
206 |
|
|
//compare nodename
|
207 |
|
|
flag = false;
|
208 |
|
|
}
|
209 |
|
|
else if ((this.nodetype == null && record.getNodeType() != null) ||
|
210 |
|
|
(this.nodetype != null && record.getNodeType() == null) ||
|
211 |
|
|
(this.nodetype != null && record.getNodeType() != null &&
|
212 |
|
|
!(this.nodetype).equals(record.getNodeType())))
|
213 |
|
|
{
|
214 |
|
|
// compare node type
|
215 |
|
|
flag = false;
|
216 |
|
|
}
|
217 |
|
|
else if ((this.nodeprefix == null && record.getNodePrefix() != null) ||
|
218 |
|
|
(this.nodeprefix != null && record.getNodePrefix() == null) ||
|
219 |
|
|
(this.nodeprefix != null && record.getNodePrefix() != null &&
|
220 |
|
|
!(this.nodeprefix).equals(record.getNodePrefix())))
|
221 |
|
|
{
|
222 |
|
|
// compare node prefix
|
223 |
|
|
flag = false;
|
224 |
|
|
}
|
225 |
|
|
else if ((this.nodedata == null && record.getNodeData() != null) ||
|
226 |
|
|
(this.nodedata != null && record.getNodeData() == null) ||
|
227 |
|
|
(this.nodedata != null && record.getNodeData() != null &&
|
228 |
|
|
!(this.nodedata).equals(record.getNodeData())))
|
229 |
|
|
{
|
230 |
|
|
// compare node data
|
231 |
|
|
flag = false;
|
232 |
|
|
}
|
233 |
|
|
return flag;
|
234 |
|
|
|
235 |
|
|
}//contentEquals
|
236 |
388
|
jones
|
}
|