Menu

Redefine a field node to be not-null-allowed

7 days ago
7 days ago
  • Jacques Dancause

    Hey all.

    I have a field node being defined in our version of FunctionalCI, called "hostname". Definition as follows:

            <field id="hostname" xsi:type="AttributeString" _delta="define">
              <sql>hostname</sql>
              <default_value />
              <is_null_allowed>true</is_null_allowed>
            </field>
    

    Now, in a child class, Server (child through FunctionalCI -> PhysicalDevice -> ConnectableCI -> DatacentreDevice -> Server), I want to redefine this node to have <is_null_allowed>false</is_null_allowed>

    Normally I would just add this definition in Server and be done with it:

            <field id="hostname" xsi:type="AttributeString" _delta="redefine">
              <sql>hostname</sql>
              <default_value />
              <is_null_allowed>false</is_null_allowed>
            </field>
    

    However, when trying to use this definition, it complains that "hostname" doesn't actually exist, despite the module that defines it being loaded:

    Error: Error loading module "ods-server": /itop_design/classes/class[cmdbAbstractObject]/class[FunctionalCI]/class[PhysicalDevice]/class[ConnectableCI]/class[DatacenterDevice]/class[Server]/fields/field[hostname] at line 80: 
    could not be modified (not found) - Loaded modules: dictionaries:1.0, core:1.0, application:1.0, authent-cas:3.0.3, authent-external:3.0.3, authent-ldap:3.0.3, authent-local:3.0.3, combodo-backoffice-darkmoon-theme:3.0.3, itop-attachments:3.0.3, itop-backup:3.0.3, itop-config:3.0.3, itop-files-information:3.0.3, itop-portal-base:3.0.3, itop-profiles-itil:3.0.3, itop-sla-computation:3.0.3, itop-structure:3.0.3, itop-themes-compat:3.0.3, itop-tickets:3.0.3, itop-welcome-itil:3.0.3, molkobain-fontawesome5-pack:1.4.0, molkobain-handy-framework:1.8.0, molkobain-newsroom-provider:1.5.0, ods-abstract-resources:3.0.4, ods-api:3.0.3, ods-asset-number:3.0.4, ods-country:3.0.4, ods-data-center-closure:3.0.3, ods-dependency-data:3.0.0, ods-deployment:3.0.0, ods-discovered-software:3.0.4, ods-enum-value:3.0.4, ods-functional-area:3.0.3, ods-global-banner:3.0.19, ods-hardware-asset:3.0.4, ods-internal-order:3.0.3, ods-login-message:3.0.4, ods-os-edition:3.0.4, ods-project:3.0.3, ods-purchase-order:3.0.2, ods-refresh-and-replacement:3.0.8, ods-room:3.0.4, ods-software-allocation:3.0.0, ods-state:3.0.4, ods-support-group-type:3.0.4, ods-support-group:3.0.4, ods-theme:3.0.0, record-health:3.0.3, combodo-db-tools:3.0.3, custom-profile:3.0.3, itop-config-mgmt:3.0.3, itop-core-update:3.0.3, itop-datacenter-mgmt:3.0.3, itop-endusers-devices:3.0.3, itop-hub-connector:3.0.3, itop-oauth-client:3.0.3, itop-service-mgmt-provider:3.0.3, itop-storage-mgmt:3.0.3, itop-virtualization-mgmt:3.0.3, molkobain-console-tooltips:1.3.0, molkobain-datacenter-view:1.10.1, ods-ac-unit:3.0.4, ods-application-solution:3.0.4, ods-brand:3.0.0, ods-business-process:3.0.4, ods-city:3.0.4, ods-cluster-namespace:3.0.4, ods-cluster:3.0.4, ods-connectable-chassis:3.0.4, ods-connectable-ci:3.0.4, ods-consumable:3.0.4, ods-contact-centre:3.0.0, ods-contact-type:3.0.4, ods-contact:3.0.3, ods-contract:3.0.4, ods-core-responsibility:3.0.4, ods-cost-centre:3.0.3, ods-custom-page:3.0.0, ods-customer-contract:3.0.4, ods-customer:3.0.4, ods-data-source:3.0.4, ods-database-schema:3.0.4, ods-datacenter-device:3.0.4, ods-db-server:3.0.4, ods-document-file:3.0.4, ods-enclosure:3.0.4, ods-entitlement:3.0.4, ods-farm:3.0.4, ods-functionalci:3.0.4, ods-hypervisor:3.0.4, ods-initiative:3.0.4, ods-ip-phone:3.0.4, ods-licence:3.0.4, ods-location:3.0.4, ods-logical-interface:3.0.6, ods-logical-partition:3.0.6, ods-mainframe:3.0.6, ods-middleware-instance:3.0.4, ods-middleware:3.0.4, ods-mobile-phone:3.0.4, ods-model:3.0.4, ods-nas:3.0.4, ods-network-device-type:3.0.4, ods-network-device:3.0.4, ods-organization:3.0.4, ods-os-family:3.0.4, ods-os-licence:3.0.4, ods-os-patch:3.0.4, ods-os-version:3.0.4, ods-other-software:3.0.4, ods-pc-software:3.0.4, ods-pc:3.0.4, ods-peripheral:3.0.4, ods-person:3.0.4, ods-phone:3.0.4, ods-physical-device:3.0.4, ods-plane:3.0.4, ods-power-connection:3.0.0, ods-power-source:3.0.0, ods-printer:3.0.4, ods-product-set:3.0.8, ods-provider-contract:3.0.4, ods-province:3.0.4, ods-purchase-order-document-file:3.0.4, ods-rack:3.0.4, ods-role:3.0.4, ods-routing-table:3.0.8, ods-san-switch:3.0.4, ods-slt:3.0.4, ods-software-instance:3.0.4, ods-software-licence:3.0.4, ods-software:3.0.4, ods-storage-system:3.0.4, ods-subnet:3.9.4, ods-substate:3.0.4, ods-switch-stack:3.0.8, ods-tablet:3.0.4, ods-tape-library:3.0.4, ods-team:3.0.4, ods-telephony-ci:3.0.4, ods-typology:3.0.4, ods-unspsc:3.0.4, ods-ups:3.0.0, ods-video-conferencing-device:3.0.4, ods-virtual-device:3.0.4, ods-virtual-host:3.0.4, ods-virtual-machine:3.0.4, ods-virtual-network-device:3.0.4, ods-web-application:3.0.4, ods-web-server:3.0.4, combodo-webhook-integration:1.2.0, itop-bridge-cmdb-ticket:3.0.3, itop-bridge-virtualization-storage:3.0.3, ods-core:3.0.3, ods-group:3.0.3, ods-lnk-classes:3.0.1, ods-pdu:3.0.0, ods-project-anticipated-outcome:3.0.1, ods-remote-application-connection:3.0.4, ods-remote-itop-connection:3.0.4, ods-server:3.0.4
    

    Now, if I add "define" instead of "redefine", I get the following error:

    Error: Declaration of Server: attempting to redeclare the inherited attribute 'hostname', originally declared in FunctionalCI
    

    I've tried many other combinations of deltas, such as:

            <field id="hostname" xsi:type="AttributeString" _delta="must_exist">
              <sql>hostname</sql>
              <default_value />
              <is_null_allowed _delta="redefine">false</is_null_allowed>
            </field>
    
            <field id="hostname" xsi:type="AttributeString" _delta="force">
              <sql>hostname</sql>
              <default_value />
              <is_null_allowed>false</is_null_allowed>
            </field>
    

    They all give me some variation of either "hostname could not be found" or "hostname is already defined on FunctionalCI".

    There is one delta which gives me a different error, usually related to using the wrong deltas:

            <field id="hostname" xsi:type="AttributeString" _delta="merge">
              <sql>hostname</sql>
              <default_value />
              <is_null_allowed>false</is_null_allowed>
            </field>
    

    Gives me this:

    Executing 'compile'
    Error: Failed to process class 'Server', from 'C:\xampp\htdocs\web\datamodels\2.x\itop-config-mgmt': Field: 'hostname', (type: AttributeString), missing (or empty) mandatory tag 'sql' under the tag 'field'
    

    Let me know if you need to know more about the context or definitions.

     

    Last edit: Jacques Dancause 7 days ago
  • Vincent @ Combodo

    It's a iTop limitation, you cannot on a child class modify all or part of any parent field.
    Adding such mandatory constrain can be performed in 2 manners

    1. Create the field on each sub-class with its own constrains
    2. Create the field on the parent and make it mandatory on the child by code for eg. with AddAttributeFlags
      You can also perform a CheckToWrite but this is after the submission so not very user friendly
     

    Last edit: Vincent @ Combodo 7 days ago
    • Jacques Dancause

      Thank you for the clarification; this makes sense.

       

Log in to post a comment.