jhipster / jhipster-core

JHipster Domain Language, used by JHipster UML and JDL-Studio to generate entities
Apache License 2.0
346 stars 116 forks source link

TypeError: Cannot set property 'microserviceName' of undefined #412

Closed kacetal closed 4 years ago

kacetal commented 4 years ago
INFO! Using JHipster version installed globally
INFO! Executing import-jdl app.jdl
INFO! Options: from-cli: true, inline: 
INFO! The JDL is being parsed.
warn: An Entity name 'User' was used: 'User' is an entity created by default by JHipster. All relationships toward it will be kept but any attributes and relationships from it will be disregarded.
info: JPAMetaModelFiltering has been detected for Borrower, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
info: JPAMetaModelFiltering has been detected for Borrow, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
info: JPAMetaModelFiltering has been detected for Book, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
info: JPAMetaModelFiltering has been detected for Author, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
info: JPAMetaModelFiltering has been detected for Publisher, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
info: JPAMetaModelFiltering has been detected for Stock, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
info: JPAMetaModelFiltering has been detected for Notification, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
info: The DTO option has been detected to be set for Borrower, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
info: The DTO option has been detected to be set for Borrow, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
info: The DTO option has been detected to be set for Book, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
info: The DTO option has been detected to be set for Author, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
info: The DTO option has been detected to be set for Publisher, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
info: The DTO option has been detected to be set for Stock, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
info: The DTO option has been detected to be set for Notification, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
TypeError: Cannot set property 'microserviceName' of undefined
Error while parsing applications and entities from the JDL TypeError: Cannot set property 'microserviceName' of undefined
TypeError: Cannot set property 'microserviceName' of undefined
    at /home/artem/.nvm/versions/node/v12.13.0/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/parsers/entity_parser.js:171:47
    at Set.forEach (<anonymous>)
    at setEntityNamesOptions (/home/artem/.nvm/versions/node/v12.13.0/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/parsers/entity_parser.js:155:22)
    at setOptions (/home/artem/.nvm/versions/node/v12.13.0/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/parsers/entity_parser.js:150:5)
    at Object.parse (/home/artem/.nvm/versions/node/v12.13.0/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/parsers/entity_parser.js:72:3)
    at getJSONEntities (/home/artem/.nvm/versions/node/v12.13.0/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/jdl/jdl_importer.js:179:23)
    at /home/artem/.nvm/versions/node/v12.13.0/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/jdl/jdl_importer.js:161:28
    at /home/artem/.nvm/versions/node/v12.13.0/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/core/jdl_object.js:78:7
    at Array.forEach (<anonymous>)
    at ValidatedJDLObject.forEachApplication (/home/artem/.nvm/versions/node/v12.13.0/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/core/jdl_object.js:76:36)
Motivation for or Use Case
Reproduce the error

jhipster import-jdl app.jdl

app.jdl

/* kacetalLibraryGateway microservice */
application {
    config {
        baseName kacetalLibraryGateway,
        packageName com.kacetal.library.gateway,
        applicationType gateway,
        serviceDiscoveryType eureka,
        buildTool maven,
        authenticationType jwt,
        databaseType sql
        prodDatabaseType postgresql,
        devDatabaseType h2Memory,
        cacheProvider hazelcast,
        searchEngine elasticsearch,
        clientFramework react,
        testFrameworks []
        nativeLanguage en,
        languages [en, fr, ru],
    }
    entities all
}

service Borrower with serviceImpl
paginate Borrower with pagination
search Borrower, BorrowerStatus with elasticsearch
filter Borrower
dto Borrower with mapstruct
microservice Borrower, BorrowerStatus with kacetalLibraryGateway
/* kacetalLibraryGateway microservice */

/* kacetalLibraryBorrow microservice */
application {
    config {
        baseName kacetalLibraryBorrow,
        applicationType microservice,
        packageName com.kacetal.library.borrow,
        serviceDiscoveryType eureka,
        authenticationType jwt,
        prodDatabaseType postgresql,
        cacheProvider hazelcast,
        searchEngine elasticsearch,
        buildTool maven,
        serverPort 8082,
        skipUserManagement true,
        nativeLanguage en,
        languages [en, fr, ru]
    }
    entities Borrow, BorrowStatus
}

service Borrow with serviceImpl
paginate Borrow with pagination
search Borrow, BorrowStatus with elasticsearch
filter Borrow
dto Borrow with mapstruct
microservice Borrow, BorrowStatus with kacetalLibraryBorrow
/* kacetalLibraryBorrow microservice */

/* kacetalLibraryBook microservice */
application {
    config {
        baseName kacetalLibraryBook,
        applicationType microservice,
        packageName com.kacetal.library.book,
        serviceDiscoveryType eureka,
        authenticationType jwt,
        prodDatabaseType postgresql,
        cacheProvider hazelcast,
        searchEngine elasticsearch,
        buildTool maven,
        serverPort 8083,
        skipUserManagement true,
        nativeLanguage en,
        languages [en, fr, ru]
    }
    entities Book, Author, Publisher
}

service Book, Author, Publisher with serviceImpl
paginate Book, Author, Publisher with pagination
search Book, Author, Publisher with elasticsearch
dto Book, Author, Publisher with mapstruct
filter Book, Author, Publisher
microservice Book, Author, Publisher with kacetalLibraryBook
/* kacetalLibraryBook microservice */

/* kacetalLibraryStock microservice */
application {
    config {
        baseName kacetalLibraryStock,
        applicationType microservice,
        packageName com.kacetal.library.stock,
        serviceDiscoveryType eureka,
        authenticationType jwt,
        prodDatabaseType postgresql,
        cacheProvider hazelcast,
        searchEngine elasticsearch,
        buildTool maven,
        serverPort 8084,
        skipUserManagement true,
        nativeLanguage en,
        languages [en, fr, ru]
    }
    entities Stock, BookStockStatus
}

service Stock with serviceImpl
paginate Stock with pagination
search Stock, BookStockStatus with elasticsearch
filter Stock
dto Stock with mapstruct
microservice Stock, BookStockStatus with kacetalLibraryStock
/* kacetalLibraryStock microservice */

/* kacetalLibraryNotification microservice */
application {
    config {
        baseName kacetalLibraryNotification,
        applicationType microservice,
        packageName com.kacetal.library.notification,
        serviceDiscoveryType eureka,
        authenticationType jwt,
        prodDatabaseType postgresql,
        cacheProvider hazelcast,
        searchEngine elasticsearch,
        buildTool maven,
        serverPort 8085,
        skipUserManagement true,
        nativeLanguage en,
        languages [en, fr, ru]
    }
    entities Notification, NotificationType
}

service Notification with serviceImpl
paginate Notification with pagination
search Notification, NotificationType with elasticsearch
filter Notification
dto Notification with mapstruct
microservice Notification, NotificationType with kacetalLibraryNotification
/* kacetalLibraryNotification microservice */

/* Entities for kacetalLibraryGateway microservice */
DEFAULT_MIN_LENGTH = 2
NAME_MAX_LENGTH = 50
PHONE_MAX_LENGTH = 20
ADDRESS_MAX_LENGTH = 200

entity Borrower {
    firstName String required minlength(DEFAULT_MIN_LENGTH) maxlength(NAME_MAX_LENGTH)
    lastName String required minlength(DEFAULT_MIN_LENGTH) maxlength(NAME_MAX_LENGTH)
    borrowerStatus BorrowerStatus required
    email String required pattern(/@/)
    phone String minlength(DEFAULT_MIN_LENGTH) maxlength(PHONE_MAX_LENGTH)
    addressLine1 String required minlength(DEFAULT_MIN_LENGTH) maxlength(ADDRESS_MAX_LENGTH)
    addressLine2 String minlength(DEFAULT_MIN_LENGTH) maxlength(ADDRESS_MAX_LENGTH)
    city String required
    country String required
}

enum BorrowerStatus {
    NON_ACTIVATED, BLOCKED_EXPIRED, BLOCKED, READY
}

relationship OneToOne {
    Borrower{user(login) required} to User
}
/* Entities for kacetalLibraryGateway microservice */

/* Entities for kacetalLibraryBorrow microservice */
DEFAULT_MIN_LENGTH = 2
DEFAULT_MAX_LENGTH = 50
MAX_PROLONGATION_TIMES = 3

entity Borrow {
    bookId Long required
    borrowerId Long required
    borrowedAt ZonedDateTime required
    borrowDuration Duration required
    borrowStatus BorrowStatus required
    notificationType String minlength(DEFAULT_MIN_LENGTH) maxlength(DEFAULT_MAX_LENGTH)
    prolonged Integer min(0) max(MAX_PROLONGATION_TIMES)
}

enum BorrowStatus {
    EXPIRED, FINISHED, PROLONGED, BORROWED, STARTED, CANCELLED
}
/* Entities for kacetalLibraryBorrow microservice */

/* Entities for kacetalLibraryBook microservice */
DEFAULT_MIN_LENGTH = 2
NAME_MAX_LENGTH = 50
DEFAULT_MAX_LENGTH = 100

entity Book {
    isbn String required unique minlength(5) maxlength(13)
    title String required maxlength(DEFAULT_MAX_LENGTH)
    publishDate ZonedDateTime required
    cover ImageBlob
}

entity Author {
    firstName String required minlength(DEFAULT_MIN_LENGTH) maxlength(NAME_MAX_LENGTH)
    lastName String required minlength(DEFAULT_MIN_LENGTH) maxlength(NAME_MAX_LENGTH)
    pseudonym String minlength(DEFAULT_MIN_LENGTH) maxlength(NAME_MAX_LENGTH)
}

entity Publisher {
    name String required unique minlength(DEFAULT_MIN_LENGTH) maxlength(DEFAULT_MAX_LENGTH)
}

relationship OneToMany {
  Publisher{books} to Book{publisher}
}

relationship ManyToMany {
  Book{authors} to Author{books}
}
/* Entities for kacetalLibraryBook microservice */

/* Entities for kacetalLibraryStock microservice */

DEFAULT_MIN_LENGTH = 2
NAME_MAX_LENGTH = 50

entity Stock {
    name String minlength(DEFAULT_MIN_LENGTH) maxlength(NAME_MAX_LENGTH)
    bookId Long required
    quantity Integer required min(0)
    BookStockStatus BookStockStatus required
}

enum BookStockStatus {
    AVAILABLE, OUT_OF_STOCK, OUT_OF_BORROW
}
/* Entities for kacetalLibraryStock microservice */

/* Entities for kacetalLibraryNotification microservice */
entity Notification {
    sentDate ZonedDateTime required
    format NotificationType required
    details String
    borrowerId Long required
    bookId Long required
}

enum NotificationType {
    EMAIL, SMS, SITE, ALL
}
/* Entities for kacetalLibraryNotification microservice */
Related issues

176 Import of Microservice Entity Fails

Suggest a Fix
JHipster Version(s)
JHipster configuration

jhipster info

INFO! Using JHipster version installed globally INFO! Executing jhipster:info INFO! Options: from-cli: true Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
/home/artem/IdeaProjects/kacetal-library
└── (empty)

cat: no such file or directory: .yo-rc.json

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)

git version 2.17.1

node: v12.13.0

npm: 6.12.0

yeoman: 3.1.1

yarn: 1.19.2

Docker version 19.03.5, build 633a0ea838

docker-compose version 1.24.1, build 4667896b

INFO! Congratulations, JHipster execution is complete!

=================

INFO! Using JHipster version installed globally INFO! Executing jhipster:info INFO! Options: from-cli: true Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
/home/artem/IdeaProjects/kacetal-library/kacetalLibraryGateway
└── (empty)
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "databaseType": "sql",
    "devDatabaseType": "h2Memory",
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "jhiPrefix": "jhi",
    "languages": [
      "en",
      "fr",
      "ru"
    ],
    "messageBroker": false,
    "nativeLanguage": "en",
    "packageName": "com.kacetal.library.gateway",
    "packageFolder": "com/kacetal/library/gateway",
    "prodDatabaseType": "postgresql",
    "searchEngine": "elasticsearch",
    "serviceDiscoveryType": "eureka",
    "skipClient": false,
    "skipServer": false,
    "testFrameworks": [],
    "websocket": false,
    "baseName": "kacetalLibraryGateway",
    "applicationType": "gateway",
    "buildTool": "maven",
    "authenticationType": "jwt",
    "cacheProvider": "hazelcast",
    "clientFramework": "react",
    "jhipsterVersion": "6.5.1",
    "skipUserManagement": false,
    "clientPackageManager": "npm",
    "serverPort": "8080",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "useSass": true
  },
  "entities": [
    "Borrower",
    "Borrow",
    "Book",
    "Author",
    "Publisher",
    "Stock",
    "Notification"
  ]
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)

git version 2.17.1

node: v12.13.0

npm: 6.12.0

yeoman: 3.1.1

yarn: 1.19.2

Docker version 19.03.5, build 633a0ea838

docker-compose version 1.24.1, build 4667896b

INFO! Congratulations, JHipster execution is complete!

Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System

Ubuntu 18.04

MathieuAA commented 4 years ago

The issue is that you treat the BorrowerStatus, BookStoreStatus as if they were actual classes (entities), they aren't. For JHipster an enum it's just another type.

You can't use enums in option declarations (search ..., microservice ...) and when you use the entities keyword when declaring an application. Hope I've been clear, if not, do tell me, I'll go over the explanation.

kacetal commented 4 years ago

Thanks, it's clear