Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix add webflux CI #315

Merged
merged 12 commits into from
Dec 13, 2021
72 changes: 31 additions & 41 deletions .github/workflows/webflux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ jobs:
- webflux-mongodb-es-session
- webflux-mongodb-oauth2
- webflux-gateway-jwt
# - webflux-gateway-oauth2
# - webflux-couchbase
# - webflux-couchbase-es-oauth2
# - webflux-psql - https://github.com/pgjdbc/r2dbc-postgresql/issues/397
# - webflux-mysql
# - webflux-mariadb-gradle - https://github.com/pgjdbc/r2dbc-postgresql/issues/397
- webflux-gateway-oauth2
- webflux-psql
# - webflux-psql-additional
- webflux-mariadb-gradle
- webflux-couchbase
include:
- app-type: webflux-mongodb
entity: mongodb
Expand All @@ -98,41 +97,32 @@ jobs:
war: 0
e2e: 1
testcontainers: 0
# - app-type: webflux-gateway-oauth2
# entity: none
# environment: prod
# war: 0
# e2e: 1
# testcontainers: 1
# - app-type: webflux-couchbase
# entity: couchbase
# profile: prod
# war: 0
# e2e: 1
# - app-type: webflux-couchbase-es-oauth2
# entity: couchbase
# profile: prod
# war: 0
# e2e: 1
# - app-type: webflux-psql
# entity: sql
# environment: prod
# war: 0
# e2e: 1
# testcontainers: 1
# - app-type: webflux-mysql
# entity: sqllight
# environment: prod
# war: 0
# e2e: 1
# testcontainers: 1
# Disabled because of missing mariadb Clob converter issue
# - app-type: webflux-mariadb-gradle
# entity: sqllight
# environment: prod
# war: 0
# e2e: 1
# testcontainers: 0
- app-type: webflux-gateway-oauth2
entity: none
environment: prod
war: 0
e2e: 1
testcontainers: 1
- app-type: webflux-psql
entity: sql
environment: prod
war: 0
e2e: 1
testcontainers: 0
# - suite: webflux-psql-additional
# jdl-sample: webflux-psql,custom-domain
- app-type: webflux-mariadb-gradle
entity: sqllight
environment: prod
war: 0
e2e: 1
testcontainers: 0
- app-type: webflux-couchbase
entity: couchbase
profile: prod
war: 0
e2e: 1
testcontainers: 1
env:
JHI_GENERATE_SKIP_CONFIG: 1
JHI_ENTITY: ${{ matrix.entity }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
This is a fragment file, it will be merged into to root template if available.
EJS fragments will process % delimiter tags in template and & delimiter tags in the merge process.
-%>
<&_ if (fragment.staticImportSection) { -&>
<%_ if (!embedded) { _%>
import <%= packageName %>.config.Constants.ID_DELIMITER
import org.springframework.data.couchbase.core.mapping.id.GenerationStrategy.UNIQUE
<%_ } _%>
<&_ } -&>


<&_ if (fragment.importSection) { -&>
import <%= packageName %>.config.ID_DELIMITER
import org.springframework.data.couchbase.core.mapping.id.GenerationStrategy

<%_ if (!embedded) { _%>
import org.springframework.data.annotation.Id
import org.springframework.data.couchbase.core.mapping.id.GeneratedValue
Expand Down Expand Up @@ -55,7 +52,7 @@
<%_ if (!embedded) { _%>
@SuppressWarnings("unused")
@IdPrefix
private String prefix = PREFIX
private var prefix: String = PREFIX,
<%_ } _%>
<&_ } -&>

Expand All @@ -64,7 +61,7 @@
<%_ if (field.id && !embedded) { _%>
@Id
<%_ if (field.id && !embedded) { _%>
@GeneratedValue(strategy = UNIQUE, delimiter = ID_DELIMITER)
@GeneratedValue(strategy = GenerationStrategy.UNIQUE, delimiter = ID_DELIMITER)
<%_ } _%>
<%_ } else { _%>
@Field
Expand Down Expand Up @@ -107,81 +104,29 @@
<%_ if (relationship.collection) { _%>
@JsonIgnore
@Field("<%= relationship.relationshipFieldNamePlural %>")
private Set<String> <%= relationship.relationshipFieldName %>Ids = new HashSet<>()
private var <%= relationship.relationshipFieldName %>Ids: MutableSet<String> = mutableSetOf(),
<%_ } else if (relationship.ownerSide) { _%>
@JsonIgnore
@Field("<%= relationship.relationshipFieldName %>")
private <%= relationship.otherEntity.primaryKey.type %> <%= relationship.relationshipFieldName %>Id
private var <%= relationship.relationshipFieldName %>Id: <%= relationship.otherEntity.primaryKey.type %>? = null,
<%_ } _%>
<%_ } _%>
<%_ } _%>
<&_ } -&>

<%_ for (const relationship of relationships) { _%>
<&_ if (fragment.relationship<%- relationship.relationshipNameCapitalized %>CustomSetSection) { -&>
<%_ if (relationship.collection) { _%>
public void set<%= relationship.relationshipNameCapitalizedPlural %>(Set<<%= relationship.otherEntity.persistClass %>> <%= relationship.otherEntityNamePlural %>) {
<%_ if (relationship.otherRelationship && !relationship.reference.owned) { _%>
if (this.<%= relationship.relationshipFieldNamePlural %> != null) {
<%_ if (relationship.otherRelationship.reference.collection) { _%>
this.<%= relationship.relationshipFieldNamePlural %>.forEach(i -> i.remove<%= relationship.otherRelationship.relationshipNameCapitalized %>(this))
<%_ } else { _%>
this.<%= relationship.relationshipFieldNamePlural %>.forEach(i -> i.set<%= relationship.otherRelationship.relationshipNameCapitalized %>(null))
<%_ } _%>
}
if (<%= relationship.otherEntityNamePlural %> != null) {
<%_ if (relationship.otherRelationship.reference.collection) { _%>
<%= relationship.otherEntityNamePlural %>.forEach(i -> i.add<%= relationship.otherRelationship.relationshipNameCapitalized %>(this))
<%_ } else { _%>
<%= relationship.otherEntityNamePlural %>.forEach(i -> i.set<%= relationship.otherRelationship.relationshipNameCapitalized %>(this))
<%_ } _%>
}
<%_ } _%>
this.<%= relationship.relationshipFieldNamePlural %> = <%= relationship.otherEntityNamePlural %>
<%_ if (!relationship.otherEntity.embedded) { _%>
this.<%= relationship.relationshipFieldName %>Ids = <%= relationship.otherEntityNamePlural %>.stream()
.map(<%= relationship.otherEntity.persistClass %>::getId)
.collect(Collectors.toSet())
<%_ } _%>
}
<%_ } else if (!relationship.otherEntity.embedded) { _%>
public void set<%= relationship.relationshipNameCapitalized %>(<%= relationship.otherEntity.persistClass %> <%= relationship.otherEntityName %>) {
<%_ if (relationship.otherRelationship && !relationship.reference.owned) { _%>
if (this.<%= relationship.relationshipFieldName %> != null) {
<%_ if (relationship.otherRelationship.reference.collection) { _%>
this.<%= relationship.relationshipFieldName %>.remove<%= relationship.otherRelationship.relationshipNameCapitalized %>(this)
<%_ } else { _%>
this.<%= relationship.relationshipFieldName %>.set<%= relationship.otherRelationship.relationshipNameCapitalized %>(null)
<%_ } _%>
}
if (<%= relationship.otherEntityName %> != null) {
<%_ if (relationship.otherRelationship.reference.collection) { _%>
<%= relationship.otherEntityName %>.add<%= relationship.otherRelationship.relationshipNameCapitalized %>(this)
<%_ } else { _%>
<%= relationship.otherEntityName %>.set<%= relationship.otherRelationship.relationshipNameCapitalized %>(this)
<%_ } _%>
}
<%_ } _%>
this.<%= relationship.relationshipFieldName %> = <%= relationship.otherEntityName %>
this.<%= relationship.relationshipFieldName %>Id = <%= relationship.otherEntityName %> != null ? <%= relationship.otherEntityName %>.get<%= relationship.otherEntity.primaryKey.nameCapitalized %>() : null
}
<%_ } _%>
<&_ } -&>
<%_ } _%>

<%_ for (const relationship of relationships) { _%>
<&_ if (fragment.relationship<%- relationship.relationshipNameCapitalized %>CustomAddSection) { -&>
public <%= persistClass %> add<%= relationship.relationshipNameCapitalized %>(<%= relationship.otherEntity.persistClass %> <%= relationship.otherEntityName %>) {
this.<%= relationship.relationshipFieldNamePlural %>.add(<%= relationship.otherEntityName %>)
fun add<%= relationship.relationshipNameCapitalized %>(<%= relationship.otherEntityName %>: <%= relationship.otherEntity.persistClass %>) : <%= persistClass %>{
this.<%= relationship.relationshipFieldNamePlural %>?.add(<%= relationship.otherEntityName %>)
<%_ if (!relationship.otherEntity.embedded || embedded && relationship.ownerSide) { _%>
<%_ if (!relationship.otherEntity.embedded) { _%>
this.<%= relationship.relationshipFieldName %>Ids.add(<%= relationship.otherEntityName %>.get<%= relationship.otherEntity.primaryKey.nameCapitalized %>())
this.<%= relationship.relationshipFieldName %>Ids.add(<%= relationship.otherEntityName %>.<%= relationship.otherEntity.primaryKey.name %>!!)
<%_ } _%>
<%_ if (relationship.otherRelationship) { _%>
<%_ if (!relationship.otherRelationship.collection) { _%>
<%= relationship.otherEntityName %>.set<%= relationship.otherRelationship.relationshipNameCapitalized %>(this)
<%= relationship.otherEntityName %>.<%= relationship.otherRelationship.relationshipName %> = this
<%_ } else if (relationship.otherRelationship.relationshipNamePlural && !relationship.otherEntityUser && relationship.otherRelationship.collection) { _%>
<%= relationship.otherEntityName %>.get<%= relationship.otherRelationship.relationshipNameCapitalizedPlural %>().add(this)
<%= relationship.otherEntityName %>.<%= relationship.otherRelationship.relationshipNamePlural %>?.add(this)
<%_ } _%>
<%_ } _%>
<%_ } _%>
Expand All @@ -192,17 +137,17 @@

<%_ for (const relationship of relationships) { _%>
<&_ if (fragment.relationship<%- relationship.relationshipNameCapitalized %>CustomRemoveSection) { -&>
public <%= persistClass %> remove<%= relationship.relationshipNameCapitalized %>(<%= relationship.otherEntity.persistClass %> <%= relationship.otherEntityName %>) {
this.<%= relationship.relationshipFieldNamePlural %>.remove(<%= relationship.otherEntityName %>)
fun remove<%= relationship.relationshipNameCapitalized %>(<%= relationship.otherEntityName %>: <%= relationship.otherEntity.persistClass %>): <%= persistClass %> {
this.<%= relationship.relationshipFieldNamePlural %>?.remove(<%= relationship.otherEntityName %>)
<%_ if (!relationship.otherEntity.embedded || (embedded && relationship.ownerSide)) { _%>
<%_ if (!relationship.otherEntity.embedded) { _%>
this.<%= relationship.relationshipFieldName %>Ids.remove(<%= relationship.otherEntityName %>.get<%= relationship.otherEntity.primaryKey.nameCapitalized %>())
this.<%= relationship.relationshipFieldName %>Ids.remove(<%= relationship.otherEntityName %>.<%= relationship.otherEntity.primaryKey.name %>!!)
<%_ } _%>
<%_ if (relationship.otherRelationship) { _%>
<%_ if (!relationship.otherRelationship.collection) { _%>
<%= relationship.otherEntityName %>.set<%= relationship.otherRelationship.relationshipNameCapitalized %>(null)
<%= relationship.otherEntityName %>.<%= relationship.otherRelationship.relationshipName %> = null
<%_ } else if (!relationship.otherEntityUser && relationship.otherRelationship.collection) { _%>
<%= relationship.otherEntityName %>.get<%= relationship.otherRelationship.relationshipNameCapitalizedPlural %>().remove(this)
<%= relationship.otherEntityName %>.<%= relationship.otherRelationship.relationshipNamePlural %>?.remove(this)
<%_ } _%>
<%_ } _%>
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import org.springframework.data.couchbase.repository.Query
import org.springframework.data.domain.Pageable
import com.couchbase.client.java.query.QueryScanConsistency
import org.springframework.data.couchbase.repository.ScanConsistency
import static <%= packageName %>.repository.JHipsterCouchbaseRepository.pageableStatement
import <%= packageName %>.repository.JHipsterCouchbaseRepository.Companion.pageableStatement
<%_ if (reactive) { _%>
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
Expand Down Expand Up @@ -70,49 +70,40 @@ interface <%= entityClass %>Repository: JHipsterCouchbaseRepository<<%= persistC
<%_
if (relationships.length !== 0) { %>

val SELECT = "SELECT meta(b).id as __id, meta(b).cas as __cas, b.*" + <%
for (const relationship of relationships) {
if (relationship.collection) {
%> ", (SELECT `<%= relationship.relationshipFieldName %>`.*, meta(`<%= relationship.relationshipFieldName %>`).id FROM `<%= relationship.relationshipFieldNamePlural %>` `<%= relationship.relationshipFieldName %>`) as `<%= relationship.relationshipFieldNamePlural %>`" + <%
} else {
%> ", (SELECT `<%= relationship.relationshipFieldName %>`.*, meta(`<%= relationship.relationshipFieldName %>`).id)[0] as `<%= relationship.relationshipFieldName %>`" + <%
}
} %>
" FROM #{#n1ql.bucket} b"

val JOIN = <%
relationships.forEach(function (relationship, index) {
if (!relationship.collection) { %>
" LEFT JOIN #{#n1ql.bucket} `<%= relationship.relationshipFieldName %>` ON KEYS b.`<%= relationship.relationshipFieldName %>`"<%
} else { %>
" LEFT NEST #{#n1ql.bucket} `<%= relationship.relationshipFieldNamePlural %>` ON KEYS b.`<%= relationship.relationshipFieldNamePlural %>`"<%
}
if (index < relationships.length - 1) { %>
+ <%
}
}) %>

fun findAll<% if (reactive) {%>By<% } %>(pageable: Pageable): <%= pageOrFlux %><<%= persistClass %>> {
return
<% if (!reactive) { %>PageImpl<<%= persistClass %>>(<% } %>
findAllBy(pageableStatement(pageable, "b"))
<% if (!reactive) { %>,
pageable,
count()
)<% } %>
companion object {
const val SELECT = "SELECT meta(b).id as __id, meta(b).cas as __cas, b.*" + <%
for (const relationship of relationships) {
if (relationship.collection) {
%> ", (SELECT `<%= relationship.relationshipFieldName %>`.*, meta(`<%= relationship.relationshipFieldName %>`).id FROM `<%= relationship.relationshipFieldNamePlural %>` `<%= relationship.relationshipFieldName %>`) as `<%= relationship.relationshipFieldNamePlural %>`" + <%
} else {
%> ", (SELECT `<%= relationship.relationshipFieldName %>`.*, meta(`<%= relationship.relationshipFieldName %>`).id)[0] as `<%= relationship.relationshipFieldName %>`" + <%
}
} %>
" FROM #{#n1ql.bucket} b"

const val JOIN = <% relationships.forEach(function (relationship, index) {
if (!relationship.collection) { %>
" LEFT JOIN #{#n1ql.bucket} `<%= relationship.relationshipFieldName %>` ON KEYS b.`<%= relationship.relationshipFieldName %>`"<%
} else { %>
" LEFT NEST #{#n1ql.bucket} `<%= relationship.relationshipFieldNamePlural %>` ON KEYS b.`<%= relationship.relationshipFieldNamePlural %>`"<%
} if (index < relationships.length - 1) { %> + <% } }) %>
}

override fun findAll<% if (reactive) {%>By<% } %>(pageable: Pageable): <%= pageOrFlux %><<%= persistClass %>> {
return <% if (!reactive) { %>PageImpl<<%= persistClass %>>(<% } %>findAllBy(pageableStatement(pageable, "b"))<% if (!reactive) { %>, pageable, count())<% } %>
}

@Query(SELECT + JOIN + " WHERE b.#{#n1ql.filter} #{[0]}")
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
fun findAllBy(pageableStatement: String): <%= listOrFlux %><<%= persistClass %>>
fun findAllBy(pageableStatement: String?): <%= listOrFlux %><<%= persistClass %>>

@Query(SELECT + JOIN + " WHERE b.#{#n1ql.filter}")
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
fun findAll(): <%= listOrFlux %><<%= persistClass %>>
override fun findAll(): <%= listOrFlux %><<%= persistClass %>>

@Query(SELECT + " USE KEYS $1" + JOIN)
@Query(SELECT + " USE KEYS \$1" + JOIN)
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
fun findById(id: String): <%= optionalOrMono %><<%= persistClass %>> <%
override fun findById(id: String?): <%= optionalOrMono %><<%= persistClass %>> <%
} _%>

<%_ if (searchEngineCouchbase) { _%>
Expand Down
Loading