Ejemplo n.º 1
1
 /*
  * public HashMap getLeafElements() { HashMap map = new HashMap(); Object[]
  * elts = dataElements.values().toArray(); for (int j=0; j<elts.length; j++)
  * { PDMDataElement data = (PDMDataElement) elts[j];
  * map.put(data.getID(),data); } Object[] ops =
  * operations.values().toArray(); for (int i=0; i<ops.length; i++){
  * PDMOperation op = (PDMOperation) ops[i]; if
  * (!(op.getInputElements().isEmpty())){ HashMap outs =
  * op.getOutputElements(); Object[] outArray = outs.values().toArray(); for
  * (int j=0; j<outArray.length; j++) { PDMDataElement d = (PDMDataElement)
  * outArray[j]; map.remove(d.getID()); } } } return map; }
  */
 public HashMap getLeafElements() {
   HashMap result = new HashMap();
   HashSet leafOps = getLeafOperations();
   if (!(leafOps.isEmpty())) {
     Iterator it = leafOps.iterator();
     while (it.hasNext()) {
       PDMOperation op = (PDMOperation) it.next();
       PDMDataElement data = op.getOutputElement();
       result.put(data.getID(), data);
     }
   } else {
     Object[] elts = dataElements.values().toArray();
     for (int j = 0; j < elts.length; j++) {
       PDMDataElement data = (PDMDataElement) elts[j];
       result.put(data.getID(), data);
     }
     Object[] ops = operations.values().toArray();
     for (int i = 0; i < ops.length; i++) {
       PDMOperation op = (PDMOperation) ops[i];
       HashMap outs = op.getOutputElements();
       Object[] outArray = outs.values().toArray();
       for (int j = 0; j < outArray.length; j++) {
         PDMDataElement d = (PDMDataElement) outArray[j];
         result.remove(d.getID());
       }
     }
   }
   return result;
 }
Ejemplo n.º 2
0
  /**
   * Writes the model to DOT.
   *
   * @param bw The writer
   * @throws IOException If writing fails
   */
  public void writeToDot(Writer bw) throws IOException {
    // super.writeToDot(bw);

    // Preamble of dot file
    bw.write(
        "digraph G {ranksep=\".3\"; fontsize=\"8\"; remincross=true; margin=\"0.0,0.0\"; rankdir=TB; ");
    bw.write("fontname=\"Arial\"; \n");
    bw.write("edge [arrowsize=\"0.5\"];\n");
    bw.write("node [fontname=\"Arial\",fontsize=\"8\"];\n");

    // Add the Data Element nodes
    Iterator it = getVerticeList().iterator();
    while (it.hasNext()) {
      Object object = it.next();
      if (object instanceof PDMDataElement) {
        ((PDMDataElement) object).writeToDot(bw, this);
      }
    }

    // Add all edges
    it = operations.values().iterator();
    while (it.hasNext()) {
      Object object = it.next();
      if (object instanceof PDMOperation) {
        ((PDMOperation) object).writeToDot(bw, this);
      }
    }

    bw.write("\n}\n");
  }
Ejemplo n.º 3
0
  public PDMState checkIfStateExists(
      PDMStateSpace statespace, HashSet data, HashSet exec, HashSet failed) {
    PDMState result = null;
    boolean bool = false;
    HashSet states = statespace.getStates();
    Iterator it = states.iterator();
    while (it.hasNext() && !bool) {
      PDMState state2 = (PDMState) it.next();
      boolean one = false;
      boolean two = false;
      boolean three = false;
      HashSet data2 = state2.dataElements;
      HashSet exec2 = state2.executedOperations;
      HashSet failed2 = state2.failedOperations;
      one = hashSetContainsSameDataElements(data, data2);
      two = hashSetContainsSameOperations(exec, exec2);
      three = hashSetContainsSameOperations(failed, failed2);

      if (one && two && three) {
        bool = true;
        result = state2;
      }
    }
    return result;
  }
Ejemplo n.º 4
0
 public void display(Graphics2D g, AffineTransform a_trans) {
   Iterator i = createIterator();
   while (i.hasNext()) {
     GlyphObject object = (GlyphObject) i.next();
     object.display(g, a_trans);
   } // while
 }
  public static void exportThis(
      String target_sea_state_set,
      String target_sea_state_datum,
      String[] sea_state_headings,
      IntegerTargetTypeLookup states,
      Element envElement,
      Document doc) {
    // ok, put us into the element
    org.w3c.dom.Element itt = doc.createElement(target_sea_state_set);

    // get on with the name attribute
    Double unknown = states.getUnknownResult();
    if (unknown != null) itt.setAttribute(UNKNOWN_TYPE, writeThis(unknown.doubleValue()));

    // now the matrix of sea states
    Collection<String> keys = states.getNames();
    for (Iterator<String> iter = keys.iterator(); iter.hasNext(); ) {
      String thisN = (String) iter.next();

      // ok, cycle through the sea states for this participant
      NamedList thisList = states.getThisSeries(thisN);
      exportThisSeries(thisN, target_sea_state_datum, thisList, sea_state_headings, itt, doc);
    }

    envElement.appendChild(itt);
  }
Ejemplo n.º 6
0
  /**
   * Returns a String representation of the <code>&lt;saml:Attribute&gt;</code> element.
   *
   * @param includeNS Determines whether or not the namespace qualifier is prepended to the Element
   *     when converted
   * @param declareNS Determines whether or not the namespace is declared within the Element.
   * @return A string containing the valid XML for this element
   */
  public String toString(boolean includeNS, boolean declareNS) {
    StringBuffer result = new StringBuffer(1000);
    String prefix = "";
    String uri = "";
    if (includeNS) {
      prefix = SAMLConstants.ASSERTION_PREFIX;
    }
    if (declareNS) {
      uri = SAMLConstants.assertionDeclareStr;
    }
    result
        .append("<")
        .append(prefix)
        .append("Attribute")
        .append(uri)
        .append(" AttributeName=\"")
        .append(_attributeName)
        .append("\" AttributeNamespace=\"")
        .append(_attributeNameSpace)
        .append("\">\n");

    Iterator iter = _attributeValue.iterator();
    while (iter.hasNext()) {
      result.append(XMLUtils.printAttributeValue((Element) iter.next(), prefix)).append("\n");
    }
    result.append("</").append(prefix).append("Attribute>\n");
    return result.toString();
  }
Ejemplo n.º 7
0
 /**
  * Constructs an instance of <code>Attribute</code>.
  *
  * @param name A String representing <code>AttributeName</code> (the name of the attribute).
  * @param nameSpace A String representing the namespace in which <code>AttributeName</code>
  *     elements are interpreted.
  * @param values A List of DOM element representing the <code>AttributeValue</code> object.
  * @exception SAMLException if there is an error in the sender or in the element definition.
  */
 public Attribute(String name, String nameSpace, List values) throws SAMLException {
   super(name, nameSpace);
   if (values == null || values.isEmpty()) {
     if (SAMLUtilsCommon.debug.messageEnabled()) {
       SAMLUtilsCommon.debug.message("Attribute: AttributeValue is" + "required.");
     }
     throw new SAMLRequesterException(SAMLUtilsCommon.bundle.getString("nullInput"));
   }
   if (_attributeValue == null) {
     _attributeValue = new ArrayList();
   }
   // Make sure this is a list of AttributeValue
   Iterator iter = values.iterator();
   String tag = null;
   while (iter.hasNext()) {
     tag = ((Element) iter.next()).getLocalName();
     if ((tag == null) || (!tag.equals("AttributeValue"))) {
       if (SAMLUtilsCommon.debug.messageEnabled()) {
         SAMLUtilsCommon.debug.message("AttributeValue: wrong input.");
       }
       throw new SAMLRequesterException(SAMLUtilsCommon.bundle.getString("wrongInput"));
     }
   }
   _attributeValue = values;
 }
Ejemplo n.º 8
0
  /**
   * Reload the composite nodes of the circuit, this is recursive
   *
   * @param g the graphics that will paint the node
   * @throws CircuitLoadingException if the internal circuit can not be loaded
   */
  public void reloadCompositeNodes(Graphics g) throws CircuitLoadingException {
    for (iterNodes = this.nodes.iterator(); iterNodes.hasNext(); ) {
      Node n = iterNodes.next();

      if (n.getCategoryID() == Node.COMPOSITE) ((CompositeNode) n).reload(g);
    }
  }
Ejemplo n.º 9
0
  // ## operation writeChemkinReactions(ReactionModel)
  // 10/26/07 gmagoon: changed to take temperature as parameter (it doesn't seem like this method is
  // currently used anywhere)
  public static String writeChemkinReactions(
      ReactionModel p_reactionModel, Temperature p_temperature) {
    // #[ operation writeChemkinReactions(ReactionModel)
    StringBuilder result = new StringBuilder();
    result.append("REACTIONS	KCAL/MOLE\n");
    CoreEdgeReactionModel cerm = (CoreEdgeReactionModel) p_reactionModel;

    LinkedHashSet all = cerm.getReactedReactionSet();

    HashSet hs = new HashSet();
    int numfor = 0;
    int numrev = 0;
    int numdup = 0;
    int numnorev = 0;
    for (Iterator iter = all.iterator(); iter.hasNext(); ) {
      Reaction rxn = (Reaction) iter.next();
      if (rxn.isForward()) {
        result.append(
            " "
                + rxn.toChemkinString(p_temperature)
                + "\n"); // 10/26/07 gmagoon: changed to avoid use of Global.temperature
        //	result.append(" " + rxn.toChemkinString(Global.temperature) + "\n");

      }
    }

    result.append("END\n");

    return result.toString();

    // #]
  }
Ejemplo n.º 10
0
  private String unirMapeos(LinkedHashMap<String, String> mapa, Object[] descripciones) {

    // mapa(llave,punto)
    // descripciones en el mismo orden que el mapeo
    String comillas = "\"";
    StringBuilder builder = new StringBuilder();

    Iterator<String> iterador = mapa.keySet().iterator();

    int indice = 0;

    while (iterador.hasNext()) {
      String llave = iterador.next();

      String puntaje = mapa.get(llave);

      String descripcion =
          descripciones[indice].toString().equals("null") ? "" : descripciones[indice].toString();

      builder.append(comillas + descripcion + comillas + "," + comillas + puntaje + comillas + ",");

      indice++;
    }
    return builder.toString();
  }
Ejemplo n.º 11
0
  /**
   * This method exports the single pattern decision instance to the XML. It MUST be called by an
   * XML exporter, as this will not have a complete header.
   *
   * @param ratDoc The ratDoc generated by the XML exporter
   * @return the SAX representation of the object.
   */
  public Element toXML(Document ratDoc) {
    Element decisionE;
    RationaleDB db = RationaleDB.getHandle();

    // Now, add pattern to doc
    String entryID = db.getRef(this);
    if (entryID == null) {
      entryID = db.addPatternDecisionRef(this);
    }

    decisionE = ratDoc.createElement("DR:patternDecision");
    decisionE.setAttribute("rid", entryID);
    decisionE.setAttribute("name", name);
    decisionE.setAttribute("type", type.toString());
    decisionE.setAttribute("phase", devPhase.toString());
    decisionE.setAttribute("status", status.toString());
    // decisionE.setAttribute("artifact", artifact);

    Element descE = ratDoc.createElement("description");
    Text descText = ratDoc.createTextNode(description);
    descE.appendChild(descText);
    decisionE.appendChild(descE);

    // Add child pattern references...
    Iterator<Pattern> cpi = candidatePatterns.iterator();
    while (cpi.hasNext()) {
      Pattern cur = cpi.next();
      Element curE = ratDoc.createElement("refChildPattern");
      Text curText = ratDoc.createTextNode("p" + new Integer(cur.getID()).toString());
      curE.appendChild(curText);
      decisionE.appendChild(curE);
    }

    return decisionE;
  }
  private static void exportThisSeries(
      String name,
      String target_sea_state_datum,
      NamedList thisList,
      String[] sea_state_headings,
      Element itt,
      Document doc) {
    // ok, put us into the element
    org.w3c.dom.Element datum = doc.createElement(target_sea_state_datum);

    datum.setAttribute("Type", name);

    // and step through its values
    Collection<Double> indices = thisList.getValues();
    int ctr = 0;
    for (Iterator<Double> iter = indices.iterator(); iter.hasNext(); ) {
      Double val = (Double) iter.next();
      if (val != null) {
        datum.setAttribute(sea_state_headings[ctr], writeThis(val.doubleValue()));
        ctr++;
      } else break;
    }

    itt.appendChild(datum);
  }
Ejemplo n.º 13
0
  public void selectNext() {
    Iterator i = new SelectionIterator(this);

    if (m_actives.size() == 1) {
      boolean isFound = false;

      // loop the iterator in reverse order of drawing
      while (i.hasNext()) {
        GlyphObject object = (GlyphObject) i.next();

        if (m_actives.isSelected(object)) {
          isFound = true;
          continue;
        } // if

        if (!isFound) {
          continue;
        } // if

        m_actives.unselectAll();
        m_actives.addActive(object);
        return;
      } // while i
    } // if

    i = new SelectionIterator(this);
    if (i.hasNext()) {
      GlyphObject object = (GlyphObject) i.next();
      m_actives.unselectAll();
      m_actives.addActive(object);
      return;
    } // if
  }
Ejemplo n.º 14
0
  public static void write() {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    Document doc;

    System.out.println("Writing patient data file\n");

    try {
      DocumentBuilder builder = factory.newDocumentBuilder();
      doc = builder.newDocument();

      Element root = doc.createElement("patientdata");
      root.appendChild(XMLInterface.nl(doc));

      // get first PatientData from DataStore
      Iterator<PatientDataStore> pdsIt = GlobalVars.pds.iterator();
      while (pdsIt.hasNext()) {
        PatientDataStore pds = pdsIt.next();
        Node n = pds.createXMLNode(doc);

        XMLInterface.addNode(doc, root, n, 0);
      }

      root.normalize();
      // create junk to write it out (see java xml tutorial)
      TransformerFactory tFactory = TransformerFactory.newInstance();
      Transformer transformer = tFactory.newTransformer();
      DOMSource src = new DOMSource(root);
      StreamResult result = new StreamResult(new File(GlobalVars.XMLDataFile));
      transformer.transform(src, result);
    } catch (Exception e) {
      System.err.println("Error WRITING xml patient data file");
      e.printStackTrace();
    }
  }
Ejemplo n.º 15
0
 public static List list(NodeList self) {
   List answer = new ArrayList();
   Iterator it = DefaultGroovyMethods.iterator(self);
   while (it.hasNext()) {
     answer.add(it.next());
   }
   return answer;
 }
Ejemplo n.º 16
0
 public static Element appendNode(Element self, Object name, Map attributes, String value) {
   Element result = appendNode(self, name, value);
   for (Iterator iterator = attributes.entrySet().iterator(); iterator.hasNext(); ) {
     Map.Entry e = (Map.Entry) iterator.next();
     putAt(result, "@" + e.getKey().toString(), e.getValue());
   }
   return result;
 }
 public Collection hasRepositoryLocations(Collection repositoryLocationsToCheck) {
   Vector v = new Vector();
   for (Iterator en = repositoryLocationsToCheck.iterator(); en.hasNext(); ) {
     IRepositoryLocation elt = (IRepositoryLocation) en.next();
     v.addElement(new Boolean(hasRepositoryLocation(elt)));
   }
   return v;
 }
 public Collection hasSourceCodeFiles(Collection sourceCodeFilesToCheck) {
   Vector v = new Vector();
   for (Iterator en = sourceCodeFilesToCheck.iterator(); en.hasNext(); ) {
     IJavaSourceFile elt = (IJavaSourceFile) en.next();
     v.addElement(new Boolean(hasSourceCodeFile(elt)));
   }
   return v;
 }
Ejemplo n.º 19
0
 public Iterator getAllAttributes() {
   Iterator i = getAllAttributesFrom(this);
   ArrayList list = new ArrayList();
   while (i.hasNext()) {
     Name name = (Name) i.next();
     if (!"xmlns".equalsIgnoreCase(name.getPrefix())) list.add(name);
   }
   return list.iterator();
 }
 public boolean hasAllRepositoryLocations(Collection repositoryLocationsToCheck) {
   for (Iterator en = repositoryLocationsToCheck.iterator(); en.hasNext(); ) {
     IRepositoryLocation elt = (IRepositoryLocation) en.next();
     if (!hasRepositoryLocation(elt)) {
       return false;
     }
   }
   return true;
 }
 public boolean hasAllSourceCodeFiles(Collection sourceCodeFilesToCheck) {
   for (Iterator en = sourceCodeFilesToCheck.iterator(); en.hasNext(); ) {
     IJavaSourceFile elt = (IJavaSourceFile) en.next();
     if (!hasSourceCodeFile(elt)) {
       return false;
     }
   }
   return true;
 }
  public void makeNSMappings(PrintWriter buffer) {
    Set keys = prefixByUri_.keySet();
    Iterator iter = keys.iterator();

    while (iter.hasNext()) {
      String uri = (String) iter.next();
      buffer.print(makeNSMapping(uri));
    }
  }
  public ActionDescriptor getAction(int id) {
    // check global actions
    for (Iterator iterator = globalActions.iterator(); iterator.hasNext(); ) {
      ActionDescriptor actionDescriptor = (ActionDescriptor) iterator.next();

      if (actionDescriptor.getId() == id) {
        return actionDescriptor;
      }
    }

    // check steps
    for (Iterator iterator = steps.iterator(); iterator.hasNext(); ) {
      StepDescriptor stepDescriptor = (StepDescriptor) iterator.next();
      ActionDescriptor actionDescriptor = stepDescriptor.getAction(id);

      if (actionDescriptor != null) {
        return actionDescriptor;
      }
    }

    // check initial actions, which we now must have unique id's
    for (Iterator iterator = initialActions.iterator(); iterator.hasNext(); ) {
      ActionDescriptor actionDescriptor = (ActionDescriptor) iterator.next();

      if (actionDescriptor.getId() == id) {
        return actionDescriptor;
      }
    }

    return null;
  }
  public JoinDescriptor getJoin(int id) {
    for (Iterator iterator = joins.iterator(); iterator.hasNext(); ) {
      JoinDescriptor joinDescriptor = (JoinDescriptor) iterator.next();

      if (joinDescriptor.getId() == id) {
        return joinDescriptor;
      }
    }

    return null;
  }
  public SplitDescriptor getSplit(int id) {
    for (Iterator iterator = splits.iterator(); iterator.hasNext(); ) {
      SplitDescriptor splitDescriptor = (SplitDescriptor) iterator.next();

      if (splitDescriptor.getId() == id) {
        return splitDescriptor;
      }
    }

    return null;
  }
Ejemplo n.º 26
0
 private static String toString(NodeList self) {
   StringBuffer sb = new StringBuffer();
   sb.append("[");
   Iterator it = DefaultGroovyMethods.iterator(self);
   while (it.hasNext()) {
     if (sb.length() > 1) sb.append(", ");
     sb.append(it.next().toString());
   }
   sb.append("]");
   return sb.toString();
 }
  public StepDescriptor getStep(int id) {
    for (Iterator iterator = steps.iterator(); iterator.hasNext(); ) {
      StepDescriptor step = (StepDescriptor) iterator.next();

      if (step.getId() == id) {
        return step;
      }
    }

    return null;
  }
Ejemplo n.º 28
0
  public static byte[] convertToJSON(
      IExtensionHelpers helpers, IHttpRequestResponse requestResponse) {

    byte[] request = requestResponse.getRequest();

    if (Objects.equals(helpers.analyzeRequest(request).getMethod(), "GET")) {
      request = helpers.toggleRequestMethod(request);
    }

    IRequestInfo requestInfo = helpers.analyzeRequest(request);

    int bodyOffset = requestInfo.getBodyOffset();

    byte content_type = requestInfo.getContentType();

    String body = new String(request, bodyOffset, request.length - bodyOffset);

    String json = "";

    Boolean success = true;

    try {
      if (content_type == 3) {
        JSONObject xmlJSONObject = XML.toJSONObject(body);
        json = xmlJSONObject.toString(2);
      } else if (content_type == 0 || content_type == 1) {
        Map<String, String> params = splitQuery(body);
        Gson gson = new Gson();
        json = gson.toJson(params);
      } else {
        json = body;
      }
    } catch (Exception e) {
      success = false;
    }

    if (!success) {
      return request;
    } else {

      List<String> headers;

      headers = helpers.analyzeRequest(request).getHeaders();

      Iterator<String> iter = headers.iterator();
      while (iter.hasNext()) {
        if (iter.next().contains("Content-Type")) iter.remove();
      }

      headers.add("Content-Type: application/json;charset=UTF-8");

      return helpers.buildHttpMessage(headers, json.getBytes());
    }
  }
Ejemplo n.º 29
0
  /**
   * Get the inputable nodes of the circuit
   *
   * @return an hashset of the inputable nodes of the circuit
   */
  public HashSet<Inputable> getInputables() {
    HashSet<Inputable> inputs = new HashSet<Inputable>();

    for (iterNodes = getNodesIterator(); iterNodes.hasNext(); ) {
      Node n = iterNodes.next();

      if (n.getCategoryID() == Node.INPUT) inputs.add((Inputable) n);
    }

    return inputs;
  }
Ejemplo n.º 30
0
  /**
   * Get the outputable nodes of the circuit
   *
   * @return an hashset of the outputable nodes of the circuit
   */
  public HashSet<Outputable> getOutputables() {
    HashSet<Outputable> outputs = new HashSet<Outputable>();

    for (iterNodes = getNodesIterator(); iterNodes.hasNext(); ) {
      Node n = iterNodes.next();

      if (n.getCategoryID() == Node.OUTPUT) outputs.add((Outputable) n);
    }

    return outputs;
  }