Skip to content

Commit

Permalink
adjusts to jhi templates
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Jul 22, 2024
1 parent 7cbfbed commit 0bf919e
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,30 +100,30 @@ data class <%= persistClass %>(
var <%= primaryKey.name %>: <%= primaryKey.type %>? = null,
<%_ } _%>
<&- fragments.classFieldsSection() -&>
<&- fragments.classFieldsSection() -&>
<%_ for (const field of fields.filter(field => !field.javaInherited && !field.transient && (embedded || !field.id || !primaryKey.composite))) { _%>
<&- fragments.field<%- field.fieldNameCapitalized %>CustomDeclarationSection() -&>
<&_ if (!fragments.field<%- field.fieldNameCapitalized %>CustomDeclarationSection()) { -&>
<&- fragments.field<%- field.fieldNameCapitalized %>CustomDeclarationSection() -&>
<&_ if (!fragments.field<%- field.fieldNameCapitalized %>CustomDeclarationSection()) { -&>
<%_ if (typeof field.javadoc !== 'undefined') { _%>
<%- formatAsFieldJavadoc(field.javadoc) %>
<%_ } _%>
<%_ if (!dtoMapstruct && typeof field.javadoc !== 'undefined') { _%>
@Schema(description = "<%- formatAsApiDescription(field.javadoc) %>"<% if (field.fieldValidationRequired) { %>, required = true<% } %>)
<%_ } _%>
<&- fragments.field<%- field.fieldNameCapitalized %>AnnotationSection() -&>
<&- fragments.field<%- field.fieldNameCapitalized %>AnnotationSection() -&>
var <%= field.fieldName %>: <% if(field.fieldTypeBlobContent === 'text') { _%>String<% } else if(field.fieldType === 'byte[]' && field.fieldTypeBlobContent !== 'text') { _%>ByteArray<%_ } else if(field.fieldType==='Integer'){ _%>Int<%_ } else { _%><%= field.fieldType %><% } %>? = null,
<%_ if (field.fieldWithContentType) { _%>
<&- fragments.field<%- field.fieldNameCapitalized %>ContentTypeAnnotationSection() -&>
<&- fragments.field<%- field.fieldNameCapitalized %>ContentTypeAnnotationSection() -&>
var <%= field.fieldName %>ContentType: String? = null,
<%_ } _%>
<&_ } -&>
<&_ } -&>
<%_ } _%>
<&- fragments.classAdditionalFieldsSection() -&>
<&- fragments.classAdditionalFieldsSection() -&>
<&- fragments.classAdditionalRelationshipsSection() -&>
// jhipster-needle-entity-add-field - JHipster will add fields here
) : <&- fragments.extendsSection() -&> Serializable<&- fragments.additionalInterfacesSection() -&> {
) :<&- fragments.extendsSection() -&> Serializable<&- fragments.additionalInterfacesSection() -&> {
<%_
// An embedded entity should not reference entities that embed it, unless the other entities are also embedded
Expand All @@ -134,7 +134,7 @@ data class <%= persistClass %>(
@Schema(description = "<%- formatAsApiDescription(relationship.javadoc) %>")
<%_ } _%>
<%_ } _%>
<&- fragments.relationship<%- relationship.relationshipNameCapitalized %>AnnotationSection() -&>
<&- fragments.relationship<%- relationship.relationshipNameCapitalized %>AnnotationSection() -&>
<%_ if (relationship.relationshipOneToMany) { _%>
<%_ if (relationship.ignoreOtherSideProperty) { _%>
@JsonIgnoreProperties(value = [
Expand Down Expand Up @@ -168,7 +168,7 @@ data class <%= persistClass %>(
<%_ }; _%>
<&- fragments.classAdditionalFieldsMethodsSection('\n\n') -&>
<&- fragments.classAdditionalFieldsMethodsSection('\n\n') -&>
<%_
for (const relationship of relationships) {
Expand All @@ -177,11 +177,11 @@ data class <%= persistClass %>(
continue;
}
_%>
<&- fragments.relationship<%- relationship.relationshipNameCapitalized %>CustomSetSection() -&>
<&- fragments.relationship<%- relationship.relationshipNameCapitalized %>CustomSetSection() -&>
<%_ if (fluentMethods) { _%>
<%_ if (relationship.collection) { _%>
<&- fragments.relationship<%- relationship.relationshipNameCapitalized %>CustomAddSection() -&>
<&_ if (!fragments.relationship<%- relationship.relationshipNameCapitalized %>CustomAddSection()) { -&>
<&- fragments.relationship<%- relationship.relationshipNameCapitalized %>CustomAddSection() -&>
<&_ if (!fragments.relationship<%- relationship.relationshipNameCapitalized %>CustomAddSection()) { -&>
fun add<%= relationship.relationshipNameCapitalized %>(<%= relationship.otherEntityName %>: <%= relationship.otherEntity.persistClass %>) : <%= persistClass %> {
this.<%= relationship.relationshipFieldNamePlural %>?.add(<%= relationship.otherEntityName %>)
<%_ if (!relationship.otherEntity.embedded || embedded && relationship.ownerSide) { _%>
Expand All @@ -195,9 +195,9 @@ data class <%= persistClass %>(
<%_ } _%>
return this;
}
<&_ } -&>
<&- fragments.relationship<%- relationship.relationshipNameCapitalized %>CustomRemoveSection() -&>
<&_ if (!fragments.relationship<%- relationship.relationshipNameCapitalized %>CustomRemoveSection()) { -&>
<&_ } -&>
<&- fragments.relationship<%- relationship.relationshipNameCapitalized %>CustomRemoveSection() -&>
<&_ if (!fragments.relationship<%- relationship.relationshipNameCapitalized %>CustomRemoveSection()) { -&>
fun remove<%= relationship.relationshipNameCapitalized %>(<%= relationship.otherEntityName %>: <%= relationship.otherEntity.persistClass %>) : <%= persistClass %>{
this.<%= relationship.relationshipFieldNamePlural %>?.remove(<%= relationship.otherEntityName %>)
<%_ if (!relationship.otherEntity.embedded || (embedded && relationship.ownerSide)) { _%>
Expand All @@ -211,7 +211,7 @@ data class <%= persistClass %>(
<%_ } _%>
return this;
}
<&_ } -&>
<&_ } -&>
<%_ } else { _%>
fun <%= relationship.relationshipFieldName %>(<%= relationship.otherEntityName %>: <%= relationship.otherEntity.persistClass %>?): <%= persistClass %> {
this.<%= relationship.relationshipName %> = <%= relationship.otherEntityName %>
Expand All @@ -221,7 +221,7 @@ data class <%= persistClass %>(
<%_ } _%>
<%_ } _%>
<&- fragments.classAdditionalRelationshipsMethodsSection() -&>
<&- fragments.classAdditionalRelationshipsMethodsSection() -&>
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here
override fun hashCode(): Int {
Expand Down Expand Up @@ -264,6 +264,6 @@ data class <%= persistClass %>(
companion object {
private const val serialVersionUID = 1L
<&- fragments.classStaticFieldsSection() -&>
<&- fragments.classStaticFieldsSection() -&>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
<&_ } -&>

<%_ for (const field of fields) { -%>
<&_ if (fragment.field<%- field.fieldNameCapitalized %>AnnotationSection) { -&>
<&_ if (fragment.field<%- field.fieldNameCapitalized %>AnnotationSection) { -&>
<%_ if (field.id && field.fieldName != 'id') { _%>
@org.springframework.data.annotation.Id
<%_ } _%>
<&_ } -&>
<&_ } -&>
<%_ } -%>

<%_ for (const relationship of relationships) { -%>
<&_ if (fragment.relationship<%- relationship.relationshipNameCapitalized %>AnnotationSection) { -&>
<&_ if (fragment.relationship<%- relationship.relationshipNameCapitalized %>AnnotationSection) { -&>
<% // just break the cycle // in the reactive area, we already have the annotation in place
if (!relationship.ownerSide && !reactive) { %>
@org.springframework.data.annotation.Transient
<% } %>
<&_ } -&>
<&_ } -&>
<%_ } -%>

Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ import org.hibernate.annotations.CacheConcurrencyStrategy
<&_ } -&>

<%_ for (const relationship of relationships) { _%>
<&_ if (fragment.relationship<%- relationship.relationshipNameCapitalized %>AnnotationSection) { -&>
<&_ if (fragment.relationship<%- relationship.relationshipNameCapitalized %>AnnotationSection) { -&>
<%_ if (relationship.relationshipOneToMany) { _%>
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
<%_ } _%>
<%_ if (relationship.relationshipManyToMany) { _%>
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
<%_ } _%>
<&_ } -&>
<&_ } -&>
<%_ } -%>
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import org.hibernate.annotations.Type
<%_ } else { _%>
@Column(name = "<%- field.fieldNameAsDatabaseColumn %>"<% if (field.fieldValidate === true) { %><% if (field.fieldValidationMaxLength) { %>, length = <%= field.fieldValidateRulesMaxlength %><% } %><% if (field.fieldValidationRequired) { %>, nullable = false<% } %><% if (field.fieldValidationUnique) { %>, unique = true<% } %><% } %>)
<%_ } _%>
<&_ } -&>
<&_ } -&>
<%_ } -%>

<%_ for (const field of fields.filter(field => field.fieldWithContentType)) { -%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ import org.springframework.data.relational.core.mapping.Table
<&_ } -&>

<%_ for (const field of fields) { _%>
<&_ if (fragment.field<%- field.fieldNameCapitalized %>AnnotationSection) { -&>
<&_ if (fragment.field<%- field.fieldNameCapitalized %>AnnotationSection) { -&>
<%_ if (field.id) { _%>
@Id
@Id
<%_ } _%>
@Column("<%- field.fieldNameAsDatabaseColumn %>")
<&_ } -&>
@Column("<%- field.fieldNameAsDatabaseColumn %>")
<&_ } -&>
<%_ } -%>

<%_ for (const field of fields.filter(field => field.fieldWithContentType)) { _%>
Expand All @@ -47,17 +47,15 @@ import org.springframework.data.relational.core.mapping.Table
<%_ } -%>

<%_ for (const relationship of relationships) { _%>
<&_ if (fragment.relationship<%- relationship.relationshipNameCapitalized %>AnnotationSection) { -&>
@Transient
<&_ } -&>
<&_ if (fragment.relationship<%- relationship.relationshipNameCapitalized %>AnnotationSection) { -&>
@Transient
<&_ } -&>
<%_ } -%>

<%_ for (const relationship of relationships) {
const reactiveRelationshipWithId = (databaseType === 'sql' && reactive && !(relationship.relationshipOneToOne &&
(!relationship.ownerSide || (relationship.ownerSide && relationship.id))));
_%>
<%_ } _%>

<&_ if (fragment.classAdditionalRelationshipsSection) { -&>
<%_ for (const relationship of relationships) { _%>
<%_ if (relationship.ownerSide && !relationship.collection && !relationship.id) { _%>
Expand All @@ -66,3 +64,4 @@ import org.springframework.data.relational.core.mapping.Table
<%_ } _%>
<%_ } _%>
<&_ } -&>
<%_ } _%>
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
<&_ if (fragment.importSection) { -&>
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
<&_ } -&>
<&_ } -&>

<&_ if (fragment.annotationSection) { -&>
<&_ if (fragment.annotationSection) { -&>
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
<&_ } -&>
<&_ } -&>

<%_ for (const relationship of relationships) { _%>
<&_ if (fragment.relationship<%- relationship.relationshipNameCapitalized %>AnnotationSection) { -&>
<&_ if (fragment.relationship<%- relationship.relationshipNameCapitalized %>AnnotationSection) { -&>
<%_ if (relationship.relationshipOneToMany) { _%>
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
<%_ } _%>
<%_ if (relationship.relationshipManyToMany) { _%>
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
<%_ } _%>
<&_ } -&>
<&_ } -&>
<%_ } -%>

0 comments on commit 0bf919e

Please sign in to comment.