THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
- Starting from version 0.67.0, the serialization layer is based on JSON. All previous serialization methods based on JSON-LD are removed (this only accounts for the UI and not the core model itself).
- All core classes that are reused in the UI should be auto-generated to a TypeScript model to avoid errors due to manual model creation.
- The currently supported JSON serialization framework is Jackson.
How-to: Make a StreamPipes model available in TypeScript
...
- Core models that are made available in the UI are either declared in the package ``streampipes-model`` or ``streampipes-model-client``
streampipes-model
orstreampipes-model-client
If any core model class is changed or a new model class has been created, the following steps should be done to generate the corresponding typescript model:
- Go to the corresponding module (e.g., streampipes-model)
- Annotate new models with @TsModel so that it will be considered by the typescript generator. For more complex models (e.g., using inheritance), have a look at some existing examples (e.g., StaticProperty), where some additional Jackson annotations might be required.
- Execute mvn
typescript-generator:generate
- This creates a new single class containing all models from the module. Copy that file to the UI folder (ui/src/app/core-model/gen). There should be two files present (for streampipes-model and streampipes-model-client), overwrite the existing file.
- Paste the Apache Header to the generated file.
- That's it! Your model should now be available to the UI.
Deserializing objects in the UI
Use the fromData method from the generated class:
Code Block | ||||
---|---|---|---|---|
| ||||
getOwnPipelines(): Observable<Pipeline[]> {
return this.http.get(this.platformServicesCommons.authUserBasePath() + "/pipelines/own").pipe(map(response => {
return (response as any[]).map(p => Pipeline.fromData(p));
}));
};
|
Pitfalls
If you are creating a new object from the UI, make sure that the corresponding @class field is manually set (if present), e.g.:
Code Block | ||||
---|---|---|---|---|
| ||||
let freeTextStaticProperty: FreeTextStaticProperty = new FreeTextStaticProperty;
freeTextStaticProperty[@class] = "org.apache.streampipes.model.staticproperty.FreeTextStaticProperty"; |