Updating existing objects

Shows you how to read in a file containing data for updating and removing objects. It also shows you how to update objects through the API.
The data for this part of the tutorial is in the file: <installdir>/tutorials/gettingStarted/data/updates.xml.
This part of the code is referred to as Step 6.
void step6() throws Exception{
To do Step 6:
  1. Read in the file containing the data on updating and removing objects.
    mainDataSource.parse("updates.xml");
    
    This file modifies some of the network elements described in the file elements.xml . The object to be updated is identified by its identifier. Then, the attribute to be updated is identified and the new values are given.
    For example:
    <updateObject id="BTS11">
      <attribute name="objectState"
                       javaClass="ilog.tgo.model.IltOSIObjectState">
        <state>
          <administrative>ShuttingDown</administrative>
          <operational>Enabled</operational>
          <usage>Active</usage>
        </state>
        <alarms>
          <new severity="Warning">4</new>
        </alarms>
        <procedural>Reporting</procedural>
        <repair>UnderRepair</repair>
        <performance state="Output">150</performance>
      </attribute>
    </updateObject>
    
    This XML description causes the given object state to be associated with the BTS11 object.
    Another way to update business objects is through the API. The remaining steps show you how to do this.
  2. Get a reference to an existing object from the data source.
    IltObject london = (IltObject)mainDataSource.getObject("London");
    
    The Base Station Controller london is to be updated and is retrieved from the data source.
  3. Create new state values for this object.
    IltOSI.State osiState = 
      new IltOSI.State(IltOSI.State.Operational.Enabled,
                       IltOSI.State.Usage.Idle,
                       IltOSI.State.Administrative.Locked);
    
    The values Enabled , Idle , and Locked of specific OSI states are created for this object through inner classes of IltOSI.State. The value Enabled is attributed to IltOSI.State.Operational. The value Idle is attributed to IltOSI.State.Usage. The value Locked is attributed to IltOSI.State.Administrative
  4. Create a new state, objectState , for this object with the primary state osiState .
    IltOSIObjectState objectState = new IltOSIObjectState(osiState);
    
    You create a new instance of the class IltOSIObjectState. An instance of this class represents the state of a telecom object as defined by the OSI SMF 10164-2 standard.
  5. Add two alarms to the alarm state.
    IltAlarm.State alarmState = (IltAlarm.State)objectState.getAlarmState();
    alarmState.addNewAlarm(IltAlarm.Severity.Minor);
    alarmState.addAcknowledgedAlarm(IltAlarm.Severity.Critical);
    
    You retrieve the alarm state from objectState using the method getAlarmState. addNewAlarm allows you to add an unacknowledged alarm with the severity Minor .
    The method alarmState.addAcknowledgedAlarm allows you to add an acknowledged alarm with the severity Critical .
  6. Update the state of the given object.
    london.setObjectState(objectState);
    }
    
    Here, you assign the state objectState with its possible alarms to the object london . The data source and its attached graphic components are automatically notified of this change.
    The sample should now look as shown in the following figure.
step6b.gif