Skip to content

Commit

Permalink
Merge pull request #280 from jhipster/fix/reactive
Browse files Browse the repository at this point in the history
Fix: reactive with Neo4J and add skip-ktlint-format flag
  • Loading branch information
sendilkumarn authored May 1, 2021
2 parents 1c7e0c1 + 2bcb469 commit 01c94e1
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 16 deletions.
7 changes: 7 additions & 0 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ const { displayLogo } = require('./util');
module.exports = class extends BaseGenerator {
constructor(args, opts) {
super(args, { fromBlueprint: true, ...opts });

// This adds support for a `--skip-ktlint-format` flag
this.option('skip-ktlint-format', {
desc: 'Indicates to skip formatting using ktlint',
type: Boolean,
defaults: false,
});
}

get initializing() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,6 @@ for (const field of filteredFields) {
<%_ } _%>
<%_ if (databaseType === 'sql' && reactive) { _%>
@Transient
<%_ } else if (databaseType === 'neo4j') { _%>
@Relationship("<%= relationshipName %>")
<%_ } _%>
var <%= relationshipFieldNamePlural %>: MutableSet<<%= asEntity(otherEntityNameCapitalized) %>>? = mutableSetOf(),

Expand Down
8 changes: 1 addition & 7 deletions generators/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ module.exports = class extends ServerGenerator {
if (!jhContext) {
this.error("This is a JHipster blueprint and should be used only like 'jhipster --blueprints myblueprint')}");
}
// This adds support for a `--skip-ktlint-format` flag
this.option('skip-ktlint-format', {
desc: 'Indicates to skip formatting using ktlint',
type: Boolean,
defaults: false,
});
}

get initializing() {
Expand Down Expand Up @@ -80,7 +74,7 @@ module.exports = class extends ServerGenerator {
const phaseFromJHipster = super._install();
const myCustomPhaseSteps = {
lintFiles() {
if (this.options['skip-ktlint-format']) {
if (this.options.skipKtlintFormat) {
this.log('Skipping ktlint format...');
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ import <%= packageName %>.security.ADMIN
import <%= packageName %>.security.jwt.JWTFilter
import <%= packageName %>.security.jwt.TokenProvider
<%_ } _%>
<%_ if (authenticationType === 'oauth2' && applicationType !== 'microservice') { _%>
import <%= packageName %>.security.extractAuthorityFromClaims
<%_ } _%>
<%_ if (authenticationType === 'session' || authenticationType === 'oauth2') { _%>
<%_ if (authenticationType === 'oauth2') { _%>
import <%= packageName %>.security.SecurityUtils
import <%= packageName %>.security.extractAuthorityFromClaims
import <%= packageName %>.security.oauth2.AudienceValidator
import <%= packageName %>.security.oauth2.JwtGrantedAuthorityConverter
import org.springframework.security.authentication.AbstractAuthenticationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ class <%= asEntity('User') %> (
<%_ if (enableHibernateCache) { _%>
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
<%_ } _%>
var persistentTokens: MutableSet<PersistentToken> = mutableSetOf()<% } %><% if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') { %>,
var persistentTokens: MutableSet<PersistentToken> = mutableSetOf()<% } %><% if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'neo4j' || databaseType === 'couchbase') { %>,
createdBy: String? = null,
createdDate: Instant? = Instant.now(),
lastModifiedBy: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ import org.springframework.data.neo4j.repository.<% if (reactive) { %>Reactive<%
interface AuthorityRepository : <% if (databaseType === 'sql') { %><% if (reactive) { %>R2dbc<% } else { %>Jpa<% } %>Repository<% } else { %><% if (reactive) { %>Reactive<% } %><% if (databaseType === 'mongodb') { %>MongoRepository<% } %><% if (databaseType === 'neo4j') { %>Neo4jRepository<% } %><% if (databaseType === 'couchbase') { %>N1qlCouchbaseRepository<% } %><% } %><Authority, String> {
<%_ if (databaseType === 'neo4j') { _%>
<% if (!reactive) { %>// See https://github.com/neo4j/sdn-rx/issues/51<%_ } _%>
<<%= asEntity('Authority') %>> findAll(): <% if (reactive) { %>Flux<% } else { %>List<% } %>
override fun findAll(): <% if (reactive) { %>Flux<% } else { %>List<% } %><<%= asEntity('Authority') %>>
<%_ } _%>
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ interface UserRepository : <% if (databaseType === 'sql') { %>JpaRepository<<%=

<%_ if (databaseType === 'neo4j') { _%>
<% if (!reactive) { %>// See https://github.com/neo4j/sdn-rx/issues/51<% } %>
fun findAll(): <%= listOrFlux %><<%= asEntity('User') %>>
override fun findAll(): <%= listOrFlux %><<%= asEntity('User') %>>
<%_ } _%>
<%_ if (databaseType === 'sql') { _%>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,6 @@ class UserService<% if (databaseType !== 'no') { %>(
<%_ } else { _%>
userRepository.save(user)
<%_ } _%>
userRepository.save(user)
.flatMap { user ->
Flux.fromIterable(user.authorities)
.flatMap { user.id?.let { it1 -> it.name?.let { it2 -> userRepository.saveUserAuthority(it1, it2) } } }
Expand Down

0 comments on commit 01c94e1

Please sign in to comment.