iotagent-node-lib icon indicating copy to clipboard operation
iotagent-node-lib copied to clipboard

extend autocast feature to control each attribute

Open AlvaroVega opened this issue 3 years ago • 4 comments

autocast feature is performed by

https://github.com/telefonicaid/iotagent-node-lib/blob/9557e7568f28ee5c35116d7213c41a8a25425897/lib/services/ngsi/ngsiUtils.js#L98-L134

It was introduced by https://github.com/dcalvoalonso/iotagent-node-lib/pull/7 in 2.7.0 release of iota-node-lib

Currently is performing casting based on some attribute types (Boolean, Number, None) which is not the best. But instead of that (which is not a best approach) control cast per attribute is proposed:

    {
        "name": "myNumber",
        "type": "MyCustomType",
        "autocastType": "Number",
        "autocast" : true
    }

as was suggested in https://github.com/telefonicaid/iotagent-node-lib/pull/1020#discussion_r621073048

(autocast feature is used by iotagent-ul, but not used by iotagent-json)

AlvaroVega avatar May 12 '21 07:05 AlvaroVega

As follow up of this issue, the current autocast feature in IOTA-UL (IOTA_AUTOCAST env var and associated config.js setting) should be removed. It makes no sense to keep both system at the same time, it can be confusing for users.

fgalan avatar May 12 '21 07:05 fgalan

@AlvaroVega I am interested to work in this issue. As per my understanding , In castJsonNativeAttributes casting take place on the basis of type. and we have to extend the castJsonNativeAttributes or do casting on the basis of ( name, autocastType) attribute too. Please confirm.

Sunny-NEC avatar Sep 17 '21 05:09 Sunny-NEC

autocast should be done in base of proposed "autocastType" field and "autocast" flag of each attribute, possible in castJsonNativeAttributes or in another new function

AlvaroVega avatar Sep 28 '21 09:09 AlvaroVega

@Sunny-NEC thanks for your willingness to work on this issue! Please go ahead and create the pull request with your contribution, so we can evaluate and provide feedback.

fgalan avatar Sep 28 '21 09:09 fgalan