diff --git a/.classpath b/.classpath
index 6dbe123..ee58b3d 100644
--- a/.classpath
+++ b/.classpath
@@ -22,7 +22,7 @@
-
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index f4217b0..df46a9a 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,12 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/pom.xml b/pom.xml
index ae0ed96..ff95fa3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -67,11 +67,6 @@
commons-logging
1.0.4
-
- dom4j
- dom4j
- 1.6
-
graphlayout
graphlayout
@@ -233,8 +228,8 @@
maven-compiler-plugin
3.1
-
- 1.7
+
+ 1.8
diff --git a/src/main/java/org/gcube/contentmanagement/lexicalmatcher/utils/DatabaseFactory.java b/src/main/java/org/gcube/contentmanagement/lexicalmatcher/utils/DatabaseFactory.java
index 63d67a3..0ea19fa 100644
--- a/src/main/java/org/gcube/contentmanagement/lexicalmatcher/utils/DatabaseFactory.java
+++ b/src/main/java/org/gcube/contentmanagement/lexicalmatcher/utils/DatabaseFactory.java
@@ -1,18 +1,13 @@
package org.gcube.contentmanagement.lexicalmatcher.utils;
-
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
-import java.util.Iterator;
import java.util.List;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.dom4j.Document;
-import org.dom4j.Node;
-import org.dom4j.io.SAXReader;
import org.gcube.contentmanagement.lexicalmatcher.analysis.core.LexicalEngineConfiguration;
import org.hibernate.Query;
import org.hibernate.Session;
@@ -30,78 +25,41 @@ public class DatabaseFactory {
return DBSessionFactory;
}
- @SuppressWarnings({"unchecked"})
public static SessionFactory initDBConnection(String configurationFile, LexicalEngineConfiguration config) throws Exception {
-
- if (config==null)
- return initDBConnection(configurationFile);
-
- InputStream stream;
- try {
- File fl = new File(configurationFile);
- stream = new FileInputStream(fl);
- } catch (Exception e) {
- stream = ClassLoader.getSystemResourceAsStream(configurationFile);
- }
- SAXReader saxReader = new SAXReader();
- Document document = saxReader.read(stream);
-
- List nodes = document.selectNodes("//hibernate-configuration/session-factory/property");
- Iterator nodesIterator = nodes.iterator();
-
-// System.out.println("--- DATABASE Configuration --- ");
-
- while (nodesIterator.hasNext()) {
- Node currentnode = nodesIterator.next();
- String element = currentnode.valueOf("@name");
- if (element.equals("connection.driver_class"))
- if (config.getDatabaseDriver() != null){
- currentnode.setText(config.getDatabaseDriver());
- }
- if (element.equals("connection.url")) {
- if (config.getDatabaseURL() != null)
- currentnode.setText(config.getDatabaseURL());
- }
- if (element.equals("connection.username")) {
- if (config.getDatabaseUserName() != null)
- currentnode.setText(config.getDatabaseUserName());
- }
- if (element.equals("connection.password")) {
- if (config.getDatabasePassword() != null)
- currentnode.setText(config.getDatabasePassword());
- }
- if (element.equals("dialect")) {
- AnalysisLogger.getLogger().trace("Dialect -> "+config.getDatabaseDialect());
- if (config.getDatabaseDialect() != null)
- currentnode.setText(config.getDatabaseDialect());
- }
- if (element.equals("c3p0.idleConnectionTestPeriod")) {
- if (config.getDatabaseIdleConnectionTestPeriod() != null)
- currentnode.setText(config.getDatabaseIdleConnectionTestPeriod());
- }
- if (element.equals("c3p0.automaticTestTable")) {
- if (config.getDatabaseAutomaticTestTable() != null)
- currentnode.setText(config.getDatabaseAutomaticTestTable());
- }
- }
+ InputStream stream= null;
+ try{
+ if (config==null)
+ return initDBConnection(configurationFile);
- Configuration cfg = new Configuration();
- cfg = cfg.configure(DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(document.asXML().getBytes())));
- cfg.setProperty("hibernate.hbm2ddl.auto", "create");
-
- SessionFactory DBSessionFactory = null;
- DBSessionFactory = cfg.buildSessionFactory();
- // close stream
- stream.close();
-
- return DBSessionFactory;
+ try {
+ File fl = new File(configurationFile);
+ stream = new FileInputStream(fl);
+ } catch (Exception e) {
+ stream = ClassLoader.getSystemResourceAsStream(configurationFile);
+ }
+
+ Configuration cfg = new Configuration();
+ cfg = cfg.configure(DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(stream));
+ cfg.setProperty("hibernate.hbm2ddl.auto", "create");
+
+ SessionFactory DBSessionFactory = null;
+ DBSessionFactory = cfg.buildSessionFactory();
+
+ // close stream
+ stream.close();
+
+ return DBSessionFactory;
+ }finally{
+ if (stream!=null)
+ stream.close();
+ }
}
@SuppressWarnings({"unchecked"})
public static List