/*
 * Licensed Materials - Property of Rogue Wave Software, Inc. 
 * © Copyright Rogue Wave Software, Inc. 2014, 2015 
 * © Copyright IBM Corp. 2009, 2014
 * © Copyright ILOG 1996, 2009
 * All Rights Reserved.
 *
 * Note to U.S. Government Users Restricted Rights:
 * The Software and Documentation were developed at private expense and
 * are "Commercial Items" as that term is defined at 48 CFR 2.101,
 * consisting of "Commercial Computer Software" and
 * "Commercial Computer Software Documentation", as such terms are
 * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4,
 * as applicable.
 */
package datasourceAPI;

import ilog.cpl.graphic.IlpPoint;
import ilog.cpl.graphic.IlpRect;
import ilog.cpl.graphic.views.IlpPolygon;
import ilog.cpl.model.IlpObject;

import ilog.tgo.model.IltAlarm;
import ilog.tgo.model.IltAlarmObjectState;
import ilog.tgo.model.IltBellcore;
import ilog.tgo.model.IltBellcoreObjectState;
import ilog.tgo.model.IltBiSONETObjectState;
import ilog.tgo.model.IltLink;
import ilog.tgo.model.IltMisc;
import ilog.tgo.model.IltNetworkElement;
import ilog.tgo.model.IltOSI;
import ilog.tgo.model.IltOSIObjectState;
import ilog.tgo.model.IltObject;
import ilog.tgo.model.IltPerformance;
import ilog.tgo.model.IltPolyGroup;
import ilog.tgo.model.IltRectGroup;
import ilog.tgo.model.IltSONET;
import ilog.tgo.model.IltSONETObjectState;

import ilog.views.IlvPoint;

/**
 * This class provides static methods to help creating the business objects
 * used in this sample.
 * 
 * <p>The object creation is kept on a different class to better illustrate
 * the difference between business objects creation and the data sources
 * hierarchy.
 * 
 * <p>Following are the business objects available from this class:
 * <ul>
 *   <li><code>SubNetwork</code> of class <code>IltNetworkElement</code>
 *   <li><code>SubNode1</code> of class <code>IltNetworkElement</code>
 *   <li><code>SubNode2</code> of class <code>IltNetworkElement</code>
 *   <li><code>SubNode1-SubNode2</code> of class <code>IltLink</code>
 *   <li><code>RectGroup</code> of class <code>IltRectGroup</code>
 *   <li><code>PolyGroup</code> of class <code>IltPolyGroup</code>
 *   <li><code>NE1</code> of class <code>IltNetworkElement</code>
 *   <li><code>NE2</code> of class <code>IltNetworkElement</code>
 *   <li><code>NE3</code> of class <code>IltNetworkElement</code>
 *   <li><code>Link1</code> of class <code>IltLink</code>
 *   <li><code>Link2</code> of class <code>IltLink</code>
 *   <li><code>Link3</code> of class <code>IltLink</code>
 *   <li><code>Link4</code> of class <code>IltLink</code>
 *   <li><code>Link5</code> of class <code>IltLink</code>
 * </ul>
 */
public final class ObjectCreationSupport {
  /**
   * This class should not be instantiated
   */
  private ObjectCreationSupport() {}
  
  private static IlvPoint[] polygonPosition = new IlvPoint[] {
      new IlvPoint(231.25f, 482.25f),   new IlvPoint(239.25f, 471.25f),
      new IlvPoint(244.25f, 425.25f),   new IlvPoint(246.25f, 396.25f),
      new IlvPoint(239.75f, 378.25f),   new IlvPoint(240.25f, 375.25f),
      new IlvPoint(246.0f, 376.25f),    new IlvPoint(248.0f, 373.75f),
      new IlvPoint(245.75f, 368.75f),   new IlvPoint(239.0f, 361.75f),
      new IlvPoint(229.75f, 358.25f),   new IlvPoint(220.25f, 339.25f),
      new IlvPoint(223.75f, 335.0f),    new IlvPoint(218.375f, 332.125f),
      new IlvPoint(217.375f, 328.125f), new IlvPoint(211.875f, 326.625f),
      new IlvPoint(210.25f, 318.25f),   new IlvPoint(204.25f, 318.25f),
      new IlvPoint(174.25f, 302.25f),   new IlvPoint(171.375f, 302.625f),
      new IlvPoint(168.125f, 305.625f), new IlvPoint(162.25f, 305.25f),
      new IlvPoint(162.25f, 299.25f),   new IlvPoint(155.125f, 296.625f),
      new IlvPoint(155.125f, 294.375f), new IlvPoint(164.25f, 291.25f),
      new IlvPoint(163.875f, 288.875f), new IlvPoint(157.625f, 287.625f),
      new IlvPoint(151.25f, 282.25f),   new IlvPoint(151.25f, 274.25f),
      new IlvPoint(170.25f, 267.25f),   new IlvPoint(183.25f, 269.25f),
      new IlvPoint(184.25f, 263.25f),   new IlvPoint(196.25f, 260.25f),
      new IlvPoint(205.25f, 274.25f),   new IlvPoint(212.25f, 271.25f),
      new IlvPoint(227.25f, 268.25f),   new IlvPoint(233.25f, 271.25f),
      new IlvPoint(238.25f, 270.25f),   new IlvPoint(234.25f, 265.25f),
      new IlvPoint(235.25f, 256.25f),   new IlvPoint(228.25f, 235.25f),
      new IlvPoint(225.75f, 230.5f),    new IlvPoint(226.25f, 227.25f),
      new IlvPoint(235.25f, 231.25f),   new IlvPoint(240.25f, 229.25f),
      new IlvPoint(243.5f, 231.5f),     new IlvPoint(245.5f, 239.75f),
      new IlvPoint(263.5f, 242.25f),    new IlvPoint(271.75f, 244.75f),
      new IlvPoint(281.25f, 241.25f),   new IlvPoint(277.25f, 234.25f),
      new IlvPoint(284.75f, 225.25f),   new IlvPoint(305.25f, 217.25f),
      new IlvPoint(314.25f, 208.25f),   new IlvPoint(316.25f, 191.25f),
      new IlvPoint(319.25f, 180.25f),   new IlvPoint(340.75f, 173.0f),
      new IlvPoint(342.25f, 181.25f),   new IlvPoint(349.75f, 187.5f),
      new IlvPoint(356.25f, 184.0f),    new IlvPoint(360.25f, 190.25f),
      new IlvPoint(360.75f, 196.0f),    new IlvPoint(365.25f, 196.25f),
      new IlvPoint(370.25f, 197.25f),   new IlvPoint(370.25f, 204.25f),
      new IlvPoint(377.25f, 203.25f),   new IlvPoint(382.25f, 204.25f),
      new IlvPoint(382.25f, 218.25f),   new IlvPoint(396.25f, 218.25f),
      new IlvPoint(399.25f, 210.25f),   new IlvPoint(401.75f, 211.25f),
      new IlvPoint(400.25f, 224.5f),    new IlvPoint(411.25f, 229.25f),
      new IlvPoint(416.25f, 235.25f),   new IlvPoint(423.25f, 235.0f),
      new IlvPoint(432.25f, 238.25f),   new IlvPoint(439.25f, 236.25f),
      new IlvPoint(445.25f, 242.25f),   new IlvPoint(450.25f, 251.25f),
      new IlvPoint(455.25f, 249.25f),   new IlvPoint(467.25f, 250.25f),
      new IlvPoint(481.25f, 255.25f),   new IlvPoint(485.25f, 259.25f),
      new IlvPoint(483.25f, 265.25f),   new IlvPoint(477.25f, 271.25f),
      new IlvPoint(473.25f, 284.25f),   new IlvPoint(470.25f, 299.25f),
      new IlvPoint(471.25f, 312.25f),   new IlvPoint(464.75f, 320.25f),
      new IlvPoint(458.25f, 315.25f),   new IlvPoint(455.25f, 319.25f),
      new IlvPoint(456.75f, 323.75f),   new IlvPoint(446.25f, 337.25f),
      new IlvPoint(441.25f, 345.25f),   new IlvPoint(435.25f, 354.25f),
      new IlvPoint(433.25f, 363.25f),   new IlvPoint(436.0f, 367.25f),
      new IlvPoint(439.25f, 362.25f),   new IlvPoint(448.25f, 358.25f),
      new IlvPoint(450.75f, 362.0f),    new IlvPoint(450.25f, 368.25f),
      new IlvPoint(457.0f, 377.25f),    new IlvPoint(456.25f, 381.75f),
      new IlvPoint(451.25f, 385.25f),   new IlvPoint(459.25f, 401.25f),
      new IlvPoint(459.25f, 406.25f),   new IlvPoint(452.25f, 410.25f),
      new IlvPoint(447.25f, 411.25f),   new IlvPoint(451.25f, 420.25f),
      new IlvPoint(456.25f, 422.25f),   new IlvPoint(457.25f, 427.25f),
      new IlvPoint(453.25f, 436.25f),   new IlvPoint(454.25f, 444.75f),
      new IlvPoint(466.25f, 453.25f),   new IlvPoint(471.0f, 451.0f),
      new IlvPoint(473.5f, 454.0f),     new IlvPoint(468.75f, 460.5f),
      new IlvPoint(469.0f, 466.75f),    new IlvPoint(447.75f, 484.0f),
      new IlvPoint(448.25f, 488.75f),   new IlvPoint(436.25f, 495.25f),
      new IlvPoint(427.5f, 495.5f),     new IlvPoint(415.75f, 489.5f),
      new IlvPoint(412.25f, 483.25f),   new IlvPoint(396.5f, 482.75f),
      new IlvPoint(384.25f, 478.75f),   new IlvPoint(378.25f, 475.25f),
      new IlvPoint(367.5f, 487.5f),     new IlvPoint(361.25f, 488.0f),
      new IlvPoint(357.75f, 491.5f),    new IlvPoint(354.5f, 509.75f),
      new IlvPoint(357.25f, 515.25f),   new IlvPoint(357.5f, 519.25f),
      new IlvPoint(348.5f, 521.5f),     new IlvPoint(344.0f, 524.0f),
      new IlvPoint(338.25f, 521.25f),   new IlvPoint(330.25f, 521.25f),
      new IlvPoint(323.25f, 517.25f),   new IlvPoint(321.75f, 512.5f),
      new IlvPoint(295.25f, 501.25f),   new IlvPoint(293.75f, 507.5f),
      new IlvPoint(284.25f, 507.5f),    new IlvPoint(274.75f, 507.75f),
      new IlvPoint(270.75f, 502.25f),   new IlvPoint(262.5f, 503.25f),
      new IlvPoint(258.25f, 498.25f),   new IlvPoint(250.75f, 496.75f),
      new IlvPoint(245.25f, 494.25f),   new IlvPoint(239.0f, 493.25f),
      new IlvPoint(241.75f, 488.25f),   new IlvPoint(239.75f, 484.75f),
      new IlvPoint(234.0f, 484.75f)
  };
  
  /**
   * Create SubNetwork object
   * <ul>
   *   <li>class:       IltNetworkElement
   *   <li>id:          SNET1
   *   <li>name:        SubNetwork
   *   <li>type:        NMW
   * </ul>
   */
  static IlpObject createSubNetwork() {
    IlpObject node = new IltNetworkElement("SNET1");
    node.setAttributeValue(IltObject.NameAttribute, "SubNetwork");
    node.setAttributeValue(IltNetworkElement.TypeAttribute, IltNetworkElement.Type.NMW);
    return node;
  }
  
  /**
   * Create BSC1 object
   * <ul>
   *   <li>class:       IltNetworkElement
   *   <li>id:          SNOD1
   *   <li>name:        BSC1
   *   <li>type:        BSC
   *   <li>position:    IlpPoint (580,80)
   *   <li>objectState: IltAlarmObjectState
   *   <li>new alarms:  Raw.Warning (2)
   * </ul>
   */
  static IlpObject createBSC1() {
    IlpObject snod = new IltNetworkElement("SNOD1");
    snod.setAttributeValue(IltObject.NameAttribute, "BSC1");
    snod.setAttributeValue(IltNetworkElement.TypeAttribute, IltNetworkElement.Type.BSC);
    snod.setAttributeValue(IltObject.PositionAttribute, new IlpPoint(580, 80));
    // Create object state (alarm object state)
    IltAlarmObjectState state = new IltAlarmObjectState();
    // Add object state to business object
    snod.setAttributeValue(IltObject.ObjectStateAttribute, state);
    // Get its alarm state
    IltAlarm.State alarms = (IltAlarm.State)state.getAlarmState();
    // Add 2 new raw.warning alarms
    alarms.setNewAlarmCount(IltAlarm.Severity.Warning, 2);
    // Add object state to business object
    snod.setAttributeValue(IltObject.ObjectStateAttribute, state);
    // Return business object
    return snod;
  }
                                     
  /**
   * Create BTS2 object
   * <ul>
   *   <li>class:       IltNetworkElement
   *   <li>id:          SNOD2
   *   <li>name:        BTS2
   *   <li>type:        BTS_Image
   *   <li>position:    IlpPoint (620,180)
   *   <li>objectState: IltOSIObjectState
   *   <li>primary:     Enabled / Active / ShuttingDown
   *   <li>secondary:   Reporting / UnderRepair
   *   <li>new alarms:  Raw.Warning (4)
   *   <li>performance: Output (150)
   * </ul>
   */
  static IlpObject createBTS2() {
    IlpObject snod = new IltNetworkElement("SNOD2");
    snod.setAttributeValue(IltObject.NameAttribute, "BTS2");
    snod.setAttributeValue(IltNetworkElement.TypeAttribute, IltNetworkElement.Type.BTS_Image);
    snod.setAttributeValue(IltObject.PositionAttribute, new IlpPoint(620, 180));
    // Define primary statuses (enabled / active / shuttingdown)
    IltOSI.State primary = new IltOSI.State(IltOSI.State.Operational.Enabled,
                                            IltOSI.State.Usage.Active,
                                            IltOSI.State.Administrative.ShuttingDown);
    // Create object state (OSI object state)
    IltOSIObjectState state = new IltOSIObjectState(primary);
    // Add object state to business object
    snod.setAttributeValue(IltObject.ObjectStateAttribute, state);
    // Define secondary statuses (reporting / underrepair)
    state.addStatus(IltOSI.Procedural.Reporting);
    state.addStatus(IltOSI.Repair.UnderRepair);
    // Get its alarm state
    IltAlarm.State alarms = (IltAlarm.State)state.getAlarmState();
    // Add 4 new raw.warning alarms
    alarms.setNewAlarmCount(IltAlarm.Severity.Warning, 4);
    // Set its performance secondary state
    state.set(IltPerformance.SecState.Output, new Float(150));
    // Return business object
    return snod;
  }
  
  /**
   * Create InternalLink object
   * <ul>
   *   <li>class:       IltLink
   *   <li>id:          ILINK
   *   <li>name:        InternalLink
   *   <li>media:       null
   *   <li>objectState: IltBiSONETObjectState
   *   <li>primary:     ActiveProtecting
   * </ul>
   */
  static IlpObject createInternalLink() {
    IlpObject link = new IltLink("ILINK");
    link.setAttributeValue(IltObject.NameAttribute, "InternalLink");
    link.setAttributeValue(IltLink.MediaAttribute, null);
    // Create object state (BiSONET object state)
    IltBiSONETObjectState state = new IltBiSONETObjectState();
    // Add object state to business object
    link.setAttributeValue(IltObject.ObjectStateAttribute, state);
    // Define primary state (activeprotecting)
    state.setState(IltSONET.State.ActiveProtecting);
    // Return business object
    return link;
  }
  
  /**
   * Create RectGroup object
   * <ul>
   *   <li>class:       IltRectGroup
   *   <li>id:          RGRP1
   *   <li>name:        RectGroup
   *   <li>position:    IlpRect (489,356,80,60)
   *   <li>objectState: IltOSIObjectState
   *   <li>primary:     Enabled / Idle / Locked
   *   <li>secondary:   PowerOff / ReservedForTest
   *   <li>new alarms:  Raw.Critical (5)
   *   <li>ack alarms:  Raw.Warning (12)
   * </ul>
   */
  static IlpObject createRectGroup() {
    IlpObject rect = new IltRectGroup("RGRP1");
    rect.setAttributeValue(IltObject.NameAttribute, "RectGroup");
    rect.setAttributeValue(IltObject.PositionAttribute, new IlpRect(489, 356, 80, 60));
    // Define primary statuses (enabled / active / shuttingdown)
    IltOSI.State primary = new IltOSI.State(IltOSI.State.Operational.Enabled,
                                            IltOSI.State.Usage.Idle,
                                            IltOSI.State.Administrative.Locked);
    // Create object state (OSI object state)
    IltOSIObjectState state = new IltOSIObjectState(primary);
    // Add object state to business object
    rect.setAttributeValue(IltObject.ObjectStateAttribute, state);
    // Define secondary statuses (reporting / underrepair)
    state.addStatus(IltOSI.Availability.PowerOff);
    state.addStatus(IltOSI.Control.ReservedForTest);
    // Get its alarm state
    IltAlarm.State alarms = (IltAlarm.State)state.getAlarmState();
    // Add 5 new raw.critical alarms
    alarms.setNewAlarmCount(IltAlarm.Severity.Critical, 5);
    // Add 12 ack raw.warning alarms
    alarms.setAcknowledgedAlarmCount(IltAlarm.Severity.Warning, 12);
    // Return business object
    return rect;
  }
  
  /**
   * Create PolyGroup object
   * <ul>
   *   <li>class:       IltPolyGroup
   *   <li>id:          PGRP1
   *   <li>name:        PolyGroup
   *   <li>position:    IlpPolygon (231.25,482.25,239.25,471.25,...)
   *   <li>objectState: IltBellcoreObjectState
   *   <li>primary:     EnabledActive
   *   <li>secondary:   TestFailure
   *   <li>misc:        HighTemperatureWarning
   *   <li>performance: Input (50)
   *   <li>new alarms:  Raw.Minor (3)
   *   <li>ack alarms:  Raw.Warning (4)
   * </ul>
   */
  static IlpObject createPolyGroup() {
    IlpObject poly = new IltPolyGroup("PGRP1");
    poly.setAttributeValue(IltObject.NameAttribute, "PolyGroup");
    poly.setAttributeValue(IltObject.PositionAttribute, 
                           new IlpPolygon(polygonPosition));
    // Create object state (Bellcore object state)
    IltBellcoreObjectState state = new IltBellcoreObjectState();
    // Add object state to business object
    poly.setAttributeValue(IltObject.ObjectStateAttribute, state);
    // Define primary state (enabledactive)
    state.setState(IltBellcore.State.EnabledActive);
    // Add secondary statuses (testfailure and hightemeraturewarning)
    state.addSecState(IltBellcore.SecState.TestFailure);
    state.addSecState(IltMisc.SecState.HighTemperatureWarning);
    // Set the input secondary state
    state.set(IltPerformance.SecState.Input, new Integer(50));
    // Get its alarm state
    IltAlarm.State alarms = (IltAlarm.State)state.getAlarmState();
    // Add 3 new raw.minor alarms
    alarms.setNewAlarmCount(IltAlarm.Severity.Minor, 3);
    // Add 4 ack raw.warning alarms
    alarms.setAcknowledgedAlarmCount(IltAlarm.Severity.Warning, 4);
    // Return business object
    return poly;
  }
  
  /**
   * Create NE1 object
   * <ul>
   *   <li>class:       IltNetworkElement
   *   <li>id:          NETE1
   *   <li>name:        NE1
   *   <li>type:        MD
   *   <li>family:      OC12
   *   <li>position:    IlpPoint (68,61)
   *   <li>objectState: IltOSIObjectState
   *   <li>primary:     Enabled / Active / ShuttingDown
   *   <li>new alarms:  Raw.Warning (4)
   * </ul>
   */
  static IlpObject createNE1() {
    IlpObject node = new IltNetworkElement("NETE1");
    node.setAttributeValue(IltObject.NameAttribute, "NE1");
    node.setAttributeValue(IltNetworkElement.TypeAttribute, IltNetworkElement.Type.MD);
    node.setAttributeValue(IltNetworkElement.FamilyAttribute, IltNetworkElement.Family.OC12);
    node.setAttributeValue(IltObject.PositionAttribute, new IlpPoint(68, 61));
    // Define primary statuses (enabled / active / shuttingdown)
    IltOSI.State primary = new IltOSI.State(IltOSI.State.Operational.Enabled,
                                            IltOSI.State.Usage.Active,
                                            IltOSI.State.Administrative.ShuttingDown);
    // Create object state (OSI object state)
    IltOSIObjectState state = new IltOSIObjectState(primary);
    // Add object state to business object
    node.setAttributeValue(IltObject.ObjectStateAttribute, state);
    // Get its alarm state
    IltAlarm.State alarms = (IltAlarm.State)state.getAlarmState();
    // Add 4 new raw.warning alarms
    alarms.setNewAlarmCount(IltAlarm.Severity.Warning, 4);
    // Return business object
    return node;
  }
  
  /**
   * Create NE2 object
   * <ul>
   *   <li>class:       IltNetworkElement
   *   <li>id:          NETE2
   *   <li>name:        NE2
   *   <li>type:        Mainframe
   *   <li>position:    IlpPoint (229,126)
   *   <li>objectState: IltBellcoreObjectState
   *   <li>primary:     EnabledActive
   *   <li>misc:        DoorAjar
   *   <li>ack alarms:  Raw.Warning (2)
   * </ul>
   */
  static IlpObject createNE2() {
    IlpObject node = new IltNetworkElement("NETE2");
    node.setAttributeValue(IltObject.NameAttribute, "NE2");
    node.setAttributeValue(IltNetworkElement.TypeAttribute, IltNetworkElement.Type.Mainframe);
    node.setAttributeValue(IltObject.PositionAttribute, new IlpPoint(229, 126));
    // Create object state (Bellcore object state)
    IltBellcoreObjectState state = new IltBellcoreObjectState();
    // Add object state to business object
    node.setAttributeValue(IltObject.ObjectStateAttribute, state);
    // Define primary state (enabledactive)
    state.setState(IltBellcore.State.EnabledActive);
    // Add secondary state (doorajar)
    state.addSecState(IltMisc.SecState.DoorAjar);
    // Get its alarm state
    IltAlarm.State alarms = (IltAlarm.State)state.getAlarmState();
    // Add 2 ack raw.warning alarms
    alarms.setAcknowledgedAlarmCount(IltAlarm.Severity.Warning, 2);
    // Return business object
    return node;
  }
  
  /**
   * Create NE3 object
   * <ul>
   *   <li>class:       IltNetworkElement
   *   <li>id:          NETE3
   *   <li>name:        NE3
   *   <li>type:        Router
   *   <li>position:    IlpPoint (151,512)
   *   <li>objectState: IltBellcoreObjectState
   *   <li>primary:     EnabledActive
   * </ul>
   */
  static IlpObject createNE3() {
    IlpObject node = new IltNetworkElement("NETE3");
    node.setAttributeValue(IltObject.NameAttribute, "NE3");
    node.setAttributeValue(IltNetworkElement.TypeAttribute, IltNetworkElement.Type.Router);
    node.setAttributeValue(IltObject.PositionAttribute, new IlpPoint(151, 512));
    // Create object state (Bellcore object state)
    IltBellcoreObjectState state = new IltBellcoreObjectState();
    // Add object state to business object
    node.setAttributeValue(IltObject.ObjectStateAttribute, state);
    // Define primary state (enabledactive)
    state.setState(IltBellcore.State.EnabledActive);
    // Return business object
    return node;
  }

  /**
   * Create Link1 object
   * <ul>
   *   <li>class:       IltLink
   *   <li>id:          LINK1
   *   <li>name:        Link1
   *   <li>media:       Fiber
   *   <li>objectState: IltSONETObjectState
   *   <li>primary:     Active
   *   <li>performance: In_Kb (array) / Input (200)
   *   <li>alarms:      notReporting
   * </ul>
   */
  static IlpObject createLink1() {
    IlpObject link = new IltLink("LINK1");
    link.setAttributeValue(IltObject.NameAttribute, "Link1");
    link.setAttributeValue(IltLink.MediaAttribute, IltLink.Media.Fiber);
    // Create object state (SONET object state)
    IltSONETObjectState state = new IltSONETObjectState();
    // Add object state to business object
    link.setAttributeValue(IltObject.ObjectStateAttribute, state);
    // Define primary state (active)
    state.setState(IltSONET.State.Active);
    // Set its performance secondary state
    Integer[] inkb = new Integer[] { 50, 70, 58, 60, 58, 62, 54, 
                                     24, 56, 85, 58, 65, 12, 35 };
    state.set(IltPerformance.SecState.In_Kb, inkb);
    // Set the input secondary state
    state.set(IltPerformance.SecState.Input, new Integer(200));
    // Get its alarm state and set it to 'notreporting'
    IltAlarm.State alarms = (IltAlarm.State)state.getAlarmState();
    alarms.setNotReporting(true);
    // Return business object
    return link;
  }
  
  /**
   * Create Link2 object
   * <ul>
   *   <li>class:       IltLink
   *   <li>id:          LINK2
   *   <li>name:        Link2
   *   <li>media:       Fiber
   *   <li>objectState: IltSONETObjectState
   *   <li>primary:     Active
   *   <li>protection:  Exercisor
   *   <li>alarms:      notReporting
   * </ul>
   */
  static IlpObject createLink2() {
    IlpObject link = new IltLink("LINK2");
    link.setAttributeValue(IltObject.NameAttribute, "Link2");
    link.setAttributeValue(IltLink.MediaAttribute, IltLink.Media.Fiber);
    // Create object state (SONET object state)
    IltSONETObjectState state = new IltSONETObjectState();
    // Add object state to business object
    link.setAttributeValue(IltObject.ObjectStateAttribute, state);
    // Define primary state (active)
    state.setState(IltSONET.State.Active);
    // Set protection
    state.addProtection(IltSONET.End.From, IltSONET.Protection.Exercisor);
    state.addProtection(IltSONET.End.To, IltSONET.Protection.Exercisor);
    // Get its alarm state and set it to 'notreporting'
    IltAlarm.State alarms = (IltAlarm.State)state.getAlarmState();
    alarms.setNotReporting(true);
    // Return business object
    return link;
  }

  /**
   * Create Link3 object
   * <ul>
   *   <li>class:       IltLink
   *   <li>id:          LINK3
   *   <li>name:        Link3
   *   <li>media:       Fiber
   *   <li>objectState: IltSONETObjectState
   *   <li>primary:     TroubleProtected
   *   <li>performance: Input (50)
   * </ul>
   */
  static IlpObject createLink3() {
    IlpObject link = new IltLink("LINK3");
    link.setAttributeValue(IltObject.NameAttribute, "Link3");
    link.setAttributeValue(IltLink.MediaAttribute, IltLink.Media.Fiber);
    // Create object state (SONET object state)
    IltSONETObjectState state = new IltSONETObjectState();
    // Add object state to business object
    link.setAttributeValue(IltObject.ObjectStateAttribute, state);
    // Define primary state (troubledprotected)
    state.setState(IltSONET.State.TroubledProtected);
    // Set the input secondary state
    state.set(IltPerformance.SecState.Input, new Integer(50));
    // Return business object
    return link;
  }

  /**
   * Create Link4 object
   * <ul>
   *   <li>class:       IltLink
   *   <li>id:          LINK4
   *   <li>name:        Link4
   *   <li>media:       Fiber
   *   <li>objectState: IltSONETObjectState
   *   <li>primary:     ActiveProtecting
   *   <li>performance: Input (200)
   * </ul>
   */
  static IlpObject createLink4() {
    IlpObject link = new IltLink("LINK4");
    link.setAttributeValue(IltObject.NameAttribute, "Link4");
    link.setAttributeValue(IltLink.MediaAttribute, IltLink.Media.Fiber);
    // Create object state (SONET object state)
    IltSONETObjectState state = new IltSONETObjectState();
    // Add object state to business object
    link.setAttributeValue(IltObject.ObjectStateAttribute, state);
    // Define primary state (activeprotecting)
    state.setState(IltSONET.State.ActiveProtecting);
    // Set the input secondary state
    state.set(IltPerformance.SecState.Input, new Integer(200));
    // Return business object
    return link;
  }
  
  /**
   * Create Link5 object
   * <ul>
   *   <li>class:       IltLink
   *   <li>id:          LINK5
   *   <li>name:        Link5
   *   <li>media:       Fiber
   *   <li>objectState: IltSONETObjectState
   *   <li>primary:     TroubleUnprotected
   *   <li>new alarms:  Raw.Warning (1)
   * </ul>
   */
  static IlpObject createLink5() {
    IlpObject link = new IltLink("LINK5");
    link.setAttributeValue(IltObject.NameAttribute, "Link5");
    link.setAttributeValue(IltLink.MediaAttribute, IltLink.Media.Fiber);
    // Create object state (SONET object state)
    IltSONETObjectState state = new IltSONETObjectState();
    // Add object state to business object
    link.setAttributeValue(IltObject.ObjectStateAttribute, state);
    // Define primary state (troubledunprotected)
    state.setState(IltSONET.State.TroubledUnprotected);
    // Get its alarm state 
    IltAlarm.State alarms = (IltAlarm.State)state.getAlarmState();
    // Add 1 new raw.warning alarm
    alarms.setNewAlarmCount(IltAlarm.Severity.Warning, 1);
    // Return business object
    return link;
  }
}