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

JEXL. Include attribute metadata in evaluation context #4594

Open
fgalan opened this issue Jul 10, 2024 · 5 comments
Open

JEXL. Include attribute metadata in evaluation context #4594

fgalan opened this issue Jul 10, 2024 · 5 comments
Labels
Milestone

Comments

@fgalan
Copy link
Member

fgalan commented Jul 10, 2024

Is your feature request related to a problem / use case? Please describe.

Adding attribute metadata context will enhance CB JEXL notification features. For instance, we could define a new attribute which value is the one in some metadata.

Describe the solution you'd like

Include attribute metadata in evaluation context at JEXL context building time.

Describe alternatives you've considered

Considering the following entity:

A value is 1,
A metadata MD1 value is 11
A metadata MD1 value is 12
B value is 2,
B metadata MD1 value is 21
B metadata MD1 value is 22

Alternative 1: use a metadata object, which keys would be attribute names. So evaluation context will be:

A: 1
B: 2
metadata: {
  A: {MD1: 11, MD2: 12},
  B: {MD1: 21, MD2: 22},
}

Alternative 2: don't use an object, but a "flatten" of context identifiers, this way:

A: 1
B: 2
A__metadata__MD1: 11
A__metadata__MD2: 12
B__metadata__MD1: 21
B__metadata__MD2: 22

In both case, name collision could occur (i.e. new object metadata could collide if some attribute is named metatata in alterative 1 and the same with attributes named eg. A__metadata__MD1) but this would be very weird and an anti-pattern.

Describe why you need this feature

  • To approach a new use case.
@fgalan fgalan added the backlog label Jul 10, 2024
@fgalan
Copy link
Member Author

fgalan commented Jul 10, 2024

The built-in attributes in https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/orion-api.md#builtin-metadata could be included in the context:

  • dateCreated
  • dateModified
  • previousValue
  • actionType

In fact, adding previousValue would solve issue #4560

@mrutid
Copy link
Member

mrutid commented Jul 10, 2024

For me 1) since JEXL provides great built in features to access JSON/Object data information and filtering.

@fgalan
Copy link
Member Author

fgalan commented Jul 10, 2024

After a brief internal discussion, let's go for alternative 1

@fgalan fgalan added this to the 4.1.0 milestone Jul 10, 2024
@mapedraza
Copy link
Collaborator

Did you consider to use a "less usual name", like __metadata to avoid unintentional collisions?

@fgalan
Copy link
Member Author

fgalan commented Jul 30, 2024

Did you consider to use a "less usual name", like __metadata to avoid unintentional collisions?

Maybe, but the syntax is more "dirty"...

Is any actual probability that some insane user :) names an attribute with the name metadata ?

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

No branches or pull requests

3 participants