|
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.cyprus;
|
|
11 |
|
|
12 |
import java.net.URI;
|
|
13 |
import java.net.URISyntaxException;
|
|
14 |
import java.util.UUID;
|
|
15 |
|
|
16 |
import org.apache.log4j.Logger;
|
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
|
|
19 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
|
|
20 |
import eu.etaxonomy.cdm.api.service.ITermService;
|
|
21 |
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
|
22 |
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
|
23 |
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
|
24 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
|
25 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
|
26 |
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
|
|
27 |
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
|
|
28 |
import eu.etaxonomy.cdm.io.cyprus.CyprusImportConfigurator;
|
|
29 |
import eu.etaxonomy.cdm.io.cyprus.CyprusTransformer;
|
|
30 |
import eu.etaxonomy.cdm.io.specimen.excel.in.SpecimenCdmExcelImportConfigurator;
|
|
31 |
import eu.etaxonomy.cdm.model.agent.Person;
|
|
32 |
import eu.etaxonomy.cdm.model.description.Feature;
|
|
33 |
import eu.etaxonomy.cdm.model.description.FeatureNode;
|
|
34 |
import eu.etaxonomy.cdm.model.description.FeatureTree;
|
|
35 |
import eu.etaxonomy.cdm.model.reference.Reference;
|
|
36 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
|
37 |
|
|
38 |
/**
|
|
39 |
* @author a.mueller
|
|
40 |
* @created 16.12.2010
|
|
41 |
* @version 1.0
|
|
42 |
*/
|
|
43 |
public class CyprusSpecimenActivator {
|
|
44 |
private static final Logger logger = Logger.getLogger(CyprusSpecimenActivator.class);
|
|
45 |
|
|
46 |
//database validation status (create, update, validate ...)
|
|
47 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
|
|
48 |
static final URI source = cyprus_specimen_local();
|
|
49 |
|
|
50 |
|
|
51 |
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
|
52 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();
|
|
53 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cyprus_dev();
|
|
54 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cyprus_production();
|
|
55 |
|
|
56 |
|
|
57 |
//check - import
|
|
58 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
|
59 |
|
|
60 |
//taxa
|
|
61 |
// static final boolean doTaxa = false;
|
|
62 |
// static final boolean doDeduplicate = false;
|
|
63 |
// static final boolean doDistribution = true;
|
|
64 |
|
|
65 |
|
|
66 |
private void doImport(ICdmDataSource cdmDestination){
|
|
67 |
|
|
68 |
//make Source
|
|
69 |
SpecimenCdmExcelImportConfigurator config= SpecimenCdmExcelImportConfigurator.NewInstance(source, cdmDestination);
|
|
70 |
config.setCheck(check);
|
|
71 |
config.setDbSchemaValidation(hbm2dll);
|
|
72 |
|
|
73 |
CdmDefaultImport myImport = new CdmDefaultImport();
|
|
74 |
|
|
75 |
|
|
76 |
//...
|
|
77 |
if (true){
|
|
78 |
System.out.println("Start import from ("+ source.toString() + ") ...");
|
|
79 |
config.setSourceReference(getSourceReference(config.getSourceReferenceTitle()));
|
|
80 |
myImport.invoke(config);
|
|
81 |
|
|
82 |
System.out.println("End import from ("+ source.toString() + ")...");
|
|
83 |
}
|
|
84 |
|
|
85 |
}
|
|
86 |
|
|
87 |
private Reference<?> getSourceReference(String string) {
|
|
88 |
Reference<?> result = ReferenceFactory.newGeneric();
|
|
89 |
result.setTitleCache(string);
|
|
90 |
return result;
|
|
91 |
}
|
|
92 |
|
|
93 |
//Cyprus
|
|
94 |
public static URI cyprus_specimen_local() {
|
|
95 |
URI sourceUrl;
|
|
96 |
try {
|
|
97 |
sourceUrl = new URI("file:/C:/localCopy/Data/zypern/Cyprus-specimens-import02_AM.xls");
|
|
98 |
return sourceUrl;
|
|
99 |
} catch (URISyntaxException e) {
|
|
100 |
e.printStackTrace();
|
|
101 |
return null;
|
|
102 |
}
|
|
103 |
}
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
/**
|
|
108 |
* @param args
|
|
109 |
*/
|
|
110 |
public static void main(String[] args) {
|
|
111 |
CyprusSpecimenActivator me = new CyprusSpecimenActivator();
|
|
112 |
me.doImport(cdmDestination);
|
|
113 |
}
|
|
114 |
|
|
115 |
}
|
cyprus specimen