Project

General

Profile

« Previous | Next » 

Revision f7541698

Added by Andreas Müller about 6 years ago

ref #7216 use pteridophyta (not spermatophyta) and remove unused alternative family implementations for Cuba import

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/app/common/tasks/Deduplicator.java
1
/**
2
* Copyright (C) 2017 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.common.tasks;
10

  
11
import org.apache.log4j.Logger;
12

  
13
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
14
import eu.etaxonomy.cdm.app.common.CdmDestinations;
15
import eu.etaxonomy.cdm.database.DbSchemaValidation;
16
import eu.etaxonomy.cdm.database.ICdmDataSource;
17
import eu.etaxonomy.cdm.model.agent.Person;
18
import eu.etaxonomy.cdm.model.agent.Team;
19
import eu.etaxonomy.cdm.model.reference.Reference;
20

  
21
/**
22
 * Deduplicates certain classes.
23
 *
24
 * CAUTION: Deduplicating teams does not yet work correctly. Team members are often duplicated.
25
 *
26
 * @author a.mueller
27
 * @date 24.11.2017
28
 *
29
 */
30
public class Deduplicator {
31
    @SuppressWarnings("unused")
32
    private static final Logger logger = Logger.getLogger(Deduplicator.class);
33

  
34
    //database validation status (create, update, validate ...)
35
//  static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
36
//  static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_cichorieae();
37
//  static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
38
    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_caryophyllales_spp();
39
//  static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_caryo_spp();
40

  
41

  
42

  
43
   static boolean doPersons = false;
44
   static boolean doTeams = true;
45
   static boolean doReferences = false;
46

  
47

  
48
    private void doInvoke(ICdmDataSource destination){
49

  
50
        try {
51
            CdmApplicationController app = CdmApplicationController.NewInstance(destination, DbSchemaValidation.VALIDATE);
52

  
53
            if (doPersons){
54
                app.getAgentService().deduplicate(Person.class, null, null);
55
            }
56
            if (doTeams){
57
                app.getAgentService().deduplicate(Team.class, null, null);
58
            }
59
            if (doReferences){
60
                app.getReferenceService().deduplicate(Reference.class, null, null);
61
            }
62
        } catch (Exception e) {
63
            e.printStackTrace();
64
        }
65

  
66

  
67
    }
68

  
69
    /**
70
     * @param args
71
     */
72
    public static void main(String[] args) {
73
        ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
74

  
75
        System.out.println("Start updating caches for "+ destination.getDatabase() + "...");
76
        Deduplicator me = new Deduplicator();
77
        me.doInvoke(destination);
78
        System.exit(0);
79

  
80
    }
81
}
app-import/src/main/java/eu/etaxonomy/cdm/app/redlist/BfnXmlImportActivator.java
9 9

  
10 10
package eu.etaxonomy.cdm.app.redlist;
11 11

  
12
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand1_kriechtiere;
13
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand1_lurche;
14
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand1_saeugetiere;
15
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand1_suessfische;
16
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand2_bodenlebendenWirbellosenMeerestiere;
17
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand2_meeresfischeUndNeunaugen;
18
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_ameisen;
19
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_bienen;
20
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_binnenmollusken;
21
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_eulenfalter;
22
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_fransenfluegler;
23
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_heuschrecken;
24
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_ohrwuermer;
25
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_pflanzenwespen;
26
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_raubfliegen;
27
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_schaben;
28
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_schwebfliegen;
29
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_spanner;
30
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_spinner;
31
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_tagfalter;
32
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_tanzfliegen;
33
import static eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportReferences.uuidBand3_zuenslerfalter;
34

  
35 12
import java.net.URI;
36 13
import java.util.Arrays;
37 14
import java.util.Iterator;
......
68 45
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_plant_localhost();
69 46
//	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
70 47
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();
71
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_animalia_production_final();
72
    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_redlist_mammalia();
48
	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_animalia_production_final();
49
//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_redlist_mammalia();
73 50

  
74 51
	private static final String sourceUriBase = "file:////BGBM-PESIHPC/RoteListen/RoteListenXml/";
75 52

  
......
153 130
//				"rldb_print_v4_0_1_0_Myxo_110708_korr_syn_neu.xml",uuidBand6_myxomyzeten.toString(),
154 131
//
155 132
//				Animals
156
		        //band1
157
				"rldb_print_v4_0_1_0_Brutvoegel.xml",BfnXmlImportReferences.uuidBand1_brutvoegel.toString(), //Brutvögel
158
				"rldb_print_v4_0_1_0_Reptilien_1.xml",uuidBand1_kriechtiere.toString(),
159
                "rldb_print_v4_0_1_0_Amphibien.xml",uuidBand1_lurche.toString(),  //Kriechtiere
160
                "RoteListe_v4_0_6_0_BFN_Saeuger_korr.xml",uuidBand1_saeugetiere.toString(), //Säugetiere
161
                "rldb_print_v4_0_1_0_Fische.xml",uuidBand1_suessfische.toString(),
162
                //
163
		        //band2
164
		        "rldb_print_v4_0_1_0_artenarmeWeichtiergruppen_121127_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
165
		        "rldb_print_v4_0_1_0_Asselspinnen_120907_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
166
		        "rldb_print_v4_0_1_0_Flohkrebse_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
167
		        "rldb_print_v4_0_1_0_Igelwuermer_120907_verantw.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
168
		        "rldb_print_v4_0_1_0_Kumazeen_120709_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
169
		        "rldb_print_v4_0_1_0_Asseln_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
170
		        "rldb_print_v4_0_1_0_Moostierchen_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
171
		        "rldb_print_v4_0_1_0_Muscheln_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
172
		        "rldb_print_v4_0_1_0_Schnecken_130206_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
173
		        "rldb_print_v4_0_1_0_Meeresfische_syn.xml",uuidBand2_meeresfischeUndNeunaugen.toString(),
174
		        "rldb_print_v4_0_1_0_Nesseltiere_130104_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
175
		        "rldb_print_v4_0_1_0_Schaedellose_120907_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(), //Schädellose
176
		        "rldb_print_v4_0_1_0_Schwaemme_121127_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(), //Schwämme
177
		        "rldb_print_v4_0_1_0_Seepocken_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
178
		        "rldb_print_v4_0_1_0_Seescheiden_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
179
		        "rldb_print_v4_0_1_0_Stachelhaeuter_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(), //Stachelhäuter
180
		        "rldb_print_v4_0_1_0_Vielborster_130206_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
181
		        "rldb_print_v4_0_1_0_Wenigborster_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
182
		        "rldb_print_v4_0_1_0_Zehnfusskrebse_130104_verantw_syn.xml", uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
183
		        //
184
		        //band3
185
			    "rldb_print_v4_0_1_0_Ameisen_110609_rev120113_syn.xml", uuidBand3_ameisen.toString(), //Hymenoptera: Formicidae
186
			    "rldb_print_v4_0_1_0_Bienen_PWKorr_HG_120413_DF_120612_syn.xml",uuidBand3_bienen.toString(),  //Hymnenoptera: Apidae
187
			    "rldb_print_v4_0_1_0_Binnenmollusken_0alle_120413_DF_syn.xml",uuidBand3_binnenmollusken.toString(),
188
			    //eulenfalter - korrekt?
189
			    "rldb_print_v4_0_1_0_Eulen_Korruebern_23-05-2012_KorrV_syn.xml",uuidBand3_eulenfalter.toString(), //Eulen & Korrübern
190
			    "rldb_print_v4_0_1_0_Thysanoptera_120413_DF_korrV_Verantw.xml",uuidBand3_fransenfluegler.toString(),
191
			    "rldb_print_v4_0_1_0_Heuschrecken_syn.xml",uuidBand3_heuschrecken.toString(),  //Saltatoria
192
			    "rldb_print_v4_0_1_0_Ohrwuermer_DF_syn.xml",uuidBand3_ohrwuermer.toString(),   //Dermaptera
193
			    "rldb_print_v4_0_1_0_Pflanzenwespen_280711_Autor_110815_HG2_120413_DF_syn.xml",uuidBand3_pflanzenwespen.toString(), //Hymenoptera: Symphata
194
			    "rldb_print_v4_0_1_0_Asilidae_GMH_Wolff_110314_HGxls_120413_DF_korrV_Verantw_syn.xml",uuidBand3_raubfliegen.toString(),
195
			    "rldb_print_v4_0_1_0_Blattoptera_140413_DF_syn.xml",uuidBand3_schaben.toString(),
196
			    "rldb_print_v4_0_1_0_Schwebfliegen_111103_KorrAS_120413_DF_syn.xml",uuidBand3_schwebfliegen.toString(), //Diptera: Syrphidae
197
			    //spanner - korrekt?
198
				"rldb_print_v4_0_1_0_Eulenspinner_Spanner_13-06-2012_KorrV_syn.xml",uuidBand3_spanner.toString(), //Eulenspinner & Spanner
199
			    "rldb_print_v4_0_1_0_Spinner_Oktober2011_eingearbKorr_120124_Korruebern_MB_02-05-2012_KorrV_syn.xml",uuidBand3_spinner.toString(),
200
			    "rldb_print_v4_0_1_0_Tagfalter_06-06-2012_KorrV_syn.xml",uuidBand3_tagfalter.toString(),
201
			    "rldb_print_v4_0_1_0_Empidoidea_120413_DF.xml",uuidBand3_tanzfliegen.toString(),  //Empidoidea
202
			    //wespen - fehlen ????? => siehe auch titel des Referenz Word Files
203
			    "rldb_print_v4_0_1_0_Pyraloidea_Februar_2012_Korruebern_MB_24-04-2012_syn.xml",uuidBand3_zuenslerfalter.toString()
133
//		        //band1
134
//				"rldb_print_v4_0_1_0_Brutvoegel.xml",BfnXmlImportReferences.uuidBand1_brutvoegel.toString(), //Brutvögel
135
//				"rldb_print_v4_0_1_0_Reptilien_1.xml",uuidBand1_kriechtiere.toString(),
136
//                "rldb_print_v4_0_1_0_Amphibien.xml",uuidBand1_lurche.toString(),  //Kriechtiere
137
//                "RoteListe_v4_0_6_0_BFN_Saeuger_korr.xml",uuidBand1_saeugetiere.toString(), //Säugetiere
138
//                "rldb_print_v4_0_1_0_Fische.xml",uuidBand1_suessfische.toString(),
139
//                //
140
//		        //band2
141
//		        "rldb_print_v4_0_1_0_artenarmeWeichtiergruppen_121127_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
142
//		        "rldb_print_v4_0_1_0_Asselspinnen_120907_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
143
//		        "rldb_print_v4_0_1_0_Flohkrebse_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
144
//		        "rldb_print_v4_0_1_0_Igelwuermer_120907_verantw.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
145
//		        "rldb_print_v4_0_1_0_Kumazeen_120709_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
146
//		        "rldb_print_v4_0_1_0_Asseln_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
147
//		        "rldb_print_v4_0_1_0_Moostierchen_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
148
//		        "rldb_print_v4_0_1_0_Muscheln_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
149
//		        "rldb_print_v4_0_1_0_Schnecken_130206_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
150
//		        "rldb_print_v4_0_1_0_Meeresfische_syn.xml",uuidBand2_meeresfischeUndNeunaugen.toString(),
151
//		        "rldb_print_v4_0_1_0_Nesseltiere_130104_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
152
//		        "rldb_print_v4_0_1_0_Schaedellose_120907_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(), //Schädellose
153
//		        "rldb_print_v4_0_1_0_Schwaemme_121127_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(), //Schwämme
154
//		        "rldb_print_v4_0_1_0_Seepocken_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
155
//		        "rldb_print_v4_0_1_0_Seescheiden_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
156
//		        "rldb_print_v4_0_1_0_Stachelhaeuter_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(), //Stachelhäuter
157
//		        "rldb_print_v4_0_1_0_Vielborster_130206_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
158
//		        "rldb_print_v4_0_1_0_Wenigborster_121128_verantw_syn.xml",uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
159
//		        "rldb_print_v4_0_1_0_Zehnfusskrebse_130104_verantw_syn.xml", uuidBand2_bodenlebendenWirbellosenMeerestiere.toString(),
160
//		        //
161
//		        //band3
162
//			    "rldb_print_v4_0_1_0_Ameisen_110609_rev120113_syn.xml", uuidBand3_ameisen.toString(), //Hymenoptera: Formicidae
163
//			    "rldb_print_v4_0_1_0_Bienen_PWKorr_HG_120413_DF_120612_syn.xml",uuidBand3_bienen.toString(),  //Hymnenoptera: Apidae
164
//			    "rldb_print_v4_0_1_0_Binnenmollusken_0alle_120413_DF_syn.xml",uuidBand3_binnenmollusken.toString(),
165
//			    //eulenfalter - korrekt?
166
//			    "rldb_print_v4_0_1_0_Eulen_Korruebern_23-05-2012_KorrV_syn.xml",uuidBand3_eulenfalter.toString(), //Eulen & Korrübern
167
//			    "rldb_print_v4_0_1_0_Thysanoptera_120413_DF_korrV_Verantw.xml",uuidBand3_fransenfluegler.toString(),
168
//			    "rldb_print_v4_0_1_0_Heuschrecken_syn.xml",uuidBand3_heuschrecken.toString(),  //Saltatoria
169
//			    "rldb_print_v4_0_1_0_Ohrwuermer_DF_syn.xml",uuidBand3_ohrwuermer.toString(),   //Dermaptera
170
//			    "rldb_print_v4_0_1_0_Pflanzenwespen_280711_Autor_110815_HG2_120413_DF_syn.xml",uuidBand3_pflanzenwespen.toString(), //Hymenoptera: Symphata
171
//			    "rldb_print_v4_0_1_0_Asilidae_GMH_Wolff_110314_HGxls_120413_DF_korrV_Verantw_syn.xml",uuidBand3_raubfliegen.toString(),
172
//			    "rldb_print_v4_0_1_0_Blattoptera_140413_DF_syn.xml",uuidBand3_schaben.toString(),
173
//			    "rldb_print_v4_0_1_0_Schwebfliegen_111103_KorrAS_120413_DF_syn.xml",uuidBand3_schwebfliegen.toString(), //Diptera: Syrphidae
174
//			    //spanner - korrekt?
175
//				"rldb_print_v4_0_1_0_Eulenspinner_Spanner_13-06-2012_KorrV_syn.xml",uuidBand3_spanner.toString(), //Eulenspinner & Spanner
176
//			    "rldb_print_v4_0_1_0_Spinner_Oktober2011_eingearbKorr_120124_Korruebern_MB_02-05-2012_KorrV_syn.xml",uuidBand3_spinner.toString(),
177
//			    "rldb_print_v4_0_1_0_Tagfalter_06-06-2012_KorrV_syn.xml",uuidBand3_tagfalter.toString(),
178
//			    "rldb_print_v4_0_1_0_Empidoidea_120413_DF.xml",uuidBand3_tanzfliegen.toString(),  //Empidoidea
179
//			    //wespen - fehlen ????? => siehe auch titel des Referenz Word Files
180
//			    "rldb_print_v4_0_1_0_Pyraloidea_Februar_2012_Korruebern_MB_24-04-2012_syn.xml",uuidBand3_zuenslerfalter.toString()
204 181

  
205 182

  
206 183
//		        //the 4 first lists, THESE ARE DUPLICATES
207
//		        "RoteListe_v4_0_6_0_BFN_Saeuger_korr.xml",
208
//                "rldb_print_v4_0_1_0_Amphibien.xml",
209
//                "rldb_print_v4_0_1_0_Reptilien_1.xml",
210
//                "rldb_print_v4_0_1_0_Heuschrecken_syn.xml"
184
//		        "RoteListe_v4_0_6_0_BFN_Saeuger_korr.xml",BfnXmlImportReferences.uuidBand1_saeugetiere.toString(),
185
                "rldb_print_v4_0_1_0_Amphibien.xml",BfnXmlImportReferences.uuidBand1_lurche.toString(),
186
                "rldb_print_v4_0_1_0_Reptilien_1.xml",BfnXmlImportReferences.uuidBand1_kriechtiere.toString(),
187
                "rldb_print_v4_0_1_0_Heuschrecken_syn.xml", BfnXmlImportReferences.uuidBand3_heuschrecken.toString()
211 188

  
212 189
				);
213 190

  
app-import/src/main/java/eu/etaxonomy/cdm/io/cuba/CubaExcelImport.java
36 36
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
37 37
import eu.etaxonomy.cdm.model.common.Language;
38 38
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
39
import eu.etaxonomy.cdm.model.common.Representation;
40 39
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
41 40
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
42 41
import eu.etaxonomy.cdm.model.description.Distribution;
......
44 43
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
45 44
import eu.etaxonomy.cdm.model.description.TaxonDescription;
46 45
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
47
import eu.etaxonomy.cdm.model.description.TextData;
48 46
import eu.etaxonomy.cdm.model.location.NamedArea;
49 47
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
50 48
import eu.etaxonomy.cdm.model.name.IBotanicalName;
......
87 85

  
88 86
    private static UUID rootUuid = UUID.fromString("206d42e4-ac32-4f20-a093-14826014e667");
89 87
    private static UUID spermatophytaUuid = UUID.fromString("139e7314-dd19-4286-a01d-8cc94ef77a09");
88
    private static UUID pteridophytaUuid = UUID.fromString("cd2a7c42-4e2b-4a42-8044-18c8e3ccb76d");
90 89

  
91 90
    private static INonViralNameParser<?> nameParser = NonViralNameParserImpl.NewInstance();
92 91
    private static NomenclaturalCode nc = NomenclaturalCode.ICNAFP;
......
1323 1322
        }
1324 1323
        TaxonNode rootNode = state.getRootNode();
1325 1324
        if (rootNode == null){
1326
            rootNode = getTaxonNodeService().find(spermatophytaUuid);
1325
            rootNode = getTaxonNodeService().find(pteridophytaUuid);
1327 1326
        }
1328 1327
        if (rootNode == null){
1329 1328
            Reference sec = getSecReference(state);
......
1570 1569

  
1571 1570
        TaxonDescription desc = getTaxonDescription(taxon, false, true);
1572 1571

  
1573
        UUID altFamUuid1;
1572
//        UUID altFamUuid1;
1574 1573
        UUID altFamUuid2;
1575 1574
        try {
1576
            altFamUuid1 = state.getTransformer().getFeatureUuid("Alt.Fam.");
1575
//            altFamUuid1 = state.getTransformer().getFeatureUuid("Alt.Fam.");
1577 1576
            altFamUuid2 = state.getTransformer().getFeatureUuid("Alt.Fam.2");
1578 1577
        } catch (UndefinedTransformerMethodException e) {
1579 1578
            throw new RuntimeException(e);
......
1583 1582
        Taxon famTaxon = makeAlternativeFamilyTaxon(state, famStr, famRef);
1584 1583

  
1585 1584

  
1586
        //TextData
1587
        Feature feature1 = getFeature(state, altFamUuid1, "Families in other Floras (Text)", "Families in other Floras (Text)", "Other floras", null);
1588
        feature1.addRepresentation(Representation.NewInstance("Familias en otras Floras", "Familias en otras Floras", null, Language.SPANISH_CASTILIAN()));
1589
//        TextData textData = TextData.NewInstance(feature1, famStr, Language.DEFAULT(), null);
1590
        TextData textData = TextData.NewInstance(feature1, null, Language.DEFAULT(), null);
1591
        textData.addSource(OriginalSourceType.PrimaryTaxonomicSource, null,null, famRef, null, famTaxon.getName(),null);
1592
        desc.addElement(textData);
1585
        //TextData  //not used anymore
1586
//        Feature feature1 = getFeature(state, altFamUuid1, "Families in other Floras (Text)", "Families in other Floras (Text)", "Other floras", null);
1587
//        feature1.addRepresentation(Representation.NewInstance("Familias en otras Floras", "Familias en otras Floras", null, Language.SPANISH_CASTILIAN()));
1588
////        TextData textData = TextData.NewInstance(feature1, famStr, Language.DEFAULT(), null);
1589
//        TextData textData = TextData.NewInstance(feature1, null, Language.DEFAULT(), null);
1590
//        textData.putText(Language.SPANISH_CASTILIAN(), "Familias en otras Floras");
1591
//        textData.addSource(OriginalSourceType.PrimaryTaxonomicSource, null,null, famRef, null, famTaxon.getName(),null);
1592
//        desc.addElement(textData);
1593 1593

  
1594 1594

  
1595 1595

  
1596 1596
        //TaxonInteraction
1597
        Feature feature2 = getFeature(state, altFamUuid2, "Families in other Floras", "Families in other Floras", "Other floras(2)", null);
1598
        feature2.setSupportsTaxonInteraction(true);
1599
        feature2.addRepresentation(Representation.NewInstance("Familias en otras Floras", "Familias en otras Floras", null, Language.SPANISH_CASTILIAN()));
1597
        Feature feature2 = getFeature(state, altFamUuid2, "Families in other Floras", "Families in other Floras", "Other floras", null);
1598
        //feature should exist already
1599
//        feature2.setSupportsTaxonInteraction(true);
1600
//        feature2.addRepresentation(Representation.NewInstance("Familias en otras Floras", "Familias en otras Floras", null, Language.SPANISH_CASTILIAN()));
1600 1601
        TaxonInteraction taxInteract = TaxonInteraction.NewInstance(feature2);
1601
        textData.putText(Language.SPANISH_CASTILIAN(), "Familias en otras Floras");
1602 1602
        taxInteract.setTaxon2(famTaxon);
1603 1603
        taxInteract.addSource(OriginalSourceType.PrimaryTaxonomicSource, null,null, famRef, null);
1604 1604
        desc.addElement(taxInteract);
1605 1605

  
1606
        //Concept Relation
1607
        famTaxon.addTaxonRelation(taxon, TaxonRelationshipType.INCLUDES(), taxon.getSec(), null);
1606
        //Concept Relation  //not used anymore
1607
//        famTaxon.addTaxonRelation(taxon, TaxonRelationshipType.INCLUDES(), taxon.getSec(), null);
1608 1608

  
1609 1609
    }
1610 1610

  
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/ImageImportTest.java
1
/**
2
* Copyright (C) 2017 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.io.greece;
10

  
11
import java.io.File;
12
import java.io.IOException;
13
import java.net.URI;
14
import java.util.ArrayList;
15

  
16
import org.apache.http.HttpException;
17
import org.apache.log4j.Logger;
18
import org.apache.sanselan.ImageReadException;
19
import org.apache.sanselan.Sanselan;
20
import org.apache.sanselan.common.IImageMetadata;
21
import org.apache.sanselan.common.ImageMetadata.Item;
22
import org.joda.time.DateTime;
23
import org.joda.time.DateTimeZone;
24
import org.joda.time.format.DateTimeFormat;
25
import org.joda.time.format.DateTimeFormatter;
26

  
27
import eu.etaxonomy.cdm.common.media.ImageInfo;
28
import eu.etaxonomy.cdm.io.common.utils.ImportDeduplicationHelper;
29
import eu.etaxonomy.cdm.model.agent.AgentBase;
30
import eu.etaxonomy.cdm.model.description.TaxonDescription;
31
import eu.etaxonomy.cdm.model.description.TextData;
32
import eu.etaxonomy.cdm.model.media.ImageFile;
33
import eu.etaxonomy.cdm.model.media.Media;
34
import eu.etaxonomy.cdm.model.taxon.Taxon;
35

  
36
/**
37
 * @author a.mueller
38
 * @date 13.05.2017
39
 *
40
 */
41
public class ImageImportTest {
42

  
43
    @SuppressWarnings("unused")
44
    private static final Logger logger = Logger.getLogger(FloraHellenicaImageImport.class);
45

  
46
    private static final String BASE_URL = "https://media.e-taxonomy.eu/flora-greece/";
47
    private static final String IMAGE_FOLDER = "////BGBM-PESIHPC/Greece/thumbs/";
48
    private ImportDeduplicationHelper deduplicationHelper = null;
49

  
50
    protected void doInvoke() {
51
        for (int plate = 1; plate < 22 ; plate++){
52
            System.out.println("Plate: " + plate);
53
            String fill = plate < 10 ? "0" : "";
54
            String plateStr = "Plate_" + fill + plate + "/";
55
            String fullFolderUrl = BASE_URL + plateStr;
56
            String fullThumbUrl = BASE_URL + "thumbs/" + plateStr;
57
            String folderStr = IMAGE_FOLDER + plateStr;
58
            File file = new File(folderStr);
59
            String[] list = file.list();
60
            System.out.println(DateTimeZone.getAvailableIDs());
61
            for (String fileStr : list){
62
                String[] taxonNameAndArtist = getTaxonName(fileStr);
63
                String taxonNameStr = taxonNameAndArtist[0];
64
                String artistStr = taxonNameAndArtist[1];
65

  
66

  
67
                if(false){
68
                    continue;
69
                }
70
                Taxon taxon = getAcceptedTaxon(taxonNameStr);
71
                TaxonDescription imageGallery = taxon.getImageGallery(true);
72
                TextData textData = TextData.NewInstance();
73

  
74
                URI uri = URI.create(fullFolderUrl + fileStr);
75

  
76
                //image metadata
77
                File imageFile = new File("");
78
                IImageMetadata metadata;
79
                try {
80
                    metadata = Sanselan.getMetadata(uri.toURL().openStream(), null);
81
                    ArrayList<?> items = metadata.getItems();
82
                    for (Object object : items){
83
                        Item item = (Item) object;
84
                        System.out.println(item.getKeyword() +  ":    " + item.getText());
85
                        String value = removeQuots(item.getText());
86
                        if("Image Description".equalsIgnoreCase(item.getKeyword())){
87
//                          media.putDescription(Language.DEFAULT(), item.getText());
88
                        }else if ("date time original".equalsIgnoreCase(item.getKeyword())){
89
                            DateTimeFormatter f = DateTimeFormat.forPattern("yyyy:MM:dd HH:mm:ss");
90
                            DateTime created = f.withZone(DateTimeZone.forID("Europe/Athens")).parseDateTime(value);
91
                            System.out.println(created);
92

  
93
                        }
94
                    }
95
                } catch (ImageReadException | IOException e1) {
96
                    // TODO Auto-generated catch block
97
                    e1.printStackTrace();
98
                }
99

  
100

  
101

  
102

  
103
                ImageInfo imageMetaData;
104
                try {
105
                    imageMetaData = ImageInfo.NewInstance(uri, 0);
106

  
107
                    String mimeType = imageMetaData.getMimeType();
108
                    String suffix = null;
109
                    int height = imageMetaData.getHeight();
110
                    int width = imageMetaData.getWidth();
111
                    Integer size = null;
112
                    DateTime mediaCreated = null;
113
                    AgentBase<?> artist = null;
114
                    Media media = ImageFile.NewMediaInstance(mediaCreated, artist, uri, mimeType, suffix, size, height, width);
115

  
116
                    textData.addMedia(media);
117
                    imageGallery.addElement(textData);
118
                } catch (IOException | HttpException e) {
119
                    // TODO Auto-generated catch block
120
                    e.printStackTrace();
121
                }
122
            }
123

  
124
        }
125
    }
126

  
127
    /**
128
     * @param text
129
     * @return
130
     */
131
    private String removeQuots(String text) {
132
        if (text.startsWith("'") && text.endsWith("'")){
133
            return text.substring(1, text.length() -1);
134
        }else{
135
            return text;
136
        }
137
    }
138

  
139
    /**
140
     * @param taxonNameStr
141
     * @return
142
     */
143
    private Taxon getAcceptedTaxon(String taxonNameStr) {
144
        return Taxon.NewInstance(null, null);
145
    }
146

  
147
    /**
148
     * @param fileStr
149
     * @return
150
     */
151
    private String[] getTaxonName(String fileStr) {
152
        String[] result = new String[2];
153
        fileStr = fileStr.split("\\.")[0];
154
        fileStr = fileStr.replaceAll("[0-9]", "");
155
        String[] x = fileStr.split("_");
156
        if (x.length == 2){
157
            result[1] = x[1];
158
        }
159

  
160
        fileStr = splitCamelCase(x[0]);
161
        String[] split = fileStr.split(" ");
162
        String name = split[0] + " " + split[1].toLowerCase() +
163
                (split.length > 2 ? " subsp. " + split[2].toLowerCase() : "");
164
        result[0] = name;
165
        System.out.println(result[0] + (result[1] != null ?  "   Artist: " + result[1]: ""));
166
        return result;
167
    }
168

  
169
    //from http://stackoverflow.com/questions/2559759/how-do-i-convert-camelcase-into-human-readable-names-in-java
170
    static String splitCamelCase(String s) {
171
        return s.replaceAll(
172
           String.format("%s",
173
//              "(?<=[A-Z])(?=[A-Z][a-z])",
174
              "(?<=[^A-Z])(?=[A-Z])"
175
//              "(?<=[A-Za-z])(?=[^A-Za-z])"
176
           ),
177
           " "
178
        );
179
     }
180

  
181
    public static void main(String[] str){
182
        ImageImportTest test = new ImageImportTest();
183
        test.doInvoke();
184
    }
185
}

Also available in: Unified diff