diff --git a/pom.xml b/pom.xml
index 49b8dfcb..31ee5301 100644
--- a/pom.xml
+++ b/pom.xml
@@ -202,6 +202,12 @@
+
+ postgresql
+ postgresql
+ 9.1-901-1.jdbc4
+
+
mysql
mysql-connector-java
diff --git a/src/main/java/info/bukova/isspst/AppInitListener.java b/src/main/java/info/bukova/isspst/AppInitListener.java
index 1f9a3e73..bb9716ad 100644
--- a/src/main/java/info/bukova/isspst/AppInitListener.java
+++ b/src/main/java/info/bukova/isspst/AppInitListener.java
@@ -48,7 +48,7 @@ public class AppInitListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent evt) {
- Logger logger = LoggerFactory.getLogger(AppInitListener.class);
+ /*Logger logger = LoggerFactory.getLogger(AppInitListener.class);
logger.info("Initializing database");
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(evt.getServletContext());
@@ -71,7 +71,7 @@ public class AppInitListener implements ServletContextListener {
this.checkGlobalSettings();
userService.removeAccess();
- loadModuleReports();
+ loadModuleReports();*/
}
private void checkMUnits()
diff --git a/src/main/java/info/bukova/isspst/ClientConnectionPrivider.java b/src/main/java/info/bukova/isspst/ClientConnectionPrivider.java
new file mode 100644
index 00000000..bd31aaa6
--- /dev/null
+++ b/src/main/java/info/bukova/isspst/ClientConnectionPrivider.java
@@ -0,0 +1,78 @@
+package info.bukova.isspst;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
+import org.hibernate.HibernateException;
+import org.hibernate.service.UnknownUnwrapTypeException;
+import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider;
+
+public class ClientConnectionPrivider implements MultiTenantConnectionProvider {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2142963179208004018L;
+
+ private DataSource dataSource;
+
+ public ClientConnectionPrivider(DataSource dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public boolean isUnwrappableAs(Class unwrapType) {
+ return ConnectionProvider.class.equals( unwrapType ) || MultiTenantConnectionProvider.class.equals( unwrapType ) || ClientConnectionPrivider.class.isAssignableFrom( unwrapType );
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T unwrap(Class unwrapType) {
+ if ( isUnwrappableAs( unwrapType ) ) {
+ return (T) this;
+ }
+ else {
+ throw new UnknownUnwrapTypeException( unwrapType );
+ }
+ }
+
+ @Override
+ public Connection getAnyConnection() throws SQLException {
+ return dataSource.getConnection();
+ }
+
+ @Override
+ public void releaseAnyConnection(Connection connection) throws SQLException {
+ connection.close();
+ }
+
+ @Override
+ public Connection getConnection(String tenantIdentifier)
+ throws SQLException {
+
+ Connection con = getAnyConnection();
+ try {
+ con.createStatement().execute("SET schema '" + tenantIdentifier + "'");
+ } catch ( SQLException e ) {
+ throw new HibernateException("Could not alter JDBC connection to specified schema [" + tenantIdentifier + "]", e);
+ }
+
+ return con;
+ }
+
+ @Override
+ public void releaseConnection(String tenantIdentifier, Connection connection)
+ throws SQLException {
+ releaseAnyConnection(connection);
+ }
+
+ @Override
+ public boolean supportsAggressiveRelease() {
+ return false;
+ }
+
+}
diff --git a/src/main/java/info/bukova/isspst/ClientResolver.java b/src/main/java/info/bukova/isspst/ClientResolver.java
new file mode 100644
index 00000000..13665048
--- /dev/null
+++ b/src/main/java/info/bukova/isspst/ClientResolver.java
@@ -0,0 +1,35 @@
+package info.bukova.isspst;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class ClientResolver implements CurrentTenantIdentifierResolver {
+
+ @Autowired
+ private HttpServletRequest request;
+ private static final String TOP_DOMAIN = "localhost"; // Bude se tahat z konfigurace...
+
+ @Override
+ public String resolveCurrentTenantIdentifier() {
+ String hostName = request.getServerName();
+ String tenant = "";
+
+ if (hostName.contains(".")) {
+ tenant = hostName.substring(0, hostName.indexOf("." + TOP_DOMAIN));
+ }
+
+ if (tenant.isEmpty()) {
+ tenant = "public";
+ }
+
+ return tenant;
+ }
+
+ @Override
+ public boolean validateExistingCurrentSessions() {
+ return false;
+ }
+
+}
diff --git a/src/main/java/info/bukova/isspst/data/TripRequirement.java b/src/main/java/info/bukova/isspst/data/TripRequirement.java
index e180571f..4d56be85 100644
--- a/src/main/java/info/bukova/isspst/data/TripRequirement.java
+++ b/src/main/java/info/bukova/isspst/data/TripRequirement.java
@@ -26,7 +26,7 @@ public class TripRequirement extends RequirementBase {
private String to;
@Column(name = "TRIP_DATE")
private Date tripDate;
- @Column(name = "END")
+ @Column(name = "TRIP_END")
private String end;
@Column(name = "END_DATE")
private Date endDate;
diff --git a/src/main/java/info/bukova/isspst/data/User.java b/src/main/java/info/bukova/isspst/data/User.java
index 65c75770..ca865b15 100644
--- a/src/main/java/info/bukova/isspst/data/User.java
+++ b/src/main/java/info/bukova/isspst/data/User.java
@@ -17,7 +17,7 @@ import javax.persistence.Table;
import org.springframework.security.core.userdetails.UserDetails;
@Entity
-@Table(name="USER")
+@Table(name="USER_LOGIN")
public class User extends Member implements UserDetails, DataModel {
/**
diff --git a/src/main/webapp/WEB-INF/jdbc.properties b/src/main/webapp/WEB-INF/jdbc.properties
index 4e3ec948..736991db 100644
--- a/src/main/webapp/WEB-INF/jdbc.properties
+++ b/src/main/webapp/WEB-INF/jdbc.properties
@@ -1,5 +1,11 @@
-jdbc.driverClassName=com.mysql.jdbc.Driver
-jdbc.dialect=org.hibernate.dialect.MySQLDialect
-jdbc.databaseurl=jdbc:mysql://127.0.0.1:3306/isspst?characterEncoding=latin2&autoReconnect=true
+#jdbc.driverClassName=com.mysql.jdbc.Driver
+#jdbc.dialect=org.hibernate.dialect.MySQLDialect
+#jdbc.databaseurl=jdbc:mysql://127.0.0.1:3306/isspst?characterEncoding=latin2&autoReconnect=true
+#jdbc.username=isspst
+#jdbc.password=xsacfgd
+
+jdbc.driverClassName=org.postgresql.Driver
+jdbc.dialect=org.hibernate.dialect.PostgreSQLDialect
+jdbc.databaseurl=jdbc:postgresql://127.0.0.1:5432/isspst
jdbc.username=isspst
jdbc.password=xsacfgd
\ No newline at end of file
diff --git a/src/main/webapp/WEB-INF/spring/root-context.xml b/src/main/webapp/WEB-INF/spring/root-context.xml
index 9a4e0675..4e061dc0 100644
--- a/src/main/webapp/WEB-INF/spring/root-context.xml
+++ b/src/main/webapp/WEB-INF/spring/root-context.xml
@@ -50,19 +50,36 @@
classpath:hibernate.cfg.xml
-
- ${jdbc.dialect}
+
+
+
-
+ -->
+
+
+
+
+
+
+
+
+
-
+
+