Arquisoft / InciManager_i2b

InciManager_i2b
MIT License
1 stars 2 forks source link

Decide which incidents to save #16

Closed alejgh closed 6 years ago

alejgh commented 6 years ago

As stated in the second deliverable:

The system will only store a selection of incidents (those submitted by a person
or entity, or some specific values submitted by sensors, not all of them).

We are free to implement this as we want. My initial idea is to have a configurations file (e.g. incidents.conf) which has a format like this:

kind=Person
kind=Entity
priority=High
...

And then have a class that reads this file and decides if a given incident must be saved or not (if it finds some value in the incident that matches the configuration file it will allow the incident to be saved). This way it is really easy for the management staff to change what incidents must be saved, even in real time with the application running.

Of course this is just a suggestion; you can do whatever seems better to you.

carmee-en commented 6 years ago

I was thinking to only store temperature/pollution values if they were greater than a value. So something likedeviationToAverage >= x, x being a double. It might be a nightmare to parse, but I'm willing to give it a try :sweat_smile:

What do you think?

alejgh commented 6 years ago

It could be great to add something like that (for pollution like you said, or temperature or other values). One possibility is the one you described (deviationToAverage >= x), but I can't think of a clean way of parsing that in java.

I would do it using a json file for the configuration like this:

{
    "temperature": {
        "type": "range",
        "max": 55,
        "min": -15
    }, 
    "kind": {
        "type": "values",
        "important": ["Person", "Entity"]
    }
}

In this case you iterate every element in the json and for every element you check the type. If the type is "range" you know there is a min and max value and you compare these values to the incident value of the property (in this case "temperature") to see if you must save it. If the type is "values" (can't think of a better name right now) you iterate every "important" value and if it matches with the incident value for that property you save it. You could add other types as needed.

The parsing will be a bit ugly no matter what we do but I think this would be the best option. You can see an example of traversing a JSON object using the jackson library in the IncidentDeserializer class.