强制生命周期强制字段

决条件:您必须熟悉教程中使用的语法 并且已经创建了一个扩展.

学习:强制在某些状态转换中填充字段

水平:中间

域:XMLPHPconstrainLifecycle

最低版本:2.1.0

用例只是其中一种强制提供字段.

对于这些用例,我们将使用UserRequest类,因为它具有生命周期。当对象具有生命周期时,iTop数据模型允许在转换和“状态”上指定必须填写哪些字段。

生命周期上的标志适用于控制台和门户,但在使用CSV导入,DataSynchro或API REST/JSON修改创建对象时,不强制提供该字段

转换上的强制性

例如,当用户请求从状态New移到Assigned状态时,您可能决定必须记录服务。
该动作称为转换,由初始状态和所施加的刺激唯一地标识。

itop_design / classes
 
    <class id="UserRequest">
      <lifecycle>
        <states>
          <!-- For User Request in State New... -->
          <state id="new">
            <transitions>
              <!-- On the transition, trigger by ev_assign stimulus... -->
              <transition id="ev_assign" _delta="must_exist">
                <flags>
                  <!-- We want to force the Service... -->
                  <attribute id="service_id" _delta="define" >
                    <!-- to be provided -->
                    <mandatory/>
                  </attribute>
                </flags>
              </transition>
            </transitions>
          </state>
        </states>
      </lifecycle>
    </class>

强制性的

在此用例中,我们要确保所有处于Assigned状态的UserRequest都定义了服务。

在状态级别定义“强制”标志时,即使未在转换级别上指定,它也会自动应用于以该状态结束的所有转换。

itop_design / classes
 
    <class id="UserRequest" _created_in="itop-request-mgmt-itil" _delta="must_exist">
      <lifecycle>
        <states>
          <state id="assigned" _delta="must_exist">
            <!-- setting no _delta is equivalent to _delta="merge" -->
            <flags>
              <!-- Here we assume that no other extension nor the default datamodel... -->
              <!-- has set flags on field 'service-id' for state 'assigned' already -->
              <attribute id="service_id" _delta="define>
                <mandatory/>
              </attribute>
            </flags>
          </state>
        </states>
      </lifecycle>
    </class>

迁移:对安装程序没有可见的影响,但是在提供服务之前,不能再在控制台或门户中修改不兼容的对象。创建审计规则以检索不符合此新约束的对象并进行修复。

原贴链接:https://www.itophub.io/wiki/page?id=2_7_0%3Acustomization%3Amandatory-on-transition


Force a field to be mandatory by lifecycle

Prerequisite: You must be familiar with the Syntax used in Tutorials and have already created an extension.

learning:
Force a field to be filled on some state/transition
level:
Intermediate
domains:
XMLPHPConstrainLifecycle
min version:
2.1.0

This use case is just one way of forcing a field to be provided.

For those use cases, we will use UserRequest class, because it has a lifecycle. When an object has a lifecycle, iTop datamodel allow to specify on a Transition and on a State which fields must be required.

Flags on lifecycle applies to Console and Portal, but do not force the field to be provided when object is created/modified using CSV import, DataSynchro or API REST/JSON

Mandatory on transition

For example, you may decide that a Service must be documented when a User Request is moved from state New to state Assigned.
That move is called a transition and is uniquely identified by the initial state and the stimulus applied.

itop_design / classes
 
    <class id="UserRequest">
      <lifecycle>
        <states>
          <!-- For User Request in State New... -->
          <state id="new">
            <transitions>
              <!-- On the transition, trigger by ev_assign stimulus... -->
              <transition id="ev_assign" _delta="must_exist">
                <flags>
                  <!-- We want to force the Service... -->
                  <attribute id="service_id" _delta="define" >
                    <!-- to be provided -->
                    <mandatory/>
                  </attribute>
                </flags>
              </transition>
            </transitions>
          </state>
        </states>
      </lifecycle>
    </class>

Mandatory on a state

In this usecase we want to be sure that all UserRequest in state Assigned have a Service defined.

When the “mandatory” flag is defined at the state level, then it automatically applies to all transitions ending on that state, even if not specified at the transition level.

itop_design / classes
 
    <class id="UserRequest" _created_in="itop-request-mgmt-itil" _delta="must_exist">
      <lifecycle>
        <states>
          <state id="assigned" _delta="must_exist">
            <!-- setting no _delta is equivalent to _delta="merge" -->
            <flags>
              <!-- Here we assume that no other extension nor the default datamodel... -->
              <!-- has set flags on field 'service-id' for state 'assigned' already -->
              <attribute id="service_id" _delta="define>
                <mandatory/>
              </attribute>
            </flags>
          </state>
        </states>
      </lifecycle>
    </class>

Migration: No visible effect on setup, but objects not compliant can no more be modified in the Console or Portal, until a Service is provided. Create an audit rule to retrieve objects not compliant to this new constrain and fix them.

标签:
由 superadmin 在 2020/08/27, 17:15 创建
    

需要帮助?

如果您需要有关XWiki的帮助,可以联系:

深圳市艾拓先锋企业管理咨询有限公司