コード例 #1
0
 @Override
 public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
   GenericBoltUtils genericBoltUtils = new GenericBoltUtils();
   outputFieldsDeclarer.declareStream(
       streamId,
       genericBoltUtils.getDeclareOutputFields(previousEmitFileds, statement.getColumns()));
 }
コード例 #2
0
  private void preparedRest() throws Exception {
    Pattern pattern = Pattern.compile("values(\\s*)\\((.+?)\\)");
    Matcher matcher = pattern.matcher(statement.getQuery());
    String[] columnsArrys = null;
    while (matcher.find()) {
      String columnsStr = matcher.group(2).replace(" ", "");
      columnsArrys = columnsStr.split(",(?=([^\']*\'[^\']*\')*[^\']*$)", -1);
    }

    for (int i = 0; i < columnsArrys.length; i++) {
      columnsArrys[i] = columnsArrys[i].substring(1, columnsArrys[i].length() - 1);
    }

    if (columnsArrys.length < 3 && columnsArrys.length % 3 != 0) {
      throw new Exception("invalid rest format");
    }

    Pattern p = Pattern.compile("\\[\\:(.+?)\\]");
    for (int i = 0; i < columnsArrys.length / 3; i++) {
      RestInfo restInfo = new RestInfo();
      restInfo.setCmd(RestCmd.valueOf(columnsArrys[i * 3]));
      restInfo.setUrl(columnsArrys[i * 3 + 1]);
      restInfo.setBody("".equals(columnsArrys[i * 3 + 2]) ? null : columnsArrys[i * 3 + 2]);

      List<BaseBindColumnDef> columns = new ArrayList<BaseBindColumnDef>();
      String valQuery = columnsArrys[i * 3 + 1];
      Matcher m = p.matcher(valQuery);
      while (m.find()) {
        String bindName = m.group(1);
        BaseBindColumnDef bindColumn = new BaseBindColumnDef();
        bindColumn.setName(bindName);
        columns.add(bindColumn);
      }
      restInfo.setColumns(columns);
      restInfos.add(restInfo);
    }
  }