UNPKG

generator-begcode

Version:

Spring Boot + Angular/React/Vue in one handy generator

22 lines (21 loc) 1.35 kB
import { fieldTypes } from '../../../lib/jhipster/index.js'; import { asPostPreparingEachEntityTask } from '../../base-application/support/task-type-inference.js'; const { CommonDBTypes } = fieldTypes; const { LONG: TYPE_LONG, INTEGER: TYPE_INTEGER } = CommonDBTypes; export default asPostPreparingEachEntityTask(function postPrepareEntity({ application, entity }) { const { relationships, builtIn, name, primaryKey } = entity; if (builtIn && name === 'User' && primaryKey) { const userIdType = primaryKey.type; const idField = primaryKey.fields[0]; const idFieldName = idField.fieldName ?? 'id'; const liquibaseFakeData = application.generateUserManagement ? [ { [idFieldName]: [TYPE_INTEGER, TYPE_LONG].includes(userIdType) ? 1 : idField.generateFakeData() }, { [idFieldName]: [TYPE_INTEGER, TYPE_LONG].includes(userIdType) ? 2 : idField.generateFakeData() }, ] : []; entity.liquibaseFakeData = liquibaseFakeData; entity.fakeDataCount = liquibaseFakeData.length; } entity.anyRelationshipIsOwnerSide = relationships.filter(relationship => !(relationship.relationshipManyToOne && relationship?.bcConfig?.leftUnidirectional && relationship?.bcConfig?.leftRelateByIdEntity)).some(relationship => relationship.ownerSide); });