예제 #1
0
  @Override
  public List<User> searchNotFollowingByAnyNameLike(String keyword, int userId)
      throws DAOException {
    List<User> userNotFollowingList = new ArrayList<>();

    try {
      String sqlKeyword = "%" + keyword + "%";
      ResultSet resultSet =
          this.executeQuery(
              SQL_SEARCH_NOT_FOLLOWING_USER_BY_ANYNAME_LIKE,
              false,
              sqlKeyword,
              sqlKeyword,
              sqlKeyword,
              userId,
              userId);
      while (resultSet.next()) {
        EntityMapping<User> EntityMapping = new EntityMapping<>(User.class);
        userNotFollowingList.add(EntityMapping.getMapping(resultSet));
      }
    } catch (Exception e) {
      throw new DAOException(e);
    } finally {
      this.CloseConnection();
    }

    return userNotFollowingList;
  }
예제 #2
0
  @Override
  public List<TweetOut> getTweetOutList(User user) throws DAOException {
    List<TweetOut> lstTweetOut = new ArrayList<>();
    try {
      ResultSet resultSet =
          this.executeQuery(
              SQL_SELECTTWEETOUT,
              false,
              user.getUserId(),
              user.getUserId(),
              user.getUserId(),
              user.getUserId(),
              user.getUserId(),
              user.getUserId());
      Pattern pat = Pattern.compile("@([\\w]+)");
      while (resultSet.next()) {
        EntityMapping<TweetOut> EntityMapping = new EntityMapping<>(TweetOut.class);
        try {
          TweetOut tmpTweetOut = EntityMapping.getMapping(resultSet);
          Matcher match = pat.matcher(tmpTweetOut.getBody());

          if (match.find()) {
            String action = match.group(1);
            DAOUser daoUser = new DAOUser(DAOFactory.getInstance());
            User user1 = daoUser.searchByUserName(action);
            tmpTweetOut.setBody(
                Jsoup.parse(tmpTweetOut.getBody())
                    .text()
                    .replace(
                        "@" + action,
                        "<a class=\"\" href=\"/User?id="
                            + user1.getUserId()
                            + "\"><strong class=\"center-middle-txt\">@"
                            + action
                            + "</strong></a>"));
          } else {
            tmpTweetOut.setBody(Jsoup.parse(tmpTweetOut.getBody()).text());
          }
          lstTweetOut.add(tmpTweetOut);
        } catch (Exception e) {
          throw new DAOException(e);
        }
      }
    } catch (Exception e) {
      throw new DAOException(e);
    } finally {
      this.CloseConnection();
    }
    return lstTweetOut;
  }
예제 #3
0
 @Override
 public User loginSearch(String pUserName, String pPassword) throws DAOException {
   User user = null;
   try {
     ResultSet resultSet = this.executeQuery(SQL_LOGIN_USER, false, pUserName, pPassword);
     if (resultSet.next()) {
       EntityMapping<User> EntityMapping = new EntityMapping<>(User.class);
       user = EntityMapping.getMapping(resultSet);
     }
   } catch (Exception e) {
     throw new DAOException(e);
   } finally {
     this.CloseConnection();
   }
   return user;
 }
예제 #4
0
 @Override
 public User searchByUserName(String userName) throws DAOException {
   User user = null;
   try {
     ResultSet resultSet = this.executeQuery(SQL_SEARCH_USER_BY_USERNAME, false, userName);
     if (resultSet.next()) {
       EntityMapping<User> EntityMapping = new EntityMapping<>(User.class);
       user = EntityMapping.getMapping(resultSet);
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     this.CloseConnection();
   }
   return user;
 }
예제 #5
0
  @Override
  public User searchByEmail(String email) throws DAOException {
    User user = null;

    try {
      ResultSet resultSet = this.executeQuery(SQL_SEARCH_USER_BY_EMAIL, false, email);
      if (resultSet.next()) {
        EntityMapping<User> EntityMapping = new EntityMapping<>(User.class);
        user = EntityMapping.getMapping(resultSet);
      }
    } catch (Exception e) {
      throw new DAOException(e);
    } finally {
      this.CloseConnection();
    }

    return user;
  }
예제 #6
0
  public Dashboard getDashboard(User user) throws DAOException {
    Dashboard dashboard = null;

    try {
      ResultSet resultSet =
          this.executeQuery(
              DASHBOARD_USER, false, user.getUserId(), user.getUserId(), user.getUserId());
      if (resultSet.next()) {
        EntityMapping<Dashboard> EntityMapping = new EntityMapping<>(Dashboard.class);
        dashboard = EntityMapping.getMapping(resultSet);
        dashboard.setUser(user);
      }
    } catch (Exception ex) {
      throw new DAOException(ex);
    } finally {
      this.CloseConnection();
    }
    return dashboard;
  }
예제 #7
0
  @Override
  public User searchById(int userId, User currentUser) throws DAOException {
    User user = null;

    try {
      ResultSet resultSet =
          this.executeQuery(
              SQL_SEARCH_USER_BY_ID_AND_CURRENT_USER,
              false,
              userId,
              userId,
              currentUser.getUserId());
      if (resultSet.next()) {
        EntityMapping<User> EntityMapping = new EntityMapping<>(User.class);
        user = EntityMapping.getMapping(resultSet);
      }
    } catch (Exception e) {
      throw new DAOException(e);
    } finally {
      this.CloseConnection();
    }

    return user;
  }