Skip to end of metadata
Go to start of metadata

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

Compare with Current View Version History

Version 1 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" 

  • Créer un document .xml par règle CEP. 

 

<?xml version="1.0" encoding="UTF-8"?> <!-- #%L cep-manager %% Copyright (C) 2014 EMAC - Gind %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% -->

  • Ouvrir la balise cepRule

<tns:cepRule xmlns:tns="http://www.gind.emac.fr/data/CepRules" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

...

 </tns:cepRule>

 

  • Définir le nom que vous souhaitez donner à la règle. 

<tns:ruleName>tns:WaterLevelRule</tns:ruleName>

  • Définir l'event stream en langage SIDDHI QL = Traduire le schéma que suit le .xml décrivant les évènements en entrée de la règle CEP
  • Ecrire la règle CEP
  • Indiquer les actions à mettre en place si la règle est vérifiée
  • Indiquer comment accèder aux événements d'entrée
  • XML vide (à compléter)
<tns:cepRule xmlns:tns="http://www.gind.emac.fr/data/CepRules" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<tns:ruleName></tns:ruleName>
	<tns:streamDefinition></tns:streamDefinition>
	<tns:rule></tns:rule>
	<tns:eventAction>
		<tns:eventElementName xmlns:ns12="http://www.emac.gind.fr/EventType"></tns:eventElementName>
		<tns:schemaDefinition>
            <tns:url></tns:url>
        </tns:schemaDefinition>
		<tns:topic xmlns:s="http://www.emac.gind.fr/EventType"></tns:topic>
	</tns:eventAction>
	<tns:context>
		<tns:subscriptionsRequired>
			<tns:entry></tns:entry>
		</tns:subscriptionsRequired>
	</tns:context>
</tns:cepRule>
  • 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>

A voir

 

 

<?xml version="1.0" encoding="UTF-8"?><!-- #%L cep-manager %% Copyright (C) 2014 EMAC - Gind %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License  as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should  have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. #L% -->
<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>

  • No labels