
# 上下文模型
#### 2.7.1上下文模型中只能有一个System
**详细描述**
在上下文模型中只能存在一个类型为System的元素；其它的三方交互的对象用ExternalSystem或者Actor元素表示。
**检查范围**
当前模型工程中的所有符合定义规则的System元素，工程设置 \> 构造型下，绑定到4+1视图 : 上下文模型的System元素。
1. 在上下文模型图上创建出来的System元素；
2. 引用到上下文模型中的System元素（包含关联空间中的引用的system元素）；
**如何检查**
查询上下文模型图中的所有元素，从中找出类型为System的元素，如果存在多个System元素，则全部列出到检查结果中，不符合规则。
**正确示例**
![](https://support.huaweicloud.com/usermanual-codeartsmodeling/zh-cn_image_0000001944385488.png "点击放大")
**错误示例**
错误示例场景1：关联空间引用system元素到上下文。
![](https://support.huaweicloud.com/usermanual-codeartsmodeling/zh-cn_image_0000001944544796.png "点击放大")
架构规则检查结果：
![](https://support.huaweicloud.com/usermanual-codeartsmodeling/zh-cn_image_0000001971663933.png "点击放大")
#### 2.7.2ExternalSystem和Actor只能存在下面两种关系中的一种：ExternalSystem和Actor使用或依赖System提供的接口；ExternalSystem和Actor提供了接口给System使用或依赖
**详细描述**
ExternalSystem和Actor元素与System之间只能通过接口交互，不能直接使用连线关系表达交互，只能由ExternalSystem和Actor实现（Realization连线）接口，并由System使用（usage连线）该接口；或者由System实现（Realization连线）接口，由ExternalSystem和Actor使用（usage连线）该接口；其中使用关系可以由依赖Dependency连线关系代替。
**检查范围**
当前模型工程中的所有符合定义规则的System、ExternalSystem和Actor元素，工程设置 \> 构造型下，绑定到4+1视图 : 上下文模型的System、ExternalSystem和Actor元素。
1. 在上下文模型图上创建出来的System、ExternalSystem和Actor元素；
2. 引用到上下文模型中的System、ExternalSystem和Actor元素（包含关联空间中的引用的System、ExternalSystem和Actor元素）；
**如何检查**
检查上下文模型中的ExternalSystem和Actor元素与System之间是否通过接口相关联，与接口之间存在使用，实现或者依赖关系连线，如果存在其它类型的连线也不符合规则，会列出不符合规则的ExternalSystem和Actor元素在检查结果列表中。
**正确示例**
![](https://support.huaweicloud.com/usermanual-codeartsmodeling/zh-cn_image_0000001944544800.png "点击放大")
**错误示例**
错误示例场景1：没有通过接口交互，Actor与system直接用连线表示交互关系。
![](https://support.huaweicloud.com/usermanual-codeartsmodeling/zh-cn_image_0000001944385484.png "点击放大")
