Package cu.repsystestbed.exceptions

Examples of cu.repsystestbed.exceptions.WorkflowException


      {
        Object lastItem = sequence.get(sequence.size() - 1);
       
        if(!(lastItem instanceof Algorithm))
        {
          throw new WorkflowException("Last item was not an algorithm.");
        }
       
        if(!((Algorithm) lastItem).assertGraph2OutputType((Graph) item))
        {
          throw new WorkflowException("Postconditions failed: assertGraph2OutputType()");
        }
       
        ((Algorithm) lastItem).setGraph2Output((Graph) item);
        logger.debug("Adding a graph");
        sequence.add(item);
      }

     
    }
    else if(item instanceof Algorithm)
    {     
      if(sequence.size() < 1)
      {
        throw new WorkflowException("Sequence is empty. First add a graph before adding an algorithm.");
      }
     
      Object lastItem = sequence.get(sequence.size() - 1);     
      Util.assertNotNull(lastItem);
     
      if(!(lastItem instanceof Graph))
      {
        throw new WorkflowException("Last item was not a graph.");
      }
     
      Algorithm alg = (Algorithm) item;
     
      if(!alg.assertGraph2ListenType((Graph) lastItem))
      {
        throw new WorkflowException("Failed preconditions: assertGraph2ListenType()");
      }
     
      alg.setGraph2Listen((Graph) lastItem);
     
      ((Graph) lastItem).addObserver(alg);
     
     
      if(item instanceof EvaluationAlgorithm)
      { 
        Util.assertNotNull(((EvaluationAlgorithm) alg).getWrappedAroundAlg());
      }
 
      logger.debug("Adding an algorithm.");
      sequence.add(item);
     
    }
    else
    {
      throw new WorkflowException("Unknown element. Cannot add.");
    }
   
  }
View Full Code Here


    Util.assertNotNull(sequence);
    Util.assertNotNull(sequence.get(0));
   
    if(!(sequence.get(0) instanceof SimpleDirectedGraph))
    {
      throw new WorkflowException("The first element in the sequence is not a graph.");
    }
   
    if(sequence.get(0) instanceof FeedbackHistoryGraph)
    {
      ((FeedbackHistoryGraph) sequence.get(0)).notifyObservers(update1AtATime);
    }
    else if(sequence.get(0) instanceof ReputationGraph)
    {
      ((ReputationGraph) sequence.get(0)).notifyObservers(null);
    }
    else if(sequence.get(0) instanceof TrustGraph)
    {
      ((TrustGraph) sequence.get(0)).notifyObservers(null);
    }
    else
    {
      throw new WorkflowException("The first element in the sequence is an unknown graph,");
    }
  }
View Full Code Here

   * @return
   * @throws WorkflowException
   */
  public static Object assertAndGetInstance(ArrayList sequence, String itemType) throws WorkflowException
  {
    if(sequence == null) throw new WorkflowException(" Workflow sequence cannot be null.");
   
    boolean found = false;
   
    for(Object o : sequence)
    {
      if(o.getClass().getCanonicalName().toLowerCase().contains(itemType.toLowerCase()))
      {
        return o;
      }
    }
   
    if(!found) throw new WorkflowException("An instance of " + itemType
        + " was not found in the workflow sequence.");
   
    //should never come here.
    return null;
   
View Full Code Here

TOP

Related Classes of cu.repsystestbed.exceptions.WorkflowException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.