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.DbSchemaValidation;
|
18
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
19
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
20
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
21
|
import eu.etaxonomy.cdm.io.common.ImportResult;
|
22
|
import eu.etaxonomy.cdm.io.media.in.MediaExcelImportConfigurator;
|
23
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
24
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
25
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
26
|
|
27
|
/**
|
28
|
*
|
29
|
* Import for Checklist of Greece.
|
30
|
*
|
31
|
* https://dev.e-taxonomy.eu/redmine/issues/6286
|
32
|
*
|
33
|
* @author a.mueller
|
34
|
* @date 13.12.2016
|
35
|
*/
|
36
|
public class GreeceImageActivator {
|
37
|
@SuppressWarnings("unused")
|
38
|
private static final Logger logger = Logger.getLogger(GreeceImageActivator.class);
|
39
|
|
40
|
|
41
|
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
42
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
|
43
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_greece_checklist_production();
|
44
|
|
45
|
// private static final UUID sourceUuid = UUID.fromString("418b5885-08fb-4f1e-ac94-8f5c84b1683d");
|
46
|
private static final UUID sourceUuid = UUID.fromString("c3d300f0-86ef-4c65-8727-c594035ed7a7");
|
47
|
// private static final String fileName = "20171107_sent_1332_images.xlsx";
|
48
|
private static final String fileName = "20171110_Turland_433_others_59.xlsx";
|
49
|
|
50
|
|
51
|
//check - import
|
52
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
53
|
|
54
|
boolean doImages = true;
|
55
|
|
56
|
private void doImport(ICdmDataSource cdmDestination){
|
57
|
|
58
|
URI source = greekChecklist(); //just any
|
59
|
//make Source
|
60
|
MediaExcelImportConfigurator config = MediaExcelImportConfigurator.NewInstance(source, cdmDestination);
|
61
|
config.setCheck(check);
|
62
|
config.setDbSchemaValidation(DbSchemaValidation.VALIDATE);
|
63
|
config.setSourceReference(getSourceReference());
|
64
|
config.setNomenclaturalCode(NomenclaturalCode.ICNAFP);
|
65
|
|
66
|
CdmDefaultImport<MediaExcelImportConfigurator> myImport = new CdmDefaultImport<>();
|
67
|
ImportResult result = myImport.invoke(config);
|
68
|
System.out.println(result.createReport());
|
69
|
|
70
|
}
|
71
|
|
72
|
|
73
|
private URI greekChecklist(){
|
74
|
return URI.create("file:////BGBM-PESIHPC/Greece/images/" + fileName);
|
75
|
}
|
76
|
|
77
|
|
78
|
private Reference getSourceReference(){
|
79
|
Reference result = ReferenceFactory.newDatabase();
|
80
|
result.setTitle(fileName);
|
81
|
result.setUuid(sourceUuid);
|
82
|
|
83
|
return result;
|
84
|
}
|
85
|
|
86
|
/**
|
87
|
* @param args
|
88
|
*/
|
89
|
public static void main(String[] args) {
|
90
|
GreeceImageActivator me = new GreeceImageActivator();
|
91
|
me.doImport(cdmDestination);
|
92
|
System.exit(0);
|
93
|
}
|
94
|
}
|