Skip to content

Commit

Permalink
derived property for datatypetypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tcharl committed Apr 13, 2021
1 parent 8b85818 commit 14fcac5
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
</a>
</li>
<!-- jhipster-needle-add-element-to-admin-menu - JHipster will add entities to the admin menu here -->
<%_ if (devDatabaseTypeH2Disk || devDatabaseTypeH2Memory || devDatabaseTypeCouchbase) { _%>
<%_ if (devDatabaseTypeH2Any || devDatabaseTypeCouchbase) { _%>
<li *ngIf="!inProduction">
<a class="dropdown-item" href="<% if (devDatabaseTypeCouchbase) { %>http://localhost:8091/<% } else if (reactive) { %> http://localhost:8092/ <% } else { %>./h2-console/<% } %>" target="_tab" (click)="collapseNavbar()">
<fa-icon icon="database" [fixedWidth]="true"></fa-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const Header = (props: IHeaderProps) => {
<Home />
{props.isAuthenticated && <EntitiesMenu />}
{props.isAuthenticated && props.isAdmin &&
<AdminMenu showOpenAPI={props.isOpenAPIEnabled} <% if (devDatabaseTypeH2Disk || devDatabaseTypeH2Memory) { %> showDatabase={!props.isInProduction} <%_ } _%> />}
<AdminMenu showOpenAPI={props.isOpenAPIEnabled} <% if (devDatabaseTypeH2Any) { %> showDatabase={!props.isInProduction} <%_ } _%> />}
<%_ if (enableTranslation) { _%>
<LocaleMenu currentLocale={props.currentLocale} onClick={handleLocaleChange} />
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ const openAPIItem = (
<MenuItem icon="book" to="/admin/docs"><Translate contentKey="global.menu.admin.apidocs">API</Translate></MenuItem>
);

<% if (devDatabaseTypeH2Disk || devDatabaseTypeH2Memory) { %>
<% if (devDatabaseTypeH2Any) { %>
const databaseItem = (
<DropdownItem tag="a" href="<% if (reactive) { %>http://localhost:8092/<% } else { %>./h2-console/<% } %>" target="_tab">
<FontAwesomeIcon icon="database" fixedWidth /> <Translate contentKey="global.menu.admin.database">Database</Translate>
</DropdownItem>
);
<%_ } _%>

export const AdminMenu = ({ showOpenAPI <% if (devDatabaseTypeH2Disk || devDatabaseTypeH2Memory) { %>, showDatabase <%_ } _%>}) => (
export const AdminMenu = ({ showOpenAPI <% if (devDatabaseTypeH2Any) { %>, showDatabase <%_ } _%>}) => (
<NavDropdown icon="users-cog" name={translate('global.menu.admin.main')} id="admin-menu" data-cy="adminMenu">
{adminMenuItems}
{showOpenAPI && openAPIItem}
<% if (devDatabaseTypeH2Disk || devDatabaseTypeH2Memory) { %>
<% if (devDatabaseTypeH2Any) { %>
{showDatabase && databaseItem}
<%_ } _%>
</NavDropdown>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<font-awesome-icon icon="book" />
<span v-text="$t('global.menu.admin.apidocs')">API</span>
</b-dropdown-item>
<%_ if (devDatabaseTypeH2Disk || devDatabaseTypeH2Memory || devDatabaseTypeCouchbase) { _%>
<%_ if (devDatabaseTypeH2Any || devDatabaseTypeCouchbase) { _%>
<b-dropdown-item v-if="!inProduction" href='<% if (devDatabaseTypeCouchbase) { %>http://localhost:8092/<% } else if (reactive) { %>http://localhost:8092/<% } else { %>./h2-console/<% } %>' target="_tab">
<font-awesome-icon icon="database" />
<span v-text="$t('global.menu.admin.database')">Database</span>
Expand Down
10 changes: 5 additions & 5 deletions generators/entity-server/templates/partials/save_template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ let mapsIdEntityInstance;
let mapsIdRepoInstance;
let otherEntityName;
if (isUsingMapsId === true) {
if (isUsingMapsId) {
mapsIdEntityInstance = mapsIdAssoc.otherEntityNameCapitalized.charAt(0).toLowerCase() + mapsIdAssoc.otherEntityNameCapitalized.slice(1);
mapsIdRepoInstance = `${mapsIdEntityInstance}Repository`;
otherEntityName = mapsIdAssoc.otherEntityName;
if (isController === true) { _%>
if (isController) { _%>
if (Objects.isNull(<%= instanceName %>.get<%= mapsIdAssoc.relationshipNameCapitalized %>())) {
throw new BadRequestAlertException("Invalid association value provided", ENTITY_NAME, "null");
}
<%_ } _%>
<%_ } _%>
<%_ if (!viaService) { _%>
<%_ if (dtoMapstruct) { _%>
resultEntity = persistInstance; _%>
<%_ resultEntity = persistInstance; _%>
<%= persistClass %> <%= persistInstance %> = <%= dtoToEntity %>(<%= instanceName %>);
<%_ if (isUsingMapsId === true) { _%>
<%_ if (isUsingMapsId) { _%>
<%= mapsIdAssoc.otherEntity.primaryKey.type %> <%= otherEntityName %>Id = <%= instanceName %>.get<%= mapsIdAssoc.relationshipNameCapitalized %>().get<%= primaryKey.nameCapitalized %>();
<%= mapsIdRepoInstance %>.findById(<%= otherEntityName %>Id).ifPresent(<%= persistInstance %>::<%_ if (!fluentMethods) { _%>set<%= mapsIdAssoc.relationshipNameCapitalized %> <%_ } else { _%><%= mapsIdAssoc.relationshipName %><%_ } _%>);
<%_ } _%>
Expand All @@ -63,7 +63,7 @@ if (isUsingMapsId === true) {
<%_ } _%>
<%_ } _%>
<%_ } else { _%>
<%_ if (isUsingMapsId === true && isController === false) { _%>
<%_ if (isUsingMapsId && !isController) { _%>
<%= mapsIdAssoc.otherEntity.primaryKey.type %> <%= otherEntityName %>Id = <%= entityInstance %>.get<%= mapsIdAssoc.relationshipNameCapitalized %>().get<%= primaryKey.nameCapitalized %>();
<%= mapsIdRepoInstance %>.findById(<%= otherEntityName %>Id).ifPresent(<%= entityInstance %>::<%_ if (!fluentMethods) { _%>set<%= mapsIdAssoc.relationshipNameCapitalized %> <%_ } else { _%><%= otherEntityName %><%_ } _%>);
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
if (queryService) {
beans.push({class: `${entityClass}QueryService`, instance: `${entityInstance}QueryService`});
}
if (isUsingMapsId === true && isController === false) {
if (isUsingMapsId && isController) {
const mapsIdEntity = mapsIdAssoc.otherEntityNameCapitalized;
const mapsIdEntityInstance = mapsIdEntity.charAt(0).toLowerCase() + mapsIdEntity.slice(1);
const mapsIdRepoInstance = `${mapsIdEntityInstance}Repository`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ _%>
<%_ if (!databaseTypeNeo4j) { _%>
<%= otherEntityName %>.set<%= otherEntityRelationshipNameCapitalized %>(this);
<%_ } _%>
<%_ } else if (otherEntityRelationshipNameCapitalizedPlural && !otherEntityUser && relationship.relationshipManyToMany) {
<%_ } else if (otherEntityRelationshipNameCapitalizedPlural && !relationship.otherEntityUser && relationship.relationshipManyToMany) {
/* JHipster version < 3.6.0 didn't ask for this relationship name */ _%>
<%= otherEntityName %>.get<%= otherEntityRelationshipNameCapitalizedPlural %>().add(this);
<%_ } _%>
Expand All @@ -627,7 +627,7 @@ _%>
<%_ if (!databaseTypeNeo4j) { _%>
<%= otherEntityName %>.set<%= otherEntityRelationshipNameCapitalized %>(null);
<%_ } _%>
<%_ } else if (otherEntityRelationshipNameCapitalizedPlural && !otherEntityUser && relationship.relationshipManyToMany) {
<%_ } else if (otherEntityRelationshipNameCapitalizedPlural && !relationship.otherEntityUser && relationship.relationshipManyToMany) {
/* JHipster version < 3.6.0 didn't ask for this relationship name */ _%>
<%= otherEntityName %>.get<%= otherEntityRelationshipNameCapitalizedPlural %>().remove(this);
<%_ } _%>
Expand Down
21 changes: 12 additions & 9 deletions generators/generator-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2581,20 +2581,21 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`;
dest.cacheProviderHazelcast = config.cacheProvider === HAZELCAST;
dest.cacheProviderMemcached = config.cacheProvider === MEMCACHED;

dest.devDatabaseTypeH2Disk = config.devDatabaseType === H2_DISK;
dest.devDatabaseTypeH2Memory = config.devDatabaseType === H2_MEMORY;
dest.devDatabaseTypeH2Any = dest.devDatabaseTypeH2Disk || dest.devDatabaseTypeH2Memory;
dest.devDatabaseTypeCouchbase = config.devDatabaseType === COUCHBASE;

dest.databaseTypeNo = config.databaseType === NO_DATABASE;
dest.databaseTypeSql = config.databaseType === SQL;
dest.databaseTypeCassandra = config.databaseType === CASSANDRA;
dest.databaseTypeCouchbase = config.databaseType === COUCHBASE;
dest.databaseTypeMongodb = config.databaseType === MONGODB;
dest.databaseTypeMysql = config.databaseType === MYSQL;
dest.databaseTypeMariadb = config.databaseType === MARIADB;
dest.databaseTypeNeo4j = config.databaseType === NEO4J;
dest.databaseTypePostgres = config.databaseType === POSTGRESQL;

dest.devDatabaseTypeH2Disk = config.devDatabaseType === H2_DISK;
dest.devDatabaseTypeH2Memory = config.devDatabaseType === H2_MEMORY;
dest.devDatabaseTypeH2Any = dest.devDatabaseTypeH2Disk || dest.devDatabaseTypeH2Memory;
dest.devDatabaseTypeCouchbase = config.devDatabaseType === COUCHBASE;
dest.databaseTypeMysql = config.databaseType === SQL && (config.devDatabaseType === MYSQL || config.prodDatabaseType === MYSQL);
dest.databaseTypeMariadb = config.databaseType === SQL && (config.devDatabaseType === MARIADB || config.prodDatabaseType === MARIADB);
dest.databaseTypePostgres =
config.databaseType === SQL && (config.devDatabaseType === POSTGRESQL || config.prodDatabaseType === POSTGRESQL);

dest.authenticationTypeSession = config.authenticationType === SESSION;
dest.authenticationTypeJwt = config.authenticationType === JWT;
Expand All @@ -2610,7 +2611,9 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`;
dest.searchEngineElasticsearch = config.searchEngine === ELASTICSEARCH;
dest.searchEngineCouchbase = config.searchEngine === COUCHBASE;

dest.reactiveSqlTestContainers = config.reactive && [MYSQL, POSTGRESQL, MSSQL, MARIADB].includes(config.prodDatabaseType);
dest.reactiveSqlTestContainers =
config.reactive &&
([MYSQL, POSTGRESQL, MSSQL, MARIADB].includes(config.prodDatabaseType) || [MYSQL, POSTGRESQL, MSSQL, MARIADB].includes(config.devDatabaseType));
}

loadPlatformConfig(config = _.defaults({}, this.jhipsterConfig, defaultConfig), dest = this) {}
Expand Down

0 comments on commit 14fcac5

Please sign in to comment.