Project

General

Profile

Download (2.01 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 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

    
10
package eu.etaxonomy.cdm.io.common;
11

    
12
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
13

    
14
import eu.etaxonomy.cdm.database.ICdmDataSource;
15

    
16
/**
17
 * @author a.mueller
18
 * @since 29.01.2009
19
 */
20
public class CdmDefaultImport<T extends IImportConfigurator> extends CdmDefaultIOBase<IImportConfigurator> implements ICdmImporter<T> {
21
	@SuppressWarnings("unused")
22
	private static final Logger logger = LogManager.getLogger(CdmDefaultImport.class);
23

    
24
	@Override
25
    public ImportResult invoke(T config){
26
		ICdmDataSource destination = config.getDestination();
27
		boolean omitTermLoading = config.isOmitTermLoading();
28
		return invoke(config, destination, omitTermLoading);
29
	}
30

    
31
	public ImportResult invoke(IImportConfigurator config, ICdmDataSource destination, boolean omitTermLoading){
32
		boolean createNew = config.isCreateNew();
33
		if (startApplicationController(config, destination, omitTermLoading, createNew) == false){
34
		    ImportResult result = new ImportResult();
35
		    result.setAborted("Application controller could not be started");
36
			return result;
37
		}else{
38
			CdmApplicationAwareDefaultImport<?> defaultImport = (CdmApplicationAwareDefaultImport<?>)getCdmAppController().getBean("defaultImport");
39
			defaultImport.authenticate(config);
40
			return defaultImport.invoke(config);
41
		}
42
	}
43

    
44
	/**
45
	 * Starts the CdmApplicationController if not yet started
46
	 * @param config Configuration
47
	 * @param destination destination
48
	 * @return false if start not successful
49
	 */
50
	public boolean startController(IImportConfigurator config, ICdmDataSource destination){
51
		boolean omitTermLoading = false;
52
		boolean createNew = false;
53
		return startApplicationController(config, destination, omitTermLoading, createNew);
54
	}
55

    
56
}
(5-5/65)