二次开发-数据环境-变迁状态
强制生命周期强制字段
先决条件:您必须熟悉教程中使用的语法 并且已经创建了一个扩展.
学习:强制在某些状态转换中填充字段
水平:[ ttps://]中间
域:[ ttps://]XML, [ ttps://]PHP, [ ttps://]constrain, [ ttps://]Lifecycle
最低版本:2.1.0
用例只是其中一种[ ttps://]强制提供字段.
对于这些用例,我们将使用UserRequest类,因为它具有生命周期。当对象具有生命周期时,iTop数据模型允许在转换和“状态”上指定必须填写哪些字段。
生命周期上的标志适用于控制台和门户,但在使用CSV导入,DataSynchro或API REST/JSON修改创建对象时,不强制提供该字段
转换上的强制性
例如,当用户请求从状态New移到Assigned状态时,您可能决定必须记录服务。
该动作称为转换,由初始状态和所施加的刺激唯一地标识。
<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都定义了服务。
在状态级别定义“强制”标志时,即使未在转换级别上指定,它也会自动应用于以该状态结束的所有转换。
<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>
迁移:对安装程序没有可见的影响,但是在提供服务之前,不能再在控制台或门户中修改不兼容的对象。创建审计规则以检索不符合此新约束的对象并进行修复。