You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

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


  • Core models that are made available in the UI are either declared in the package streampipes-model or streampipes-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:

    1. Go to the corresponding module (e.g., streampipes-model)
    2. 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.
    3. Execute mvn typescript-generator:generate
    4. 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. 
    5. Paste the Apache Header into the generated file.
    6. 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";



  • No labels