Project

General

Profile

Download (23.2 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 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.io.cdmLight.out;
10

    
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;
18
import java.util.Map;
19
import java.util.Set;
20
import java.util.UUID;
21

    
22
import org.apache.logging.log4j.LogManager;
23
import org.apache.logging.log4j.Logger;
24
import org.junit.Assert;
25
import org.junit.Before;
26
import org.junit.Test;
27
import org.unitils.dbunit.annotation.DataSet;
28
import org.unitils.dbunit.annotation.DataSets;
29
import org.unitils.spring.annotation.SpringBeanByName;
30
import org.unitils.spring.annotation.SpringBeanByType;
31

    
32
import eu.etaxonomy.cdm.api.service.IClassificationService;
33
import eu.etaxonomy.cdm.api.service.ICommonService;
34
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
35
import eu.etaxonomy.cdm.api.service.ITermService;
36
import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
37
import eu.etaxonomy.cdm.io.cdmLight.CdmLightExportConfigurator;
38
import eu.etaxonomy.cdm.io.cdmLight.CdmLightExportTable;
39
import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultExport;
40
import eu.etaxonomy.cdm.io.common.ExportDataWrapper;
41
import eu.etaxonomy.cdm.io.common.ExportResult;
42
import eu.etaxonomy.cdm.io.common.IExportConfigurator.TARGET;
43
import eu.etaxonomy.cdm.model.common.CdmBase;
44
import eu.etaxonomy.cdm.model.common.Language;
45
import eu.etaxonomy.cdm.model.description.Distribution;
46
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
47
import eu.etaxonomy.cdm.model.description.TaxonDescription;
48
import eu.etaxonomy.cdm.model.location.NamedArea;
49
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
50
import eu.etaxonomy.cdm.model.name.Rank;
51
import eu.etaxonomy.cdm.model.name.TaxonName;
52
import eu.etaxonomy.cdm.model.reference.Reference;
53
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
54
import eu.etaxonomy.cdm.model.taxon.Classification;
55
import eu.etaxonomy.cdm.model.taxon.Synonym;
56
import eu.etaxonomy.cdm.model.taxon.Taxon;
57
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
58
import eu.etaxonomy.cdm.model.taxon.TaxonNodeStatus;
59
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
60
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
61
import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy;
62

    
63
/**
64
 * @author k.luther
65
 * @since 17.01.2018
66
 */
67
public class CdmLightExportTest extends CdmTransactionalIntegrationTest{
68

    
69
        @SuppressWarnings("unused")
70
        private static final Logger logger = LogManager.getLogger(CdmLightExportTest.class);
71

    
72
        @SpringBeanByName
73
        private CdmApplicationAwareDefaultExport<CdmLightExportConfigurator> defaultExport;
74

    
75
        @SpringBeanByType
76
        private IClassificationService classificationService;
77

    
78
        @SpringBeanByType
79
        private ITermService termService;
80

    
81
        @SpringBeanByType
82
        private ITaxonNodeService taxonNodeService;
83

    
84
        @SpringBeanByType
85
        private ICommonService commonService;
86

    
87
        @Before
88
        public void setUp()  {
89
            createFullTestDataSet();
90
        }
91

    
92
        @Test
93
        @DataSets({
94
            @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
95
            @DataSet(value="/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml")
96
        })
97
        public void testSubTree(){
98

    
99
            CdmLightExportConfigurator config = CdmLightExportConfigurator.NewInstance();
100
            config.setTaxonNodeFilter(TaxonNodeFilter.NewSubtreeInstance(UUID.fromString("f8c9933a-fe3a-42ce-8a92-000e27bfdfac")));
101

    
102
            config.setTarget(TARGET.EXPORT_DATA);
103
            ExportResult result = defaultExport.invoke(config);
104
            ExportDataWrapper<?> exportData = result.getExportData();
105
            testExceptionsErrorsWarnings(result);
106

    
107
            @SuppressWarnings("unchecked")
108
            Map<String, byte[]> data = (Map<String, byte[]>) exportData.getExportData();
109

    
110
            byte[] taxonByte = data.get(CdmLightExportTable.TAXON.getTableName());
111
            Assert.assertNotNull("Taxon table must not be null", taxonByte);
112
            String taxonStr = new String(taxonByte);
113
            String notExpected = "\"9182e136-f2e2-4f9a-9010-3f35908fb5e0\"";
114
            Assert.assertFalse("Result must not contain root taxon", taxonStr.startsWith(notExpected));
115
            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\"";
116
            Assert.assertTrue(taxonStr.contains(expected));
117

    
118
            byte[] reference = data.get(CdmLightExportTable.REFERENCE.getTableName());
119
            String referenceString = new String(reference);
120
            Assert.assertNotNull("Reference table must not be null", reference);
121
            expected ="\"b8dd7f4a-0c7f-4372-bc5d-3b676363bc0f\",\"Mill. (1804)\",\"\",\"The book of botany\",\"1804\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"3\",\"1804\",\"Mill.\"";
122
            Assert.assertTrue(referenceString.contains(expected));
123

    
124
            byte[] geographicAreaFact = data.get(CdmLightExportTable.GEOGRAPHIC_AREA_FACT.getTableName());
125
            String geographicAreaFactString = new String(geographicAreaFact);
126
            Assert.assertNotNull("Geographical fact table must not be null", geographicAreaFact);
127
            expected ="\"674e9e27-9102-4166-8626-8cb871a9a89b\",\"b2c86698-500e-4efb-b9ae-6bb6e701d4bc\",\"Africa\",\"present\"";
128
            Assert.assertTrue(geographicAreaFactString.contains(expected));
129

    
130
            byte[] nomenclaturalAuthor = data.get(CdmLightExportTable.NOMENCLATURAL_AUTHOR.getTableName());
131
            String nomenclaturalAuthorString = new String(nomenclaturalAuthor);
132
            Assert.assertNotNull("Nomenclatural Author table must not be null", nomenclaturalAuthor);
133
            expected ="\"Mill.\",\"Mill.\",\"\",\"\",\"\",\"\"";
134
            Assert.assertTrue(nomenclaturalAuthorString.contains(expected));
135

    
136
            byte[] scientificName = data.get(CdmLightExportTable.SCIENTIFIC_NAME.getTableName());
137
            String scientificNameString = new String(scientificName);
138
            Assert.assertNotNull("Scientific Name table must not be null", scientificName);
139
            expected ="\"3483cc5e-4c77-4c80-8cb0-73d43df31ee3\",\"\",\"Subspecies\",\"43\",\"Genus species subsp. subspec Mill.\",\"Genus species subsp. subspec\",\"Genus\",\"\",\"\",\"species\",\"subsp.\",\"subspec\",\"\",\"\",\"\",";
140
            Assert.assertTrue(scientificNameString.contains(expected));
141
            if (config.isAddHTML()){
142
                expected = "\"<i>Genus</i> <i>species</i> subsp. <i>subspec</i> Mill., The book of botany 3: 22. 1804\"";
143
                Assert.assertTrue(scientificNameString.contains(expected));
144
            }
145

    
146
            expected ="\"Book\",\"The book of botany\",\"The book of botany\",\"Mill.\",\"Mill.\",\"3:22\",\"3\",\"22\",\"1804\",\"1804\",\"\",\"\",\"\",\"\"";
147
            Assert.assertTrue(scientificNameString.contains(expected));
148

    
149
            byte[] homotypicGroup = data.get(CdmLightExportTable.HOMOTYPIC_GROUP.getTableName());
150
            String homotypicGroupString = new String(homotypicGroup);
151
            Assert.assertNotNull("Reference table must not be null", homotypicGroup);
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
            }else{
155
                expected ="\"= Genus species subsp. subspec Mill., The book of botany 3: 22. 1804\",\"\"";
156
            }
157
            Assert.assertTrue(homotypicGroupString.contains(expected));
158
        }
159

    
160
        @Test
161
        @DataSets({
162
            @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
163
            @DataSet(value="/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml")
164
        })
165
        public void testFullTreeWithUnpublished(){
166

    
167
            CdmLightExportConfigurator config = CdmLightExportConfigurator.NewInstance();
168
            config.setTarget(TARGET.EXPORT_DATA);
169
            config.getTaxonNodeFilter().setIncludeUnpublished(true);
170

    
171
            ExportResult result = defaultExport.invoke(config);
172
            testExceptionsErrorsWarnings(result);
173
            ExportDataWrapper<?> exportData = result.getExportData();
174
            @SuppressWarnings("unchecked")
175
            Map<String, byte[]> data = (Map<String, byte[]>) exportData.getExportData();
176

    
177
            ByteArrayInputStream stream = new ByteArrayInputStream( data.get(CdmLightExportTable.TAXON.getTableName()));
178
            BufferedReader reader = new BufferedReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
179

    
180
            int count = 0;
181
            try {
182
                while (reader.readLine() != null) {
183
                    count ++;
184
                }
185
                Assert.assertTrue("There should be 5 taxa", count == 5+1);// 1 header line
186

    
187
                stream = new ByteArrayInputStream(data.get(CdmLightExportTable.REFERENCE.getTableName()));
188
                reader = new BufferedReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
189
                count = 0;
190
                while (reader.readLine() != null) {
191
                    count ++;
192
                }
193
                Assert.assertTrue("There should be 7 references (6 nomenclatural references and 1 sec reference)", count == 7+1);  //1 header line
194
                stream = new ByteArrayInputStream(data.get(CdmLightExportTable.SYNONYM.getTableName()));
195
                reader = new BufferedReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
196
                count = 0;
197
                while (reader.readLine() != null) {
198
                    count ++;
199
                }
200
                Assert.assertTrue("There should be 1 synonym", count == 1+1);  // 1 header line
201
            } catch (IOException e) {
202
                e.printStackTrace();
203
                Assert.fail("IO Exception thrown during test.");
204
            }
205
            byte[] taxonByte = data.get(CdmLightExportTable.TAXON.getTableName());
206
            Assert.assertNotNull("Taxon table must not be null", taxonByte);
207
            String taxonStr = new String(taxonByte);
208
            String notExpected = "\"9182e136-f2e2-4f9a-9010-3f35908fb5e0\"";
209
            Assert.assertFalse("Result must not contain root taxon", taxonStr.startsWith(notExpected));
210
            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\"";
211
            Assert.assertTrue(taxonStr.contains(expected));
212
            String expectedExcluded = "\"1\",\"My status note [My sec ref: 27]\"";
213
            Assert.assertTrue(taxonStr.contains(expectedExcluded));
214

    
215
            byte[] reference = data.get(CdmLightExportTable.REFERENCE.getTableName());
216
            String referenceString = new String(reference);
217
            Assert.assertNotNull("Reference table must not be null", reference);
218
            expected ="\"b8dd7f4a-0c7f-4372-bc5d-3b676363bc0f\",\"Mill. (1804)\",\"\",\"The book of botany\",\"1804\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"3\",\"1804\",\"Mill.\"";
219
            Assert.assertTrue(referenceString.contains(expected));
220

    
221
            byte[] geographicAreaFact = data.get(CdmLightExportTable.GEOGRAPHIC_AREA_FACT.getTableName());
222
            String geographicAreaFactString = new String(geographicAreaFact);
223
            Assert.assertNotNull("Geographical fact table must not be null", geographicAreaFact);
224
            expected ="\"674e9e27-9102-4166-8626-8cb871a9a89b\",\"b2c86698-500e-4efb-b9ae-6bb6e701d4bc\",\"Africa\",\"present\"";
225
            Assert.assertTrue(geographicAreaFactString.contains(expected));
226

    
227
            byte[] nomenclaturalAuthor = data.get(CdmLightExportTable.NOMENCLATURAL_AUTHOR.getTableName());
228
            String nomenclaturalAuthorString = new String(nomenclaturalAuthor);
229
            Assert.assertNotNull("Nomenclatural Author table must not be null", nomenclaturalAuthor);
230
            expected ="\"Mill.\",\"Mill.\",\"\",\"\",\"\",\"\"";
231
            Assert.assertTrue(nomenclaturalAuthorString.contains(expected));
232

    
233
            byte[] scientificName = data.get(CdmLightExportTable.SCIENTIFIC_NAME.getTableName());
234
            String scientificNameString = new String(scientificName);
235
            Assert.assertNotNull("Scientific Name table must not be null", scientificName);
236
            expected ="\"3483cc5e-4c77-4c80-8cb0-73d43df31ee3\",\"\",\"Subspecies\",\"43\",\"Genus species subsp. subspec Mill.\",\"Genus species subsp. subspec\",\"Genus\",\"\",\"\",\"species\",\"subsp.\",\"subspec\",\"\",\"\",\"\",";
237
            Assert.assertTrue(scientificNameString.contains(expected));
238
            expected ="\"Book\",\"The book of botany\",\"The book of botany\",\"Mill.\",\"Mill.\",\"3:22\",\"3\",\"22\",\"1804\",\"1804\",\"\",\"\",\"\",\"\"";
239
            Assert.assertTrue(scientificNameString.contains(expected));
240

    
241
            byte[] homotypicGroup = data.get(CdmLightExportTable.HOMOTYPIC_GROUP.getTableName());
242
            String homotypicGroupString = new String(homotypicGroup);
243
            Assert.assertNotNull("Reference table must not be null", homotypicGroup);
244
            if (config.isAddHTML()){
245
                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 My sec ref\",\"\",\"\"";
246
            }else{
247
                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) My sec ref\",\"\",\"\"";
248
            }
249
            Assert.assertTrue(homotypicGroupString.contains(expected));
250
        }
251

    
252
        @Test
253
        @DataSets({
254
            @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
255
            @DataSet(value="/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml")
256
        })
257
        public void testFullData(){
258

    
259
            CdmLightExportConfigurator config = CdmLightExportConfigurator.NewInstance();
260
            config.setTarget(TARGET.EXPORT_DATA);
261

    
262
            ExportResult result = defaultExport.invoke(config);
263
            testExceptionsErrorsWarnings(result);
264

    
265
            ExportDataWrapper<?> exportData = result.getExportData();
266
            @SuppressWarnings("unchecked")
267
            Map<String, byte[]> data = (Map<String, byte[]>) exportData.getExportData();
268

    
269
            ByteArrayInputStream stream = new ByteArrayInputStream( data.get(CdmLightExportTable.TAXON.getTableName()));
270
            BufferedReader reader = new BufferedReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
271
            String line;
272
            int count = 0;
273
            try {
274
                while ((line = reader.readLine()) != null) {
275
                    count ++;
276
                }
277
                Assert.assertTrue("There should be 4 taxa", count == 5);// 5 because of the header line
278

    
279
                stream = new ByteArrayInputStream(data.get(CdmLightExportTable.REFERENCE.getTableName()));
280
                reader = new BufferedReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
281
                count = 0;
282
                while ((line = reader.readLine()) != null) {
283
                    count ++;
284
                }
285
                Assert.assertTrue("There should be 5 references", count == 6);
286
                try{
287
                    stream = new ByteArrayInputStream(data.get(CdmLightExportTable.SYNONYM.getTableName()));
288
                    // now there are always all tables also if empty
289
                    reader = new BufferedReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
290

    
291
                    boolean dummyLine = true;
292
                    count = 0;
293
                    while ((line = reader.readLine()) != null) {
294
                        if (!(line.startsWith("\"DUMMY") || line.startsWith("\"Synonym_ID"))){
295
                            dummyLine = dummyLine && false;
296
                        }
297
                        count++;
298
                    }
299
                    Assert.assertTrue("There should be 0 synomyms", dummyLine && count == 3);
300
//                    Assert.fail("There should not be a synonym table, because the only synonym is not public.");
301
                }catch(NullPointerException e){
302
                    //OK, should be thrown
303
                }
304
            } catch (IOException e) {
305
                throw new RuntimeException(e);
306
            }
307
        }
308

    
309
        @Test
310
        @DataSets({
311
            @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
312
            @DataSet(value="/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml")
313
        })
314
        public void testFullSampleData(){
315

    
316
            commonService.createFullSampleData();
317
            commitAndStartNewTransaction();
318

    
319

    
320
            CdmLightExportConfigurator config = CdmLightExportConfigurator.NewInstance();
321
            config.setTarget(TARGET.EXPORT_DATA);
322

    
323
            ExportResult result = defaultExport.invoke(config);
324
            testExceptionsErrorsWarnings(result);
325
        }
326

    
327
        private void testExceptionsErrorsWarnings(ExportResult result) {
328
            Assert.assertTrue(result.getExceptions().size() == 0);
329
            Assert.assertTrue(result.getErrors().size() == 0);
330
            Assert.assertTrue(result.getWarnings().size() == 0);
331
        }
332

    
333
        public void createFullTestDataSet() {
334

    
335
            Set<TaxonNode> nodesToSave = new HashSet<>();
336

    
337
            Reference sec1 = ReferenceFactory.newGeneric();
338
            setUuid(sec1, "4b6acca1-959b-4790-b76e-e474a0882990");
339
            sec1.setTitle("My sec ref");
340

    
341
            Classification classification = Classification.NewInstance("CdmLightExportTest Classification");
342
            setUuid(classification, "4096df99-7274-421e-8843-211b603d832e");
343

    
344
            NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();
345
            TaxonName familyName = parser.parseReferencedName("Family L., Sp. Pl. 3: 22. 1752",
346
                    NomenclaturalCode.ICNAFP, Rank.FAMILY());
347
            setUuid(familyName,"e983cc5e-4c77-4c80-8cb0-73d43df31ef7");
348
            setUuid(familyName.getNomenclaturalReference(), "b0dd7f4a-0c7f-4372-bc5d-3b676363bc63");
349
            Taxon family = Taxon.NewInstance(familyName, sec1);
350
            setUuid(family,"3162e136-f2e2-4f9a-9010-3f35908fbae1");
351
            TaxonNode node1 = classification.addChildTaxon(family, sec1, "22");
352
            setUuid(node1, "0fae5ad5-ffa2-4100-bcd7-8aa9dda0aebc");
353
            nodesToSave.add(node1);
354

    
355
            TaxonName genusName = parser.parseReferencedName("Genus Humb., The book of botany 3: 22. 1804",
356
                    NomenclaturalCode.ICNAFP, Rank.GENUS());
357
            setUuid(genusName,"5e83cc5e-4c77-4d80-8cb0-73d63df35ee3");
358
            setUuid(genusName.getNomenclaturalReference(), "5ed27f4a-6c7f-4372-bc5d-3b67636abc52");
359
            Taxon genus = Taxon.NewInstance(genusName, sec1);
360
            setUuid(genus,"3f52e136-f2e1-4f9a-9010-2f35908fbd39");
361

    
362
            TaxonNode node2 = node1.addChildTaxon(genus, sec1, "33");
363
            setUuid(node2, "43ca733b-fe3a-42ce-8a92-000e27badf44");
364
            nodesToSave.add(node2);
365

    
366
            TaxonName speciesName = parser.parseReferencedName("Genus species Mill., The book of botany 3: 22. 1804",
367
                    NomenclaturalCode.ICNAFP, Rank.SPECIES());
368
            setUuid(speciesName,"f983cc5e-4c77-4c80-8cb0-73d43df31ee9");
369
            setUuid(speciesName.getNomenclaturalReference(), "a0dd7f4a-0c7f-4372-bc5d-3b676363bc0e");
370
            Taxon species = Taxon.NewInstance(speciesName, sec1);
371
            setUuid(species,"9182e136-f2e2-4f9a-9010-3f35908fb5e0");
372
            TaxonName synonymName = parser.parseReferencedName("Genus synonym Mill., The book of botany 3: 22. 1804", NomenclaturalCode.ICNAFP, Rank.SPECIES());
373

    
374
            setUuid(synonymName, "1584157b-5c43-4150-b271-95b2c99377b2");
375
            Synonym  synonymUnpublished = Synonym.NewInstance(synonymName, sec1);
376
            setUuid(synonymName, "a87c16b7-8299-4d56-a682-ce20973428ea");
377
            synonymUnpublished.setPublish(false);
378
            species.addHomotypicSynonym(synonymUnpublished);
379
            TaxonNode node3 = node2.addChildTaxon(species, sec1, "33");
380
            setUuid(node3, "a0c9733a-fe3a-42ce-8a92-000e27bfdfa3");
381
            nodesToSave.add(node3);
382

    
383
            TaxonName subspeciesName = parser.parseReferencedName("Genus species subsp. subspec Mill., The book of botany 3: 22. 1804",
384
                    NomenclaturalCode.ICNAFP, Rank.SUBSPECIES());
385
            setUuid(subspeciesName,"3483cc5e-4c77-4c80-8cb0-73d43df31ee3");
386
            setUuid(subspeciesName.getNomenclaturalReference(), "b8dd7f4a-0c7f-4372-bc5d-3b676363bc0f");
387

    
388
            Taxon subspecies = Taxon.NewInstance(subspeciesName, sec1);
389
            setUuid(subspecies, "b2c86698-500e-4efb-b9ae-6bb6e701d4bc");
390
            TaxonNode node4 = node3.addChildTaxon(subspecies, sec1, "33");
391
            setUuid(node4, "f8c9933a-fe3a-42ce-8a92-000e27bfdfac");
392
            nodesToSave.add(node4);
393

    
394
            TaxonName subspeciesNameUnpublished = parser.parseReferencedName("Genus species subsp. unpublished Mill., The book of botany 3: 22. 1804",
395
                    NomenclaturalCode.ICNAFP, Rank.SUBSPECIES());
396
            setUuid(subspeciesNameUnpublished,"b6da7ab2-6c67-44b7-9719-2557542f5a23");
397

    
398
            Taxon subspeciesUnpublished = Taxon.NewInstance(subspeciesNameUnpublished, sec1);
399
            setUuid(subspeciesUnpublished, "290e295a-9089-4616-a30c-15ded79e064f");
400
            subspeciesUnpublished.setPublish(false);
401
            TaxonNode node5 = node3.addChildTaxon(subspeciesUnpublished, sec1, "33");
402
            //excluded node
403
            setUuid(node5, "81d9c9b2-c8fd-4d4f-a0b4-e7e656dcdc20");
404
            node5.setStatus(TaxonNodeStatus.EXCLUDED);
405
            node5.setCitation(sec1);
406
            node5.setCitationMicroReference("27");
407
            node5.putStatusNote(Language.ENGLISH(), "My status note");
408
            nodesToSave.add(node5);
409

    
410
            classificationService.save(classification);
411
            taxonNodeService.save(nodesToSave);
412

    
413
            TaxonDescription description = TaxonDescription.NewInstance(species);
414

    
415
            Distribution distribution = Distribution.NewInstance(NamedArea.AFRICA(), PresenceAbsenceTerm.PRESENT());
416
            setUuid(distribution,"674e9e27-9102-4166-8626-8cb871a9a89b");
417
            description.addElement(distribution);
418

    
419
            subspecies.addDescription(description);
420
            commitAndStartNewTransaction(null);
421
        }
422

    
423
        private void setUuid(CdmBase cdmBase, String uuidStr) {
424
            cdmBase.setUuid(UUID.fromString(uuidStr));
425
        }
426

    
427
        @Override
428
        public void createTestDataSet() throws FileNotFoundException {}
429
}
    (1-1/1)