1
|
/**
|
2
|
* Copyright (C) 2016 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.media.in.MediaExcelImportConfigurator;
|
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
|
*
|
30
|
* Import for new images for the flora of greece.
|
31
|
*
|
32
|
* https://dev.e-taxonomy.eu/redmine/issues/7075
|
33
|
*
|
34
|
* @author a.mueller
|
35
|
* @since 13.12.2016
|
36
|
*/
|
37
|
public class GreeceImageActivator {
|
38
|
@SuppressWarnings("unused")
|
39
|
private static final Logger logger = Logger.getLogger(GreeceImageActivator.class);
|
40
|
|
41
|
|
42
|
static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
43
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
|
44
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_greece_checklist_production();
|
45
|
|
46
|
// private static final UUID sourceUuid = UUID.fromString("0fd093fe-ffdf-4ace-847b-aad6f0659678");
|
47
|
private static final UUID sourceUuid = UUID.fromString("9e6a3815-fb8d-46c3-a250-6d8a350d03fc");
|
48
|
|
49
|
private static final String fileName = "20190507_fog_images.xlsx";
|
50
|
// private static final String fileName = "20190124_fog_images.xlsx";
|
51
|
|
52
|
|
53
|
// NOTE!!: Darauf achten, dass die Header case sensitiv sind und keine Leerzeichen am Ende sein sollten, trim funktioniert seltsamerweise nicht immer
|
54
|
|
55
|
//check - import
|
56
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
57
|
|
58
|
private void doImport(ICdmDataSource cdmDestination){
|
59
|
|
60
|
DbSchemaValidation schemaVal = cdmDestination.getDatabaseType() == DatabaseTypeEnum.H2 ? DbSchemaValidation.CREATE : DbSchemaValidation.VALIDATE;
|
61
|
URI source = greekChecklist(); //just any
|
62
|
//make Source
|
63
|
MediaExcelImportConfigurator config = MediaExcelImportConfigurator.NewInstance(source, cdmDestination);
|
64
|
config.setCheck(check);
|
65
|
config.setDbSchemaValidation(schemaVal);
|
66
|
config.setSourceReference(getSourceReference());
|
67
|
config.setNomenclaturalCode(NomenclaturalCode.ICNAFP);
|
68
|
|
69
|
CdmDefaultImport<MediaExcelImportConfigurator> myImport = new CdmDefaultImport<>();
|
70
|
ImportResult result = myImport.invoke(config);
|
71
|
System.out.println(result.createReport());
|
72
|
|
73
|
}
|
74
|
|
75
|
|
76
|
private URI greekChecklist(){
|
77
|
return URI.create("file:////BGBM-PESIHPC/Greece/images/" + fileName);
|
78
|
}
|
79
|
|
80
|
|
81
|
private Reference getSourceReference(){
|
82
|
Reference result = ReferenceFactory.newDatabase();
|
83
|
result.setTitle(fileName);
|
84
|
result.setUuid(sourceUuid);
|
85
|
|
86
|
return result;
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
* @param args
|
91
|
*/
|
92
|
public static void main(String[] args) {
|
93
|
GreeceImageActivator me = new GreeceImageActivator();
|
94
|
me.doImport(cdmDestination);
|
95
|
System.exit(0);
|
96
|
}
|
97
|
}
|