Guide: Rédiger une règle CEP
Exemple fil rouge: SI la hauteur d'eau dépasse 3m ALORS je créée une instance de risque émergeant appelé "Inondation"
Nom de la règle: tns:WaterLevelRule
Evénements d'entrée: Event_WaterStationMeasures associé au topic: WaterStationTopic accessible à l'adresse: ${eventProducerSimulatorBroker}
Condition: waterLevel > 3.0
Si condition vérifiée à l'arrivée d'un événement:
Action Emerging Risk créé comme nouveau noeud du modèle dans un espace de connaissance et une collaboration donnés (ici en cours)
nom du risque: Flooding risk at Orléans
emplacement du risque sur le modèle: '110' as node__position__x, '110' as node__position__y, '61' as node__dimension__width, '61' as node__dimension__height,
image du risque: '/##application_name##/webjars/gind/ioda/crisis_objectives/images/model/nodes/objectives/geoLoc/emergingRisk.png'
longitude associée au risque: stationLong
latitude associée au risque: stationLat
altitude associée au risque: 0.0
- XML obtenu avec l'exemple présenté
<tns:cepRule xmlns:tns="http://www.gind.emac.fr/data/CepRules" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <tns:ruleName>tns:WaterLevelRule</tns:ruleName> <tns:streamDefinition> <![CDATA[ define stream Event_WaterStationMeasures (id string, cityName string, stationName string, stationLat float, stationLong float, waterLevel float, waterFlow float); ]]> </tns:streamDefinition> <tns:rule> <![CDATA[ from Event_WaterStationMeasures[waterLevel > 3.0] select '${collaborationName}' as collaborationName, '${knowledgeSpaceName}' as knowledgeSpaceName, '{http://fr.emac.gind/crisis_objectives}Emerging Risk' as node__type, 'name' as node__property0__name, str:concat('Flooding Risk at ', stationName) as node__property0__value, 'similar concepts' as node__property1__name, '' as node__property1__value, 'Impacted components' as node__property2__name, '' as node__property2__value, 'similar concept of objective created' as node__property3__name, '' as node__property3__value, 'opportunity_threaten' as node__role0, 'emerging_risk' as node__role1, '110' as node__position__x, '110' as node__position__y, '61' as node__dimension__width, '61' as node__dimension__height, '/##application_name##/webjars/gind/ioda/crisis_objectives/images/model/nodes/objectives/geoLoc/emergingRisk.png' as node__geoLocalisation__point__image, stationLong as node__geoLocalisation__point__longitude, stationLat as node__geoLocalisation__point__latitude, '0.0' as node__geoLocalisation__point__altitude insert into addNodeEvent; ]]> </tns:rule> <tns:eventAction> <tns:eventElementName xmlns:ns12="http://www.emac.gind.fr/EventType">ns12:addNodeEvent</tns:eventElementName> <tns:schemaDefinition> <tns:url>classpath://event/EventType.xsd</tns:url> </tns:schemaDefinition> <tns:topic xmlns:s="http://www.emac.gind.fr/EventType">s:addNodeTopic</tns:topic> </tns:eventAction> <tns:context> <tns:subscriptionsRequired> <tns:entry> <tns:topic xmlns:ns12="http://www.mines-albi.fr/loireFloodingTopic">ns12:WaterStationTopic</tns:topic> <tns:correspondingEvent xmlns:ns12="http://www.mines-albi.fr/loireFloodingEvent">ns12:Event_WaterStationMeasures</tns:correspondingEvent> <tns:endpointAddressToSubscribe>${eventProducerSimulatorBroker}</tns:endpointAddressToSubscribe> </tns:entry> </tns:subscriptionsRequired> </tns:context> </tns:cepRule>
Extensions internes
type | name | description | args | comment |
---|---|---|---|---|
cypher | CypherQuery | Performs a Neo4J query | arg0 = query, | overrides process method |
model | CountNodes | Gives the numbers of nodes of a model | arg0 = model | |
model | FindNodeByProperty | Finds first node containing a given property value | arg0 = model, arg1 = propertyName, arg2 = propertyValue | |
model | FormatModelInJSON | Serializes the model in JSON | arg0 = model, arg1 = type, arg2 = template | |
model | GetId | Gets the id of a given node/edge | arg0 = BO (node or edge) | |
model | GetRoles | Gets the roles of a given node/edge | arg0 = BO (node or edge) | |
node | FindValuePropertyOnNode | Gives the value of a given property from a given node | arg0 = node, arg1 = propertyName | |
node | GetOnNode | Gives the value of a given field from a given node | arg0 = node, arg1 = fieldName | |
util | Get | Gives the value of a given field from a given generic object | arg0 = object, arg1 = fieldName | redundant? |
util | RandBound | Gives a given number (int or double) | arg0 = min, arg1 = max, arg2 = type (int | double) | |
util | ToString | Returns the String value of an object | arg0 = the object | |
util | ContainsList | Returns yes if an element belongs to the given list | arg0 = the list arg1 = the element | |
util | ListIntersection | |||