Example #1
0
  private void addChannel(Document doc, Element root, Integer channel, HashSet<Integer> values) {
    Element el = doc.createElement(_channel);
    Attr attr = doc.createAttribute(_number);
    attr.setValue(Integer.toString(channel + 1));
    el.setAttributeNode(attr);
    Text txt;
    for (Integer x : values) {
      txt = doc.createTextNode(x.toString());
      el.appendChild(txt);
    }

    root.appendChild(el);
  }
Example #2
0
  private void addMagicChannel(Document doc, Element root, int channel, double x, double y) {
    Element el = doc.createElement(_channel);
    // Element xel = doc.createElement(_x);
    // Element yel = doc.createElement(_y);
    Attr attr = doc.createAttribute(_number);
    attr.setValue(Integer.toString(channel + 1));
    el.setAttributeNode(attr);

    attr = doc.createAttribute(_x);
    attr.setValue(Double.toString(x));
    el.setAttributeNode(attr);

    attr = doc.createAttribute(_y);
    attr.setValue(Double.toString(y));
    el.setAttributeNode(attr);

    // xel.appendChild(doc.createTextNode(Integer.toString(x)));
    // yel.appendChild(doc.createTextNode(Integer.toString(y)));

    // el.appendChild(xel);
    // el.appendChild(yel);
    root.appendChild(el);
  }
Example #3
0
  /**
   * Method responsible for creating Document type response
   *
   * @param responseObject
   * @return Document or Null if exception occurs
   */
  protected Document createResponseObject(Map<String, String> responseObject)
      throws ResponseException {
    try {
      DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

      // root elements
      Document doc = docBuilder.newDocument();
      Element rootElement = doc.createElement("snmp-response-message");
      doc.appendChild(rootElement);

      Element status = doc.createElement("status");
      rootElement.appendChild(status);

      Element result = doc.createElement("result");
      result.appendChild(doc.createTextNode(String.valueOf(resultCode)));
      status.appendChild(result);

      Element description = doc.createElement("description");
      description.appendChild(doc.createTextNode(descriptionText));
      status.appendChild(description);

      Element operation = doc.createElement("weatherProbe");
      rootElement.appendChild(operation);

      Attr attr = doc.createAttribute("ip");
      attr.setValue(att.get("IP-ADDRESS"));
      operation.setAttributeNode(attr);

      if (resultCode != 0) {
        return doc;
      }

      for (Map.Entry<String, String> entry : responseObject.entrySet()) {
        Element nextElement = doc.createElement(entry.getKey());
        nextElement.appendChild(doc.createTextNode(entry.getValue()));
        operation.appendChild(nextElement);
      }
      return doc;
    } catch (ParserConfigurationException e) {
      LOG.error(e.toString());
      throw new ResponseException(
          "<snmp-response-message><status><result>2</result><description>"
              + e.toString()
              + "</description></status><weatherProbe ip=\""
              + att.get("IP-ADDRESS")
              + "\"/></snmp-response-message>");
    }
  }
Example #4
0
  private void addFade(Document doc, Element root, FadeData fade) {
    Element el = doc.createElement(_cue);
    Attr attr;

    attr = doc.createAttribute(_number);
    attr.setValue(Integer.toString(fade.getCueNumber()));
    el.setAttributeNode(attr);

    attr = doc.createAttribute(_uptime);
    attr.setValue(Integer.toString(fade.getUpTime()));
    el.setAttributeNode(attr);

    attr = doc.createAttribute(_downTime);
    attr.setValue(Integer.toString(fade.getDownTime()));
    el.setAttributeNode(attr);

    attr = doc.createAttribute(_upTimeDelay);
    attr.setValue(Integer.toString(fade.getDelayUpTime()));
    el.setAttributeNode(attr);

    attr = doc.createAttribute(_downTimeDelay);
    attr.setValue(Integer.toString(fade.getDelayDownTime()));
    el.setAttributeNode(attr);

    if (fade.getFollowTime() >= 0) {
      attr = doc.createAttribute(_followtime);
      attr.setValue(Integer.toString(fade.getFollowTime()));
      el.setAttributeNode(attr);
    }

    if (fade.getNextCue() > 0) {
      attr = doc.createAttribute(_nextCue);
      attr.setValue(Integer.toString(fade.getNextCue()));
      el.setAttributeNode(attr);
    }

    CueData cue = fade.getCue();

    attr = doc.createAttribute(_discription);
    attr.setValue(cue.getDescription());
    el.setAttributeNode(attr);

    for (Integer chan : cue.keySet()) addChannel(doc, el, chan, cue.get(chan));

    root.appendChild(el);
  }