OCS库存详情

名称:自动创建对象的配置器

描述:基于现有对象的模板。

版本:1.1.2

发布:2019-03-26

itop-version-min:2.6.0

码:用于自动对象创建的combodo配置器

状态:稳定

下载:https://store.itophub.io/en_US/products/combodo-configurator-for-automatic-object-creation

备用名称:模板(模板)

扩散:iTop集线器

该组件的其他版本:1.0.14 

该扩展旨在改进终端用户生产效率。它会自动从现有数据中创建一组预填充的对象。

在可能的用法中,您可以:

  • 当将请求分配给处理人员时,将执行用户请求的预设工单,即所选服务的依赖。
  • 在选定的服务上的合同和依赖上预设一个特性列表,以便在创建合同时立即进行记录。
  • 在…上预设SLA依赖
  • 预设服务器接口

可以将其与对象复印机结合使用,例如:从配置项创建“移至生产”请求。将自动(或不)分配请求,然后预先填写工作单。

请注意,在大多数情况下,您将不得不更改现有的数据模型来定义模板类。

原则

触发方式

在以下情况下将复制模板:

  • 创建对象时
  • 当对象达到给定状态时(需要生命周期)

可以通过OQL过滤掉触发器的范围中的对象:SELECT UserRequest WHERE team_id_friendlyname ='Doers'。

操作活动

满足触发条件后,模块将执行以下操作:

  1. 查找模板。这是通过OQL来完成的。例如。 SELECT WorkOrderTemplate WHERE service_id = :trigger->service_id
  2. 对于每个模板,
    1. 实例化一个称为副本的对象
    2. 在副本上执行一系列功能。这被形式化为操作活动的列表。例如,“clone(description)+set(ticket_id,$trigger->id$)” ”将从模板复制属性描述,然后将父工单设置为触发复制的工单
    3. (可选)找到当前模板的子代,并对每个子代执行相同的操作; (即,a + b + c,以递归方式)
  3. (可选)在触发对象上执行一系列操作活动(设置价值,施加刺激)。

在触发对象上显示报告(尽管这是可选的):

https://www.itophub.io/wiki/media?media=extensions%3Areport.png

修订记录

日期版本描述
2019-03-261.1.2-修复了使用对象复印机复制列表时的问题
-修复了模具操作活动中的自定义日期格式
2019-01-161.1.1安全硬化
2018-12-191.1.0-支持附件复印
-修复了从配置项创建工单的重复链接
2018-06-261.0.14为CaseLog属性添加copy_head动词,进行ES翻译
2017-11-151.0.13修复错误消息或工具提示中显示的有关设置只读属性的错误。
2017-09-291.0.12仅在目标类可写时,才在对象中显示功能的详细信息。
2017-04-041.0.11案例日志:在案例日志上使用set时,该条目设置了两次,HTML格式丢失,并且如果该日志是首次从源复制而来,则该日志已损坏。
2017-03-271.0.10通过一些自定义(在工单日期上预设),中断了相关字段的刷新。 iTop 2.3中引入的回归
2017-03-231.0.9XSS脆弱性的修复
2016-08-091.0.8修复了与iTop 2.3.0的兼容性(仍向后兼容):使用隐藏字段和案例日志时,可以正确处理面包屑+错误修复程序。
2015-10-051.0.7修复了与iTop 2.2.0的兼容性(向后兼容)
2015-09-301.0.6新动词:nullify。用于保留日期或日期时间未定义(与动词重置不同,因为此类属性的默认价值为“现在”)
2015-07-021.0.5将数据从触发对象传输到副本:copy_from_trigger。自定义操作活动的新动词:call_method。
2015-04-081.0.3将数据从副本升级到触发对象:retrofit_from_copy
2015-02-131.0.2处理创建的对象的情况(无生命周期)
2015-02-061.0.1修复了报告中的错误:当应用多个规则时,仅显示最后一个报告
2015-02-031.0.0首次发布的版本

安装

展开ZIP文件,然后将itop-stencils和itop-object-copier文件夹的内容复制到iTop的扩展文件夹中,然后再次启动安装程序。

在启动安装程序之前,请确保Web服务器具有足够的权利来读取扩展文件夹及其所有子文件夹的内容。

当提示您选择要安装的扩展时,请在可用的扩展列表中检查“对象复印机”和“模具”。

配置

设定名称描述
规则一系列规则 

规则是由…

规则设定名称描述
name唯一标识符(尚未使用) 
trigger_class触发复制的对象类别用户请求
trigger_scopetrigger_class类的所有OQL返回对象SELECT UserRequest JOIN Team … WHERE Team.org_id = 123
trigger_state可选:到达状态。如果保留为空白,则对象创建的内容将为触发器和操作活动。如果定义了生命周期,则指定“ new”与将参数留为空白具有相同的作用。已分配
report_label可选:在创建的修改后的触发对象上显示的报告的标签或字典条目(附加标语)。如果缺少此条目,则禁用反馈已为工单创建任务列表
templatesOQL。触发对象上的过滤器可以使用参数:触发器-> xxxSELECT Template WHERE team_id = :trigger->team_id
copy_class为每个模板创建的对象类工作指示
copy_actions一系列操作活动(请参阅以下说明),将在每个对模板上执行
copy_hierarchy可选的。必须设置为复制分层模板array('template_parent_attcode'⇒'parent_id', 'copy_parent_attcode'⇒'parent_id')
retrofit_from_copy可选:对于每个副本,将在触发对象上执行一系列操作活动(请参阅以下说明)(副本是从中选择值的对象)
copy_from_触trigger1.0.4中的新增功能-可选:要在副本上执行的一系列操作活动(请参见以下说明),触发对象是数据的源
retrofit一系列操作活动(请参阅以下说明)将在触发对象上执行。将执行一次,并且在执行完Retrofit_from_copy操作活动之后

report_label可以本地化,而无需创建字典。为此,请为每种支持的语言创建设置report_labell <language_code>(例如“ menu_label/FR FR”)。设置report_label将是默认的报告。

如果设置了copy_hierarchy,请确保查询模板不会同时返回模板及其子模板之一。否则,子模板将被实例化多次(首先作为模板,然后作为其中一个模板的子模板)。在大多数情况下,添加条件AND parent_id = 0就足够了。

功能被指定为格式为“ verb(arg1 [,arg2 […]]])”的字符串。这意味着源对象和目标对象。源对象和目标对象都依赖于定义了一系列对象的上下文:

  • copy_actions:来源是当前模板对象,目的地是相应的副本
  • copy_from_trigger (1.0.4中的新增功能):源是触发对象,目标是副本
  • retrofit_from_copy:源是顶级副本,目标是触发对象
  • retrofit:源和目标是触发对象

https://www.itophub.io/wiki/media?media=extensions%3Astencils-actions.png

以下动词可用:

动词参量描述
clone_scalars<无>将所有标量属性从源复制到目标
cloneattcode1,attcode2,...将给定的属性从源复制到目标
reset密码将属性(在目标位置)重置为其默认的价值
nullify密码1.0.6中的新增功能-将属性重置为空的价值(从最终用户的角度来看,它似乎是未定义)
copyatt_to_read,att_to_write从att_to_read (source) to att_to_write (destination)
append密码,字符串将字符串追加到属性(目标)。该字符串可以包含占位符(请参见下面的说明)。逗号必须以反斜杠转义。允许换行(\ n)。字符集必须为utf-8.
setattcode,价值设置一个价值(目的地)。如果价值是字符串,则它可以包含占位符(请参阅下面的说明)。逗号必须以反斜杠转义。允许换行(\ n)。字符集必须为utf-8.
add_to_listattRead,attWrite,attLink,价值attRead(源)是一个外部键,attWrite(目标)是一个N-N链接集,attLink是链接类上的属性,它将被设置为<价值>
apply_stimulus刺激代码在目的地上施加刺激。请注意,此动词会执行记录和对象
call_method职能名称1.0.4中的新增功能-在编写的对象上调用提供的方法。其原型必须为“公众职能xxxx($ oSource)”。如果是职能,则职能可以发送异常。在这种情况下,失效消息将显示在log/error.log文件中
clone_attachments<无>1.1.0中的新增功能-将所有附件从源复制到目标

没有用于记录(动词更新)的动词,因为该模块负责该动词。在实现call_method时,这尤其有意义:您无需在目标上调用DBUpdate。另一方面,如果您修改源对象,则必须将其保存到DB。无论如何,明智的做法是从另一个操作活动集执行修改,修改后的对象实际上将成为目的地。

用的占位符:

  • $ this-> attcode $,其中表示源对象
  • $trigger-> attcode $,其中触发器表示触发触发器(仅适用于副本对象)
  • $ current_contact_id $
  • $ current_contact_friendlyname $
  • $current_date$
  • $current_time$

局限性

  • 1.1.2之前的iTop 2.4.0或更高版本中,如果您为iTop定义了自定义日期格式,则在$this->attcode$ or $trigger->attcode$​, 时,日期属性不能正确解码,导致到错误| Error | itop-stencils: rule #3 - Action: set(start_date,$trigger->start_date$) - Wrong format for date attribute start_date, expecting "Y-m-d H:i:s" and got "13-12-2018 00:00:00".
  • 从1.1.2(和iTop从2.4.0开始)仅用于Date(或DateTime)属性,将使用以下语法:
    • $this->​raw(attcode)$ or $trigger->​raw(attcode)$

配置示例

'itop-stencils' => (
   'rules' => (
      (
         'name' => 'Work orders',
         'trigger_class' => 'UserRequest',
         'trigger_scope' => 'SELECT UserRequest',
         'trigger_state' => 'assigned', // triggered when reaching this state
         'report_label' => 'A task list has been created for the ticket', // Label or dictionary entry
         'report_label/FR FR' => 'Une liste de tâche a été créée pour ce ticket',
         'templates' => 'SELECT WorkerOrderTemplate WHERE service_id = :trigger->service_id', // A query to define how to look for the templates
         'copy_class' => 'WorkOrder', // Class of the copied templates
         'copy_actions' => ( // Series of actions to preset the object in the creation form
            'clone(name)',
            'clone(description)',
            'set(ticket_id,$trigger->id$)',
            'set(team_id,$trigger->team_id$)',
            'set(agent_id,$trigger->agent_id$)',
         ),
         'copy_hierarchy' => (
            'template_parent_attcode' => 'parent_id',
            'copy_parent_attcode' => 'workorder_parent_id'
         ),
         'retrofit' => ( // Series of actions to retrofit some information from the created object to the source object
            'set(private_log,A task list has been created for the ticket)',
         ),
      ),
   ),
),

局限性

这些是对象复印机的局限性。

当前未处理以下类型的属性,因此无法预先设置(并且未提供错误消息):

  • 1-N链接(例如服务器接口)
  • 附件
  • 斑点
  • 秒表

变通方案将使用动词“ call_method”(1.0.4中的新增功能)并将您的需要作为目标对象的一种方法来实现。

故障排除

所有错误均记录到文件log/error.log中

从终端用户的角度来看,行为是:

  • 如果未找到模板,则忽略该规则
  • 如果找到错误(错误的OQL,则无法写入目标对象,…),则GUI中未显示任何内容。

原贴链接:https://www.itophub.io/wiki/page?id=extensions%3Aitop-stencils 


Configurator for automatic object creation

name:
Configurator for automatic object creation
description:
Templating based on existing objects.
version:
1.1.2
release:
2019-03-26
itop-version-min:
2.6.0
code:
combodo-configurator-for-automatic-object-creation
state:
stable
download:
https://store.itophub.io/en_US/products/combodo-configurator-for-automatic-object-creation
alternate-name:
Stencils (templating)
diffusion:
iTop Hub

Other versions of this component: 1.0.14

This extensions aims at improving the end-users productivity. It automatically creates a set of prefilled objects out of existing data.

Amongst the possible usages, you can:

  • Preset work orders on a user request, depending on the selected service, to be executed when the request is being assigned to an agent.

  • Preset a list of characteristics on a contract, depending on the selected service, to be recorded right when a contract is being created.

  • Preset the SLAs depending on …

  • Preset server interfaces

This can be combined with Object Copier… for instance: Create a “Move to production” request from a CI. The request gets automatically (or not) assigned, then the work orders are prefilled.

Note that in most cases you will have to alter the existing data model to define your template class.

Principles

Triggering

The templates will be copied under the following circumstances:

  • either when an object is being created

  • or when an object is reaching a given state (lifecycle required)

The objects being in the scope of the trigger can be filtered out by the mean of an OQL: SELECT UserRequest WHERE team_id_friendlyname='Doers'.

Actions

Once the triggering conditions have been met, the module will perform the following:

  1. Look for the templates. This is done by the mean of an OQL. E.g. SELECT WorkOrderTemplate WHERE service_id = :trigger->service_id

  2. For each template,

    1.  

    Instantiate an object called the copy

    1.  

    Perform a series of action on the copy. This is formalized as a list of actions. For instance, “clone(description)+set(ticket_id,$trigger->id$)” will copy the attribute description from the template, then set the parent ticket to be the ticket that triggered the copy

    1.  

    Optionaly find the children of the current template, and for each child perform the same operations; (i.e. a + b + c, recursively)

  3. Optionaly perform a series of actions (set a value, apply a stimulus) back on the triggering object.

A report is displayed (though this is optional) on the triggering object:https://www.itophub.io/wiki/media?media=extensions%3Areport.png

Revision history

DateVersionDescription
2019-03-261.1.2- Fix Issue when copying list with object copier
- Fix Custom Date format in Stencils actions
2019-01-161.1.1Security hardening
2018-12-191.1.0- Support for attachment copy
- Fix duplicated links on Ticket creation from CI
2018-06-261.0.14Add copy_head verb for CaseLog attributes, ES translation
2017-11-151.0.13Fix error displayed in error message or tooltip, about read-only attributes being set.
2017-09-291.0.12Showing action in object details only when target class is writable.
2017-04-041.0.11Case logs : when using set on a case log, the entry was set twice, the HTML formatting was lost, and if the log was first copied from the source, it was broken.
2017-03-271.0.10With some customizations (preset on ticket dates), the refresh of dependent fields was broken. Regression introduced in iTop 2.3
2017-03-231.0.9Fix for XSS vulnerability
2016-08-091.0.8Fix for compatibility with iTop 2.3.0 (still backward compatible): properly handle the breadcrumb + bug fix when using hidden fields and case logs.
2015-10-051.0.7Fix for compatibility with iTop 2.2.0 (backward compatible)
2015-09-301.0.6New verb: nullify. Usefull for leaving a date or datetime undefined (differs from the verb reset because the default value for such attributes is “now”)
2015-07-021.0.5Transfer data from the triggering object to the copies: copy_from_trigger. New verb for custom actions: call_method.
2015-04-081.0.3Retrofit data from the copies to the triggering object: retrofit_from_copy
2015-02-131.0.2Handle the case of an object created (no lifecycle)
2015-02-061.0.1Fixed bug on the reporting: when several rules apply, then only the last report is being displayed
2015-02-031.0.0First released version

Installation

Expand the ZIP file, then copy the contents of the folders itop-stencils and itop-object-copier into the extensions folder of iTop and launch the setup again.

Make sure that the web server has enough rights to read the content of the extensions folder and all its sub-folders before launching the setup

When prompted to select the extensions to install, check “Object copier” and “Stencils” in the list of available extensions.

Configuration

Setting nameDescriptionExample
rulesan array of rules 

A rule is made of…

Rule setting nameDescriptionExample
nameA unique identifier (not used yet) 
trigger_classThe class of objects triggering the copyUserRequest
trigger_scopeAny OQL returning objects of the class trigger_classSELECT UserRequest JOIN Team … WHERE Team.org_id = 123
trigger_stateOptional: the reached state. If left blank, then the object creation will trigger the actions. If a lifecycle is defined, specifying “new” has the same effect as leaving the parameter blankassigned
report_labelOptional: Label or dictionary entry for the report displayed on the created/modified triggering object (additional banner). The feedback is disabled if this entry is missingA task list has been created for the ticket
templatesAn OQL. The parameters :trigger->xxx are available to filter on the triggering objectSELECT Template WHERE team_id = :trigger->team_id
copy_classThe class of objects to create for each templateWorkOrder
copy_actionsA series of actions (see below explanations) that will be executed on each couple template/copy
copy_hierarchyOptional. Must be set to copy a hierarchy of templatesarray('template_parent_attcode'⇒'parent_id', 'copy_parent_attcode'⇒'parent_id')
retrofit_from_copyOptional: A series of actions (see below explanations) to be executed back on the triggering object, for each copy (the copy being the object from which values will be picked)
copy_from_triggerNew in 1.0.4 - Optional: A series of actions (see below explanations) to be executed on the copy, the triggering object being the data source
retrofitA series of actions (see below explanations) to be executed back on the triggering object. Will be executed once, and after all the retrofit_from_copy actions have been performed

report_label can be localized without the burden of create dictionaries. To do so, create the settings report_label/<language_code> (e.g. “menu_label/FR FR”) for each supported language. The setting report_label will be the default value.

If copy_hierarchy is set, then make sure that the query templates will not return at the same time templates and one of their children. Otherwise, children templates will be instantiated a number of times (first as a template, then and as child of one of the templates). Adding the condition AND parent_id = 0 will be sufficient in most of the cases.

An action is specified as a string having formatted as “verb(arg1[,arg2[…]])”. It implies a source object and a destination object. Source and destination objects both depend on the context in which the series of actions is defined:

  • copy_actions: source is the current template object, destination is the corresponding copy

  • copy_from_trigger ( new in 1.0.4 ): source is the triggering object, destination is a copy

  • retrofit_from_copy: source is a top level copy, destination is the triggering object

  • retrofit: source and destination are the triggering object

https://www.itophub.io/wiki/media?media=extensions%3Astencils-actions.png

The following verbs are available:

VerbParametersDescription
clone_scalars<none>Copy all the scalar attributes from source to destination
cloneattcode1,attcode2, …Copy the given attributes from source to destination
resetattcodeReset the attribute (on destination) to its default value
nullifyattcodeNew in 1.0.6 - Reset the attribute to its null value (will appear to be undefined from the end users perspective)
copyatt_to_read,att_to_writeCopy from att_to_read (source) to att_to_write (destination)
appendattcode,stringAppend the string to the attribute (destination). The string can contain placeholders (see explanations below). Commas must be escaped with a backslash. Newlines (\n) are allowed. The character set must be utf-8.
setattcode,valueSet a value (destination). If the value is a string, it can then contain placeholders (see explanations below). Commas must be escaped with a backslash. Newlines (\n) are allowed. The character set must be utf-8.
add_to_listattRead,attWrite,attLink,valueattRead (source) is an external key, attWrite (destination) is a N-N link set, attLink is an attribute on the link class that will be set to <value>
apply_stimulusstimulus codeApplies a stimulus on destination. Note that this verb does record the object
call_methodfunction nameNew in 1.0.4 - Calls the provided method on the written object. Its prototype must be “public function xxxx($oSource)”. The function can send exceptions in case of failure. In such a case, the error message gets displayed in the log/error.log file
clone_attachments<none>New in 1.1.0 - Copy all the attachments from source to destination

There is no verb for recording (insert/update), because the module is in charge of that. This is of particular interest when implementing call_method: you do not need to call DBUpdate on the destination. On the other hand, should you modify the source object, then you have to save it to the DB. Anyhow it is wiser to perform the modification from another actions set, where the modified object will actually be the destination.

Available placeholders:

  • $this->attcode$ where this represents the source object

  • $trigger->attcode$, where trigger represents the triggering object (only for copy actions)

  • $current_contact_id$

  • $current_contact_friendlyname$

  • $current_date$

  • $current_time$

Limitations

  • Before 1.1.2 with iTop 2.4.0 or above, if you have defined a custom date format for your iTop, the a date attribute is not decoded correctly when using$this->attcode$ or $trigger->attcode$​, leading to an error | Error | itop-stencils: rule #3 - Action: set(start_date,$trigger->start_date$) - Wrong format for date attribute start_date, expecting "Y-m-d H:i:s" and got "13-12-2018 00:00:00".

  • From 1.1.2 (and iTop from 2.4.0) for Date (or DateTime) attributes only, the following syntax as to be used:

    •  

    $this->​raw(attcode)$ or $trigger->​raw(attcode)$

Configuration example

'itop-stencils' => (
   'rules' => (
      (
         'name' => 'Work orders',
         'trigger_class' => 'UserRequest',
         'trigger_scope' => 'SELECT UserRequest',
         'trigger_state' => 'assigned', // triggered when reaching this state
         'report_label' => 'A task list has been created for the ticket', // Label or dictionary entry
         'report_label/FR FR' => 'Une liste de tâche a été créée pour ce ticket',
         'templates' => 'SELECT WorkerOrderTemplate WHERE service_id = :trigger->service_id', // A query to define how to look for the templates
         'copy_class' => 'WorkOrder', // Class of the copied templates
         'copy_actions' => ( // Series of actions to preset the object in the creation form
            'clone(name)',
            'clone(description)',
            'set(ticket_id,$trigger->id$)',
            'set(team_id,$trigger->team_id$)',
            'set(agent_id,$trigger->agent_id$)',
         ),
         'copy_hierarchy' => (
            'template_parent_attcode' => 'parent_id',
            'copy_parent_attcode' => 'workorder_parent_id'
         ),
         'retrofit' => ( // Series of actions to retrofit some information from the created object to the source object
            'set(private_log,A task list has been created for the ticket)',
         ),
      ),
   ),
),

Limitations

These are the limitations of Object Copier.

The following types of attributes are currently not handled and therefore cannot be preset (and no error message is given):

  • 1-N links (e.g. Server Interfaces)

  • Attachments

  • Blobs

  • Stop watches

The workaround is to use the verb 'call_method' (new in 1.0.4) and implement your need as a method of the destination object.

Troubleshooting

All errors are logged to the file log/error.log

The behavior from the end-user perspective is:

  • If no template have been found, the rule is ignored

  • If an error is found (wrong OQL, the target object cannot be written, …) nothing is shown in the GUI.

标签:
由 superadmin 在 2020/08/27, 16:03 创建
    

需要帮助?

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

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