2 * Copyright (C) 2016 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.app
.greece
;
11 import eu
.etaxonomy
.cdm
.common
.URI
;
12 import java
.util
.UUID
;
14 import org
.apache
.log4j
.Logger
;
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
.common
.Language
;
25 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
26 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
27 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
31 * Import for new images for the Flora of Greece.
33 * https://dev.e-taxonomy.eu/redmine/issues/7075
38 * <LI>In Excel file we should have 3 URI columns for large, medium and small.</LI>
39 * If they not exists create cells with something like "=WECHSELN(C2;"large";"medium")" (German Excel version)
40 * Label these columns url_size1, url_size2 and url_size3</LI>
41 * <LI>If the medium and small versions of the images do not yet exist, create them in an according folder
42 * (you may need to ask for access to the server in Greece)</LI>
43 * <LI>Copy only the new images into a local folder (use date to
44 * determine new images if more images are in the original folder)</LI>
45 * <LI>Open IrfanView and open File->BatchConversion/Rename</LI>
46 * <LI>Use Advanced options for bulk resize and use the following parameters:</LI>
47 * <UL><LI> for small: -> Set one or both sides to width=210 (height=-empty-)</LI>
48 * <LI> for medium: -> Set short side to 350</LI>
50 * <LI>Select all images and move them to the "input files"</LI>
51 * <LI>Choose correct "Output folder for result files" (repeat for both sizes)</LI>
52 * <LI>Upload images in both folders to correct place in remote server</LI>
53 * <LI>Update the filename parameter in code below.</LI>
54 * <LI>Upload the Excel file to /BGBM-PESIHPC/Greece/images/ (see {@link #greekChecklist()}) below</LI>
55 * <LI>Run with localH2 to test if everything works, if yes
62 public class GreeceImageActivator
{
64 @SuppressWarnings("unused")
65 private static final Logger logger
= Logger
.getLogger(GreeceImageActivator
.class);
67 static final ICdmDataSource cdmDestination
= CdmDestinations
.localH2();
68 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_greece_checklist();
70 private static final UUID sourceUuid
= UUID
.fromString("6fb69240-b344-484a-83c0-2befcee3e6e1");
71 // private static final UUID sourceUuid = UUID.fromString("47716558-a2c1-4108-a9f4-7da241b9c26e");
73 private static final String fileName
= "metadata_FoG_20200512.xlsx";
74 // private static final String fileName = "metadata_FoG_AK_Willing_correct.xlsx";
77 // NOTE!!: Darauf achten, dass die Header case sensitiv sind und keine Leerzeichen am Ende sein sollten, trim funktioniert seltsamerweise nicht immer
80 static final CHECK check
= CHECK
.IMPORT_WITHOUT_CHECK
;
82 private void doImport(ICdmDataSource cdmDestination
){
84 DbSchemaValidation schemaVal
= cdmDestination
.getDatabaseType() == DatabaseTypeEnum
.H2 ? DbSchemaValidation
.CREATE
: DbSchemaValidation
.VALIDATE
;
85 URI source
= greekChecklist(); //just any
87 MediaExcelImportConfigurator config
= MediaExcelImportConfigurator
.NewInstance(source
, cdmDestination
);
88 config
.setCheck(check
);
89 config
.setDbSchemaValidation(schemaVal
);
90 config
.setSourceReference(getSourceReference());
91 config
.setDescriptionLanguage(Language
.uuidEnglish
);
92 config
.setTitleLanguageUuid(Language
.uuidEnglish
);
93 config
.setNomenclaturalCode(NomenclaturalCode
.ICNAFP
);
95 CdmDefaultImport
<MediaExcelImportConfigurator
> myImport
= new CdmDefaultImport
<>();
96 ImportResult result
= myImport
.invoke(config
);
97 System
.out
.println(result
.createReport());
100 private URI
greekChecklist(){
101 return URI
.create("file:////BGBM-PESIHPC/Greece/images/" + fileName
);
104 private Reference
getSourceReference(){
105 Reference result
= ReferenceFactory
.newDatabase();
106 result
.setTitle(fileName
);
107 result
.setUuid(sourceUuid
);
112 public static void main(String
[] args
) {
113 GreeceImageActivator me
= new GreeceImageActivator();
114 me
.doImport(cdmDestination
);