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

Rigth type (entity vs attribute) utilization in update action #279

Open
fgalan opened this issue Aug 29, 2018 · 1 comment
Open

Rigth type (entity vs attribute) utilization in update action #279

fgalan opened this issue Aug 29, 2018 · 1 comment

Comments

@fgalan
Copy link
Member

fgalan commented Aug 29, 2018

Given this action:

"action":{
        "type":"update",
        "parameters":{
            "id":"${id}_mirror",
            "type":"device", (1)
            "attributes": [
                {
                    "name":"abnormal",
                    "type":"boolean", (2)
                    "value":"true"
                }
            ]
        }
    }

Is supposed that (1) refers to entity type and (2) referst to attribute type.

However, I'm unsure about if this is the current behaviour right now. This issue is about doing a test for taht, closing the issue with no action if everything is ok or fixing the bug in Perseo FE otherwise.

@AlvaroVega
Copy link
Member

According with

function buildUpdateOptions(action, event) {
var options,
attr,
parameterTypeGiven = action.parameters.type !== undefined;
action.parameters.id = action.parameters.id || '${id}';
action.parameters.type = action.parameters.type || '${type}' || 'None';
action.parameters.isPattern = action.parameters.isPattern || 'false';
action.parameters.attributes = action.parameters.attributes || [];
// old format, with only one attribute to update
if (action.parameters.name) {
action.parameters.attributes.push({
name: action.parameters.name,
value: action.parameters.value,
type: action.parameters.attrType
});
}
options = {
id: myutils.expandVar(action.parameters.id, event),
isPattern: myutils.expandVar(action.parameters.isPattern, event)
};
if (action.parameters.service !== undefined) {
options.service = myutils.expandVar(action.parameters.service, event);
}
if (action.parameters.subservice !== undefined) {
options.subservice = myutils.expandVar(action.parameters.subservice, event);
}
if (action.parameters.externalCBUrl !== undefined) {
options.externalCBUrl = myutils.expandVar(action.parameters.externalCBUrl, event);
}
if (action.parameters.actionType) {
options.actionType = myutils.expandVar(action.parameters.actionType, event);
}
options.attributes = [];
for (var i = 0; i < action.parameters.attributes.length; i++) {
attr = {
name: myutils.expandVar(action.parameters.attributes[i].name, event),
value: myutils.expandVar(action.parameters.attributes[i].value, event, true)
};
//The portal does not provide 'type' for attribute, "plain" rules could
if (action.parameters.attributes[i].type !== undefined) {
attr.type = myutils.expandVar(action.parameters.attributes[i].type, event);
}
options.attributes.push(attr);
}
if (event.type !== undefined || parameterTypeGiven) {
options.type = myutils.expandVar(action.parameters.type, event);
}
return options;
}

action.parameters.type is entity type
action.parameters.attributes[X].type is an attribute type

Moreover, only ${type} is expanded in entity_type.

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

No branches or pull requests

2 participants