Package q_impress.pmi.lib.translators

Examples of q_impress.pmi.lib.translators.TranslationException


     
      // generate user classes
      generateUserClasses();
      routeUserClasses();
    } catch (ParserConfigurationException e) {
      throw new TranslationException(this, "Unable to generate XML for queue network.", e);
    }
   
    // serialize the document
    try {
      DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
      DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
      LSSerializer writer = impl.createLSSerializer();
      LSOutput output = impl.createLSOutput();
     
      output.setByteStream(outStream);
      writer.write(network.getXmlDoc(), output);
    } catch (ClassCastException e) {
      throw new TranslationException(this, "Unable to generate XML for queue network.", e);
    } catch (ClassNotFoundException e) {
      throw new TranslationException(this, "Unable to generate XML for queue network.", e);
    } catch (InstantiationException e) {
      throw new TranslationException(this, "Unable to generate XML for queue network.", e);
    } catch (IllegalAccessException e) {
      throw new TranslationException(this, "Unable to generate XML for queue network.", e);
    }
  }
View Full Code Here


    ActionDecorator nodeDec;
    PaStepStub paStepStub;
    try {
      nodeDec = (ActionDecorator) translator.getDecoratorsFactory().getDecorator(node);
      paStepStub = nodeDec.getPaStepStub();
      if (paStepStub == null) throw new TranslationException(this, "Unable to generate property for node \"" + node.getQualifiedName() + "\" : no PaStep stereotype associated.");
    } catch (InvalidContextException e) {
      throw new TranslationException(this, "Unable to generate property for node \"" + node.getQualifiedName() + "\"", e);
    } catch (ClassNotFoundException e) {
      throw new TranslationException(this, "Unable to generate property for node \"" + node.getQualifiedName() + "\"", e);
    }
   
   
    String comment = "Reliability value computed from " + nodeName;
    String rule = chosenProp;
View Full Code Here

        Model model = (Model)obj;
        try {
          modelDec = (ModelDecorator) decFactory.getDecorator(model);
          break;
        } catch (ClassNotFoundException e) {
          throw new TranslationException(this, "Initialization failed", e);
        } catch (InvalidContextException e) {
          throw new TranslationException(this, "Initialization failed", e);
        }
      }
    }
   
    if (modelDec == null) throw new TranslationException(this, "no UML model found.");
   
    // find the activity and create the decorator
    for (Activity act : modelDec.getAllActivities()) {
      if (act.getQualifiedName().equals(activityQualifiedName)) { // found
        try {
          activity = act;
          activityDec = (ActivityDecorator) decFactory.getDecorator(activity);
        } catch (InvalidContextException e) {
          throw new TranslationException(this, "Initialization failed", e);
        } catch (ClassNotFoundException e) {
          throw new TranslationException(this, "Initialization failed", e);
        }
      }
    }
  }
View Full Code Here

  ModuleTranslator findModuleTranslator(ActivityNode node) throws TranslationException {
    for(ModuleTranslator translator : moduleTranslators) {
      if (translator.getTranslatedNodes().contains(node)) return translator;
    }
   
    throw new TranslationException(this, "Unable to find module translator for node \"" + node.getQualifiedName() + "\"");
  }
View Full Code Here

   * @see ITranslator
   */
  @Override
  public void translate() throws TranslationException {
    // for now only one start node is admitted
    if (startNodes.size() == 0) throw new TranslationException(this, "No initial node defined for activity");
    if (startNodes.size() > 1) throw new TranslationException(this, "Multiple initial nodes are not supported");
   
    ActivityNode node = startNodes.iterator().next();
   
    if (parentTranslator != null) { // we need to create the start transition
      openGuard();
View Full Code Here

      headerWriter.write("module " + moduleName);
     
      // write module main variable
      headerWriter.write("\n\n" + stateVarName + " : [0.." + Integer.toString((nodesCounter - 1)) + "] init 2;");
    } catch (IOException e) {
      throw new TranslationException(this, "Unable to generate header for PRISM module", e);
    }
  }
View Full Code Here

   * Checks if a node has only a single outgoing transition.
   * @param node the node to check.
   * @throws TranslationException if the node has multiple outgoing transitions.
   */
  private void checkSingleOutgoingTransition(ActivityNode node) throws TranslationException {
    if (node.getOutgoings().size() == 0) throw new TranslationException(this, "Action \"" + node.getQualifiedName() + "\" has no outgoing edge.");
    else if (node.getOutgoings().size() > 1) new TranslationException(this, "Action \"" + node.getQualifiedName() + "\" has multiple outgoing edges.");
  }
View Full Code Here

    ActivityNode target = edge.getTarget();
    ActionDecorator actionDec = null;
    try {
      actionDec = (ActionDecorator) translator.getDecoratorsFactory().getDecorator(node);
    } catch (InvalidContextException e) {
      throw new TranslationException(this, "Unable to visit node \"" + node.getQualifiedName() + "\"", e);
    } catch (ClassNotFoundException e) {
      throw new TranslationException(this, "Unable to visit node \"" + node.getQualifiedName() + "\"", e);
    }
   
    double outProb = 1d;
    double negProb = 0d;
   
    PaStepStub stub = actionDec.getPaStepStub();
    if (stub == null) {
      throw new TranslationException(this, "Unable to visit node \"" + node.getQualifiedName() + "\" : no PaStep stereotype associated.");
    }
   
    outProb = stub.getProb();
    negProb = 1d - outProb;
   
View Full Code Here

      try {
        ActivityEdgeDecorator edgeDec = (ActivityEdgeDecorator) translator.getDecoratorsFactory().getDecorator(edge);
        normalizationFactor += edgeDec.getProbability();
        probabilities.put(edge, edgeDec.getProbability());
      } catch (InvalidContextException e) {
        throw new TranslationException(this, "Unable to visit node \"" + node.getQualifiedName() + "\"", e);
      } catch (ClassNotFoundException e) {
        throw new TranslationException(this, "Unable to visit node \"" + node.getQualifiedName() + "\"", e);
      }
    }
   
    // normalize probabilities
    for (ActivityEdge edge : probabilities.keySet()) {
View Full Code Here

   */
  private void openGuard(String action) throws TranslationException{
    try {
      bodyWriter.write("[" + action + "]");
    } catch (IOException e) {
      throw new TranslationException(this, "Unable to open guard condition", e);
    }
  }
View Full Code Here

TOP

Related Classes of q_impress.pmi.lib.translators.TranslationException

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.