Version Differences for Event Selector

(AHPSCRIPTS-11)
Line 28:
       
  return result;</pre>    return result;</pre> 
       
    + = Notify Only When Status of Workflow Changed =  
    + This script checks the status of the previous build. If the previous status is the same as the current status, it will not notify. If the status has changed (i.e. from Success to Failure or viceversa) then it will notify.  
    + ==== AHPSCRIPTS-19 ====  
    + <pre>/******  
    + * @auther: Steve Boone  
    + */  
       
    + import com.urbancode.anthill3.domain.workflow.*;  
    + import com.urbancode.anthill3.dashboard.*;  
       
    + boolean result = false;  
       
    + if (event instanceof WorkflowEvent &&  
    + event.getCase().isComplete()) {  
    + Long wid = event.getCase().getWorkflow().getId();  
    + BuildLifeWorkflowCaseSummary[] blwcs=DashboardFactory.getInstance().getBuildLifeWorkflowSummariesByWorkflow(wid, null, new Integer(2));  
    +  
    + if(blwcs.length == 2){  
    + if(!blwcs[0].getStatus().equals(blwcs[1].getStatus())){  
    + result=true;  
    + }  
    + }  
       
    + }  
    + return result; </pre>  
       
    + Another alternative method that is more accurate:  
    + <pre>import com.urbancode.anthill3.domain.buildlife.*;  
    + import com.urbancode.anthill3.domain.workflow.*;  
    + import com.urbancode.anthill3.dashboard.*;  
       
    + boolean result = false;  
       
    + if (event instanceof WorkflowEvent && event.getCase().isComplete()) {  
    + buildLifeFact = BuildLifeFactory.getInstance();  
    + buildLife = event.getCase().getBuildLife();  
    + buildStatus = event.getCase().getStatus();  
       
    + priorSuccess = buildLifeFact.restorePriorMostRecentSuccessForProfile(buildLife, buildLife.getProfile());  
    + priorFailure = buildLifeFact.restorePriorMostRecentFailureForProfile(buildLife, buildLife.getProfile());  
    +  
    + if (priorSuccess != null && priorFailure != null) {  
    + boolean previousWasSuccess = priorSuccess.getActualWorkspaceDate().after(priorFailure.getActualWorkspaceDate());  
    +  
    + if (previousWasSuccess != buildStatus.isSuccess()) {  
    + result = true;  
    + }  
    + }  
    + else if (buildStatus.isSuccess() && priorFailure != null) {  
    + result = true;  
    + }  
    + else if (!buildStatus.isSuccess() && priorSuccess != null) {  
    + result = true;  
    + }  
    + else { result = false; }  
    + }  
    +  
    + return result;</pre>