Skip to content

Commit

Permalink
Merge pull request #20 from jhipster/master
Browse files Browse the repository at this point in the history
Update from upstream
  • Loading branch information
inngvar authored Sep 17, 2020
2 parents e49444f + 3fe6ed6 commit d02ac44
Show file tree
Hide file tree
Showing 18 changed files with 453 additions and 12 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ jhipster -d --blueprint quarkus
✅ JDL import - `jhipster --blueprints quarkus import-jdl sample.jh`
# Contributors ✨
# ❤️ for community
Thanks goes to these wonderful people:
<table><tr><td align="center"><a href="https://github.com/danielpetisme"><img src="https://avatars3.githubusercontent.com/u/593564?s=400&v=4" width="100px;" alt="Daniel Petisme (founder stream lead)"/><br/><sub><b>Daniel Petisme</b><br/><b>(founder stream lead)</b></sub></a></td><td align="center"><a href="https://github.com/amanganiello90"><img src="https://avatars3.githubusercontent.com/u/20536757?s=400&v=4" width="100px;" alt="Angelo Manganiello"/><br /><sub><b>Angelo Manganiello</b></sub></a></td></tr></table>
Interested in contributing?
Check out [JHipster contributing guide](https://github.com/jhipster/generator-jhipster/blob/master/CONTRIBUTING.md) to get started.
# License
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import java.time.Instant;
<%_ } _%>
<%_ if (fieldsContainLocalDate) { _%>
import java.time.LocalDate;
import <%= packageName %>.config.Constants;
import javax.json.bind.annotation.JsonbDateFormat;
<%_ } _%>
<%_ if (fieldsContainZonedDateTime) { _%>
import java.time.ZonedDateTime;
Expand Down Expand Up @@ -118,6 +120,9 @@ public class <%= asDto(entityClass) %> implements Serializable {
<%_ } _%>
<%_ if (fieldType === 'byte[]' && databaseType === 'sql') { _%>
@Lob
<%_ } _%>
<%_ if (fieldType === 'LocalDate') { _%>
@JsonbDateFormat(value = Constants.LOCAL_DATE_FORMAT)
<%_ } _%>
<%_ if (fieldTypeBlobContent !== 'text') { _%>
public <%= fieldType %> <%= fieldName %>;
Expand Down
37 changes: 37 additions & 0 deletions generators/server/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ const serverFiles = {
file: 'package/config/JsonbConfiguration.java',
renameTo: generator => `${generator.javaDir}config/JsonbConfiguration.java`
},
{
file: 'package/config/JHipsterInfo.java',
renameTo: generator => `${generator.javaDir}config/JHipsterInfo.java`
},
{
file: 'package/config/LocalDateProvider.java',
renameTo: generator => `${generator.javaDir}config/LocalDateProvider.java`
},
{
file: 'package/config/hibernate/JHipsterCompatibleImplicitNamingStrategy.java',
renameTo: generator => `${generator.javaDir}config/hibernate/JHipsterCompatibleImplicitNamingStrategy.java`
Expand All @@ -122,6 +130,19 @@ const serverFiles = {
renameTo: generator => `${generator.javaDir}config/hibernate/JHipsterCompatiblePhysicalNamingStrategy.java`
}
]
},
{
path: SERVER_TEST_SRC_DIR,
templates: [
{
file: 'package/config/mock/JHipsterInfoMock.java',
renameTo: generator => `${generator.javaDir}/config/mock/JHipsterInfoMock.java`
},
{
file: 'package/config/LocalDateProviderTest.java',
renameTo: generator => `${generator.javaDir}/config/LocalDateProviderTest.java`
}
]
}
],
serverJavaDomain: [
Expand Down Expand Up @@ -199,6 +220,10 @@ const serverFiles = {
file: 'package/service/dto/UserDTO.java',
renameTo: generator => `${generator.javaDir}service/dto/UserDTO.java`
},
{
file: 'package/service/dto/ManagementInfoDTO.java',
renameTo: generator => `${generator.javaDir}service/dto/ManagementInfoDTO.java`
},
{
file: 'package/service/AuthenticationService.java',
renameTo: generator => `${generator.javaDir}service/AuthenticationService.java`
Expand All @@ -215,6 +240,10 @@ const serverFiles = {
file: 'package/service/MailService.java',
renameTo: generator => `${generator.javaDir}service/MailService.java`
},
{
file: 'package/service/ManagementInfoService.java',
renameTo: generator => `${generator.javaDir}service/ManagementInfoService.java`
},
{
file: 'package/service/UsernameAlreadyUsedException.java',
renameTo: generator => `${generator.javaDir}service/UsernameAlreadyUsedException.java`
Expand Down Expand Up @@ -286,6 +315,10 @@ const serverFiles = {
file: 'package/web/rest/AccountResource.java',
renameTo: generator => `${generator.javaDir}web/rest/AccountResource.java`
},
{
file: 'package/web/rest/ManagementInfoResource.java',
renameTo: generator => `${generator.javaDir}web/rest/ManagementInfoResource.java`
},
{
file: 'package/web/rest/SpaFilter.java',
renameTo: generator => `${generator.javaDir}web/rest/SpaFilter.java`
Expand Down Expand Up @@ -322,6 +355,10 @@ const serverFiles = {
{
file: 'package/web/rest/UserResourceTest.java',
renameTo: generator => `${generator.javaDir}web/rest/UserResourceTest.java`
},
{
file: 'package/web/rest/ManagementInfoResourceTest.java',
renameTo: generator => `${generator.javaDir}web/rest/ManagementInfoResourceTest.java`
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion generators/server/templates/quarkus/build.gradle.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ dependencies {
implementation "io.quarkus:quarkus-mailer"
implementation "io.quarkus:quarkus-hibernate-orm-panache"
implementation "io.quarkus:quarkus-hibernate-validator"
implementation "io.quarkus:quarkus-hibernate-orm-panache"
<%_ if (devDatabaseType === 'mariadb' || prodDatabaseType === 'mariadb') { _%>
implementation "io.quarkus:quarkus-jdbc-mariadb"
liquibaseRuntime "io.quarkus:quarkus-jdbc-mariadb"
Expand All @@ -237,6 +236,7 @@ dependencies {
implementation "io.quarkus:quarkus-liquibase"
implementation "io.quarkus:quarkus-elytron-security"
implementation "io.quarkus:quarkus-smallrye-jwt"
implementation "io.quarkus:quarkus-smallrye-openapi"
implementation "org.mapstruct:mapstruct:${mapstruct_version}"
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")

Expand All @@ -250,6 +250,7 @@ dependencies {
annotationProcessor "org.mapstruct:mapstruct-processor:${mapstruct_version}"

testImplementation "io.quarkus:quarkus-junit5"
testImplementation "io.quarkus:quarkus-junit5-mockito"
testImplementation "io.rest-assured:rest-assured"
testImplementation "org.assertj:assertj-core"
testImplementation "com.tngtech.archunit:archunit-junit5-api:${archunit_junit5_version}"
Expand Down
10 changes: 9 additions & 1 deletion generators/server/templates/quarkus/pom.xml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@
prodDatabaseType}) _%>
<%- include('./partials/security_pom.xml.ejs', {
}) _%>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
Expand All @@ -133,6 +136,11 @@
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-mockito</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ public final class Constants {

public static final String DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";

public static final String LOCAL_DATE_FORMAT = "yyyy-MM-dd";
private Constants() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<%#
Copyright 2013-2020 the original author or authors from the JHipster project.
This file is part of the JHipster project, see https://www.jhipster.tech/
for more information.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-%>
package <%=packageName%>.config;

import io.quarkus.arc.config.ConfigProperties;
import org.eclipse.microprofile.config.inject.ConfigProperty;


@ConfigProperties(prefix = "jhipster.info")
public interface JHipsterInfo {

@ConfigProperty(name = "swagger.enable", defaultValue = "true")
Boolean isEnable();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<%#
Copyright 2013-2020 the original author or authors from the JHipster project.
This file is part of the JHipster project, see https://www.jhipster.tech/
for more information.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-%>
package <%=packageName%>.config;

import javax.ws.rs.ext.ParamConverter;
import javax.ws.rs.ext.ParamConverterProvider;
import javax.ws.rs.ext.Provider;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

@Provider
public class LocalDateProvider implements ParamConverterProvider {

public static DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(Constants.LOCAL_DATE_FORMAT);

@Override
public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) {
if(!rawType.equals(LocalDate.class)){
return null;
}
return new ParamConverter<>() {
@Override
public T fromString(String value) {
return (T) LocalDate.parse(value, dateFormatter);
}

@Override
public String toString(T value) {
return ((LocalDate) value).format(dateFormatter);
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<%#
Copyright 2013-2020 the original author or authors from the JHipster project.
This file is part of the JHipster project, see https://www.jhipster.tech/
for more information.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-%>
package <%=packageName%>.service;

import io.quarkus.runtime.configuration.ProfileManager;
import <%=packageName%>.config.JHipsterInfo;
import <%=packageName%>.service.dto.ManagementInfoDTO;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

/**
* Provides information for management/info resource
*/
@ApplicationScoped
public class ManagementInfoService {

private final JHipsterInfo JHipsterInfo;

@Inject
public ManagementInfoService(JHipsterInfo JHipsterInfo) {
this.JHipsterInfo = JHipsterInfo;
}

public ManagementInfoDTO getManagementInfo(){
var info = new ManagementInfoDTO();
if(JHipsterInfo.isEnable()){
info.activeProfiles.add("swagger");
}
info.activeProfiles.add(ProfileManager.getActiveProfile());
info.displayRibbonOnProfiles = ProfileManager.getActiveProfile();
return info;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<%#
Copyright 2013-2020 the original author or authors from the JHipster project.
This file is part of the JHipster project, see https://www.jhipster.tech/
for more information.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-%>
package <%=packageName%>.service.dto;

import io.quarkus.runtime.annotations.RegisterForReflection;

import javax.json.bind.annotation.JsonbProperty;
import java.util.ArrayList;
import java.util.List;

/**
* DTO to emulate /management/info response
*/
@RegisterForReflection
public class ManagementInfoDTO {

public List<String> activeProfiles = new ArrayList<>();

@JsonbProperty("display-ribbon-on-profiles")
public String displayRibbonOnProfiles;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<%#
Copyright 2013-2020 the original author or authors from the JHipster project.
This file is part of the JHipster project, see https://www.jhipster.tech/
for more information.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-%>
package <%=packageName%>.web.rest;

import <%=packageName%>.service.ManagementInfoService;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Path("/management/info")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@RequestScoped
public class ManagementInfoResource {

private final ManagementInfoService managementInfoService;

@Inject
public ManagementInfoResource(ManagementInfoService managementInfoService) {
this.managementInfoService = managementInfoService;
}

@GET
public Response info(){
return Response.ok(managementInfoService.getManagementInfo()).build();
}
}
Loading

0 comments on commit d02ac44

Please sign in to comment.