1
|
/**
|
2
|
* Copyright (C) 2017 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
|
package eu.etaxonomy.cdm.app.greece;
|
10
|
|
11
|
import java.net.URI;
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
|
16
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
17
|
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
|
18
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
19
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
20
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
21
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
22
|
import eu.etaxonomy.cdm.io.common.ImportResult;
|
23
|
import eu.etaxonomy.cdm.io.greece.GreeceGenusAuthorImportConfigurator;
|
24
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
25
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
26
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
27
|
|
28
|
/**
|
29
|
* @author a.mueller
|
30
|
* @since 08.12.2017
|
31
|
*
|
32
|
*/
|
33
|
public class GreeceGenusAuthorActivator {
|
34
|
@SuppressWarnings("unused")
|
35
|
private static final Logger logger = Logger.getLogger(GreeceGenusAuthorActivator.class);
|
36
|
|
37
|
|
38
|
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
39
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
|
40
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_greece_checklist_production();
|
41
|
|
42
|
private static final UUID sourceUuid = UUID.fromString("65e2cd54-8378-4949-9cb7-b973d2033da6");
|
43
|
private static final String fileName = "Nov2017changes.xlsx";
|
44
|
|
45
|
|
46
|
//check - import
|
47
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
48
|
|
49
|
boolean doImages = true;
|
50
|
|
51
|
private void doImport(ICdmDataSource cdmDestination){
|
52
|
|
53
|
DbSchemaValidation schemaVal = cdmDestination.getDatabaseType() == DatabaseTypeEnum.H2 ? DbSchemaValidation.CREATE : DbSchemaValidation.VALIDATE;
|
54
|
URI source = greekChecklist(); //just any
|
55
|
//make Source
|
56
|
GreeceGenusAuthorImportConfigurator config = GreeceGenusAuthorImportConfigurator.NewInstance(source, cdmDestination);
|
57
|
config.setCheck(check);
|
58
|
config.setDbSchemaValidation(schemaVal);
|
59
|
config.setSourceReference(getSourceReference());
|
60
|
config.setNomenclaturalCode(NomenclaturalCode.ICNAFP);
|
61
|
|
62
|
CdmDefaultImport<GreeceGenusAuthorImportConfigurator> myImport = new CdmDefaultImport<>();
|
63
|
ImportResult result = myImport.invoke(config);
|
64
|
System.out.println(result.createReport());
|
65
|
|
66
|
}
|
67
|
|
68
|
|
69
|
private URI greekChecklist(){
|
70
|
return URI.create("file:////BGBM-PESIHPC/Greece/" + fileName);
|
71
|
}
|
72
|
|
73
|
|
74
|
private Reference getSourceReference(){
|
75
|
Reference result = ReferenceFactory.newDatabase();
|
76
|
result.setTitle(fileName);
|
77
|
result.setUuid(sourceUuid);
|
78
|
|
79
|
return result;
|
80
|
}
|
81
|
|
82
|
/**
|
83
|
* @param args
|
84
|
*/
|
85
|
public static void main(String[] args) {
|
86
|
GreeceGenusAuthorActivator me = new GreeceGenusAuthorActivator();
|
87
|
me.doImport(cdmDestination);
|
88
|
System.exit(0);
|
89
|
}
|
90
|
|
91
|
|
92
|
}
|