Esempio n. 1
0
 public static OMElement queryToOM(Query query) {
   OMFactory factory = OMAbstractFactory.getOMFactory();
   OMElement queryChild =
       factory.createOMElement(
           new QName(
               CEPConstants.CEP_CONF_NAMESPACE,
               CEPConstants.CEP_CONF_ELE_QUERY,
               CEPConstants.CEP_CONF_CEP_NAME_SPACE_PREFIX));
   Expression queryExpression = query.getExpression();
   String queryName = query.getName();
   OMElement queryIP = null;
   List<String> ipList = query.getIpList();
   for (String ip : ipList) {
     queryIP = factory.createOMElement(new QName(CEPConstants.CEP_CONF_QUERY_IP));
     queryIP.setText(ip);
     queryChild.addChild(queryIP);
   }
   queryChild.addAttribute(CEPConstants.CEP_CONF_ATTR_NAME, queryName, null);
   OMElement omQueryExpression = ExpressionHelper.expressionToOM(queryExpression);
   queryChild.addChild(omQueryExpression);
   if (query.getOutput() != null) {
     OMElement queryOutput = OutputHelper.outputToOM(query.getOutput());
     queryChild.addChild(queryOutput);
   }
   return queryChild;
 }
Esempio n. 2
0
  public static Query fromOM(OMElement queryElement) {
    Query query = new Query();
    String name =
        queryElement.getAttribute(new QName(CEPConstants.CEP_CONF_ATTR_NAME)).getAttributeValue();
    query.setName(name);

    Iterator iterator = queryElement.getChildrenWithName(new QName(CEPConstants.CEP_CONF_QUERY_IP));

    while (iterator != null && iterator.hasNext()) {
      OMElement ipElement = (OMElement) iterator.next();
      String ip = ipElement.getText();
      query.addIP(ip);
    }

    OMElement expressionElement =
        queryElement.getFirstChildWithName(
            new QName(CEPConstants.CEP_CONF_NAMESPACE, CEPConstants.CEP_CONF_ELE_EXPRESSION));
    if (expressionElement != null) {
      query.setExpression(ExpressionHelper.fromOM(expressionElement));
    }

    OMElement outputOmElement =
        queryElement.getFirstChildWithName(
            new QName(CEPConstants.CEP_CONF_NAMESPACE, CEPConstants.CEP_CONF_ELE_OUTPUT));
    if (expressionElement != null && outputOmElement != null) {
      query.setOutput(OutputHelper.fromOM(outputOmElement));
    }
    return query;
  }