-
Notifications
You must be signed in to change notification settings - Fork 89
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
Provide an alternative expression plugin #800
Merged
fgalan
merged 5 commits into
telefonicaid:expression-lib-alternative-pre-landing
from
orchestracities:expression-lib-alternative
May 6, 2020
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5248c3b
add support for jexl as additional expression lanaguage
chicco785 042c9fd
fix tables using <code> and |
chicco785 8eb5505
apply fix suggested by @fgalan
chicco785 3b6824b
apply suggestion by @fgalan
chicco785 ae53333
Merge branch 'master' into expression-lib-alternative
chicco785 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,16 @@ function doActivate(newConfig, callback) { | |
commandRegistry, | ||
securityService; | ||
|
||
logger.format = logger.formatters.pipe; | ||
|
||
config.setConfig(newConfig); //moving up here because otherwise env variable are not considered by the code below | ||
|
||
if (!config.getConfig().dieOnUnexpectedError) { | ||
process.on('uncaughtException', globalErrorHandler); | ||
} | ||
|
||
newConfig = config.getConfig(); | ||
|
||
if (newConfig.contextBroker) { | ||
if (! newConfig.contextBroker.url && newConfig.contextBroker.host && newConfig.contextBroker.port) { | ||
newConfig.contextBroker.url = 'http://' + newConfig.contextBroker.host + ':' + newConfig.contextBroker.port; | ||
|
@@ -113,7 +123,16 @@ function doActivate(newConfig, callback) { | |
} | ||
} | ||
|
||
config.setConfig(newConfig); | ||
if (newConfig.defaultExpressionLanguage && | ||
(newConfig.defaultExpressionLanguage === 'legacy' || | ||
newConfig.defaultExpressionLanguage ==='jexl')){ | ||
logger.info(context, 'Using ' + newConfig.defaultExpressionLanguage + ' as default expression language'); | ||
} else { | ||
logger.info(context, 'Default expression language not set, or invalid, using legacy configuration'); | ||
newConfig.defaultExpressionLanguage = 'legacy'; | ||
} | ||
|
||
config.setConfig(newConfig); //after chaging some configuration, we re apply the configuration | ||
|
||
logger.info(context, 'Activating IOT Agent NGSI Library.'); | ||
|
||
|
@@ -156,10 +175,6 @@ function doActivate(newConfig, callback) { | |
], callback); | ||
}; | ||
|
||
if (!config.getConfig().dieOnUnexpectedError) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why delete this check? Apparently is not related with current feature, is it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it was moved upfront |
||
process.on('uncaughtException', globalErrorHandler); | ||
} | ||
|
||
config.setSecurityService(securityService); | ||
config.setRegistry(registry); | ||
config.setGroupRegistry(groupRegistry); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,12 +22,14 @@ | |
* please contact with::[email protected] | ||
* | ||
* Modified by: Daniel Calvo - ATOS Research & Innovation | ||
* Modified by: Federico M. Facca - Martel Innovate | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var _ = require('underscore'), | ||
parser = require('./expressionParser'), | ||
legacyParser = require('./expressionParser'), | ||
jexlParser = require('./jexlParser'), | ||
config = require('../commonConfig'), | ||
/*jshint unused:false*/ | ||
logger = require('logops'), | ||
|
@@ -62,7 +64,27 @@ function mergeAttributes(attrList1, attrList2) { | |
|
||
|
||
function update(entity, typeInformation, callback) { | ||
|
||
function checkJexl(typeInformation){ | ||
if (config.getConfig().defaultExpressionLanguage === 'jexl' && | ||
typeInformation.expressionLanguage && | ||
typeInformation.expressionLanguage !== 'legacy') { | ||
return true; | ||
} else if (config.getConfig().defaultExpressionLanguage === 'jexl' && | ||
!typeInformation.expressionLanguage) { | ||
return true; | ||
} else if (config.getConfig().defaultExpressionLanguage === 'legacy' && | ||
typeInformation.expressionLanguage && typeInformation.expressionLanguage === 'jexl') { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
function processEntityUpdateNgsi1(entity) { | ||
var parser = legacyParser; | ||
if (checkJexl(typeInformation)){ | ||
parser = jexlParser; | ||
} | ||
var expressionAttributes = [], | ||
ctx = parser.extractContext(entity.attributes); | ||
|
||
|
@@ -76,6 +98,10 @@ function update(entity, typeInformation, callback) { | |
} | ||
|
||
function processEntityUpdateNgsi2(attributes) { | ||
var parser = legacyParser; | ||
if (checkJexl(typeInformation)){ | ||
parser = jexlParser; | ||
} | ||
var expressionAttributes = [], | ||
ctx = parser.extractContext(attributes); | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlvaroVega not removed, but moved upfront ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i moved upfront in the code, to be sure that env variables are all checked before