Skip to content

Commit

Permalink
Merge pull request #427 from mshima/migration
Browse files Browse the repository at this point in the history
templates adjusts
  • Loading branch information
DanielFran authored Aug 6, 2024
2 parents 23b0a3f + e2ae79d commit 6db43b9
Show file tree
Hide file tree
Showing 75 changed files with 162 additions and 154 deletions.
2 changes: 2 additions & 0 deletions generators/spring-boot-v2/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export default class extends BaseApplicationGenerator {
['JWT_UserFeignClientInterceptor.', 'UserFeignClientInterceptor_jwt.'],
['OAuth2UserClientFeignConfiguration.', 'OAuth2InterceptedFeignConfiguration.'],
['OAuth2_UserFeignClientInterceptor.', 'TokenRelayRequestInterceptor.'],
['UserJWTController', 'AuthenticateController'],
['TokenProviderSecurityMetersTests', 'TokenAuthenticationSecurityMetersIT'],
]) {
// Files renamed in v8
sourceFile = sourceFile.replace(...fileMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class LocaleConfiguration {
}
}
if (locale != null) {
exchange.attributes[LOCALE_REQUEST_ATTRIBUTE_NAME] = locale
exchange.attributes[LOCALE_REQUEST_ATTRIBUTE_NAME] = locale
}
if (timeZone != null) {
exchange.attributes[TIME_ZONE_REQUEST_ATTRIBUTE_NAME] = timeZone
Expand Down
3 changes: 0 additions & 3 deletions generators/spring-boot/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ export default class extends BaseApplicationGenerator {
'JwtAuthenticationTestUtils.java',
'AuthenticationIntegrationTest.java',
'SecurityInMemoryConfiguration.java',
'TokenAuthenticationSecurityMetersIT.java',
'TokenAuthenticationIT.java',
'AuthenticateController.java',
'AuthenticateControllerIT.java',
'CRLFLogConverterTest.java',
'SpaWebFilterIT_reactive.java',
'SpaWebFilterTestController_reactive.java',
Expand Down
8 changes: 4 additions & 4 deletions generators/spring-boot/templates.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ describe('test if kotlin templates has a matching java template', async () => {
for (const file of files.filter(
file =>
// Partials reworked
!file.includes('/common/') &&
// Partials reworked
!file.includes('/partials/') &&
!file.includes('field_validators.ejs') &&
// Removed partial
!file.includes('update_template.ejs') &&
// Partials reworked
!file.includes('relationship_validators.ejs') &&
// Modularized file in JHipster 8
Expand All @@ -30,7 +30,7 @@ describe('test if kotlin templates has a matching java template', async () => {
const javaTemplate = file.replace('.kt', '.java').replace('kotlin/_package_', 'java/_package_');
const possibleTemplates = [];
let javaTemplateRelativePath;
if (['src', 'partials', 'reactive'].includes(folder)) {
if (['src', '_global_partials_entity_', 'reactive'].includes(folder)) {
javaTemplateRelativePath = relative(join(__dirname, 'templates'), javaTemplate);
possibleTemplates.push(
join(jhipster8Generators, 'server/templates', javaTemplateRelativePath),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import javax.validation.constraints.*
<%_ for (const field of fields) { _%>
<&_ if (fragment.field<%- field.fieldNameCapitalized %>AnnotationSection) { -&>
<%_ if (field.fieldValidate === true) { -%>
<%- include('../common/field_validators', {field, reactive}); -%>
<%- include('../../../../../../_global_partials_entity_/field_validators', {field, reactive}); -%>
<%_ } _%>
<&_ } -&>
<%_ } -%>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%#
Copyright 2013-2019 the original author or authors from the JHipster project.
Copyright 2013-2024 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package <%= packageName %>.client
import org.springframework.cloud.openfeign.FeignClient
import org.springframework.cloud.openfeign.FeignClientsConfiguration
import org.springframework.core.annotation.AliasFor
import kotlin.reflect.KClass
Expand All @@ -40,7 +39,7 @@ annotation class AuthorizedFeignClient(
* [feign.codec.Encoder], [feign.Contract].
*
* @return the custom `@Configuration` for the feign client.
* @see FeignClientsConfiguration for the defaults.
* @see org.springframework.cloud.openfeign.FeignClientsConfiguration for the defaults.
*/
@get:AliasFor(annotation = FeignClient::class, attribute = "configuration")
val configuration: Array<KClass<*>> = [OAuth2InterceptedFeignConfiguration::class],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ModifyServersOpenApiFilter: GlobalFilter, Ordered {
private val log = LoggerFactory.getLogger(javaClass)

private var rewritedBody = ""

fun getRewritedBody() = rewritedBody

override fun writeWith(body: Publisher<out DataBuffer>): Mono<Void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class KafkaTestContainer: InitializingBean, DisposableBean {
.withLogConsumer(Slf4jLogConsumer(log))
.withReuse(true)
}

override fun destroy() {
if (null != kafkaContainer && kafkaContainer.isRunning) {
kafkaContainer.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers.content
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.request
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.cloud.stream.test.binder.MessageCollector;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.MimeTypeUtils;
import <%= packageName %>.IntegrationTest;
import <%= packageName %>.config.EmbeddedKafka;
import <%= packageName %>.config.KafkaSseConsumer;
import <%= packageName %>.config.KafkaSseProducer;
import java.util.HashMap
import java.util.Map
import java.util.concurrent.BlockingQueue
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.cloud.stream.test.binder.MessageCollector
import org.springframework.messaging.Message
import org.springframework.messaging.MessageChannel
import org.springframework.messaging.MessageHeaders
import org.springframework.messaging.support.GenericMessage
import org.springframework.security.test.context.support.WithMockUser
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.MvcResult
import org.springframework.util.MimeTypeUtils
import <%= packageName %>.IntegrationTest
import <%= packageName %>.config.EmbeddedKafka
import <%= packageName %>.config.KafkaSseConsumer
import <%= packageName %>.config.KafkaSseProducer
@IntegrationTest
@AutoConfigureMockMvc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ class CacheConfiguration(<%_ if (!cacheProviderNo) { _%>
createCache(cm, <%= packageName %>.repository.UserRepository.USERS_BY_LOGIN_CACHE)
createCache(cm, <%= packageName %>.repository.UserRepository.USERS_BY_EMAIL_CACHE)
<%_ if (enableHibernateCache) { _%>
createCache(cm, <%= packageName %>.domain.<%= user.persistClass %>::class.java.name)
createCache(cm, <%= user.entityAbsoluteClass %>::class.java.name)
createCache(cm, <%= packageName %>.domain.Authority::class.java.name)
createCache(cm, <%= packageName %>.domain.<%= user.persistClass %>::class.java.name + ".authorities")
createCache(cm, <%= user.entityAbsoluteClass %>::class.java.name + ".authorities")
<%_ if (authenticationTypeSession) { _%>
createCache(cm, <%= packageName %>.domain.PersistentToken::class.java.name)
createCache(cm, <%= packageName %>.domain.<%= user.persistClass %>::class.java.name + ".persistentTokens")
createCache(cm, <%= user.entityAbsoluteClass %>::class.java.name + ".persistentTokens")
<%_ } _%>
<%_ } _%>
<%_ } _%>
Expand Down Expand Up @@ -731,12 +731,12 @@ class CacheConfiguration(<%_ if (!cacheProviderNo) { _%>
createCache(it, <%= packageName %>.repository.UserRepository.USERS_BY_LOGIN_CACHE, jcacheConfiguration)
createCache(it, <%= packageName %>.repository.UserRepository.USERS_BY_EMAIL_CACHE, jcacheConfiguration)
<%_ if (enableHibernateCache) { _%>
createCache(it, <%= packageName %>.domain.<%= user.persistClass %>::class.java.name, jcacheConfiguration)
createCache(it, <%= user.entityAbsoluteClass %>::class.java.name, jcacheConfiguration)
createCache(it, <%= packageName %>.domain.Authority::class.java.name, jcacheConfiguration)
createCache(it, <%= packageName %>.domain.<%= user.persistClass %>::class.java.name + ".authorities", jcacheConfiguration)
createCache(it, <%= user.entityAbsoluteClass %>::class.java.name + ".authorities", jcacheConfiguration)
<%_ if (authenticationTypeSession) { _%>
createCache(it, <%= packageName %>.domain.PersistentToken::class.java.name, jcacheConfiguration)
createCache(it, <%= packageName %>.domain.<%= user.persistClass %>::class.java.name + ".persistentTokens", jcacheConfiguration)
createCache(it, <%= user.entityAbsoluteClass %>::class.java.name + ".persistentTokens", jcacheConfiguration)
<%_ } _%>
<%_ } _%>
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ EJS fragments will process % delimiter tags in template and & delimiter tags in
<&_ if (fragment.importSection) { -&>
<%_ if (!embedded) { _%>
import <%= packageName %>.config.ID_DELIMITER
import <%= packageName %>.domain.<%= persistClass %>.Companion.TYPE_NAME
import <%= entityAbsoluteClass %>.Companion.TYPE_NAME
import org.springframework.data.couchbase.core.mapping.id.GenerationStrategy
import org.springframework.data.annotation.Id
import org.springframework.data.couchbase.core.mapping.id.GeneratedValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import java.util.UUID
import <%= packageName %>.repository.CouchbaseSearchRepository.Companion.SEARCH_CONDITION
<%_ } _%>

import <%= packageName %>.domain.<%= persistClass %>.Companion.TYPE_NAME
import <%= entityAbsoluteClass %>.Companion.TYPE_NAME

/**
* Spring Data Couchbase repository for the <%= persistClass %> entity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ interface CouchbaseSearchRepository<T, ID>: JHipsterCouchbaseRepository<T, ID> {

@Query(FIND_IDS_QUERY + " AND " + SEARCH_CONDITION)
@ScanConsistency(query = QueryScanConsistency.NOT_BOUNDED)
fun searchIds(queryString: String): <%= listOrFlux %><T>
fun searchIds(queryString: String): <%= listOrFlux %><T>

@Query(FIND_IDS_QUERY + " AND " + SEARCH_CONDITION)
@ScanConsistency(query = QueryScanConsistency.NOT_BOUNDED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package <%= packageName %>.repository
import <%= packageName %>.domain.PersistentToken
import <%= packageName %>.domain.<%= user.persistClass %>
import <%= user.entityAbsoluteClass %>
import org.springframework.data.couchbase.repository.CouchbaseRepository
import java.util.List
import java.util.Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-%>
package <%= packageName %>.repository.search
import <%= packageName %>.domain.<%= user.persistClass %>
import <%= user.entityAbsoluteClass %>
<%_ if (reactive) { _%>
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate
<%_ } else { _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package <%= packageName %>.config.dbmigrations
import <%= packageName %>.domain.Authority
import <%= packageName %>.domain.<%= user.persistClass %>
import <%= user.entityAbsoluteClass %>
import <%= packageName %>.security.ADMIN
import <%= packageName %>.security.USER
import <%= packageName %>.config.SYSTEM_ACCOUNT
Expand All @@ -44,7 +44,7 @@ class InitialSetupMigration(private val template: MongoTemplate) {
var adminAuthority = createAdminAuthority()
adminAuthority = template.save(adminAuthority)
<%_ if (!authenticationTypeOauth2) { _%>
addUsers(userAuthority, adminAuthority);
addUsers(userAuthority, adminAuthority)
<%_ } _%>
}
Expand Down Expand Up @@ -84,7 +84,7 @@ class InitialSetupMigration(private val template: MongoTemplate) {
createdDate = Instant.now(),
authorities = mutableSetOf(userAuthority)
)
return userUser;
return userUser
}
private fun createAdmin(adminAuthority: Authority, userAuthority: Authority): <%= user.persistClass %> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class <%= entityClass %>RepositoryInternalImpl(
converter
), <%= entityClass %>RepositoryInternal {
private val db: DatabaseClient = template.databaseClient;
private val db: DatabaseClient = template.databaseClient
companion object {
private val entityTable = Table.aliased("<%= entityTableName %>", EntityManager.ENTITY_ALIAS)
Expand Down Expand Up @@ -152,11 +152,11 @@ class <%= entityClass %>RepositoryInternalImpl(
override fun findById(id: <%= primaryKey.type %>?): Mono<<%= persistClass %>> {
<%_ if (primaryKey.type != 'Long') { _%>
val whereClause = Conditions.isEqual(entityTable.column("<%= primaryKey.fields[0].columnName %>"), Conditions.just(StringUtils.wrap(id.toString(), "'")));
val whereClause = Conditions.isEqual(entityTable.column("<%= primaryKey.fields[0].columnName %>"), Conditions.just(StringUtils.wrap(id.toString(), "'")))
<%_ } else { _%>
val whereClause = Conditions.isEqual(entityTable.column("<%= primaryKey.fields[0].columnName %>"), Conditions.just(id.toString()));
val whereClause = Conditions.isEqual(entityTable.column("<%= primaryKey.fields[0].columnName %>"), Conditions.just(id.toString()))
<%_ }_%>
return createQuery(null, whereClause).one();
return createQuery(null, whereClause).one()
}
<%_ if (implementsEagerLoadApis) { _%>
Expand Down Expand Up @@ -212,7 +212,7 @@ class <%= entityClass %>RepositoryInternalImpl(
protected fun deleteRelations(entityId: <%= primaryKey.type %>?): Mono<Void> {
<%_ relationships.filter(function(rel) {
return (rel.relationshipManyToMany && rel.ownerSide);
return (rel.relationshipManyToMany && rel.ownerSide)
}).forEach(function(rel, idx) { _%>
<%_ if (idx === 0) { _%>
return entityManager.deleteFromLinkTable(<%= rel.relationshipName %>Link, entityId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ class EntityManager(
fun createSelect(selectFrom: SelectFromAndJoin, entityType: Class<*>, pageable: Pageable?, where: Condition?): String {
if (pageable != null) {
if (where != null) {
return createSelectImpl(selectFrom.limitOffset(pageable.pageSize.toLong(), pageable.offset).where(where), entityType, pageable.sort);
return createSelectImpl(selectFrom.limitOffset(pageable.pageSize.toLong(), pageable.offset).where(where), entityType, pageable.sort)
} else {
return createSelectImpl(selectFrom.limitOffset(pageable.pageSize.toLong(), pageable.offset), entityType, pageable.sort);
return createSelectImpl(selectFrom.limitOffset(pageable.pageSize.toLong(), pageable.offset), entityType, pageable.sort)
}
} else {
if (where != null) {
return createSelectImpl(selectFrom.where(where), entityType, null);
return createSelectImpl(selectFrom.where(where), entityType, null)
} else {
return createSelectImpl(selectFrom, entityType, null);
return createSelectImpl(selectFrom, entityType, null)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import java.util.function.BiFunction
import org.springframework.stereotype.Service
import <%= packageName %>.domain.<%= user.persistClass %>
import <%= user.entityAbsoluteClass %>
import io.r2dbc.spi.Row
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ class MariadbTestContainer: SqlTestContainer {
mariaDBContainer?.start()
}
}

override fun getTestContainer() = mariaDBContainer as JdbcDatabaseContainer<*>
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MysqlTestContainer : SqlTestContainer {
mysqlContainer?.stop()
}
}

override fun afterPropertiesSet() {
if (null == mysqlContainer) {
mysqlContainer = MySQLContainer("<%= DOCKER_MYSQL %>-debian")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%#
Copyright 2013-2022 the original author or authors from the JHipster project.
Copyright 2013-2024 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%#
Copyright 2013-2022 the original author or authors from the JHipster project.
Copyright 2013-2024 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import tech.jhipster.config.JHipsterConstants
import org.slf4j.LoggerFactory
import org.springframework.boot.runApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
<%_ if (databaseTypeSql) { _%>
<%_ if (databaseMigrationLiquibase) { _%>
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties
<%_ } _%>
import org.springframework.boot.context.properties.EnableConfigurationProperties
Expand All @@ -38,7 +38,7 @@ import java.net.InetAddress
import java.net.UnknownHostException
@SpringBootApplication
@EnableConfigurationProperties(<% if (databaseTypeSql) { %>LiquibaseProperties::class, <% } %>ApplicationProperties::class)
@EnableConfigurationProperties(<% if (databaseMigrationLiquibase) { %>LiquibaseProperties::class, <% } %>ApplicationProperties::class)
class <%= mainClass %>(private val env: Environment) {
private val log = LoggerFactory.getLogger(javaClass)
Expand Down Expand Up @@ -90,6 +90,7 @@ class <%= mainClass %>(private val env: Environment) {
val protocol = if (env.getProperty("server.ssl.key-store") != null) {
"https"
} else "http"
val applicationName = env.getProperty("spring.application.name")
val serverPort = env.getProperty("server.port")
val contextPath = env.getProperty("server.servlet.context-path") ?: "/"
var hostAddress = "localhost"
Expand All @@ -103,7 +104,7 @@ class <%= mainClass %>(private val env: Environment) {
"""
----------------------------------------------------------
Application '${env.getProperty("spring.application.name")}' is running! Access URLs:
Application '$applicationName' is running! Access URLs:
Local: $protocol://localhost:$serverPort$contextPath
External: $protocol://$hostAddress:$serverPort$contextPath
Profile(s): ${env.activeProfiles.joinToString(",")}
Expand Down
Loading

0 comments on commit 6db43b9

Please sign in to comment.