3.1.3.3 User Objects 用户对象
[翻译]
用户对象是赋予 mxGraph 图表上下文的内容,它存储与视觉单元相关的业务逻辑。在 HelloWorld 示例中,用户对象只是一个字符串,在这种情况下,它仅表示将为该单元显示的标签。在更复杂的应用程序中,这些用户对象将是对象。通常,对象的某个属性将是视觉单元显示的标签,其余部分描述与应用领域相关的逻辑。
[原文]
The User object is what gives mxGraph diagrams a context, it stores the business logic associated with a visual cell. In the HelloWorld example the user object has just been a string, in this case it simply represents the label that will be displayed for that cell. In more complex applications, these user objects will be objects instead. Some attribute of that object will generally be the label that the visual cell will display, the rest of the object describes logic relating to the application domain.
- context /'kntekst/ 上下文
- business /'bzns/ 业务
- logic /'ldk/ 逻辑
- attribute /'aetrbjut/ 属性
- domain /do'men/ 领域
[翻译]
以简单的工作流或流程应用程序为例,假设我们有以下图(此示例在线可用,从任务窗口选择 Swimlanes 示例):
[原文]
Using the example of a simple workflow or process application, say we have the graph below (this example is available online, select the Swimlanes example from the tasks window):
- workflow /'wrkflo/ 工作流
- process /'prɑses/ 流程
- available /'velbl/ 可用的
- swimlanes /'swmlenz/ 泳道
- tasks /taesks/ 任务
一个简单的工作流 /A simple workflow
- simple /'smpl/ 简单的
- workflow /'wrkflo/ 工作流
[翻译]
通常,此工作流将存在于某个应用服务器和/或数据库上。浏览器用户连接到该服务器,或某个与应用服务器链接的前端服务器,用户的 Web 应用程序请求“订单”工作流。服务器获取该工作流的数据并传输到客户端。
[原文]
Typically, this workflow will exist on some application server and/or database. The browser user connects to that server, or some front-end server linked to the application server and the user's web application requests the “order” workflow. The server obtains the data of that workflow and transmits it to the client.
- typically /'tpkli/ 通常
- application /aepl'ken/ 应用
- server /'srvr/ 服务器
- transmits /traens'mts/ 传输
- client /'klant/ 客户端
[翻译]
mxGraph 支持在服务器端填充模型并传输到客户端,以及反向传输的过程。请参见后续关于“I/O 和服务器通信”的章节。
[原文]
mxGraph supports the process of populating the model on the server-side and transmitting to the client, and back again. See the later chapter on “I/O and Server Communication”.
- supports /s'prts/ 支持
- populating /'ppjulet/ 填充
- server-side /'srvr sad/ 服务器端
- transmitting /traens'mt/ 传输
- communication /kmjun'ken/ 通信
[翻译]
传输的数据将是视觉模型(图表)以及业务逻辑(主要包含在用户对象中)。客户端最初将显示上述图表。如果用户有权限编辑此工作流,他们通常可以做两件事:1) 编辑图表,添加和移除顶点,以及更改连接;2) 编辑单元(顶点和/或边)的用户对象。
[原文]
The data transmitted will be both the visual model (the diagram) as well as the business logic (mostly contained in the user objects). The client will initially show the diagram above. If the user has permission to edit this workflow they will normally be able to do two things, 1) edit the diagram, add and remove vertices, as well as changing the connections, and 2) edit the user objects of the cells (vertices and/or edges).
- transmitted /traens'mtd/ 传输
- visual /'vul/ 视觉的
- permission /pr'mn/ 权限
- edit /'edt/ 编辑
- vertices /'vrtsiz/ 顶点
[翻译]
在在线演示中,如果您右键单击并选择“检查库存”菱形的属性,您将看到以下对话框:
[原文]
In the online demo, if you right click and select properties of the “Check Inventory” diamond you will see this dialog:
- demo /'demo/ 演示
- right /rat/ 右键
- properties /'prprtiz/ 属性
- diamond /'damnd/ 菱形
- dialog /'dalɡ/ 对话框
顶点的属性/The properties of a vertex
- properties /'prprtiz/ 属性
- vertex /'vrtks/ 顶点
[翻译]
这些属性显示几何、标签、ID 等,但对话框也可以轻松显示单元的用户对象。可能会有一些对工作流引擎上如何实际检查库存的引用。这可能是服务器和客户端分配远程方法调用标识的特定于应用程序的机制。另一个值可能是该过程返回的对象类型,在这种情况下可能是布尔值或整数,表示库存水平。鉴于返回类型,可以在图表中强制执行约束,并提供视觉警报,例如,如果输出边的决策检查与顶点的返回类型不对应。
[原文]
These properties show the geometry, label, ID etc, but a dialog could just as easily show the user object of the cell. There might be a reference to some process on the workflow engine as to how the inventory is actually checked. This might be an application specific mechanism for both the server and client to assign some identification to remote method calls. Another value might be the type of object that process returned, maybe a boolean or an integer to indicate stock level in this case. Given that return type, it is possible to enforce constraints with the diagram and provide visual alerts of if, say, the outgoing edges decision check does not correspond to the return type of the vertex.
- geometry /di'mtri/ 几何
- reference /'refrns/ 引用
- inventory /'nvntri/ 库存
- constraints /kn'strents/ 约束
- alerts /'lrts/ 警报
[翻译]
接下来,作为示例,输出边的用户对象可能包含标签和布尔状态。同样,基于 mxGraph 的编辑器可能提供更改布尔值的方法。在服务器上,执行过程时,可能会跟随与决策节点返回的布尔值相对应的边。
[原文]
Next, as an example, the user objects of the outgoing edges might contain a label and a boolean state. Again, the mxGraph-based editor might provide the means to alter the boolean value. On the server, when executing the process, it might follow the edges that correspond to the boolean value returned by the decision node.
- outgoing /'atɡo/ 输出的
- boolean /'bulin/ 布尔
- alter /'ltr/ 更改
- executing /'ekskjut/ 执行
- correspond /kr'spnd/ 对应
[翻译]
请记住,上述示例非常特定于领域,用于解释用户对象如何映射到应用程序的业务逻辑。它可视化了 mxGraph 如何创建我们称为上下文图的内容。上下文由顶点之间的连接和存储在用户对象中的业务逻辑形成。典型应用程序从服务器接收视觉和业务逻辑,可能允许编辑两者,然后将两者传输回服务器进行持久化或执行。
[原文]
Keep in mind that the above example is very domain specific, it is there to explain how the user object maps to the business logic of the application. It visualizes how mxGraph creates what we term a contextual graph. The context is formed by the connections between vertices and the business logic stored within the user objects. A typical application receives the visual and business logic from a sever, may allow editing of both, then transmits both back to the server for persistence and/or execution.
- domain /do'men/ 领域
- contextual /kn'tekstul/ 上下文的
- connections /k'neknz/ 连接
- persistence /pr'sstns/ 持久化
- execution /eks'kjun/ 执行