为单独活动构造状况算法
执行以下步骤可为单独活动 (“叶活动”) 状况计算创建自定义算法。
事前准备:
步骤 1:编写处理程序类
HealthStatusHandler 接口用于提供自定义计算算法:
HealthStatusHandler.java
calculateHealthStatus(<Collection of leaf activity objects>, event);
您可以扩展此接口并覆盖某些 API,以便使用自定义算法。例如,以下示例代码将根据活动完工率来计算状况:
package com.ptc.projectmanagement.plan.HealthStatusHandler;
public class HealthStatusBasedOnPercentWorkComplete implements HealthStatusHandler, Serializable{
@Override
calculateHealthStatus(ArrayList<PlanActivity> leafActivities, Object event){
for(Object activity : leafActivities){
PlanActivity leafActivity = (PlanActivity)activity;
if(leafActivity.getPercentWorkComplete() < 50){
leafActivity.setHealthStatusType(HealthStatusType.RED);
}
else if(leafActivity.getPercentWorkComplete() == 50){
leafActivity.setHealthStatusType(HealthStatusType.YELLOW);
}
else if(leafActivity.getPercentWorkComplete() > 50){
leafActivity.setHealthStatusType(HealthStatusType.GREEN);
}
}
PersistenceHelper.manager.save(leafActivities);
}
}
步骤 2:配置处理程序类
编写状况计算的自定义算法后,必须将其添加到 projectmanagement.service.properties.xconf 中。
2. 导航至以下位置:
${WT_HOME}\Windchill\codebase\com\ptc\projectmanagement\projectmanagement.service.properties.xconf
3. 编辑以下条目,以包含活动子类型的内部名称和处理程序类名称:
<Service context="default" name="com.ptc.projectmanagement.plan.HealthStatusHandler">
<Option cardinality="singleton" requestor= "null"
selector = "<internal type name>"
serviceClass="<fully qualified handler class name>"/>
</Service>
例如,给定上述示例处理程序类和内部名称 "org.rnd.Custom_Engineering_Activity":
<Service context="default" name="com.ptc.projectmanagement.plan.HealthStatusHandler">
<Option cardinality="singleton" requestor= "null"
selector = "org.rnd.Custom_Engineering_Activity"
serviceClass="com.ptc.projectmanagement.plan.HealthStatusBasedOnPercentWorkComplete"/>
</Service>
4. 从 Windchill shell 运行以下命令:
xconfmanager -p
|
PlanActivity 类型定义了以下预置处理程序。此处理程序不起作用:
<Service context="default" name="com.ptc.projectmanagement.plan.HealthStatusHandler"> <Option cardinality="singleton" requestor= "null" selector = "com.ptc.projectmanagement.plan.PlanActivity" serviceClass="com.ptc.projectmanagement.plan. PlanActivityHealthStatusHandler"/> </Service>
|