pgAttributes.put((String)pgAttrLibIds.get(i), new PGAttr(pgName, pgAttrName, pgAttrType, pgAggregateType)); }
}
  private void addPropGroups() {    String pgName = "";    String pgAttrName = "";    String pgAttrType = "";    String pgValue = "";    String pgAggregateType = "";    Timestamp pgStartDate;    Timestamp pgEndDate;    try {      Connection conn = DBUtils.getConnection();      try {        Statement stmt = conn.createStatement();	        // get the propery group attribute lib ids for this agent        ArrayList pgAttrLibIds = new ArrayList();        String query = DBUtils.getQuery(QUERY_PG_ID, substitutions);        ResultSet rs = stmt.executeQuery(query);        while (rs.next()) {          pgAttrLibIds.add(rs.getString(1));        }        // get pg name and attribute names and types for each property group        for (int i = 0; i < pgAttrLibIds.size(); i++) {          substitutions.put(":pgAttrLibId", (String)pgAttrLibIds.get(i));          query = DBUtils.getQuery(QUERY_PG_ATTRS, substitutions);          rs = stmt.executeQuery(query);          while (rs.next()) {            pgName = rs.getString(1);            pgAttrName = rs.getString(2);            pgAttrType = rs.getString(3);            pgAggregateType = rs.getString(4);          }          pgAttributes.put((String)pgAttrLibIds.get(i),                           new PGAttr(pgName, pgAttrName,                                       pgAttrType, pgAggregateType));        }        // get values for each attribute in each property group        PGPropMultiVal multiValueData = null;        for (int i = 0; i < pgAttrLibIds.size(); i++) {          String pgAttrLibId = (String)pgAttrLibIds.get(i);          substitutions.put(":pgAttrLibId", pgAttrLibId);          PGAttr pgAttr = (PGAttr)pgAttributes.get(pgAttrLibId);          String attrType = pgAttr.getAttrType();          String aggregateType = pgAttr.getAggregateType();          query = DBUtils.getQuery(QUERY_PG_VALUES, substitutions);          rs = stmt.executeQuery(query);          while (rs.next()) {            if (aggregateType.equals("SINGLE")) {              pgValue = rs.getString(1);              pgStartDate = rs.getTimestamp(2);              pgEndDate = rs.getTimestamp(3);              addPGAttributeData(pgAttrLibId, pgValue, pgStartDate, pgEndDate);            } else {              pgValue = rs.getString(1);              pgStartDate = rs.getTimestamp(2);              pgEndDate = rs.getTimestamp(3);              if (multiValueData == null)                 multiValueData = new PGPropMultiVal();              multiValueData.addValue(pgValue);            }          }          if (multiValueData != null) {            addPGAttributeData(pgAttrLibId, multiValueData, null, null);            multiValueData = null;          }        }        rs.close();        stmt.close();      } finally {        conn.close();      }    } catch (Exception e) {      if(log.isErrorEnabled()) {        log.error("Exception", e);      }      throw new RuntimeException("Error" + e);    }    // after creating all the property group data    // create the property groups, initialize them and add them as children    ContainerBase pgContainer = new ContainerBase("Property Groups");    pgContainer.initProperties();    addChild(pgContainer);    Iterator propGroupData = propertyGroups.values().iterator();    while (propGroupData.hasNext()) {      PropGroupData pgd = (PropGroupData)propGroupData.next();      PropGroupComponent newPG = new PropGroupBase(pgd);      newPG.initProperties();      pgContainer.addChild(newPG);    }  }