Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

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é
Règle Hauteur d'eau
<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

typenamedescriptionargscomment
cypherCypherQuery??

arg0 = query,
arg1 = collaborationName,
arg2 = knowledgeSpceName

overrides process method
modelCountNodesGives the numbers of nodes of a modelarg0 = model 
modelFindNodeByPropertyFinds first node containing a given property valuearg0 = model,
arg1 = propertyName,
arg2 = propertyValue
first?
modelFormatModelInJSONSerializes the model in JSONarg0 = model,
arg1 = type,
arg2 = template
 
modelGetIdGets the id of a given node/edgearg0 = BO (node or edge)Big hazardous cast in BO
nodeFindValuePropertyOnNodeGives the value of a given property from a given nodearg0 = node,
arg1 = propertyName
hazardous cast + missing index out of bounds check
nodeGetOnNodeGives the value of a given field from a given nodearg0 = node,
arg1 = fieldName
oh ... my ... god
utilGetGives the value of a given field from a given generic objectarg0 = object,
arg1 = fieldName
redundant?
utilRandBoundGives a given number (int or double)arg0 = min,
arg1 = max,
arg2 = type (int | double)
 
utilStringReturns the String value of an objectarg0 = the object 
     
     
     
     
     

 

 

A voir

  • No labels