批量修改

在iTop中有两种方法可以执行批量修改:

  • 交互式CSV导入:这对于重新导入一组已导出和修改的数据很有用。FIXME缺少日期格式功能
  • 在对象列表上修改功能:当您想在一组对象中对齐值时,这对于数据清理(规范化)很有用,或者在您需要以相同方式修改许多对象时用于日常操作时,这很有用。

交互式CSV导入

iTop提供了功能强大的CSV导入特性,可协助终端用户(和管理员)在iTop中大规模创建或更新对象。

要启动CSV导入向导,请单击导入管理部分中的CSV导入菜单。

CSV Import Menu Item

仅具有批量修改权利的用户才能使用交互式CSV导入

CSV模板

iTop提供了用于创建或导入任何类对象的CSV模板。您可以从CSV导入向导的第三个选项卡“模板”中下载或复制粘贴该模板。

CSV Import Templates

从下拉列表中选择所需的类以生成模板。然后,单击大的Excel图标以下载模板,或者从图标下面的文本区域复制粘贴文本。

获取预填充模板的另一种方法是导出以CSV格式存在的对象。参考导出数据 有关如何执行此任务的详细说明。

值的预期格式

为了加载某些类型的属性,您需要以特定格式提供它们的价值。

链接集

检查一下这里 导入关系所需的格式

日期

可以在导入期间指定导入的数据的日期格式,但是源文件中的所有日期都必须使用相同的格式。该格式可以是在iTop上定义的默认格式,也可以是您指定的任何格式。

HTML文字

您可以为原始HTML提供标签。例如:<p> <b>Bold<< b> <br>是<< p>

图像文件(2.4中的新增功能)

某些类将图像或文件文档作为其字段之一。例如,Person类,包含保存这个人的照片的图片域。以交互方式编辑人物时,用户可以从她的计算机上载图像以提供人物图片。但是,在执行CSV导入时,由于CSV格式不支持此文件,因此无法“上载”此类文件或将其内容放入CSV文件本身。

在这种情况下,CSV文件必须在相应的CSV列中提供一个用于上传文件的URL。必须从iTop服务器可以访问此URL,并返回所需的图像(或文件文档)。如果上载失败,或者上载文档的格式与该字段的预期格式不匹配(例如,如果URL不返回图片域的图像),则导入和更新对该字段(以及整行)都会失败的CSV将会被拒绝)。

局限性:

  • 该URL必须直接指向要上传的图像(不支持重定向)
  • 必须从iTop Web服务器可以访问URL(请注意,某些公众网站可能拒绝访问PHP脚本-它们检查HTTP用户处理人员字符串)
  • 该URL不需要身份验证,因为上传是由iTop服务器本身完成的
  • 支持指向iTop本身的URL(例如CSVVExcel导出提供的URL)。但仅当它们指向相同的iTop实例时(在这种情况下,导入才会解析提供的URL并从iTop数据库中读取文档)。
  • 如果使用管理员账号执行CSV导入,则可以指定iTop服务器本身上的文件的路径(但这仅适用于管理员)。

外部对象

要加载作为另一个对象的外部键的属性,可以提供被声明为远程类的协调属性的属性的任意组合。

示例:如果要加载用户请求并设置提交人(caller_id),则可以提供这些列的任意组合来标识提交人:

  • Caller->Email

  • Caller->Organization name

  • Caller->First Name

  • Caller->Last Name

  • Caller->Full Name

  • Caller->Employee number

标签集

要加载TagSet属性,必须导入标签,并用管道|分隔标签。开头和结尾必须有一个管道。

上载数据

CSV导入的第一步包括将数据上传到服务器。您可以从计算机上载文件,也可以直接在向导的第二个选项卡中复制粘贴数据。

要从计算机上载文件,请使用向导第一个选项卡上的文件上载表单。确保您还选择了用于保存文件的适当字符集。

如果您使用的字符集在下拉列表中不可用,请联系人您的iTop管理员(此列表可通过 csv_import_charsets 配置变量进行配置)。

如果选择复制粘贴数据,请使用向导的第二个选项卡复制并粘贴数据:

Copy and paste data

然后单击下一步»继续向导的下一步。

CSV Import Step 2

在此步骤中必须调整以下参数:

参数含义
分隔符这是用于分隔CSV文件中不同列的字符。如果列的正确显示和页面底部的预览中的分隔,则当前选择正确。 (CSV文件的典型选择是逗号)
文字限定符有时,单元格内的值包含分隔符。然后,将这些字段用文本限定符括起来,以防止在单元格的中间错误地解释分隔符。 (典型的价值是单引号或双引号)
将第一行视为标题如果文件的第一行包含标题(列名)而不是实际的数据,则选中此框。请注意,在页面底部的预览中,标题行以不同的颜色显示。
开始时跳过x行某些CSV文件(通常是由手工脚本生成的CSV文件)在文件的开头包含一些注释。使用此设置可以告诉iTop忽略跳过注释所需的任意行。跳过的行从页面底部的预览中删除。

如果重音符号未在预览中正确显示,请使用<< <<返回按钮返回向导的第一页,并选择适当的字符集,然后再次上传CSV文件。

数据在预览中看起来正确后,单击“下一步»”按钮转到下一步:

Data mapping

导入向导的第三步定义了CSV文件的列与iTop中对象的字段之间的映射。第一个运维包括选择导入的对象类别。这确定了可用于映射的字段列表。

字段映射

如果CSV文件最初是使用模板或iTop CSV导出创建的,则CSV中提供的标题应会自动为您提供正确的映射。

如果不是这种情况,则必须手动创建此映射。

该向导需要为导入的数据的每一列映射。但是,通过选择-忽略此字段-作为此列的映射,可以忽略(即不导入)列。

搜索规则

CSV导入向导可用于在iTop中创建或更新对象。向导使用在此步骤中定义的搜索规则来确定CSV文件的每一行是否对应于iTop中的现有对象。如果对象存在,则将对其进行更新,否则将创建它。通常,在iTop搜索表单中,所有选定的搜索规则都使用AND运算符进行合并。 (即对象必须与对象规则的每个搜索匹配,才被视为匹配项)。

完全相同的导入CSV文件可以在所选搜索规则的iTop依赖中产生不同的结果。创建或更新的对象数依赖于在此阶段定义的搜索规则。

高级管理员的用法

管理员可以访问高级模式(页面右上方的复选框),该模式允许根据其内部标识符(ID或键号)对导入对象进行访问。这对于重命名从iTop导出的对象很有用。不要对未从iTop导出的对象使用此选项,或者至少确保您知道要导入的数据!高级模式还允许管理员按照说明使用导入LinkedSet这里.

设计提示适用于管理员

为数据模型中的每个类定义了对帐属性。如果在负载中提供了此类属性,则会将它们自动设置为搜索规则。

一旦映射和搜索规则看起来正确,就可以通过单击Simulate Import:按钮进行导入的仿真。

模拟导入

几秒钟后,将显示以下总结屏幕:

https://www.itophub.io/wiki/media?w=600&tok=4e6cdd&media=2_7_0%3Auser%3Acsv-import-4.png

注意要创建的对象数和要更新的对象数,以及错误数。您可以使用页面顶部的过滤器复选框,以更快地分析结果。

错误的行用红色后台突出显示。错误不会阻止导入运行,但是相应的行将被拒绝。

如果模拟结果看起来很奇怪,则可能是搜索规则不正确。然后按“返回”按钮变更,然后再次模拟。如果需要修改数据,请单击| <<重新启动(“复制并粘贴数据”选项卡将包含上载的数据的副本)。如果模拟看起来正确,请单击“运行数据”!以执行实际的数据。

运行导入

如果导入的对象数量以及要创建或更新的对象百分比超过一定水平,则会显示确认对话框:

CSV Import confirmation dialog

单击“是”关闭对话框,然后继续数据导入。

向导的最后一个屏幕显示总结在总结期间执行的操作。

Import Summary

如果出现错误,被拒绝的行会在报告的底部列出,可以将它们复制粘贴并进行更正,然后再次导入。

替代方法是进行迭代:

  1. 完成导入向导,并注意哪些行有错误。包含错误的行将被忽略。
  2. 在引用CSV文件中修复错误中的行。
  3. 使用引用CSV文件(整个文件)重新运行导入
  4. 重复直到找不到错误。

iTop将忽略那些未更改的行,因为相应的数据已经更新(除非与此同时其他人在两次导入之间进行了修改)。如果您需要维护数据的引用CSV文件,则首选对整个CSV文件进行迭代。

修改功能

iTop允许批量修改对象列表。在一个运维中,此运维对于将许多对象的字段设置为相同的价值非常有用。

  • 量修改。仅当列表中的所有对象属于同一类时,才可以在列表中使用。例如,不可能在“联系人”列表上执行“修改”,因为该列表可能包含“团队”和“人员”的混合。如果要执行这样的运维,请确保将搜索缩小为仅一类对象。
  • 访问受限。并非所有用户都可以执行批量操作。如果该菜单项未显示在下拉列表中,请让您的管理员检查iTop账号的安全简档。
  • 改大量对象。 (数百个或更多),这可能需要很多时间才能执行。由于出于安全的原因,所有交互操作都是有时间限制的(超时),因此联系人在进行重大修改之前先对管理员进行检查,以检查是否允许在交互模式下保持这种状态。大型更新操作的另一种解决方案是准备一个CSV文件,该文件将以命令行模式直接加载到服务器上。

Modify All..

从“其他操作活动”菜单项中选择“修改”,将显示以下页面:

Modify All

在此步骤中,您可以选择要更新的对象。默认情况下,所有这些都被选中,因此将被修改。浏览列表以检查是否存在问题,然后单击下一步»进入下一个屏幕。

对象修改版表单出现,每个字段旁边都有一个复选框和一个数字指标。指标告诉所有选定对象中,此特定字段存在多少个不同的值。如果该字段的所有对象都具有相同的价值,则指标为绿色(Only One Value),选中该复选框,并且该字段是可编辑的。否则,指标为红色,并且未选中该复选框。当鼠标指针位于红色指标上时,将显示工具提示,显示有关该字段的不同值的信息。

Modify All Form

仅选中相应复选框的字段将被修改。所有其他字段将保持不变。通过选中红色指标(即字段在对象之间包含多个不同值)前面的复选框,可以将所有值强制为同一个同质价值。

单击预览修改»以显示确认屏幕:

Modify All Confirmation

检查列表以检查“操作”列中是否报告了任何错误,并且准备就绪后,单击“全部修改”以实际执行批量修改。

原文链接:https://www.itophub.io/wiki/page?id=2_7_0%3Auser%3Abulk_modify


Bulk Modifications

There are two ways to perform bulk modifications in iTop:

  • The Interactive CSV Import: this is useful for re-importing a set of exported and modified data. FIXME missing date format capabilities

  • The Modify action on a list of objects: this is useful for data clean-up (normalization) when you want to align values within a set of objects, or for daily operations when you need to modify many objects in the same manner.

Interactive CSV Import

iTop provides a powerful CSV Import feature to assist end-users (and administrators) in massively creating or updating objects in iTop.

To launch the CSV Import Wizard, click on the CSV Import menu in the Data Administration section.

CSV Import Menu Item

Only users with bulk modify rights are allowed to use the interactive CSV import

CSV Templates

iTop provides CSV templates for creating/importing any class of objects. You can either download or copy/paste the template from the third tab Templates in the CSV Import wizard.

CSV Import Templates

Select the desired class from the drop-down list to generate the template. Then either click on the big Excel icon to download the template, or copy/paste the text from the text area below the icon.

Another way to obtain a pre-filled template is to export existing objects in CSV. Refer to Export data for detailed instructions about how to perform this task.

Expected format for values

In order to load some type of attributes, you need to provide their value in a particular format.

LinkedSet

Check here for the format required to import relationships

Date

Date format of the imported data can be specified during the import, but all dates in your source file must be using the same format. This format can be either the default one defined on your iTop or any that you specify.

Text with HTML

You can provide the raw HTML with tags. Example: <p><b>Bold</b><br>Yes</p>

Image / file (New in 2.4)

Some classes contain an image or a file document as one of their field. For example, the Person class, contains a Picture field which holds the picture of this person. When editing a Person interactively, the user can upload an image from her computer to provide the picture of the person. However when performing a CSV import, it is not possible to “upload” such a file or to put its content inside the CSV file itself, since the CSV format does not support this.

In such a case the CSV file must provide - in the appropriate CSV column - an URL to upload the file from. This URL must be accessible from the iTop server and return the expected image (or file document). If the upload fails or if the format of the uploaded document does not match the expected format for the field (for example if the URL does not return an image for the picture field), the import/update will fail for this field (and the whole line of the CSV will be rejected).

Limitations:

  • The URL must point directly to the image to upload (redirections are not supported)

  • The URL must be accessible from the iTop web server (beware some public websites may deny access to a PHP script - they check the HTTP User Agent string)

  • The URL must not require authentication, since the upload is done by the iTop server itself

  • URLs pointing to iTop itself (like the URLs provided by CSV/Excel export) are supported. But only if they point to the same iTop instance (in such a case the import will parse the provided URL and will read the document from the iTop database).

  • If you use an administrator account to perform the CSV import, you can specify a path to a file located on the iTop server itself (but this works only for administrators).

External object

For loading an attribute which is an external key to another object, you can provide any combination of attributes which are declared as reconciliation attributes for the remote class.

Example: if you were to load UserRequest and set the Caller (caller_id), you could provide any combination of those columns to identify the caller:

  • Caller->Email

  • Caller->Organization name

  • Caller->First Name

  • Caller->Last Name

  • Caller->Full Name

  • Caller->Employee number

TagSet

For loading a TagSet attribute, the tags have to be imported with their label separated by a pipe |. There must be a pipe at the beginning and at the end.

Uploading Data

The first step of the CSV import consists of uploading the data to the server. You can either upload a file from your computer or directly copy/paste the data in the second tab of the wizard.

To upload the file from your computer, use the file upload form on the first tab of the wizard. Make sure that you also select the appropriate character set that was used for saving the file.

If the character set that you use is not available in the drop-down list, contact your iTop administrator (this list is configurable via the csv_import_charsets configuration variable).

If you choose to copy/paste the data, use the second tab Copy and paste data of the wizard:

Copy and paste data

Then click Next » to proceed with the next step of the wizard.

CSV Import Step 2

The following parameters must be adjusted during this step:

ParameterMeaning
Separator CharacterThis is the character used for separating the different columns inside the CSV file. If the columns are properly displayed and separated in the preview at the bottom of the page, then the current choice is correct. (The typical choice for a CSV file is the comma)
Text Qualifier CharacterSometimes the values inside the cells contain the separator character. Such fields are then enclosed by the text qualifier character to prevent the separator character from being wrongly interpreted in the middle of a cell. (A typical value is either a simple or double quote)
Treat the first line as a headerCheck this box if the first line of the file contains a header (column names) instead of actual data. Note that on the preview at the bottom of the page, the header line is displayed with a different color.
Skip x lines at the beginningSome CSV files (typically CSV files generated by hand-made scripts) contain some comments at the beginning of the file. Use this setting to tell iTop to ignore as many lines as needed to skip the comments. The skipped lines are removed from the preview at the bottom of the page.

If the accented characters do not displayed properly in the preview, go back to the first page of the wizard using the << Back button and pick the appropriate character set before uploading again your CSV file.

Once the data looks correct in the preview, click on the Next » button to move to the next step:

Data mapping

The third step of the Import Wizard defines the mapping between the column of the CSV file and the fields of the object in iTop. The first operation consists of selecting the class of objects to import. This determines the list of fields available for the mapping.

Fields Mapping

If the CSV file has been originally created using a template or an iTop CSV export, the header provided in the CSV should automatically give you the correct mapping.

If this is not the case, you have to create this mapping manually.

The wizard requires a mapping for each column of the imported data. However a column can be ignored (i.e. not imported) by selecting – ignore this field – as the mapping for this column.

Search Criteria

The CSV Import Wizard can be used to either create or update objects in iTop. The wizard uses the search criteria defined at this step to determine whether each line of the CSV file corresponds to an existing object in iTop or not. If the object exists, then it will be updated, otherwise it will be created. Typically in iTop search forms, all selected search criteria are combined using the AND operator. (i.e. an object must match each value of the Search criteria to be considered as a match).

The exact same imported CSV file can produce different results in iTop depending on the selected search criteria. The number of objects created or updated depends on the search criteria defined at this stage.

Advanced Usage for Administrators

Administrators have access to an Advanced mode (a checkbox at the top-right of the page), which allows to import objects based on their internal identifiers (ID or Key number). This is useful for renaming objects exported from iTop. Do not use this option for objects not exported from iTop, or at least make sure that you know the data you are importing! The Advanced modealso allows administrators to import LinkedSet as described here.

Design tip for Administrators

Reconciliation attributes are defined for each class in the Datamodel. If such attributes are provided in the load, they are automatically set as Search criteria.

Once the mapping and the search criteria looks correct, proceed to the simulation of the import by clicking on the Simulate Import: button.

Simulate import

After a few seconds, the following summary screen is displayed:

https://www.itophub.io/wiki/media?w=600&tok=4e6cdd&media=2_7_0%3Auser%3Acsv-import-4.png

Note the number of objects to be created and the number of objects to be updated, as well as the number of errors. You can use the checkboxes at the top of the page to filter the display for a quicker analysis of the results.

The lines in errors are highlighted with a red background. Errors will not prevent the import from running, but the corresponding lines will be rejected.

If the results from the simulation look wierd, maybe the Search criteria aren't correct. then press Back button to change them and Simulate again. If you need to modify the data, click on |<< Restart (the Copy and paste data tab will contain a copy of the uploaded data). If the simulation looks correct, click Run the Import! to perform the actual import.

Run import

If the number of objects imported and the percentage of objects to be created or updated exceeds a certain level, a confirmation dialog is displayed:

CSV Import confirmation dialog

Click Yes to close the dialog and proceed with the data import.

The last screen of the wizard displays the summary of the operations performed during the import.

Import Summary

In case of errors, the rejected lines are listed at the bottom of the report, they can be copied/pasted and corrected before being imported again.

An alternative to this is to proceed iteratively:

  1. Complete the import wizard, and note which lines have errors. Lines containing errors are simply ignored.

  2. Fix the lines in error in your reference CSV file.

  3. Re-run the import with your reference CSV file (the whole file)

  4. Repeat until no error is found.

iTop will ignore lines that have been unchanged, because the corresponding data is already up-to-date (unless modified between two imports by somebody else in the mean time ). Iterating on the whole CSV file may be the preferred option, if you need to maintain a reference CSV file of your data.

The Modify Action

iTop allows the bulk modification of a list of objects. This operation is very useful for setting a field of many objects to the same value, in one operation.

  • Bulk modification. This is only possible on a list if all the objects of the list are of the same class. For example, it is not possible to perform a Modify on a list of Contacts, since the list may contain a mix of Teams and Persons. If you want to perform such an operation, make sure that you narrow your search to just one class of objects.

  • Limited access. Not all users are allowed to perform bulk operations. If the menu item is not displayed in the drop-down list, ask your administrator to check the security profile of your iTop account.

  • Modifying a large number of objects. (several hundreds or more) This may require a lot of time to be performed. Since all interactive operations are time-limited (time-out) for security reasons, contact your administrator before performing major modifications, to check if this is allowed/sustainable in interactive mode. An alternate solution for large update operations is to prepare a CSV file that will be loaded directly on the server in command-line mode.

Modify All..

Select Modify from the Other Actions menu item, the following page is displayed:

Modify All

At this step, you can select the objects to be updated. By default, all of them are checked and therefore will be modified. Browse the list to check that there is no issue and click on Next » to proceed to the next screen.

The object modification form appears with a checkbox and a numeric indicator next to each field. The indicator tells how many different values exist for this specific field among all the selected objects. If all objects have the same value for this field, the indicator is green (Only One Value), the checkbox is checked and the field is editable. Otherwise, the indicator is red and the checkbox is unchecked. When the pointer of the mouse is positioned over a red indicator, a tooltip is displayed showing information about the different values of the field.

Modify All Form

Only the fields for which the corresponding checkbox is checked will be modified. All other fields will remain unchanged. By checking the checkbox in front of a red indicator (i.e. a field that contains several different values among the objects) you can force all the values to the same homogenous value.

Click on Preview Modifications » to display a confirmation screen:

Modify All Confirmation

Inspect the list to check if any errors are reported in the Operations column, and when ready, click on Modify All to actually perform the bulk modification.

标签:
由 superadmin 在 2020/08/25, 16:04 创建
    

需要帮助?

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

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