Exemplo n.º 1
0
  Action createAction(Rule rule) {
    String s = rule.getProperty(Rule.pAction);
    Action action = Action.createAction(s);
    action.setOwner(rule);
    int i = s.indexOf(" ");
    String as[];
    if (i >= 0) {
      as = TextUtils.split(s.substring(i + 1, s.length()));
    } else {
      as = new String[0];
    }
    Array array = new Array();
    HashMapOrdered hashmapordered = new HashMapOrdered(true);
    for (int j = 0; j < as.length; j++) {
      int k = as[j].indexOf("=");
      if (k == -1) {
        array.add(as[j]);
      } else {
        hashmapordered.add(as[j].substring(0, k), as[j].substring(k + 1));
      }
    }

    action.initializeFromArguments(array, hashmapordered);
    return action;
  }
Exemplo n.º 2
0
  private static List<HashMapOrdered> travel(List<GenericValue> monitors, String parentAttr) {
    List<HashMapOrdered> retlist = new ArrayList<HashMapOrdered>();

    HashMapOrdered hashMap = null;
    String oldId = "";
    for (GenericValue val : monitors) {
      String id = val.getString("id");

      if (id != null)
        if (((parentAttr == null && val.getString("parentAttrName") == null))
            || (parentAttr.equals(val.getString("parentAttrName")))) {

          if (!id.equals(oldId)) {
            if (hashMap != null) {
              retlist.add(hashMap);
            }
            hashMap = new HashMapOrdered(false);
          }

          if (hasChildrenAttr(monitors, val.getString("attrName"), id)) {
            List<HashMapOrdered> children = travel(monitors, val.getString("attrName"));
            for (HashMapOrdered child : children) {
              if (child == null) continue;
              hashMap.add(child);
            }

          } else {
            hashMap.add(val.getString("attrName"), val.getString("attrValue"));
          }
        }
      oldId = val.getString("id");
    }

    if (hashMap != null) retlist.add(hashMap);
    return retlist;
  }
Exemplo n.º 3
0
  public static Array get(String groupId, String stype) throws Exception {
    List<GenericValue> groups = getGroupValues(groupId, stype);
    Array retlist = new Array();
    if (groups.size() <= 0) return retlist;

    HashMapOrdered hashMap = new HashMapOrdered(false);
    for (GenericValue val : groups) {
      hashMap.add(val.getString("attrName"), val.getString("attrValue"));
    }
    retlist.add(hashMap);

    List<GenericValue> monitors = MonitorEntity.getMonitorsValueByGroupId(groupId, stype);
    List<HashMapOrdered> children = travel(monitors, null);
    for (HashMapOrdered child : children) {
      if (child == null) continue;
      retlist.add(child);
    }

    List<GenericValue> childreGroups = getChild(groupId, stype);

    for (GenericValue val : childreGroups) {
      HashMapOrdered childreGroup = new HashMapOrdered(false);
      String group = val.getString("id");
      String groupName = getGroupName(group);
      String[] splits = group.split("\\.");
      String id = "0";
      if (splits.length > 1) {
        id = splits[splits.length - 1];
      }
      childreGroup.add("_class", "SubGroup");
      childreGroup.add("_id", id);
      childreGroup.add("_encoding", "GBK");
      childreGroup.add("_group", group);
      childreGroup.add("_name", groupName);
      retlist.add(childreGroup);
    }

    return retlist;
  }