Exemple #1
0
  public static void createAggregation(String aggName, String schemaName, String... urls) {
    StreamAggregation s = NoSql.em().find(StreamAggregation.class, aggName);
    if (s == null) {
      s = new StreamAggregation();
    } else {
      if (!s.getSchema().getName().equals(schemaName))
        throw new RuntimeException(
            "Aggregation name=" + aggName + " is already in use under group=" + schemaName);
    }

    SecureSchema schema = SecureSchema.findByName(NoSql.em(), schemaName);

    s.setName(aggName);
    List<String> streamUrls = s.getUrls();
    streamUrls.clear();

    for (String url : urls) {
      streamUrls.add(url);
    }

    s.setSchema(schema);
    NoSql.em().put(s);
    NoSql.em().put(schema);
    NoSql.em().flush();
  }