1
|
/**
|
2
|
* Copyright (C) 2007 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.test.integration;
|
11
|
|
12
|
import static org.junit.Assert.assertEquals;
|
13
|
import static org.junit.Assert.assertNotNull;
|
14
|
import static org.junit.Assert.fail;
|
15
|
|
16
|
import java.util.Set;
|
17
|
import java.util.UUID;
|
18
|
|
19
|
import org.apache.log4j.Logger;
|
20
|
|
21
|
import eu.etaxonomy.cdm.api.application.CdmApplicationDefaultController;
|
22
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
23
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
24
|
import eu.etaxonomy.cdm.model.common.Language;
|
25
|
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
|
26
|
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
27
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
28
|
import eu.etaxonomy.cdm.model.description.TextData;
|
29
|
import eu.etaxonomy.cdm.model.name.BotanicalName;
|
30
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
31
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
32
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
33
|
|
34
|
/**
|
35
|
* @author a.mueller
|
36
|
* @created 28.05.2008
|
37
|
* @version 1.0
|
38
|
*/
|
39
|
public class CreateDataTestNoUnit {
|
40
|
private static Logger logger = Logger.getLogger(CreateDataTestNoUnit.class);
|
41
|
|
42
|
private CdmApplicationDefaultController app;
|
43
|
|
44
|
|
45
|
public void test(){
|
46
|
boolean isCreated = true;
|
47
|
DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;
|
48
|
if (isCreated == false){
|
49
|
dbSchemaValidation = DbSchemaValidation.CREATE;
|
50
|
}
|
51
|
ICdmDataSource dataSource = CreateDataTest.cdm_test();
|
52
|
app = CdmApplicationDefaultController.NewInstance(dataSource, dbSchemaValidation);
|
53
|
|
54
|
TaxonNameBase<?,?> genusName2 = (TaxonNameBase<?,?>)app.getNameService().find(UUID.fromString(CreateDataTest.genusNameUuid));
|
55
|
Set<TaxonBase> set = (Set<TaxonBase>)genusName2.getTaxonBases();
|
56
|
System.out.println("Size:" + set.size());
|
57
|
for (TaxonBase tb : set){
|
58
|
System.out.println(tb.getName());
|
59
|
}
|
60
|
|
61
|
//taxon
|
62
|
Taxon genusTaxon = (Taxon)app.getTaxonService().find(UUID.fromString(CreateDataTest.genusUuid));
|
63
|
assertNotNull(genusTaxon);
|
64
|
//name
|
65
|
BotanicalName genusName = (BotanicalName)genusTaxon.getName();
|
66
|
assertNotNull(genusName);
|
67
|
Set<TaxonBase> taxaSet = genusName.getTaxonBases();
|
68
|
for (TaxonBase tb : taxaSet){
|
69
|
System.out.println(tb.getName());
|
70
|
}
|
71
|
|
72
|
//taxonBases of Name
|
73
|
Set<TaxonBase> taxonBases = genusName.getTaxonBases();
|
74
|
logger.warn(taxonBases.size());
|
75
|
Set<Taxon> children = genusTaxon.getTaxonomicChildren();
|
76
|
for (Taxon child : children){
|
77
|
child.getSynonyms();
|
78
|
child.getMisappliedNames();
|
79
|
child.getHomotypicGroup();
|
80
|
child.getHomotypicSynonymsByHomotypicGroup();
|
81
|
child.getHomotypicSynonymsByHomotypicRelationship();
|
82
|
}
|
83
|
|
84
|
Set<TaxonDescription> descriptions = genusTaxon.getDescriptions();
|
85
|
assertEquals(2, descriptions.size());
|
86
|
TaxonDescription description = descriptions.iterator().next();
|
87
|
|
88
|
|
89
|
Set<DescriptionElementBase> descriptionElements = description.getElements();
|
90
|
|
91
|
Language language = Language.DEFAULT();
|
92
|
for (DescriptionElementBase descriptionElement : descriptionElements){
|
93
|
if (descriptionElement instanceof TextData){
|
94
|
TextData textData = (TextData)descriptionElement;
|
95
|
textData.getText(language);
|
96
|
}else if(descriptionElement instanceof CommonTaxonName){
|
97
|
CommonTaxonName commonTaxonName = (CommonTaxonName)descriptionElement;
|
98
|
commonTaxonName.getName();
|
99
|
commonTaxonName.getLanguage();
|
100
|
}else{
|
101
|
fail();
|
102
|
}
|
103
|
}
|
104
|
|
105
|
}
|
106
|
|
107
|
|
108
|
/**
|
109
|
* @param args
|
110
|
*/
|
111
|
public static void main(String[] args) {
|
112
|
CreateDataTestNoUnit test = new CreateDataTestNoUnit();
|
113
|
test.test();
|
114
|
}
|
115
|
}
|