Project

General

Profile

« Previous | Next » 

Revision c385a1b7

Added by Andreas Müller almost 6 years ago

latest changes to BgbmInstancesUpdater, E+M Import, GermanSL Import, etct

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/app/berlinModelImport/EuroMedActivator.java
77 77
	private static final Logger logger = Logger.getLogger(EuroMedActivator.class);
78 78

  
79 79
	//database validation status (create, update, validate ...)
80
	static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
80
	static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
81 81
//    static final Source berlinModelSource = BerlinModelSources.euroMed_Pub2();
82 82
	static final Source berlinModelSource = BerlinModelSources.euroMed_BGBM42();
83 83
//	static final Source berlinModelSource = BerlinModelSources.euroMed_PESI3();
84

  
85
//    static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
84
//
85
  static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
86 86
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_euroMed();
87
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_pesi_euromed();
88 87

  
89
	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_test_euromed();
90
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
88
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_euromed();
91 89

  
92 90

  
91
    //check - import
92
    static final CHECK check = CHECK.CHECK_ONLY;
93

  
93 94
	static final boolean includePesiExport = false;
94 95

  
95 96
	static final int sourceSecId = 7000000; //500000
96 97
	static final UUID classificationUuid = UUID.fromString("314a68f9-8449-495a-91c2-92fde8bcf344");
97 98
	static final boolean useSingleClassification = true;
98
	static final String classificationName = "Euro+Med 2017";
99
	static final String classificationName = "Euro+Med 2018";
99 100
	static final UUID featureTreeUuid = UUID.fromString("6a5e1c2b-ec0d-46c8-9c7d-a2059267ffb7");
100 101
	static final Object[] featureKeyList = new Integer[]{1, 31, 4, 98, 41};
101 102

  
......
104 105

  
105 106
	static final int partitionSize = 2500;
106 107

  
107
	//check - import
108
	static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
109 108

  
110 109
	//editor - import
111 110
	static final EDITOR editor = EDITOR.EDITOR_AS_EDITOR;
......
144 143
	static String occurrenceSourceFilter = " occurrenceFk IN ( SELECT occurrenceId FROM v_cdm_exp_occurrenceAll )";
145 144
	static String commonNameFilter = " commonNameId IN ( SELECT commonNameId FROM v_cdm_exp_commonNamesAll )";
146 145
	static String webMarkerFilter = " TableNameFk <> 500 OR ( RIdentifierFk IN (SELECT RIdentifier FROM v_cdm_exp_taxaAll)) ";
147
	static String authorTeamFilter = null; // " authorTeamId IN (SELECT authorTeamId FROM v_cdm_exp_authorTeamsAll) ";
148
	static String authorFilter = null;  // " authorId IN (SELECT authorId FROM v_cdm_exp_authorsAll) ";
146
	static String authorTeamFilter = /* null;  //*/ " authorTeamId IN (SELECT authorTeamId FROM v_cdm_exp_authorTeamsAll) ";
147
	static String authorFilter = /* null;  //*/ " authorId IN (SELECT authorId FROM v_cdm_exp_authorsAll) ";
149 148

  
150 149

  
151 150

  
......
162 161
	static final boolean doTaxonNames = true;
163 162
	static final boolean doRelNames = true;
164 163
	static final boolean doNameStatus = true;
165
	static final boolean doTypes = false;  //serious types do not exist in E+M
164
	static final boolean doTypes = false;  //serious types do not exist in E+M except for name types which are handled in name relations
166 165
	static final boolean doNameFacts = true;
167 166

  
168 167
	//taxa
169 168
	static final boolean doTaxa = true;
170 169
	static final boolean doFacts = true;
171
	static final boolean doCommonNames = true;
170
	static final boolean doCommonNames = false;
172 171
	static final boolean doOccurences = true;
173
	static final boolean doRelTaxa = false;
172
	static final boolean doRelTaxa = true;
174 173
	static final boolean doRunTransmissionEngine = (hbm2dll == DbSchemaValidation.VALIDATE);
175 174

  
176 175
	//etc.
177
	static final boolean doMarker = true;
176
	static final boolean doMarker = false;
178 177

  
179 178

  
180 179
	public void importEm2CDM (Source source, ICdmDataSource destination, DbSchemaValidation hbm2dll){
......
206 205
		config.setDoMarker(doMarker ^ invers);
207 206
		config.setDoUser(doUser ^ invers);
208 207

  
208
		config.setEuroMed(true);
209

  
209 210
		config.setUseClassification(useClassification);
210 211
		config.setSourceRefUuid(BerlinModelTransformer.uuidSourceRefEuroMed);
211 212
		config.setEditor(editor);
app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmDestinations.java
121 121
        return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
122 122
    }
123 123

  
124
	public static ICdmDataSource cdm_local_test_euromed(){
124
	public static ICdmDataSource cdm_local_euromed(){
125 125
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
126 126
		String cdmServer = "127.0.0.1";
127 127
		String cdmDB = "euroMed";
......
133 133
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
134 134
		String cdmServer = "127.0.0.1";
135 135
		String cdmDB = "euroMed2";
136
		String cdmUserName = "root";
136
		String cdmUserName = "edit";
137 137
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
138 138
	}
139 139
	public static ICdmDataSource cdm_local_test_euromed3(){
app-import/src/main/java/eu/etaxonomy/cdm/app/common/TestActivator.java
39 39
	@SuppressWarnings("unused")
40 40
	private static final Logger logger = Logger.getLogger(TestActivator.class);
41 41

  
42
	//static final Source faunaEuropaeaSource = FaunaEuropaeaSources.faunEu();
43 42
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();
44
	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
45
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_production();
43
//	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
44
	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_test1();
46 45
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_edit_cichorieae_preview();
47
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cyprus_production();
46

  
48 47

  
49 48

  
50 49
	static final int limitSave = 2000;
51 50

  
52 51
	static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
53
//	static final CHECK check = CHECK.CHECK_ONLY;
54
//	static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.NONE;
55
//	static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.UPDATE;
56
	static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;
52
	static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.CREATE;
57 53
	static final NomenclaturalCode nomenclaturalCode  = NomenclaturalCode.ICNAFP;
58 54

  
59 55

  
......
62 58
	 * @param args
63 59
	 */
64 60
	public static void main(String[] args) {
61
	    new TestActivator().invoke();
62
	    System.exit(0);
63
	}
65 64

  
66
		ICdmDataSource destination = cdmDestination;
67

  
68
		CdmApplicationController app;
69

  
70
//		applicationEventMulticaster
71
//		app = CdmIoApplicationController.NewInstance(destination, dbSchemaValidation);
72

  
73
		IProgressMonitor progressMonitor = DefaultProgressMonitor.NewInstance();
74
		String resourcePath= "/eu/etaxonomy/cdm/appimportTestApplicationContext.xml";
75
		ClassPathResource resource = new ClassPathResource(resourcePath);
76
//		ApplicationListener<?> listener = new AppImportApplicationListener();
77
//		List<ApplicationListener> listeners = new ArrayList<ApplicationListener>();
78
//		listeners.add(listener);
79
//		app = CdmApplicationController.NewInstance(resource, destination, dbSchemaValidation, false, progressMonitor, listeners);
80
		app = CdmApplicationController.NewInstance(resource, destination, dbSchemaValidation, false, progressMonitor);
65
	private void invoke(){
66
       ICdmDataSource destination = cdmDestination;
81 67

  
68
        CdmApplicationController app;
82 69

  
70
//	      applicationEventMulticaster
71
//	      app = CdmIoApplicationController.NewInstance(destination, dbSchemaValidation);
83 72

  
84
		if (true){
85
			return;
86
		}
73
        IProgressMonitor progressMonitor = DefaultProgressMonitor.NewInstance();
74
        String resourcePath= "/eu/etaxonomy/cdm/appimportTestApplicationContext.xml";
75
        ClassPathResource resource = new ClassPathResource(resourcePath);
76
//	      ApplicationListener<?> listener = new AppImportApplicationListener();
77
//	      List<ApplicationListener> listeners = new ArrayList<>();
78
//	      listeners.add(listener);
79
//	      app = CdmApplicationController.NewInstance(resource, destination, dbSchemaValidation, false, progressMonitor, listeners);
80
//	        app = CdmApplicationController.NewInstance(resource, destination, dbSchemaValidation, false, progressMonitor);
81
	        app = CdmApplicationController.NewInstance(destination, dbSchemaValidation, false);
87 82

  
88
		TransactionStatus tx = app.startTransaction();
83
	        if (true){
84
	            return;
85
	        }
89 86

  
90
		State state = (State)app.getTermService().find(UUID.fromString("881b9c80-626d-47a6-b308-a63ee5f4178f"));
91
		DefinedTerm modifier = (DefinedTerm)app.getTermService().find(UUID.fromString("efc38dad-205c-4028-ad9d-ae509a14b37a"));
92
		CategoricalData cd = CategoricalData.NewInstance();
93
		StateData stateData = StateData.NewInstance();
94
		stateData.setState(state);
95
		stateData.addModifier(modifier);
87
	        TransactionStatus tx = app.startTransaction();
96 88

  
97
		StateData stateData2 = StateData.NewInstance();
98
		stateData2.setState(state);
99
		stateData2.addModifier(modifier);
89
	        State state = (State)app.getTermService().find(UUID.fromString("881b9c80-626d-47a6-b308-a63ee5f4178f"));
90
	        DefinedTerm modifier = (DefinedTerm)app.getTermService().find(UUID.fromString("efc38dad-205c-4028-ad9d-ae509a14b37a"));
91
	        CategoricalData cd = CategoricalData.NewInstance();
92
	        StateData stateData = StateData.NewInstance();
93
	        stateData.setState(state);
94
	        stateData.addModifier(modifier);
100 95

  
101
		cd.addStateData(stateData2);
96
	        StateData stateData2 = StateData.NewInstance();
97
	        stateData2.setState(state);
98
	        stateData2.addModifier(modifier);
102 99

  
103
		app.getDescriptionService().saveDescriptionElement(cd);
104
		System.out.println("Saved");
100
	        cd.addStateData(stateData2);
105 101

  
106
		app.commitTransaction(tx);
102
	        app.getDescriptionService().saveDescriptionElement(cd);
103
	        System.out.println("Saved");
107 104

  
108
		URI	uri = URI.create("file:///C:/localCopy/Data/xper/Cichorieae-DA2.sdd.xml");
109
		SDDImportConfigurator configurator = SDDImportConfigurator.NewInstance(uri, destination);
110
		CdmDefaultImport<SDDImportConfigurator> myImport = new CdmDefaultImport<>();
105
	        app.commitTransaction(tx);
111 106

  
112
		myImport.setCdmAppController(app);
107
	        URI uri = URI.create("file:///C:/localCopy/Data/xper/Cichorieae-DA2.sdd.xml");
108
	        SDDImportConfigurator configurator = SDDImportConfigurator.NewInstance(uri, destination);
109
	        CdmDefaultImport<SDDImportConfigurator> myImport = new CdmDefaultImport<>();
113 110

  
114
		ImportResult result = myImport.invoke(configurator);
115
		System.out.println(result.toString());
111
	        myImport.setCdmAppController(app);
116 112

  
117
		if (true){
118
			return;
119
		}
113
	        ImportResult result = myImport.invoke(configurator);
114
	        System.out.println(result.toString());
120 115

  
116
	        if (true){
117
	            return;
118
	        }
121 119

  
122 120

  
123 121
	}
124 122

  
125 123

  
126

  
127 124
}
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;
......
57 34

  
58 35
/**
59 36
 * @author a.oppermann
60
 * @created 16.07.2013
37
 * @since 16.07.2013
61 38
 */
62 39
public class BfnXmlImportActivator {
63 40

  
......
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/database/update/BgbmInstancesUpdater.java
34 34
	};
35 35

  
36 36
	private static String[] testDatabases = new String[]{
37
	    "cdm_col",
37
//	    "cdm_col",
38 38
	    "cdm_Test_Caryophyllales",
39 39
	    "cdm_additivity_test",
40 40
        "cdm_bgbm_edit_usergroup",
41 41
	    "cdm_campanulaceae","cdm_caryo_nepenthes",
42
		"cdm_corvidae", "cdm_cyprus","cdm_edaphobase_test",
43
		"cdm_edit_algaterra", "cdm_edit_cichorieae",
42
	    "cdm_caryo_spp","cdm_causcasus_workshop",
43
        "cdm_corvidae", "cdm_cyprus","cdm_edaphobase_test",
44
		"cdm_edit_algaterra", "cdm_edit_algaterranew","cdm_edit_cichorieae",
44 45
		"cdm_edit_flora_central_africa", "cdm_edit_flora_malesiana",
45 46
		"cdm_edit_globis", "cdm_edit_palmae",
46 47
		"cdm_flora_cuba", "cdm_flora_guianas",
......
53 54
		"cdm_proibiosphere_chenopodium_pilot",
54 55
		"cdm_rem_conf_ak", "cdm_rem_conf_am", "cdm_rem_conf_kl", "cdm_rem_conf_pp",
55 56
		"cdm_rl_animalia","cdm_rl_german_sl","cdm_rl_mammalia", "cdm_rl_plantae",
56
		"cdm_salvador",
57
		"cdm_salvador","cdm_test1","cdm_test2",
57 58
        "cdm_test_euromed",
58 59
        "cdm_vibrant_index"
59 60
		};
......
70 71
		"cdm_production_campanulaceae",
71 72
		"cdm_production_caryo_amaranthaceae",
72 73
		"cdm_production_caryo_nepenthaceae",
73
		"cdm_production_caryo_nyctaginaceae",
74 74
        "cdm_production_caryophyllales",
75 75
        "cdm_production_caryophyllales_spp",
76 76
        "cdm_production_cichorieae",
77
		"cdm_production_corvidae","cdm_production_cyprus",
77
		"cdm_production_corvidae",
78
	    "cdm_production_cyprus",
78 79
		"cdm_production_diptera",
79 80
		"cdm_production_edaphobase",
80 81
        "cdm_production_euromed",
......
88 89
        "cdm_production_flora_malesiana_prospective",
89 90
		"cdm_production_flore_gabon",
90 91
		"cdm_production_globis",
92
		"cdm_production_myristicaceae",
91 93
		"cdm_production_palmae",
92 94
		"cdm_production_phycobank",
93 95
		"cdm_production_piB_ants_pilot",
......
98 100
		"cdm_production_piB_nephrolepis_pilot",
99 101
		"cdm_production_piB_spiders_pilot",
100 102
		"cdm_production_rl_animalia",
103
        "cdm_production_rl_animalia_final",
101 104
		"cdm_production_rl_armeria_demo",
102
        "cdm_production_rl_fungi",
103 105
		"cdm_production_rl_german_sl",
104 106
        "cdm_production_rl_lumbricidae",
105 107
        "cdm_production_rl_mammalia",
......
109 111
        "cdm_production_rubiaceae_mexico",
110 112
        "cdm_production_salvador",
111 113
		"cdm_production_vibrant_index"
112
	    };
114
	};
113 115

  
114 116

  
115 117
	static BgbmServer bgbmServer = BgbmServer.TEST;
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelCommonNamesImport.java
86 86
		if (isNotBlank(state.getConfig().getCommonNameFilter())){
87 87
			result += " AND " + state.getConfig().getCommonNameFilter();
88 88
		}
89
		result += " ORDER BY CommonNameId ";
89 90

  
90 91
		return result;
91 92
	}
......
94 95
	protected String getRecordQuery(BerlinModelImportConfigurator config) {
95 96
		String recordQuery = "";
96 97
		recordQuery =
97
				" SELECT     cn.CommonNameId, cn.CommonName, PTaxon.RIdentifier AS taxonId, cn.PTNameFk, cn.RefFk AS refId, cn.Status, cn.RegionFks, cn.MisNameRefFk, " +
98
					       "               cn.NameInSourceFk, cn.Created_When, cn.Updated_When, cn.Created_Who, cn.Updated_Who, cn.Note AS Notes, languageCommonName.Language, " +
99
					       "               languageCommonName.LanguageOriginal, languageCommonName.ISO639_1, languageCommonName.ISO639_2,   " +
100
					       "               emLanguageReference.RefFk AS languageRefRefFk, emLanguageReference.ReferenceShort, emLanguageReference.ReferenceLong,  " +
101
					       "               emLanguageReference.LanguageFk, languageReferenceLanguage.Language AS refLanguage, languageReferenceLanguage.ISO639_2 AS refLanguageIso639_2,  "+
102
					       "               misappliedTaxon.RIdentifier AS misappliedTaxonId " +
103
					" FROM         PTaxon AS misappliedTaxon RIGHT OUTER JOIN " +
104
					    "                  emLanguage AS languageReferenceLanguage RIGHT OUTER JOIN " +
105
					               "       emLanguageReference ON languageReferenceLanguage.LanguageId = emLanguageReference.LanguageFk RIGHT OUTER JOIN " +
106
					               "       emCommonName AS cn INNER JOIN " +
107
					               "       PTaxon ON cn.PTNameFk = PTaxon.PTNameFk AND cn.PTRefFk = PTaxon.PTRefFk ON  " +
108
					               "       emLanguageReference.ReferenceId = cn.LanguageRefFk LEFT OUTER JOIN " +
109
					                "      emLanguage AS languageCommonName ON cn.LanguageFk = languageCommonName.LanguageId ON misappliedTaxon.PTNameFk = cn.NameInSourceFk AND  " +
110
					                "      misappliedTaxon.PTRefFk = cn.MisNameRefFk " +
111
			" WHERE cn.CommonNameId IN (" + ID_LIST_TOKEN + ")";
98
				" SELECT rel.RelPTaxonId, rel.RelQualifierFk, acc.RIdentifier accTaxonId, factTaxon.RIdentifier factTaxonId, accName.NameId, f.FactId, " +
99
				           "       cn.CommonNameId, cn.CommonName, tax.RIdentifier AS taxonId, cn.PTNameFk, cn.RefFk AS refId, cn.Status, cn.RegionFks, cn.MisNameRefFk, " +
100
					       "       cn.NameInSourceFk, cn.Created_When, cn.Updated_When, cn.Created_Who, cn.Updated_Who, cn.Note AS Notes, languageCommonName.Language, " +
101
					       "       languageCommonName.LanguageOriginal, languageCommonName.ISO639_1, languageCommonName.ISO639_2,   " +
102
					       "       emLanguageReference.RefFk AS languageRefRefFk, emLanguageReference.ReferenceShort, emLanguageReference.ReferenceLong,  " +
103
					       "       emLanguageReference.LanguageFk, languageReferenceLanguage.Language AS refLanguage, languageReferenceLanguage.ISO639_2 AS refLanguageIso639_2,  "+
104
					       "       misappliedTaxon.RIdentifier AS misappliedTaxonId " +
105
				  " FROM  PTaxon AS misappliedTaxon RIGHT OUTER JOIN " +
106
					       "      emLanguage AS languageReferenceLanguage RIGHT OUTER JOIN " +
107
			               "      emLanguageReference ON languageReferenceLanguage.LanguageId = emLanguageReference.LanguageFk RIGHT OUTER JOIN " +
108
			               "      emCommonName AS cn INNER JOIN " +
109
			               "      PTaxon AS tax ON cn.PTNameFk = tax.PTNameFk AND cn.PTRefFk = tax.PTRefFk ON  " +
110
			               "      emLanguageReference.ReferenceId = cn.LanguageRefFk LEFT OUTER JOIN " +
111
			               "      emLanguage AS languageCommonName ON cn.LanguageFk = languageCommonName.LanguageId ON misappliedTaxon.PTNameFk = cn.NameInSourceFk AND  " +
112
			               "      misappliedTaxon.PTRefFk = cn.MisNameRefFk " +
113

  
114
	                     "     LEFT OUTER JOIN Fact f ON cn.CommonNameId = f.ExtensionFk " +
115
	                     "     LEFT OUTER JOIN PTaxon factTaxon ON factTaxon.PTNameFk = f.PTNameFk AND factTaxon.PTRefFk = f.PTRefFk " +
116
	                     "     LEFT OUTER JOIN RelPTaxon rel ON rel.PTNameFk1 = tax.PTNameFk AND rel.PTRefFk1 = tax.PTRefFk AND rel.RelQualifierFk IN (2,6,7) " +
117
                         "     LEFT OUTER JOIN PTaxon acc ON rel.PTNameFk2 = acc.PTNameFk AND rel.PTRefFk2 = acc.PTRefFk " +
118
                         "     LEFT OUTER JOIN Name accName ON accName.NameId = acc.PTNameFk " +
119
			        " WHERE cn.CommonNameId IN (" + ID_LIST_TOKEN + ") " +
120
			        " ORDER BY cn.CommonNameId ";
121

  
112 122
		return recordQuery;
113 123
	}
114 124

  
......
174 184
	//	logger.warn("MisappliedNameRefFk  not yet implemented for Common Names");
175 185

  
176 186
		ResultSet rs = partitioner.getResultSet();
187
		Integer lastCommonNameId = null;
177 188
		try{
178 189
			while (rs.next()){
179 190

  
180 191
				//create TaxonName element
181 192
				Integer commonNameId = rs.getInt("CommonNameId");
182 193
				int taxonId = rs.getInt("taxonId");
194
				Integer factTaxonId = nullSafeInt(rs, "factTaxonId");
195
				Integer accTaxonId = nullSafeInt(rs, "accTaxonId");  //if common name is related to synonym this is the accepted taxon id
196

  
183 197
				Integer refId = nullSafeInt(rs, "refId");
184 198
//				Integer ptNameFk = nullSafeInt(rs,"PTNameFk");
185 199
				String commonNameString = rs.getString("CommonName");
......
195 209
				Integer nameInSourceFk = nullSafeInt( rs, "NameInSourceFk");
196 210
				Integer misappliedTaxonId = nullSafeInt( rs, "misappliedTaxonId");
197 211

  
212
				if (commonNameId == lastCommonNameId){
213
				    logger.warn("CommonNameId >1 times in query. This may happen due to LEFT JOINS to fact and/or accepted taxon and e.g. multiple taxon relationships. 2018-04-01 no such double relation existed in E+M. ");
214
				}else{
215
				    lastCommonNameId = commonNameId;
216
				}
217

  
198 218
				//regions
199 219
				String regionFks  = rs.getString("RegionFks");
200
				String[] regionFkSplit = regionFks.split(",");
220
				String[] regionFkSplit = (regionFks==null)? new String[0] : regionFks.split(",");
201 221

  
202 222
				//commonNameString
203 223
				if (isBlank(commonNameString)){
......
212 232
				if (taxonBase == null){
213 233
					logger.warn("Taxon (" + taxonId + ") could not be found. Common name " + commonNameString + "(" + commonNameId + ") not imported");
214 234
					continue;
215
				}else if (! taxonBase.isInstanceOf(Taxon.class)){
216
					logger.warn("taxon (" + taxonId + ") is not accepted. Can't import common name " +  commonNameId);
217
					continue;
235
				}else if (taxonBase.isInstanceOf(Taxon.class)){
236
				    taxon = CdmBase.deproxy(taxonBase, Taxon.class);
237
				    if (factTaxonId != null && !factTaxonId.equals(taxonId)){
238
				        logger.warn("Fact taxon ("+factTaxonId+") for common name "+commonNameId+" differs from common name taxon " + taxonId);
239
				    }
218 240
				}else{
219
					taxon = CdmBase.deproxy(taxonBase, Taxon.class);
241
				    Taxon factTaxon = null;
242
				    if (factTaxonId != null && factTaxonId.equals(accTaxonId)){
243
				        factTaxon = taxonMap.get(String.valueOf(factTaxonId));
244
				    }
245
				    if (factTaxon != null){
246
				        taxon = factTaxon;
247
				    }else{
248
				        logger.warn("taxon (" + taxonId + ") is not accepted. Can't import common name " +  commonNameId + ". FactTaxonId= " +  factTaxonId + "; accTaxonId = " + accTaxonId);
249
				        continue;
250
				    }
220 251
				}
221 252

  
222 253
				//Language
......
253 284
					if (languageRefRefFk == null){
254 285
						languageRefRefFk = refId;
255 286
					}else{
256
						logger.warn("CommonName.RefFk (" + CdmUtils.Nz(refId) + ") and LanguageReference.RefFk " + (languageRefRefFk==null? "null" : languageRefRefFk)  + " are not equal. I will import only languageReference.RefFk");
287
						logger.warn("CommonName.RefFk (" + CdmUtils.Nz(refId) + ") and LanguageReference.RefFk " + languageRefRefFk  + " are not equal. I will import only languageReference.RefFk");
257 288
					}
258 289
				}
259 290

  
......
268 299
				if (nameInSourceFk != null && nameUsedInSource == null){
269 300
					logger.warn("Name used in source (" + nameInSourceFk + ") was not found for common name " + commonNameId);
270 301
				}
271
				DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(reference, microCitation, nameUsedInSource, originalNameString);
272 302
				for (CommonTaxonName commonTaxonName : commonTaxonNames){
273
					commonTaxonName.addSource(source);
303
				    DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(reference, microCitation, nameUsedInSource, originalNameString);
304
	                commonTaxonName.addSource(source);
274 305
				}
275 306

  
276 307

  
......
315 346
							misappliedNameDescription.addElement(commonNameClone);
316 347
						}
317 348
					}else{
318
						logger.warn("Misapplied name is null for common name " + commonNameId);
349
						//wird schon oben gelogged
350
					    //logger.warn("Misapplied name is null for common name " + commonNameId);
319 351
					}
320 352

  
321 353
				}
......
358 390
			return false;
359 391
		} catch (ClassCastException e) {
360 392
			e.printStackTrace();
361
		}
393
		} catch (Exception e) {
394
            throw e;
395
        }
362 396

  
363 397
		//	logger.info( i + " names handled");
364 398
		getTaxonService().save(taxaToSave);
......
507 541
				NamedArea newArea = getNamedArea(state, null, region, "Language region '" + region + "'", null, null, null);
508 542
//				getTermService().save(newArea);
509 543
				regionMap.put(String.valueOf(regionId), newArea);
510
				logger.warn("Found new area: " +  region);
544
				logger.info("Found new area: " +  region);
511 545
			}else if (splitRegion.length == 2){
512 546
				String emCode = splitRegion[1].trim();
513 547
				String tdwgCode = emTdwgMap.get(emCode);
......
547 581
			area = Country.RUSSIANFEDERATION();
548 582
		}else if (tdwgCode.equalsIgnoreCase("Gg")){
549 583
			area = Country.GEORGIA();
550
		}else{
584
		}else if (tdwgCode.equalsIgnoreCase("SM")){
585
            area = getNamedArea(state, BerlinModelTransformer.uuidSM , "Serbia & Montenegro", "Serbia & Montenegro", "SM", null, null);
586
            getTermService().saveOrUpdate(area);
587
        }else if (tdwgCode.equalsIgnoreCase("Tu")){
588
            area = Country.TURKEYREPUBLICOF();
589
        }else{
551 590
			area = TdwgAreaProvider.getAreaByTdwgAbbreviation(tdwgCode);
552 591
		}
553 592
		if (area == null){
......
588 627
			if (isNotBlank(emCode) ){
589 628
				emCode = emCode.trim();
590 629
				if (emCode.equalsIgnoreCase("Ab") || emCode.equalsIgnoreCase("Rf")||
591
						emCode.equalsIgnoreCase("Uk") || emCode.equalsIgnoreCase("Gg")){
630
						emCode.equalsIgnoreCase("Uk") || emCode.equalsIgnoreCase("Gg")
631
						|| emCode.equalsIgnoreCase("SM") || emCode.equalsIgnoreCase("Tu")){
592 632
					emTdwgMap.put(emCode, emCode);
593 633
				}else if (isNotBlank(TDWGCode)){
594 634
					emTdwgMap.put(emCode, TDWGCode.trim());
......
601 641
		emTdwgMap.put("Uk / Uk(U)", "Uk");
602 642
		emTdwgMap.put("Ar / Ar(A)", "TCS-AR");
603 643
		emTdwgMap.put("Hs / Hs(S)", "SPA-SP");
644
		emTdwgMap.put("Hb / Hb(E)", "IRE-IR");
604 645

  
605 646
		return emTdwgMap;
606 647
	}
......
638 679
			Set<String> referenceIdSet = new HashSet<>();
639 680
			while (rs.next()){
640 681
				handleForeignKey(rs, taxonIdSet, "taxonId");
641
				handleForeignKey(rs, taxonIdSet, "misappliedTaxonId");
682
				handleForeignKey(rs, taxonIdSet, "factTaxonId");
683
                handleForeignKey(rs, taxonIdSet, "misappliedTaxonId");
642 684
				handleForeignKey(rs, referenceIdSet, "refId");
643 685
				handleForeignKey(rs, referenceIdSet, "languageRefRefFk");
644 686
				handleForeignKey(rs, nameIdSet, "NameInSourceFk");
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelImportBase.java
34 34
import eu.etaxonomy.cdm.model.location.Country;
35 35
import eu.etaxonomy.cdm.model.location.NamedArea;
36 36
import eu.etaxonomy.cdm.model.location.NamedAreaType;
37
import eu.etaxonomy.cdm.model.name.Rank;
38
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
39 37
import eu.etaxonomy.cdm.model.reference.Reference;
40 38
import eu.etaxonomy.cdm.model.taxon.Taxon;
41 39
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
......
44 42
 * @author a.mueller
45 43
 * @since 20.03.2008
46 44
 */
47
public abstract class BerlinModelImportBase extends DbImportBase<BerlinModelImportState, BerlinModelImportConfigurator>  implements ICdmIO<BerlinModelImportState>, IPartitionedIO<BerlinModelImportState> {
45
public abstract class BerlinModelImportBase
46
            extends DbImportBase<BerlinModelImportState, BerlinModelImportConfigurator>
47
            implements ICdmIO<BerlinModelImportState>, IPartitionedIO<BerlinModelImportState> {
48 48
    private static final long serialVersionUID = -4982506434258587864L;
49 49
    private static final Logger logger = Logger.getLogger(BerlinModelImportBase.class);
50 50

  
......
192 192
		TaxonBase<?> taxonBase = taxonMap.get(String.valueOf(taxonId));
193 193

  
194 194
		//TODO for testing
195
		if (taxonBase == null && ! state.getConfig().isDoTaxa()){
196
			taxonBase = Taxon.NewInstance(TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES()), null);
197
		}
195
//		if (taxonBase == null && ! state.getConfig().isDoTaxa()){
196
//			taxonBase = Taxon.NewInstance(TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES()), null);
197
//		}
198 198

  
199 199
		Taxon taxon;
200 200
		if ( taxonBase instanceof Taxon ) {
......
376 376
			return getNamedArea(state, BerlinModelTransformer.uuidTerceira, "Menorca", "Euro+Med area 'Menorca'", "Bl(N)", null, null);
377 377
		}
378 378

  
379
		logger.warn("Area(em: '" + em + "', tdwg: '" + tdwg +"') could not be found for occurrence import");
379
		logger.warn("Area(em: '" + em + "', tdwg: '" + tdwg +"') could not be found");
380 380

  
381 381
		return null;
382 382
	}
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelImportConfigurator.java
57 57
	private boolean doTypes = true;
58 58

  
59 59
	private boolean isSalvador = false;
60
	private boolean isEuroMed = false;
60 61

  
61 62
	//taxa
62 63
	private boolean doTaxa = true;
......
641 642
    public boolean isSalvador() {return isSalvador;}
642 643
    public void setSalvador(boolean isSalvador) {this.isSalvador = isSalvador;}
643 644

  
645
    public boolean isEuroMed() {return isEuroMed;}
646
    public void setEuroMed(boolean isEuroMed) {this.isEuroMed = isEuroMed;}
647

  
644 648
    public UUID getFeatureTreeUuid() {
645 649
        return featureTreeUuid;
646 650
    }
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelOccurrenceSourceImport.java
238 238
			if (names.size() == 1){
239 239
				return names.get(0);
240 240
			}else {
241
				if (names.size()> 2){
241
				if (names.size()> 1){
242 242
					logger.info("There is more than one name matching oldName: " + oldName + ".");
243 243
				}
244
				return null;
244
				return names.get(0);
245 245
				//taxonName = nameParser.parseSimpleName(oldName);
246 246
			}
247 247
		}
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonImport.java
104 104
	protected String getRecordQuery(BerlinModelImportConfigurator config) {
105 105
		String sqlSelect = " SELECT pt.*  ";
106 106
		String sqlFrom = " FROM PTaxon pt ";
107
		if (isEuroMed(config) ){
107
		if (config.isEuroMed()){
108 108
			sqlFrom = " FROM PTaxon AS pt " +
109 109
							" INNER JOIN v_cdm_exp_taxaAll AS em ON pt.RIdentifier = em.RIdentifier " +
110 110
							" LEFT OUTER JOIN Reference r ON pt.LastScrutinyFk = r.RefId ";
......
121 121
		return strRecordQuery;
122 122
	}
123 123

  
124
	private boolean isEuroMed(BerlinModelImportConfigurator config) {
125
		return config.getTaxonTable().trim().equals("v_cdm_exp_taxaAll");
126
	}
127

  
128 124
	@Override
129 125
	protected boolean doCheck(BerlinModelImportState state){
130 126
		IOValidator<BerlinModelImportState> validator = new BerlinModelTaxonImportValidator();
......
143 139
		ResultSet rs = partitioner.getResultSet();
144 140
		try{
145 141
			boolean publishFlagExists = state.getConfig().getSource().checkColumnExists("PTaxon", "PublishFlag");
146
			boolean isEuroMed = isEuroMed(state.getConfig());
142
			boolean isEuroMed = config.isEuroMed();
147 143
			while (rs.next()){
148 144

  
149 145
			//	if ((i++ % modCount) == 0 && i!= 1 ){ logger.info("PTaxa handled: " + (i-1));}
......
183 179
				Taxon taxon;
184 180
				try {
185 181
					logger.debug(statusFk);
186
					if (statusFk == T_STATUS_ACCEPTED || statusFk == T_STATUS_UNRESOLVED ){
182
					if (statusFk == T_STATUS_ACCEPTED || statusFk == T_STATUS_UNRESOLVED
183
					        || statusFk == T_STATUS_PRO_PARTE_SYN || statusFk == T_STATUS_PARTIAL_SYN ){
187 184
						taxon = Taxon.NewInstance(taxonName, reference);
188 185
						taxonBase = taxon;
189 186
						if (statusFk == T_STATUS_UNRESOLVED){
190 187
							taxon.setTaxonStatusUnknown(true);
191 188
						}
192
					}else if (statusFk == T_STATUS_SYNONYM || statusFk == T_STATUS_PRO_PARTE_SYN || statusFk == T_STATUS_PARTIAL_SYN){
189
						//TODO marker for pp and partial?
190
					}else if (statusFk == T_STATUS_SYNONYM ){
193 191
						synonym = Synonym.NewInstance(taxonName, reference);
194 192
						taxonBase = synonym;
195
						if (statusFk == T_STATUS_PRO_PARTE_SYN){
196
						    synonym.setProParte(true);
197
						}
198
						if (statusFk == T_STATUS_PARTIAL_SYN){
199
							synonym.setPartial(true);
200
						}
193
//						if (statusFk == T_STATUS_PRO_PARTE_SYN){
194
//						    synonym.setProParte(true);
195
//						}
196
//						if (statusFk == T_STATUS_PARTIAL_SYN){
197
//							synonym.setPartial(true);
198
//						}
201 199
					}else{
202 200
						logger.warn("TaxonStatus " + statusFk + " not yet implemented. Taxon (RIdentifier = " + taxonId + ") left out.");
203 201
						success = false;
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonNameImport.java
33 33
import eu.etaxonomy.cdm.model.agent.Person;
34 34
import eu.etaxonomy.cdm.model.agent.Team;
35 35
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
36
import eu.etaxonomy.cdm.model.common.Annotation;
36 37
import eu.etaxonomy.cdm.model.common.CdmBase;
37 38
import eu.etaxonomy.cdm.model.common.Extension;
38 39
import eu.etaxonomy.cdm.model.common.ExtensionType;
......
260 261

  
261 262
					//created, notes
262 263
					boolean excludeUpdated = true;
263
					success &= doIdCreatedUpdatedNotes(state, taxonName, rs, nameId, NAMESPACE, excludeUpdated, false);
264
					boolean excludeNotes = true;
265
					success &= doIdCreatedUpdatedNotes(state, taxonName, rs, nameId, NAMESPACE, excludeUpdated, excludeNotes);
266
					handleNameNotes(state, taxonName, rs, nameId);
264 267

  
265 268
					//NonViralName
266 269
					if (taxonName.isNonViral()){
......
326 329
	}
327 330

  
328 331

  
329
	private Rank handleProlesAndRaceSublusus(BerlinModelImportState state, ResultSet rs, Rank rank) throws SQLException {
332
	/**
333
     * @param state
334
     * @param taxonName
335
     * @param rs
336
     * @param nameId
337
	 * @throws SQLException
338
     */
339
    private void handleNameNotes(BerlinModelImportState state, TaxonName taxonName, ResultSet rs, int nameId) throws SQLException {
340
        String notesOrig = rs.getString("notes");
341
        String notes = filterNotes(notesOrig, nameId);
342
        if (isNotBlank(notes) && taxonName != null ){
343
            String notesString = String.valueOf(notes);
344
            if (notesString.length() > 65530 ){
345
                notesString = notesString.substring(0, 65530) + "...";
346
                logger.warn("Notes string is longer than 65530 and was truncated: " + taxonName);
347
            }
348
            Annotation notesAnnotation = Annotation.NewInstance(notesString, Language.DEFAULT());
349
            //notesAnnotation.setAnnotationType(AnnotationType.EDITORIAL());
350
            //notes.setCommentator(bmiConfig.getCommentator());
351
            taxonName.addAnnotation(notesAnnotation);
352
        }
353

  
354
    }
355

  
356
    private static final String MCL = "MCL\\s?[0-9]{1,3}(\\-[0-9]{1,4}(\\-[0-9]{1,4}(\\-[0-9]{1,4}(\\-[0-9]{1,3})?)?)?)?";
357
    /**
358
     * @param notes
359
     */
360
    private String filterNotes(String notes, int nameId) {
361
        String result;
362
        if (isBlank(notes)){
363
            result = null;
364
        }else if (notes.matches("Acc:.*")){
365
            if (notes.matches("Acc: .*\\$$") || (notes.matches("Acc: .*"+MCL))){
366
                result = null;
367
            }else if (notes.matches("Acc: .*(\\$|"+MCL+")\\s*\\{.*\\}")){
368
                notes = notes.substring(notes.indexOf("{")+1, notes.length()-1);
369
                result = notes;
370
            }else if (notes.matches("Acc: .*(\\$|"+MCL+")\\s*\\[.*\\]")){
371
                notes = notes.substring(notes.indexOf("[")+1, notes.length()-1);
372
                result = notes;
373
            }else{
374
                logger.warn("Name id: " + nameId + ". Namenote: " + notes);
375
                result = notes;
376
            }
377
        }else if (notes.matches("Syn:.*")){
378
            if (notes.matches("Syn: .*\\$$") || (notes.matches("Syn: .*"+MCL))){
379
                result = null;
380
            }else if (notes.matches("Syn: .*(\\$|"+MCL+")\\s*\\{.*\\}")){
381
                notes = notes.substring(notes.indexOf("{")+1, notes.length()-1);
382
                result = notes;
383
            }else if (notes.matches("Syn: .*(\\$|"+MCL+")\\s*\\[.*\\]")){
384
                notes = notes.substring(notes.indexOf("[")+1, notes.length()-1);
385
                result = notes;
386
            }else{
387
                logger.warn("Name id: " + nameId + ". Namenote: " + notes);
388
                result = notes;
389
            }
390
        }else{
391
            result = notes;
392
        }
393
        return result;
394
    }
395

  
396

  
397
    private Rank handleProlesAndRaceSublusus(BerlinModelImportState state, ResultSet rs, Rank rank) throws SQLException {
330 398
		Rank result;
331 399
		String rankAbbrev = rs.getString("RankAbbrev");
332 400
//		String rankStr = rs.getString("Rank");
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonNameRelationImport.java
36 36
import java.util.Map;
37 37
import java.util.Set;
38 38

  
39
import org.apache.commons.lang.StringUtils;
40 39
import org.apache.log4j.Logger;
41 40
import org.springframework.stereotype.Component;
42 41

  
......
46 45
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner;
47 46
import eu.etaxonomy.cdm.model.agent.Person;
48 47
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
48
import eu.etaxonomy.cdm.model.common.Annotation;
49
import eu.etaxonomy.cdm.model.common.AnnotationType;
49 50
import eu.etaxonomy.cdm.model.common.CdmBase;
50 51
import eu.etaxonomy.cdm.model.name.HybridRelationshipType;
51 52
import eu.etaxonomy.cdm.model.name.IBotanicalName;
......
77 78

  
78 79
	@Override
79 80
	protected String getIdQuery(BerlinModelImportState state) {
80
		if (StringUtils.isNotBlank(state.getConfig().getNameIdTable())){
81
			String result = super.getIdQuery(state);
82
			result += " WHERE nameFk1 IN (SELECT NameId FROM %s) OR ";
83
			result += "       nameFk2 IN (SELECT NameId FROM %s)";
84
			result = String.format(result, state.getConfig().getNameIdTable(),state.getConfig().getNameIdTable() );
85
			return result;
81
		String nameIdTable = state.getConfig().getNameIdTable();
82
		String result = super.getIdQuery(state);
83
	    if (isNotBlank(nameIdTable)){
84
			if (state.getConfig().isEuroMed()){
85
			    result += " WHERE nameFk1 IN (SELECT NameId FROM %s) AND RelNameQualifierFk NOT IN (1, 3, 9, 10, 16, 6, 61) OR ";
86
			    result += "       nameFk2 IN (SELECT NameId FROM %s) AND RelNameQualifierFk NOT IN (2) ";
87
			    //2 is unclear, 17 should be in both, 62 links names to itself
88
			    result = String.format(result, nameIdTable, nameIdTable);
89
			}else{
90
			    result += " WHERE nameFk1 IN (SELECT NameId FROM %s) OR ";
91
			    result += "       nameFk2 IN (SELECT NameId FROM %s) ";
92
			    result = String.format(result, nameIdTable, nameIdTable );
93
			}
94

  
86 95
		}else{
87
			return super.getIdQuery(state);
96
			//
88 97
		}
98
	    return result;
89 99
	}
90 100

  
91 101

  
......
143 153

  
144 154
				if (nameFrom != null && nameTo != null){
145 155
					success = handleNameRelationship(success, config, name1Id, name2Id,	relQualifierFk,
146
							notes, nameFrom, nameTo, citation, microcitation, rule);
156
							notes, nameFrom, nameTo, citation, microcitation, rule, relNameId);
147 157

  
148 158
					if (! nameFrom.isProtectedTitleCache()){
149 159
						nameFrom.setTitleCache(null);
......
195 205
	 * @param citation
196 206
	 * @param microcitation
197 207
	 * @param rule
208
	 * @param relNameId
198 209
	 * @return
199 210
	 */
200 211
	private boolean handleNameRelationship(boolean success,
201 212
				BerlinModelImportConfigurator config, int name1Id, int name2Id,
202 213
				int relQualifierFk, String notes, TaxonName nameFrom,
203 214
				TaxonName nameTo, Reference citation,
204
				String microcitation, String rule) {
215
				String microcitation, String rule, int relNameId) {
205 216
		AnnotatableEntity nameRelationship = null;
206 217
		if (relQualifierFk == NAME_REL_IS_BASIONYM_FOR){
207 218
			nameRelationship = nameTo.addBasionym(nameFrom, citation, microcitation, rule);
......
240 251
				if (isLectoType){
241 252
					status = NameTypeDesignationStatus.LECTOTYPE();
242 253
				}
243
				nameRelationship = nameTo.addNameTypeDesignation(nameFrom, citation, microcitation, originalNameString, status, isRejectedType, isConservedType, /*isLectoType,*/ isNotDesignated, addToAllNames);
254
				if (isNotDesignated && nameTo == nameFrom){
255
				    nameFrom = null;  //E+M case
256
				}
257

  
258
				nameRelationship = nameTo.addNameTypeDesignation(nameFrom, citation, microcitation, originalNameString, status, isRejectedType, isConservedType, isNotDesignated, addToAllNames);
244 259
			}
245 260

  
246 261
		}else if (relQualifierFk == NAME_REL_IS_ORTHOGRAPHIC_VARIANT_OF){
......
276 291
				success = false;
277 292
			}
278 293
		}
279
		doNotes(nameRelationship, notes);
294
		Annotation annotation = doNotes(nameRelationship, notes);
295
		if (config.isEuroMed() && annotation != null){
296
		    if (relQualifierFk == NAME_REL_IS_BASIONYM_FOR){
297
		        annotation.setAnnotationType(AnnotationType.TECHNICAL());
298
		    }else if ((relQualifierFk == NAME_REL_IS_LECTOTYPE_OF) && !notes.contains("designated")){
299
		        annotation.setAnnotationType(AnnotationType.TECHNICAL());
300
		    }else{
301
		        logger.warn("Annotation type not defined for name relationship " + relNameId);
302
		    }
303
		}else if (annotation != null){
304
            logger.warn("Annotation type not defined for name relationship " + relNameId);
305
		}
280 306
		return success;
281 307
	}
282 308

  
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonRelationImport.java
293 293
								taxonRelationship = makeTaxonomicallyIncluded(state, classificationMap, treeRefFk, fromTaxon, toTaxon, citation, microcitation);
294 294
							}else if (relQualifierFk == TAX_REL_IS_MISAPPLIED_NAME_OF){
295 295
								 taxonRelationship = toTaxon.addMisappliedName(fromTaxon, citation, microcitation);
296
							}else{
296
                            }else if (relQualifierFk == TAX_REL_IS_PROPARTE_SYN_OF ||
297
                                    //TODO homo/hetero
298
                                    relQualifierFk == TAX_REL_IS_PROPARTE_HOMOTYPIC_SYNONYM_OF ||
299
                                    relQualifierFk == TAX_REL_IS_PROPARTE_HETEROTYPIC_SYNONYM_OF ){
300
                                    toTaxon.addProparteSynonym(fromTaxon, citation, microcitation);
301
                            }else if(relQualifierFk == TAX_REL_IS_PARTIAL_SYN_OF ||
302
                                    //TODO homo/hetero
303
                                    relQualifierFk == TAX_REL_IS_PARTIAL_HOMOTYPIC_SYNONYM_OF ||
304
                                    relQualifierFk == TAX_REL_IS_PARTIAL_HETEROTYPIC_SYNONYM_OF ){
305
                                toTaxon.addPartialSynonym(fromTaxon, citation, microcitation);
306
                            }else{
297 307
								handleAllRelatedTaxa(state, fromTaxon, classificationMap, fromRefFk);
298 308
								handleAllRelatedTaxa(state, toTaxon, classificationMap, treeRefFk);
299 309
								logger.warn("Unhandled taxon relationship: RelId:" + relPTaxonId + "; QualifierId: " + relQualifierFk);
......
316 326
									relQualifierFk == TAX_REL_IS_HOMOTYPIC_SYNONYM_OF ||
317 327
									relQualifierFk == TAX_REL_IS_HETEROTYPIC_SYNONYM_OF){
318 328
								//pro parte already set by taxon mapping
319
							}else if (relQualifierFk == TAX_REL_IS_PROPARTE_SYN_OF ||
320
									relQualifierFk == TAX_REL_IS_PROPARTE_HOMOTYPIC_SYNONYM_OF ||
321
									relQualifierFk == TAX_REL_IS_PROPARTE_HETEROTYPIC_SYNONYM_OF ){
322
									synonym.setProParte(true);
323
							}else if(relQualifierFk == TAX_REL_IS_PARTIAL_SYN_OF ||
324
									relQualifierFk == TAX_REL_IS_PARTIAL_HOMOTYPIC_SYNONYM_OF ||
325
									relQualifierFk == TAX_REL_IS_PARTIAL_HETEROTYPIC_SYNONYM_OF ){
326
							        synonym.setPartial(true);
329
//							}else if (relQualifierFk == TAX_REL_IS_PROPARTE_SYN_OF ||
330
//									relQualifierFk == TAX_REL_IS_PROPARTE_HOMOTYPIC_SYNONYM_OF ||
331
//									relQualifierFk == TAX_REL_IS_PROPARTE_HETEROTYPIC_SYNONYM_OF ){
332
//									synonym.setProParte(true);
333
//							}else if(relQualifierFk == TAX_REL_IS_PARTIAL_SYN_OF ||
334
//									relQualifierFk == TAX_REL_IS_PARTIAL_HOMOTYPIC_SYNONYM_OF ||
335
//									relQualifierFk == TAX_REL_IS_PARTIAL_HETEROTYPIC_SYNONYM_OF ){
336
//							        synonym.setPartial(true);
327 337
							}else{
328 338
								success = false;
329 339
								logger.warn("Synonym relationship type not yet implemented: " + relQualifierFk);
......
610 620
		if (relQualifierFk == TAX_REL_IS_INCLUDED_IN ||
611 621
				relQualifierFk == TAX_REL_IS_MISAPPLIED_NAME_OF){
612 622
			return true;
623
		}else if (relQualifierFk == TAX_REL_IS_PROPARTE_SYN_OF ||
624
	                relQualifierFk == TAX_REL_IS_PARTIAL_SYN_OF ||
625
	                relQualifierFk == TAX_REL_IS_PROPARTE_HOMOTYPIC_SYNONYM_OF ||
626
	                relQualifierFk == TAX_REL_IS_PROPARTE_HETEROTYPIC_SYNONYM_OF ||
627
	                relQualifierFk == TAX_REL_IS_PARTIAL_HOMOTYPIC_SYNONYM_OF ||
628
	                relQualifierFk == TAX_REL_IS_PARTIAL_HETEROTYPIC_SYNONYM_OF
629
                    ){
630
	            return true;
631

  
613 632
		}else{
614 633
			return false;
615 634
		}
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/germanSL/GermanSLImporBase.java
1
/**
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.io.redlist.germanSL;
10

  
11
import org.apache.log4j.Logger;
12

  
13
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImport;
14
import eu.etaxonomy.cdm.model.name.IBotanicalName;
15

  
16
/**
17
 * @author a.mueller
18
 * @since 15.05.2018
19
 *
20
 */
21
public abstract class GermanSLImporBase
22
        extends SimpleExcelTaxonImport<GermanSLImportConfigurator> {
23

  
24
    private static final long serialVersionUID = 236093186271666895L;
25

  
26
    private static final Logger logger = Logger.getLogger(GermanSLImporBase.class);
27

  
28

  
29
    protected class NameResult{
30
        IBotanicalName name;
31
        boolean proParte = false;
32
        String sensu = null;
33
        String auct = null;
34
    }
35

  
36
    protected boolean isAccepted(String statusStr, NameResult nameResult){
37
        if (nameResult.proParte){
38
            return true; //pro parte synonyms and misapplied names are always handled as concept relationships
39
            //and therefore need to be accepted
40
        }else if ("FALSE()".equals(statusStr) || "0".equals(statusStr) || "false".equalsIgnoreCase(statusStr)){
41
            return true;
42
        } else if ("TRUE()".equals(statusStr) || "1".equals(statusStr)|| "true".equalsIgnoreCase(statusStr)){
43
            return false;
44
        }else{
45
            logger.warn("Unhandled taxon status: " + statusStr);
46
            return false;
47
        }
48
    }
49
}
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/germanSL/GermanSLTaxonImport.java
20 20

  
21 21
import eu.etaxonomy.cdm.common.CdmUtils;
22 22
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
23
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImport;
24 23
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState;
25 24
import eu.etaxonomy.cdm.model.common.CdmBase;
26 25
import eu.etaxonomy.cdm.model.common.DefinedTerm;
......
46 45
 *
47 46
 */
48 47
@Component
49
public class GermanSLTaxonImport<CONFIG extends GermanSLImportConfigurator>
50
            extends SimpleExcelTaxonImport<CONFIG> {
48
public class GermanSLTaxonImport
49
            extends GermanSLImporBase {
51 50

  
52 51
    private static final long serialVersionUID = 236093186271666895L;
53 52

  
......
99 98

  
100 99

  
101 100
    @Override
102
    protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) {
101
    protected void firstPass(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
103 102
        String line = state.getCurrentLine() + ": ";
104 103
        HashMap<String, String> record = state.getOriginalRecord();
105 104

  
......
119 118
        //status
120 119
        String statusStr = getValue(record, SYNONYM);
121 120
        TaxonBase<?> taxonBase;
122
        if (isAccepted(statusStr)){
121
        if (isAccepted(statusStr, nameResult)){
123 122
            taxonBase = Taxon.NewInstance(taxonName, sec);
124
            if (nameResult.proParte){
125
                logger.warn(line + "accepted taxon can not be pro parte");
126
            }
123
//            if (nameResult.proParte){
124
//                logger.warn(line + "accepted taxon can not be pro parte in GermanSL");
125
//            }
127 126
        }else{
128 127
            Synonym syn = Synonym.NewInstance(taxonName, sec);
129
            if (nameResult.proParte){
130
                syn.setProParte(true);
131
            }
128
//            if (nameResult.proParte){
129
//                syn.setProParte(true);
130
//            }
132 131
            taxonBase = syn;
133 132
        }
134 133
        if (!isBlank(nameResult.sensu)){
......
217 216
     * @param secRefStr
218 217
     * @return
219 218
     */
220
    private Reference getSecRef(SimpleExcelTaxonImportState<CONFIG> state, String secRefStr, String line) {
219
    private Reference getSecRef(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state, String secRefStr, String line) {
221 220
        Reference result = state.getReference(secRefStr);
222 221
        if (result == null && secRefStr != null){
223 222
            result = ReferenceFactory.newGeneric();
......
261 260
    }
262 261

  
263 262

  
264
    private class NameResult{
265
        IBotanicalName name;
266
        boolean proParte = false;
267
        String sensu = null;
268
        String auct = null;
269
    }
270 263

  
271 264
    /**
272 265
     * @param record
273 266
     * @param state
274 267
     * @return
275 268
     */
276
    private NameResult makeName(String line, HashMap<String, String> record, SimpleExcelTaxonImportState<CONFIG> state) {
269
    public NameResult makeName(String line, HashMap<String, String> record, SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
277 270

  
278 271
        String specieNrStr = getValue(record, SPECIES_NR);
279 272
        String nameStr = getValue(record, ABBREVIAT);
......
335 328
     * @param rankStr
336 329
     * @return
337 330
     */
338
    private Rank makeRank(String line, SimpleExcelTaxonImportState<CONFIG> state, String rankStr) {
331
    private Rank makeRank(String line, SimpleExcelTaxonImportState<GermanSLImportConfigurator> state, String rankStr) {
339 332
        Rank rank = null;
340 333
        try {
341 334
            rank = state.getTransformer().getRankByKey(rankStr);
......
386 379
     * @param fullName
387 380
     * @return
388 381
     */
389
    private IBotanicalName getExistingName(SimpleExcelTaxonImportState<CONFIG> state, IBotanicalName fullName) {
382
    private IBotanicalName getExistingName(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state, IBotanicalName fullName) {
390 383
        initExistinNames(state);
391 384
        return (IBotanicalName)state.getName(fullName.getTitleCache());
392 385
    }
......
395 388
     * @param state
396 389
     */
397 390
    @SuppressWarnings("rawtypes")
398
    private void initExistinNames(SimpleExcelTaxonImportState<CONFIG> state) {
391
    private void initExistinNames(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
399 392
        if (!nameMapIsInitialized){
400 393
            List<String> propertyPaths = Arrays.asList("");
401 394
            List<TaxonName> existingNames = this.getNameService().list(null, null, null, null, propertyPaths);
......
429 422
    }
430 423

  
431 424

  
432

  
433
    private boolean isAccepted(String statusStr){
434
        if ("FALSE()".equals(statusStr) || "0".equals(statusStr) || "false".equalsIgnoreCase(statusStr)){
435
            return true;
436
        } else if ("TRUE()".equals(statusStr) || "1".equals(statusStr)|| "true".equalsIgnoreCase(statusStr)){
437
            return false;
438
        }else{
439
            logger.warn("Unhandled taxon status: " + statusStr);
440
            return false;
441
        }
442
    }
443

  
444

  
445 425
    /**
446 426
     * @param next
447 427
     * @return
......
457 437

  
458 438

  
459 439
    @Override
460
    protected boolean isIgnore(SimpleExcelTaxonImportState<CONFIG> state) {
440
    protected boolean isIgnore(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
461 441
        return ! state.getConfig().isDoTaxa();
462 442
    }
463 443
}
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/germanSL/GermanSLTaxonRelationImport.java
15 15
import org.apache.log4j.Logger;
16 16
import org.springframework.stereotype.Component;
17 17

  
18
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImport;
19 18
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState;
20
import eu.etaxonomy.cdm.model.common.CdmBase;
21 19
import eu.etaxonomy.cdm.model.reference.Reference;
22 20
import eu.etaxonomy.cdm.model.taxon.Classification;
23 21
import eu.etaxonomy.cdm.model.taxon.Synonym;
......
31 29
 *
32 30
 */
33 31
@Component
34
public class GermanSLTaxonRelationImport<CONFIG extends GermanSLImportConfigurator>
35
            extends SimpleExcelTaxonImport<CONFIG> {
32
public class GermanSLTaxonRelationImport extends GermanSLImporBase {
36 33

  
37 34
    private static final long serialVersionUID = 3381597141845204995L;
38 35

  
......
50 47
    private int count = 0;
51 48

  
52 49
    @Override
53
    protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) {
50
    protected void firstPass(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
54 51
        count++;
55 52
        Map<String, String> record = state.getOriginalRecord();
56 53
        String line = state.getCurrentLine() + ": ";
......
59 56
        String acceptedStr = getValue(record, GermanSLTaxonImport.VALID_NR);
60 57
        String idStr = getValue(record, GermanSLTaxonImport.SPECIES_NR);
61 58
        String statusStr = getValue(record, GermanSLTaxonImport.SYNONYM);
59
        NameResult nameResult = GermanSLTaxonImport.makeName (line, record, state);
62 60

  
63 61
        Classification classification = getClassification(state);
64 62
        TaxonBase<?> taxonBase = GermanSLTaxonImport.taxonIdMap.get(idStr);
65 63
        Taxon parent;
66
        if (isAccepted(statusStr)){
64
        if (isAccepted(statusStr, nameResult)){
67 65
            TaxonBase<?> parentTmp = GermanSLTaxonImport.taxonIdMap.get(parentStr);
68 66
            if (parentTmp == null){
69 67
                logger.warn(line + "Parent is missing: "+ parentStr);
......
100 98
    }
101 99

  
102 100

  
103
    private boolean isAccepted(String statusStr){
104
        if ("FALSE()".equals(statusStr) || "0".equals(statusStr) || "false".equalsIgnoreCase(statusStr)){
105
            return true;
106
        } else if ("TRUE()".equals(statusStr) || "1".equals(statusStr)|| "true".equalsIgnoreCase(statusStr)){
107
            return false;
108
        }else{
109
            logger.warn("Unhandled taxon status: " + statusStr);
110
            return false;
111
        }
112
    }
113

  
114

  
115
    /**
116
     * @param next
117
     * @return
118
     */
119
    private Taxon getAccepted(TaxonBase<?> taxonBase) {
120
        if (taxonBase.isInstanceOf(Taxon.class)){
121
            return CdmBase.deproxy(taxonBase, Taxon.class);
122
        }else{
123
            Synonym syn = CdmBase.deproxy(taxonBase, Synonym.class);
124
            return syn.getAcceptedTaxon();
125
        }
126
    }
127

  
128

  
129 101
    boolean needsFinalSave = true;
130 102
    /**
131 103
     * {@inheritDoc}
132 104
     */
133 105
    @Override
134
    protected void secondPass(SimpleExcelTaxonImportState<CONFIG> state) {
106
    protected void secondPass(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
135 107
        if (needsFinalSave){
136 108
            getTaxonService().saveOrUpdate(taxaToSave);
137 109
            needsFinalSave = false;
......
142 114
    /**
143 115
     * @return
144 116
     */
145
    private Classification getClassification(SimpleExcelTaxonImportState<CONFIG> state) {
117
    private Classification getClassification(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
146 118
        if (classification == null){
147 119
            GermanSLImportConfigurator config = state.getConfig();
148 120
            classification = Classification.NewInstance(config.getClassificationName());
......
154 126
    }
155 127

  
156 128
    @Override
157
    protected boolean isIgnore(SimpleExcelTaxonImportState<CONFIG> state) {
129
    protected boolean isIgnore(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
158 130
        return ! state.getConfig().isDoTaxa();
159 131
    }
160 132
}
app-import/src/test/resources/eu/etaxonomy/cdm/io/PUBLIC.xsd
12 12
	<xsd:element name="COLLECTION_EXTENSION" type="COLLECTION_EXTENSION__type" />
13 13
	<xsd:element name="AGENTBASE_CONTACT_URLS_AUD" type="AGENTBASE_CONTACT_URLS_AUD__type" />
14 14
	<xsd:element name="STATISTICALMEASUREMENTVALUE_DEFINEDTERMBASE_AUD" type="STATISTICALMEASUREMENTVALUE_DEFINEDTERMBASE_AUD__type" />
15
	<xsd:element name="WORKINGSET_TAXONBASE_AUD" type="WORKINGSET_TAXONBASE_AUD__type" />
15
	<xsd:element name="DESCRIPTIVEDATASET_TAXONBASE_AUD" type="DESCRIPTIVEDATASET_TAXONBASE_AUD__type" />
16 16
	<xsd:element name="FEATURETREE_RIGHTS" type="FEATURETREE_RIGHTS__type" />
17 17
	<xsd:element name="COLLECTION_MEDIA_AUD" type="COLLECTION_MEDIA_AUD__type" />
18 18
	<xsd:element name="REFERENCE_EXTENSION" type="REFERENCE_EXTENSION__type" />
19 19
	<xsd:element name="CDM_VIEW_CDM_VIEW" type="CDM_VIEW_CDM_VIEW__type" />
20 20
	<xsd:element name="REFERENCE_ANNOTATION" type="REFERENCE_ANNOTATION__type" />
21 21
	<xsd:element name="DESCRIPTIONBASE_SPECIMENOROBSERVATIONBASE" type="DESCRIPTIONBASE_SPECIMENOROBSERVATIONBASE__type" />
22
	<xsd:element name="WORKINGSET_REPRESENTATION" type="WORKINGSET_REPRESENTATION__type" />
22
	<xsd:element name="DESCRIPTIVEDATASET_REPRESENTATION" type="DESCRIPTIVEDATASET_REPRESENTATION__type" />
23 23
	<xsd:element name="TERMVOCABULARY_MARKER" type="TERMVOCABULARY_MARKER__type" />
24 24
	<xsd:element name="TAXONRELATIONSHIP_ANNOTATION_AUD" type="TAXONRELATIONSHIP_ANNOTATION_AUD__type" />
25 25
	<xsd:element name="MEDIA_MARKER_AUD" type="MEDIA_MARKER_AUD__type" />
......
133 133
	<xsd:element name="SPECIMENOROBSERVATIONBASE_MEDIA_AUD" type="SPECIMENOROBSERVATIONBASE_MEDIA_AUD__type" />
134 134
	<xsd:element name="TAXONBASE_MARKER" type="TAXONBASE_MARKER__type" />
135 135
	<xsd:element name="DEFINEDTERMBASE_MARKER_AUD" type="DEFINEDTERMBASE_MARKER_AUD__type" />
136
	<xsd:element name="WORKINGSET_DESCRIPTIONBASE_AUD" type="WORKINGSET_DESCRIPTIONBASE_AUD__type" />
136
	<xsd:element name="DESCRIPTIVEDATASET_DESCRIPTIONBASE_AUD" type="DESCRIPTIVEDATASET_DESCRIPTIONBASE_AUD__type" />
137 137
	<xsd:element name="TAXONNAMEBASE_EXTENSION_AUD" type="TAXONNAMEBASE_EXTENSION_AUD__type" />
138 138
	<xsd:element name="DETERMINATIONEVENT_MARKER_AUD" type="DETERMINATIONEVENT_MARKER_AUD__type" />
139 139
	<xsd:element name="CLASSIFICATION_ORIGINALSOURCEBASE" type="CLASSIFICATION_ORIGINALSOURCEBASE__type" />
......
158 158
	<xsd:element name="AGENTBASE_CREDIT" type="AGENTBASE_CREDIT__type" />
159 159
	<xsd:element name="DEFINEDTERMBASE_ORIGINALSOURCEBASE" type="DEFINEDTERMBASE_ORIGINALSOURCEBASE__type" />
160 160
	<xsd:element name="AGENTBASE_CONTACT_PHONENUMBERS" type="AGENTBASE_CONTACT_PHONENUMBERS__type" />
161
	<xsd:element name="WORKINGSET_MARKER_AUD" type="WORKINGSET_MARKER_AUD__type" />
161
	<xsd:element name="DESCRIPTIVEDATASET_MARKER_AUD" type="DESCRIPTIVEDATASET_MARKER_AUD__type" />
162 162
	<xsd:element name="TERMVOCABULARY_EXTENSION_AUD" type="TERMVOCABULARY_EXTENSION_AUD__type" />
163 163
	<xsd:element name="SPECIMENOROBSERVATIONBASE_MARKER" type="SPECIMENOROBSERVATIONBASE_MARKER__type" />
164 164
	<xsd:element name="PERMISSIONGROUP_GRANTEDAUTHORITYIMPL" type="PERMISSIONGROUP_GRANTEDAUTHORITYIMPL__type" />
......
185 185
	<xsd:element name="COLLECTION_RIGHTS_AUD" type="COLLECTION_RIGHTS_AUD__type" />
186 186
	<xsd:element name="INDIVIDUALASSOCIATION_LANGUAGESTRING_AUD" type="INDIVIDUALASSOCIATION_LANGUAGESTRING_AUD__type" />
187 187
	<xsd:element name="AGENTBASE_DEFINEDTERMBASE_AUD" type="AGENTBASE_DEFINEDTERMBASE_AUD__type" />
188
	<xsd:element name="WORKINGSET_DESCRIPTIONBASE" type="WORKINGSET_DESCRIPTIONBASE__type" />
188
	<xsd:element name="DESCRIPTIVEDATASET_DESCRIPTIONBASE" type="DESCRIPTIVEDATASET_DESCRIPTIONBASE__type" />
189 189
	<xsd:element name="GENBANKACCESSION_AUD" type="GENBANKACCESSION_AUD__type" />
190 190
	<xsd:element name="POLYTOMOUSKEY_EXTENSION_AUD" type="POLYTOMOUSKEY_EXTENSION_AUD__type" />
191 191
	<xsd:element name="DESCRIPTIONELEMENTBASE_STATEDATA_AUD" type="DESCRIPTIONELEMENTBASE_STATEDATA_AUD__type" />
192
	<xsd:element name="WORKINGSET_ANNOTATION" type="WORKINGSET_ANNOTATION__type" />
192
	<xsd:element name="DESCRIPTIVEDATASET_ANNOTATION" type="DESCRIPTIVEDATASET_ANNOTATION__type" />
193 193
	<xsd:element name="FEATURETREE_ORIGINALSOURCEBASE" type="FEATURETREE_ORIGINALSOURCEBASE__type" />
194 194
	<xsd:element name="TAXONBASE_MARKER_AUD" type="TAXONBASE_MARKER_AUD__type" />
195 195
	<xsd:element name="MEDIA_ANNOTATION_AUD" type="MEDIA_ANNOTATION_AUD__type" />
......
212 212
	<xsd:element name="CDMMETADATA" type="CDMMETADATA__type" />
213 213
	<xsd:element name="RELATIONSHIPTERMBASE_INVERSEREPRESENTATION_AUD" type="RELATIONSHIPTERMBASE_INVERSEREPRESENTATION_AUD__type" />
214 214
	<xsd:element name="SPECIMENOROBSERVATIONBASE" type="SPECIMENOROBSERVATIONBASE__type" />
215
	<xsd:element name="WORKINGSET" type="WORKINGSET__type" />
215
	<xsd:element name="DESCRIPTIVEDATASET" type="DESCRIPTIVEDATASET__type" />
216 216
	<xsd:element name="MEDIA_SEQUENCE" type="MEDIA_SEQUENCE__type" />
217 217
	<xsd:element name="TERMVOCABULARY_RIGHTS_AUD" type="TERMVOCABULARY_RIGHTS_AUD__type" />
218 218
	<xsd:element name="FEATURENODE_DEFINEDTERMBASE_ONLYAPPLICABLE" type="FEATURENODE_DEFINEDTERMBASE_ONLYAPPLICABLE__type" />
......
228 228
	<xsd:element name="TYPEDESIGNATIONBASE_ANNOTATION" type="TYPEDESIGNATIONBASE_ANNOTATION__type" />
229 229
	<xsd:element name="NAMERELATIONSHIP_ANNOTATION" type="NAMERELATIONSHIP_ANNOTATION__type" />
230 230
	<xsd:element name="ADDRESS" type="ADDRESS__type" />
231
	<xsd:element name="MULTIACCESSKEY_COVEREDTAXON" type="WORKINGSET_TAXONBASE__type" />
231
	<xsd:element name="MULTIACCESSKEY_COVEREDTAXON" type="DESCRIPTIVEDATASET_TAXONBASE__type" />
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff