Im writing a Jhipster generator module and I need to scaffold a new entity. Just like running jhipster:entity but inside the generator javascript
How should I do this? I see in the base generator methods "addEntityToCache(...)", "addEntityToMenu(...)". But I don't see: "addEntity(definition)" where definition is the configuration json that it's stored in .jhipster
It's this feature possible? can I extend the entity sub-generator to reuse the code?
Create entity.json file inside project/.jhipster
{
"fluentMethods": true,
"relationships": [],
"fields": [
{
"fieldName": "field_name_in_pojo_class",
"fieldType": "data_type_of_that_field"
}
],
"changelogDate": "20180523121144",
"dto": "no",
"service": "serviceClass",
"entityTableName": "entity_name_here",
"jpaMetamodelFiltering": false,
"pagination": "pagination",
"microserviceName": "project_name_here",
"searchEngine": false
}
Related
I am new to using Jhipster, I generated a gateway application in which I am trying to create entities that allow filtering as indicated in https://www.jhipster.tech/entities-filtering/
My JDL application looks like this:
application {
config {
baseName Appcommun,
applicationType gateway,
packageName co.appcommunity.gateway,
serviceDiscoveryType eureka,
authenticationType jwt,
databaseType sql,
devDatabaseType h2Disk,
prodDatabaseType mysql,
cacheProvider hazelcast,
buildTool maven,
clientFramework angularX,
enableTranslation true,
nativeLanguage es,
languages [es, en],
testFrameworks [protractor]
}
entities *
}
entity Community {
name String required unique,
description String,
code String required unique,
location String,
address String required,
logo String
}
dto * with mapstruct
filter Community
service * with serviceClass
When I run the Jhipster jdl jdlfile.jdl
You can see the following messages:
info: The filter option is set for Community, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
WARNING! Not compatible with jpaMetamodelFiltering, disabling
Generated Entity JSON looks like:
{
"name": "Community",
"fields": [
{
"fieldName": "name",
"fieldType": "String",
"fieldValidateRules": ["required", "unique"]
},
{
"fieldName": "description",
"fieldType": "String"
}
],
"relationships": [],
"entityTableName": "community",
"dto": "mapstruct",
"pagination": "no",
"service": "serviceClass",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"readOnly": false,
"embedded": false,
"applications": ["easycommuniy"],
"databaseType": "sql",
"changelogDate": "20210603013758"
}
No filter service was generated.
Can any body say me what I'm doing wrong?
Can someone give me some hints? What am I doing wrong?
I tried to put jpaMetamodelFiltering": true, and regenerate the entity with the same result.
Thanks.
I am trying to add multiple models in the same time using aws CDK when one of the models is referencing the other one.
Ex:
"Gender": {
"contentType": "application/json",
"modelName": "GenderModel",
"schema": {
"type": "string",
"enum": [
"Not Specified",
"Male",
"Female",
"Non-Binary"
],
"schema": "http://json-schema.org/draft-04/schema#",
"title": "GenderModel"
}
},
and
"Requirements": {
"contentType": "application/json",
"modelName": "RequirementsModel",
"schema": {
"type": "object",
"properties": {
"gender": {
"ref": "https://apigateway.amazonaws.com/restapis/${Token[TOKEN.791]}/models/GenderModel"
}
},
"required": [
"gender",
],
"additionalProperties": false,
"schema": "http://json-schema.org/draft-04/schema#",
"title": "RequirementsModel"
}
},
When i deploy this fails with
Model reference must be in canonical form
From what i can see this fails because the GenderModel does not exists. If i first add the GenderModel in the stack and then i add the RequirementsModel and deploy again it works just fine because the GenderModel was previously created. If i want to create both of the models in the same time it will fail.
I tried to make sure the order of addModel call is correct but it seems it does not work.
Solution Found
Seems like you have to add explicitly specify the dependency.
modelB.node.addDependency(modelA)
This will avoid the error and add the models in the correct order
The problem is https://apigateway.amazonaws.com/restapis/${Token[TOKEN.791]}/models/GenderModel, specifically the ${Token[TOKEN.791]} part. When the API is not created, at CloudFormation synthetisation time, id is not known and placeholder value used - https://docs.aws.amazon.com/cdk/latest/guide/tokens.html
You can use the Ref intristic function to compose model by the reference
const getModelRef = (api: RestApi, model: Model): string =>
Fn.join(
'',
['https://apigateway.amazonaws.com/restapis/',
api.restApiId,
'/models/',
model.modelId]);
I am trying to understand the provisioning process of Digital Twins and I am reading this doc: https://learn.microsoft.com/en-us/azure/digital-twins/tutorial-facilities-setup
But I can not follow the point in this section
however, I can not understand the response for "dotnet run GetOntologies"
Anyone can help me to understand better what are those values? and how are they related to "models are available"?
In Azure Digital Twins, the Ontology entity contains a set of all types and subtypes that can be used in your application. In your example the "Required" and "Default" ontology are enabled (this is by default). If you use the REST API to see what the "Default" ontology contains you get the following:
{
"id": 2,
"name": "Default",
"loaded": true,
"types": [
{
"id": 17,
"category": "SensorDataType",
"name": "Humidity",
"disabled": false,
"logicalOrder": 0
},
{
"id": 18,
"category": "SensorDataType",
"name": "Temperature",
"disabled": false,
"logicalOrder": 0
},
{
"id": 19,
"category": "SensorDataSubtype",
"name": "RoomHumidity",
"disabled": false,
"logicalOrder": 0,
"friendlyName": "Room Humidity"
}, // etc etc
As you can see in the example above, the ontology has basic definitions for the types of sensors/spaces/data types for things related to Smart Building scenarios. The BACnet and Advanced ontologies just add different and more specific types. When you set an ontology to 'enabled', you can start using those types/subtypes. You can check them out in the REST API with:
https://your-url.your-region.azuresmartspaces.net/management/api/v1.0/ontologies/3?includes=Types
I'm currently working with Custom Entities (Developer Entities) via modifying Entities JSON Docs
I know how to create & link manually my Custom Entities with my Intents.
I had
en-US.json with customized entities (Valid json)
{
"invocation": "Test",
"intents": [
...
],
"dialogflow": {
"intents": [
{
"name": "Default Fallback Intent",
"auto": true,
"webhookUsed": true,
"fallbackIntent": true
},
{
"name": "Default Welcome Intent",
"auto": true,
"webhookUsed": true,
"events": [
{
"name": "WELCOME"
}
]
}
],
"entities": [
{
"id": "f060b6f7-7a17-4355-9fa6-3ce02f0ce33a",
"name": "additionalTopic",
"isOverridable": true,
"entries": [
{
"synonyms": [
"usuk",
"us",
"uk",
"us music",
"uk music",
"play usuk",
"play us",
"play uk",
"play us music",
"play uk music"
],
"value": "usuk"
},
{
"synonyms": [
"vn",
"vietnamese"
],
"value": "vn"
}
],
"isEnum": false,
"automatedExpansion": false
}
]
}
It looks like correct as Entities JSON Docs
I build with jovo command line : jovo build
It generated additionalTopic.json & additionalTopic_usersays_en.json in folder platforms/googleAction/dialogflow/entities, as image
These steps in above looks like OK, right?
Then I deploy to DialogFlow via jovo command line : jovo deploy --project-id PROJECT_ID
It deployed success as usually.
Last steps I going to DialogFlow Console to check Custom Entities I created,
And here it is.
Entities name appeared, but where is synonyms?
What I want is after deployed, it expects as first image in above.
Please take a look and help me find the way,
Really thanks.
p/s : I'm using DialogFlow Console version 2.
It looks like this is the bug in jovo-framework.
In this time, jovo-framework only support for DialogFlow version 1.
jovo releases note : https://github.com/jovotech/jovo-framework-nodejs/releases
I'm attempting to utilize Contentful on a current project of mine and I'm trying to understand how to filter my query results based on a field in a linked object.
My top level object contains a Link defined as such:
"name": "Service_Description",
"fields": [
{
"name": "Header",
"id": "header",
"type": "Link",
"linkType": "Entry",
"required": true,
"validations": [
{
"linkContentType": [
"offerGeneral"
]
}
],
"localized": false,
"disabled": false,
"omitted": false
},
This "header" field links to another content type that has this definition:
"fields": [
{
"name": "General",
"id": "general",
"type": "Link",
"linkType": "Entry",
"required": true,
"validations": [
{
"linkContentType": [
"genericGeneral"
]
}
],
"localized": false,
"disabled": false,
"omitted": false
},
which then links to the lowest level:
"fields": [{
"name": "TagList",
"id": "tagList",
"type": "Array",
"items": {
"type": "Link",
"linkType": "Entry",
"validations": [
{
"linkContentType": [
"tag"
]
}
]
},
"validations": []
}
where tagList is an array of tags this piece of content may have.
I want to be able to run a query from the top level object that says get me X number of these "Service_Description" content entries where it contains a tag from a supplied list of tags.
In PostMan, I've been running with this:
https://cdn.contentful.com/spaces/{SPACE_ID}/entries?access_token={ACCESS_TOKEN}&content_type=serviceDescription&include=3
I'm trying to add a filter something like so:
fields.header.fields.general.fields.tagList.sys.id%5Bin%5D={TAG_SYS_ID}
This is clearly incorrect, but I've been struggling with how to walk this relationship to achieve my goal. Perusing the documentation this seems to have something to do with includes, but I'm unsure of how to rectify the problem.
Any direction on how to achieve my goal or if this is possible?
This is now possible, something I believe was solved for in the API based on requests for this functionality. You can see the thread here.
This gist of it is that you have to query on the entries that have linked entries and then include the contentType for those linked entries in the query like so:
contentfulClient.getEntries({
'content_type': 'location',
'fields.market.fields.marketName': 'New York',
'fields.market.sys.contentType.sys.id': 'marketRegion'
})
Unfortunately what you are requesting is not currently possible in Contentful.
We were facing a very similar issue with nested/referenced content types and support said it wasn't possible.
We ended up writing a very complicated system that allowed us to do what you want. Essentially doing a full text search for the referenced content and then querying all of the parents entries. We then matched the relationships by iterating over the parents to find the relationship.
Sorry it couldn't be easier. Hopefully the devs work on something that improve this complication. We have brought this to their attention.