1
|
/**
|
2
|
* Copyright (C) 2015 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.cdm.persistence.dao.hibernate.taxon;
|
10
|
|
11
|
import static org.junit.Assert.assertEquals;
|
12
|
|
13
|
import java.io.FileNotFoundException;
|
14
|
import java.util.List;
|
15
|
import java.util.UUID;
|
16
|
|
17
|
import org.junit.Before;
|
18
|
import org.junit.Test;
|
19
|
import org.unitils.dbunit.annotation.DataSet;
|
20
|
import org.unitils.spring.annotation.SpringBeanByType;
|
21
|
|
22
|
import eu.etaxonomy.cdm.model.name.IBotanicalName;
|
23
|
import eu.etaxonomy.cdm.model.name.Rank;
|
24
|
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
|
25
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
26
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
27
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
28
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
29
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
30
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
31
|
import eu.etaxonomy.cdm.persistence.dao.reference.IReferenceDao;
|
32
|
import eu.etaxonomy.cdm.persistence.dao.taxon.IClassificationDao;
|
33
|
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonDao;
|
34
|
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonNodeDao;
|
35
|
import eu.etaxonomy.cdm.persistence.dto.ClassificationLookupDTO;
|
36
|
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
|
37
|
import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy;
|
38
|
|
39
|
/**
|
40
|
* @author a.kohlbecker
|
41
|
* @since Jun 15, 2015
|
42
|
*/
|
43
|
public class ClassificationDaoHibernateImplTest extends CdmTransactionalIntegrationTest {
|
44
|
|
45
|
@SpringBeanByType
|
46
|
private ITaxonDao taxonDao;
|
47
|
@SpringBeanByType
|
48
|
private IClassificationDao classificationDao;
|
49
|
@SpringBeanByType
|
50
|
private IReferenceDao referenceDao;
|
51
|
@SpringBeanByType
|
52
|
private ITaxonNodeDao taxonNodeDao;
|
53
|
|
54
|
private boolean includeUnpublished;
|
55
|
|
56
|
private static final UUID FLAT_CLASSIFICATION_UUID = UUID.fromString("2a5ceebb-4830-4524-b330-78461bf8cb6b");
|
57
|
private static final UUID CLASSIFICATION_FULL_UUID = UUID.fromString("a71467a6-74dc-4148-9530-484628a5ab0e");
|
58
|
private static final UUID UUID_ABIES = UUID.fromString("19f560d9-a555-4883-9c54-39d04872307c");
|
59
|
private static final UUID UUID_PINACEAE = UUID.fromString("74216ed8-5f04-439e-87e0-500738f5e7fc");
|
60
|
private static final UUID UUID_ABIES_NODE = UUID.fromString("56b10cf0-9522-407e-9f90-0c2dba263c94");
|
61
|
private static final UUID UUID_FLAT_ROOT = UUID.fromString("75202d4e-b2aa-4343-8b78-340a52d15c40");
|
62
|
|
63
|
@Before
|
64
|
public void setUp() {
|
65
|
includeUnpublished = true;
|
66
|
}
|
67
|
|
68
|
/**
|
69
|
* see https://dev.e-taxonomy.eu/redmine/issues/2778
|
70
|
* Classification/{uuid}/childNodesAt/{rank-uuid} fails if only species in database
|
71
|
*/
|
72
|
@Test
|
73
|
@DataSet(value="ClassificationDaoHibernateImplTest.listRankSpecificRootNodes.xml")
|
74
|
public void testListRankSpecificRootNodesFlatHierarchie() {
|
75
|
|
76
|
checkPreconditions();
|
77
|
|
78
|
Classification classification = classificationDao.load(FLAT_CLASSIFICATION_UUID);
|
79
|
|
80
|
includeUnpublished = true;
|
81
|
// test for the bug in https://dev.e-taxonomy.eu/redmine/issues/2778
|
82
|
Rank rank = Rank.GENUS();
|
83
|
// run both queries in dao method since rank != null
|
84
|
List<TaxonNode> rootNodes = classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished,
|
85
|
null, null, null, 0);
|
86
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished,
|
87
|
null, null, null, 1));
|
88
|
assertEquals(3, rootNodes.size());
|
89
|
|
90
|
rank = null;
|
91
|
// run only fist query in dao method since rank == null
|
92
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished,
|
93
|
null, null, null, 0);
|
94
|
assertEquals("The absolut root nodes should be returned", 3, rootNodes.size());
|
95
|
|
96
|
//no unpublished
|
97
|
includeUnpublished = false;
|
98
|
|
99
|
rank = Rank.GENUS();
|
100
|
// run both queries in dao method since rank != null
|
101
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished,
|
102
|
null, null, null, 0);
|
103
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished,
|
104
|
null, null, null, 1));
|
105
|
assertEquals(2, rootNodes.size()); //5002 in unpublished
|
106
|
|
107
|
rank = null;
|
108
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished,
|
109
|
null, null, null, 0);
|
110
|
assertEquals("The absolut root nodes should be returned", 2, rootNodes.size());
|
111
|
}
|
112
|
|
113
|
|
114
|
/**
|
115
|
* Test listRankSpecificRootNode with an existing classification
|
116
|
*/
|
117
|
@Test
|
118
|
@DataSet(value="ClassificationDaoHibernateImplTest.listRankSpecificRootNodes.xml")
|
119
|
public void testListRankSpecificRootNodesWithHierarchie() {
|
120
|
|
121
|
// check preconditions
|
122
|
checkPreconditions();
|
123
|
|
124
|
Classification classification = classificationDao.load(CLASSIFICATION_FULL_UUID);
|
125
|
includeUnpublished = false;
|
126
|
Rank rank = Rank.GENUS();
|
127
|
// run both queries in dao method since rank != null
|
128
|
List<TaxonNode> rootNodes = classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 0);
|
129
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 1));
|
130
|
assertEquals("Only the genus should come back", 1, rootNodes.size());
|
131
|
assertEquals(Rank.GENUS(), rootNodes.get(0).getTaxon().getName().getRank());
|
132
|
assertEquals(UUID_ABIES, rootNodes.get(0).getTaxon().getUuid());
|
133
|
|
134
|
rank = Rank.SUBGENUS();
|
135
|
// run both queries in dao method since rank != null
|
136
|
includeUnpublished = true;
|
137
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 0);
|
138
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 1));
|
139
|
assertEquals("Only the 2 species should come back", 2, rootNodes.size());
|
140
|
for (TaxonNode tn : rootNodes){
|
141
|
assertEquals(Rank.SPECIES(), tn.getTaxon().getName().getRank());
|
142
|
}
|
143
|
// run both queries in dao method since rank != null
|
144
|
includeUnpublished = false;
|
145
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 0);
|
146
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 1));
|
147
|
assertEquals("Only the 1 published species should come back", 1, rootNodes.size());
|
148
|
for (TaxonNode tn : rootNodes){
|
149
|
assertEquals(Rank.SPECIES(), tn.getTaxon().getName().getRank());
|
150
|
}
|
151
|
|
152
|
rank = Rank.SUBFAMILY();
|
153
|
// run both queries in dao method since rank != null
|
154
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 0);
|
155
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 1));
|
156
|
assertEquals("Only the genus should come back", 1, rootNodes.size());
|
157
|
assertEquals(Rank.GENUS(), rootNodes.get(0).getTaxon().getName().getRank());
|
158
|
assertEquals(UUID_ABIES, rootNodes.get(0).getTaxon().getUuid());
|
159
|
|
160
|
rank = Rank.FAMILY();
|
161
|
// run both queries in dao method since rank != null
|
162
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 0);
|
163
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 1));
|
164
|
assertEquals("Only the family should come back", 1, rootNodes.size());
|
165
|
assertEquals(Rank.FAMILY(), rootNodes.get(0).getTaxon().getName().getRank());
|
166
|
assertEquals(UUID_PINACEAE, rootNodes.get(0).getTaxon().getUuid());
|
167
|
|
168
|
rank = null;
|
169
|
// run only fist query in dao method since rank == null
|
170
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 0);
|
171
|
assertEquals("Only the family as the absolut root node should come back", 1, rootNodes.size());
|
172
|
assertEquals(Rank.FAMILY(), rootNodes.get(0).getTaxon().getName().getRank());
|
173
|
assertEquals(UUID_PINACEAE, rootNodes.get(0).getTaxon().getUuid());
|
174
|
|
175
|
}
|
176
|
|
177
|
/**
|
178
|
* Test listRankSpecificRootNode with an existing classification
|
179
|
*/
|
180
|
@Test
|
181
|
@DataSet(value="ClassificationDaoHibernateImplTest.listRankSpecificRootNodes.xml")
|
182
|
public void testListRankSpecificRootNodesWithHierarchie_withSubtree() {
|
183
|
|
184
|
// check preconditions
|
185
|
checkPreconditions();
|
186
|
|
187
|
Classification classification = classificationDao.load(CLASSIFICATION_FULL_UUID);
|
188
|
TaxonNode subtree = taxonNodeDao.findByUuid(UUID_ABIES_NODE);
|
189
|
|
190
|
includeUnpublished = false;
|
191
|
Rank rank = null;
|
192
|
// run only first query as rank is null
|
193
|
List<TaxonNode> rootNodes = classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 0);
|
194
|
assertEquals("Only 1 node - the Abies node - should come back as root node for the subtree", 1, rootNodes.size());
|
195
|
assertEquals(Rank.GENUS(), rootNodes.get(0).getTaxon().getName().getRank());
|
196
|
assertEquals(UUID_ABIES, rootNodes.get(0).getTaxon().getUuid());
|
197
|
|
198
|
rank = Rank.GENUS();
|
199
|
// run both queries in dao method since rank != null
|
200
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 0);
|
201
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 1));
|
202
|
assertEquals("Only 1 node - the Abies node - should come back", 1, rootNodes.size());
|
203
|
assertEquals(Rank.GENUS(), rootNodes.get(0).getTaxon().getName().getRank());
|
204
|
assertEquals(UUID_ABIES, rootNodes.get(0).getTaxon().getUuid());
|
205
|
|
206
|
|
207
|
rank = Rank.SUBGENUS();
|
208
|
// run both queries in dao method since rank != null
|
209
|
includeUnpublished = true;
|
210
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 0);
|
211
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 1));
|
212
|
assertEquals("Only the 2 species should come back", 2, rootNodes.size());
|
213
|
for (TaxonNode tn : rootNodes){
|
214
|
assertEquals(Rank.SPECIES(), tn.getTaxon().getName().getRank());
|
215
|
}
|
216
|
// same with unpublished
|
217
|
includeUnpublished = false;
|
218
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 0);
|
219
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 1));
|
220
|
assertEquals("Only the 1 published species should come back", 1, rootNodes.size());
|
221
|
for (TaxonNode tn : rootNodes){
|
222
|
assertEquals(Rank.SPECIES(), tn.getTaxon().getName().getRank());
|
223
|
}
|
224
|
|
225
|
rank = Rank.SUBFAMILY();
|
226
|
// run both queries in dao method since rank != null
|
227
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 0);
|
228
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 1));
|
229
|
assertEquals("Only the genus should come back", 1, rootNodes.size());
|
230
|
assertEquals(Rank.GENUS(), rootNodes.get(0).getTaxon().getName().getRank());
|
231
|
assertEquals(UUID_ABIES, rootNodes.get(0).getTaxon().getUuid());
|
232
|
|
233
|
rank = Rank.FAMILY();
|
234
|
// run both queries in dao method since rank != null
|
235
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 0);
|
236
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 1));
|
237
|
assertEquals("Only the genus should come back as family is not in subtree", 1, rootNodes.size());
|
238
|
assertEquals(Rank.GENUS(), rootNodes.get(0).getTaxon().getName().getRank());
|
239
|
assertEquals(UUID_ABIES, rootNodes.get(0).getTaxon().getUuid());
|
240
|
|
241
|
//no classification filter
|
242
|
//should have no effect as subtree is kind of classification filter
|
243
|
TaxonNode rootNode = classification.getRootNode();
|
244
|
classification = null;
|
245
|
rank = null;
|
246
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 0);
|
247
|
assertEquals("Only 1 node - the Abies node - should come back", 1, rootNodes.size());
|
248
|
assertEquals(UUID_ABIES, rootNodes.get(0).getTaxon().getUuid());
|
249
|
|
250
|
rank = Rank.GENUS();
|
251
|
rootNodes = classificationDao.listRankSpecificRootNodes(null, subtree, rank, includeUnpublished, null, null, null, 0);
|
252
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 1));
|
253
|
assertEquals("Only 1 node - the Abies node - should come back", 1, rootNodes.size());
|
254
|
assertEquals(UUID_ABIES, rootNodes.get(0).getTaxon().getUuid());
|
255
|
|
256
|
rank = Rank.SUBGENUS();
|
257
|
includeUnpublished = true;
|
258
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 0);
|
259
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 1));
|
260
|
assertEquals("Only the 2 species should come back", 2, rootNodes.size());
|
261
|
|
262
|
//with root node
|
263
|
subtree = rootNode;
|
264
|
rank = null;
|
265
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 0);
|
266
|
assertEquals("Only the family should come back", 1, rootNodes.size());
|
267
|
assertEquals(Rank.FAMILY(), rootNodes.get(0).getTaxon().getName().getRank());
|
268
|
assertEquals(UUID_PINACEAE, rootNodes.get(0).getTaxon().getUuid());
|
269
|
|
270
|
rank = Rank.GENUS();
|
271
|
rootNodes = classificationDao.listRankSpecificRootNodes(null, subtree, rank, includeUnpublished, null, null, null, 0);
|
272
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 1));
|
273
|
assertEquals("Only 1 node - the Abies node - should come back", 1, rootNodes.size());
|
274
|
assertEquals(UUID_ABIES, rootNodes.get(0).getTaxon().getUuid());
|
275
|
|
276
|
rank = Rank.SUBGENUS();
|
277
|
includeUnpublished = true;
|
278
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 0);
|
279
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 1));
|
280
|
assertEquals("Only the 2 species should come back", 2, rootNodes.size());
|
281
|
|
282
|
|
283
|
//flat hierarchie
|
284
|
classification = classificationDao.load(FLAT_CLASSIFICATION_UUID);
|
285
|
includeUnpublished = false;
|
286
|
|
287
|
rank = null;
|
288
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 0);
|
289
|
assertEquals("No subtree should be returned as subtree is not from classification", 0, rootNodes.size());
|
290
|
|
291
|
subtree = taxonNodeDao.findByUuid(UUID_FLAT_ROOT);
|
292
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 0);
|
293
|
// assertEquals("The 2 published species should be returned", 2, rootNodes.size());
|
294
|
|
295
|
rank = Rank.GENUS();
|
296
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 0);
|
297
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, subtree, rank, includeUnpublished, null, null, null, 1));
|
298
|
assertEquals(2, rootNodes.size()); //5002 in unpublished
|
299
|
|
300
|
}
|
301
|
|
302
|
/**
|
303
|
* Test listRankSpecificRootNode with all classifications
|
304
|
*/
|
305
|
@Test
|
306
|
@DataSet(value="ClassificationDaoHibernateImplTest.listRankSpecificRootNodes.xml")
|
307
|
public void testListRankSpecificRootNodesWithNoClassification() {
|
308
|
Classification classification = null;
|
309
|
|
310
|
Rank rank = Rank.GENUS();
|
311
|
// run both queries in dao method since rank != null
|
312
|
List<TaxonNode> rootNodes = classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 0);
|
313
|
rootNodes.addAll(classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 1));
|
314
|
assertEquals("3 Species from no hierarchie and 1 genus from hierarchie should return", 4, rootNodes.size());
|
315
|
|
316
|
rank = null;
|
317
|
// run only fist query in dao method since rank == null
|
318
|
rootNodes = classificationDao.listRankSpecificRootNodes(classification, null, rank, includeUnpublished, null, null, null, 0);
|
319
|
assertEquals("4 taxa should return (3 species from no hierarchie, 1 family, from hierarchie classification", 4, rootNodes.size());
|
320
|
}
|
321
|
|
322
|
private void checkPreconditions() {
|
323
|
// check preconditions
|
324
|
List<TaxonBase> taxa = taxonDao.list(null, null);
|
325
|
assertEquals(5, taxa.size());
|
326
|
|
327
|
// for(TaxonBase t : taxa) {
|
328
|
// assertEquals(Rank.SPECIES().getUuid(), t.getName().getRank().getUuid());
|
329
|
// }
|
330
|
}
|
331
|
|
332
|
@Test
|
333
|
@DataSet(value="ClassificationDaoHibernateImplTest.listRankSpecificRootNodes.xml")
|
334
|
public void testClassificationLookup() {
|
335
|
|
336
|
Classification classification = classificationDao.load(CLASSIFICATION_FULL_UUID);
|
337
|
ClassificationLookupDTO classificationLookupDto = classificationDao.classificationLookup(classification);
|
338
|
assertEquals(4, classificationLookupDto.getTaxonIds().size());
|
339
|
}
|
340
|
|
341
|
|
342
|
/**
|
343
|
* At the moment the data created is special to the issue https://dev.e-taxonomy.eu/redmine/issues/2778
|
344
|
* ClassificationDaoHibernateImplTest.issue2778.xml
|
345
|
*
|
346
|
* {@inheritDoc}
|
347
|
*/
|
348
|
@Override
|
349
|
// @Test // uncomment to write out the test data xml file for this test class
|
350
|
@DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDBDataSet.xml")
|
351
|
public final void createTestDataSet() throws FileNotFoundException {
|
352
|
|
353
|
// 1. create the entities and save them
|
354
|
Classification flatHierarchieClassification = Classification.NewInstance("European Abies");
|
355
|
flatHierarchieClassification.setUuid(FLAT_CLASSIFICATION_UUID);
|
356
|
classificationDao.save(flatHierarchieClassification);
|
357
|
|
358
|
Reference sec = ReferenceFactory.newBook();
|
359
|
sec.setTitleCache("Kohlbecker, A., Testcase standart views, 2013", true);
|
360
|
Reference sec_sensu = ReferenceFactory.newBook();
|
361
|
sec_sensu.setTitleCache("Komarov, V. L., Flora SSSR 29", true);
|
362
|
referenceDao.save(sec);
|
363
|
referenceDao.save(sec_sensu);
|
364
|
|
365
|
|
366
|
IBotanicalName n_abies_alba = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
|
367
|
n_abies_alba.setNameCache("Abies alba", true);
|
368
|
Taxon t_abies_alba = Taxon.NewInstance(n_abies_alba, sec);
|
369
|
taxonDao.save(t_abies_alba);
|
370
|
|
371
|
IBotanicalName n_abies_grandis = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
|
372
|
n_abies_grandis.setNameCache("Abies grandis", true);
|
373
|
Taxon t_abies_grandis = Taxon.NewInstance(n_abies_grandis, sec);
|
374
|
taxonDao.save(t_abies_grandis);
|
375
|
|
376
|
IBotanicalName n_abies_kawakamii = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
|
377
|
n_abies_kawakamii.setNameCache("Abies kawakamii", true);
|
378
|
Taxon t_abies_kawakamii = Taxon.NewInstance(n_abies_kawakamii, sec);
|
379
|
taxonDao.save(t_abies_kawakamii);
|
380
|
|
381
|
// BotanicalName n_abies_lasiocarpa = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
|
382
|
// n_abies_lasiocarpa.setNameCache("Abies lasiocarpa", true);
|
383
|
// Taxon t_abies_lasiocarpa = Taxon.NewInstance(n_abies_lasiocarpa, sec);
|
384
|
// taxonDao.save(t_abies_lasiocarpa);
|
385
|
|
386
|
IBotanicalName n_abies = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS());
|
387
|
n_abies.setNameCache("Abies", true);
|
388
|
Taxon t_abies = Taxon.NewInstance(n_abies, sec);
|
389
|
t_abies.setUuid(UUID_ABIES);
|
390
|
taxonDao.save(t_abies);
|
391
|
|
392
|
IBotanicalName n_pinaceae = TaxonNameFactory.NewBotanicalInstance(Rank.FAMILY());
|
393
|
n_pinaceae.setNameCache("Pinaceae", true);
|
394
|
Taxon t_pinaceae = Taxon.NewInstance(n_pinaceae, sec);
|
395
|
t_pinaceae.setUuid(UUID_PINACEAE);
|
396
|
taxonDao.save(t_pinaceae);
|
397
|
|
398
|
|
399
|
// add taxa to classifications
|
400
|
flatHierarchieClassification.addChildTaxon(t_abies_alba, null, null);
|
401
|
flatHierarchieClassification.addChildTaxon(t_abies_grandis, null, null);
|
402
|
flatHierarchieClassification.addChildTaxon(t_abies_kawakamii, null, null);
|
403
|
// flatHierarchieClassification.addChildTaxon(t_abies_lasiocarpa, null, null);
|
404
|
classificationDao.saveOrUpdate(flatHierarchieClassification);
|
405
|
|
406
|
// 1. create the entities and save them
|
407
|
Classification fullHierarchieClassification = Classification.NewInstance("European Abies full hierarchie");
|
408
|
fullHierarchieClassification.setUuid(CLASSIFICATION_FULL_UUID);
|
409
|
classificationDao.save(fullHierarchieClassification);
|
410
|
|
411
|
fullHierarchieClassification.addParentChild(t_pinaceae, t_abies, null, null);
|
412
|
fullHierarchieClassification.addParentChild(t_abies, t_abies_alba, null, null);
|
413
|
fullHierarchieClassification.addParentChild(t_abies, t_abies_grandis, null, null);
|
414
|
|
415
|
classificationDao.saveOrUpdate(fullHierarchieClassification);
|
416
|
|
417
|
|
418
|
|
419
|
// 2. end the transaction so that all data is actually written to the db
|
420
|
setComplete();
|
421
|
endTransaction();
|
422
|
|
423
|
// use the fileNameAppendix if you are creating a data set file which need to be named differently
|
424
|
// from the standard name. Fir example if a single test method needs different data then the other
|
425
|
// methods the test class you may want to set the fileNameAppendix when creating the data for this method.
|
426
|
String fileNameAppendix = "listRankSpecificRootNodes";
|
427
|
|
428
|
// 3.
|
429
|
writeDbUnitDataSetFile(new String[] {
|
430
|
"TAXONBASE", "TAXONNAME",
|
431
|
"REFERENCE",
|
432
|
"AGENTBASE","HOMOTYPICALGROUP",
|
433
|
"CLASSIFICATION", "TAXONNODE",
|
434
|
"LANGUAGESTRING",
|
435
|
"HIBERNATE_SEQUENCES" // IMPORTANT!!!
|
436
|
},
|
437
|
fileNameAppendix, true );
|
438
|
}
|
439
|
|
440
|
}
|