2 * Copyright (C) 2017 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
.owl
.out
;
12 import java
.io
.FileNotFoundException
;
14 import java
.util
.Collections
;
15 import java
.util
.List
;
16 import java
.util
.UUID
;
18 import org
.apache
.log4j
.Logger
;
19 import org
.junit
.Test
;
20 import org
.unitils
.dbunit
.annotation
.DataSet
;
21 import org
.unitils
.spring
.annotation
.SpringBeanByName
;
22 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
24 import eu
.etaxonomy
.cdm
.api
.service
.IClassificationService
;
25 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonNodeService
;
26 import eu
.etaxonomy
.cdm
.api
.service
.ITermTreeService
;
27 import eu
.etaxonomy
.cdm
.common
.URI
;
28 import eu
.etaxonomy
.cdm
.io
.common
.CdmApplicationAwareDefaultExport
;
29 import eu
.etaxonomy
.cdm
.io
.common
.ExportDataWrapper
;
30 import eu
.etaxonomy
.cdm
.io
.common
.ExportResult
;
31 import eu
.etaxonomy
.cdm
.io
.common
.IExportConfigurator
.TARGET
;
32 import eu
.etaxonomy
.cdm
.io
.descriptive
.owl
.out
.StructureTreeOwlExportConfigurator
;
33 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
34 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
35 import eu
.etaxonomy
.cdm
.model
.term
.TermNode
;
36 import eu
.etaxonomy
.cdm
.model
.term
.TermTree
;
37 import eu
.etaxonomy
.cdm
.model
.term
.TermType
;
38 import eu
.etaxonomy
.cdm
.model
.term
.TermVocabulary
;
39 import eu
.etaxonomy
.cdm
.test
.integration
.CdmTransactionalIntegrationTest
;
40 import eu
.etaxonomy
.cdm
.test
.unitils
.CleanSweepInsertLoadStrategy
;
46 public class OwlExportTest
extends CdmTransactionalIntegrationTest
{
47 @SuppressWarnings("unused")
48 private static final Logger logger
= Logger
.getLogger(OwlExportTest
.class);
51 private CdmApplicationAwareDefaultExport
<StructureTreeOwlExportConfigurator
> defaultExport
;
54 private IClassificationService classificationService
;
57 private ITermTreeService termTreeService
;
60 private ITaxonNodeService taxonNodeService
;
64 @DataSet(loadStrategy
=CleanSweepInsertLoadStrategy
.class, value
="/eu/etaxonomy/cdm/database/ClearDBDataSet.xml")
65 public void testEmptyData(){
66 File destinationFolder
= null;
67 StructureTreeOwlExportConfigurator config
= StructureTreeOwlExportConfigurator
.NewInstance();
68 config
.setFeatureTreeUuids(createFeatureTree());
69 config
.setVocabularyUuids(Collections
.EMPTY_LIST
);
70 config
.setDestination(destinationFolder
);
71 config
.setTarget(TARGET
.EXPORT_DATA
);
72 ExportResult result
= defaultExport
.invoke(config
);
73 System
.out
.println(result
.createReport());
74 ExportDataWrapper
<?
> exportData
= result
.getExportData();
77 public List
<UUID
> createFeatureTree() {
78 TermTree
<Feature
> tree
= TermTree
.NewFeatureInstance();
79 TermVocabulary
<Feature
> voc
= TermVocabulary
.NewInstance(TermType
.Feature
, Feature
.class,
80 "voc description", "vocabulary", "voc", URI
.create("http://test.voc"));
82 Feature featureA
= Feature
.NewInstance("A", "A", "A");
83 voc
.addTerm(featureA
);
84 TermNode
<Feature
> nodeA
= tree
.getRoot().addChild(featureA
);
86 Feature featureA1
= Feature
.NewInstance("A1", "A1", "A1");
87 voc
.addTerm(featureA1
);
88 TermNode
<Feature
> nodeA1
= nodeA
.addChild(featureA1
);
90 Feature featureA2
= Feature
.NewInstance("A2", "A2", "A2");
91 voc
.addTerm(featureA2
);
92 TermNode
<Feature
> nodeA2
= nodeA
.addChild(featureA2
);
94 Feature featureB
= Feature
.NewInstance("B", "B", "B");
95 voc
.addTerm(featureB
);
96 TermNode
<Feature
> nodeB
= tree
.getRoot().addChild(featureB
);
98 Feature featureB1
= Feature
.NewInstance("B", "B1", "B1");
99 voc
.addTerm(featureB1
);
100 TermNode
<Feature
> nodeB1
= nodeB
.addChild(featureB1
);
102 Feature featureC
= Feature
.NewInstance("C", "C", "C");
103 voc
.addTerm(featureC
);
104 TermNode
<Feature
> nodeC
= tree
.getRoot().addChild(featureC
);
106 termTreeService
.save(tree
);
107 return Collections
.singletonList(tree
.getUuid());
111 public void createTestDataSet() throws FileNotFoundException
{
113 // writeDbUnitDataSetFile(new String[] {
115 // }, "testAttachDnaSampleToDerivedUnit");
116 // } catch (FileNotFoundException e) {
117 // e.printStackTrace();
122 private void setUuid(CdmBase cdmBase
, String uuidStr
) {
123 cdmBase
.setUuid(UUID
.fromString(uuidStr
));