-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4eb3881
commit 06a9099
Showing
21 changed files
with
18,114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,6 +134,7 @@ jobs: | |
- oauth2app | ||
- mysqlapp | ||
- mariadbapp | ||
- mssqlapp | ||
- flywayapp | ||
- undertowapp | ||
- eurekaapp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
.../lite/generator/server/springboot/database/mssql/application/MssqlApplicationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package tech.jhipster.lite.generator.server.springboot.database.mssql.application; | ||
|
||
import org.springframework.stereotype.Service; | ||
import tech.jhipster.lite.generator.project.domain.Project; | ||
import tech.jhipster.lite.generator.server.springboot.database.mssql.domain.MssqlService; | ||
|
||
@Service | ||
public class MssqlApplicationService { | ||
|
||
private final MssqlService mssqlService; | ||
|
||
public MssqlApplicationService(MssqlService mssqlService) { | ||
this.mssqlService = mssqlService; | ||
} | ||
|
||
public void init(Project project) { | ||
mssqlService.init(project); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...main/java/tech/jhipster/lite/generator/server/springboot/database/mssql/domain/Mssql.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package tech.jhipster.lite.generator.server.springboot.database.mssql.domain; | ||
|
||
import java.util.Map; | ||
import java.util.TreeMap; | ||
import tech.jhipster.lite.generator.buildtool.generic.domain.Dependency; | ||
|
||
public class Mssql { | ||
|
||
public static final String MSSQL_DOCKER_IMAGE_NAME = "mcr.microsoft.com/mssql/server"; | ||
|
||
private Mssql() {} | ||
|
||
public static String getDockerImageName() { | ||
return MSSQL_DOCKER_IMAGE_NAME; | ||
} | ||
|
||
public static Dependency driver() { | ||
return Dependency.builder().groupId("com.microsoft.sqlserver").artifactId("mssql-jdbc").build(); | ||
} | ||
|
||
public static Map<String, Object> springProperties(String baseName) { | ||
TreeMap<String, Object> result = new TreeMap<>(); | ||
result.put("spring.datasource.url", "jdbc:sqlserver://msmssql-mssql:1433;database=" + baseName); | ||
result.put("spring.datasource.driver-class-name", "com.microsoft.sqlserver.jdbc.SQLServerDriver"); | ||
|
||
result.put("spring.jpa.hibernate.ddl-auto", "update"); | ||
result.put("spring.datasource.username", "root"); | ||
result.put("spring.jpa.properties.hibernate.format_sql", true); | ||
result.put("spring.jpa.properties.hibernate.dialect", "org.hibernate.dialect. org.hibernate.dialect.SQLServer2008Dialect"); | ||
return result; | ||
} | ||
|
||
public static Map<String, Object> springPropertiesForTest(String baseName) { | ||
TreeMap<String, Object> result = new TreeMap<>(); | ||
result.put("spring.datasource.driver-class-name", "org.testcontainers.jdbc.ContainerDatabaseDriver"); | ||
result.put("spring.datasource.url", "jdbc:tc:" + Mssql.getDockerImageName() + ":///" + baseName); | ||
result.put("spring.datasource.username", baseName); | ||
result.put("spring.datasource.password", ""); | ||
result.put("spring.datasource.hikari.maximum-pool-size", 2); | ||
return result; | ||
} | ||
} |
118 changes: 118 additions & 0 deletions
118
...h/jhipster/lite/generator/server/springboot/database/mssql/domain/MssqlDomainService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package tech.jhipster.lite.generator.server.springboot.database.mssql.domain; | ||
|
||
import static tech.jhipster.lite.generator.project.domain.DefaultConfig.*; | ||
|
||
import tech.jhipster.lite.error.domain.GeneratorException; | ||
import tech.jhipster.lite.generator.buildtool.generic.domain.BuildToolService; | ||
import tech.jhipster.lite.generator.docker.domain.DockerService; | ||
import tech.jhipster.lite.generator.project.domain.DatabaseType; | ||
import tech.jhipster.lite.generator.project.domain.Project; | ||
import tech.jhipster.lite.generator.project.domain.ProjectRepository; | ||
import tech.jhipster.lite.generator.server.springboot.common.domain.Level; | ||
import tech.jhipster.lite.generator.server.springboot.common.domain.SpringBootCommonService; | ||
import tech.jhipster.lite.generator.server.springboot.database.sqlcommon.domain.SQLCommonService; | ||
|
||
public class MssqlDomainService implements MssqlService { | ||
|
||
public static final String SOURCE = "server/springboot/database/mongodb"; | ||
|
||
private final ProjectRepository projectRepository; | ||
private final BuildToolService buildToolService; | ||
private final SpringBootCommonService springBootCommonService; | ||
private final SQLCommonService sqlCommonService; | ||
private final DockerService dockerService; | ||
|
||
public MssqlDomainService( | ||
ProjectRepository projectRepository, | ||
BuildToolService buildToolService, | ||
SpringBootCommonService springBootCommonService, | ||
SQLCommonService sqlCommonService, | ||
DockerService dockerService | ||
) { | ||
this.projectRepository = projectRepository; | ||
this.buildToolService = buildToolService; | ||
this.springBootCommonService = springBootCommonService; | ||
this.sqlCommonService = sqlCommonService; | ||
this.dockerService = dockerService; | ||
} | ||
|
||
@Override | ||
public void init(Project project) { | ||
addSpringData(project); | ||
addDriver(project); | ||
addDockerCompose(project); | ||
addJavaFiles(project); | ||
addProperties(project); | ||
addHibernateCore(project); | ||
addTestcontainers(project); | ||
addLoggerInConfiguration(project); | ||
} | ||
|
||
@Override | ||
public void addSpringData(Project project) { | ||
sqlCommonService.addSpringDataJpa(project); | ||
} | ||
|
||
@Override | ||
public void addDriver(Project project) { | ||
buildToolService.addDependency(project, Mssql.driver()); | ||
} | ||
|
||
@Override | ||
public void addDockerCompose(Project project) { | ||
project.addDefaultConfig(BASE_NAME); | ||
|
||
dockerService | ||
.getImageNameWithVersion(Mssql.getDockerImageName()) | ||
.ifPresentOrElse( | ||
imageName -> project.addConfig("mssqlDockerImage", imageName), | ||
() -> { | ||
throw new GeneratorException("Version not found for docker image: " + Mssql.getDockerImageName()); | ||
} | ||
); | ||
sqlCommonService.addDockerComposeTemplate(project, DatabaseType.MSSQL.id()); | ||
} | ||
|
||
@Override | ||
public void addJavaFiles(Project project) { | ||
sqlCommonService.addJavaFiles(project, DatabaseType.MSSQL.id()); | ||
} | ||
|
||
@Override | ||
public void addProperties(Project project) { | ||
springBootCommonService.addPropertiesComment(project, "Database Configuration"); | ||
|
||
Mssql | ||
.springProperties(project.getBaseName().orElse("jhipster")) | ||
.forEach((k, v) -> springBootCommonService.addProperties(project, k, v)); | ||
springBootCommonService.addPropertiesNewLine(project); | ||
} | ||
|
||
private void addTestcontainers(Project project) { | ||
this.sqlCommonService.addTestcontainers( | ||
project, | ||
DatabaseType.MSSQL.id(), | ||
Mssql.springPropertiesForTest(project.getBaseName().orElse("jhipster")) | ||
); | ||
} | ||
|
||
@Override | ||
public void addHibernateCore(Project project) { | ||
sqlCommonService.addHibernateCore(project); | ||
} | ||
|
||
@Override | ||
public void addLoggerInConfiguration(Project project) { | ||
sqlCommonService.addLoggers(project); | ||
addLogger(project, "org.reflections", Level.WARN); | ||
addLogger(project, Mssql.driver().getGroupId(), Level.WARN); | ||
|
||
springBootCommonService.addLoggerTest(project, "com.github.dockerjava", Level.WARN); | ||
springBootCommonService.addLoggerTest(project, "org.testcontainers", Level.WARN); | ||
} | ||
|
||
public void addLogger(Project project, String packageName, Level level) { | ||
springBootCommonService.addLogger(project, packageName, level); | ||
springBootCommonService.addLoggerTest(project, packageName, level); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...va/tech/jhipster/lite/generator/server/springboot/database/mssql/domain/MssqlService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package tech.jhipster.lite.generator.server.springboot.database.mssql.domain; | ||
|
||
import tech.jhipster.lite.generator.project.domain.Project; | ||
|
||
public interface MssqlService { | ||
void init(Project project); | ||
|
||
void addSpringData(Project project); | ||
void addDriver(Project project); | ||
void addHibernateCore(Project project); | ||
void addDockerCompose(Project project); | ||
void addJavaFiles(Project project); | ||
void addProperties(Project project); | ||
void addLoggerInConfiguration(Project project); | ||
} |
40 changes: 40 additions & 0 deletions
40
...erator/server/springboot/database/mssql/infrastructure/config/MssqlBeanConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package tech.jhipster.lite.generator.server.springboot.database.mssql.infrastructure.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import tech.jhipster.lite.generator.buildtool.generic.domain.BuildToolService; | ||
import tech.jhipster.lite.generator.docker.domain.DockerService; | ||
import tech.jhipster.lite.generator.project.domain.ProjectRepository; | ||
import tech.jhipster.lite.generator.server.springboot.common.domain.SpringBootCommonService; | ||
import tech.jhipster.lite.generator.server.springboot.database.mssql.domain.MssqlDomainService; | ||
import tech.jhipster.lite.generator.server.springboot.database.mssql.domain.MssqlService; | ||
import tech.jhipster.lite.generator.server.springboot.database.sqlcommon.domain.SQLCommonService; | ||
|
||
@Configuration | ||
public class MssqlBeanConfiguration { | ||
|
||
private final ProjectRepository projectRepository; | ||
private final BuildToolService buildToolService; | ||
private final SpringBootCommonService springBootCommonService; | ||
private final SQLCommonService sqlCommonService; | ||
private final DockerService dockerService; | ||
|
||
public MssqlBeanConfiguration( | ||
ProjectRepository projectRepository, | ||
BuildToolService buildToolService, | ||
SpringBootCommonService springBootCommonService, | ||
SQLCommonService sqlCommonService, | ||
DockerService dockerService | ||
) { | ||
this.projectRepository = projectRepository; | ||
this.buildToolService = buildToolService; | ||
this.springBootCommonService = springBootCommonService; | ||
this.sqlCommonService = sqlCommonService; | ||
this.dockerService = dockerService; | ||
} | ||
|
||
@Bean | ||
public MssqlService mssqlService() { | ||
return new MssqlDomainService(projectRepository, buildToolService, springBootCommonService, sqlCommonService, dockerService); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...generator/server/springboot/database/mssql/infrastructure/primary/rest/MssqlResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package tech.jhipster.lite.generator.server.springboot.database.mssql.infrastructure.primary.rest; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import tech.jhipster.lite.generator.project.domain.GeneratorAction; | ||
import tech.jhipster.lite.generator.project.domain.Project; | ||
import tech.jhipster.lite.generator.project.infrastructure.primary.dto.ProjectDTO; | ||
import tech.jhipster.lite.generator.server.springboot.database.mssql.application.MssqlApplicationService; | ||
import tech.jhipster.lite.technical.infrastructure.primary.annotation.GeneratorStep; | ||
|
||
@RestController | ||
@RequestMapping("/api/servers/spring-boot/databases/mssql") | ||
@Tag(name = "Spring Boot - Database") | ||
class MssqlResource { | ||
|
||
private final MssqlApplicationService mongodbApplicationService; | ||
|
||
public MssqlResource(MssqlApplicationService mongodbApplicationService) { | ||
this.mongodbApplicationService = mongodbApplicationService; | ||
} | ||
|
||
@Operation(summary = "Add MSSQL drivers and dependencies, with testcontainers") | ||
@ApiResponse(responseCode = "500", description = "An error occurred while adding MSSQL") | ||
@PostMapping | ||
@GeneratorStep(id = GeneratorAction.MSSQL) | ||
public void init(@RequestBody ProjectDTO projectDTO) { | ||
Project project = ProjectDTO.toProject(projectDTO); | ||
mongodbApplicationService.init(project); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.