// $Header: /Development/AEDevelopment/projects/org.activebpel.rt.ht/src/org/activebpel/rt/ht/def/validation/rules/AeEscalationDefRule14Validator.java,v 1.2 2008/02/15 17:40:57 EWittmann Exp $
/////////////////////////////////////////////////////////////////////////////
//               PROPRIETARY RIGHTS STATEMENT
// The contents of this file represent confidential information that is the
// proprietary property of Active Endpoints, Inc.  Viewing or use of
// this information is prohibited without the express written consent of
// Active Endpoints, Inc. Removal of this PROPRIETARY RIGHTS STATEMENT
// is strictly forbidden. Copyright (c) 2002-2007 All rights reserved.
/////////////////////////////////////////////////////////////////////////////

package org.activebpel.rt.ht.def.validation.rules;

import org.activebpel.rt.ht.AeMessages;
import org.activebpel.rt.ht.def.AeEscalationDef;

/**
 * An escalation MUST specify exactly one escalation action.
 * 
 * Note: Schema validation should catch duplicate actions such as 2 reassignment elements.
 */
public class AeEscalationDefRule14Validator extends AeAbstractHtValidator
{
   /**
    * @see org.activebpel.rt.ht.def.visitors.AeAbstractHtDefVisitor#visit(org.activebpel.rt.ht.def.AeEscalationDef)
    */
   public void visit(AeEscalationDef aDef)
   {
      executeRule(aDef);
      super.visit(aDef);
   }
   
   /**
    * rule logic
    * 
    * @param aDef
    */
   protected void executeRule(AeEscalationDef aDef)
   {
      int counter = 0;
      
      if (aDef.getReassignment() != null)
      {
         counter++;
      }
      
      if (aDef.getLocalNotification() != null)
      {
         counter++;
      }
      
      if (aDef.getNotification() != null)
      {
         counter++;
      }
      
      if (counter != 1)
      {
         reportProblem(AeMessages.getString("AeEscalationDefRule14Validator.0"), aDef); //$NON-NLS-1$
      }
   }
}
