telefonicaid / fiware-cygnus

A connector in charge of persisting context data sources into other third-party databases and storage systems, creating a historical view of the context
https://fiware-cygnus.rtfd.io/
GNU Affero General Public License v3.0
64 stars 104 forks source link

Dynamic New Entity id for name_mappings #1743

Open YatinArora-NEC opened 5 years ago

YatinArora-NEC commented 5 years ago

Hi

I am using Cygnus-1.7.1 and i am using name mapping feature in order to shorten the collection name . I want the new Entity id should be dynamic as per the old Entity id.

The name mapping configuration is as follows:

 {
  "serviceMappings": [
    {
      "originalService": "(.+)",
      "servicePathMappings": [
        {
          "originalServicePath": "/(.+)",
          "entityMappings": [
            {
              "originalEntityId": "ReserveWaterLevel.(.+)",
              "originalEntityType": "WaterSystem",
              "newEntityId": "WaterLevel",
              "attributeMappings": []
            }
          ]
        }
      ]
    }
  ]
}

In the above configuration i am trying to make generic new EntityId that is whenever ReserveWaterLevel.1 comes it should be mapped with WaterLevel.1 ,similarly whenever ReserveWaterLevel.2 comes it should be mapped with WaterLevel.2 in a single mapping.

Anyone can suggest me how can I approach further.

fgalan commented 5 years ago

Your Cygnus version (1.7.1) is pretty old. Current one is 1.17.0 and the namemappings functionality has been improved in the meanwhile. Maybe the issue you have could have been solved.

Could you upgrade to Cygnus 1.17.0 and test again, please?

manucarrace commented 4 years ago

@YatinArora-NEC there are some examples in documentation maybe could help you.

https://github.com/telefonicaid/fiware-cygnus/blob/master/doc/cygnus-ngsi/installation_and_administration_guide/name_mappings.md#case-7-groups-maching-service-entitytype-attribute-name-and-attribute-type-in-the-same-tableprefix-depending-on-entityid

You can write "newEntityId": "WaterLevel$1" to refer to the first result of previous regular expression (...)