Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows to define custom mappings for devices and assets for a tenant group only #28

Closed
Aschen opened this issue Feb 26, 2021 · 0 comments · Fixed by #61
Closed

Allows to define custom mappings for devices and assets for a tenant group only #28

Aschen opened this issue Feb 26, 2021 · 0 comments · Fixed by #61

Comments

@Aschen
Copy link
Contributor

Aschen commented Feb 26, 2021

Description

Custom mappings for assets and sensors are general so they will be loaded in every tenant collections.

If I have 2 kinds of tenants: air-quality and water-management, they will have different metadata for sensors and assets since it's two different kind of use case.

With the current implementation, every tenant kind will share the mappings of the two use cases.

We need a way to register custom mappings only for a particular tenant kind. And if no kind is specified then the mappings is applied to every tenant kind.

Possible API:

// only for "water-management" tenants
deviceManager.registerAssetsMappings(pipesMappings, 'water-management');
deviceManager.registerAssetsMappings(valvesMappings, 'water-management');

// only for "air-quality" tenants
deviceManager.registerAssetsMappings(classroomsMappings, 'air-quality');

// for all tenants
deviceManager.registerAssetsMappings(reportsMappings);
@Leodau Leodau self-assigned this Mar 4, 2021
@Leodau Leodau changed the title Allows to define custom mappings for sensors and assets for a tenant kind only Allows to define custom mappings for sensors and assets for a tenant group only Mar 16, 2021
@Leodau Leodau removed their assignment Mar 16, 2021
@Leodau Leodau changed the title Allows to define custom mappings for sensors and assets for a tenant group only Allows to define custom mappings for devices and assets for a tenant group only Mar 17, 2021
Leodau pushed a commit that referenced this issue May 4, 2021
### What this PR does

This PR allows to have custom mapping for each tenant group for the `assets` and `devices` collections
#28
They are meant to be loaded at application startup

For `devices` collection, only `qos`, `measures`, and `metadata` fields are meant to be customized.
For `assets` collection, only `metadata` field is meant to be customized.

### How to test

1) Functional tests.

2) Clone KIoTP repo on branch `add-custom-mappings`
Install plugins and switch to the `add-custom-mappings` branch on the `device-plugin-manager`
Define your own mappings in `lib/plugins/device-manager/mappings/`
Register it in `lib/plugins/device-manager/index.ts` with the provided methods
Run KIoTP
Create and engine `kourou device-manager/engine:create -a group="groupTest" index="test"`
Verify the mappings are correctly added.

```ts
deviceManagerPlugin.devices.registerQos
deviceManagerPlugin.devices.registerMetadata
deviceManagerPlugin.devices.registerMeasure

deviceManagerPlugin.assets.registerMetadata

```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants