Git Product home page Git Product logo

Comments (2)

marcc-orange avatar marcc-orange commented on June 12, 2024

I understand you are trying to serialize a Tracker type to a Text type.
This was not anticipated, so you found an edge case.

Sadly, Cepheus CEP does not handle nesting of types (it would be nice to be able to just define the nested attribute is a Tracker (e.g { "name":"nested", "type":"Tracker" } in the out configuration).

For reference, others projects having the same problem with serializing a JTS Point geometry which seem related to your issue: bedatadriven/jackson-datatype-jts#8 and bedatadriven/jackson-datatype-jts#15.

What is unclear for me, is why you would like to serialize the whole Tracker event to Text when you already asked to match all its fields to the Alert type. The time and location from an Alert are taken from the Tracker, so why not add additional attributes if you need more info from the Tracker type in your Alert type.

If this is because you simplified the statement to demonstrate the problem compared to the original Geofencing example, maybe a solution in the mean time would be transpose each of the properties from the Tracker you want in the Alert like this:

{
    "service": "test",
    "servicePath": "/tracker",
    "host": "http://172.17.0.1:8080",
    "reset": true,
    "statements": [
        "INSERT INTO Alert SELECT *, 
                                  t.id as nestedAlertId,
                                  t.location as nestedAlertLocation,
                                  t.time as nestedAlertTime
         FROM Tracker t WHERE NOT polygon({point(0, 0), point(0,50), point(50,50), point(50, 0), point(0, 0)}).contains(t.location)"
    ],
    "in": [
        {
            "id": ".*",
            "type": "Tracker",
            "isPattern": true,
            "attributes": [
                {
                    "name": "time",
                    "type": "date"
                },
                {
                    "name": "location",
                    "type": "geo:point"
                }
            ],
            "providers": [
                {
                    "url": "http://172.17.0.1:1026",
                    "service": "test",
                    "servicePath": "/tracker"
                }
            ]
        }
    ],
    "out": [
        {
            "id": "Fence1",
            "type": "Alert",
            "attributes": [
                {
                    "name": "time",
                    "type": "date"
                },
                {
                    "name": "location",
                    "type": "geo:point"
                },
                {
                    "name": "inside",
                    "type": "boolean"
                },
                {
                    "name": "nestedAlertId",
                    "type": "string"
                },
                {
                    "name": "nestedAlertLocation",
                    "type": "geo:point"
                },
                {
                    "name": "nestedAlertTime",
                    "type": "date"
                }
            ],
            "brokers": [
                {
                    "url": "http://172.17.0.1:1026",
                    "serviceName": "test",
                    "servicePath": "/tracker",
                    "authToken": null
                }
            ]
        }
    ]
}

from fiware-cepheus.

efviodo avatar efviodo commented on June 12, 2024

The reason why I am trying to serialize the whole Tracker as "text" (could be even java.util.Map) is because Cepheus is part of a much more complex architecture of an IoT application where I have multiples types of context entities and each one generates Alerts. Then I am working on a integration component that takes each Alert and for example send it to a third party system (could be fire an Email, etc).

Since each context entity have a different schema (entity type) I want to define something like an "Envelope" entity type for all the alerts in order to get a common set of attributes, most of them for internal use. That's the reason why I am putting the whole Tracker info into a single attribute in my example. Just to clarify, I am not serializing Tracker as "text", in fact I am using type "java.util.Map". I put it as "text" in the issue just to make it simple.

In the meantime I can "flat" the whole context as you suggests at the cost of losing the "common" envelope.

Thank you and I hope you can incorporate this issue as a future bug fixes.

Best Regards.

from fiware-cepheus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.