refactor(module-web,module-ejb): refactor code

This commit is contained in:
Damian Pierzchalski 2018-12-17 15:39:30 +01:00
parent 4cc53430d3
commit fa9942c031
18 changed files with 175 additions and 148 deletions

52
.gitignore vendored
View File

@ -1,50 +1,2 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
.classpath
.project
.settings
~*
*.idea
*.iml
MANIFEST.MF
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
*.sqlite
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Directory #
#############
bin/
out/
target/
.vscode/launch.json
/module-ejb/target/
/module-web/target/

50
_gitignore Normal file
View File

@ -0,0 +1,50 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
.classpath
.project
.settings
~*
*.idea
*.iml
MANIFEST.MF
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
*.sqlite
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Directory #
#############
bin/
out/
target/
.vscode/launch.json

View File

@ -1,21 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>app</artifactId>
<groupId>pl.myboardgames</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>module-ejb</artifactId>
<packaging>ejb</packaging>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
</dependency>
</dependencies>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>app</artifactId>
<groupId>pl.myboardgames</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>module-ejb</artifactId>
<packaging>ejb</packaging>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +1,4 @@
package pl.myboardgames.boardgame;
package pl.myboardgames.boardgame.db;
import java.util.HashSet;
import java.util.Set;
@ -8,6 +8,8 @@ import javax.persistence.EntityNotFoundException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import pl.myboardgames.boardgame.model.BoardGameEntity;
@Stateless
public class BoardGameDao {

View File

@ -1,4 +1,4 @@
package pl.myboardgames.boardgame;
package pl.myboardgames.boardgame.model;
import java.util.HashSet;
import java.util.Set;
@ -13,7 +13,7 @@ import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import pl.myboardgames.user.UserEntity;
import pl.myboardgames.user.model.UserEntity;
@Entity
@Table(name = "boardgames")

View File

@ -1,7 +1,6 @@
package pl.myboardgames.user;
package pl.myboardgames.user.db;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
@ -9,7 +8,8 @@ import javax.persistence.EntityNotFoundException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import pl.myboardgames.boardgame.BoardGameEntity;
import pl.myboardgames.boardgame.model.BoardGameEntity;
import pl.myboardgames.user.model.UserEntity;
@Stateless
public class UserDao {

View File

@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pl.myboardgames.user;
package pl.myboardgames.user.model;
import java.util.HashSet;
import java.util.Set;
@ -15,7 +15,7 @@ import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import pl.myboardgames.boardgame.BoardGameEntity;
import pl.myboardgames.boardgame.model.BoardGameEntity;
/**
*

View File

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>ide</org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>
</properties>
</project-shared-configuration>
-->
<org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>ide</org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>
</properties>
</project-shared-configuration>

View File

@ -1,28 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>app</artifactId>
<groupId>pl.myboardgames</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>module-web</artifactId>
<packaging>war</packaging>
<name>module-web</name>
<dependencies>
<dependency>
<groupId>pl.myboardgames</groupId>
<artifactId>module-ejb</artifactId>
<type>ejb</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
</dependency>
</dependencies>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>app</artifactId>
<groupId>pl.myboardgames</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>module-web</artifactId>
<packaging>war</packaging>
<name>module-web</name>
<dependencies>
<dependency>
<groupId>pl.myboardgames</groupId>
<artifactId>module-ejb</artifactId>
<type>ejb</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,18 +1,18 @@
package pl.myboardgames;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
/**
* A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6
* "no XML" approach to activating JAX-RS.
*
* <p>
* Resources are served relative to the servlet path specified in the {@link ApplicationPath}
* annotation.
* </p>
*/
@ApplicationPath("/api/v1")
public class JaxRsActivator extends Application {
/* class body intentionally left blank */
}
package pl.myboardgames;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
/**
* A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6
* "no XML" approach to activating JAX-RS.
*
* <p>
* Resources are served relative to the servlet path specified in the {@link ApplicationPath}
* annotation.
* </p>
*/
@ApplicationPath("/api/v1")
public class JaxRsActivator extends Application {
/* class body intentionally left blank */
}

View File

@ -3,12 +3,14 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pl.myboardgames.boardgame;
package pl.myboardgames.boardgame.dto;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import pl.myboardgames.user.UserShortDto;
import pl.myboardgames.boardgame.model.BoardGameEntity;
import pl.myboardgames.user.dto.UserShortDto;
/**

View File

@ -3,13 +3,15 @@
* To change ret template file, choose Tools | Templates
* and open the template in the editor.
*/
package pl.myboardgames.boardgame;
package pl.myboardgames.boardgame.dto;
import pl.myboardgames.boardgame.model.BoardGameEntity;
/**
*
* @author Nao
*/
class BoardGameMapper {
public class BoardGameMapper {
public BoardGameMapper() {
}

View File

@ -3,7 +3,9 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pl.myboardgames.boardgame;
package pl.myboardgames.boardgame.dto;
import pl.myboardgames.boardgame.model.BoardGameEntity;
/**
*

View File

@ -1,4 +1,4 @@
package pl.myboardgames.boardgame;
package pl.myboardgames.boardgame.resources;
import java.util.stream.Collectors;
import javax.ejb.EJB;
@ -13,9 +13,15 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import pl.myboardgames.boardgame.db.BoardGameDao;
import pl.myboardgames.boardgame.dto.BoardGameDto;
import pl.myboardgames.boardgame.dto.BoardGameMapper;
import pl.myboardgames.boardgame.dto.BoardGameShortDto;
import pl.myboardgames.boardgame.model.BoardGameEntity;
@Path("/boardgame")
@RequestScoped
public class BoardGameController {
public class BoardGameResource {
@EJB
BoardGameDao boardGameDatabase;

View File

@ -3,13 +3,14 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pl.myboardgames.user;
package pl.myboardgames.user.dto;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import pl.myboardgames.boardgame.BoardGameShortDto;
import pl.myboardgames.boardgame.dto.BoardGameShortDto;
import pl.myboardgames.user.model.UserEntity;
/**
*

View File

@ -3,13 +3,15 @@
* To change ret template file, choose Tools | Templates
* and open the template in the editor.
*/
package pl.myboardgames.user;
package pl.myboardgames.user.dto;
import pl.myboardgames.user.model.UserEntity;
/**
*
* @author Nao
*/
class UserMapper {
public class UserMapper {
public UserMapper() {
}

View File

@ -3,7 +3,9 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pl.myboardgames.user;
package pl.myboardgames.user.dto;
import pl.myboardgames.user.model.UserEntity;
/**
*

View File

@ -1,4 +1,4 @@
package pl.myboardgames.user;
package pl.myboardgames.user.resources;
import java.util.stream.Collectors;
import javax.ejb.EJB;
@ -12,11 +12,17 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import pl.myboardgames.boardgame.BoardGameShortDto;
import pl.myboardgames.boardgame.dto.BoardGameShortDto;
import pl.myboardgames.user.db.UserDao;
import pl.myboardgames.user.dto.UserDto;
import pl.myboardgames.user.dto.UserMapper;
import pl.myboardgames.user.dto.UserShortDto;
import pl.myboardgames.user.model.UserEntity;
@Path("/user")
@RequestScoped
public class UserController {
public class UserResource {
@EJB
UserDao userDatabase;