THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
This documents describes the serialization layer between the UI and Core.
Basics
- 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
Automatic Generation
- Run the script create-client-model.sh. It will automatically create and copy the new model files.
- The new files can be found in:
- ui/projects/streampipes/platform-services/src/lib/model/gen/
- streampipes-model.ts
- streampipes-mode-client.ts
- ui/projects/streampipes/platform-services/src/lib/model/gen/
Manuel Steps
- Core models that are made available in the UI are either declared in the package
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/projects/streampipes/platform-services/src/lib/model/gen). There should be two files present (for streampipes-model and streampipes-model-client), overwrite the existing file.
- Paste the Apache Header into 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:
Deserialization
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.:
Creating a new object in the UI
let freeTextStaticProperty: FreeTextStaticProperty = new FreeTextStaticProperty(); freeTextStaticProperty[@class] = "org.apache.streampipes.model.staticproperty.FreeTextStaticProperty";