1
|
/**
|
2
|
* Copyright (C) 2009 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
|
|
10
|
package eu.etaxonomy.cdm.datagenerator;
|
11
|
|
12
|
import java.util.Random;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.agent.Person;
|
15
|
import eu.etaxonomy.cdm.model.common.Language;
|
16
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
17
|
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
|
18
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
19
|
import eu.etaxonomy.cdm.model.description.TextData;
|
20
|
import eu.etaxonomy.cdm.model.name.BotanicalName;
|
21
|
import eu.etaxonomy.cdm.model.name.Rank;
|
22
|
//import eu.etaxonomy.cdm.model.reference.Book;
|
23
|
//import eu.etaxonomy.cdm.model.reference.Database;
|
24
|
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
|
25
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
26
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
27
|
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
|
28
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
29
|
|
30
|
public class TaxonGenerator {
|
31
|
private static String[] genera = {"Carex", "Abies", "Belladonna", "Dracula", "Maria", "Calendula", "Polygala", "Vincia"};
|
32
|
private static String[] epitheta = {"vulgaris", "magdalena", "officinalis", "alba", "negra", "communa", "alpina", "rotundifolia", "greutheriana", "helventica", "allemania", "franca"};
|
33
|
private static String[] ranks = {"subsp", "var", "f"};
|
34
|
|
35
|
private Random rnd = new Random();
|
36
|
|
37
|
public static Taxon getTestTaxon(){
|
38
|
ReferenceFactory refFactory = ReferenceFactory.newInstance();
|
39
|
Person deCandolle = Person.NewInstance();
|
40
|
deCandolle.setTitleCache("DC.");
|
41
|
ReferenceBase sec = refFactory.newDatabase();
|
42
|
sec.setTitleCache("Flora lunaea");
|
43
|
ReferenceBase citationRef = refFactory.newBook();
|
44
|
citationRef.setTitleCache("Sp. lunarum");
|
45
|
|
46
|
//genus taxon with Name, combinationAuthor,
|
47
|
BotanicalName botName = BotanicalName.NewInstance(Rank.GENUS());
|
48
|
botName.setTitleCache("Hieracium L.");
|
49
|
botName.setGenusOrUninomial("Hieracium");
|
50
|
botName.setCombinationAuthorTeam(Person.NewInstance());
|
51
|
botName.getCombinationAuthorTeam().setNomenclaturalTitle("L.");
|
52
|
Taxon genusTaxon = Taxon.NewInstance(botName, sec);
|
53
|
|
54
|
//a name that is the basionym of genusTaxon's name
|
55
|
BotanicalName basionym = BotanicalName.NewInstance(Rank.GENUS());
|
56
|
basionym.setTitleCache("Hieracilla DC.");
|
57
|
basionym.setGenusOrUninomial("Hieracilla");
|
58
|
basionym.setCombinationAuthorTeam(deCandolle);
|
59
|
botName.addBasionym(basionym, null, null, "216");
|
60
|
|
61
|
//species taxon that is the child of genus taxon
|
62
|
BotanicalName botSpecies = BotanicalName.NewInstance(Rank.SPECIES());
|
63
|
botSpecies.setTitleCache("Hieracium asturianum Pau");
|
64
|
botSpecies.setGenusOrUninomial("Hieracium");
|
65
|
botSpecies.setSpecificEpithet("asturianum");
|
66
|
botSpecies.setCombinationAuthorTeam(Person.NewInstance());
|
67
|
botSpecies.getCombinationAuthorTeam().setNomenclaturalTitle("Pau");
|
68
|
Taxon childTaxon = Taxon.NewInstance(botSpecies, sec);
|
69
|
childTaxon.setTaxonomicParent(genusTaxon, citationRef, "456");
|
70
|
|
71
|
//homotypic synonym of childTaxon1
|
72
|
BotanicalName botSpecies4= BotanicalName.NewInstance(Rank.SPECIES());
|
73
|
botSpecies4.setTitleCache("Hieracium gueri DC.");
|
74
|
botSpecies4.setGenusOrUninomial("Hieracium");
|
75
|
botSpecies4.setSpecificEpithet("gueri");
|
76
|
botSpecies4.setCombinationAuthorTeam(deCandolle);
|
77
|
Synonym homoSynonym = Synonym.NewInstance(botSpecies4, sec);
|
78
|
childTaxon.addSynonym(homoSynonym, SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF());
|
79
|
|
80
|
|
81
|
//2nd child species taxon that is the child of genus taxon
|
82
|
BotanicalName botSpecies2= BotanicalName.NewInstance(Rank.SPECIES());
|
83
|
botSpecies2.setTitleCache("Hieracium wolffii Zahn");
|
84
|
botSpecies2.setGenusOrUninomial("Hieracium");
|
85
|
botSpecies2.setSpecificEpithet("wolffii");
|
86
|
botSpecies2.setCombinationAuthorTeam(Person.NewInstance());
|
87
|
botSpecies2.getCombinationAuthorTeam().setNomenclaturalTitle("Zahn");
|
88
|
Taxon childTaxon2 = Taxon.NewInstance(botSpecies2, sec);
|
89
|
childTaxon2.setTaxonomicParent(genusTaxon, citationRef, "499");
|
90
|
|
91
|
//heterotypic synonym of childTaxon2
|
92
|
BotanicalName botSpecies3= BotanicalName.NewInstance(Rank.SPECIES());
|
93
|
botSpecies3.setTitleCache("Hieracium lupium DC.");
|
94
|
botSpecies3.setGenusOrUninomial("Hieracium");
|
95
|
botSpecies3.setSpecificEpithet("lupium");
|
96
|
botSpecies3.setCombinationAuthorTeam(deCandolle);
|
97
|
Synonym heteroSynonym = Synonym.NewInstance(botSpecies3, sec);
|
98
|
childTaxon2.addSynonym(heteroSynonym, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
|
99
|
|
100
|
//missaplied Name for childTaxon2
|
101
|
BotanicalName missName= BotanicalName.NewInstance(Rank.SPECIES());
|
102
|
missName.setTitleCache("Hieracium lupium DC.");
|
103
|
missName.setGenusOrUninomial("Hieracium");
|
104
|
missName.setSpecificEpithet("lupium");
|
105
|
missName.setCombinationAuthorTeam(deCandolle);
|
106
|
Taxon misappliedName = Taxon.NewInstance(missName, sec);
|
107
|
childTaxon2.addMisappliedName(misappliedName, citationRef, "125");
|
108
|
|
109
|
genusTaxon.addDescription(getTestDescription());
|
110
|
|
111
|
return genusTaxon;
|
112
|
}
|
113
|
|
114
|
public static TaxonDescription getTestDescription(){
|
115
|
TaxonDescription taxonDescription = TaxonDescription.NewInstance();
|
116
|
Language language = Language.DEFAULT();
|
117
|
|
118
|
//textData
|
119
|
TextData textData = TextData.NewInstance();
|
120
|
String descriptionText = "this is a desciption for a taxon";
|
121
|
LanguageString languageString = LanguageString.NewInstance(descriptionText, language);
|
122
|
textData.putText(languageString);
|
123
|
taxonDescription.addElement(textData);
|
124
|
|
125
|
//commonName
|
126
|
String commonNameString = "Sch?nveilchen";
|
127
|
CommonTaxonName commonName = CommonTaxonName.NewInstance(commonNameString, language);
|
128
|
taxonDescription.addElement(commonName);
|
129
|
|
130
|
return taxonDescription;
|
131
|
}
|
132
|
}
|