Skip to content

Commit

Permalink
feat: upgrade to JHipster 6.3.0 (#189)
Browse files Browse the repository at this point in the history
* upgrade version in package json

* test: update to version 6.3.0

* Update JHipster version

* Update JHipster version

* fix: update tests

* fix tests

* fix: add AuditEventServiceIT

* fix: files file

* Rename AuditEventServiceIt.kt.ejs to AuditEventServiceIT.kt.ejs

* fix: entity query Service

* Update EntityResourceIT.kt.ejs

* Update EntityResourceIT.kt.ejs

* Update AuditEventServiceIT.kt.ejs

* Update ExceptionTranslatorTestController.kt.ejs

* Regex should be explicit in Kotlin

* fix insecure random source for tokens

closes #183

* Update generators/server/templates/src/main/kotlin/package/service/util/RandomUtil.kt.ejs

Co-Authored-By: Sendil Kumar N <sendilkumarn@live.com>

* Update generators/server/templates/src/main/kotlin/package/service/util/RandomUtil.kt.ejs

Co-Authored-By: Sendil Kumar N <sendilkumarn@live.com>

* Update generators/server/templates/src/main/kotlin/package/service/util/RandomUtil.kt.ejs

Co-Authored-By: Sendil Kumar N <sendilkumarn@live.com>

* Update generators/server/templates/src/main/kotlin/package/service/util/RandomUtil.kt.ejs

Co-Authored-By: Sendil Kumar N <sendilkumarn@live.com>

* fix compilation error

* upgrade version in package json

test: update to version 6.3.0

Update JHipster version

Update JHipster version

fix: update tests

fix tests

fix: add AuditEventServiceIT

fix: files file

Rename AuditEventServiceIt.kt.ejs to AuditEventServiceIT.kt.ejs

fix: entity query Service

Update EntityResourceIT.kt.ejs

Update EntityResourceIT.kt.ejs

Update AuditEventServiceIT.kt.ejs

Update ExceptionTranslatorTestController.kt.ejs

Regex should be explicit in Kotlin

fix: id should not be optional

fix: cache configuration

fix: cache configuration

feat: update to JHipster v6.3.1

update package-lock.json

fix issues

* Update AuditResource.kt.ejs

* Update UserRepository.kt.ejs

* Update PersistenceAuditEventRepository.kt.ejs

* Update AuditEventService.kt.ejs

* Update AuditResource.kt.ejs

* fix: type issues

* fix couchbase error

* update package json

* update mvn command

* debug commit

* fix debug

* fix mongodb failure issues

* Update azure-pipelines.yml

* polish
  • Loading branch information
sendilkumarn committed Oct 2, 2019
1 parent f7b482c commit deec358
Show file tree
Hide file tree
Showing 52 changed files with 1,582 additions and 495 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ env:
- JHI_LIB_BRANCH=release
# if JHI_GEN_BRANCH value is release, use the release from NPM
- JHI_GEN_REPO=https://github.com/jhipster/generator-jhipster.git
- JHI_GEN_BRANCH=v6.2.0
- JHI_GEN_BRANCH=v6.3.1
# specific config
- SPRING_OUTPUT_ANSI_ENABLED=ALWAYS
- SPRING_JPA_SHOW_SQL=false
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
JHI_LIB_BRANCH: release
# if JHI_GEN_BRANCH value is release, use the release from NPM
JHI_GEN_REPO: https://github.com/jhipster/generator-jhipster.git
JHI_GEN_BRANCH: v6.2.0
JHI_GEN_BRANCH: v6.3.1
# specific config
SPRING_OUTPUT_ANSI_ENABLED: NEVER
SPRING_JPA_SHOW_SQL: false
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
JHI_APP: ngx-h2mem-ws-nol2
JHI_ENTITY: sql
webflux-mongodb:
JHI_APP: webflux-mongodb
JHI_APP: kotlin-webflux-mongo
JHI_ENTITY: mongodb
ms-micro-eureka-uaa:
JHI_APP: ms-micro-eureka-uaa
Expand Down
2 changes: 1 addition & 1 deletion generators/entity-server/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function writeFiles() {

const serverCacheKt = new NeedleServerChacheKt(this);

if (['ehcache', 'infinispan'].includes(this.cacheProvider) && this.enableHibernateCache) {
if (['ehcache', 'caffeine', 'infinispan'].includes(this.cacheProvider) && this.enableHibernateCache) {
serverCacheKt.addEntityToCache(
this.asEntity(this.entityClass),
this.relationships,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if (!viaService) {
resultEntity = asEntity(entityInstance) %>
var <%= asEntity(entityInstance) %> = <%= dtoToEntity %>(<%= instanceName %>)
<%_ if (isUsingMapsId === true) { _%>
val <%= otherEntityName %>Id = <%= instanceName %>.<%= mapsIdAssoc.relationshipName%>Id
val <%= otherEntityName %>Id = <%= instanceName %>.<%= mapsIdAssoc.relationshipName %>Id
if (<%= otherEntityName %>Id != null) {
<%= mapsIdRepoInstance %>.findById(<%= otherEntityName %>Id)
.ifPresent { <%= asEntity(entityInstance) %>.<%= otherEntityName %> = it }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let importJsonIgnoreProperties = false;
let importSet = false;
let hasDto = dto === 'mapstruct';
let isUsingMapsId = false;
let primaryKeyType = pkType;
let hasTextBlob = false;
let hasRelationship = relationships.length !== 0;
let fieldsContainEnum = false;
Expand All @@ -48,6 +49,7 @@ const uniqueEnums = {}; %><%- include imports -%>
for (idx in relationships) {
isUsingMapsId = relationships[idx].useJPADerivedIdentifier;
if ( isUsingMapsId === true) {
primaryKeyType = (relationships[idx].otherEntityName === 'user' && authenticationType === 'oauth2') ? 'String' : pkType;
break;
}
isUsingMapsId = false;
Expand Down Expand Up @@ -216,7 +218,7 @@ class <%= asEntity(entityClass) %>(
<%_ if (searchEngine === 'elasticsearch') { _%>
@org.springframework.data.elasticsearch.annotations.Field(type = FieldType.Keyword)
<%_ } _%>
var id: <%= pkType %>? = null,
var id: <%= primaryKeyType %>? = null,

<%_
for (var idx in fields) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-%>
package <%=packageName%>.repository

package <%=packageName%>.repository<%
const primaryKeyType = getPkTypeBasedOnDBAndAssociation(authenticationType, databaseType, relationships);
%>
import <%=packageName%>.domain.<%= asEntity(entityClass) %>
<%_ if (fieldsContainOwnerManyToMany) { _%>
import org.springframework.data.domain.Page
Expand Down Expand Up @@ -59,7 +60,7 @@ import java.util.UUID
@Suppress("unused")
<%_ } _%>
@Repository
interface <%=entityClass%>Repository : <% if (databaseType === 'sql') { %>JpaRepository<% } %><% if (databaseType === 'mongodb') { %>MongoRepository<% } %><% if (databaseType === 'cassandra') { %>CassandraRepository<% } %><% if (databaseType === 'couchbase') { %>N1qlCouchbaseRepository<% } %><<%=asEntity(entityClass)%>, <%= pkType %>><% if (jpaMetamodelFiltering) { %>, JpaSpecificationExecutor<<%= asEntity(entityClass) %>><% } %> {
interface <%=entityClass%>Repository : <% if (databaseType === 'sql') { %>JpaRepository<% } %><% if (databaseType === 'mongodb') { %>MongoRepository<% } %><% if (databaseType === 'cassandra') { %>CassandraRepository<% } %><% if (databaseType === 'couchbase') { %>N1qlCouchbaseRepository<% } %><<%=asEntity(entityClass)%>, <%= primaryKeyType %>><% if (jpaMetamodelFiltering) { %>, JpaSpecificationExecutor<<%= asEntity(entityClass) %>><% } %> {
<%_ for (idx in relationships) {
if (relationships[idx].relationshipType === 'many-to-one' && relationships[idx].otherEntityName === 'user' && databaseType === 'sql') { _%>

Expand All @@ -82,7 +83,7 @@ interface <%=entityClass%>Repository : <% if (databaseType === 'sql') { %>JpaRep

@Query("select <%= entityInstance %> from <%= asEntity(entityClass) %> <%= entityInstance %><% for (idx in relationships) {
if (relationships[idx].relationshipType === 'many-to-many' && relationships[idx].ownerSide === true) { %> left join fetch <%=entityInstance%>.<%=relationships[idx].relationshipFieldNamePlural%><%} }%> where <%=entityInstance%>.id =:id")
fun findOneWithEagerRelationships(@Param("id") id: <%= pkType %>): Optional<<%= asEntity(entityClass) %>>
fun findOneWithEagerRelationships(@Param("id") id: <%= primaryKeyType %>): Optional<<%= asEntity(entityClass) %>>
<%_
} else if (databaseType === 'mongodb') { _%>

Expand All @@ -93,7 +94,7 @@ interface <%=entityClass%>Repository : <% if (databaseType === 'sql') { %>JpaRep
fun findAllWithEagerRelationships(): MutableList<<%= asEntity(entityClass) %>>

@Query("{'id': ?0}")
fun findOneWithEagerRelationships(id: <%= pkType %>): Optional<<%= asEntity(entityClass) %>>
fun findOneWithEagerRelationships(id: <%= primaryKeyType %>): Optional<<%= asEntity(entityClass) %>>
<%_ }
} _%>
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-%>
package <%= packageName %>.repository.reactive

package <%= packageName %>.repository.reactive<%
const primaryKeyType = getPkTypeBasedOnDBAndAssociation(authenticationType, databaseType, relationships);
%>
import <%= packageName %>.domain.<%= asEntity(entityClass) %>
<%_ if (databaseType === 'cassandra') { _%>
import org.springframework.data.cassandra.repository.ReactiveCassandraRepository
Expand All @@ -43,7 +44,7 @@ import java.util.UUID
*/
@Suppress("unused")
@Repository
interface <%= entityClass %>ReactiveRepository: Reactive<% if (databaseType === 'mongodb') { %>Mongo<% } if (databaseType === 'couchbase') { %>CouchbaseSorting<% } if (databaseType === 'cassandra') { %>Cassandra<% } %>Repository<<%= asEntity(entityClass) %>, <%= pkType %>> {
interface <%= entityClass %>ReactiveRepository: Reactive<% if (databaseType === 'mongodb') { %>Mongo<% } if (databaseType === 'couchbase') { %>CouchbaseSorting<% } if (databaseType === 'cassandra') { %>Cassandra<% } %>Repository<<%= asEntity(entityClass) %>, <%= primaryKeyType %>> {
<%_ if (databaseType === 'couchbase') { _%>

@Query("#{#n1ql.selectEntity} WHERE #{#n1ql.filter}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-%>
package <%=packageName%>.repository.search
package <%=packageName%>.repository.search<%
const primaryKeyType = getPkTypeBasedOnDBAndAssociation(authenticationType, databaseType, relationships);
%>

import <%=packageName%>.domain.<%= asEntity(entityClass) %>
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository<% if (databaseType === 'cassandra') { %>
Expand All @@ -26,4 +28,4 @@ import java.util.UUID<% } %>
/**
* Spring Data Elasticsearch repository for the [<%= asEntity(entityClass) %>] entity.
*/
interface <%=entityClass%>SearchRepository : ElasticsearchRepository<<%= asEntity(entityClass) %>, <% if (databaseType === 'sql') { %>Long<% } %><% if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>String<% } %><% if (databaseType === 'cassandra') { %>UUID<% } %>>
interface <%=entityClass%>SearchRepository : ElasticsearchRepository<<%= asEntity(entityClass) %>, <% if (databaseType === 'sql') { %><%=primaryKeyType%><% } %><% if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>String<% } %><% if (databaseType === 'cassandra') { %>UUID<% } %>>
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class <%= serviceClassName %>(
}

/**
* Function to convert ConsumerCriteria to a [Specification].
* Function to convert [<%= criteria %>] to a [Specification].
* @param criteria The object which holds all the filters, which the entities should match.
* @return the matching [Specification] of the entity.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-%>
package <%=packageName%>.service
package <%=packageName%>.service<%
const primaryKeyType = getPkTypeBasedOnDBAndAssociation(authenticationType, databaseType, relationships);
%>
<% const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass);
const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance); %>
<%_ if (dto === 'mapstruct') { _%>
Expand Down Expand Up @@ -90,14 +92,14 @@ interface <%= entityClass %>Service {
* @param id the id of the entity.
* @return the entity.
*/
fun findOne(id: <%= pkType %>): Optional<<%= instanceType %>>
fun findOne(id: <%= primaryKeyType %>): Optional<<%= instanceType %>>

/**
* Delete the "id" <%= entityInstance %>.
*
* @param id the id of the entity.
*/
fun delete(id: <%= pkType %>)<% if (searchEngine === 'elasticsearch') { %>
fun delete(id: <%= primaryKeyType %>)<% if (searchEngine === 'elasticsearch') { %>

/**
* Search for the <%= entityInstance %> corresponding to the query.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ import io.github.jhipster.service.filter.ZonedDateTimeFilter
<%_ } _%>

<%_
const referenceFilterType = '' + pkType + 'Filter';
var filterVariables = [{name:'id', type: pkType, filterType:referenceFilterType,fieldInJavaBeanMethod:'Id' } ];
const primaryKeyType = getPkTypeBasedOnDBAndAssociation(authenticationType, databaseType, relationships);
const referenceFilterType = '' + primaryKeyType + 'Filter';
var filterVariables = [{name:'id', type: primaryKeyType, filterType:referenceFilterType,fieldInJavaBeanMethod:'Id' } ];
var extraFilters = {};
fields.forEach((field) => {
const fieldType = field.fieldType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let importApiModelProperty = false;
let importJsonIgnore = false;
let importJsonIgnoreProperties = false;
let importSet = false;
const primaryKeyType = getPkTypeBasedOnDBAndAssociation(authenticationType, databaseType, relationships);
const uniqueEnums = {};
%><%- include ../../domain/imports -%>

Expand Down Expand Up @@ -63,9 +64,9 @@ import java.util.UUID
<%_ if (fieldsContainBlob && databaseType === 'sql') { _%>
import javax.persistence.Lob
<%_ } _%>
<%_ for (idx in fields) { if (fields[idx].fieldIsEnum) { _%>
import <%=packageName%>.domain.enumeration.<%= fields[idx].fieldType %>
<%_ } } _%>
<%_ Object.keys(uniqueEnums).forEach(function(element) { _%>
import <%=packageName%>.domain.enumeration.<%= element %>
<%_ }); _%>
<%_
var mappedRels = [];
relationships.forEach((relationship) => {
Expand All @@ -85,7 +86,7 @@ _%>
<%_ } _%>
data class <%= asDto(entityClass) %>(

var id: <%= pkType %>? = null,
var id: <%= primaryKeyType %>? = null,
<%_ for (idx in fields) {
if (typeof fields[idx].javadoc !== 'undefined') { _%>
<%- formatAsFieldJavadoc(fields[idx].javadoc) %>
Expand Down Expand Up @@ -147,7 +148,7 @@ data class <%= asDto(entityClass) %>(
}
_%>

var <%= relationshipFieldName %>Id: <% if (relationshipFieldName === 'user' && authenticationType === 'oauth2') { %>String<% } else { %><%= pkType %><% } %>? = null<%= comma %>
var <%= relationshipFieldName %>Id: <% if (relationshipFieldName === 'user' && authenticationType === 'oauth2') { %>String<% } else { %><%= primaryKeyType %><% } %>? = null<%= comma %>
<%_ if (otherEntityFieldCapitalized !== 'Id' && otherEntityFieldCapitalized !== '') {
comma = index === (mappedRels.length - 1) ? '' : ',';
_%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ package <%= packageName %>.service<% if (service === 'serviceImpl') { %>.impl<%
const repository = entityInstance + 'Repository';
const searchRepository = entityInstance + 'SearchRepository';
let isUsingMapsId = false;
let primaryKeyType = pkType;
let mapsIdAssoc;
for (idx in relationships) {
isUsingMapsId = relationships[idx].useJPADerivedIdentifier;
if ( isUsingMapsId === true) {
mapsIdAssoc = relationships[idx];
primaryKeyType = (relationships[idx].otherEntityName === 'user' && authenticationType === 'oauth2') ? 'String' : pkType;
break;
}
isUsingMapsId = false;
Expand Down Expand Up @@ -151,7 +153,7 @@ class <%= serviceClassName %>(
<%_ if (databaseType === 'sql') { _%>
@Transactional(readOnly = true)
<%_ } _%>
<% if (service === 'serviceImpl') { %>override <% } %>fun findOne(id: <%= pkType %>): Optional<<%= instanceType %>> {
<% if (service === 'serviceImpl') { %>override <% } %>fun findOne(id: <%= primaryKeyType %>): Optional<<%= instanceType %>> {
log.debug("Request to get <%= entityClass %> : {}", id)<%- include('../../common/get_template', {asEntity, asDto, viaService, returnDirectly:true}); -%>
}

Expand All @@ -160,7 +162,7 @@ class <%= serviceClassName %>(
*
* @param id the id of the entity.
*/
<% if (service === 'serviceImpl') { %>override <% } %>fun delete(id: <%= pkType %>) {
<% if (service === 'serviceImpl') { %>override <% } %>fun delete(id: <%= primaryKeyType %>) {
log.debug("Request to delete <%= entityClass %> : {}", id)
<%- include('../../common/delete_template', {viaService: viaService}); -%>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ _%>
<%_
// DTO -> entity mapping
var mappedRelsDto = [];
let primaryKeyType = pkType;
for (idx in relationships) {
const relationshipType = relationships[idx].relationshipType;
const otherEntityName = relationships[idx].otherEntityName;
const ownerSide = relationships[idx].ownerSide;
const isUsingMapsId = relationships[idx].useJPADerivedIdentifier;
primaryKeyType = (isUsingMapsId === true && otherEntityName === 'user' && authenticationType === 'oauth2') ? 'String' : primaryKeyType;
if (relationshipType === 'many-to-one' || (relationshipType === 'one-to-one' && ownerSide === true) ||
(relationshipType === 'many-to-many' && ownerSide === false) ||
relationshipType === 'one-to-many' ||
Expand Down Expand Up @@ -119,6 +123,6 @@ _%>
<%_ } _%>
<%_ if (databaseType === 'sql' || databaseType === 'mongodb') { _%>

fun fromId(id: <%= pkType %>?) = id?.let { <%= asEntity(entityClass) %>(it) }
fun fromId(id: <%= primaryKeyType %>?) = id?.let { <%= asEntity(entityClass) %>(it) }
<%_ } _%>
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ package <%=packageName%>.web.rest
<%_ const viaService = service !== 'no';
let isUsingMapsId = false;
let mapsIdAssoc;
let primaryKeyType = pkType;
for (idx in relationships) {
isUsingMapsId = relationships[idx].useJPADerivedIdentifier;
if ( isUsingMapsId === true) {
mapsIdAssoc = relationships[idx];
primaryKeyType = (relationships[idx].otherEntityName === 'user' && authenticationType === 'oauth2') ? 'String' : pkType;
break;
}
isUsingMapsId = false;
Expand Down Expand Up @@ -247,7 +249,7 @@ _%><%- include('../../common/inject_template', {viaService: viaService, construc
<%_ if (databaseType === 'sql' && isUsingMapsId === true && !viaService) { _%>
@Transactional(readOnly = true)
<%_ } _%>
fun get<%= entityClass %>(@PathVariable id: <%= pkType %>): ResponseEntity<<%= instanceType %>> {
fun get<%= entityClass %>(@PathVariable id: <%= primaryKeyType %>): ResponseEntity<<%= instanceType %>> {
log.debug("REST request to get <%= entityClass %> : {}", id)<%- include('../../common/get_template', {asEntity, asDto, viaService, returnDirectly:false}); -%>
return ResponseUtil.wrapOrNotFound(<%= instanceName %>)
}
Expand All @@ -259,7 +261,7 @@ _%><%- include('../../common/inject_template', {viaService: viaService, construc
* @return the [ResponseEntity] with status `204 (NO_CONTENT)`.
*/
@DeleteMapping("/<%= entityApiUrl %>/{id}")
fun delete<%= entityClass %>(@PathVariable id: <%= pkType %>): ResponseEntity<Void> {
fun delete<%= entityClass %>(@PathVariable id: <%= primaryKeyType %>): ResponseEntity<Void> {
log.debug("REST request to delete <%= entityClass %> : {}", id)
<%- include('../../common/delete_template', {viaService: viaService}); -%>
return ResponseEntity.noContent()
Expand Down
Loading

0 comments on commit deec358

Please sign in to comment.