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.app.caryophyllales;
|
11
|
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.application.ICdmRepository;
|
17
|
import eu.etaxonomy.cdm.app.berlinModelImport.SourceBase;
|
18
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
19
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
20
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
21
|
import eu.etaxonomy.cdm.io.caryo.CaryoImportConfigurator;
|
22
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
23
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
24
|
import eu.etaxonomy.cdm.io.common.Source;
|
25
|
import eu.etaxonomy.cdm.model.agent.Person;
|
26
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
27
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
28
|
|
29
|
/**
|
30
|
* @author a.mueller
|
31
|
* @since 16.10.2012
|
32
|
*/
|
33
|
public class CaryoActivator extends SourceBase{
|
34
|
private static final Logger logger = Logger.getLogger(CaryoActivator.class);
|
35
|
|
36
|
//database validation status (create, update, validate ...)
|
37
|
static final DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
|
38
|
static final Source source = caryo_len61();
|
39
|
|
40
|
|
41
|
static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
42
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();
|
43
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_postgres_CdmTest();
|
44
|
|
45
|
static final String classificationName = "Caryophyllales";
|
46
|
|
47
|
//classification
|
48
|
static final UUID classificationUuid = UUID.fromString("9edc58b5-de3b-43aa-9f31-1ede7c009c2b");
|
49
|
|
50
|
//check - import
|
51
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
52
|
|
53
|
//taxa
|
54
|
static final boolean doTaxa = true;
|
55
|
static final boolean doDeduplicate = true;
|
56
|
|
57
|
|
58
|
private void doImport(ICdmDataSource cdmDestination){
|
59
|
|
60
|
//make Source
|
61
|
CaryoImportConfigurator config= CaryoImportConfigurator.NewInstance(source, cdmDestination);
|
62
|
config.setClassificationUuid(classificationUuid);
|
63
|
config.setCheck(check);
|
64
|
config.setDoTaxa(doTaxa);
|
65
|
config.setDbSchemaValidation(hbm2dll);
|
66
|
config.setSourceReferenceTitle("NCU - Caryophyllales, v0.4");
|
67
|
config.setClassificationName(classificationName);
|
68
|
|
69
|
CdmDefaultImport<CaryoImportConfigurator> myImport = new CdmDefaultImport<CaryoImportConfigurator>();
|
70
|
|
71
|
|
72
|
//...
|
73
|
if (true){
|
74
|
System.out.println("Start import from ("+ source.toString() + ") ...");
|
75
|
config.setSourceReference(getSourceReference(config.getSourceReferenceTitle()));
|
76
|
myImport.invoke(config);
|
77
|
System.out.println("End import from ("+ source.toString() + ")...");
|
78
|
}
|
79
|
|
80
|
|
81
|
|
82
|
//deduplicate
|
83
|
if (doDeduplicate){
|
84
|
ICdmRepository app = myImport.getCdmAppController();
|
85
|
int count = app.getAgentService().deduplicate(Person.class, null, null);
|
86
|
logger.warn("Deduplicated " + count + " persons.");
|
87
|
// count = app.getAgentService().deduplicate(Team.class, null, null);
|
88
|
// logger.warn("Deduplicated " + count + " teams.");
|
89
|
count = app.getReferenceService().deduplicate(Reference.class, null, null);
|
90
|
logger.warn("Deduplicated " + count + " references.");
|
91
|
}
|
92
|
|
93
|
}
|
94
|
|
95
|
private Reference getSourceReference(String string) {
|
96
|
Reference result = ReferenceFactory.newGeneric();
|
97
|
result.setTitleCache(string, true);
|
98
|
return result;
|
99
|
}
|
100
|
|
101
|
|
102
|
public static Source caryo_len61(){
|
103
|
// Cyryophyllales source
|
104
|
String dbms = Source.SQL_SERVER_2008;
|
105
|
String strServer = "Lenovo-T61";
|
106
|
String strDB = "caryo";
|
107
|
int port = 1433;
|
108
|
String userName = "WebUser";
|
109
|
return makeSource(dbms, strServer, strDB, port, userName, null);
|
110
|
}
|
111
|
|
112
|
|
113
|
|
114
|
/**
|
115
|
* @param args
|
116
|
*/
|
117
|
public static void main(String[] args) {
|
118
|
CaryoActivator me = new CaryoActivator();
|
119
|
me.doImport(cdmDestination);
|
120
|
}
|
121
|
|
122
|
}
|