Personalizzazione avanzata > Business Logic Customization > Windchill ProjectLink Customization > Configuring Automatic Deadline Calculation > Construct a Deadline Algorithm for Summary Activities
  
Construct a Deadline 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 Deadline Mode.
Review the registered event listeners: Registered Event Listeners for Deadline and Status Calculation
Review supported APIs: Supported APIs for Activity Calculation
Review custom handler guidelines: Custom Handler Guidelines for Status and Deadline Calculation
Step 1: Author a Handler Class
The EPPSummaryDeadlineHandler interface allows you to provide a custom calculation algorithm:
EPPSummaryDeadlineHandler.java
calculateDeadlineForSummaryActivities(ArrayList<PlanActivity> summaryActivities, 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 the summary activity deadline based on the latest deadline of its child activities:
package com.ptc.projectmanagement.plan.EPPSummaryDeadlineHandler;
public class CustomDeadlineRollUpImplementation implements EPPSummaryDeadlineHandler {
@Override
public void calculateDeadlineForSummaryActivities(ArrayList<PlanActivity> activitiesCollection, Object event)
throws WTException, WTPropertyVetoException {
try{
WTCollection summaryActivities = new WTArrayList(activitiesCollection);
summaryActivities = CollectionsHelper.manager.refresh(summaryActivities);

for (Object activity: summaryActivities){
Timestamp max = null;

if(activity instanceof PlanActivity){
PlanActivity planActivity = (PlanActivity)activity;

if (planActivity.isSummary()) {
WTCollection childCollection = PlannableHelper.service.getAllChildren(planActivity);
Iterator<PlanActivity> itr = childCollection.persistableIterator();

while (itr.hasNext()) {
PlanActivity act = itr.next();

if(max == null && act.getDeadline() != null)
max = act.getDeadline();

else if (max != null && act.getDeadline() != null
&& max.before(act.getDeadline()))
max = act.getDeadline();
}
}
planActivity.setDeadline(max);
activities.add(planActivity);
}
}
PersistenceHelper.manager.save(activities);

} catch(Exception ae){
ae.printStackTrace();
}

}
}
Step 2: Configure the Handler Class
Once the custom algorithm for deadline roll-up 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 Deadline 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.EPPSummaryDeadlineHandler">
<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.EPPSummaryDeadlineHandler">
<Option cardinality="singleton" requestor= "null"
selector = "org.rnd.Custom_Engineering_Activity"
serviceClass="com.ptc.projectmanagement.plan.CustomDeadlineRollUpImplementation"/>
</Service>
4. Run the following command from a Windchill shell:
xconfmanager -p
* 
The PlanActivity type has following an out-of-the-box handler defined. This handler rolls up the deadline of child activities that are in the critical path:
<Service context="default" name="com.ptc.projectmanagement.plan.EPPSummaryDeadlineHandler">
<Option cardinality="singleton" requestor= "null"
selector = "com.ptc.projectmanagement.plan.PlanActivity"
serviceClass="com.ptc.projectmanagement.plan.PlanSummaryActivityDeadlineHandler"/>
</Service>