Skip to content

Commit

Permalink
adjusts
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Sep 18, 2024
1 parent e44aec3 commit c74d5df
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions generators/bootstrap-application-base/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { lookupCommandsConfigs } from '../../lib/command/lookup-commands-configs
import { loadCommandConfigsIntoApplication, loadCommandConfigsKeysIntoTemplatesContext } from '../../lib/command/load.js';
import { getConfigWithDefaults } from '../../lib/jhipster/default-application-options.js';
import { removeFieldsWithNullishValues } from '../base/support/index.js';
import { getBlobContentType, isFieldBinaryType, isFieldBlobType } from '../../lib/application/field-types.js';
import { createAuthorityEntity, createUserEntity, createUserManagementEntity } from './utils.js';
import { exportJDLTransform, importJDLTransform } from './support/index.js';

Expand Down Expand Up @@ -360,6 +361,16 @@ export default class BootstrapApplicationBase extends BaseApplicationGenerator {
this.validateResult(loadEntitiesOtherSide(entities, { application }));

for (const entity of entities) {
for (const field of entity.fields) {
if (isFieldBinaryType(field)) {
field.fieldTypeBlobContent |= getBlobContentType(field.fieldType);
if (application.databaseTypeCassandra) {
field.fieldType = 'ByteBuffer';
} else if (isFieldBlobType(field)) {
field.fieldType = 'byte[]' as any;
}
}
}
for (const relationship of entity.relationships) {
if (relationship.ownerSide === undefined) {
// ownerSide backward compatibility
Expand Down
7 changes: 6 additions & 1 deletion lib/application/field-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export type FieldType = (typeof fieldTypes)[keyof typeof fieldTypes];

type FieldBlobType = (typeof blobFieldTypes)[keyof typeof blobFieldTypes];

type FieldBinaryType = (typeof blobFieldTypes)[keyof typeof blobFieldTypes] | 'byte[]';

export const isBlobType = (fieldType: string): fieldType is FieldBlobType => blobFieldTypesValues.includes(fieldType);

export const getBlobContentType = (fieldType: FieldBlobType) => {
Expand All @@ -52,6 +54,9 @@ export const getBlobContentType = (fieldType: FieldBlobType) => {

export const isFieldBlobType = (field: Field): field is SetFieldType<Field, 'fieldType', FieldBlobType> => isBlobType(field.fieldType);

export const isFieldBinaryType = (field: Field): field is SetFieldType<Field, 'fieldType', FieldBinaryType> =>
isBlobType(field.fieldType) || field.fieldType === 'byte[]';

export const isFieldEnumType = (field: Field): field is SetRequired<Field, 'enumFileName' | 'enumValues'> => Boolean(field.fieldValues);

export const isFieldNotEnumType = (field: Field): field is SetFieldType<Field, 'fieldType', FieldType> => Boolean(field.fieldValues);
export const isFieldNotEnumType = (field: Field): field is SetFieldType<Field, 'fieldType', FieldType> => !field.fieldValues;

0 comments on commit c74d5df

Please sign in to comment.