1 |
94853726
|
Andreas Müller
|
/**
|
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 |
5b9d66b0
|
Andreas Müller
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_greece_checklist();
|
40 |
1064bb88
|
Andreas Müller
|
boolean doCheckNames = false;
|
41 |
94853726
|
Andreas Müller
|
|
42 |
1064bb88
|
Andreas Müller
|
private static final UUID sourceUuid = UUID.fromString("70efe59f-8b0c-4f83-b54e-2a16f567fe8e");
|
43 |
94853726
|
Andreas Müller
|
|
44 |
1064bb88
|
Andreas Müller
|
private static final String fileName = "WillingImport_Kreta_no_barcode_005_243.xlsx";
|
45 |
106c8a4d
|
Andreas Müller
|
|
46 |
94853726
|
Andreas Müller
|
|
47 |
|
|
private void doImport(ICdmDataSource cdmDestination){
|
48 |
|
|
|
49 |
|
|
DbSchemaValidation schemaVal = cdmDestination.getDatabaseType() == DatabaseTypeEnum.H2 ? DbSchemaValidation.CREATE : DbSchemaValidation.VALIDATE;
|
50 |
|
|
URI source = greekChecklist(); //just any
|
51 |
|
|
//make Source
|
52 |
|
|
GreeceWillingImportConfigurator config = GreeceWillingImportConfigurator.NewInstance(source, cdmDestination);
|
53 |
|
|
config.setCheck(CHECK.IMPORT_WITHOUT_CHECK);
|
54 |
|
|
config.setDbSchemaValidation(schemaVal);
|
55 |
|
|
config.setSourceReference(getSourceReference());
|
56 |
|
|
config.setNomenclaturalCode(NomenclaturalCode.ICNAFP);
|
57 |
1064bb88
|
Andreas Müller
|
config.setIsH2(cdmDestination.getDatabaseType() == DatabaseTypeEnum.H2);
|
58 |
|
|
config.setCheckNamesOnly(doCheckNames);
|
59 |
94853726
|
Andreas Müller
|
|
60 |
|
|
CdmDefaultImport<GreeceWillingImportConfigurator> myImport = new CdmDefaultImport<>();
|
61 |
|
|
ImportResult result = myImport.invoke(config);
|
62 |
|
|
System.out.println(result.createReport());
|
63 |
|
|
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
private URI greekChecklist(){
|
68 |
106c8a4d
|
Andreas Müller
|
return URI.create("file:////BGBM-PESIHPC/Greece/images/" + fileName);
|
69 |
94853726
|
Andreas Müller
|
}
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
private Reference getSourceReference(){
|
73 |
|
|
Reference result = ReferenceFactory.newDatabase();
|
74 |
|
|
// xx;
|
75 |
106c8a4d
|
Andreas Müller
|
result.setTitle("BGBM Herbar");
|
76 |
94853726
|
Andreas Müller
|
result.setUuid(sourceUuid);
|
77 |
|
|
|
78 |
|
|
return result;
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
/**
|
82 |
|
|
* @param args
|
83 |
|
|
*/
|
84 |
|
|
public static void main(String[] args) {
|
85 |
|
|
GreeceWillingActivator me = new GreeceWillingActivator();
|
86 |
|
|
me.doImport(cdmDestination);
|
87 |
|
|
System.exit(0);
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
}
|