Menu

Uniqueness rule with filter

Nico
2021-08-30
2021-12-23
  • Nico

    Nico - 2021-08-30

    Hi,
    I have created a new class to manage RFID tokens. It's parent is "PhysicalDevices". For the PhysicalDevices class a unique rule is configured taking care of unique asset numbers.
    In the new class for RFID tokens the asset number attribute is not needed/defined, so i tried to remove that class from the uniqueness rule using a filter like this:

    <filter><![CDATA[finalclass NOT IN ('NM_RFIDdongle')]]></filter>
    

    But without success: If i create a new RFID token I get an error that asset number has to be filled.
    Where am I going wrong?
    Thanks in advance,
    best regards,
    Nico

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2021-08-30

    Can you show the entire XML modification for this class to see how the filter is applied?

     

    Last edit: Jeffrey Bostoen 2021-08-30
  • Nico

    Nico - 2021-08-30

    Sure:

       <class id="PhysicalDevice" _delta="if_exists">
          <properties>
            <uniqueness_rules>
              <rule id="serialnumber" _delta="define">
                <attributes>
                  <attribute id="serialnumber"/>
                </attributes>
              </rule>
              <rule id="assetnumber" _delta="define">
                <attributes>
                  <attribute id="asset_number"/>
                </attributes>
                <filter><![CDATA[finalclass NOT IN ('NM_RFIDdongle')]]></filter>
              </rule>
            </uniqueness_rules>
    
     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2021-08-30

    Did you add a dependency in the extension to the iTop module where PhysicalDevice is defined?

    It seems like it is totally ignoring your (re)definition.
    Which leads me to the next point: I'd expect a value of "redefine" for the rule ID. But you can also move it o the filter-node instead.

     
    • Nico

      Nico - 2021-08-30

      Hmm, as you can see I configured the delta for the class "PhysicalDevice" as "if_exists" and added 2 rules (delta="define").
      That in fact is working, the uniqueness is checkes and shows errors if values already exist in the database. But the filter is not working, so I get warnings on the RFID dongle class, too.

       
      • Jeffrey Bostoen

        Jeffrey Bostoen - 2021-08-30

        Can you attach the module's PHP file and the datamodel XML please?

         
        • Nico

          Nico - 2021-08-30

          I created a complete Extension just for this test. It should add the new class und define the uniqueness rules. In Class PC the rules are functinonal.

           
          • Jeffrey Bostoen

            Jeffrey Bostoen - 2021-08-30

            Try in the module PHP file:

            dependencies => array(
                'itop-config-mgmt/2.7.0'
              )
            

            See if it helps

             
            • Nico

              Nico - 2021-08-30

              I configured the dependency but with same results, the filter is still not recognized :-(

               
            • Nico

              Nico - 2021-09-02

              Have you find something other?
              Did you succesfully configured some kind of this filters?
              Thanks.

               
  • Pierre Goiffon

    Pierre Goiffon - 2021-12-23

    Hello,
    Sorry this is an old thread...

    See the uniqueness rules documentation, you will see :

    The use of finalclass attribute in uniqueness rule is not supported

    You can try to disable the rule in the child class : this should work !
    In the XML, in the NM_RFIDdongle class properties, only override the disable attribute for the uniqueness rule.

     

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.