Examples of WorkflowParserException


Examples of cu.repsystestbed.exceptions.WorkflowParserException

      return alg;
     
    }
    catch(Exception e)
    {
      throw new WorkflowParserException("Could not load algorithm " + classPath, e);
    }
  }
View Full Code Here

Examples of cu.repsystestbed.exceptions.WorkflowParserException

            TrustGraph tg = new TrustGraph(new TrustEdgeFactory());
            m_workflow.addItem(tg);
            storage.put("int_tg_" + r.nextInt(1000), tg);
            break;
          default:
            throw new WorkflowParserException("Unknown input graph type for algorithm" + o);
          }
        }
      }
      m_workflow.addItem(o);
    }
View Full Code Here

Examples of cu.repsystestbed.exceptions.WorkflowParserException

      parse();
     
    }
    catch(Exception e)
    {
      throw new WorkflowParserException("Error reading or parsing the ini file. Cause: ", e);
    }
   
  }
View Full Code Here

Examples of cu.repsystestbed.exceptions.WorkflowParserException

  {
   
    String workflowDefn = (String) m_properties.get(WORKFLOW);
    String[] workflowElements = workflowDefn.split(",");
   
    if(workflowElements.length < 1) throw new WorkflowParserException("Workflow must have at least 1 element");
   
    for(int i=0; i< workflowElements.length; i++)
    {
      //remove the squigly brackets { and }
      if(workflowElements[i].contains("{"))
      {
        String[] temp = workflowElements[i].split("\\{");
        if(temp.length == 2)
        {
          workflowElements[i] = temp[1];
        }
        else
        {
          throw new WorkflowParserException("Could not parse workflow " + workflowDefn
              + ". Error in " + workflowElements[i]);
        }
      }
      else if(workflowElements[i].contains("}"))
      {
        String[] temp = workflowElements[i].split("\\}");
        if(temp.length == 1)
        {
          workflowElements[i] = temp[0].trim();
        }
        else
        {
          throw new WorkflowParserException("Could not parse workflow " + workflowDefn
              + ". Error in " + workflowElements[i]);
        }
      }
     
    }
   
    for(int i=0; i< workflowElements.length; i++)
    {
      if(i==0)
      {
        //first element must be graph
        if(!isGraph(workflowElements[i].trim()))
        {
          throw new WorkflowParserException("The first element in the workflow should be a graph.");
        }
         
        //inputFile is expected for the first element. This is the input to create a graph
        String graphInputFile = m_properties.getProperty(workflowElements[i].trim() + ".inputFile");
        if(graphInputFile == null)
        {
          throw new WorkflowParserException("Expected property in the ini file not found. "
              + m_properties.getProperty(workflowElements[i] + ".inputFile"));
        }
       
        //create and add the input graph to workflow
        if(isGraph(workflowElements[i].trim(), FEEDBACKHISTORYGRAPH))
        {
          DefaultArffFeedbackGenerator feedbackGen = new DefaultArffFeedbackGenerator();
          ArrayList<Feedback> feedbacks = new ArrayList<Feedback>();
         
          try
          {
           
            feedbacks = (ArrayList<Feedback>) feedbackGen.generateHardcoded(graphInputFile);
            FeedbackHistoryGraph feedbackHistoryGraph = (FeedbackHistoryGraph) createGraphInstance(FEEDBACKHISTORYGRAPH);
            Util.assertNotNull(feedbackHistoryGraph);
            feedbackHistoryGraph.addFeedbacks(feedbacks, false);
            m_workflow.addItem(feedbackHistoryGraph);
           
          }
          catch(Exception e)
          {
            throw new WorkflowParserException("Error creating a feedback history graph from "
                  + graphInputFile + " or error adding to workflow. Cause: ", e);
          }
   
        }
        else if(isGraph(workflowElements[i].trim(), REPUTATIONGRAPH))
        {
          try
          {
            ReputationGraph repGraph = ReputationGraphCreator.createGraph(graphInputFile);
            Util.assertNotNull(repGraph);
            m_workflow.addItem(repGraph);
           
           
          }catch(Exception e)
          {
            throw new WorkflowParserException("Error creating a reputation graph from "
                + graphInputFile + " or error adding to workflow. Cause: ", e);       
          }
        }else if(isGraph(workflowElements[i].trim(), TRUSTGRAPH))
        {
          try
          {
            TrustGraph trustGraph = TrustGraphCreator.createGraph(graphInputFile);
            Util.assertNotNull(trustGraph);
            m_workflow.addItem(trustGraph);
           
           
          }
          catch(Exception e)
          {
            throw new WorkflowParserException("Error creating a trust graph from "
                + graphInputFile + " or error adding to workflow. Cause: ", e);   
          }
        }
      }else
      {
     
        //add the other elements to the workflow. They can be graphs or algorithms.
       
        if(isGraph(workflowElements[i].trim()))
        {
          try
          {
            Graph graph = createGraphInstance(workflowElements[i].trim());
            Util.assertNotNull(graph);
            m_workflow.addItem(graph);
           
          }
          catch(Exception e)
          {
            throw new WorkflowParserException("Error creating a graph "
                + workflowElements[i].trim() + " or error adding to workflow. Cause: ", e)
          }
        }
        else
        {
          //it is an algorithm
          try
          {
            String algName = workflowElements[i];
           
            logger.debug("Loading algorithm " + algName.trim());
            String classPath = m_properties.getProperty(algName.trim() + ".classpath");
           
            try
            {
              Util.assertNotNull(classPath);
            }
            catch(Exception e)
            {
              throw new WorkflowParserException(algName.trim() + ".classpath setting not found.", e);
            }
           
            logger.debug("Algorithm class: " + classPath);
            Algorithm alg = createAlgorithmInstance(classPath);
            Util.assertNotNull(alg);
           
            String propLocation = m_properties.getProperty(algName.trim() + ".properties");
            if(propLocation != null)
            {
             
              Properties algProperties = new Properties();
              try
              {
                algProperties.load(new FileInputStream(propLocation));
                alg.setConfig(algProperties);
              }
              catch(Exception e)
              {
                logger.error("Cannot set algorithm properties.", e);
              }
             
            }
           
           
            /*
             * If it is a evaluation algorithm, then get .classpath and .evaluate settings.
             * Instantiate the inner algorithm and wrap it with the eval alg.
             */
            if(alg instanceof EvaluationAlgorithm)
            {
              String innerAlgName = m_properties.getProperty(algName.trim() + ".evaluate");
             
              try
              {
                Util.assertNotNull(innerAlgName);
              }
              catch(Exception e)
              {
                throw new WorkflowParserException(algName.trim() + ".evalute setting not found. An evaluation " +
                    "algorithm must wrap a reputation system testbed algorithm.", e);
              }
             
              logger.debug("Inner algorithm name: " + innerAlgName);
             
              String innerAlgClasspath = m_properties.getProperty(innerAlgName.trim() + ".classpath");
             
              try
              {
                Util.assertNotNull(innerAlgClasspath);
              }
              catch(Exception e)
              {
                throw new WorkflowParserException(".classpath setting not found for an algorithm. ", e);
              }
             
              logger.debug("Inner algorithm classpath: " + innerAlgClasspath);
              Algorithm innerAlg = createAlgorithmInstance(innerAlgClasspath);
              Util.assertNotNull(innerAlg);
             
              ((EvaluationAlgorithm) alg).wrap(innerAlg);
             
            }
           
            m_workflow.addItem(alg);
           
          }
          catch(Exception e)
          {
            throw new WorkflowParserException("Error creating a algorithm "
                + workflowElements[i].trim() + " or error adding to workflow. Cause: ", e);           
          }
        }
      }
     
View Full Code Here

Examples of cu.repsystestbed.exceptions.WorkflowParserException

  private Graph createGraphInstance(String graphType) throws WorkflowParserException
  {
   
    if(!isGraph(graphType))
    {
      throw new WorkflowParserException("The first element in the workflow must be either " +
          "a feedbackhistorygraph, reputationgraph or a trustgraph");
    }
     
    Graph graph;
    if(graphType.equalsIgnoreCase(FEEDBACKHISTORYGRAPH))
    {
      return new FeedbackHistoryGraph(new FeedbackHistoryEdgeFactory());
     
    }
    else if(graphType.equalsIgnoreCase(REPUTATIONGRAPH))
    {
      return new ReputationGraph(new ReputationEdgeFactory());
     
    }
    else if(graphType.equalsIgnoreCase(TRUSTGRAPH))
    {
      return new TrustGraph(new TrustEdgeFactory());
    }
    else
    {
      throw new WorkflowParserException("Unknown graph type.");
    }

  }
View Full Code Here

Examples of cu.repsystestbed.exceptions.WorkflowParserException

      return alg;
     
    }
    catch(Exception e)
    {
      throw new WorkflowParserException("Could not load algorithm " + classPath, e);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.