public UUID[] queryUserFocusFilters(String user) {
    Set<UUID> filterIdSet = new LinkedHashSet<UUID>();
    PreparedStatement pstm = null;
    ResultSet rs = null;
    Connection conn = null;
    try {
      conn = DbPoolConnection.getInstance().getReadConnection();
      pstm = conn.prepareStatement("SELECT filter_id FROM user_focus_filter" + " WHERE user = ?");
      pstm.setString(1, user);

      rs = pstm.executeQuery();
      while (rs.next()) {
        UUID id = DataAccessFactory.getInstance().createUUID(rs.getObject("filter_id").toString());
        filterIdSet.add(id);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbPoolConnection.getInstance().closeResultSet(rs);
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    return filterIdSet.toArray(new UUID[0]);
  }
  public List<Filter> queryAllFilters() {
    List<Filter> filterList = new ArrayList<Filter>();
    PreparedStatement pstm = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
      conn = DbPoolConnection.getInstance().getReadConnection();
      pstm = conn.prepareStatement("SELECT * FROM filter WHERE is_valid = true");
      rs = pstm.executeQuery();
      while (rs.next()) {
        UUID id = DataAccessFactory.getInstance().createUUID(Long.toString(rs.getLong("id")));
        Timestamp createTime = rs.getTimestamp("create_time");
        String createUser = rs.getString("create_user");
        Filter filter = new FilterImpl(id, createUser, createTime, null);
        filter.setName(rs.getString("name"));
        filter.setXml(rs.getString("xml"));
        filter.setAnd(rs.getBoolean("is_and"));
        filter.setPublic(rs.getBoolean("is_public"));
        filter.setVisible(rs.getBoolean("is_visible"));
        filterList.add(filter);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbPoolConnection.getInstance().closeResultSet(rs);
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    return filterList;
  }
Beispiel #3
0
  /**
   * @description:init new template xml from node
   * @date:2014-5-6 下午4:36:46
   * @version:v1.0
   * @param node
   */
  protected void initTemplateXml(Node node) {
    try {
      org.w3c.dom.Node templateNode = XMLUtil.getSingleNode(node, "template");
      String idStr = XMLUtil.getSingleNode(templateNode, "id").getTextContent();
      UUID id = DataAccessFactory.getInstance().createUUID(idStr);
      String templateTypeIdStr =
          XMLUtil.getSingleNode(templateNode, "templateTypeId").getTextContent();
      UUID templateTypeId = DataAccessFactory.getInstance().createUUID(templateTypeIdStr);

      String name = XMLUtil.getSingleNode(templateNode, "name").getTextContent();

      this.id = id;
      this.templateTypeId = templateTypeId;
      this.name = name;
      this.description = XMLUtil.getSingleNodeTextContent(templateNode, "description");

      String flowIdStr = XMLUtil.getSingleNode(templateNode, "flowId").getTextContent();
      this.flowId = DataAccessFactory.getInstance().createUUID(flowIdStr);

      List<Node> rowNodes = XMLUtil.getNodes(templateNode, "layout/rows/row");
      for (Node rowNode : rowNodes) {
        List<Node> columnNodes = XMLUtil.getNodes(rowNode, "column");
        FieldRow fieldRow = new FieldRow();
        for (Node columnNode : columnNodes) {
          List<Node> fieldNodes = XMLUtil.getNodes(columnNode, "field");
          FieldColumn fieldColumn = new FieldColumn();
          for (Node fieldNode : fieldNodes) {
            Field tempField = initFieldNode(fieldNode);
            fieldColumn.addField(tempField);
            this.fieldSet.add(tempField);
          }
          fieldRow.addColumn(fieldColumn);
        }

        fieldRowList.add(fieldRow);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Beispiel #4
0
 /**
  * (non-Javadoc)
  *
  * <p>Title:get
  *
  * @param id
  * @return
  * @see com.sogou.qadev.cache.Cache#get(java.lang.String)
  */
 public Flow get(String id) {
   Flow tmp = null;
   Object flow = EhcacheHandler.getInstance().get(EhcacheHandler.FOREVER_CACHE, id);
   if (flow != null) {
     if (flow instanceof Flow) {
       tmp = (Flow) flow;
     }
   } else {
     tmp =
         new FlowAccessSessionMySQL()
             .queryFlowById(DataAccessFactory.getInstance().createUUID(id));
     if (tmp != null) {
       EhcacheHandler.getInstance().set(EhcacheHandler.FOREVER_CACHE, tmp.getId().getValue(), tmp);
     }
   }
   if (tmp == null) {
     logger.info("flow id : " + id + " is not in cache");
   }
   return tmp;
 }
  public Filter queryFilter(UUID id) {
    if (id == null) {
      return null;
    }
    Filter filter = null;

    PreparedStatement pstm = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
      conn = DbPoolConnection.getInstance().getReadConnection();
      pstm = conn.prepareStatement("SELECT * FROM filter" + " WHERE id = ?");
      pstm.setLong(1, Long.parseLong(id.getValue()));

      rs = pstm.executeQuery();
      if (rs.next()) {
        String createUser = rs.getString("create_user");
        Timestamp createTime = rs.getTimestamp("create_time");
        UUID fatherId = null;
        if (rs.getObject("father_id") != null)
          fatherId =
              DataAccessFactory.getInstance().createUUID(rs.getObject("father_id").toString());

        filter = new FilterImpl(id, createUser, createTime, fatherId);
        filter.setName(rs.getString("name"));
        filter.setXml(rs.getString("xml"));
        filter.setAnd(rs.getBoolean("is_and"));
        filter.setPublic(rs.getBoolean("is_public"));
        filter.setVisible(rs.getBoolean("is_visible"));
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbPoolConnection.getInstance().closeResultSet(rs);
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    return filter;
  }
Beispiel #6
0
 /**
  * (non-Javadoc)
  *
  * <p>Title:addField
  *
  * @param type
  * @param dataType
  * @return
  * @see
  *     com.sogou.qadev.service.cynthia.bean.Template#addField(com.sogou.qadev.service.cynthia.bean.Field.Type,
  *     com.sogou.qadev.service.cynthia.bean.Field.DataType)
  */
 public Field addField(Type type, DataType dataType) {
   UUID fieldId = DataAccessFactory.getInstance().newUUID("FIEL");
   Field field = new FieldImpl(fieldId, this.id, type, dataType);
   this.fieldSet.add(field);
   return field;
 }
Beispiel #7
0
  /**
   * @description:init field from field node
   * @date:2014-5-6 下午4:35:54
   * @version:v1.0
   * @param fieldNode
   * @return
   */
  protected Field initFieldNode(Node fieldNode) {
    Field field = null;
    try {
      String fieldIdStr = XMLUtil.getSingleNode(fieldNode, "id").getTextContent();
      UUID fieldId = DataAccessFactory.getInstance().createUUID(fieldIdStr);

      String typeStr = XMLUtil.getSingleNode(fieldNode, "type").getTextContent();
      Type type = Type.valueOf(typeStr);

      DataType dataType = null;
      String dataTypeStr = XMLUtil.getSingleNode(fieldNode, "dataType").getTextContent();
      if (dataTypeStr.length() > 0) dataType = DataType.valueOf(dataTypeStr);

      field = new FieldImpl(fieldId, id, type, dataType);

      String fieldName = XMLUtil.getSingleNode(fieldNode, "name").getTextContent();
      field.setName(fieldName);

      String fieldDescription = XMLUtil.getSingleNode(fieldNode, "description").getTextContent();
      if (fieldDescription.length() > 0) field.setDescription(fieldDescription);

      String fieldTip = XMLUtil.getSingleNodeTextContent(fieldNode, "fieldTip");
      if (fieldTip != null) field.setFieldTip(fieldTip);

      String fieldSize = XMLUtil.getSingleNodeTextContent(fieldNode, "fieldSize");
      if (fieldSize != null) field.setFieldSize(fieldSize);

      String defaultValue = XMLUtil.getSingleNode(fieldNode, "defaultValue").getTextContent();
      if (defaultValue.length() > 0) field.setDefaultValue(defaultValue);

      String controlFieldIdStr =
          XMLUtil.getSingleNode(fieldNode, "controlFieldId").getTextContent();
      if (controlFieldIdStr.length() > 0)
        field.setControlFieldId(DataAccessFactory.getInstance().createUUID(controlFieldIdStr));

      //////////////////////////////////////////////////////////////////////////////////////////////////////////////
      try {
        Node controlHiddenFieldIdNode = XMLUtil.getSingleNode(fieldNode, "controlHiddenFieldId");
        String controlHiddenFieldIdStr = "";
        if (controlHiddenFieldIdNode != null) {
          controlHiddenFieldIdStr = controlHiddenFieldIdNode.getTextContent();
        }
        if (controlHiddenFieldIdStr.length() > 0) {
          field.setControlHiddenFieldId(
              DataAccessFactory.getInstance().createUUID(controlHiddenFieldIdStr));
        }

        Set<UUID> controlHiddenFieldsSet = new LinkedHashSet<UUID>();
        List<Node> controlHiddenFieldsList =
            XMLUtil.getNodes(fieldNode, "controlHiddenFields/controlHiddenField");
        if (controlHiddenFieldsList != null && controlHiddenFieldsList.size() > 0) {
          for (Node controlHiddenFieldNode : controlHiddenFieldsList) {
            UUID controlHiddenFieldId =
                DataAccessFactory.getInstance().createUUID(controlHiddenFieldNode.getTextContent());
            controlHiddenFieldsSet.add(controlHiddenFieldId);
          }
          field.setControlHiddenFieldsIds(controlHiddenFieldsSet);
        }

        Set<UUID> controlHiddenStatesSet = new LinkedHashSet<UUID>();
        List<Node> controlHiddenStatesList =
            XMLUtil.getNodes(fieldNode, "controlHiddenStates/controlHiddenState");
        if (controlHiddenStatesList != null && controlHiddenStatesList.size() > 0) {
          for (Node controlHiddenStateNode : controlHiddenStatesList) {
            UUID controlHiddenStateId =
                DataAccessFactory.getInstance().createUUID(controlHiddenStateNode.getTextContent());
            controlHiddenStatesSet.add(controlHiddenStateId);
          }
          field.setControlHiddenStatesIds(controlHiddenStatesSet);
        }
      } catch (Exception e) {
        e.printStackTrace();
        System.err.println("init 表单出错");
      }
      //////////////////////////////////////////////////////////////////////////////////////////////////////////////

      Set<Option> optionSet = new LinkedHashSet<Option>();

      List<Node> optionNodeList = XMLUtil.getNodes(fieldNode, "options/option");
      for (Node optionNode : optionNodeList) {
        String optionIdStr = XMLUtil.getSingleNode(optionNode, "id").getTextContent();
        UUID optionId = DataAccessFactory.getInstance().createUUID(optionIdStr);

        OptionImpl optionImpl = new OptionImpl(optionId, fieldId);

        String optionName = XMLUtil.getSingleNode(optionNode, "name").getTextContent();
        optionImpl.setName(optionName);

        String optionDescription =
            XMLUtil.getSingleNode(optionNode, "description").getTextContent();
        if (optionDescription.length() > 0) optionImpl.setDescription(optionDescription);

        String controlOptionIdStr =
            XMLUtil.getSingleNode(optionNode, "controlOptionId").getTextContent();
        if (controlOptionIdStr.length() > 0)
          optionImpl.setControlOptionId(
              DataAccessFactory.getInstance().createUUID(controlOptionIdStr));

        String forbiddenStr = XMLUtil.getSingleNode(optionNode, "forbidden").getTextContent();
        Forbidden forbidden = Forbidden.valueOf(forbiddenStr);
        optionImpl.setForbidden(forbidden);

        String indexOrderStr = XMLUtil.getSingleNode(optionNode, "indexOrder").getTextContent();
        int indexOrder = Integer.parseInt(indexOrderStr);
        optionImpl.setIndexOrder(indexOrder);

        optionSet.add(optionImpl);
      }

      field.setOptions(optionSet);

      Set<UUID> controlOptionIdSet = new LinkedHashSet<UUID>();

      List<Node> controlOptionIdNodeList =
          XMLUtil.getNodes(fieldNode, "controlOptionIds/controlOptionId");
      for (Node controlOptionIdNode : controlOptionIdNodeList) {
        UUID controlOptionId =
            DataAccessFactory.getInstance().createUUID(controlOptionIdNode.getTextContent());
        controlOptionIdSet.add(controlOptionId);
      }

      field.setControlOptionIds(controlOptionIdSet);

      Set<String> controlRoleIdSet = new LinkedHashSet<String>();

      List<Node> controlRoleIdNodeList =
          XMLUtil.getNodes(fieldNode, "controlRoleIds/controlRoleId");
      for (Node controlRoleIdNode : controlRoleIdNodeList) {
        controlRoleIdSet.add(controlRoleIdNode.getTextContent());
      }

      field.setControlRoleIds(controlRoleIdSet);

      Set<UUID> actionIdSet = new LinkedHashSet<UUID>();

      Set<String> controlActionIdSet = new LinkedHashSet<String>();

      List<Node> controlActionIdNodeList =
          XMLUtil.getNodes(fieldNode, "controlActionIds/controlActionId");
      for (Node controlActionIdNode : controlActionIdNodeList) {
        actionIdSet.add(
            DataAccessFactory.getInstance()
                .createUUID(controlActionIdNode.getTextContent().split("\\_")[0]));
        controlActionIdSet.add(controlActionIdNode.getTextContent());
      }

      field.setControlActionIds(controlActionIdSet);

      List<Node> actionIdNodeList = XMLUtil.getNodes(fieldNode, "actionIds/actionId");
      for (Node actionIdNode : actionIdNodeList)
        actionIdSet.add(DataAccessFactory.getInstance().createUUID(actionIdNode.getTextContent()));
      field.setActionIds(actionIdSet);

    } catch (Exception e) {
      e.printStackTrace();
    }
    return field;
  }
  public Filter[] queryFilters(String user) {
    DataAccessSession das = DataAccessFactory.getInstance().getSysDas();

    List<Filter> filterList = new ArrayList<Filter>();

    PreparedStatement pstm = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
      conn = DbPoolConnection.getInstance().getReadConnection();
      pstm =
          conn.prepareStatement(
              "SELECT * FROM filter WHERE (create_user = ? OR is_public = true AND create_user != ?)"
                  + " AND father_id IS NULL AND is_valid = true ORDER BY name");
      pstm.setString(1, user);
      pstm.setString(2, DataAccessFactory.sysUser);

      rs = pstm.executeQuery();
      while (rs.next()) {
        UUID id = DataAccessFactory.getInstance().createUUID(rs.getObject("id").toString());
        String createUser = rs.getString("create_user");
        Timestamp createTime = rs.getTimestamp("create_time");

        Filter filter = new FilterImpl(id, createUser, createTime, null);
        filter.setName(rs.getString("name"));
        filter.setXml(rs.getString("xml"));
        filter.setAnd(rs.getBoolean("is_and"));
        filter.setPublic(rs.getBoolean("is_public"));
        filter.setVisible(rs.getBoolean("is_visible"));

        filterList.add(filter);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbPoolConnection.getInstance().closeResultSet(rs);
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    Map<UUID, Boolean> templateAllowMap = new HashMap<UUID, Boolean>();
    Map<UUID, List<Template>> allTemplateTypeMap = new HashMap<UUID, List<Template>>();
    Map<UUID, Template> allTemplateMap = new HashMap<UUID, Template>();
    Map<UUID, Flow> allFlowMap = new HashMap<UUID, Flow>();

    Iterator<Filter> filterItr = filterList.iterator();
    while (filterItr.hasNext()) {
      Filter filter = filterItr.next();

      Document xmlDoc = null;
      try {
        xmlDoc = XMLUtil.string2Document(filter.getXml(), "UTF-8");
      } catch (Exception e) {
        e.printStackTrace();
        System.err.println("error filter id: " + filter.getId());
      }

      if (xmlDoc == null) {
        filterItr.remove();
        continue;
      }

      Node queryNode = XMLUtil.getSingleNode(xmlDoc, "query");
      Node templateTypeNode = XMLUtil.getSingleNode(queryNode, "templateType");
      List<Node> templateNodeList = XMLUtil.getNodes(queryNode, "template");

      List<Template> templateList = new ArrayList<Template>();

      if (templateNodeList.size() == 0) {
        String templateTypeIdStr = XMLUtil.getAttribute(templateTypeNode, "id");
        UUID templateTypeId = DataAccessFactory.getInstance().createUUID(templateTypeIdStr);

        if (allTemplateTypeMap.get(templateTypeId) == null) {
          List<Template> templateTypeList = das.queryTemplates(templateTypeId);
          for (Template template : templateTypeList) {
            allTemplateMap.put(template.getId(), template);
          }
        }
        templateList.addAll(allTemplateTypeMap.get(templateTypeId));
      } else {
        for (Node templateNode : templateNodeList) {
          String templateIdStr = XMLUtil.getAttribute(templateNode, "id");
          UUID templateId = DataAccessFactory.getInstance().createUUID(templateIdStr);

          if (allTemplateMap.get(templateId) == null) {
            Template tmp = das.queryTemplate(templateId);
            allTemplateMap.put(templateId, tmp);
          }
          Template template = allTemplateMap.get(templateId);
          if (template != null) {
            templateList.add(template);
          }
        }
      }

      boolean filterAllow = false;

      for (Template template : templateList) {
        if (templateAllowMap.containsKey(template.getId())) {
          if (templateAllowMap.get(template.getId())) {
            filterAllow = true;
            break;
          }

          continue;
        }

        if (allFlowMap.get(template.getFlowId()) == null) {
          Flow tmp = das.queryFlow(template.getFlowId());
          allFlowMap.put(template.getFlowId(), tmp);
        }

        Flow flow = allFlowMap.get(template.getFlowId());

        if (flow == null) {
          templateAllowMap.put(template.getId(), false);
          continue;
        }

        Role[] roleArray = flow.queryUserNodeRoles(user, template.getId());
        if (roleArray != null && roleArray.length > 0) {
          filterAllow = true;
          templateAllowMap.put(template.getId(), true);
          break;
        }

        if (flow.isActionEveryoneRole(Action.readUUID)
            || flow.isActionEveryoneRole(Action.editUUID)) {
          filterAllow = true;
          templateAllowMap.put(template.getId(), true);
          break;
        }

        Action[] actionArray = flow.getActions();
        if (actionArray != null) {
          for (Action action : actionArray) {
            if (flow.isActionEveryoneRole(action.getId())) {
              filterAllow = true;
              templateAllowMap.put(template.getId(), true);
              break;
            }
          }
        }

        if (filterAllow) {
          break;
        }

        templateAllowMap.put(template.getId(), false);
      }

      if (!filterAllow) filterItr.remove();
    }

    return filterList.toArray(new Filter[filterList.size()]);
  }
 public Filter creatTempFilter(String createUser, Timestamp createTime, UUID fatherId) {
   UUID id = DataAccessFactory.getInstance().createUUID("0");
   return new FilterImpl(id, createUser, createTime, fatherId);
 }
/** @author jinjing */
public class FilterAccessSessionMySQL {
  private static DataAccessSession das = DataAccessFactory.getInstance().getSysDas();

  public FilterAccessSessionMySQL() {}

  public Filter addFilter(Filter filter) {
    Filter newFilter = null;
    PreparedStatement pstm = null;
    Connection conn = null;
    try {
      conn = DbPoolConnection.getInstance().getConnection();
      pstm =
          conn.prepareStatement(
              "INSERT INTO filter"
                  + " SET id = ?"
                  + ", name = ?"
                  + ", xml = ?"
                  + ", create_user = ?"
                  + ", create_time = ?"
                  + ", is_and = ?"
                  + ", is_public = ?"
                  + ", is_visible = ?"
                  + ", father_id = ?");

      pstm.setLong(1, Long.parseLong(filter.getId().getValue()));
      pstm.setString(2, filter.getName());
      pstm.setString(3, filter.getXml());
      pstm.setString(4, filter.getCreateUser());
      pstm.setTimestamp(5, filter.getCreateTime());
      pstm.setBoolean(6, filter.isAnd());
      pstm.setBoolean(7, filter.isPublic());
      pstm.setBoolean(8, filter.isVisible());

      if (filter.getFatherId() != null)
        pstm.setLong(9, Long.parseLong(filter.getFatherId().getValue()));
      else pstm.setNull(9, java.sql.Types.NULL);

      pstm.executeUpdate();
      newFilter = filter;
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    return newFilter;
  }

  public Filter[] queryFilters(String user) {
    DataAccessSession das = DataAccessFactory.getInstance().getSysDas();

    List<Filter> filterList = new ArrayList<Filter>();

    PreparedStatement pstm = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
      conn = DbPoolConnection.getInstance().getReadConnection();
      pstm =
          conn.prepareStatement(
              "SELECT * FROM filter WHERE (create_user = ? OR is_public = true AND create_user != ?)"
                  + " AND father_id IS NULL AND is_valid = true ORDER BY name");
      pstm.setString(1, user);
      pstm.setString(2, DataAccessFactory.sysUser);

      rs = pstm.executeQuery();
      while (rs.next()) {
        UUID id = DataAccessFactory.getInstance().createUUID(rs.getObject("id").toString());
        String createUser = rs.getString("create_user");
        Timestamp createTime = rs.getTimestamp("create_time");

        Filter filter = new FilterImpl(id, createUser, createTime, null);
        filter.setName(rs.getString("name"));
        filter.setXml(rs.getString("xml"));
        filter.setAnd(rs.getBoolean("is_and"));
        filter.setPublic(rs.getBoolean("is_public"));
        filter.setVisible(rs.getBoolean("is_visible"));

        filterList.add(filter);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbPoolConnection.getInstance().closeResultSet(rs);
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    Map<UUID, Boolean> templateAllowMap = new HashMap<UUID, Boolean>();
    Map<UUID, List<Template>> allTemplateTypeMap = new HashMap<UUID, List<Template>>();
    Map<UUID, Template> allTemplateMap = new HashMap<UUID, Template>();
    Map<UUID, Flow> allFlowMap = new HashMap<UUID, Flow>();

    Iterator<Filter> filterItr = filterList.iterator();
    while (filterItr.hasNext()) {
      Filter filter = filterItr.next();

      Document xmlDoc = null;
      try {
        xmlDoc = XMLUtil.string2Document(filter.getXml(), "UTF-8");
      } catch (Exception e) {
        e.printStackTrace();
        System.err.println("error filter id: " + filter.getId());
      }

      if (xmlDoc == null) {
        filterItr.remove();
        continue;
      }

      Node queryNode = XMLUtil.getSingleNode(xmlDoc, "query");
      Node templateTypeNode = XMLUtil.getSingleNode(queryNode, "templateType");
      List<Node> templateNodeList = XMLUtil.getNodes(queryNode, "template");

      List<Template> templateList = new ArrayList<Template>();

      if (templateNodeList.size() == 0) {
        String templateTypeIdStr = XMLUtil.getAttribute(templateTypeNode, "id");
        UUID templateTypeId = DataAccessFactory.getInstance().createUUID(templateTypeIdStr);

        if (allTemplateTypeMap.get(templateTypeId) == null) {
          List<Template> templateTypeList = das.queryTemplates(templateTypeId);
          for (Template template : templateTypeList) {
            allTemplateMap.put(template.getId(), template);
          }
        }
        templateList.addAll(allTemplateTypeMap.get(templateTypeId));
      } else {
        for (Node templateNode : templateNodeList) {
          String templateIdStr = XMLUtil.getAttribute(templateNode, "id");
          UUID templateId = DataAccessFactory.getInstance().createUUID(templateIdStr);

          if (allTemplateMap.get(templateId) == null) {
            Template tmp = das.queryTemplate(templateId);
            allTemplateMap.put(templateId, tmp);
          }
          Template template = allTemplateMap.get(templateId);
          if (template != null) {
            templateList.add(template);
          }
        }
      }

      boolean filterAllow = false;

      for (Template template : templateList) {
        if (templateAllowMap.containsKey(template.getId())) {
          if (templateAllowMap.get(template.getId())) {
            filterAllow = true;
            break;
          }

          continue;
        }

        if (allFlowMap.get(template.getFlowId()) == null) {
          Flow tmp = das.queryFlow(template.getFlowId());
          allFlowMap.put(template.getFlowId(), tmp);
        }

        Flow flow = allFlowMap.get(template.getFlowId());

        if (flow == null) {
          templateAllowMap.put(template.getId(), false);
          continue;
        }

        Role[] roleArray = flow.queryUserNodeRoles(user, template.getId());
        if (roleArray != null && roleArray.length > 0) {
          filterAllow = true;
          templateAllowMap.put(template.getId(), true);
          break;
        }

        if (flow.isActionEveryoneRole(Action.readUUID)
            || flow.isActionEveryoneRole(Action.editUUID)) {
          filterAllow = true;
          templateAllowMap.put(template.getId(), true);
          break;
        }

        Action[] actionArray = flow.getActions();
        if (actionArray != null) {
          for (Action action : actionArray) {
            if (flow.isActionEveryoneRole(action.getId())) {
              filterAllow = true;
              templateAllowMap.put(template.getId(), true);
              break;
            }
          }
        }

        if (filterAllow) {
          break;
        }

        templateAllowMap.put(template.getId(), false);
      }

      if (!filterAllow) filterItr.remove();
    }

    return filterList.toArray(new Filter[filterList.size()]);
  }

  public Map<String, String> getFilterIdNameMap(String userName) {
    Map<String, String> idNameMap = new HashMap<String, String>();

    PreparedStatement pstm = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
      conn = DbPoolConnection.getInstance().getReadConnection();
      pstm =
          conn.prepareStatement(
              "SELECT id,name FROM filter WHERE create_user = ? and xml !=null order by name");
      pstm.setString(1, userName);
      rs = pstm.executeQuery();
      while (rs.next()) {
        idNameMap.put(rs.getString("id"), rs.getString("name"));
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbPoolConnection.getInstance().closeAll(rs, pstm, conn);
    }
    return idNameMap;
  }

  public Filter[] querySysFilters(String user, DataAccessSession das) {
    List<Filter> filterList = new ArrayList<Filter>();

    PreparedStatement pstm = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
      conn = DbPoolConnection.getInstance().getReadConnection();
      pstm = conn.prepareStatement("SELECT * FROM filter WHERE create_user = ?");
      pstm.setString(1, DataAccessFactory.sysUser);
      rs = pstm.executeQuery();
      while (rs.next()) {
        UUID id = DataAccessFactory.getInstance().createUUID(Long.toString(rs.getLong("id")));
        Timestamp createTime = rs.getTimestamp("create_time");

        Filter filter = new FilterImpl(id, DataAccessFactory.sysUser, createTime, null);
        filter.setName(rs.getString("name"));
        filter.setXml(rs.getString("xml"));
        filter.setAnd(rs.getBoolean("is_and"));
        filter.setPublic(rs.getBoolean("is_public"));
        filter.setVisible(rs.getBoolean("is_visible"));

        filterList.add(filter);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {

      DbPoolConnection.getInstance().closeResultSet(rs);
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    return filterList.toArray(new Filter[filterList.size()]);
  }

  public List<Filter> queryAllFilters() {
    List<Filter> filterList = new ArrayList<Filter>();
    PreparedStatement pstm = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
      conn = DbPoolConnection.getInstance().getReadConnection();
      pstm = conn.prepareStatement("SELECT * FROM filter WHERE is_valid = true");
      rs = pstm.executeQuery();
      while (rs.next()) {
        UUID id = DataAccessFactory.getInstance().createUUID(Long.toString(rs.getLong("id")));
        Timestamp createTime = rs.getTimestamp("create_time");
        String createUser = rs.getString("create_user");
        Filter filter = new FilterImpl(id, createUser, createTime, null);
        filter.setName(rs.getString("name"));
        filter.setXml(rs.getString("xml"));
        filter.setAnd(rs.getBoolean("is_and"));
        filter.setPublic(rs.getBoolean("is_public"));
        filter.setVisible(rs.getBoolean("is_visible"));
        filterList.add(filter);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbPoolConnection.getInstance().closeResultSet(rs);
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    return filterList;
  }

  public Filter[] queryFocusFilters(String user, DataAccessSession das) {
    List<Filter> filterList = new ArrayList<Filter>();
    PreparedStatement pstm = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
      conn = DbPoolConnection.getInstance().getReadConnection();
      pstm =
          conn.prepareStatement(
              "SELECT * FROM  filter WHERE is_valid = true AND (create_user = ? OR is_public = true AND create_user != ?)"
                  + " AND father_id IS NULL AND id IN(SELECT filter_id FROM user_focus_filter where user = ?)  ORDER BY name");
      pstm.setString(1, user);
      pstm.setString(2, DataAccessFactory.sysUser);
      pstm.setString(3, user);

      rs = pstm.executeQuery();
      while (rs.next()) {
        UUID id = DataAccessFactory.getInstance().createUUID(Long.toString(rs.getLong("id")));
        String createUser = rs.getString("create_user");
        Timestamp createTime = rs.getTimestamp("create_time");

        Filter filter = new FilterImpl(id, createUser, createTime, null);
        filter.setName(rs.getString("name"));
        filter.setXml(rs.getString("xml"));
        filter.setAnd(rs.getBoolean("is_and"));
        filter.setPublic(rs.getBoolean("is_public"));
        filter.setVisible(rs.getBoolean("is_visible"));

        filterList.add(filter);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbPoolConnection.getInstance().closeResultSet(rs);
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    // 暂时不需要验证权限
    /*
    Map<UUID, Boolean> templateAllowMap = new HashMap<UUID, Boolean>();

    Iterator<Filter> filterItr = filterList.iterator();
    while(filterItr.hasNext()){
    	Filter filter = filterItr.next();

    	if(filter.getXml()==null||"".endsWith(filter.getXml()))
    	{//add by lyl for filter init
    		continue;
    	}
    	Document xmlDoc = null;
    	try{
    		xmlDoc = XMLUtil.string2Document(filter.getXml(), "UTF-8");
    	}
    	catch(Exception e){
    		e.printStackTrace();
    		System.err.println("error filter id: " + filter.getId());
    	}

    	if(xmlDoc == null){
    		filterItr.remove();
    		continue;
    	}

    	Node queryNode = XMLUtil.getSingleNode(xmlDoc, "query");
    	Node templateTypeNode = XMLUtil.getSingleNode(queryNode, "templateType");
    	List<Node> templateNodeList = XMLUtil.getNodes(queryNode, "template");

    	List<Template> templateList = new ArrayList<Template>();

    	if(templateNodeList.size() == 0){
    		String templateTypeIdStr = XMLUtil.getAttribute(templateTypeNode, "id");
    		UUID templateTypeId = DataAccessFactory.getInstance().createUUID(templateTypeIdStr);

    		templateList.addAll(das.queryTemplates(templateTypeId));
    	}
    	else{
    		for(Node templateNode : templateNodeList){
    			String templateIdStr = XMLUtil.getAttribute(templateNode, "id");
    			UUID templateId = DataAccessFactory.getInstance().createUUID(templateIdStr);

    			Template template = das.queryTemplate(templateId);
    			if(template != null){
    				templateList.add(template);
    			}
    		}
    	}

    	boolean filterAllow = false;

    	for(Template template : templateList){
    		if(templateAllowMap.containsKey(template.getId())){
    			if(templateAllowMap.get(template.getId())){
    				filterAllow = true;
    				break;
    			}

    			continue;
    		}

    		Flow flow = das.queryFlow(template.getFlowId());
    		if(flow == null){
    			templateAllowMap.put(template.getId(), false);
    			continue;
    		}

    		Role[] roleArray = flow.queryUserNodeRoles(user, template.getNodeId());
    		if(roleArray != null && roleArray.length > 0){
    			filterAllow = true;
    			templateAllowMap.put(template.getId(), true);
    			break;
    		}

    		if(flow.isActionEveryoneRole(Action.readUUID) || flow.isActionEveryoneRole(Action.editUUID)){
    			filterAllow = true;
    			templateAllowMap.put(template.getId(), true);
    			break;
    		}

    		Action[] actionArray = flow.getActions();
    		if(actionArray != null){
    			for(Action action : actionArray){
    				if(flow.isActionEveryoneRole(action.getId())){
    					filterAllow = true;
    					templateAllowMap.put(template.getId(), true);
    					break;
    				}
    			}
    		}

    		if(filterAllow){
    			break;
    		}

    		templateAllowMap.put(template.getId(), false);
    	}

    	if(!filterAllow)
    		filterItr.remove();
    }
    */
    return filterList.toArray(new Filter[filterList.size()]);
  }

  public Map<String, String> queryFilterIdAndName(String userName) {
    Map<String, String> idNameMap = new LinkedHashMap<String, String>();
    Statement stat = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
      conn = DbPoolConnection.getInstance().getReadConnection();
      stat = conn.createStatement();

      String sql = "select id ,name from filter where is_valid=1 ";
      if (userName != null && userName.length() > 0) {
        sql +=
            " and id in (select DISTINCT filter_id from user_focus_filter where user = '******') ";
      }
      sql += " order by name";

      rs = stat.executeQuery(sql);
      while (rs.next()) {
        idNameMap.put(rs.getString("id"), rs.getString("name"));
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbPoolConnection.getInstance().closeAll(rs, stat, conn);
    }

    // 添加系统过滤器
    idNameMap.putAll(ConfigUtil.allSysFilterMap);

    return idNameMap;
  }

  public Filter queryFilter(UUID id) {
    if (id == null) {
      return null;
    }
    Filter filter = null;

    PreparedStatement pstm = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
      conn = DbPoolConnection.getInstance().getReadConnection();
      pstm = conn.prepareStatement("SELECT * FROM filter" + " WHERE id = ?");
      pstm.setLong(1, Long.parseLong(id.getValue()));

      rs = pstm.executeQuery();
      if (rs.next()) {
        String createUser = rs.getString("create_user");
        Timestamp createTime = rs.getTimestamp("create_time");
        UUID fatherId = null;
        if (rs.getObject("father_id") != null)
          fatherId =
              DataAccessFactory.getInstance().createUUID(rs.getObject("father_id").toString());

        filter = new FilterImpl(id, createUser, createTime, fatherId);
        filter.setName(rs.getString("name"));
        filter.setXml(rs.getString("xml"));
        filter.setAnd(rs.getBoolean("is_and"));
        filter.setPublic(rs.getBoolean("is_public"));
        filter.setVisible(rs.getBoolean("is_visible"));
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbPoolConnection.getInstance().closeResultSet(rs);
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    return filter;
  }

  public ErrorCode removeFilter(UUID id) {
    ErrorCode errorCode = ErrorCode.unknownFail;

    PreparedStatement pstm = null;
    Connection conn = null;
    try {
      conn = DbPoolConnection.getInstance().getConnection();
      pstm = conn.prepareStatement("DELETE FROM filter" + " WHERE id = ?");
      pstm.setLong(1, Long.parseLong(id.getValue()));

      if (pstm.executeUpdate() > 0) errorCode = ErrorCode.success;
    } catch (Exception e) {
      e.printStackTrace();
      errorCode = ErrorCode.dbFail;
    } finally {
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    return errorCode;
  }

  public ErrorCode updateFilter(Filter filter) {
    ErrorCode errorCode = ErrorCode.unknownFail;

    PreparedStatement pstm = null;
    Connection conn = null;

    try {
      conn = DbPoolConnection.getInstance().getConnection();
      pstm =
          conn.prepareStatement(
              "update filter"
                  + " SET	name = ?"
                  + ", xml = ?"
                  + ", is_and = ?"
                  + ", is_public = ?"
                  + ", is_visible = ?"
                  + ", is_valid = ?"
                  + " WHERE id = ?");
      pstm.setString(1, filter.getName());
      pstm.setString(2, filter.getXml());
      pstm.setBoolean(3, filter.isAnd());
      pstm.setBoolean(4, filter.isPublic());
      pstm.setBoolean(5, filter.isVisible());
      pstm.setBoolean(6, filter.isValid());
      pstm.setLong(7, Long.parseLong(filter.getId().getValue()));

      if (pstm.executeUpdate() > 0) errorCode = ErrorCode.success;

    } catch (Exception e) {
      e.printStackTrace();
      errorCode = ErrorCode.dbFail;
    } finally {
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    return errorCode;
  }

  public Filter createFilter(String createUser, Timestamp createTime, UUID fatherId) {
    UUID id = DataAccessFactory.getInstance().newUUID("FILT");
    return new FilterImpl(id, createUser, createTime, fatherId);
  }

  public Filter creatTempFilter(String createUser, Timestamp createTime, UUID fatherId) {
    UUID id = DataAccessFactory.getInstance().createUUID("0");
    return new FilterImpl(id, createUser, createTime, fatherId);
  }

  public UUID[] queryUserFocusFilters(String user) {
    Set<UUID> filterIdSet = new LinkedHashSet<UUID>();
    PreparedStatement pstm = null;
    ResultSet rs = null;
    Connection conn = null;
    try {
      conn = DbPoolConnection.getInstance().getReadConnection();
      pstm = conn.prepareStatement("SELECT filter_id FROM user_focus_filter" + " WHERE user = ?");
      pstm.setString(1, user);

      rs = pstm.executeQuery();
      while (rs.next()) {
        UUID id = DataAccessFactory.getInstance().createUUID(rs.getObject("filter_id").toString());
        filterIdSet.add(id);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbPoolConnection.getInstance().closeResultSet(rs);
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    return filterIdSet.toArray(new UUID[0]);
  }

  public ErrorCode removeFilterFocusUser(UUID filterId) {
    ErrorCode errorCode = ErrorCode.unknownFail;

    PreparedStatement pstm = null;
    Connection conn = null;
    try {
      conn = DbPoolConnection.getInstance().getConnection();
      pstm = conn.prepareStatement("DELETE FROM user_focus_filter" + " WHERE filter_id = ?");
      pstm.setLong(1, Long.parseLong(filterId.getValue()));

      pstm.executeUpdate();
      errorCode = ErrorCode.success;
    } catch (Exception e) {
      e.printStackTrace();
      errorCode = ErrorCode.dbFail;
    } finally {
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    return errorCode;
  }

  public ErrorCode removeUserFocusFilter(String user, UUID filterId) {
    ErrorCode errorCode = ErrorCode.unknownFail;

    PreparedStatement pstm = null;
    Connection conn = null;
    try {
      conn = DbPoolConnection.getInstance().getConnection();
      pstm =
          conn.prepareStatement(
              "DELETE FROM user_focus_filter" + " WHERE user = ? AND filter_id = ?");
      pstm.setString(1, user);
      pstm.setLong(2, Long.parseLong(filterId.getValue()));

      if (pstm.executeUpdate() > 0) errorCode = ErrorCode.success;
    } catch (Exception e) {
      e.printStackTrace();
      errorCode = ErrorCode.dbFail;
    } finally {
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    return errorCode;
  }

  public ErrorCode addUserFocusFilter(String user, UUID filterId) {
    ErrorCode errorCode = ErrorCode.unknownFail;

    PreparedStatement pstm = null;
    Connection conn = null;

    try {
      conn = DbPoolConnection.getInstance().getConnection();
      pstm = conn.prepareStatement("INSERT INTO user_focus_filter SET user = ?, filter_id = ?");
      pstm.setString(1, user);
      pstm.setLong(2, Long.parseLong(filterId.getValue()));

      if (pstm.executeUpdate() > 0) errorCode = ErrorCode.success;

    } catch (Exception e) {
      e.printStackTrace();

      errorCode = ErrorCode.dbFail;
    } finally {
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    return errorCode;
  }

  //	public HashMap<String,String> queryAllValidRelateUsers()
  //	{
  //		PreparedStatement pstm = null;
  //		Connection conn = null;
  //		ResultSet rs = null;
  //		Map<String,String> relatedUserMap = new HashMap<String,String>();
  //		try
  //		{
  //			conn = DbPoolConnection.getInstance().getReadConnection();
  //			pstm = conn.prepareStatement("SELECT * FROM user_info"
  //					+ " WHERE isValid = ?");
  //			pstm.setInt(1, 1);
  //
  //			rs = pstm.executeQuery();
  //			while(rs.next())
  //			{
  //				String relatedUser = rs.getString("nick_name");
  //				String email = rs.getString("user_name");
  //				relatedUserMap.put(email, relatedUser);
  //			}
  //		}
  //		catch(Exception e)
  //		{
  //			e.printStackTrace();
  //		}
  //		finally
  //		{
  //			DbPoolConnection.getInstance().closeResultSet(rs);
  //			DbPoolConnection.getInstance().closeStatment(pstm);
  //			DbPoolConnection.getInstance().closeConn(conn);
  //		}
  //
  //		return (HashMap<String, String>) relatedUserMap;
  //	}
  //
  //	public HashMap<String,String> queryValidRelatedUser(String email)
  //	{
  //		PreparedStatement pstm = null;
  //		Connection conn        = null;
  //		ResultSet rs = null;
  //		//Set<String> relatedUserSet = new LinkedHashSet<String>();
  //		Map<String,String>relatedUserMap = new HashMap<String,String>();
  //		try
  //		{
  //			conn = DbPoolConnection.getInstance().getReadConnection();
  //			pstm = conn.prepareStatement("SELECT * FROM user_info"
  //					+ " WHERE isValid = ? and user_name = ?");
  //			pstm.setInt(1, 1);
  //			pstm.setString(2, email);
  //
  //			rs = pstm.executeQuery();
  //			while(rs.next())
  //			{
  //				String relatedUser = rs.getString("nick_name");
  //				relatedUserMap.put(email, relatedUser);
  //			}
  //		}
  //		catch(Exception e)
  //		{
  //			e.printStackTrace();
  //		}
  //		finally
  //		{
  //			DbPoolConnection.getInstance().closeResultSet(rs);
  //			DbPoolConnection.getInstance().closeStatment(pstm);
  //			DbPoolConnection.getInstance().closeConn(conn);
  //		}
  //
  //		return (HashMap<String, String>) relatedUserMap;
  //	}

  //	public String[] queryRelatedUsers(String user)
  //	{
  //		PreparedStatement pstm = null;
  //		Connection conn = null;
  //		ResultSet rs = null;
  //		Set<String> relatedUserSet = new LinkedHashSet<String>();
  //		try
  //		{
  //			conn = DbPoolConnection.getInstance().getReadConnection();
  //			pstm = conn.prepareStatement("SELECT * FROM user_info"
  //					+ " WHERE user_name = ?");
  //			pstm.setString(1, user);
  //
  //			rs = pstm.executeQuery();
  //			while(rs.next())
  //			{
  //				String relatedUser = rs.getString("nick_name");
  //				relatedUserSet.add(relatedUser);
  //			}
  //		}
  //		catch(Exception e)
  //		{
  //			e.printStackTrace();
  //		}
  //		finally
  //		{
  //			DbPoolConnection.getInstance().closeResultSet(rs);
  //			DbPoolConnection.getInstance().closeStatment(pstm);
  //			DbPoolConnection.getInstance().closeConn(conn);
  //		}
  //
  //		return relatedUserSet.toArray(new String[0]);
  //	}
  //
  //	public ErrorCode updateUser(String user,String relatedUser)
  //	{
  //		ErrorCode errorCode = ErrorCode.unknownFail;
  //
  //		PreparedStatement pstm = null;
  //		Connection conn = null;
  //		try
  //		{
  //			conn = DbPoolConnection.getInstance().getConnection();
  //			pstm = conn.prepareStatement("update user_info"
  //					+ " SET nick_name = ? where user_name = ?");
  //			pstm.setString(1, relatedUser);
  //			pstm.setString(2, user);
  //
  //			if(pstm.executeUpdate() >0)
  //				errorCode = ErrorCode.success;
  //
  //		}
  //		catch(Exception e)
  //		{
  //			e.printStackTrace();
  //
  //			errorCode = ErrorCode.dbFail;
  //		}
  //		finally
  //		{
  //			DbPoolConnection.getInstance().closeStatment(pstm);
  //			DbPoolConnection.getInstance().closeConn(conn);
  //		}
  //
  //		return errorCode;
  //	}
  //
  //	public ErrorCode removeValidRelatedUser(String user,String relatedUser)
  //	{
  //		ErrorCode errorCode = ErrorCode.unknownFail;
  //
  //		PreparedStatement pstm = null;
  //		Connection conn = null;
  //		try
  //		{
  //			conn = DbPoolConnection.getInstance().getConnection();
  //			pstm = conn.prepareStatement("update user_info"
  //					+ " set isValid = ? WHERE user_name = ? AND nick_name = ?");
  //			pstm.setInt(1, 0);
  //			pstm.setString(2, user);
  //			pstm.setString(3, relatedUser);
  //			pstm.execute();
  //			errorCode = ErrorCode.success;
  //		}
  //		catch(Exception e)
  //		{
  //			e.printStackTrace();
  //
  //			errorCode = ErrorCode.dbFail;
  //		}
  //		finally
  //		{
  //			DbPoolConnection.getInstance().closeStatment(pstm);
  //			DbPoolConnection.getInstance().closeConn(conn);
  //		}
  //
  //		return errorCode;
  //	}
  //
  //	public ErrorCode addRelatedUser(String user, String relatedUser)
  //	{
  //		ErrorCode errorCode = ErrorCode.unknownFail;
  //		PreparedStatement pstm = null;
  //		Connection conn = null;
  //		try
  //		{
  //			conn = DbPoolConnection.getInstance().getConnection();
  //			pstm = conn.prepareStatement("INSERT INTO user_info"
  //					+ " SET user_name = ?, nick_name = ?");
  //			pstm.setString(1, user);
  //			pstm.setString(2, relatedUser);
  //			if(pstm.executeUpdate()>0)
  //				errorCode = ErrorCode.success;
  //		}
  //		catch(Exception e)
  //		{
  //			e.printStackTrace();
  //			errorCode = ErrorCode.dbFail;
  //		}
  //		finally
  //		{
  //			DbPoolConnection.getInstance().closeStatment(pstm);
  //			DbPoolConnection.getInstance().closeConn(conn);
  //		}
  //
  //		return errorCode;
  //	}
  //
  //	public ErrorCode removeRelatedUser(String user, String relatedUser)
  //	{
  //		ErrorCode errorCode = ErrorCode.unknownFail;
  //		PreparedStatement pstm = null;
  //		Connection conn = null;
  //		try
  //		{
  //			conn = DbPoolConnection.getInstance().getConnection();
  //			pstm = conn.prepareStatement("DELETE FROM user_info"
  //					+ " WHERE user_name = ? AND nick_name = ?");
  //			pstm.setString(1, user);
  //			pstm.setString(2, relatedUser);
  //
  //			if(pstm.executeUpdate() > 0)
  //				errorCode = ErrorCode.success;
  //
  //		}
  //		catch(Exception e)
  //		{
  //			e.printStackTrace();
  //			errorCode = ErrorCode.dbFail;
  //		}
  //		finally
  //		{
  //			DbPoolConnection.getInstance().closeStatment(pstm);
  //			DbPoolConnection.getInstance().closeConn(conn);
  //		}
  //
  //		return errorCode;
  //	}
  //

  public List<String> queryFocusUsersByFilter(UUID filterId) {
    List<String> userList = new ArrayList<String>();
    PreparedStatement pstm = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
      conn = DbPoolConnection.getInstance().getReadConnection();
      pstm = conn.prepareStatement("SELECT USER FROM user_focus_filter where filter_id=?");
      pstm.setLong(1, Long.parseLong(filterId.getValue()));
      rs = pstm.executeQuery();
      while (rs.next()) {
        userList.add(rs.getString("user"));
      }

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DbPoolConnection.getInstance().closeResultSet(rs);
      DbPoolConnection.getInstance().closeStatment(pstm);
      DbPoolConnection.getInstance().closeConn(conn);
    }

    return userList;
  }
}