/**
* Execute the loader of the data into the database.
*/
public void execute() {
Validation validation = new Validation(SchemaUtil.urlToSchema(XSD),
srcConn);
if (validation.succeed()) {
validation.setDocument(srcLoad);
if (validation.succeed()) {
JdlConnection jdlConnection = null;
try {
JdbcType jdbc = ObjectFactoryUtil
.getJdbcTypeBySrcXml(srcConn);
LoadType load = ObjectFactoryUtil
.getLoadTypeBySrcXml(srcLoad);
jdlConnection = new JdlConnection(jdbc);
CsvLoadType csv = load.getCsv();
if (csv != null) {
try {
CsvLoader csvLoader = new CsvLoader(csv, new File(
srcData));
csvLoader.dataInsert(jdlConnection);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
XmlLoadType xml = load.getXml();
if (xml != null) {
XmlLoader xPathParsing = new XmlLoader(xml,
DomUtil.srcToDocument(srcData));
xPathParsing.dataInsert(jdlConnection);
}
} catch (JAXBException e) {
e.printStackTrace();
} finally {
try {
if (jdlConnection != null)
jdlConnection.closeConnection();
} catch (SQLException e) {
log.error("closing connection", e);
}
}
} else {
System.err.println(validation.getError());
}
} else {
System.err.println(validation.getError());
}
}