Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jharks.workflow.conditions;
 
 
 
This RuleCondition peeks into the stack of queues on the SessionHistory object and checks to see the specified queue is on the top of the stack and is currently empty. For example, to check whether the next queue on the stack is of type Problem Class and currently empty you could configure a rule-condition as:
    <rule-condition type="org.jharks.workflow.conditions.
                             EmptyQueueCondition">
      <property name="category" value="Problem Class"/>
    </rule-condition>
 

Author(s):
Michael J. Rizzo
Version:
1.0
public class EmptyQueueCondition extends QueueTypeCondition {

    
The logger for the module.
    protected Log logger = LogFactory.getLog(getClass().getName());
    
    
    public boolean checkCondition(Object param) {
        if (param instanceof SessionHistory) {
            SessionHistory sh = (SessionHistoryparam;
            Stackable element = null;
            
            try {
              element = sh.peek();
            } catch (EmptyStackException ese) {
              .info("No queues left on the stack: EmptyQueueCondition " +
                    "is satisfied: " + ese.getMessage());
              return true;
            }
            
            if (element.getElementType().equalsIgnoreCase(getCategory()) && 
                    element.queueSize() == 0)
                return true;
                
        } else {
            throw new ClassCastException("Expecting SessionHistory Object.");
        }
        return false;
    }
New to GrepCode? Check out our FAQ X