2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.io
.cdmLight
.out
;
11 import java
.io
.BufferedReader
;
12 import java
.io
.ByteArrayInputStream
;
13 import java
.io
.FileNotFoundException
;
14 import java
.io
.IOException
;
15 import java
.io
.InputStreamReader
;
16 import java
.nio
.charset
.Charset
;
17 import java
.util
.HashSet
;
20 import java
.util
.UUID
;
22 import org
.apache
.log4j
.Logger
;
23 import org
.junit
.Assert
;
24 import org
.junit
.Before
;
25 import org
.junit
.Test
;
26 import org
.unitils
.dbunit
.annotation
.DataSet
;
27 import org
.unitils
.dbunit
.annotation
.DataSets
;
28 import org
.unitils
.spring
.annotation
.SpringBeanByName
;
29 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
31 import eu
.etaxonomy
.cdm
.api
.service
.IClassificationService
;
32 import eu
.etaxonomy
.cdm
.api
.service
.ICommonService
;
33 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonNodeService
;
34 import eu
.etaxonomy
.cdm
.api
.service
.ITermService
;
35 import eu
.etaxonomy
.cdm
.filter
.TaxonNodeFilter
;
36 import eu
.etaxonomy
.cdm
.io
.cdmLight
.CdmLightExportConfigurator
;
37 import eu
.etaxonomy
.cdm
.io
.cdmLight
.CdmLightExportTable
;
38 import eu
.etaxonomy
.cdm
.io
.common
.CdmApplicationAwareDefaultExport
;
39 import eu
.etaxonomy
.cdm
.io
.common
.ExportDataWrapper
;
40 import eu
.etaxonomy
.cdm
.io
.common
.ExportResult
;
41 import eu
.etaxonomy
.cdm
.io
.common
.IExportConfigurator
.TARGET
;
42 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
43 import eu
.etaxonomy
.cdm
.model
.description
.Distribution
;
44 import eu
.etaxonomy
.cdm
.model
.description
.PresenceAbsenceTerm
;
45 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
46 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
47 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
48 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
49 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
50 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
51 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
52 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
53 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
54 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
55 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
56 import eu
.etaxonomy
.cdm
.strategy
.parser
.NonViralNameParserImpl
;
57 import eu
.etaxonomy
.cdm
.test
.integration
.CdmTransactionalIntegrationTest
;
58 import eu
.etaxonomy
.cdm
.test
.unitils
.CleanSweepInsertLoadStrategy
;
64 public class CdmLightExportTest
extends CdmTransactionalIntegrationTest
{
66 @SuppressWarnings("unused")
67 private static final Logger logger
= Logger
.getLogger(CdmLightExportTest
.class);
70 private CdmApplicationAwareDefaultExport
<CdmLightExportConfigurator
> defaultExport
;
73 private IClassificationService classificationService
;
76 private ITermService termService
;
79 private ITaxonNodeService taxonNodeService
;
82 private ICommonService commonService
;
86 // DefinedTerm ipniIdentifierTerm = DefinedTerm.NewIdentifierTypeInstance("IPNI Identifier", "IPNI Identifier", "IPNI Identifier");
87 // ipniIdentifierTerm.setUuid(DefinedTerm.uuidIpniNameIdentifier);
89 // DefinedTerm tropicosIdentifierTerm = DefinedTerm.NewIdentifierTypeInstance("Tropicos Identifier", "Tropicos Identifier", "Tropicos Identifier");
90 // tropicosIdentifierTerm.setUuid(DefinedTerm.uuidTropicosNameIdentifier);
92 // DefinedTerm wfoIdentifierTerm = DefinedTerm.NewIdentifierTypeInstance("WFO Identifier", "WFO Identifier", "WFO Identifier");
93 // wfoIdentifierTerm.setUuid(DefinedTerm.uuidWfoNameIdentifier);
94 // List<DefinedTermBase> terms = new ArrayList();
95 // terms.add(wfoIdentifierTerm);
96 // terms.add(tropicosIdentifierTerm);
97 // terms.add(ipniIdentifierTerm);
98 // termService.saveOrUpdate(terms);
99 createFullTestDataSet();
104 @DataSet(loadStrategy
=CleanSweepInsertLoadStrategy
.class, value
="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
105 @DataSet(value
="/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml")
107 public void testSubTree(){
109 CdmLightExportConfigurator config
= new CdmLightExportConfigurator(null);
110 // config.setCreateCondensedDistributionString(false);
111 config
.setTaxonNodeFilter(TaxonNodeFilter
.NewSubtreeInstance(UUID
.fromString("f8c9933a-fe3a-42ce-8a92-000e27bfdfac")));
113 config
.setTarget(TARGET
.EXPORT_DATA
);
114 ExportResult result
= defaultExport
.invoke(config
);
115 ExportDataWrapper
<?
> exportData
= result
.getExportData();
116 testExceptionsErrorsWarnings(result
);
118 @SuppressWarnings("unchecked")
119 Map
<String
, byte[]> data
= (Map
<String
, byte[]>) exportData
.getExportData();
121 byte[] taxon
= data
.get(CdmLightExportTable
.TAXON
.getTableName());
122 Assert
.assertNotNull("Taxon table must not be null", taxon
);
123 String taxonStr
= new String(taxon
);
124 String notExpected
= "\"9182e136-f2e2-4f9a-9010-3f35908fb5e0\"";
125 Assert
.assertFalse("Result must not contain root taxon", taxonStr
.startsWith(notExpected
));
126 String expected
= "\"b2c86698-500e-4efb-b9ae-6bb6e701d4bc\",\"4096df99-7274-421e-8843-211b603d832e\",\"CdmLightExportTest Classification\",\"3483cc5e-4c77-4c80-8cb0-73d43df31ee3\",\"9182e136-f2e2-4f9a-9010-3f35908fb5e0\",\"4b6acca1-959b-4790-b76e-e474a0882990\",\"My sec ref\"";
127 Assert
.assertTrue(taxonStr
.contains(expected
));
129 byte[] reference
= data
.get(CdmLightExportTable
.REFERENCE
.getTableName());
130 String referenceString
= new String(reference
);
131 Assert
.assertNotNull("Reference table must not be null", reference
);
132 expected
="\"b8dd7f4a-0c7f-4372-bc5d-3b676363bc0f\",\"Mill. 1804\",\"\",\"The book of botany\",\"1804\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"3\",\"1804\",\"Mill.\"";
133 Assert
.assertTrue(referenceString
.contains(expected
));
135 byte[] geographicAreaFact
= data
.get(CdmLightExportTable
.GEOGRAPHIC_AREA_FACT
.getTableName());
136 String geographicAreaFactString
= new String(geographicAreaFact
);
137 Assert
.assertNotNull("Geographical fact table must not be null", geographicAreaFact
);
138 expected
="\"674e9e27-9102-4166-8626-8cb871a9a89b\",\"b2c86698-500e-4efb-b9ae-6bb6e701d4bc\",\"Africa\",\"present\"";
139 Assert
.assertTrue(geographicAreaFactString
.contains(expected
));
141 byte[] nomenclaturalAuthor
= data
.get(CdmLightExportTable
.NOMENCLATURAL_AUTHOR
.getTableName());
142 String nomenclaturalAuthorString
= new String(nomenclaturalAuthor
);
143 Assert
.assertNotNull("Nomenclatural Author table must not be null", nomenclaturalAuthor
);
144 expected
="\"Mill.\",\"Mill.\",\"\",\"\",\"\",\"\"";
145 Assert
.assertTrue(nomenclaturalAuthorString
.contains(expected
));
147 byte[] scientificName
= data
.get(CdmLightExportTable
.SCIENTIFIC_NAME
.getTableName());
148 String scientificNameString
= new String(scientificName
);
149 Assert
.assertNotNull("Scientific Name table must not be null", scientificName
);
150 expected
="\"3483cc5e-4c77-4c80-8cb0-73d43df31ee3\",\"\",\"Subspecies\",\"43\",\"Genus species subsp. subspec Mill.\",\"Genus species subsp. subspec\",\"Genus\",\"\",\"\",\"species\",\"subsp.\",\"subspec\",\"\",\"\",\"\",";
151 Assert
.assertTrue(scientificNameString
.contains(expected
));
152 if (config
.isAddHTML()){
153 expected
= "\"<i>Genus</i> <i>species</i> subsp. <i>subspec</i> Mill., The book of botany 3: 22. 1804\"";
154 Assert
.assertTrue(scientificNameString
.contains(expected
));
157 expected
="\"Book\",\"The book of botany\",\"The book of botany\",\"Mill.\",\"Mill.\",\"3:22\",\"3\",\"22\",\"1804\",\"1804\",\"\",\"\",\"\",\"\"";
158 Assert
.assertTrue(scientificNameString
.contains(expected
));
160 byte[] homotypicGroup
= data
.get(CdmLightExportTable
.HOMOTYPIC_GROUP
.getTableName());
161 String homotypicGroupString
= new String(homotypicGroup
);
162 Assert
.assertNotNull("Reference table must not be null", homotypicGroup
);
163 if (config
.isAddHTML()){
164 expected
="\"<i>Genus</i> <i>species</i> subsp. <i>subspec</i> Mill., The book of botany 3: 22. 1804\",\"\"";
166 expected
="\"Genus species subsp. subspec Mill., The book of botany 3: 22. 1804\",\"\"";
168 Assert
.assertTrue(homotypicGroupString
.contains(expected
));
173 @DataSet(loadStrategy
=CleanSweepInsertLoadStrategy
.class, value
="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
174 @DataSet(value
="/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml")
176 public void testFullTreeWithUnpublished(){
178 CdmLightExportConfigurator config
= new CdmLightExportConfigurator(null);
179 config
.setTarget(TARGET
.EXPORT_DATA
);
180 config
.getTaxonNodeFilter().setIncludeUnpublished(true);
182 ExportResult result
= defaultExport
.invoke(config
);
183 testExceptionsErrorsWarnings(result
);
184 ExportDataWrapper
<?
> exportData
= result
.getExportData();
185 @SuppressWarnings("unchecked")
186 Map
<String
, byte[]> data
= (Map
<String
, byte[]>) exportData
.getExportData();
188 ByteArrayInputStream stream
= new ByteArrayInputStream( data
.get(CdmLightExportTable
.TAXON
.getTableName()));
189 BufferedReader reader
= new BufferedReader(new InputStreamReader(stream
, Charset
.forName("UTF-8")));
193 while ((line
= reader
.readLine()) != null) {
196 Assert
.assertTrue("There should be 5 taxa", count
== 6);// 6 because of the header line
198 stream
= new ByteArrayInputStream(data
.get(CdmLightExportTable
.REFERENCE
.getTableName()));
199 reader
= new BufferedReader(new InputStreamReader(stream
, Charset
.forName("UTF-8")));
201 while ((line
= reader
.readLine()) != null) {
204 Assert
.assertTrue("There should be 7 references (6 nomenclatural references and 1 sec reference)", count
== 8);
205 stream
= new ByteArrayInputStream(data
.get(CdmLightExportTable
.SYNONYM
.getTableName()));
206 reader
= new BufferedReader(new InputStreamReader(stream
, Charset
.forName("UTF-8")));
208 while ((line
= reader
.readLine()) != null) {
211 Assert
.assertTrue("There should be 1 synonym", count
== 2);
212 } catch (IOException e
) {
214 Assert
.fail("IO Exception thrown during test.");
216 byte[] taxon
= data
.get(CdmLightExportTable
.TAXON
.getTableName());
217 Assert
.assertNotNull("Taxon table must not be null", taxon
);
218 String taxonStr
= new String(taxon
);
219 String notExpected
= "\"9182e136-f2e2-4f9a-9010-3f35908fb5e0\"";
220 Assert
.assertFalse("Result must not contain root taxon", taxonStr
.startsWith(notExpected
));
221 String expected
= "\"b2c86698-500e-4efb-b9ae-6bb6e701d4bc\",\"4096df99-7274-421e-8843-211b603d832e\",\"CdmLightExportTest Classification\",\"3483cc5e-4c77-4c80-8cb0-73d43df31ee3\",\"9182e136-f2e2-4f9a-9010-3f35908fb5e0\",\"4b6acca1-959b-4790-b76e-e474a0882990\",\"My sec ref\"";
222 Assert
.assertTrue(taxonStr
.contains(expected
));
224 byte[] reference
= data
.get(CdmLightExportTable
.REFERENCE
.getTableName());
225 String referenceString
= new String(reference
);
226 Assert
.assertNotNull("Reference table must not be null", reference
);
227 expected
="\"b8dd7f4a-0c7f-4372-bc5d-3b676363bc0f\",\"Mill. 1804\",\"\",\"The book of botany\",\"1804\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"3\",\"1804\",\"Mill.\"";
228 Assert
.assertTrue(referenceString
.contains(expected
));
230 byte[] geographicAreaFact
= data
.get(CdmLightExportTable
.GEOGRAPHIC_AREA_FACT
.getTableName());
231 String geographicAreaFactString
= new String(geographicAreaFact
);
232 Assert
.assertNotNull("Geographical fact table must not be null", geographicAreaFact
);
233 expected
="\"674e9e27-9102-4166-8626-8cb871a9a89b\",\"b2c86698-500e-4efb-b9ae-6bb6e701d4bc\",\"Africa\",\"present\"";
234 Assert
.assertTrue(geographicAreaFactString
.contains(expected
));
236 byte[] nomenclaturalAuthor
= data
.get(CdmLightExportTable
.NOMENCLATURAL_AUTHOR
.getTableName());
237 String nomenclaturalAuthorString
= new String(nomenclaturalAuthor
);
238 Assert
.assertNotNull("Nomenclatural Author table must not be null", nomenclaturalAuthor
);
239 expected
="\"Mill.\",\"Mill.\",\"\",\"\",\"\",\"\"";
240 Assert
.assertTrue(nomenclaturalAuthorString
.contains(expected
));
242 byte[] scientificName
= data
.get(CdmLightExportTable
.SCIENTIFIC_NAME
.getTableName());
243 String scientificNameString
= new String(scientificName
);
244 Assert
.assertNotNull("Scientific Name table must not be null", scientificName
);
245 expected
="\"3483cc5e-4c77-4c80-8cb0-73d43df31ee3\",\"\",\"Subspecies\",\"43\",\"Genus species subsp. subspec Mill.\",\"Genus species subsp. subspec\",\"Genus\",\"\",\"\",\"species\",\"subsp.\",\"subspec\",\"\",\"\",\"\",";
246 Assert
.assertTrue(scientificNameString
.contains(expected
));
247 expected
="\"Book\",\"The book of botany\",\"The book of botany\",\"Mill.\",\"Mill.\",\"3:22\",\"3\",\"22\",\"1804\",\"1804\",\"\",\"\",\"\",\"\"";
248 Assert
.assertTrue(scientificNameString
.contains(expected
));
250 byte[] homotypicGroup
= data
.get(CdmLightExportTable
.HOMOTYPIC_GROUP
.getTableName());
251 String homotypicGroupString
= new String(homotypicGroup
);
252 Assert
.assertNotNull("Reference table must not be null", homotypicGroup
);
253 if (config
.isAddHTML()){
254 expected
="\"<i>Genus</i> <i>species</i> subsp. <i>subspec</i> Mill., The book of botany 3: 22. 1804\",\"\",\"\",\"<i>Genus</i> <i>species</i> subsp. <i>subspec</i> Mill., The book of botany 3: 22. 1804\",\"\",\"\"";
256 expected
="\"Genus species subsp. subspec Mill., The book of botany 3: 22. 1804\",\"\",\"\",\"Genus species subsp. subspec Mill., The book of botany 3: 22. 1804\",\"\",\"\"";
258 Assert
.assertTrue(homotypicGroupString
.contains(expected
));
263 @DataSet(loadStrategy
=CleanSweepInsertLoadStrategy
.class, value
="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
264 @DataSet(value
="/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml")
266 public void testFullData(){
268 CdmLightExportConfigurator config
= new CdmLightExportConfigurator(null);
269 config
.setTarget(TARGET
.EXPORT_DATA
);
271 ExportResult result
= defaultExport
.invoke(config
);
272 testExceptionsErrorsWarnings(result
);
274 ExportDataWrapper
<?
> exportData
= result
.getExportData();
275 @SuppressWarnings("unchecked")
276 Map
<String
, byte[]> data
= (Map
<String
, byte[]>) exportData
.getExportData();
278 ByteArrayInputStream stream
= new ByteArrayInputStream( data
.get(CdmLightExportTable
.TAXON
.getTableName()));
279 BufferedReader reader
= new BufferedReader(new InputStreamReader(stream
, Charset
.forName("UTF-8")));
283 while ((line
= reader
.readLine()) != null) {
286 Assert
.assertTrue("There should be 4 taxa", count
== 5);// 5 because of the header line
288 stream
= new ByteArrayInputStream(data
.get(CdmLightExportTable
.REFERENCE
.getTableName()));
289 reader
= new BufferedReader(new InputStreamReader(stream
, Charset
.forName("UTF-8")));
291 while ((line
= reader
.readLine()) != null) {
294 Assert
.assertTrue("There should be 5 references", count
== 6);
296 stream
= new ByteArrayInputStream(data
.get(CdmLightExportTable
.SYNONYM
.getTableName()));
297 // now there are always all tables also if empty
298 reader
= new BufferedReader(new InputStreamReader(stream
, Charset
.forName("UTF-8")));
300 while ((line
= reader
.readLine()) != null) {
303 Assert
.assertTrue("There should be 0 synomyms", count
== 1);
304 // Assert.fail("There should not be a synonym table, because the only synonym is not public.");
305 }catch(NullPointerException e
){
306 //OK, should be thrown
308 } catch (IOException e
) {
309 throw new RuntimeException(e
);
315 @DataSet(loadStrategy
=CleanSweepInsertLoadStrategy
.class, value
="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
316 @DataSet(value
="/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml")
318 public void testFullSampleData(){
320 commonService
.createFullSampleData();
321 commitAndStartNewTransaction();
324 CdmLightExportConfigurator config
= new CdmLightExportConfigurator(null);
325 config
.setTarget(TARGET
.EXPORT_DATA
);
327 ExportResult result
= defaultExport
.invoke(config
);
328 testExceptionsErrorsWarnings(result
);
331 private void testExceptionsErrorsWarnings(ExportResult result
) {
332 Assert
.assertTrue(result
.getExceptions().size() == 0);
333 Assert
.assertTrue(result
.getErrors().size() == 0);
334 Assert
.assertTrue(result
.getWarnings().size() == 0);
337 public void createFullTestDataSet() {
338 Set
<TaxonNode
> nodesToSave
= new HashSet
<>();
340 Reference sec1
= ReferenceFactory
.newGeneric();
341 setUuid(sec1
, "4b6acca1-959b-4790-b76e-e474a0882990");
342 sec1
.setTitle("My sec ref");
344 Classification classification
= Classification
.NewInstance("CdmLightExportTest Classification");
345 setUuid(classification
, "4096df99-7274-421e-8843-211b603d832e");
347 NonViralNameParserImpl parser
= NonViralNameParserImpl
.NewInstance();
348 TaxonName familyName
= parser
.parseReferencedName("Family L., Sp. Pl. 3: 22. 1752",
349 NomenclaturalCode
.ICNAFP
, Rank
.FAMILY());
350 setUuid(familyName
,"e983cc5e-4c77-4c80-8cb0-73d43df31ef7");
351 setUuid(familyName
.getNomenclaturalReference(), "b0dd7f4a-0c7f-4372-bc5d-3b676363bc63");
352 Taxon family
= Taxon
.NewInstance(familyName
, sec1
);
353 setUuid(family
,"3162e136-f2e2-4f9a-9010-3f35908fbae1");
354 TaxonNode node1
= classification
.addChildTaxon(family
, sec1
, "22");
355 setUuid(node1
, "0fae5ad5-ffa2-4100-bcd7-8aa9dda0aebc");
356 nodesToSave
.add(node1
);
358 TaxonName genusName
= parser
.parseReferencedName("Genus Humb., The book of botany 3: 22. 1804",
359 NomenclaturalCode
.ICNAFP
, Rank
.GENUS());
360 setUuid(genusName
,"5e83cc5e-4c77-4d80-8cb0-73d63df35ee3");
361 setUuid(genusName
.getNomenclaturalReference(), "5ed27f4a-6c7f-4372-bc5d-3b67636abc52");
362 Taxon genus
= Taxon
.NewInstance(genusName
, sec1
);
363 setUuid(genus
,"3f52e136-f2e1-4f9a-9010-2f35908fbd39");
365 TaxonNode node2
= node1
.addChildTaxon(genus
, sec1
, "33");
366 setUuid(node2
, "43ca733b-fe3a-42ce-8a92-000e27badf44");
367 nodesToSave
.add(node2
);
369 TaxonName speciesName
= parser
.parseReferencedName("Genus species Mill., The book of botany 3: 22. 1804",
370 NomenclaturalCode
.ICNAFP
, Rank
.SPECIES());
371 setUuid(speciesName
,"f983cc5e-4c77-4c80-8cb0-73d43df31ee9");
372 setUuid(speciesName
.getNomenclaturalReference(), "a0dd7f4a-0c7f-4372-bc5d-3b676363bc0e");
373 Taxon species
= Taxon
.NewInstance(speciesName
, sec1
);
374 setUuid(species
,"9182e136-f2e2-4f9a-9010-3f35908fb5e0");
375 TaxonName synonymName
= parser
.parseReferencedName("Genus synonym Mill., The book of botany 3: 22. 1804", NomenclaturalCode
.ICNAFP
, Rank
.SPECIES());
377 setUuid(synonymName
, "1584157b-5c43-4150-b271-95b2c99377b2");
378 Synonym synonymUnpublished
= Synonym
.NewInstance(synonymName
, sec1
);
379 setUuid(synonymName
, "a87c16b7-8299-4d56-a682-ce20973428ea");
380 synonymUnpublished
.setPublish(false);
381 species
.addHomotypicSynonym(synonymUnpublished
);
382 TaxonNode node3
= node2
.addChildTaxon(species
, sec1
, "33");
383 setUuid(node3
, "a0c9733a-fe3a-42ce-8a92-000e27bfdfa3");
384 nodesToSave
.add(node3
);
386 TaxonName subspeciesName
= parser
.parseReferencedName("Genus species subsp. subspec Mill., The book of botany 3: 22. 1804",
387 NomenclaturalCode
.ICNAFP
, Rank
.SUBSPECIES());
388 setUuid(subspeciesName
,"3483cc5e-4c77-4c80-8cb0-73d43df31ee3");
389 setUuid(subspeciesName
.getNomenclaturalReference(), "b8dd7f4a-0c7f-4372-bc5d-3b676363bc0f");
391 Taxon subspecies
= Taxon
.NewInstance(subspeciesName
, sec1
);
392 setUuid(subspecies
, "b2c86698-500e-4efb-b9ae-6bb6e701d4bc");
393 TaxonNode node4
= node3
.addChildTaxon(subspecies
, sec1
, "33");
394 setUuid(node4
, "f8c9933a-fe3a-42ce-8a92-000e27bfdfac");
395 nodesToSave
.add(node4
);
397 TaxonName subspeciesNameUnpublished
= parser
.parseReferencedName("Genus species subsp. unpublished Mill., The book of botany 3: 22. 1804",
398 NomenclaturalCode
.ICNAFP
, Rank
.SUBSPECIES());
399 setUuid(subspeciesNameUnpublished
,"b6da7ab2-6c67-44b7-9719-2557542f5a23");
401 Taxon subspeciesUnpublished
= Taxon
.NewInstance(subspeciesNameUnpublished
, sec1
);
402 setUuid(subspeciesUnpublished
, "290e295a-9089-4616-a30c-15ded79e064f");
403 subspeciesUnpublished
.setPublish(false);
404 TaxonNode node5
= node3
.addChildTaxon(subspeciesUnpublished
, sec1
, "33");
405 setUuid(node5
, "81d9c9b2-c8fd-4d4f-a0b4-e7e656dcdc20");
406 nodesToSave
.add(node5
);
408 classificationService
.save(classification
);
409 taxonNodeService
.save(nodesToSave
);
411 TaxonDescription description
= TaxonDescription
.NewInstance(species
);
413 Distribution distribution
= Distribution
.NewInstance(NamedArea
.AFRICA(), PresenceAbsenceTerm
.PRESENT());
414 setUuid(distribution
,"674e9e27-9102-4166-8626-8cb871a9a89b");
415 description
.addElement(distribution
);
417 subspecies
.addDescription(description
);
418 commitAndStartNewTransaction(null);
421 private void setUuid(CdmBase cdmBase
, String uuidStr
) {
422 cdmBase
.setUuid(UUID
.fromString(uuidStr
));
426 public void createTestDataSet() throws FileNotFoundException
{
428 // writeDbUnitDataSetFile(new String[] {
430 // }, "testAttachDnaSampleToDerivedUnit");
431 // } catch (FileNotFoundException e) {
432 // e.printStackTrace();