Business Objects and Data Sources > Alarms > Loading an Alarm Defined in XML

This section shows how to load an alarm from an XML file in a data source. For detailed information about data sources, see section Data Sources.

All you have to do is create a data source using the data source default implementation defined by IltDefaultDataSource and pass the XML file to be read to its parse method, as follows:

dataSource = new IltDefaultDataSource();  
dataSource.parse("AlarmXMLFile.xml");

Below is an example of an alarm defined in XML format. For details about the XML elements used in this example, see Table 3.1, Elements in an XML Data File.

How to Define an Alarm in XML

In this example, the first alarm object (alarm 1) is an acknowledged raw alarm with a perceived severity level of Warning, and affecting the managed object Router1. The second alarm object (alarm 2) is a nonacknowledged impact alarm with a perceived severity level of MajorHigh, and affecting the managed object Gateway1.

<cplData>  
 <addObject id="alarm 1">    
  <class>ilog.tgo.model.IltAlarm</class>    
  <attribute name="notificationId">alarm 1</attribute>    
  <attribute name="alarmAckState">true</attribute>    
  <attribute name="ackSystemId">leipzig</attribute>    
  <attribute name="ackUserId">leibniz</attribute>    
  <attribute name="ackTime">Mon, 05 Jan 2004 13:33:25 GMT+0430</attribute> 
  <attribute name="alarmRaisedTime">Mon, 05 Jan 2004 13:30:12 GMT+0430</attribute> 
  <attribute name="managedObjectInstance" javaClass="java.lang.String">Router1</attribute>    
  <attribute name="alarmType"></attribute>    
  <attribute name="perceivedSeverity">Raw.Warning</attribute>    
  <attribute name="probableCause">0</attribute>  
 </addObject>   
 <addObject id="alarm 2">    
  <class>ilog.tgo.model.IltAlarm</class>    
  <attribute name="notificationId">alarm 2</attribute>    
  <attribute name="alarmAckState">false</attribute>   
  <attribute name="alarmRaisedTime">Mon, 05 Jan 2004 13:54:52 GMT+0430</attribute> 
  <attribute name="managedObjectInstance" javaClass="java.lang.String">Gateway1</attribute>    
  <attribute name="perceivedSeverity">Impact.MajorHigh</attribute>    
  <attribute name="probableCause">303</attribute>  
 </addObject>
</cplData> 

The following figure shows the two alarms displayed in a table component:

images/alarmtable.gif

Figure 11.1 Alarms Displayed in a Table Component

The attribute managedObjectInstance may be of any Java class. To benefit from the automatic consolidation of alarm states from individual alarms, use the same value as the object identifier of the corresponding managed object. See Setting the Alarm Counters.

To set a value in XML, specify the Java class of the value. For well-known classes, use:

<attribute name="comments" javaClass="java.lang.String">comment</attribute>.

For other specific classes, the XML format will be the same but the classes must conform to the JViews TGO type converter constraints.

For details about the well-known classes and the type converter, refer to Type Converter in the Context and Deployment Descriptor documentation.