Project

General

Profile

1
package eu.dnetlib.iis.core.workflows.stats;
2

    
3
import eu.dnetlib.data.mapreduce.hbase.statsExport.drivers.DBDriver;
4
import eu.dnetlib.iis.core.java.HadoopContext;
5
import eu.dnetlib.iis.core.java.PortBindings;
6
import eu.dnetlib.iis.core.java.Process;
7
import eu.dnetlib.iis.core.java.porttype.PortType;
8
import org.apache.log4j.Logger;
9

    
10
import java.util.HashMap;
11
import java.util.Map;
12

    
13
/**
14
 * @author eri
15
 * 
16
 *         Simple Wrapper for preparing the Database for the Import
17
 */
18
public class DBInitWrapper implements Process {
19
	private Logger log = Logger.getLogger(this.getClass());
20
	private DBDriver dbDriver;
21

    
22
	@Override
23
	public void run(PortBindings portBindings, HadoopContext context, Map<String, String> parameters) throws Exception {
24

    
25
		dbDriver = new DBDriver(parameters.get("Stats_db_Url"), 
26
				parameters.get("Stats_db_User"), 
27
				parameters.get("Stats_db_Pass"), 
28
				parameters.get("Stats_db_Driver"));
29
		try {
30
			dbDriver.prepareDB(parameters.get("Stats_db_User"));
31
		} catch (Exception ex) {
32
			log.error("Failed to prepare database schema on :" + parameters.get("Stats_db_Url") + "for " + parameters.get("Stats_db_User") + ex);
33
			throw new Exception("Failed to prepare schema on :" + parameters.get("Stats_db_Url")+"for "+ parameters.get("Stats_db_User"), ex);
34
		}
35

    
36
	}
37

    
38
	@Override
39
	public Map<String, PortType> getInputPorts() {
40
		return createInputPorts();
41

    
42
	}
43

    
44
	@Override
45
	public Map<String, PortType> getOutputPorts() {
46
		return createOutputPorts();
47

    
48
	}
49

    
50
	private static HashMap<String, PortType> createInputPorts() {
51
		HashMap<String, PortType> inputPorts = new HashMap<String, PortType>();
52

    
53
		return inputPorts;
54
	}
55

    
56
	private static HashMap<String, PortType> createOutputPorts() {
57
		HashMap<String, PortType> outputPorts = new HashMap<String, PortType>();
58

    
59
		return outputPorts;
60
	}
61

    
62
}
(3-3/7)