1 | |
---|
2 | package eu.clarin.cmdi.vlo.config; |
---|
3 | |
---|
4 | import java.io.File; |
---|
5 | import org.simpleframework.xml.Element; |
---|
6 | import org.simpleframework.xml.Root; |
---|
7 | |
---|
8 | /** |
---|
9 | * A dataRoot describes the meta data sources. |
---|
10 | * |
---|
11 | * In an XML file, a dataRoot is reflected like this:<br><br> |
---|
12 | * |
---|
13 | * {@literal <DataRoot>} |
---|
14 | * {@literal<originName>}name{@literal</originName>} |
---|
15 | * {@literal<rootFile>}topLevelMetadataDirectory/{@literal</rootFile>} |
---|
16 | * {@literal<prefix>}startOfUrl{@literal</prefix>} |
---|
17 | * {@literal<tostrip>}leftPartOfRootFile{@literal</tostrip>} |
---|
18 | * {@literal<deleteFirst>}falseOrTrue{@literal</deleteFirst>} |
---|
19 | * {@literal</DataRoot>} |
---|
20 | * |
---|
21 | * @author keeloo |
---|
22 | */ |
---|
23 | @Root // Simple directive |
---|
24 | public class DataRoot extends Object { |
---|
25 | |
---|
26 | /** |
---|
27 | * Constructor method |
---|
28 | */ |
---|
29 | public DataRoot (){ |
---|
30 | } |
---|
31 | |
---|
32 | /** |
---|
33 | * Constructor method |
---|
34 | * |
---|
35 | * @param originName name describing the meta data |
---|
36 | * @param rootFile top level directory in which the meta data is stored |
---|
37 | * @param prefix left part of the rootFile |
---|
38 | * @param toStrip if you want to create the URL to the meta data, this is |
---|
39 | * the part to be removed from the rootFile |
---|
40 | * @param deleteFirst |
---|
41 | */ |
---|
42 | public DataRoot(String originName, File rootFile, String prefix, String toStrip, Boolean deleteFirst) { |
---|
43 | this.originName = originName; |
---|
44 | this.rootFile = rootFile; |
---|
45 | this.prefix = prefix; |
---|
46 | this.tostrip = toStrip; |
---|
47 | this.deleteFirst = deleteFirst; |
---|
48 | } |
---|
49 | |
---|
50 | /** |
---|
51 | * Test for equality of the object itself and the object passed to it |
---|
52 | * |
---|
53 | * @param dataRoot |
---|
54 | * @return true if the object equals this, false otherwise |
---|
55 | */ |
---|
56 | @Override |
---|
57 | public boolean equals (Object object){ |
---|
58 | boolean equal = false; |
---|
59 | |
---|
60 | if (object == null) { |
---|
61 | // define this object to be different from nothing |
---|
62 | } else { |
---|
63 | if (! (object instanceof DataRoot)) { |
---|
64 | // the object is not a DataRoot, define it not to be equal |
---|
65 | } else { |
---|
66 | equal = this.originName.equals(((DataRoot) object).originName); |
---|
67 | equal = this.rootFile.equals(((DataRoot) object).rootFile) && equal; |
---|
68 | equal = this.prefix.equals(((DataRoot) object).prefix) && equal; |
---|
69 | equal = this.tostrip.equals(((DataRoot) object).tostrip) && equal; |
---|
70 | |
---|
71 | equal = this.deleteFirst == ((DataRoot) object).deleteFirst && equal; |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | return equal; |
---|
76 | } |
---|
77 | |
---|
78 | /** |
---|
79 | * Generate by the ide |
---|
80 | * |
---|
81 | * @return hash code |
---|
82 | */ |
---|
83 | @Override |
---|
84 | public int hashCode() { |
---|
85 | int hash = 7; |
---|
86 | hash = 29 * hash + (this.originName != null ? this.originName.hashCode() : 0); |
---|
87 | hash = 29 * hash + (this.rootFile != null ? this.rootFile.hashCode() : 0); |
---|
88 | hash = 29 * hash + (this.prefix != null ? this.prefix.hashCode() : 0); |
---|
89 | hash = 29 * hash + (this.tostrip != null ? this.tostrip.hashCode() : 0); |
---|
90 | hash = 29 * hash + (this.deleteFirst ? 1 : 0); |
---|
91 | return hash; |
---|
92 | } |
---|
93 | |
---|
94 | /** |
---|
95 | * name describing the meta data |
---|
96 | */ |
---|
97 | @Element // Simple directive |
---|
98 | private String originName; |
---|
99 | |
---|
100 | /** |
---|
101 | * top level directory in which the meta data is stored |
---|
102 | */ |
---|
103 | @Element |
---|
104 | private File rootFile; |
---|
105 | |
---|
106 | /** |
---|
107 | * Web equivalent of the toStrip. For example: |
---|
108 | * |
---|
109 | * /lat/apache/htdocs/ |
---|
110 | */ |
---|
111 | @Element |
---|
112 | private String prefix; |
---|
113 | |
---|
114 | /** |
---|
115 | * Left part of the rootFile |
---|
116 | * |
---|
117 | * By first removing {@literal tostrip} from {@literal rootFile} and then |
---|
118 | * append the result of that operation to the {@literal prefix} you obtain |
---|
119 | * the URL to the meta data. |
---|
120 | */ |
---|
121 | @Element |
---|
122 | private String tostrip; |
---|
123 | |
---|
124 | /** |
---|
125 | * Flag to signal the removal of records from the Solr server |
---|
126 | * |
---|
127 | * The value of this flag overrides the value defined in the {@lieteral |
---|
128 | * VloConfig.xml} file. With the deleteFirst flag you can control the |
---|
129 | * removal of the records originating from originName. |
---|
130 | */ |
---|
131 | @Element |
---|
132 | private boolean deleteFirst = false; |
---|
133 | |
---|
134 | /** |
---|
135 | * Get the value of the prefix element<br><br> |
---|
136 | * |
---|
137 | * For a description of the element, refer to the general VLO |
---|
138 | * documentation. |
---|
139 | * |
---|
140 | * @return the value |
---|
141 | */ |
---|
142 | public String getPrefix() { |
---|
143 | return prefix; |
---|
144 | } |
---|
145 | |
---|
146 | /** |
---|
147 | * Set the value of the prefix element<br><br> |
---|
148 | * |
---|
149 | * For a description of the element, refer to the general VLO |
---|
150 | * documentation. |
---|
151 | * |
---|
152 | * @param prefix the value |
---|
153 | */ |
---|
154 | public void setPrefix(String prefix) { |
---|
155 | this.prefix = prefix; |
---|
156 | } |
---|
157 | |
---|
158 | /** |
---|
159 | * Get the value of the {@literal tostrip} element<br><br> |
---|
160 | * |
---|
161 | * For a description of the element, refer to the general VLO |
---|
162 | * documentation. |
---|
163 | * |
---|
164 | * @return the value |
---|
165 | */ |
---|
166 | public String getToStrip() { |
---|
167 | return tostrip; |
---|
168 | } |
---|
169 | |
---|
170 | /** |
---|
171 | * Set the value of the {@literal tostrip} element<br><br> |
---|
172 | * |
---|
173 | * For a description of the element, refer to the general VLO |
---|
174 | * documentation. |
---|
175 | * |
---|
176 | * @param tostrip the value |
---|
177 | */ |
---|
178 | public void setTostrip(String tostrip) { |
---|
179 | this.tostrip = tostrip; |
---|
180 | } |
---|
181 | |
---|
182 | /** |
---|
183 | * Get the value of the originName element<br><br> |
---|
184 | * |
---|
185 | * For a description of the element, refer to the general VLO |
---|
186 | * documentation. |
---|
187 | * |
---|
188 | * @return the value |
---|
189 | */ |
---|
190 | public String getOriginName() { |
---|
191 | return originName; |
---|
192 | } |
---|
193 | |
---|
194 | /** |
---|
195 | * Set the value of the originName element<br><br> |
---|
196 | * |
---|
197 | * For a description of the element, refer to the general VLO |
---|
198 | * documentation. |
---|
199 | * |
---|
200 | * @param originName the value |
---|
201 | */ |
---|
202 | public void setOriginName(String originName) { |
---|
203 | this.originName = originName; |
---|
204 | } |
---|
205 | |
---|
206 | /** |
---|
207 | * Get the value of the rootFile element<br><br> |
---|
208 | * |
---|
209 | * For a description of the element, refer to the general VLO |
---|
210 | * documentation. |
---|
211 | * |
---|
212 | * @return the value |
---|
213 | */ |
---|
214 | public File getRootFile() { |
---|
215 | return rootFile; |
---|
216 | } |
---|
217 | |
---|
218 | /** |
---|
219 | * Set the value of the rootFile element<br><br> |
---|
220 | * |
---|
221 | * For a description of the element, refer to the general VLO |
---|
222 | * documentation. |
---|
223 | * |
---|
224 | * @param rootFile the value |
---|
225 | */ |
---|
226 | public void setRootFile(File rootFile) { |
---|
227 | this.rootFile = rootFile; |
---|
228 | } |
---|
229 | |
---|
230 | /** |
---|
231 | * Set the value of the deleteFirst element<br><br> |
---|
232 | * |
---|
233 | * For a description of the element, refer to the general VLO |
---|
234 | * documentation. |
---|
235 | * |
---|
236 | * @param deleteFirst the value |
---|
237 | */ |
---|
238 | public void setDeleteFirst(boolean deleteFirst) { |
---|
239 | this.deleteFirst = deleteFirst; |
---|
240 | } |
---|
241 | |
---|
242 | /** |
---|
243 | * Get the value of the deleteFirst element<br><br> |
---|
244 | * |
---|
245 | * For a description of the element, refer to the general VLO |
---|
246 | * documentation. |
---|
247 | * |
---|
248 | * @return the value |
---|
249 | */ |
---|
250 | public boolean deleteFirst() { |
---|
251 | return deleteFirst; |
---|
252 | } |
---|
253 | } |
---|
254 | |
---|