Project

General

Profile

Revision fec55d19

IDfec55d195b879f779e83540cbfc75a20f6408a33
Parent 9a9ea69a
Child 4d0649fd

Added by Andreas Müller almost 2 years ago

ref #1444 remove some files from ERMS import

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/common/TestDatabase.java
1
/**
2
* Copyright (C) 2008 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*/
6

  
7
package eu.etaxonomy.cdm.app.common;
8

  
9
import java.util.ArrayList;
10
import java.util.GregorianCalendar;
11
import java.util.List;
12

  
13
import org.apache.log4j.Logger;
14
import org.springframework.transaction.TransactionStatus;
15

  
16
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
17
import eu.etaxonomy.cdm.common.AccountStore;
18
import eu.etaxonomy.cdm.database.CdmDataSource;
19
import eu.etaxonomy.cdm.database.DbSchemaValidation;
20
import eu.etaxonomy.cdm.database.ICdmDataSource;
21
import eu.etaxonomy.cdm.io.jaxb.DataSet;
22
import eu.etaxonomy.cdm.model.agent.AgentBase;
23
import eu.etaxonomy.cdm.model.agent.Institution;
24
import eu.etaxonomy.cdm.model.agent.InstitutionalMembership;
25
import eu.etaxonomy.cdm.model.agent.Person;
26
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
27
import eu.etaxonomy.cdm.model.common.TimePeriod;
28
import eu.etaxonomy.cdm.model.common.VersionableEntity;
29
import eu.etaxonomy.cdm.model.description.Feature;
30
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
31
import eu.etaxonomy.cdm.model.description.QuantitativeData;
32
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
33
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
34
import eu.etaxonomy.cdm.model.description.TaxonDescription;
35
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
36
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
37
import eu.etaxonomy.cdm.model.location.Country;
38
import eu.etaxonomy.cdm.model.location.NamedAreaType;
39
import eu.etaxonomy.cdm.model.name.Rank;
40
import eu.etaxonomy.cdm.model.name.TaxonName;
41
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
42
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
43
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
44
import eu.etaxonomy.cdm.model.reference.Reference;
45
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
46
import eu.etaxonomy.cdm.model.taxon.Classification;
47
import eu.etaxonomy.cdm.model.taxon.Synonym;
48
import eu.etaxonomy.cdm.model.taxon.SynonymType;
49
import eu.etaxonomy.cdm.model.taxon.Taxon;
50
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
51
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
52

  
53
/**
54
 * @author a.babadshanjan
55
 * @since 28.10.2008
56
 */
57
public class TestDatabase {
58

  
59
	private static final String server = "192.168.2.10";
60
	private static final String username = "edit";
61

  
62
	private static final Logger logger = Logger.getLogger(TestDatabase.class);
63

  
64
	public static ICdmDataSource CDM_DB(String dbname) {
65

  
66
		logger.info("Setting DB " + dbname);
67
		String password = AccountStore.readOrStorePassword(dbname, server, username, null);
68
		ICdmDataSource datasource = CdmDataSource.NewMySqlInstance(server, dbname, username, password);
69
		return datasource;
70
	}
71

  
72
    public static CdmApplicationController
73
    initDb(ICdmDataSource db, DbSchemaValidation dbSchemaValidation, boolean omitTermLoading) {
74

  
75
		logger.info("Initializing database '" + db.getName() + "'");
76

  
77
		CdmApplicationController appCtrInit = null;
78
		appCtrInit = CdmApplicationController.NewInstance(db, dbSchemaValidation, omitTermLoading);
79

  
80
		return appCtrInit;
81
    }
82

  
83
	public static void loadTestData(String dbname, CdmApplicationController appCtr) {
84

  
85
		logger.info("Loading test data into " + dbname);
86

  
87
		TransactionStatus txStatus = appCtr.startTransaction();
88
		DataSet dataSet = buildDataSet();
89

  
90
		appCtr.getTermService().save(dataSet.getTerms());
91
		appCtr.getTaxonService().save((List)dataSet.getTaxonBases());
92

  
93
		appCtr.commitTransaction(txStatus);
94
		appCtr.close();
95
    }
96

  
97
	/**
98
	 * This method constructs a small sample classification to test JAXB marshaling.
99
	 * The sample tree contains four taxa. The root taxon has two children taxa, and
100
	 * there is one "free" taxon without a parent and children.
101
	 */
102
	private static DataSet buildDataSet() {
103

  
104
		List<AgentBase> agents = new ArrayList<AgentBase>();
105
	    List<VersionableEntity> agentData = new ArrayList<VersionableEntity>();
106
	    //List<Agent> agentData = new ArrayList<Agent>();
107

  
108
	    //List<TermBase> terms = new ArrayList<TermBase>();
109
	    List<DefinedTermBase> terms = new ArrayList<>();
110
	    List<Reference> references = new ArrayList<>();
111
	    List<TaxonName> taxonomicNames = new ArrayList<>();
112
	    List<TaxonBase> taxonBases = new ArrayList<>();
113

  
114
	    List<Feature> features = new ArrayList<Feature>();
115

  
116
	    Feature feature1 = Feature.BIOLOGY_ECOLOGY();
117

  
118
	    TaxonNameDescription taxNameDescription = TaxonNameDescription.NewInstance();
119
//	    taxNameDescription.addFeature(feature1); //was removed from model in 3.3
120
	    QuantitativeData element = QuantitativeData.NewInstance();
121
	    StatisticalMeasurementValue statisticalValue = StatisticalMeasurementValue.NewInstance();
122
	    statisticalValue.setType(StatisticalMeasure.MAX());
123
	    statisticalValue.setValue((float) 2.1);
124
	    element.addStatisticalValue(statisticalValue);
125
	    taxNameDescription.addElement(element);
126

  
127
	    SpecimenOrObservationBase<?> specimen = DerivedUnit.NewPreservedSpecimenInstance();
128

  
129
	    specimen.setIndividualCount("12");
130

  
131
	    TaxonNameDescription newTaxNameDesc = TaxonNameDescription.NewInstance();
132
	    IndividualsAssociation indAss = IndividualsAssociation.NewInstance();
133
	    indAss.setAssociatedSpecimenOrObservation(specimen);
134

  
135
	    newTaxNameDesc.addElement(indAss);
136

  
137
		Reference citRef, sec;
138
		TaxonName name1, name2, name21, nameRoot1, nameFree, synName11, synName12, synName2, synNameFree;
139
		TaxonName nameRoot2, nameR2_1, nameR2_2;
140
		Taxon child1, child2, child21, root1T, root2T, freeT;
141
		Taxon childR2_1, childR2_2;
142
		TaxonNode child1Node, child2Node, child21Node, root1TNode, root2TNode, freeTNode;
143
		TaxonNode childR2_1Node, childR2_2Node;
144
		Classification taxTree, taxTree2;
145
		Synonym syn11, syn12, syn2, synFree;
146
		Rank rankSpecies, rankSubspecies, rankGenus;
147

  
148
		// agents
149
		// - persons, institutions
150

  
151
		Person linne = new Person("Carl", "Linne", "L.");
152
		linne.setTitleCache("Linne & Karl", true);
153
		GregorianCalendar birth = new GregorianCalendar(1707, 4, 23);
154
		GregorianCalendar death = new GregorianCalendar(1778, 0, 10);
155
		TimePeriod period = TimePeriod.NewInstance(birth, death);
156
		linne.setLifespan(period);
157

  
158
//		Keyword keyword = Keyword.NewInstance("plantarum", "lat", "");
159
//		linne.addKeyword(keyword);
160

  
161
		Institution institute = Institution.NewInstance();
162

  
163
		agents.add(linne);
164
		agents.add(institute);
165

  
166
		// agent data
167
		// - contacts, addresses, memberships
168

  
169
		//Contact contact1 = new Contact();
170
		//contact1.setEmail("someone@somewhere.org");
171
		InstitutionalMembership membership
172
		    = new InstitutionalMembership(institute, linne, period, "Biodiversity", "Head");
173
		//agentData.add(contact1);
174

  
175
		agentData.add(membership);
176

  
177
		// terms
178
		// - ranks, keywords
179

  
180
		rankSpecies = Rank.SPECIES();
181
		rankSubspecies = Rank.SUBSPECIES();
182
		rankGenus = Rank.GENUS();
183

  
184
//		terms.add(keyword);
185

  
186
        // taxonomic names
187

  
188
		nameRoot1 = TaxonNameFactory.NewBotanicalInstance(rankGenus,"Calendula",null,null,null,linne,null,"p.100", null);
189
		nameRoot1.addDescription(taxNameDescription);
190
		nameRoot1.addDescription(newTaxNameDesc);
191
		name1 = TaxonNameFactory.NewBotanicalInstance(rankSpecies,"Calendula",null,"arvensis",null,linne,null,"p.1", null);
192
		synName11 = TaxonNameFactory.NewBotanicalInstance(rankSpecies,"Caltha",null,"arvensis",null,linne,null,"p.11", null);
193
		synName12 = TaxonNameFactory.NewBotanicalInstance(rankSpecies,"Calendula",null,"sancta",null,linne,null,"p.12", null);
194

  
195
		name2 = TaxonNameFactory.NewBotanicalInstance(rankSpecies,"Calendula",null,"lanzae",null,linne,null,"p.2", null);
196
		synName2 = TaxonNameFactory.NewBotanicalInstance(rankSpecies,"Calendula",null,"echinata",null,linne,null,"p.2", null);
197

  
198
		name21 = TaxonNameFactory.NewBotanicalInstance(rankSubspecies,"Calendula",null,"lanzea","something",linne,null,"p.1", null);
199
		//name211 = BotanicalName.NewInstance(rankSpecies,"Calendula",null,"lanzea",null,linne,null,"p.1", null);
200
		//name212 = BotanicalName.NewInstance(rankSpecies,"Calendula",null,"lanzea",null,linne,null,"p.1", null);
201

  
202
		nameRoot2 =
203
		        TaxonNameFactory.NewBotanicalInstance(rankGenus,"Sonchus",null,null,null,linne,null,"p.200", null);
204
		nameR2_1 = TaxonNameFactory.NewBotanicalInstance(rankSpecies,"Sonchus",null,"child1",null,linne,null,"p.1", null);
205
		nameR2_2 = TaxonNameFactory.NewBotanicalInstance(rankSpecies,"Sonchus",null,"child2",null,linne,null,"p.2", null);
206

  
207
		nameFree = TaxonNameFactory.NewBotanicalInstance(rankSpecies,"Cichorium",null,"intybus",null,linne,null,"p.200", null);
208
		synNameFree = TaxonNameFactory.NewBotanicalInstance(rankSpecies,"Cichorium",null,"balearicum",null,linne,null,"p.2", null);
209

  
210
		taxonomicNames.add(nameRoot1);
211
		taxonomicNames.add(name1);
212
		taxonomicNames.add(synName11);
213
		taxonomicNames.add(synName12);
214
		taxonomicNames.add(name2);
215
		taxonomicNames.add(name21);
216
		taxonomicNames.add(synName2);
217
		taxonomicNames.add(nameFree);
218
		taxonomicNames.add(synNameFree);
219
		taxonomicNames.add(nameRoot2);
220

  
221
        // references
222
		sec = ReferenceFactory.newBook();
223
		sec.setAuthorship(linne);
224
		sec.setTitleCache("Plant Specification & Taxonomy", true);
225
		references.add(sec);
226

  
227
		citRef = ReferenceFactory.newDatabase();
228
		citRef.setAuthorship(linne);
229
		citRef.setTitleCache("BioCASE", true);
230
		references.add(citRef);
231

  
232
		// taxa
233

  
234
		root1T = Taxon.NewInstance(nameRoot1, sec);
235
		root2T = Taxon.NewInstance(nameRoot2, sec);
236
		freeT = Taxon.NewInstance(nameFree, sec);
237
		child1 = Taxon.NewInstance(name1, sec);
238
		child2 = Taxon.NewInstance(name2, sec);
239
		child21 = Taxon.NewInstance(name21, sec);
240
		childR2_1 = Taxon.NewInstance(nameR2_1, sec);
241
		childR2_2 = Taxon.NewInstance(nameR2_2, sec);
242

  
243
		//TaxonInteractions
244

  
245
		TaxonInteraction descBase = TaxonInteraction.NewInstance();
246
		descBase.setTaxon2(root1T);
247
		Feature hostplant = Feature.HOSTPLANT();
248

  
249
		descBase.setFeature(hostplant);
250
		TaxonDescription taxDesc = TaxonDescription.NewInstance();
251
		taxDesc.addElement(descBase);
252
		root2T.addDescription(taxDesc);
253

  
254
		//locations
255

  
256
		taxDesc = TaxonDescription.NewInstance();
257
		Feature locationFeature = Feature.DISTRIBUTION();
258

  
259

  
260
		//locationFeature.
261
		Country area = Country.NewInstance("", "locationTest", null);
262
		area.setType(NamedAreaType.NATURAL_AREA());
263

  
264
		//Country woC= Country.NewInstance();
265
		area.addCountry(Country.AFGHANISTAN());
266
		taxDesc.addGeoScope(area);
267
//		taxDesc.addFeature(locationFeature); //was removed from model in 3.3
268
		root1T.addDescription(taxDesc);
269

  
270

  
271
		// synonyms
272

  
273
		synFree = Synonym.NewInstance(synNameFree, sec);
274
		syn11 = Synonym.NewInstance(synName11, sec);
275
		syn12 = Synonym.NewInstance(synName12, sec);
276
		syn2 = Synonym.NewInstance(synName2, sec);
277

  
278
		child1.addSynonym(syn11, SynonymType.HOMOTYPIC_SYNONYM_OF());
279
		child1.addSynonym(syn12, SynonymType.HETEROTYPIC_SYNONYM_OF());
280
		child2.addSynonym(syn2, SynonymType.HETEROTYPIC_SYNONYM_OF());
281
		freeT.addSynonym(synFree, SynonymType.HETEROTYPIC_SYNONYM_OF());
282

  
283
		taxonBases.add(synFree);
284
		taxonBases.add(syn11);
285
		taxonBases.add(syn12);
286
		taxonBases.add(syn2);
287

  
288
		// taxonomic children
289

  
290
		//TODO: Adapt to classification
291
		taxTree = Classification.NewInstance("TestTree");
292

  
293
		root1TNode = taxTree.addChildTaxon(root1T, sec, null);
294
		child1Node = root1TNode.addChildTaxon(child1, null, null);
295
		child2Node = root1TNode.addChildTaxon(child2, null, null);
296
		child21Node = child2Node.addChildTaxon(child21, null, null);
297

  
298
		taxTree2 = Classification.NewInstance("TestTree2");
299

  
300
		root2TNode = taxTree2.addChildTaxon(root2T, sec, null);
301
		root2TNode.addChildTaxon(child1, sec, "p.1010").setSynonymToBeUsed(syn11);
302
		root2TNode.addChildTaxon(child2, null, null);
303

  
304
		/*
305
		root1T.addTaxonomicChild(child1, sec, "p.1010");
306
		root1T.addTaxonomicChild(child2, sec, "p.1020");
307
		child2.addTaxonomicChild(child21, sec, "p.2000");
308

  
309
		root2T.addTaxonomicChild(child1, sec, "p.1010");
310
		root2T.addTaxonomicChild(child2, sec, "p.1020");
311
		*/
312
		//
313

  
314

  
315
		taxonBases.add(root1T);
316
		taxonBases.add(root2T);
317
		taxonBases.add(freeT);
318
		taxonBases.add(child1);
319
		taxonBases.add(child2);
320
		taxonBases.add(child21);
321
		taxonBases.add(childR2_1);
322
		taxonBases.add(childR2_2);
323

  
324
		DataSet dataSet = new DataSet();
325

  
326
		logger.warn("WARNING: TestDatabase has been commented in parts. Mainly, must be adapted to classification.");
327

  
328
		dataSet.setTerms(terms);
329
		dataSet.setAgents(agents);
330
//		dataSet.setAgentData(agentData); //TODO
331
		dataSet.setReferences(references);
332
		dataSet.setTaxonomicNames(taxonomicNames);
333
		dataSet.setTaxonBases((List)taxonBases);
334

  
335

  
336
		return dataSet;
337

  
338
	}
339
}
cdm-pesi/src/test/java/eu/etaxonomy/cdm/io/erms/ermsErrors.txt
1
ERRORS in ERMS
2
=====================
3

  
4
- there is one case, where a nomen nudum is the accepted taxon for an other taxon
5

  
6
SELECT     dbo.tu.tu_status, tu_1.tu_acctaxon, tu_1.id, dbo.tu.tu_displayname
7
FROM         dbo.tu INNER JOIN
8
                      dbo.tu AS tu_1 ON dbo.tu.id = tu_1.tu_acctaxon
9
WHERE     (dbo.tu.tu_status = 3) OR
10
                      (tu_1.id = 111846) OR
11
                      (tu_1.id = 111850)
12
					  
13
- there are 448 cases where the tu_acctaxon has not a status "accepted"
14

  
15
SELECT     dbo.tu.tu_status AS acceptedStatus, dbo.tu.tu_displayname AS acceptedName, unaccepted.tu_status AS unacceptedStatus, 
16
                      unaccepted.tu_displayname AS unacceptedName
17
FROM         dbo.tu INNER JOIN
18
                      dbo.tu AS unaccepted ON dbo.tu.id = unaccepted.tu_acctaxon
19
WHERE     (dbo.tu.tu_status <> 1)
20
ORDER BY acceptedStatus, unacceptedStatus 
21

  
22
- 289 cases where parent taxon is not accepted (is this allowed ?)
23

  
24
- there are 46 taxa with a status not accepted, a parent not accepted and an parent.tu_acctaxon not accepted 
25

  
26
SELECT     TOP (100) PERCENT tu_1.id, tu_1.tu_status, accTaxon.tu_status AS accStatus, parent.tu_status AS parentStatus, 
27
                      accParent.tu_status AS accParentStatus, tu_1.tu_displayname AS displayname, parent.tu_displayname AS parentdisplayname, tu_1.tu_acctaxon, 
28
                      dbo.status.status_name, dbo.status.status_id AS myStatus, parent.id AS parentId, tu_1.tu_sp
29
FROM         dbo.status RIGHT OUTER JOIN
30
                      dbo.tu AS accTaxon RIGHT OUTER JOIN
31
                      dbo.tu AS tu_1 ON accTaxon.id = tu_1.tu_acctaxon LEFT OUTER JOIN
32
                      dbo.tu AS parent ON tu_1.tu_parent = parent.id ON dbo.status.status_id = tu_1.tu_status LEFT OUTER JOIN
33
                      dbo.tu AS accParent ON parent.tu_acctaxon = accParent.id
34
WHERE     (tu_1.tu_status <> 1) AND (parent.tu_status <> 1) AND (accParent.tu_status <> 1)
35
ORDER BY accParentStatus, parentStatus
36

  
37
- there are 27 taxa with a status not accepted, a parent not accepted and an parent.tu_acctaxon not accepted and an tu_acctaxon not accepted
38

  
39
SELECT     TOP (100) PERCENT tu_1.id, tu_1.tu_status, accTaxon.tu_status AS accStatus, parent.tu_status AS parentStatus, 
40
                      accParent.tu_status AS accParentStatus, tu_1.tu_displayname AS displayname, parent.tu_displayname AS parentdisplayname, tu_1.tu_acctaxon, 
41
                      dbo.status.status_name, dbo.status.status_id AS myStatus, parent.id AS parentId, tu_1.tu_sp
42
FROM         dbo.status RIGHT OUTER JOIN
43
                      dbo.tu AS accTaxon RIGHT OUTER JOIN
44
                      dbo.tu AS tu_1 ON accTaxon.id = tu_1.tu_acctaxon LEFT OUTER JOIN
45
                      dbo.tu AS parent ON tu_1.tu_parent = parent.id ON dbo.status.status_id = tu_1.tu_status LEFT OUTER JOIN
46
                      dbo.tu AS accParent ON parent.tu_acctaxon = accParent.id
47
WHERE     (tu_1.tu_status <> 1) AND (parent.tu_status <> 1) AND (accParent.tu_status <> 1) AND (accTaxon.tu_status <> 1)
48
ORDER BY accParentStatus, parentStatus

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)