Menu

Lifecycle for class object (PhysicalDevice)

Valentin
2022-01-20
2022-01-27
  • Valentin

    Valentin - 2022-01-20

    Hello.
    I am trying to add a lifecycle for an object. Using instructions from the website. I fixed the typos and the "state attribute" declaration. But the controls lifecycle don't show up.
    Maybe you need to declare buttons?
    Use iTop 3.0.0

      <class id="PhysicalDevice" _delta="if_exists">
        <properties>
          <fields_semantic>
            <state_attribute>status</state_attribute>
          </fields_semantic>
        </properties>
    
        <fields>
          <field id="status">
          <default_value _delta="redefine">implementation</default_value>
          </field>
        </fields>
    
          <lifecycle _delta="define">
            <!-- list of possible stimuli, triggering transition -->
            <stimuli>
              <stimulus id="ev_move2prod" xsi:type="StimulusUserAction"/>
              <stimulus id="ev_obsolete" xsi:type="StimulusUserAction"/>
              <stimulus id="ev_stock" xsi:type="StimulusUserAction"/>
            </stimuli>
            <states>
              <state id="implementation">
                <flags/>
                <!-- From each state, define possible transitions -->
                <transitions>
                  <!-- Recommended: use stimulus code as transition id -->
                  <transition id="ev_move2prod">
                    <!-- Define the stimulus which will trigger that transition -->
                    <stimulus>ev_move2prod</stimulus>
                    <!-- define the target state, where the transition will end -->
                    <target>production</target>
                    <!-- below flags are mandatory but can be empty -->
                    <flags/>
                    <actions/>
                  </transition>
                </transitions>
              </state>
              <state id="production">
                <flags/>
                <transitions>
                  <transition id="ev_obsolete">
                    <target>obsolete</target>
                    <actions/>
                  </transition>
                  <transition id="ev_stock">
                    <target>stock</target>
                    <actions/>
                  </transition>
                </transitions>
              </state>
              <state id="obsolete">
                <flags/>
                <transitions/>
              </state>
              <state id="stock">
                <flags/>
                <transitions>
                  <!-- The below transition is identical to the one on state implementation -->
                  <transition id="ev_move2prod">
                    <stimulus>ev_move2prod</stimulus>
                    <target>production</target>
                    <flags/>
                    <actions/>
                  </transition>
                </transitions>
              </state>
            </states>
          </lifecycle>
      </class>
    
     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2022-01-20

    Might be overlooking it, but aren't you missing a specification where you say which the initial state is?

     
  • Valentin

    Valentin - 2022-01-20

    <default_value _delta="redefine">implementation</default_value>
    specifies a default value for "status".

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2022-01-21

    Sorry, in the documentation I noticed "initial_state_path", although it doesn't seem to be present in datamodel-production.xml ? Is this something deprecated, it seems present in the code though?

     
    • Valentin

      Valentin - 2022-01-24

      In the documentation says "initial_state_path", but it's optional.
      I think the documentation is incomplete. It looks like you need to write a php class for the target object type

       
      👍
      1
  • Valentin

    Valentin - 2022-01-27

    Seems to have figured it out.
    The physical device is an abstract class.
    I thought (based on the example on the site) that the lifecycle is inherited by subordinate classes. Looks like no.
    I defined a lifecycle for a real object and it worked.

     
    👍
    1
    • Pierre Goiffon

      Pierre Goiffon - 2022-01-27

      Hello,
      Thanks for the feedback Valentin !
      We might need to update the wiki : I've just checked the XML reference and indeed there's a lack of details on this subject :/ What do you think @cisou ?

       
      👍
      1

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.