Skip to main content

创建分类方案

在 将分类方案分配 给您的组织之前,必须通过在有效的 JSON 文件中定义分类的配置选项来创建方案。 您创建的分类方案必须遵循分类语法,即 Portal for ArcGIS 随附的 JSON 方案,用于描述和验证分类方案。

根据组织的需要,您可以创建简单方案,其中至少定义所需属性;您也可以创建复杂方案,其中将使用 ArcGIS Arcade 表达式 对项目进行高度详细的分类。 请参阅以下分类方案的完整示例,或者从 ArcGIS/Classification GitHub 资料档案库 下载示例方案。

注:

以下示例和 ArcGIS/Classification GitHub 资料档案库 中的示例方案旨在用作创建满足组织需求的分类方案的参考。

当创建分类方案时,需要首先定义以下属性:

注:

除非另有说明,否则属性为可选项。

注:

Arcade 表达式不支持 < 和 > 字符。

  • name - 必需属性,用于标识分类方案的名称。

  • version - 必需属性,用于标识分类方案的版本。

  • grammarVersion - 必需属性,用于指定方案所遵循的分类语法的版本。 通过在门户网站上浏览至 组织 > 设置 > 项目 > 项目分类 ,可以找到分类语法版本。

  • helpToolTip - 将鼠标悬停在分类表单顶部的 信息 按钮 信息 上时将显示的帮助文本。

  • helpURL - 当单击分类表单顶部的 信息 按钮 信息 时,将在新选项卡上打开的方案帮助文档的 URL。

  • bannerExpression - 将在项目页面的 分类 下显示的分类信息。 可以使用 Arcade 表达式创建通栏文本或者将该值设置为空字符串,以实现在分类表单中为 uiElements 定义的通用编码逻辑(例如, bannerOrder 、 bannerLabel 和 labelDelimiter )。

    注:

    如果您忽略此属性或者将其定义为空字符串,则必须至少具有一个已定义 bannerOrder 的属性以实现通用编码逻辑。

  • selectionTextExpression - 将显示在 编辑分类 对话框上的分类信息。 可以使用 Arcade 表达式创建通栏文本或者将该值设置为空字符串,以实现在分类表单中为 uiElements 定义的通用编码逻辑(例如, selectionDisplayOrder 、 selectionDisplayLabel 和 labelDelimiter )。

    注:

    如果您忽略此属性或者将其定义为空字符串,则必须至少具有一个已定义 selectionDisplayOrder 的属性以实现通用编码逻辑。

  • attributeCategories - 将在分类表单中显示为部分或选项卡的属性类别的列表。

    注:

    单词 default 为保留关键字,无法用作属性类别。

{ "name": "academic-institution-classification-schema", "version": "2.0", "grammarVersion": "2.0", "helpURL": "https://ansible.hynes.com/portal/home/schema_help.pdf", "helpTooltip": "Click to open the schema help document", "bannerExpression": "", "selectionTextExpression": "", "attributeCategories": [] }


## 定义 classificationMetadata {#953}

所需 `classificationMetadata` 对象可以包含以下属性:

- `primaryAttribute` - 必需属性,用于标识在分类表单中显示为主分类字段的属性。

- `defaultValue` - 必需属性,用于指定 `primaryAttribute` 属性的默认值。

- `classificationValueProperties` - 必需的对象数组,其中每个对象表示标识为 `primaryAttribute` 值的属性的分类选项,并定义该选项的特定属性。 可以为每个分类选项定义以下属性:

- `value` - 必需属性,用于指定在分类表单中使用的选项的标注。

- `acronym` - 该选项的首字母缩写。

- `textColor` - 选择该选项后,其标注将以此颜色显示在分类表单中的 **当前选择** 下。 可以使用预定义颜色名称或者 RGB 和 HEX 值指定颜色。

- `backgroundColor` - 选择该选项后,其标注将以此颜色高亮显示在分类表单中的 **当前选择** 下。 可以使用预定义颜色名称或者 RGB 和 HEX 值指定颜色。

```nohighlight
{
...

"classificationMetadata": {
 "primaryAttribute": "classification",
 "defaultValue": "Public Data",
 "classificationValueProperties": [
   {
     "value": "Public Data",
     "acronym": "Public Data",
     "backgroundColor": "Green",
     "textColor": "Black"
   },
   {
     "value": "Restricted",
     "acronym": "Restricted",
     "backgroundColor": "Yellow",
     "textColor": "Black"
   },
   {
     "value": "Confidential",
     "acronym": "Confidential",
     "backgroundColor": "Red",
     "textColor": "Black"
   }
 ]
}
}

定义属性

在必需 attributes 对象中定义的每个属性都对应于分类表单中的输入字段。 可以为每个属性定义以下特性:

  • label - 必需属性,用于指定在分类表单中使用的属性的标注。

  • description - 在输入字段中用作占位符的描述。

  • type - 必需特性,用于定义属性的数据类型。 受支持的数据类型为字符串、日期、整型、浮点型和布尔型。

  • isRequired - 布尔值(true 或 false),用于指定该属性是否为必需项。 无法将其定义为空字符串。

  • uiElement - 必需属性,用于标识分类表单中属性的 UI 元素类型。 7 个可能的值如下:

    • text - 单行文本框。

    • checkbox - 标准复选框。

    • date - 日期选取器,允许以 DD/MM/YYYY 格式从日历中选择日期。

    • single-select - 下拉菜单,用于选择单个选项。

    • multi-select - 下拉菜单,用于选择多个选项。

    • multi-grouped-select - 下拉菜单,用于从相关选项组中选择单个选项,但无法选择顶级组本身。

    • multi-grouped-select-nested - 下拉菜单,用于选择相关选项组或者从这些组中选择单个选项。

  • defaultValue - 为属性分配的默认值。 只能为 single-select、multi-select、multi-grouped-select 和 multi-grouped-select-nested uiElement 类型设置此属性。

  • defaultDateTimeline - 与 defaultDateTimelineUnits 结合使用,以设置属性的默认日期。 只能为日期 uiElement 类型设置此属性。

  • defaultDateTimelineUnits - 与 defaultDateTimeline 结合使用,以设置属性的默认日期。 可能的值为年、月和日。 只能为日期 uiElement 类型设置此属性。

  • validValues - 在分类表单中 single-select 或 multi-select uiElement 类型下拉菜单中显示的选项的列表。 如果这些选项由 valueExpression 的 Arcade 表达式生成,则可以将其定义为空字符串。

  • validValuesMap - 在分类表单中 multi-grouped-select 或 multi-grouped-select-nested uiElement 类型下拉菜单中显示的选项的映射。 如果这些选项由 valueExpression 的 Arcade 表达式生成,则可以将其定义为空字符串。

  • valueExpression - Arcade 表达式,当未定义 validValues 和 validValuesMap ,或者未将其定义为空字符串时,该表达式将返回选项列表。

  • isAttributeEnabled - Arcade 表达式,该表达式将返回一个布尔值,用于指定将在分类表单中显示还是隐藏属性。

  • attributeValidation - Arcade 表达式,该表达式将基于分类表单中为属性选择的值返回空字符串或错误消息。

  • arcadeResultLookup - 键和值的映射,用于为 valueExpression 定义 Arcade 表达式以生成列表。

  • attributeCategory - 属性在分类表单中显示的 attributeCategories 部分或选项卡。

  • selectionDisplayOrder - 属性在 selectionTextExpression 文本中出现的顺序。

    注:

    如果您忽略 selectionTextExpression 或者将其定义为空字符串,则必须在分类中至少为一个属性定义此属性。

  • selectionDisplayLabel - 在 selectionTextExpression 文本中使用的属性的标注。

  • bannerOrder - 属性在 bannerExpression 文本中出现的顺序。

    注:

    如果您忽略 bannerExpression 或者将其定义为空字符串,则必须在分类中至少为一个属性定义此属性。

  • bannerLabel - 在 bannerExpression 文本中使用的属性的标注。

  • labelDelimiter - 分隔符,用于在 selectionTextExpression 和 bannerExpression 文本中分隔属性的标注和值。

  • valueDelimiter - 分隔符,当 multi-select uiElement 类型中的选定值显示在 selectionTextExpression 和 bannerExpression 文本中时,用于分隔这些值。

  • attributeDelimiter - 分隔符,用于在 selectionTextExpression 和 bannerExpression 文本中分隔属性及其前一个属性。

  • labelTooltip - 将鼠标悬停在属性标注旁的 信息 按钮 信息 上时将显示的帮助文本。

{ ...

"attributes": { "classification": { "label": "Classification", "description": "Classification", "type": "string", "uiElement": "single-select", "validValues": [{"label": "Public Data", "value": "Public Data"}, {"label": "Restricted", "value": "Restricted"}, {"label": "Confidential", "value": "Confidential"}], "selectionDisplayOrder": 1, "bannerOrder": 1, "labelDelimiter": "", "valueDelimiter": "-", "attributeDelimiter": ";" }, "program": { "label": "Program", "description": "Program", "type": "string", "uiElement": "single-select", "valueExpression": "function getProgramValidValues(schemaJsonString, valueJsonString, attributeId) {\n var valueJson = Dictionary(valueJsonString)\n var schemaJson = Dictionary(schemaJsonString)\n if (!HasKey(valueJson, "classification"))\n return null;\n if (valueJson.classification == "Public Data")\n return schemaJson.attributes[attributeId].arcadeResultLookup["Public_Data_List"];\n if (valueJson.classification == "Restricted")\n return schemaJson.attributes[attributeId].arcadeResultLookup["Restricted_List"];\n if (valueJson.classification == "Confidential")\n return schemaJson.attributes[attributeId].arcadeResultLookup["Confidential_List"];\n return null;\n}\ngetProgramValidValues(schemaJsonString, valueJsonString, attributeId)", "arcadeResultLookup": { "Public_Data_List": [{"label": "Intra-agency", "value": "Intra-agency"}, {"label": "Marketing", "value": "Marketing"}, {"label": "Promotional", "value": "Promotional"}], "Restricted_List": [{"label": "Compliance", "value": "Compliance"}, {"label": "Financial", "value": "Financial"}, {"label": "Human Resources", "value": "Human Resources"}, {"label": "Market Data", "value": "Market Data"}, {"label": "PII", "value": "PII"}, {"label": "Proprietary", "value": "Proprietary"}], "Confidential_List": [{"label": "Intellectual Property", "value": "Intellectual Property"}, {"label": "Legal", "value": "Legal"}, {"label": "Security", "value": "Security"}] }, "selectionDisplayOrder": 2, "bannerOrder": 2, "labelDelimiter": "", "valueDelimiter": "-", "attributeDelimiter": ";" } } }


## 定义布局 {#166}

必需 `layouts` 对象用于指定属性在分类表单中的显示顺序。 可以包含以下内容:

- `default` - 包含特定布局详细信息的对象。 可以在该对象内定义以下属性:

- `layoutElements` - 必需对象,用于在分类表单中映射属性及其顺序。 可以为该对象中的每个属性定义以下特性:

 - `formDisplayOrder` - 必需整数,用于标识属性在分类表单中的显示顺序。

```nohighlight
{
...

"layouts": {
 "default": {
   "layoutElements": {
     "classification": {
       "formDisplayOrder": 1
     },
     "program": {
       "formDisplayOrder": 2
     }
   }
 }
}
}

完整示例

以下是分类方案的完整示例:

注:

以下示例方案和 ArcGIS/Classification GitHub 资料档案库 中的示例方案旨在用作创建满足组织需求的分类方案的参考。

{
"name": "academic-institution-classification-schema",
"version": "2.0",
"grammarVersion": "2.0",
"helpURL": "https://ansible.hynes.com/portal/home/schema_help.pdf",
"helpTooltip": "Click to open the schema help document",
"bannerExpression": "",
"selectionTextExpression": "",
"attributeCategories": [],
"classificationMetadata": {
 "primaryAttribute": "classification",
 "defaultValue": "Public Data",
 "classificationValueProperties": [
   {
     "value": "Public Data",
     "acronym": "Public Data",
     "backgroundColor": "Green",
     "textColor": "Black"
   },
   {
     "value": "Restricted",
     "acronym": "Restricted",
     "backgroundColor": "Yellow",
     "textColor": "Black"
   },
   {
     "value": "Confidential",
     "acronym": "Confidential",
     "backgroundColor": "Red",
     "textColor": "Black"
   }
 ]
},
"attributes": {
 "classification": {
   "label": "Classification",
   "description": "Classification",
   "type": "string",
   "uiElement": "single-select",
   "validValues": [{"label": "Public Data", "value": "Public Data"}, {"label": "Restricted", "value": "Restricted"}, {"label": "Confidential", "value": "Confidential"}],
   "selectionDisplayOrder": 1,
   "bannerOrder": 1,
   "labelDelimiter": "",
   "valueDelimiter": "-",
   "attributeDelimiter": ";"
 },
 "program": {
   "label": "Program",
   "description": "Program",
   "type": "string",
   "uiElement": "single-select",
   "valueExpression": "function getProgramValidValues(schemaJsonString, valueJsonString, attributeId) {\n    var valueJson = Dictionary(valueJsonString)\n    var schemaJson = Dictionary(schemaJsonString)\n    if (!HasKey(valueJson, \"classification\"))\n        return null;\n    if (valueJson.classification == \"Public Data\")\n        return schemaJson.attributes[attributeId].arcadeResultLookup[\"Public_Data_List\"];\n    if (valueJson.classification == \"Restricted\")\n        return schemaJson.attributes[attributeId].arcadeResultLookup[\"Restricted_List\"];\n    if (valueJson.classification == \"Confidential\")\n        return schemaJson.attributes[attributeId].arcadeResultLookup[\"Confidential_List\"];\n    return null;\n}\ngetProgramValidValues(schemaJsonString, valueJsonString, attributeId)",
   "arcadeResultLookup": {
     "Public_Data_List": [{"label": "Intra-agency", "value": "Intra-agency"}, {"label": "Marketing", "value": "Marketing"}, {"label": "Promotional", "value": "Promotional"}],
     "Restricted_List": [{"label": "Compliance", "value": "Compliance"}, {"label": "Financial", "value": "Financial"}, {"label": "Human Resources", "value": "Human Resources"}, {"label": "Market Data", "value": "Market Data"}, {"label": "PII", "value": "PII"}, {"label": "Proprietary", "value": "Proprietary"}],
     "Confidential_List": [{"label": "Intellectual Property", "value": "Intellectual Property"}, {"label": "Legal", "value": "Legal"}, {"label": "Security", "value": "Security"}]
   },
   "selectionDisplayOrder": 2,
   "bannerOrder": 2,
   "labelDelimiter": "",
   "valueDelimiter": "-",
   "attributeDelimiter": ";"
 }
},
"layouts": {
 "default": {
   "layoutElements": {
     "classification": {
       "formDisplayOrder": 1
     },
     "program": {
       "formDisplayOrder": 2
     }
   }
 }
}
}