Project

General

Profile

« Previous | Next » 

Revision 51171c9d

Added by Andreas Müller over 12 years ago

last updates for Taxon Excel Import and moving all success variables to state

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/jaxb/JaxbImport.java
64 64
//	protected boolean doInvoke(IImportConfigurator config,
65 65
//			Map<String, MapWrapper<? extends CdmBase>> stores) {
66 66
		@Override
67
		protected boolean doInvoke(JaxbImportState state) {
67
		protected void doInvoke(JaxbImportState state) {
68 68
			
69 69
		state.getConfig();
70
		boolean success = true;
71
        URI uri = null;
70
		URI uri = null;
72 71
		JaxbImportConfigurator jaxbImpConfig = (JaxbImportConfigurator)state.getConfig();
73 72
    	
74 73
    	String urlFileName = jaxbImpConfig.getSource().toString();
......
78 77
			logger.debug("uri: " + uri.toString());
79 78
    	} catch (URISyntaxException ex) {
80 79
			logger.error("File not found");
81
			return false;
80
			state.setUnsuccessfull();
81
			return;
82 82
    	}
83 83

  
84 84
		logger.info("Deserializing " + urlFileName + " to DB " ); //+ dbname
......
101 101
		// save data in DB
102 102
		logger.error("Saving data to DB... "); //+ dbname
103 103
		
104
		success = saveData(jaxbImpConfig, dataSet);
104
		saveData(state, dataSet);
105 105
		
106
		return success;
106
		return;
107 107
	}
108 108

  
109 109
	
110 110
	/**  Saves data in DB */
111
	private boolean saveData (JaxbImportConfigurator jaxbImpConfig, DataSet dataSet) {
112

  
113
		boolean ret = true;
111
	private void saveData (JaxbImportState state, DataSet dataSet) {
112
		JaxbImportConfigurator jaxbImpConfig = state.getConfig();
113
		
114
		boolean success = true;
114 115
		Collection<TaxonBase> taxonBases;
115 116
		List<? extends AgentBase> agents;
116 117
		List<DefinedTermBase> terms;
......
146 147
		if ((jaxbImpConfig.isDoTerms() == true)
147 148
				&& (terms = dataSet.getTerms()).size() > 0) {
148 149
			//txStatus = startTransaction();
149
			ret &= saveTerms(terms);
150
			success &= saveTerms(terms);
150 151
			
151 152
			//commitTransaction(txStatus);
152 153
		}
153 154
		if ((jaxbImpConfig.isDoTermVocabularies() == true) 
154 155
				&& (termVocabularies = dataSet.getTermVocabularies()).size() > 0) {
155 156
			//txStatus = startTransaction();
156
			ret &= saveTermVocabularies(termVocabularies);
157
			success &= saveTermVocabularies(termVocabularies);
157 158
			
158 159
		}
159 160
		
......
182 183
			}
183 184
		} catch (Exception ex) {
184 185
			logger.error("Error saving users");
185
			ret = false;
186
			success = false;
186 187
		}
187 188
		
188 189
		//txStatus = startTransaction();
......
195 196
			}
196 197
		} catch (Exception ex) {
197 198
			logger.error("Error saving agents");
198
			ret = false;
199
			success = false;
199 200
		}
200 201
		//commitTransaction(txStatus);
201 202

  
......
212 213
		} catch (Exception ex) {
213 214
			ex.printStackTrace();
214 215
			logger.error("Error saving references");
215
			ret = false;
216
			success = false;
216 217
		}
217 218
		//commitTransaction(txStatus);
218 219

  
......
227 228
			}
228 229
		} catch (Exception ex) {
229 230
			logger.error("Error saving taxon names");
230
			ret = false;
231
			success = false;
231 232
		}
232 233
		//commitTransaction(txStatus);
233 234

  
......
243 244
			}
244 245
		} catch (Exception ex) {
245 246
			logger.error("Error saving homotypical groups");
246
			ret = false;
247
			success = false;
247 248
		}
248 249
		//commitTransaction(txStatus);
249 250

  
......
265 266
		} catch (Exception ex) {
266 267
			logger.error("Error saving taxa");
267 268
			ex.printStackTrace();
268
			ret = false;
269
			success = false;
269 270
		}
270 271
		//commitTransaction(txStatus);
271 272

  
......
281 282
			}
282 283
		} catch (Exception ex) {
283 284
			logger.error("Error saving type designations");
284
			ret = false;
285
			success = false;
285 286
		}
286 287
		//commitTransaction(txStatus);
287 288

  
......
302 303
			}
303 304
		} catch (Exception ex) {
304 305
			logger.error("Error saving occurrences");
305
			ret = false;
306
			success = false;
306 307
		}
307 308
		//commitTransaction(txStatus);
308 309

  
......
317 318
			}
318 319
		} catch (Exception ex) {
319 320
			logger.error("Error saving feature data");
320
			ret = false;
321
			success = false;
321 322
		}
322 323
		//commitTransaction(txStatus);
323 324

  
......
332 333
			}
333 334
		} catch (Exception ex) {
334 335
			logger.error("Error saving media");
335
			ret = false;
336
			success = false;
336 337
		}
337 338
		
338 339
		if (jaxbImpConfig.isDoClassificationData() == true) {
......
349 350
		
350 351
		commitTransaction(txStatus);
351 352
		logger.info("All data saved");
352

  
353
		return ret;
353
		if (!success){
354
			state.setUnsuccessfull();
355
		}
356
		
357
		return;
354 358

  
355 359
	}
356 360
	

Also available in: Unified diff