Skip to content

Commit

Permalink
feat: ajustes devido ao db postgres #64
Browse files Browse the repository at this point in the history
  • Loading branch information
tacianosilva committed May 1, 2023
1 parent b6f51ce commit a5beda7
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 46 deletions.
65 changes: 31 additions & 34 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.11</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<groupId>br.ufrn.dct</groupId>
<artifactId>apf-bsi</artifactId>
<version>0.0.1-SNAPSHOT</version>
Expand Down Expand Up @@ -44,7 +50,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
<java.version>17</java.version>
<sonar.organization>tacianosilva-github</sonar.organization>
<sonar.language>java</sonar.language>
<sonar.java.source>java</sonar.java.source>
Expand All @@ -54,78 +60,76 @@
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
<version>2.1.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.1.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.1.5.RELEASE</version>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.1.5.RELEASE</version>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>2.1.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.5.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>2.1.5.RELEASE</version>
<optional>true</optional>
</dependency>

<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.5.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.1.5.RELEASE</version>
<scope>test</scope>
<version>42.6.0</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.196</version>
<scope>test</scope>
</dependency>
<dependency>
<!-- dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.21</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
<version>1.9.22</version>
</dependency -->

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.13.1</version>
<version>6.14.3</version>
<scope>test</scope>
</dependency>

Expand All @@ -135,16 +139,10 @@
<version>2.3.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>2.1.5.RELEASE</version>
</dependency>

<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>2.3.4</version>
<version>3.1.1</version>
</dependency>
</dependencies>

Expand All @@ -162,7 +160,6 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.5.RELEASE</version>
<executions>
<execution>
<goals>
Expand All @@ -179,7 +176,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<version>0.8.10</version>
<executions>
<execution>
<goals>
Expand Down Expand Up @@ -294,7 +291,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<version>0.8.10</version>
</plugin>
</plugins>
</reporting>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/br/ufrn/dct/apf/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.springframework.data.annotation.Transient;

@Entity
@Table(name = "user")
@Table(name = "users")
public class User implements Serializable {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@Repository("projectRepository")
public interface ProjectRepository extends JpaRepository<Project, Long> {

@Query(value = "SELECT * FROM apf.project p, apf.member m where p.project_id = m.project_id and m.user_id = :userId", nativeQuery=true)
@Query(value = "SELECT * FROM project p, member m where p.project_id = m.project_id and m.user_id = :userId", nativeQuery=true)
List<Project> findByUserId(@Param("userId") Long userId);

List<Project> findByNameContaining(String name);
Expand Down
25 changes: 15 additions & 10 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@
# = DATA SOURCE
# ===============================
spring.datasource.url=jdbc:postgresql://localhost:5432/apf_db
spring.datasource.name=apf_db
spring.datasource.username=apf_user
spring.datasource.password=12345
spring.datasource.testWhileIdle=true
spring.datasource.validationQuery=SELECT 1
spring.datasource.driverclassname=org.postgresql.Driver
spring.datasource.continueOnError=true
spring.datasource.driver-class-name=org.postgresql.Driver
spring.data.jpa.repositories.bootstrap-mode=default

# ===============================
# = JPA / HIBERNATE
# ===============================
spring.jpa.properties.hibernate.default_schema=apf
# spring.jpa.properties.hibernate.default_schema=apf
spring.jpa.show-sql=true
#spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.defer-datasource-initialization=true
spring.sql.init.continue-on-error=true

spring.jpa.hibernate.ddl-auto=create
#spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl
spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
Expand All @@ -27,6 +29,9 @@ logging.level.br.ufrn.dct.apf=DEBUG
#logging.level.org.hibernate.SQL=DEBUG
#logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE

spring.jpa.properties.hibernate.globally_quoted_identifiers=true
spring.jpa.properties.hibernate.globally_quoted_identifiers_skip_column_definitions = true

# ===============================
# = Thymeleaf configurations
# ===============================
Expand All @@ -40,15 +45,15 @@ spring.thymeleaf.cache=false
# Context path of the application.
server.servlet.context-path=/apf
# Display name of the application.
server.display-name=Analisador de Pontos de Função
server.servlet.application-display-name=Analisador de Pontos de Função
# Define server port.
server.port=8080

# ==============================================================
# = Spring Security / Queries for AuthenticationManagerBuilder
# ==============================================================
spring.queries.users-query=select email, password, active from apf.user where email=?
spring.queries.roles-query=select u.email, r.role_name from apf.user u inner join apf.user_role ur on(u.user_id=ur.user_id) inner join apf.role r on(ur.role_id=r.role_id) where u.email=?
spring.queries.users-query=select email, password, active from users where email=?
spring.queries.roles-query=select u.email, r.role_name from users u inner join user_role ur on(u.user_id=ur.user_id) inner join role r on(ur.role_id=r.role_id) where u.email=?

# =============================================================
# = Spring General
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
INSERT INTO role VALUES (1,'ADMIN');
INSERT INTO role VALUES (2,'USER');

INSERT INTO attribution VALUES (1,'PROJECT MANAGER');
INSERT INTO attribution VALUES (2,'PROJECT MEMBER');

0 comments on commit a5beda7

Please sign in to comment.