1
|
/* just for testing */
|
2
|
/**
|
3
|
* Copyright (C) 2009 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.cdm.test.function;
|
12
|
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.aspectj.PropertyChangeTest;
|
18
|
import eu.etaxonomy.cdm.model.agent.Person;
|
19
|
import eu.etaxonomy.cdm.model.common.Language;
|
20
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
21
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
22
|
import eu.etaxonomy.cdm.model.location.TdwgArea;
|
23
|
import eu.etaxonomy.cdm.model.name.BotanicalName;
|
24
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
|
25
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
26
|
import eu.etaxonomy.cdm.model.name.Rank;
|
27
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
28
|
import eu.etaxonomy.cdm.model.name.ZoologicalName;
|
29
|
//import eu.etaxonomy.cdm.model.reference.Journal;
|
30
|
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
|
31
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
32
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
33
|
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
|
34
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
35
|
|
36
|
|
37
|
public class TestModel {
|
38
|
private static final UUID TEST_TAXON_UUID = UUID.fromString("b3084573-343d-4279-ba92-4ab01bb47db5");
|
39
|
static Logger logger = Logger.getLogger(TestModel.class);
|
40
|
ReferenceFactory refFactory = ReferenceFactory.newInstance();
|
41
|
|
42
|
public void testSomething(){
|
43
|
|
44
|
logger.info("Create name objects...");
|
45
|
logger.info(NomenclaturalStatusType.NUDUM().getRepresentation(Language.LATIN()).getAbbreviatedLabel());
|
46
|
NonViralName tn = NonViralName.NewInstance(Rank.SPECIES());
|
47
|
BotanicalName tn3 = BotanicalName.NewInstance(Rank.SUBSPECIES());
|
48
|
ZoologicalName parentName = ZoologicalName.NewInstance(Rank.FAMILY());
|
49
|
|
50
|
logger.info("Create reference objects...");
|
51
|
ReferenceBase sec = refFactory.newJournal();
|
52
|
sec.setTitleCache("TestJournal", true);
|
53
|
|
54
|
logger.info("Create taxon objects...");
|
55
|
Taxon childTaxon = Taxon.NewInstance(tn, sec);
|
56
|
Synonym syn = Synonym.NewInstance(tn3, sec);
|
57
|
childTaxon.addSynonym(syn, SynonymRelationshipType.SYNONYM_OF());
|
58
|
Taxon parentTaxon = Taxon.NewInstance(parentName, sec);
|
59
|
parentTaxon.setUuid(TEST_TAXON_UUID);
|
60
|
parentTaxon.addTaxonomicChild(childTaxon, sec, null);
|
61
|
|
62
|
// setup listeners
|
63
|
PropertyChangeTest listener = new PropertyChangeTest();
|
64
|
tn.addPropertyChangeListener(listener);
|
65
|
tn3.addPropertyChangeListener(listener);
|
66
|
|
67
|
// test listeners
|
68
|
tn.setGenusOrUninomial("tn1-Genus1");
|
69
|
tn3.setGenusOrUninomial("tn3-genus");
|
70
|
tn3.getGenusOrUninomial();
|
71
|
|
72
|
logger.info("Create new Author agent...");
|
73
|
Person team= Person.NewInstance();
|
74
|
team.addPropertyChangeListener(listener);
|
75
|
team.setTitleCache("AuthorAgent1", true);
|
76
|
tn.setCombinationAuthorTeam(team);
|
77
|
}
|
78
|
|
79
|
public void testParentRelation(){
|
80
|
TaxonNameBase taxonName = BotanicalName.NewInstance(Rank.SPECIES());
|
81
|
ReferenceBase ref = refFactory.newJournal();
|
82
|
Taxon parent = Taxon.NewInstance(taxonName, ref);
|
83
|
Taxon child = Taxon.NewInstance(taxonName, null);
|
84
|
parent.addTaxonomicChild(child, null, null);
|
85
|
if (child.getTaxonomicParent() != parent){
|
86
|
logger.warn("Error");
|
87
|
}
|
88
|
}
|
89
|
|
90
|
public void testDescription(){
|
91
|
ReferenceBase ref = refFactory.newJournal();
|
92
|
Taxon taxon = Taxon.NewInstance(null, ref);
|
93
|
TaxonDescription desc = TaxonDescription.NewInstance();
|
94
|
taxon.addDescription(desc);
|
95
|
taxon.removeDescription(desc);
|
96
|
}
|
97
|
|
98
|
public void testTDWG(){
|
99
|
// NamedArea tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("GER");
|
100
|
// NamedArea tdwgArea2 = TdwgArea.getAreaByTdwgLabel("Qatar");
|
101
|
// System.out.println(tdwgArea.getLabel());
|
102
|
// System.out.println(tdwgArea2.getRepresentation(Language.DEFAULT()).getAbbreviatedLabel());
|
103
|
}
|
104
|
|
105
|
private void test(){
|
106
|
System.out.println("Start ...");
|
107
|
TestModel sc = new TestModel();
|
108
|
//sc.testSomething();
|
109
|
//sc.testParentRelation();
|
110
|
//sc.testDescription();
|
111
|
sc.testTDWG();
|
112
|
System.out.println("\nEnd ...");
|
113
|
}
|
114
|
|
115
|
/**
|
116
|
* @param args
|
117
|
*/
|
118
|
public static void main(String[] args) {
|
119
|
TestModel sc = new TestModel();
|
120
|
sc.test();
|
121
|
}
|
122
|
|
123
|
}
|