Add db creation.

This commit is contained in:
Paulo Gustavo Veiga 2023-12-04 20:00:06 -08:00
parent fa06852806
commit e1b517f657
11 changed files with 74 additions and 177 deletions

View File

@ -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;

View File

@ -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

View File

@ -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)

View File

@ -146,7 +146,6 @@
<version>2.7.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
@ -198,101 +197,6 @@
<scope>compile</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>hsqldb</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<driver>org.hsqldb.jdbc.JDBCDriver</driver>
<url>jdbc:hsqldb:file:${project.build.directory}/db/wisemapping</url>
<username>sa</username>
</configuration>
<dependencies>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.7.2</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>drop-schemas</id>
<phase>prepare-package</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<onError>continue</onError>
<orderFile>descending</orderFile>
<fileset>
<basedir>${project.basedir}</basedir>
<includes>
<include>config/database/hsql/drop-schemas.sql</include>
<include>config/database/hsql/create-schemas.sql</include>
<include>config/database/hsql/apopulate-schemas.sql</include>
</includes>
</fileset>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>mysqldb</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.31</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>init-schema</id>
<goals>
<goal>execute</goal>
</goals>
<phase>prepare-package</phase>
</execution>
</executions>
<configuration>
<driver>com.mysql.jdbc.Driver</driver>
<username>root</username>
<password/>
<url>jdbc:mysql://127.0.0.1:3306/?useUnicode=true&amp;characterEncoding=UTF-8</url>
<autocommit>false</autocommit>
<srcFiles>
<srcFile>config/database/mysql/create-database.sql</srcFile>
<srcFile>config/database/mysql/create-schemas.sql</srcFile>
<srcFile>config/database/mysql/apopulate-schemas.sql</srcFile>
</srcFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>

View File

@ -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);
}

View File

@ -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();

View File

@ -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

View File

@ -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();
}

View File

@ -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://<hostname:port>/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