diff --git a/config/database/hsql/drop-schemas.sql b/config/database/hsql/drop-schemas.sql deleted file mode 100644 index 77bf9e7b..00000000 --- a/config/database/hsql/drop-schemas.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS ACCESS_AUDITORY; DROP TABLE IF EXISTS COLLABORATION; DROP TABLE IF EXISTS COLLABORATION_PROPERTIES; DROP TABLE IF EXISTS MINDMAP_HISTORY; DROP TABLE IF EXISTS R_LABEL_MINDMAP; DROP TABLE IF EXISTS LABEL; DROP TABLE IF EXISTS MINDMAP; DROP TABLE IF EXISTS USER; DROP TABLE IF EXISTS COLLABORATOR; COMMIT; \ No newline at end of file diff --git a/wise-webapp/db/wisemapping.properties b/wise-webapp/db/wisemapping.properties new file mode 100644 index 00000000..456f39de --- /dev/null +++ b/wise-webapp/db/wisemapping.properties @@ -0,0 +1,5 @@ +#HSQL Database Engine 2.7.1 +#Mon Nov 27 22:17:59 PST 2023 +modified=yes +tx_timestamp=270 +version=2.7.1 diff --git a/wise-webapp/db/wisemapping.script b/wise-webapp/db/wisemapping.script new file mode 100644 index 00000000..14464be6 --- /dev/null +++ b/wise-webapp/db/wisemapping.script @@ -0,0 +1,46 @@ +SET DATABASE UNIQUE NAME HSQLDB8C147822D0 +SET DATABASE DEFAULT RESULT MEMORY ROWS 0 +SET DATABASE EVENT LOG LEVEL 0 +SET DATABASE TRANSACTION CONTROL LOCKS +SET DATABASE DEFAULT ISOLATION LEVEL READ COMMITTED +SET DATABASE TRANSACTION ROLLBACK ON CONFLICT TRUE +SET DATABASE TEXT TABLE DEFAULTS '' +SET DATABASE SQL NAMES FALSE +SET DATABASE SQL RESTRICT EXEC FALSE +SET DATABASE SQL REFERENCES FALSE +SET DATABASE SQL SIZE TRUE +SET DATABASE SQL TYPES FALSE +SET DATABASE SQL TDC DELETE TRUE +SET DATABASE SQL TDC UPDATE TRUE +SET DATABASE SQL SYS INDEX NAMES TRUE +SET DATABASE SQL CONCAT NULLS TRUE +SET DATABASE SQL UNIQUE NULLS TRUE +SET DATABASE SQL CONVERT TRUNCATE TRUE +SET DATABASE SQL AVG SCALE 0 +SET DATABASE SQL DOUBLE NAN TRUE +SET FILES WRITE DELAY 500 MILLIS +SET FILES BACKUP INCREMENT TRUE +SET FILES CACHE SIZE 10000 +SET FILES CACHE ROWS 50000 +SET FILES SCALE 32 +SET FILES LOB SCALE 32 +SET FILES DEFRAG 0 +SET FILES NIO TRUE +SET FILES NIO SIZE 256 +SET FILES LOG TRUE +SET FILES LOG SIZE 50 +SET FILES CHECK 270 +SET DATABASE COLLATION "SQL_TEXT" PAD SPACE +CREATE USER SA PASSWORD DIGEST 'd41d8cd98f00b204e9800998ecf8427e' +ALTER USER SA SET LOCAL TRUE +CREATE SCHEMA PUBLIC AUTHORIZATION DBA +ALTER SEQUENCE SYSTEM_LOBS.LOB_ID RESTART WITH 1 +SET DATABASE DEFAULT INITIAL SCHEMA PUBLIC +GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.CARDINAL_NUMBER TO PUBLIC +GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.YES_OR_NO TO PUBLIC +GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.CHARACTER_DATA TO PUBLIC +GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.SQL_IDENTIFIER TO PUBLIC +GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.TIME_STAMP TO PUBLIC +GRANT DBA TO SA +SET SCHEMA SYSTEM_LOBS +INSERT INTO BLOCKS VALUES(0,2147483647,0) diff --git a/wise-webapp/pom.xml b/wise-webapp/pom.xml index 7837066a..95de836d 100644 --- a/wise-webapp/pom.xml +++ b/wise-webapp/pom.xml @@ -146,7 +146,6 @@ 2.7.1 runtime - com.fasterxml.jackson.core jackson-databind @@ -198,101 +197,6 @@ compile - - - hsqldb - - true - - - - - org.codehaus.mojo - sql-maven-plugin - 1.5 - - - org.hsqldb.jdbc.JDBCDriver - jdbc:hsqldb:file:${project.build.directory}/db/wisemapping - sa - - - - - org.hsqldb - hsqldb - 2.7.2 - - - - - drop-schemas - prepare-package - - execute - - - continue - descending - - ${project.basedir} - - config/database/hsql/drop-schemas.sql - config/database/hsql/create-schemas.sql - config/database/hsql/apopulate-schemas.sql - - - - - - - - - - - mysqldb - - false - - - - - org.codehaus.mojo - sql-maven-plugin - 1.5 - - - mysql - mysql-connector-java - 8.0.31 - - - - - init-schema - - execute - - prepare-package - - - - com.mysql.jdbc.Driver - root - - jdbc:mysql://127.0.0.1:3306/?useUnicode=true&characterEncoding=UTF-8 - false - - config/database/mysql/create-database.sql - config/database/mysql/create-schemas.sql - config/database/mysql/apopulate-schemas.sql - - - - - - - diff --git a/wise-webapp/src/main/java/com/wisemapping/config/Application.java b/wise-webapp/src/main/java/com/wisemapping/config/Application.java index cb986831..daa5b5e1 100644 --- a/wise-webapp/src/main/java/com/wisemapping/config/Application.java +++ b/wise-webapp/src/main/java/com/wisemapping/config/Application.java @@ -14,15 +14,15 @@ import org.springframework.security.web.firewall.StrictHttpFirewall; @SpringBootApplication @ImportResource(value = {"classpath:spring/wisemapping-service.xml"}) -@ComponentScan({"com.wisemapping.security", "com.wisemapping.service", "com.wisemapping.dao", "com.wisemapping.util"}) +@ComponentScan({"com.wisemapping.security", "com.wisemapping.service", "com.wisemapping.dao", "com.wisemapping.util", "com.wisemapping.model"}) public class Application { public static void main(String[] args) { new SpringApplicationBuilder() - .parent(Application.class, HibernateConfig.class, MethodSecurityConfig.class).web(WebApplicationType.NONE) - .child(MvcAppConfig.class, MvcSecurityConfig.class, ServletConfig.class).web(WebApplicationType.SERVLET) - .sibling(RestAppConfig.class).web(WebApplicationType.SERVLET) + .parent(Application.class, MethodSecurityConfig.class).web(WebApplicationType.NONE) + .child(MvcAppConfig.class, MvcSecurityConfig.class, HibernateConfig.class, ServletConfig.class).web(WebApplicationType.SERVLET) +// .sibling(RestAppConfig.class).web(WebApplicationType.SERVLET) .run(args); } diff --git a/wise-webapp/src/main/java/com/wisemapping/config/HibernateConfig.java b/wise-webapp/src/main/java/com/wisemapping/config/HibernateConfig.java index 29bf47d1..94982292 100644 --- a/wise-webapp/src/main/java/com/wisemapping/config/HibernateConfig.java +++ b/wise-webapp/src/main/java/com/wisemapping/config/HibernateConfig.java @@ -8,37 +8,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @EnableTransactionManagement @EnableJpaRepositories("com.wisemapping.model") public class HibernateConfig { -// @Value("${database.hibernate.dialect}") -// private String dbDialect; -// -// @Value("${database.driver}") -// private String dbDriver; -// -// @Value("${database.url}") -// private String dbUrl; -// -// @Value("${database.username}") -// private String dbUsername; -// @Value("${database.password}") -// private String dbPassword; -// -// @Value("${database.validation.enabled:true}") -// private boolean dbSetOnBorrow; -// -// @Value("${database.validation.query:SELECT 1}") -// private String dbValQuery; -// @Bean -// public LocalSessionFactoryBean sessionFactory() { -// final LocalSessionFactoryBean result = new LocalSessionFactoryBean(); -// result.setPackagesToScan("com.wisemapping.model"); -// result.setDataSource(dataSource()); -// result.setHibernateProperties(hibernateProperties()); -// -// return result; -// } -// -// // @Bean // public HibernateTransactionManager hibernateTransactionManager() { // final HibernateTransactionManager result = new HibernateTransactionManager(); diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/LabelManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/LabelManagerImpl.java index 92f39492..733831bc 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/LabelManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/LabelManagerImpl.java @@ -25,6 +25,7 @@ import org.hibernate.SessionFactory; import org.hibernate.query.SelectionQuery; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import java.util.List; @@ -32,7 +33,7 @@ import java.util.List; @Repository("labelManager") public class LabelManagerImpl implements LabelManager { - @Resource + @Autowired private SessionFactory sessionFactory; @Override diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java index 78c013b6..059f0e68 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java @@ -22,6 +22,7 @@ import com.wisemapping.model.*; import com.wisemapping.security.DefaultPasswordEncoderFactories; import com.wisemapping.security.LegacyPasswordEncoder; import jakarta.annotation.Resource; +import jakarta.persistence.EntityManagerFactory; import org.hibernate.ObjectNotFoundException; import org.hibernate.Session; import org.hibernate.SessionFactory; @@ -39,8 +40,8 @@ import java.util.concurrent.CopyOnWriteArraySet; @Repository public class UserManagerImpl implements UserManager { -// @Autowired - private SessionFactory sessionFactory; + @Autowired + private EntityManagerFactory entityManagerFactory; @Autowired private PasswordEncoder passwordEncoder; @@ -54,7 +55,7 @@ public class UserManagerImpl } private Session getSession() { - return sessionFactory.getCurrentSession(); + return entityManagerFactory.unwrap(SessionFactory.class).getCurrentSession(); } diff --git a/wise-webapp/src/main/resources/application.properties b/wise-webapp/src/main/resources/application.properties index 6b3f60ee..96234d5f 100755 --- a/wise-webapp/src/main/resources/application.properties +++ b/wise-webapp/src/main/resources/application.properties @@ -1,37 +1,17 @@ ################################################################################## -# Database Configuration +Springboot Common ################################################################################## -# MySQL 5.X configuration properties -#database.url=jdbc:mysql://localhost/wisemapping?useUnicode=yes&characterEncoding=UTF-8 -#database.driver=com.mysql.cj.jdbc.Driver -#database.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect -#database.username=wisemapping -#database.password=password -#database.validation.enabled=true -#database.validation.query=SELECT 1 +spring.datasource.initialize=true +spring.jpa.open-in-view=true +#spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext +spring.sql.init.mode=always +spring.main.allow-circular-references=true -## PostgreSQL configuration properties -#database.url=jdbc:postgresql:///wisemapping -#database.driver=org.postgresql.Driver -#database.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect -#database.username=wisemapping -#database.password=password -#database.validation.enabled=true -#database.validation.query= -#database.validation.enabled=false +spring.jpa.properties.hibernate.current_session_context_class=thread +spring.jpa.properties.hibernate.format_sql=true - -##database.base.url=/Users/veigap/repos/wisemapping-open-source/wise-webapp -### HSQL Configuration properties -##database.url=jdbc:hsqldb:file:${database.base.url}/db/wisemapping -##database.driver=org.hsqldb.jdbc.JDBCDriver -##database.hibernate.dialect=org.hibernate.dialect.HSQLDialect -# -#database.username=sa -#database.password= -#database.validation.enabled=false -#database.validation.query= +logging.level.root=TRACE ################################################################################## # Mail configuration. Must be configured to enable user registration confirmation. @@ -155,8 +135,6 @@ security.oauth2.google.userinfoUrl=https://www.googleapis.com/oauth2/v3/userinfo security.oauth2.google.url=https//review - - ####################################################################################### # User Account filtering policies ####################################################################################### @@ -165,20 +143,13 @@ security.oauth2.google.url=https//review #accounts.exclusion.domain= -####################################################################################### -# Spring related configurations -####################################################################################### -spring.main.allow-circular-references=true +################################################################################## +# Database Configuration +################################################################################## -database.base.url=/Users/veigap/repos/wisemapping-open-source/wise-webapp +database.base.url=/Users/veigap/ spring.datasource.url=jdbc:hsqldb:file:${database.base.url}/db/wisemapping spring.datasource.username=sa spring.datasource.password= spring.datasource.driver-class-name = org.hsqldb.jdbc.JDBCDriver spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HSQLDialect -spring.jpa.open-in-view=true -spring.h2.console.enabled=true -spring.h2.console.path=/h2-ui - - -logging.level.root=DEBUG diff --git a/config/database/hsql/apopulate-schemas.sql b/wise-webapp/src/main/resources/data-hsqldb.sql similarity index 100% rename from config/database/hsql/apopulate-schemas.sql rename to wise-webapp/src/main/resources/data-hsqldb.sql diff --git a/config/database/hsql/create-schemas.sql b/wise-webapp/src/main/resources/schema-hsqldb.sql similarity index 100% rename from config/database/hsql/create-schemas.sql rename to wise-webapp/src/main/resources/schema-hsqldb.sql