Construct a Status Algorithm for Individual Activities
Perform the following steps to create a custom algorithm for individual activity (“leaf activity”) status calculation.
Before you begin:
You will need the internal name of the activity subtype created in Set the Status Mode.
Review the registered event listeners: Registered Event Listeners for Deadline and Status Calculation
Review supported APIs: Supported APIs for Activity Calculation
Step 1: Author a Handler Class
The HealthStatusHandler interface allows you to provide a custom calculation algorithm:
HealthStatusHandler.java
calculateHealthStatus(<Collection of leaf activity objects>, event);
You can extend this interface and override certain APIs in order to utilize your custom algorithm. For example, the following sample code would calculate the status based on the percentage of work completed for the activity:

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);

}
}
Step 2: Configure the Handler Class
Once the custom algorithm for status calculation is authored, you must to add it to projectmanagement.service.properties.xconf.
1. Copy the internal name of the activity subtype created in Set the Status Mode.
2. Navigate to the following location:
${WT_HOME}/Windchill/codebase/com/ptc/projectmanagement/projectmanagement.service.properties.xconf
3. Edit the following entry to include the internal name of the activity subtype and your handler class name:
<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>
For example, given the sample handler class above and an internal name of “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. Run the following command from a Windchill shell:
xconfmanager -p
* 
The PlanActivity type has the following an out-of-the-box handler defined. This handler has no effect.
<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>
War dies hilfreich?