属性规则属性

摘要

Describe 函数将返回已添加属性规则的数据集的以下属性。

可将属性规则添加到地理数据库要素类。返回的 dataType 是要素类或表的 dataType

属性

属性说明数据类型
batch
(只读)

指示是否在批处理模式下执行规则。

  • True - 在批处理模式下执行规则。
  • False - 不在批处理模式下执行规则。

计算规则可能会返回 true 或 false,但约束规则将始终返回 false,验证规则将始终为 true。

Boolean
checkParameters
(只读)

系统生成的用于定义基于 Data Reviewer 的规则配置的 JSON 值。

了解有关可用 ArcGIS Data Reviewer 校验的详细信息

Object
creationTime
(只读)

创建属性规则的日期和时间。

DateTime
description
(只读)

属性规则的描述。

String
errorMessage
(只读)

如果属性规则具有自定义错误消息(即约束规则),则此属性将返回为该规则分配的错误消息。

String
errorNumber
(只读)

如果属性规则具有自定义错误编号(即约束规则),则此属性将返回为该规则分配的错误编号。

Long
evaluationOrder
(只读)

如果规则类型为计算,则该值可提供执行规则的顺序。赋值顺序基于将规则添加至数据集的顺序。例如,如果规则 A规则 B 之前添加,则规则 A 的赋值编号将较小。

Long
excludeFromClientEvaluation
(只读)

将返回一个布尔值,用于描述是否从客户端赋值中排除规则。

  • True - 将从客户端赋值中排除该规则(仅限服务器)。
  • False - 将针对所有客户端执行该规则。

Boolean
fieldName
(只读)

如果将属性规则分配给字段(即计算规则类型),则该属性将返回字段名称。

String
id
(只读)

将规则 ID 作为整数值返回。

Integer
isEnabled
(只读)

返回的布尔值描述了是否已启用该规则。

  • True - 该规则已启用并将得到支持。
  • False - 该规则被禁用并且不会得到支持。

Boolean
name
(只读)

属性规则的名称。

String
referencesExternalService
(只读)

指示规则是否引用任何外部服务。

Boolean
requiredGeodatabaseClientVersion
(只读)

将根据规则来设置所需的地理数据库客户端版本,具体取决于脚本表达式中使用的 Arcade 函数。例如,如果脚本包含 Sequence 操作,则需要 10.6.1 版本的地理数据库。

String
scriptExpression
(只读)

用于定义规则的 Arcade 表达式。

注:

此属性不可用于 Data Reviewer 规则

String
severity
(只读)

定义错误的严重性。此属性适用于验证规则类型。

Integer
subtypeCode
(只读)

如果将属性规则分配给子类型,则该属性将返回所分配的子类型代码。

Long
tags
(只读)

一组用于标识规则的标记。

String
triggeringEvents
(只读)

属性规则中定义的触发事件。例如,在编辑过程中,插入、更新或删除事件可能会触发规则。

String
type
(只读)

属性规则的类型。例如,规则可以为计算或约束规则类型。

String
userEditable
(只读)

将返回一个布尔值,用于描述规则是否允许对此规则正在进行修改的属性字段进行编辑。

  • True - 编辑者可以编辑属性值。
  • False - 编辑者不能编辑属性值。

Boolean

代码示例

属性规则属性示例(独立脚本)

以下独立 Python 脚本用于打印要素类属性规则属性的报表。

# Import the required modules
import arcpy
# Path to the input feature class or table
fc = "C:\\MyProject\\MyDatabase.sde\\myGDB.USER1.Building"
# Print a report of the attribute rule properties
attRules = arcpy.Describe(fc).attributeRules
print("- Attribute Rule Properties -")
for ar in attRules:    
    if "Calculation" in ar.type:       
        print("- Calculation Rule:")
        print(" Name: {0}".format(ar.name))
        print(" Creation time: {0}".format(ar.creationTime))
        print(" Field: {0}".format(ar.fieldName))
        print(" Subtype code: {0}".format(ar.subtypeCode))
        print(" Description: {0}".format(ar.description))
        print(" Is editable: {0}".format(ar.userEditable))
        print(" Is enabled: {0}".format(ar.isEnabled))
        print(" Evaluation order: {0}".format(ar.evaluationOrder))
        print(" Exclude from client evaluation: {0}".format(ar.excludeFromClientEvaluation))
        print(" Triggering events: {0}".format(ar.triggeringEvents))
        print(" Script expression: {0} \n".format(ar.scriptExpression))
        print(" Is flagged as a batch rule: {0} \n".format(ar.batch))
        print(" Severity: {0} \n".format(ar.severity))
        print(" Tags: {0} \n".format(ar.tags))
    elif "Constraint" in ar.type:       
        print("- Constraint Rule:")
        print(" Name: {0}".format(ar.name))
        print(" Creation time: {0}".format(ar.creationTime))
        print(" Subtype code: {0}".format(ar.subtypeCode))
        print(" Description: {0}".format(ar.description))
        print(" Is editable: {0}".format(ar.userEditable))
        print(" Is enabled: {0}".format(ar.isEnabled))
        print(" Error number: {0}".format(ar.errorNumber))
        print(" Error message: {0}".format(ar.errorMessage))
        print(" Exclude from client evaluation: {0}".format(ar.excludeFromClientEvaluation))
        print(" Triggering events: {0}".format(ar.triggeringEvents))
        print(" Script expression: {0} \n".format(ar.scriptExpression))
        print(" Tags: {0} \n".format(ar.tags))
    elif "Validation" in ar.type:       
        print("- Validation Rule:")
        print(" Name: {0}".format(ar.name))
        print(" Creation time: {0}".format(ar.creationTime))
        print(" Subtype code: {0}".format(ar.subtypeCode))
        print(" Description: {0}".format(ar.description))
        print(" Is enabled: {0}".format(ar.isEnabled))
        print(" Error number: {0}".format(ar.errorNumber))
        print(" Error message: {0}".format(ar.errorMessage))
        print(" Script expression: {0} \n".format(ar.scriptExpression))
        print(" Is flagged as a batch rule: {0} \n".format(ar.batch))
        print(" Severity: {0} \n".format(ar.severity))
        print(" Tags: {0} \n".format(ar.tags))
Data Reviewer 属性规则属性示例(独立脚本)

以下独立 Python 脚本用于打印 Data Reviewer 生成的属性规则的检查参数属性报告。

# Import the required modules import arcpy
# Path to the input feature class or table fc = "C:\\MyProject\\MyDatabase.sde\\myGDB.USER1.FacilitySite"
# Print a report of the checkParameter properties attRules = arcpy.da.Describe(fc)['attributeRules'] for rule in range(len(attRules)):
    for key, value in attRules[rule]['checkParameters'].items():
        print("{}: {}".format(key, value))

在本主题中