Menu

How to rename a class

2018-11-17
2018-11-20
  • Sébastien Potin

    Hello,

    Someone in my company created an extension with a sub class "Domain"

    <class id="Domain" _delta="define">
             <parent>Licence</parent>
             <properties>
                <category>bizmodel,searchable</category>
                <abstract>false</abstract>
                <key_type>autoincrement</key_type>
                <db_table>domain</db_table>
                <db_key_field>id</db_key_field>
                <db_final_class_field />
                 <naming>
                  <attributes>
                    <attribute id="name"/>
                  </attributes>
                </naming> 
             </properties>
             <presentation />
             <methods />
          </class>
    

    I would like to know how rename it because this cause me some trouble to install the IPAM extension because it contain a class "Domain" too ....

    Thanks in advance for your answers,
    Sebastien

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2018-11-18

    I doubt there's an official way.

    What I would do: rename the class in the XML.
    Then DON'T run the iTop setup just yet, but manually change the name of the table 'domain' to 'newclassname'.
    Then run iTop setup.

    Try this in a test environment first. I'm also unsure what the consequences may be for any history on the objects.

     
  • Vincent @ Combodo

    https://www.itophub.io/wiki/page?id=2_5_0%3Acustomization%3Axml_reference

    Rename a node

    Another attribute is _rename_from. Use it to specify that the item (e.g. a class field) is in fact an existing item renamed from _rename_from to id.

     
  • Guillaume Lajarige

    Hi Sebastien,

    Be careful with class renaming. If you change the id in the /class node, you will have to make sure there is no data related to the class name in the database.

    For example if you class is derivated from another (eg. like UserRequest is from Ticket), you will have to migrate the finalclass field of the parent class table in the DB.
    From what I see in the snippet you pasted, seems like your class derivates from the License class. So check the license table in your DB, you might have Domain in the finalclass.

    Same goes with the attachments, if you have enable them on the class, you will have to change the value in the itemclass field.

    Finally, changing the table name of the Domain class is optional for the renaming itself but might be necessary to avoid collision with the IPAM module.

    Hope it helps :)

     
  • Sébastien Potin

    Hello,

    I did it yesterday and works well !

    I rename table and final class, then modify the extension.

    Thanks all !

     
  • Guillaume Lajarige

    Glad it helped! :)

     

Log in to post a comment.

MongoDB Logo MongoDB