Menu

Data Model Toolkit - missing (or empty) mandatory tag 'sql' under the tag 'field'

2021-05-26
2021-05-26
  • Martin Vysohlid

    Martin Vysohlid - 2021-05-26

    Hello,

    I am customizing iTop by creating an extension. Everything was going fine until I tried to
    extend the Farm object and use field of an AttributeExternalKey and AttributeExternalField
    pair. My XML definition is:�

        <class id="Farm" _delta="if_exists">
          <fields>
            <field id="location_id" xsi:type="AttributeExternalKey">
              <sql>location_id</sql>
              <filter><![CDATA[SELECT l FROM Location AS l JOIN Organization AS root ON 
    l.org_id=root.id JOIN Organization AS child ON child.parent_id BELOW root.id WHERE 
    child.id= :this->org_id]]></filter>
              <dependencies>
                <attribute id="org_id"/>
              </dependencies>
              <target_class>Location</target_class>
              <is_null_allowed>true</is_null_allowed>
              <on_target_delete>DEL_MANUAL</on_target_delete>
              <allow_target_creation>true</allow_target_creation>
            </field>
            <field id="location_name" xsi:type="AttributeExternalField">
              <extkey_attcode>location_id</extkey_attcode>
              <target_attcode>name</target_attcode>
            </field>
          </fields>
          <presentation>
            .
            .
            .
          </presentation>
        </class>
    

    But Data Model Toolkit is complaining about missing <sql> tag, which is for sure presented.
    DMT error:</sql>

    An error occured while processing the PHP files of the data model:
    
    Failed to process class 'Farm', from '/var/www/html/datamodels/2.x/itop-virtualization-
    mgmt': Field: 'location_id', (type: AttributeExternalKey), missing (or empty) mandatory tag 
    'sql' under the tag 'field'
    
    Check the PHP files describing the data model before running the toolkit again !
    

    Suppport info:

    iTopVersion: 2.7.4
    iTopBuild: 7194
    iTopBuildDate: 2021-03-17 09:47:08
    DataModelVersion: 2.7.2
    MySQLVersion: 10.3.25-MariaDB-0+deb10u1
    PHPVersion: 7.3.27-1~deb10u1
    OSVersion: Linux
    WebServerVersion: Apache/2.4.38 (Debian)
    PHPModules: Core, date, libxml, openssl, pcre, zlib, filter, hash, Reflection, SPL, sodium, session, standard, apache2handler, mysqlnd, PDO, xml, apcu, calendar, ctype, dom, mbstring, fileinfo, ftp, gd, gettext, iconv, json, ldap, exif, mysqli, pdo_mysql, apc, posix, readline, shmop, SimpleXML, soap, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xmlreader, xmlwriter, xsl, zip, Phar, Zend OPcache
    ItopSetting/cron_max_execution_time: 600
    ItopSetting/timezone: Europe/Paris
    PHPSetting/memory_limit: 256M
    PHPSetting/max_execution_time: 30
    PHPSetting/upload_max_filesize: 30M
    PHPSetting/post_max_size: 50M
    MySQLSetting/max_allowed_packet: 16777216
    MySQLSetting/key_buffer_size: 134217728
    MySQLSetting/query_cache_size: 33554432
    MySQLStatus/Key_read_requests: 0
    MySQLStatus/Key_reads: 0
    InstallDate: 2021-05-25 18:03:13
    InstallPath: /var/www/html/
    ---- Installation choices ----
    InstalledExtension/itop-config-mgmt-core/2.7.4
    InstalledExtension/itop-config-mgmt-datacenter/2.7.4
    InstalledExtension/itop-config-mgmt-end-user/2.7.4
    InstalledExtension/itop-config-mgmt-storage/2.7.4
    InstalledExtension/itop-config-mgmt-virtualization/2.7.4
    InstalledExtension/itop-service-mgmt-enterprise/2.7.4
    InstalledExtension/itop-ticket-mgmt-itil-user-request/2.7.4
    InstalledExtension/itop-ticket-mgmt-itil-incident/2.7.4
    InstalledExtension/itop-ticket-mgmt-itil-enhanced-portal/2.7.4
    InstalledExtension/itop-ticket-mgmt-itil/2.7.4
    InstalledExtension/itop-change-mgmt-simple/2.7.4
    InstalledExtension/itop-kown-error-mgmt/2.7.4
    InstalledExtension/itop-problem-mgmt/2.7.4
    InstalledExtension/pse-custom_fields/0.0.1 (Extension)
    ---- Actual modules installed ----
    InstalledModule/authent-cas: 2.7.4
    InstalledModule/authent-external: 2.7.4
    InstalledModule/authent-ldap: 2.7.4
    InstalledModule/authent-local: 2.7.4
    InstalledModule/combodo-db-tools: 2.7.4
    InstalledModule/itop-attachments: 2.7.4
    InstalledModule/itop-backup: 2.7.4
    InstalledModule/itop-config-mgmt: 2.7.4
    InstalledModule/itop-config: 2.7.4
    InstalledModule/itop-datacenter-mgmt: 2.7.4
    InstalledModule/itop-endusers-devices: 2.7.4
    InstalledModule/itop-files-information: 2.7.4
    InstalledModule/itop-hub-connector: 2.7.4
    InstalledModule/itop-portal-base: 2.7.4
    InstalledModule/itop-portal: 2.7.4
    InstalledModule/itop-profiles-itil: 2.7.4
    InstalledModule/itop-sla-computation: 2.7.4
    InstalledModule/itop-storage-mgmt: 2.7.4
    InstalledModule/itop-tickets: 2.7.4
    InstalledModule/itop-virtualization-mgmt: 2.7.4
    InstalledModule/itop-welcome-itil: 2.7.4
    InstalledModule/pse-custom_fields: 0.0.1
    InstalledModule/itop-bridge-virtualization-storage: 2.7.4
    InstalledModule/itop-change-mgmt: 2.7.4
    InstalledModule/itop-core-update: 2.7.4
    InstalledModule/itop-incident-mgmt-itil: 2.7.4
    InstalledModule/itop-knownerror-mgmt: 2.7.4
    InstalledModule/itop-problem-mgmt: 2.7.4
    InstalledModule/itop-request-mgmt-itil: 2.7.4
    InstalledModule/itop-service-mgmt: 2.7.4
    InstalledModule/itop-full-itil: 2.7.4
    
     

    Last edit: Martin Vysohlid 2021-05-26
  • Guillaume Lajarige

    Hello Martin,

    This is most likely because you didn't put a "_delta" attribute on the "field" tag. Therefore the compiler is only keeping the structural nodes but not their content. Just add "_delta="define"" on that node and it should work alright.

    Hope this helps,
    Guillaume

     
  • Erwan Taloc

    Erwan Taloc - 2021-05-26

    i just tested this
    <field id="user-content-location_id" xsi:type="AttributeExternalKey" _delta="define"> as mention by Guillaume
    In fact if you don't have _delta="define" instruction before the field section, you have to use it for each new attribute you define
    So it is the same for location_name</field>

     
  • Martin Vysohlid

    Martin Vysohlid - 2021-05-26

    Thank you both, it was just that problem. I was copy/pasting attributes from original definition XML and doesn't added the _delta property.

     

    Last edit: Martin Vysohlid 2021-05-26
  • Martin Vysohlid

    Martin Vysohlid - 2021-05-26

    One more problem on it, now as I moved forward and finetuned the presentation section. The result is duplicating displayed Farm properties/fields which is not happening with other extended entities like Server or VirtualMachine and NetworkDevice.

    complete XML definition:

        <class id="Farm" _delta="if_exists">
          <fields>
            <field id="location_id" xsi:type="AttributeExternalKey" _delta="define">
              <sql>location_id</sql>
              <filter><![CDATA[SELECT l FROM Location AS l JOIN Organization AS root ON l.org_id=root.id JOIN Organization AS child ON child.parent_id BELOW root.id WHERE child.id= :this->org_id]]></filter>
              <dependencies>
                <attribute id="org_id"/>
              </dependencies>
              <target_class>Location</target_class>
              <is_null_allowed>true</is_null_allowed>
              <on_target_delete>DEL_MANUAL</on_target_delete>
              <allow_target_creation>true</allow_target_creation>
            </field>
            <field id="location_name" xsi:type="AttributeExternalField" _delta="define">
              <extkey_attcode>location_id</extkey_attcode>
              <target_attcode>name</target_attcode>
            </field>
          </fields>
          <presentation>
            <details>
              <items>
                <item id="contacts_list">
                  <rank>10</rank>
                </item>
                <item id="documents_list">
                  <rank>20</rank>
                </item>
                <item id="applicationsolution_list">
                  <rank>30</rank>
                </item>
                <item id="logicalvolumes_list">
                  <rank>40</rank>
                </item>
                <item id="hypervisor_list">
                  <rank>50</rank>
                </item>
                <item id="virtualmachine_list">
                  <rank>60</rank>
                </item>
                <item id="providercontracts_list">
                  <rank>70</rank>
                </item>
                <item id="services_list">
                  <rank>80</rank>
                </item>
                <item id="col:col1">
                  <rank>90</rank>
                  <items>
                    <item id="fieldset:Server:baseinfo">
                      <rank>10</rank>
                      <items>
                        <item id="name">
                          <rank>10</rank>
                        </item>
                        <item id="org_id">
                          <rank>20</rank>
                        </item>
                        <item id="location_id">
                          <rank>30</rank>
                        </item>
                        <item id="status">
                          <rank>40</rank>
                        </item>
                        <item id="business_criticity">
                          <rank>50</rank>
                        </item>
                        <item id="move2production">
                          <rank>60</rank>
                        </item>
                        <item id="description">
                          <rank>70</rank>
                        </item>
                      </items>
                    </item>
                  </items>
                </item>
              </items>
            </details>
            <search>
              <items>
                <item id="name">
                  <rank>10</rank>
                </item>
                <item id="org_id">
                  <rank>20</rank>
                </item>
                <item id="location_id">
                  <rank>25</rank>
                </item>
                <item id="business_criticity">
                  <rank>30</rank>
                </item>
                <item id="move2production">
                  <rank>40</rank>
                </item>
              </items>
            </search>
            <list>
              <items>
                <item id="org_id">
                  <rank>10</rank>
                </item>
                <item id="location_id">
                  <rank>15</rank>
                </item>
                <item id="status">
                  <rank>20</rank>
                </item>
                <item id="business_criticity">
                  <rank>30</rank>
                </item>
                <item id="move2production">
                  <rank>40</rank>
                </item>
              </items>
            </list>
          </presentation>
        </class>
    
     

    Last edit: Martin Vysohlid 2021-05-26
  • Guillaume Lajarige

    Like for the field, you have to put the right _delta flag on the nodes you want to add/remove/modify. You should take a look at the documentation here.

    Cheers,
    Guillaume

     
  • Pierre Goiffon

    Pierre Goiffon - 2021-05-26

    Just to add a reference to the original ticket : [#1977]

     

    Related

    Tickets: #1977

  • Martin Vysohlid

    Martin Vysohlid - 2021-05-26

    OK finaly got the point, thank you werry much, this also simplified the extension's XML definition.

     
  • Guillaume Lajarige

    Glad to see you fixed it! 😊

    Take care Martin,
    Guillaume

     

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.