Menu

Bidirectional linking of objects

Andre Vanz
2012-11-19
2014-07-30
  • Andre Vanz

    Andre Vanz - 2012-11-19

    Hello all,

    I've been trying out iTop. I have switched to v2 as the datamodel provides more objects we use out of the box. However we wanted Software Instances to be linked to each other, for example there's many occurences of web (or app) servers to be dependent on a DB-server. But also, DB-servers who are dependent on other DB-servers (fail over constructions).

    I've added a lnkSoftwareInstanceToSoftwareInstance in the datamodel and I can now add links to other SoftwareInstances (yay!) but unlike other linked classes they are uni-directional, in the sense that when you like SoftwareInstance A to SoftwareInstance B, then A will show B in my tab with related software, but B won't show in A's tab.

    I've added this field in Software Instance:

    <field id="related_software_list" xsi:type="AttributeLinkedSetIndirect">
              <linked_class>lnkSoftwareInstanceToSoftwareInstance</linked_class>
              <ext_key_to_me>software_id1</ext_key_to_me>
              <count_min>0</count_min>
              <count_max>0</count_max>
              <ext_key_to_remote>software_id2</ext_key_to_remote>
              <duplicates/>
    </field>
    

    And this class for lnkSoftwareInstanceToSoftwareInstance:

    <code>
    <class id="lnkSoftwareInstanceToSoftwareInstance" _delta="define">
          <parent>cmdbAbstractObject</parent>
          <properties>
            <is_link>1</is_link>
            <category>bizmodel</category>
            <abstract>false</abstract>
            <key_type>autoincrement</key_type>
            <db_table>lnksoftwareinstancetosoftwareinstance</db_table>
            <db_key_field>id</db_key_field>
            <db_final_class_field/>
            <naming>
              <format>%1$s relates to %2$s</format>
              <attributes>
                <attribute id="software_id1"/>
                <attribute id="software_id2"/>
              </attributes>
            </naming>
            <display_template/>
            <icon/>
            <reconciliation>
              <attributes>
                <attribute id="software_id1"/>
                <attribute id="software_id2"/>
              </attributes>
            </reconciliation>
          </properties>
          <fields>
            <field id="software_id1" xsi:type="AttributeExternalKey">
              <sql>software_id1</sql>
              <target_class>SoftwareInstance</target_class>
              <is_null_allowed>false</is_null_allowed>
              <on_target_delete>DEL_AUTO</on_target_delete>
            </field>
            <field id="software_name1" xsi:type="AttributeExternalField">
              <extkey_attcode>software_id1</extkey_attcode>
              <target_attcode>name</target_attcode>
            </field>
            <field id="software_id2" xsi:type="AttributeExternalKey">
              <sql>software_id2</sql>
              <target_class>SoftwareInstance</target_class>
              <is_null_allowed>false</is_null_allowed>
              <on_target_delete>DEL_AUTO</on_target_delete>
            </field>
            <field id="software_name2" xsi:type="AttributeExternalField">
              <extkey_attcode>software_id2</extkey_attcode>
              <target_attcode>name</target_attcode>
            </field>
          </fields>
          <methods/>
          <presentation>
            <details>
              <items>
                <item id="software_id1">
                  <rank>10</rank>
                </item>
                <item id="software_id2">
                  <rank>20</rank>
                </item>
              </items>
            </details>
            <search>
              <items>
                <item id="software_id1">
                  <rank>10</rank>
                </item>
                <item id="software_id2">
                  <rank>20</rank>
                </item>
              </items>
            </search>
            <list>
              <items>
                <item id="software_id1">
                  <rank>10</rank>
                </item>
                <item id="software_id2">
                  <rank>20</rank>
                </item>
              </items>
            </list>
          </presentation>
        </class></code>

    Did I do something wrong, or is there a way to do this? Thanks in advance for any help :-)

     
    • Marnix K

      Marnix K - 2014-07-30

      I tried to implement this on my own setup. But I don't get a related software field shown in.

      I created a new module with above lnkSoftwareInstanceToSoftwareInstance name.
      I didn't get the table created, so i deleted the and tags and then I got the table created.

      I added the field definition to the datamodel.itop-config-mgmt.xml file at the <class id="user-content-SoftwareInstance" _delta="define"></class>

      But the field doesn't appear at the software / software instance or any other software related item in iTop.

      Could you be a little bit more specific how you did this

       
  • Bruno Bonfils

    Bruno Bonfils - 2012-11-19

    I think you need another field with the same definition except reverse ext_key_to_me / to_remote

     
  • Andre Vanz

    Andre Vanz - 2012-11-20

    I am not sure if I am doing it right, but I've added another field, with another id, which was the reverse of the first one. However I don't see it linked yet (I know it is linked, but I want it to show them all in the same list).

    So when I connect A to B, B shows up in my Related Software tab at A, but A doesn't in B's. I probably could set a second field and make a new tab for that list, but I was trying to get it in the same list. Is that possible?

    Thanks for the help so far by the way!

     
  • Rob Harvey

    Rob Harvey - 2013-12-03

    Is there a tutorial - like the adding a field or creating a custom CI - for linking tables together?

    I have created a custom CI for a Mobile Service (Service number, SIM Card Number, PUK, Carrier, etc) that I want to relate to the existing Mobile Phone (IMEI, Model, etc).

    You can have a mobile device that doesn't have a SIM card so the relationship is one way. If a mobile device has a service number - that should be linked to the information for that service number. But a service number doesn't have to be linked to hardware.

    Does that make sense? Can you tell I'm in over my head? :)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.