Business Objects and Data Sources > Links > Links

Links are used to display the transmission elements making up the network lines. Links feature the same dynamic display as network elements.

Link Class

Links are predefined business objects of the class IltLink used to represent connections between network resources.

The IltLink class defines the following attributes:

The link technology is very similar to the link media. While the media represents the physical connection (fiber, electrical, for example), the technology represents the various networking technologies that a link can carry. For example, you may have two fiber links, one of them being used for voice and the other one for data.

You can retrieve the class IltLink using its GetIlpClass method. You can handle its instances as simple IlpObject instances and set and get its attributes with the generic methods getAttributeValue and setAttributeValue.

Loading a Link Defined in XML

This section shows how to load a link 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 the parse method of the data source, as shown below:

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

Below is an example of a link 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 a Link in XML
<cpldata>
  <addObject id="NE1">
    <class>ilog.tgo.model.IltNetworkElement</class>
      <attribute name="name">NE1</attribute>
      <attribute name="family">OC12</attribute>
      <attribute name="type">MD</attribute>
      <attribute name="position" javaClass="ilog.cpl.graphic.IlpPoint">
        <x>200</x> <y>200</y>
      </attribute>
  </addObject>
  <addObject id="NE2">
    <class>ilog.tgo.model.IltNetworkElement</class>
      <attribute name="name">NE2</attribute>
      <attribute name="type">MD</attribute>
      <attribute name="position" javaClass="ilog.cpl.graphic.IlpPoint">
        <x>400</x> <y>200</y>
      </attribute>
  </addObject>
  <addObject id="NE1-NE2">
    <class>ilog.tgo.model.IltLink</class>
      <link> <from>NE1</from> <to>NE2</to> </link>
        <attribute name="name">Link1</attribute>
        <attribute name="media">Fiber</attribute>
        <attribute name="objectState"
                          javaClass="ilog.tgo.model.IltSONETObjectState">
          <state>ActiveProtecting</state>
          <protection>Exercisor</protection>
        </attribute>
  </addObject>
</cplData>

The figure below shows the link displayed in a network component:

images/linkinxml12.gif

Figure 5.1 Link Displayed in a Network Component

Creating a Link with the API

This section shows how to create a link through the API and how to add it to a data source.

How to Create a Link with the API
IltNetworkElement ne1 = new IltNetworkElement("NE1", 
                                               IltNetworkElement.Type.MD, 
                                               new IltOSIObjectState());
ne1.setAttributeValue(IltObject.PositionAttribute, 
                      new IlpPoint(200, 200));
IltNetworkElement ne2 = new IltNetworkElement("NE2", 
                                               IltNetworkElement.Type.MD, 
                                               new IltOSIObjectState());
ne2.setAttributeValue(IltObject.PositionAttribute, 
                      new IlpPoint(400, 200));
IltSONETObjectState linkState = new
             IltSONETObjectState(IltSONET.State.ActiveProtecting);
linkState.addProtection(IltSONET.End.From, IltSONET.Protection.Exercisor);
linkState.addProtection(IltSONET.End.To, IltSONET.Protection.Exercisor);
IltLink link = new IltLink (linkState, "Link1", IltLink.Media.Fiber);
 
IltDefaultDataSource dataSource = new IltDefaultDataSource();
dataSource.setLink(link.getIdentifier(), ne1.getIdentifier(),
             ne2.getIdentifier());
List objs = new ArrayList();
objs.add(ne1);
objs.add(ne2);
objs.add(link);
dataSource.addObjects(objs);

The result looks like this:

images/linkinxml13.gif

Figure 5.2 Link Displayed in a Network Component