Skip to content

Commit

Permalink
backport some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Jan 28, 2025
1 parent 1d16463 commit ea7516c
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class <%= serviceClassName %>(
const metamodelFieldName = (relationship.relationshipManyToMany || relationship.relationshipType === 'one-to-many') ? relationship.relationshipFieldNamePlural : relationship.relationshipFieldName; _%>
if (criteria.<%= relationship.relationshipName %>Id != null) {
specification = specification.and(buildSpecification(criteria.<%= relationship.relationshipName %>Id as Filter<<%= relationship.otherEntity.primaryKey.type %>>) {
it.join(<%= persistClass %>_.<%= metamodelFieldName %>, JoinType.LEFT).get(<%= asEntity(relationship.otherEntityNameCapitalized) %>_.<%= relationship.otherEntity.primaryKey.name %>)
it.join(<%= persistClass %>_.<%= metamodelFieldName %>, JoinType.LEFT).get(<%= relationship.otherEntity.persistClass %>_.<%= relationship.otherEntity.primaryKey.name %>)
})
}
<%_ }); // forEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import tech.jhipster.service.filter.*
var extraFilters = {};
fields.filter(field => !field.transient).forEach((field) => {
const fieldType = field.fieldType;
if (isFilterableType(fieldType)) {
if (field.filterableField) {
var filterType;
if (field.fieldIsEnum == true) {
filterType = fieldType + 'Filter';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ data class <%= dtoClass %>(
if (field && field.blobContentTypeText) {
property = `var ${reference.name}: String? = null`;
} else if (reference.collection && reference.relationship) {
property = `var ${reference.name}: MutableSet<${asDto(reference.relationship.otherEntity.entityNameCapitalized)}> = mutableSetOf()`;
property = `var ${reference.name}: MutableSet<${reference.relationship.otherEntity.dtoClass}> = mutableSetOf()`;
} else if (reference.relationship) {
property = `var ${reference.name}: ${asDto(reference.relationship.otherEntity.entityNameCapitalized)}? = null`;
property = `var ${reference.name}: ${reference.relationship.otherEntity.dtoClass}? = null`;
} else if (reference.type === 'byte[]') {
property = `var ${reference.name}: ByteArray? = null`;
} else if (reference.type === 'Integer') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ _%>
import <%= entityAbsoluteClass %>
import <%= entityAbsolutePackage %>.service.dto.<%= dtoClass %>

<%_ for (const otherEntity of this._.uniq(dtoRelationships.map(relationship => relationship.otherEntity).filter(otherEntity => otherEntity !== entity))) { _%>
<%_ for (const otherEntity of this._.uniq(dtoRelationships.map(relationship => relationship.otherEntity).filter(otherEntity => otherEntity.entityClass !== entityClass))) { _%>
import <%= otherEntity.entityAbsoluteClass.replace('undefined',entityAbsolutePackage ) %>
import <%= otherEntity.entityAbsolutePackage || entityAbsolutePackage %>.service.dto.<%= otherEntity.dtoClass %>
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ import java.net.URISyntaxException
<%_ if (searchEngineElasticsearch && !reactive) { _%>
import java.util.stream.Collectors
import java.util.stream.StreamSupport
import org.elasticsearch.index.query.QueryBuilders.queryStringQuery
<%_ } _%>

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
-%>
package <%= packageName %>.config

<%_ if (!skipUserManagement || authenticationTypeOauth2) { _%>
<%_ if (generateBuiltInUserEntity) { _%>
// Regex for acceptable logins
const val LOGIN_REGEX: String = "<%- LOGIN_REGEX %>"
<%_ } _%>
<%_ if (!skipUserManagement || authenticationTypeOauth2 || ['sql','mongodb','couchbase'].includes(databaseType)) { _%>
<%_ if (generateBuiltInUserEntity || ['sql','mongodb','couchbase'].includes(databaseType)) { _%>
const val SYSTEM_ACCOUNT: String = "system"
<%_ } _%>
<%_ if (!skipUserManagement || authenticationTypeOauth2) { _%>
<%_ if (generateUserManagement || authenticationTypeOauth2) { _%>
const val DEFAULT_LANGUAGE: String = "<%= nativeLanguage %>"
<%_ } _%>
<%_ if (databaseTypeCouchbase) { _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import java.util.Locale
import jakarta.mail.MessagingException

import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.MessageSource
import org.springframework.context.annotation.Lazy
import org.springframework.mail.MailException
import org.springframework.mail.javamail.JavaMailSender
import org.springframework.mail.javamail.MimeMessageHelper
Expand All @@ -54,6 +56,10 @@ class MailService(

private val log = LoggerFactory.getLogger(javaClass)

@Autowired
@Lazy
private lateinit var self: MailService

@Async
fun sendEmail(to: String, subject: String, content: String, isMultipart: Boolean, isHtml: Boolean) {
log.debug(
Expand Down Expand Up @@ -91,26 +97,26 @@ class MailService(
}
val content = templateEngine.process(templateName, context)
val subject = messageSource.getMessage(titleKey, null, locale)
sendEmail(user.email!!, subject, content, isMultipart = false, isHtml = true)
self.sendEmail(user.email!!, subject, content, isMultipart = false, isHtml = true)
}
<%_ if (!authenticationTypeOauth2) { _%>
@Async
fun sendActivationEmail(user: <%= user.persistClass %>) {
log.debug("Sending activation email to '${user.email}'")
sendEmailFromTemplate(user, "mail/activationEmail", "email.activation.title")
self.sendEmailFromTemplate(user, "mail/activationEmail", "email.activation.title")
}
@Async
fun sendCreationEmail(user: <%= user.persistClass %>) {
log.debug("Sending creation email to '${user.email}'")
sendEmailFromTemplate(user, "mail/creationEmail", "email.activation.title")
self.sendEmailFromTemplate(user, "mail/creationEmail", "email.activation.title")
}
@Async
fun sendPasswordResetMail(user: <%= user.persistClass %>) {
log.debug("Sending password reset email to '${user.email}'")
sendEmailFromTemplate(user, "mail/passwordResetEmail", "email.reset.title")
self.sendEmailFromTemplate(user, "mail/passwordResetEmail", "email.reset.title")
}
<%_ } _%>
}
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class AccountResource(
val userLogin = getCurrentUserLogin()
.orElseThrow { AccountResourceException("") }
val existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.email)
if (existingUser.isPresent && !existingUser.get().login.equals(userLogin, ignoreCase = true)) {
if (existingUser.isPresent && !existingUser.orElseThrow().login.equals(userLogin, ignoreCase = true)) {
throw EmailAlreadyUsedException()
}
val user = userRepository.findOneByLogin(userLogin)
Expand Down Expand Up @@ -455,7 +455,7 @@ class AccountResource(
fun requestPasswordReset(@RequestBody mail: String) {
val user = userService.requestPasswordReset(mail)
if (user.isPresent()) {
mailService.sendPasswordResetMail(user.get())
mailService.sendPasswordResetMail(user.orElseThrow())
} else {
// Pretend the request has been successful to prevent checking which emails really exist
// but log that an invalid attempt has been made
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const val PROBLEM_BASE_URL: String = "https://www.jhipster.tech/problem"
val DEFAULT_TYPE: URI = URI.create("$PROBLEM_BASE_URL/problem-with-message")
@JvmField
val CONSTRAINT_VIOLATION_TYPE: URI = URI.create("$PROBLEM_BASE_URL/constraint-violation")
<%_ if (!skipUserManagement) { _%>
<%_ if (generateUserManagement) { _%>
@JvmField
val INVALID_PASSWORD_TYPE: URI = URI.create("$PROBLEM_BASE_URL/invalid-password")
@JvmField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ _%>
class TechnicalStructureTest {
@ArchTest
val respectsTechnicalArchitectureLayers = layeredArchitecture()
.layer("Config").definedBy("..config..")
.layer("Config").definedBy("..config..")
<%_ if (hasClientLayer) { _%>
.layer("Client").definedBy("..client..")
.layer("Client").definedBy("..client..")
<%_ } _%>
.layer("Web").definedBy("..web..")
.optionalLayer("Service").definedBy("..service..")
.layer("Security").definedBy("..security..")
.layer("Web").definedBy("..web..")
.optionalLayer("Service").definedBy("..service..")
.layer("Security").definedBy("..security..")
<%_ if (hasDomainLayer) { _%>
.layer("Persistence").definedBy("..repository..")
.optionalLayer("Persistence").definedBy("..repository..")
.layer("Domain").definedBy("..domain..")
<%_ } _%>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class MailServiceIT {
verify(javaMailSender, atLeastOnce()).send(messageCaptor.capture())
val message = messageCaptor.value

val propertyFilePath = "i18n/messages_${getJavaLocale(langKey)}.properties"
val propertyFilePath = "i18n/messages_${getMessageSourceSuffixForLanguage(langKey)}.properties"
val resource = this::class.java.classLoader.getResource(propertyFilePath)
assertNotNull(resource)
val file = File(URI(resource.file).path)
Expand All @@ -250,7 +250,7 @@ class MailServiceIT {
/**
* Convert a lang key to the Java locale.
*/
private fun getJavaLocale(langKey: String): String {
private fun getMessageSourceSuffixForLanguage(langKey: String): String {
var javaLangKey = langKey
val matcher2 = PATTERN_LOCALE_2.matcher(langKey)
if (matcher2.matches()) {
Expand Down

0 comments on commit ea7516c

Please sign in to comment.