Developing Custom Actions 开发客户操作
This section describes how to develop custom actions in Java classes.The Agile PLM clients can make direct method calls into these classes to perform the actions.
这节描述在Java类里如何开发用户操作。Agile PLM 客户端可以直接调用类实现这些操作。
You can initiate a custom action from the following areas of Agile PLM clients:
你可以启动一个客户操作在AgilePLM客户端的以下区域:
Action menu 操作菜单
Tools menu 工具菜单
External reports 外部报表
Workflow Status 工作流状态
Defining a Custom Action 定义一个客户操作
To define a custom action, create a Java class that implements the ICustomAction interface , a server-side API in the com.agile.px package.
The code should define the action to perform .The Agile PLM server initiates the action by calling the doAction() method,which must be provide in your class.
要定义一个客户操作,创建一个实现了ICustomAction 接口的Java类,一个包含在com.agile.px 包里的服务器端API.
代码里必须定义了这个操作的实现。Agile PLM服务器初始化这个操作通过调用doAction()这个函数,这个函数必须在你的类中提供。
The following example shows the code for a HelloWorld class. When the doAction() method is called, the method returns "Hello World." If you invoke the HelloWorld custom action from Actions menu, the string "Hello World“ will be logged to the object's History table. If you invoke the HelloWorld custom action from a workflow,the string ”HelloWorld" will be logged to the change order's History table when it enters the appropriate workflow status.
下面的例子展示了一个HelloWorld的代码。当doAction()函数被调用时,这个方法返回"HelloWorld",当你在操作菜单中调用HelloWorld客户操作时,这个"Hello World"字符串将记录在对象的历史表中,如果你在工作流中调用HelloWorld客户操作,这个"HelloWorld"字符串将记录在更改单的历史表中。
Example : Defining a HelloWorld class for a custom action
实例: 定义一个客户操作在HelloWorld 类
package actions;
import com.agile.px.*;
import com.agile.api.*;
public class HelloWorld implements ICustomAction
{
public ActionResult doAction(IAgileSession session,INode actionNode,IDataObject affectedObject)
{
return new ActionResult(ActionResult.STRING,"Hello World");
}
}
The above HelloWorld class does not perform a useful action, it simply demonstrates how to implement the class for a custom action.
上面的HelloWorld类并不是实用的用户操作,只是演示了如何使用类来实现一个用户操作。
Packaging and Deploying a Custom Action
After you develop classes for a custom action, follow these instructions to properly package and deploy them.
当你为客户操作开发了一个类之后,按照下列步骤打包并发布他们。
To package and deploy a custom action: 打包和部署一个用户操作
1.Use your Java development enviroment or the Java Archive tool(or JAR tool) to create one or more JAR files for the custom action.Make sure the JAR file(s) includes a METAINF/services directory that contains a file named com.agile.px.ICustomAction,which is a text file the fully qualified Java class names,one class per line,for the cstom action.
使用Java开发环境或者Java打包工具为一个客户操作创建一个或多个JAR文件。确认这个打包文件包含一个在METAINF/services 目录下一个名为com.agile.px.ICustomAction 的文件,完全符合Java类名 一个类一行,为这个客户操作。
Multiple custom action can be included in one package.For example ,the com.agile.px.ICustomAction file could look like this:
多个客户操作可以包含在一个包里,举例,这个com.agile.px.ICustomAction 文件可能如下所示:
actions.HelloWorld
actions.RFQConsolidation
acions.RefreshCustomerFromCRM
actions.StartMfg
actions.ObsoletPartReplacer
actions.WorkflowConflictResolver
2.Place the JAR file(s) in the agile_home/integration/sdk/extensions folder on the same computer where the Agile Application Server is installed.
把这个JAR文件放在与安装AgileApplicationServer同一台机器的Agile_home/Intergration/sdk/extension 目录里。
Configuring Custom Action in Agile Java Client 在Agile Java 客户端配置用户操作
In Agile Java Client,you can define custom action in the Admin module.To configure Agile PLM system settings,you must log in as a user with adinistrator privlieges.
在Agile Java 客户端,你可以在Admin 模块中定义一个用户操作。要配置系统设定,你必须以系统管理员权限登录。
Using the Process Extension Library
The Process Extension Library is where you define the custom actions that can be used in Agile PLM client.When you add a custom action to the Process Extension Library, you specify how to initiate that action from the client.
进程扩展库是你定义的能在Agile PLM 客户端使用的用户操作的地方。当你添加了一个用户操作在进程扩展库,你要定义这个用户操作在客户端的哪里开始启动。
1.Log In to Agile Java Client as an administrator
2.Click the Admin tab
3.Open the Data Settings folder
4.Open the Process Extension node
5.In the Process Extension Library window,click the Add Process Extension button to open the Add Process Extension dialog box
6.Type the folowing information 输入如下信息
Name -Type the name of the process extension. 名称-输入进程扩展的名字
API Name- This field is automatically filled in after completing the Name field. 应用程序接口名-这个字段当完成名称字段后自动填充
Description-Type a brief description of the process extension. 描述-输入一个关于这个进程扩展的概述。
Type-Select Internal Custom Action. This activeates the Internal Custom Action fileld.
类型-选择内部用户操作。
Initiate From -Select one or more location from which the process extension can be initiate. Choose from the following options:
启动位置-选择一个或多个进程扩展可以启动的位置,从以下选项中选择:
Action menu -Allows you to selet the custom action from the Action menu of a properly configured class.
操作菜单-允许你选择用户操作从操作菜单。
External report-Allows you to generate a report by accessing an external resource or URL.If the process extension is an internal custom action, the External Report option is unavailable.
外部报表-允许你通过访问外部资源或这网址来产生一个报表,如果进程扩展是一个内部客户操作,这个外部报表是不可用的。
Tools menu -Allow you to select the custom action from the Tools menu .
工具菜单-允许你从工具菜单中选择一个用户操作。
Workflow status-Invoke the custom action whenever a properly configured wokrflow enters a particular status.
工作流状态-当符合设置的工作流状态时调用用户操作。
If you specify that a process extension is initiate from the Actions menu or a workflow status,you can configure subclass or wokrflows to use it. If you specify that a process extension is used to generate an external report,you can use Agile Web Client to create the report. If you specify that a process extension is initiated from the Tool menu ,it's available all times in the Agile PLM client.
当你定义一个进程扩展从动作菜单或者工作流状态开始启动时,可以用一个子类或者一个工作流来使用它;
当你定义一个进程扩展用来产生外部报表,你可以使用Agile Web客户端来创建报表。
当你定义一个进程扩展用来从工具菜单启动,那么他可以在Agile PLM客户端所有时间可用。
Roles-Select one or more roles to use for the cutom action . To use the roles and privilege of the current user,leave this field blank.To temporaily overide roles and privileges of the current user,select one or more roles . Once the custom action is completed ,the client reverts to the current users's roles and privileges.
角色-选个一个或多个使用用户操作的角色。这个字段不选默认使用当前用户的角色和权限。选择一个或多个角色可以覆盖当前的角色和权限。一旦用户操作结束,客户端会恢复到当前用户的角色和权限。
Enabled-Select Yes or No. 现在可用 -选择是或否。