1
|
/**
|
2
|
* Copyright (C) 2018 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.GreeceWillingImportConfigurator;
|
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 21.08.2018
|
31
|
*
|
32
|
*/
|
33
|
public class GreeceWillingActivator {
|
34
|
@SuppressWarnings("unused")
|
35
|
private static final Logger logger = Logger.getLogger(GreeceWillingActivator.class);
|
36
|
|
37
|
|
38
|
static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
39
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_greece_checklist_production();
|
40
|
|
41
|
private static final UUID sourceUuid = UUID.fromString("b96b8a10-e2a5-4a01-b2f2-435a59a7a269");
|
42
|
|
43
|
private static final String fileName = "WillingImport.xslx";
|
44
|
|
45
|
private void doImport(ICdmDataSource cdmDestination){
|
46
|
|
47
|
DbSchemaValidation schemaVal = cdmDestination.getDatabaseType() == DatabaseTypeEnum.H2 ? DbSchemaValidation.CREATE : DbSchemaValidation.VALIDATE;
|
48
|
URI source = greekChecklist(); //just any
|
49
|
//make Source
|
50
|
GreeceWillingImportConfigurator config = GreeceWillingImportConfigurator.NewInstance(source, cdmDestination);
|
51
|
config.setCheck(CHECK.IMPORT_WITHOUT_CHECK);
|
52
|
config.setDbSchemaValidation(schemaVal);
|
53
|
config.setSourceReference(getSourceReference());
|
54
|
config.setNomenclaturalCode(NomenclaturalCode.ICNAFP);
|
55
|
|
56
|
CdmDefaultImport<GreeceWillingImportConfigurator> myImport = new CdmDefaultImport<>();
|
57
|
ImportResult result = myImport.invoke(config);
|
58
|
System.out.println(result.createReport());
|
59
|
|
60
|
}
|
61
|
|
62
|
|
63
|
private URI greekChecklist(){
|
64
|
return URI.create("file:////BGBM-PESIHPC/Greece/" + fileName);
|
65
|
}
|
66
|
|
67
|
|
68
|
private Reference getSourceReference(){
|
69
|
Reference result = ReferenceFactory.newDatabase();
|
70
|
// xx;
|
71
|
result.setTitle(fileName);
|
72
|
result.setUuid(sourceUuid);
|
73
|
|
74
|
return result;
|
75
|
}
|
76
|
|
77
|
/**
|
78
|
* @param args
|
79
|
*/
|
80
|
public static void main(String[] args) {
|
81
|
GreeceWillingActivator me = new GreeceWillingActivator();
|
82
|
me.doImport(cdmDestination);
|
83
|
System.exit(0);
|
84
|
}
|
85
|
|
86
|
}
|