Construct a Status Algorithm for Summary Activities
Perform the following steps to create a custom algorithm for how deadlines are rolled-up for summary activities.
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 HealthStatusRollupHandler interface allows you to provide a custom calculation algorithm:
HealthStatusRollupHandler.java
rollupHealthStatus(<Summary activity object>, event);
You can extend this interface and override certain APIs in order to utilize your custom algorithm. For example, the following sample code would roll up status from selected children based on their duration:

package com.ptc.projectmanagement.plan.HealthStatusRollupHandler;
public class SummaryRollupBasedonDurationOfChildren implements HealthStatusRollupHandler {
@Override
public void rollUpHealthStatus(Plannable plannable, Object event) throws WTException, WTPropertyVetoException {

if(plannable instanceof AbstractPlanActivity && plannable.isSummary()){
Duration baseDuration = Duration.newDuration();
baseDuration.setDurationFormat(DurationFormat.DAYS);
baseDuration.setMillis(DurationUtils.toMillis(3, DurationFormat.DAYS));
WTCollection children = PlannableHelper.service.getImmediateCriticalChildren(plannable);
WTArrayList eligibleChildren = new WTArrayList();
if(children.size()>0){
Iterator<Plannable> iter = children.persistableIterator();
while (iter.hasNext()) {
Plannable childPlannable = (Plannable) iter.next();
if(childPlannable.getDuration().getMillis()> baseDuration.getMillis()){
eligibleChildren.add(childPlannable);
}
}
HealthStatusType healthStatusType = PlannableUtils.getWorstHealthStatus(eligibleChildren);
plannable = (Plannable) PersistenceHelper.manager.refresh(plannable);
((AbstractPlanActivity)plannable).setHealthStatusType(healthStatusType);
plannable = (Plannable) PersistenceHelper.manager.save((Persistable) plannable);
}
}
}
}
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.HealthStatusRollupHandler">
<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.HealthStatusRollupHandler">
<Option cardinality="singleton" requestor= "null"
selector = "org.rnd.Custom_Engineering_Activity"
serviceClass="com.ptc.projectmanagement.plan.SummaryRollupBasedonDurationOfChildren"/>
</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 rolls up the status from child activities in the critical path:
<Service context="default" name="com.ptc.projectmanagement.plan.HealthStatusRollupHandler">
<Option cardinality="singleton" requestor= "null"
selector = "com.ptc.projectmanagement.plan.PlanActivity"
serviceClass="com.ptc.projectmanagement.plan.PlanHealthStatusRollupHandler"/>
</Service>
도움이 되셨나요?