Skip to content

Commit 38ad4d4

Browse files
authored
Merge pull request #164 from jhipster/gh-141
Upgrade to JHipster 6.1.2
2 parents b7c0525 + b54d3c5 commit 38ad4d4

File tree

69 files changed

+1218
-983
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1218
-983
lines changed

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919

2020
os:
2121
- linux
22+
dist: xenial
2223
services:
2324
- docker
25+
- xvfb
2426
language: node_js
2527
node_js:
2628
- '10.16.0'
@@ -45,14 +47,15 @@ env:
4547
- JHI_LIB_BRANCH=release
4648
# if JHI_GEN_BRANCH value is release, use the release from NPM
4749
- JHI_GEN_REPO=https://github.com/jhipster/generator-jhipster.git
48-
- JHI_GEN_BRANCH=v6.0.1
50+
- JHI_GEN_BRANCH=v6.1.2
4951
# specific config
5052
- SPRING_OUTPUT_ANSI_ENABLED=ALWAYS
5153
- SPRING_JPA_SHOW_SQL=false
5254
- JHI_DISABLE_WEBPACK_LOGS=true
5355
- JHI_E2E_HEADLESS=true
5456
- JHI_SCRIPTS=$HOME/generator-jhipster/test-integration/scripts
5557
- KOTLIN_JHI_SCRIPTS=$TRAVIS_BUILD_DIR/test-integration/scripts
58+
- NG_CLI_ANALYTICS="false"
5659
matrix:
5760
- JHI_APP=ngx-default JHI_PROFILE=prod JHI_PROTRACTOR=1 JHI_ENTITY=sql JHI_SONAR=1
5861
- JHI_APP=ngx-psql-es-noi18n-mapsid JHI_PROFILE=prod JHI_PROTRACTOR=1 JHI_ENTITY=sqlfull
@@ -86,7 +89,7 @@ before_install:
8689
- sudo /etc/init.d/postgresql stop
8790
# Use this for Protractor
8891
- export DISPLAY=:99.0
89-
- sh -e /etc/init.d/xvfb start
92+
# - sh -e /etc/init.d/xvfb start
9093
# Update NPM
9194
- npm install -g npm
9295
# Install Yarn

azure-pipelines.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,23 @@ jobs:
3131
JHI_LIB_BRANCH: release
3232
# if JHI_GEN_BRANCH value is release, use the release from NPM
3333
JHI_GEN_REPO: https://github.com/jhipster/generator-jhipster.git
34-
JHI_GEN_BRANCH: v6.0.1
34+
JHI_GEN_BRANCH: v6.1.2
3535
# specific config
3636
SPRING_OUTPUT_ANSI_ENABLED: NEVER
3737
SPRING_JPA_SHOW_SQL: false
3838
JHI_DISABLE_WEBPACK_LOGS: true
3939
JHI_E2E_HEADLESS: true
4040
JHI_SCRIPTS: $HOME/generator-jhipster/test-integration/scripts
4141
KOTLIN_JHI_SCRIPTS: $(Build.Repository.LocalPath)/test-integration/scripts
42+
NG_CLI_ANALYTICS: false
4243

4344
strategy:
4445
matrix:
46+
ngx-default:
47+
JHI_APP: ngx-default
48+
JHI_ENTITY: sql
49+
JHI_PROFILE: prod
50+
JHI_PROTRACTOR: 1
4551
jdl-default:
4652
JHI_APP: kotlin-jdl-default
4753
JHI_ENTITY: jdl

generators/entity-server/templates/src/main/kotlin/package/domain/Entity.kt.ejs

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ let importJsonIgnore = false;
2222
let importJsonIgnoreProperties = false;
2323
let importSet = false;
2424
let hasDto = dto === 'mapstruct';
25+
let isUsingMapsId = false;
26+
let hasTextBlob = false;
27+
let hasRelationship = relationships.length !== 0;
2528
let fieldsContainEnum = false;
2629
let fieldsContainManyToMany = false;
2730
let fieldsContainOneToOne = false;
28-
let isUsingMapsId = false;
2931
const uniqueEnums = {}; %><%- include imports -%>
3032
<%_
3133
//todo: maybe move to generator-jhipster/generators/entity/index.js
@@ -50,6 +52,12 @@ const uniqueEnums = {}; %><%- include imports -%>
5052
}
5153
isUsingMapsId = false;
5254
}
55+
for (idx in fields) {
56+
if ((prodDatabaseType === 'postgresql' || devDatabaseType === 'postgresql') && fields[idx].fieldTypeBlobContent === 'text') {
57+
hasTextBlob = true;
58+
break;
59+
}
60+
}
5361
_%>
5462

5563
<%_ if (databaseType === 'cassandra') { _%>
@@ -69,6 +77,8 @@ import io.swagger.annotations.ApiModelProperty
6977
<%_ } if (enableHibernateCache) { _%>
7078
import org.hibernate.annotations.Cache
7179
import org.hibernate.annotations.CacheConcurrencyStrategy
80+
<%_ } if (hasTextBlob === true || (fieldsContainUUID === true && ['mysql', 'mariadb'].includes(prodDatabaseType))) { _%>
81+
import org.hibernate.annotations.Type
7282
<%_ } if (databaseType === 'mongodb') { _%>
7383
import org.springframework.data.annotation.Id
7484
import org.springframework.data.mongodb.core.mapping.Field
@@ -147,7 +157,7 @@ import java.time.ZonedDateTime
147157
<%_ } if (fieldsContainDuration === true) { _%>
148158
import java.time.Duration
149159
<%_ } _%>
150-
<%_ if (databaseType === 'cassandra') { _%>
160+
<%_ if (databaseType === 'cassandra' || fieldsContainUUID === true) { _%>
151161
import java.util.UUID
152162
<%_ }
153163
Object.keys(uniqueEnums).forEach(function(element) { _%>
@@ -242,11 +252,17 @@ for (var idx in fields) {
242252
<%_ } _%>
243253
<%_ if (fieldType === 'byte[]') { _%>
244254
@Lob
245-
<%_ } _%>
246-
<%_if (['Instant', 'ZonedDateTime', 'LocalDate', 'Duration'].includes(fieldType)) { _%>
255+
<%_ if ((prodDatabaseType === 'postgresql' || devDatabaseType === 'postgresql') && fieldTypeBlobContent === 'text' ) { _%>
256+
@Type(type = "org.hibernate.type.TextType")
257+
<%_ }
258+
}
259+
if (['Instant', 'ZonedDateTime', 'LocalDate', 'Duration'].includes(fieldType)) { _%>
247260
@Column(name = "<%-fieldNameAsDatabaseColumn %>"<% if (required) { %>, nullable = false<% } %><% if (unique) { %>, unique = true<% } %>)
248261
<%_ } else if (fieldType === 'BigDecimal') { _%>
249262
@Column(name = "<%-fieldNameAsDatabaseColumn %>", precision = 21, scale = 2<% if (required) { %>, nullable = false<% } %><% if (unique) { %>, unique = true<% } %>)
263+
<%_ } else if (fieldType === 'UUID' && ['mysql', 'mariadb'].includes(prodDatabaseType)) { _%>
264+
@Type(type = "uuid-char")
265+
@Column(name = "<%-fieldNameAsDatabaseColumn %>", length = 36<% if (required) { %>, nullable = false<% } %><% if (unique) { %>, unique = true<% } %>)
250266
<%_ } else { _%>
251267
@Column(name = "<%-fieldNameAsDatabaseColumn %>"<% if (fieldValidate === true) { %><% if (fieldValidateRules.includes('maxlength')) { %>, length = <%= fieldValidateRulesMaxlength %><% } %><% if (required) { %>, nullable = false<% } %><% if (unique) { %>, unique = true<% } %><% } %>)
252268
<%_ } _%>
@@ -442,26 +458,23 @@ for (var idx in fields) {
442458
return id == other.id
443459
}
444460
445-
override fun hashCode(): Int {
446-
return 31
447-
}
461+
override fun hashCode() = 31
448462
449-
override fun toString(): String {
450-
return "<%= asEntity(entityClass) %>{" +
451-
"id=$id" +
452-
<%_ for (idx in fields) {
453-
const fieldType = fields[idx].fieldType;
454-
const fieldTypeBlobContent = fields[idx].fieldTypeBlobContent;
455-
const fieldName = fields[idx].fieldName;
456-
const fieldInJavaBeanMethod = fields[idx].fieldInJavaBeanMethod;
457-
const isNumeric = ['integer', 'long', 'float', 'double', 'bigdecimal'].includes(fieldType.toLowerCase());_%>
458-
", <%= fieldName %>=<% if (! isNumeric) { %>'<% } %>$<%= fieldName %><% if (! isNumeric) { %>'<% } %>" +
459-
<%_ if ((fieldType === 'byte[]' || fieldType === 'ByteBuffer') && fieldTypeBlobContent !== 'text') { _%>
460-
", <%= fieldName %>ContentType='$<%= fieldName %>ContentType'" +
461-
<%_ } _%>
463+
override fun toString() = "<%= asEntity(entityClass) %>{" +
464+
"id=$id" +
465+
<%_ for (idx in fields) {
466+
const fieldType = fields[idx].fieldType;
467+
const fieldTypeBlobContent = fields[idx].fieldTypeBlobContent;
468+
const fieldName = fields[idx].fieldName;
469+
const fieldInJavaBeanMethod = fields[idx].fieldInJavaBeanMethod;
470+
const isNumeric = ['integer', 'long', 'float', 'double', 'bigdecimal'].includes(fieldType.toLowerCase());_%>
471+
", <%= fieldName %>=<% if (! isNumeric) { %>'<% } %>$<%= fieldName %><% if (! isNumeric) { %>'<% } %>" +
472+
<%_ if ((fieldType === 'byte[]' || fieldType === 'ByteBuffer') && fieldTypeBlobContent !== 'text') { _%>
473+
", <%= fieldName %>ContentType='$<%= fieldName %>ContentType'" +
462474
<%_ } _%>
463-
"}"
464-
}
475+
<%_ } _%>
476+
"}"
477+
465478
466479
companion object {
467480
private const val serialVersionUID = 1L

generators/entity-server/templates/src/main/kotlin/package/domain/imports.ejs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ if (!importApiModelProperty) {
3535
}
3636
3737
for (idx in relationships) {
38-
if (relationships[idx].relationshipType === 'one-to-many'
39-
|| relationships[idx].relationshipType === 'one-to-one' && relationships[idx].ownerSide === false
40-
|| relationships[idx].relationshipType === 'many-to-many' && relationships[idx].ownerSide === false) {
38+
if (relationships[idx].ownerSide === false && ['one-to-many', 'one-to-one', 'many-to-many'].includes(relationships[idx].relationshipType)) {
4139
importJsonIgnore = true;
4240
} else if (relationships[idx].relationshipType === 'many-to-one') {
4341
importJsonIgnoreProperties = true;

generators/entity-server/templates/src/main/kotlin/package/service/EntityQueryService.kt.ejs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ class <%= serviceClassName %>(
125125
}
126126
127127
/**
128-
* Function to convert [<%= criteria %>] to a [Specification].
128+
* Function to convert ConsumerCriteria to a [Specification].
129+
* @param criteria The object which holds all the filters, which the entities should match.
130+
* @return the matching [Specification] of the entity.
129131
*/
130132
private fun createSpecification(criteria: <%= criteria %>?): Specification<<%= asEntity(entityClass) %>?> {
131133
var specification: Specification<<%= asEntity(entityClass) %>?> = Specification.where(null)

generators/entity-server/templates/src/main/kotlin/package/service/dto/EntityCriteria.kt.ejs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
package <%= packageName %>.service.dto
2020

2121
import java.io.Serializable
22-
<%_ if (fieldsContainDuration === true) { _%>
23-
import java.time.Duration
24-
<%_ } _%>
2522
import io.github.jhipster.service.Criteria
2623
<%_ for (idx in fields) { if (fields[idx].fieldIsEnum === true) { _%>
2724
import <%= packageName %>.domain.enumeration.<%= fields[idx].fieldType %>
@@ -36,14 +33,17 @@ import io.github.jhipster.service.filter.StringFilter
3633
<%_ if (fieldsContainBigDecimal === true) { _%>
3734
import io.github.jhipster.service.filter.BigDecimalFilter
3835
<%_ } _%>
36+
<%_ if (fieldsContainDuration === true) { _%>
37+
import io.github.jhipster.service.filter.DurationFilter
38+
<%_ } _%>
3939
<%_ if (fieldsContainInstant === true) { _%>
4040
import io.github.jhipster.service.filter.InstantFilter
4141
<%_ } _%>
4242
<%_ if (fieldsContainLocalDate === true) { _%>
4343
import io.github.jhipster.service.filter.LocalDateFilter
4444
<%_ } _%>
45-
<%_ if (fieldsContainDuration === true) { _%>
46-
import io.github.jhipster.service.filter.RangeFilter
45+
<%_ if (fieldsContainUUID === true) { _%>
46+
import io.github.jhipster.service.filter.UUIDFilter
4747
<%_ } _%>
4848
<%_ if (fieldsContainZonedDateTime === true) { _%>
4949
import io.github.jhipster.service.filter.ZonedDateTimeFilter
@@ -53,14 +53,14 @@ import io.github.jhipster.service.filter.ZonedDateTimeFilter
5353
const referenceFilterType = '' + pkType + 'Filter';
5454
var filterVariables = [{name:'id', type: pkType, filterType:referenceFilterType,fieldInJavaBeanMethod:'Id' } ];
5555
var extraFilters = {};
56-
fields.forEach((field, index) => {
56+
fields.forEach((field) => {
5757
const fieldType = field.fieldType;
5858
if (isFilterableType(fieldType)) {
5959
var filterType;
6060
if (field.fieldIsEnum == true) {
6161
filterType = fieldType + 'Filter';
62-
extraFilters[fieldType] = {type : filterType, superType: 'Filter<' + fieldType + '>', fieldType:fieldType};
63-
} else if (['Duration', 'LocalDate', 'ZonedDateTime', 'Instant', 'String', 'Long', 'Integer', 'Float', 'Double', 'BigDecimal', 'Boolean'].includes(fieldType)) {
62+
extraFilters[fieldType] = {type: filterType, superType: 'Filter<' + fieldType + '>', fieldType: fieldType};
63+
} else if (['Duration', 'UUID', 'LocalDate', 'ZonedDateTime', 'Instant', 'String', 'Long', 'Integer', 'Float', 'Double', 'BigDecimal', 'Boolean'].includes(fieldType)) {
6464
filterType = fieldType + 'Filter';
6565
} else {
6666
filterType = 'Filter<' + fieldType + '>';
@@ -71,10 +71,7 @@ import io.github.jhipster.service.filter.ZonedDateTimeFilter
7171
fieldInJavaBeanMethod: field.fieldInJavaBeanMethod });
7272
}
7373
});
74-
if (fieldsContainDuration === true) {
75-
extraFilters['java.time.Duration'] = {type : 'DurationFilter', superType: 'RangeFilter<Duration>', fieldType: 'Duration'};
76-
}
77-
relationships.forEach((relationship, index) => {
74+
relationships.forEach((relationship) => {
7875
const relationshipType = relationship.relationshipType;
7976
// user has a String PK when using OAuth, so change relationships accordingly
8077
let oauthAwareReferenceFilterType = referenceFilterType;
@@ -125,15 +122,11 @@ _%>
125122
126123
constructor(filter: <%= extraFilter.type %>) : super(filter)
127124
128-
override fun copy(): <%= extraFilter.type %> {
129-
return <%= extraFilter.type %>(this)
130-
}
125+
override fun copy() = <%= extraFilter.type %>(this)
131126
}
132127
<%_ }); _%>
133128
134-
override fun copy(): <%= entityClass %>Criteria {
135-
return <%= entityClass %>Criteria(this)
136-
}
129+
override fun copy() = <%= entityClass %>Criteria(this)
137130
138131
companion object {
139132
private const val serialVersionUID: Long = 1L

generators/entity-server/templates/src/main/kotlin/package/service/dto/EntityDTO.kt.ejs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import java.math.BigDecimal
5757
<%_ if (fieldsContainBlob && databaseType === 'cassandra') { _%>
5858
import java.nio.ByteBuffer
5959
<%_ } _%>
60-
<%_ if (databaseType === 'cassandra') { _%>
60+
<%_ if (databaseType === 'cassandra' || fieldsContainUUID === true) { _%>
6161
import java.util.UUID
6262
<%_ } _%>
6363
<%_ if (fieldsContainBlob && databaseType === 'sql') { _%>
@@ -165,7 +165,5 @@ data class <%= asDto(entityClass) %>(
165165
return id == other.id
166166
}
167167
168-
override fun hashCode(): Int {
169-
return id.hashCode()
170-
}
168+
override fun hashCode() = id.hashCode()
171169
}

generators/entity-server/templates/src/main/kotlin/package/service/impl/EntityServiceImpl.kt.ejs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ class <%= serviceClassName %>(
137137
*
138138
* @return the list of entities.
139139
*/
140-
<% if (service === 'serviceImpl') { %>override <% } %>fun findAllWithEagerRelationships(pageable: Pageable): Page<<%= instanceType %>> {
141-
return <%= entityInstance %>Repository.findAllWithEagerRelationships(pageable)<% if (dto !== 'mapstruct') { %><% } else { %>.map(<%= entityToDtoReference %>)<% } %>
142-
}
140+
<% if (service === 'serviceImpl') { %>override <% } %>fun findAllWithEagerRelationships(pageable: Pageable) =
141+
<%= entityInstance %>Repository.findAllWithEagerRelationships(pageable)<% if (dto !== 'mapstruct') { %><% } else { %>.map(<%= entityToDtoReference %>)<% } %>
142+
143143
<%_ } _%>
144144
<%- include('../../common/get_filtered_template', {asEntity, asDto}); -%>
145145
/**

generators/entity-server/templates/src/main/kotlin/package/service/mapper/EntityMapper.kt.ejs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,33 @@ _%>
7171
7272
<%_
7373
// DTO -> entity mapping
74-
var renMapAnotDto = false; //Render Mapping Annotation during DTO to Entity conversion?
74+
var mappedRelsDto = [];
7575
for (idx in relationships) {
7676
const relationshipType = relationships[idx].relationshipType;
7777
const ownerSide = relationships[idx].ownerSide;
7878
if (relationshipType === 'many-to-one' || (relationshipType === 'one-to-one' && ownerSide === true) ||
7979
(relationshipType === 'many-to-many' && ownerSide === false) ||
8080
relationshipType === 'one-to-many' ||
8181
relationshipType === 'one-to-one' && ownerSide === false) {
82-
renMapAnotDto = true;
83-
break;
82+
mappedRelsDto.push(idx)
8483
}
85-
} if(renMapAnotDto === true) { _%>
84+
}
85+
var renMapAnotDto = mappedRelsDto.length > 0; //Render Mapping Annotation during DTO to Entity conversion?
86+
if(renMapAnotDto === true) {
87+
_%>
8688
@Mappings(<% } %>
8789
<%_
8890
// var hasOAuthUser = false; // if OAuthuser, use a String id in fromId() method
89-
for (idx in relationships) {
91+
for (idx in mappedRelsDto) {
9092
const relationshipType = relationships[idx].relationshipType;
9193
const relationshipName = relationships[idx].relationshipName;
9294
// hasOAuthUser = (relationshipName === 'user' && authenticationType === 'oauth2');
9395
const relationshipNamePlural = relationships[idx].relationshipNamePlural;
96+
const relationshipNameCapitalized = relationships[idx].relationshipNameCapitalized;
9497
const ownerSide = relationships[idx].ownerSide;
95-
const comma = parseInt(idx, 10) ===relationships.length-1 ? '' : ',';
98+
const isLast = parseInt(idx, 10) === mappedRelsDto.length-1;
99+
const useComma = !isLast || ((relationshipType === 'one-to-many' || relationshipType === 'many-to-many') && fluentMethods);
100+
const comma = useComma ? ',' : '';
96101
if (relationshipType === 'many-to-one' || (relationshipType === 'one-to-one' && ownerSide === true)) {
97102
_%>
98103
Mapping(source = "<%= relationshipName %>Id", target = "<%= relationshipName %>")<%= comma %>
@@ -102,16 +107,17 @@ _%>
102107
Mapping(target = "<%= relationshipNamePlural %>", ignore = true)<%= comma %>
103108
<%_ } else if (relationshipType === 'one-to-one' && ownerSide === false) { _%>
104109
Mapping(target = "<%= relationshipName %>", ignore = true)<%= comma %>
105-
<%_ } _%>
110+
<%_ }
111+
if ((relationshipType === 'one-to-many' || relationshipType === 'many-to-many') && fluentMethods) { _%>
112+
Mapping(target = "remove<%= relationshipNameCapitalized %>", ignore = true)<% if(!isLast) { %>,<% } %>
106113
<%_ } _%>
114+
<%_ } _%>
107115
<%_ if (renMapAnotDto === true) { _%>
108116
)
109117
override fun toEntity(dto: <%= asDto(entityClass) %>): <%= asEntity(entityClass) %>
110118
<%_ } _%>
111119
<%_ if (databaseType === 'sql' || databaseType === 'mongodb') { _%>
112120
113-
fun fromId(id: <%= pkType %>?): <%= asEntity(entityClass) %>? {
114-
return id?.let { <%= asEntity(entityClass) %>(it) }
115-
}
121+
fun fromId(id: <%= pkType %>?) = id?.let { <%= asEntity(entityClass) %>(it) }
116122
<%_ } _%>
117123
}

generators/entity-server/templates/src/main/kotlin/package/web/rest/EntityResource.kt.ejs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ _%><%- include('../../common/inject_template', {viaService: viaService, construc
184184
/**
185185
* `GET /<%= entityApiUrl %>` : get all the <%= entityInstancePlural %>.
186186
*<% if (pagination !== 'no') { %>
187-
* @param pageable the pagination information.<% } if (!jpaMetamodelFiltering && fieldsContainOwnerManyToMany) { %>
187+
* @param pageable the pagination information.
188+
* @param queryParams a [MultiValueMap] query parameters.
189+
* @param uriBuilder a [UriComponentsBuilder] URI builder.<% } if (!jpaMetamodelFiltering && fieldsContainOwnerManyToMany) { %>
188190
* @param eagerload flag to eager load entities from relationships (This is applicable for many-to-many).<% } if (jpaMetamodelFiltering) { %>
189191
* @param criteria the criteria which the requested entities should match.<% } else if (fieldsContainNoOwnerOneToOne) { %>
190192
* @param filter the filter of the request.<% } %>
@@ -246,7 +248,9 @@ _%><%- include('../../common/inject_template', {viaService: viaService, construc
246248
* to the query.
247249
*
248250
* @param query the query of the <%= entityInstance %> search.<% if (pagination !== 'no') { %>
249-
* @param pageable the pagination information.<% } %>
251+
* @param pageable the pagination information.
252+
* @param queryParams a [MultiValueMap] query parameters.
253+
* @param uriBuilder a [UriComponentsBuilder] URI builder.<% } %>
250254
* @return the result of the search.
251255
*/
252256
@GetMapping("/_search/<%= entityApiUrl %>")<%- include('../../common/search_template', {asEntity, asDto, viaService}); -%><% } %>

0 commit comments

Comments
 (0)