@Test
  public void getForumsByUserId() {
    User user = new User();
    user.setPassword("1");
    user.setEmail("a");
    user.setRegistrationDate(new Date());
    persistance.putUser(user);

    Site site = new Site();
    site.getSitePaymentSettings().setUserId(-1);
    site.setSubDomain("$");
    site.getThemeId().setTemplateDirectory("f");
    site.getThemeId().setThemeCss("G");
    site.setTitle("F");
    persistance.putSite(site);

    UserOnSiteRight userOnUserRight = new UserOnSiteRight();
    userOnUserRight.setActive(true);
    userOnUserRight.setSiteAccessType(SiteAccessLevel.ADMINISTRATOR);
    user.addUserOnSiteRight(userOnUserRight);
    site.addUserOnSiteRight(userOnUserRight);
    persistance.putUserOnSiteRight(userOnUserRight);

    DraftForum forum = new DraftForum();
    forum.setSiteId(site.getSiteId());
    forum.setName("name");
    persistance.putItem(forum);

    List<DraftItem> userForums =
        persistance.getDraftItemsByUserId(user.getUserId(), ItemType.FORUM);
    Assert.assertEquals(forum, userForums.get(0));
  }
Exemplo n.º 2
0
  /** Web service operation */
  @WebMethod(operationName = "getUserByToken")
  @WebResult(name = "User")
  public User getUserByToken(@WebParam(name = "token") String token) {
    User user = new User();
    try {
      Statement stmt = conn.createStatement();
      String sql;
      sql = "SELECT user_id FROM token WHERE token_id = ?";
      PreparedStatement dbStatement = conn.prepareStatement(sql);
      dbStatement.setString(1, token);
      ResultSet rs = dbStatement.executeQuery();

      while (rs.next()) {
        user.setUserID(rs.getInt("user_id"));
      }
      rs.close();

      String sql2 = "SELECT * FROM user WHERE user_id = ?";
      PreparedStatement dbStatement2 = conn.prepareStatement(sql);
      dbStatement2.setInt(1, user.getUserID());
      ResultSet rs2 = dbStatement2.executeQuery();

      while (rs2.next()) {
        user.setName(rs.getString("name"));
        user.setEmail(rs.getString("email"));
        user.setPassword(rs.getString("password"));
      }
      rs2.close();
      stmt.close();
    } catch (SQLException ex) {
      Logger.getLogger(UserWS.class.getName()).log(Level.SEVERE, null, ex);
    }

    return user;
  }
Exemplo n.º 3
0
 @Test
 public void testUpdate() throws Exception {
   user.setEmail("*****@*****.**");
   user.setPassword("changedPassword");
   user.setType(UserType.STUDENT);
   assertTrue(h2User.update(user));
 }
  @Override
  public User getUserDetails(String uname) {
    Connection con = null;
    try {
      con = DBConnectionFactory.getConnection();
      Statement st = con.createStatement();
      String sql =
          "select fname, lname, email, mobile, usertype "
              + "from user_details "
              + "where uname='"
              + uname
              + "'";
      ResultSet rs = st.executeQuery(sql);
      if (rs.next()) {
        User u = new User();
        u.setUname(uname);
        u.setFname(rs.getString(1));
        u.setLname(rs.getString(2));
        u.setEmail(rs.getString(3));
        u.setMobile(rs.getString(4));
        u.setUsertype(rs.getString(5));

        return u;
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      try {
        con.close();
      } catch (SQLException e) {
        e.printStackTrace();
      }
    }
    return null;
  }
  @Test
  public void getForumsByUserIdWithoutActive() {
    User user = new User();
    user.setPassword("1");
    user.setEmail("a");
    user.setRegistrationDate(new Date());
    persistance.putUser(user);

    Site site = new Site();
    site.getSitePaymentSettings().setUserId(-1);
    site.setSubDomain("$");
    site.getThemeId().setTemplateDirectory("f");
    site.getThemeId().setThemeCss("G");
    site.setTitle("F");
    persistance.putSite(site);

    DraftForum forum = new DraftForum();
    forum.setSiteId(site.getSiteId());
    forum.setName("name");
    persistance.putItem(forum);

    List<DraftItem> userForums =
        persistance.getDraftItemsByUserId(user.getUserId(), ItemType.FORUM);
    Assert.assertEquals(0, userForums.size());
  }
Exemplo n.º 6
0
  /**
   * Import users
   *
   * @param nodes list of users nodes (wrapper node, thus only one)
   * @return
   */
  private Boolean processUsers(NodeList nodes) {
    NodeList users = nodes.item(0).getChildNodes();

    for (int i = 0; i < users.getLength(); i++) {
      if (users.item(i).getNodeType() == Node.ELEMENT_NODE) {
        Element userNode = (Element) users.item(i);

        User user = new User();

        user.setIduser(Integer.parseInt(getTagValue("iduser", userNode)));
        user.setForename(getTagValue("forename", userNode));
        user.setSurname(getTagValue("surname", userNode));
        user.setPermitNumber(getTagValue("permitNumber", userNode));
        user.setAddress(getTagValue("address", userNode));
        user.setEmail(getTagValue("email", userNode));
        user.setRegistered(
            DatatypeConverter.parseDateTime(getTagValue("registered", userNode)).getTime());
        user.setExpire(DatatypeConverter.parseDateTime(getTagValue("expire", userNode)).getTime());
        user.setPassword(getTagValue("password", userNode));
        user.setLevel(getTagValue("level", userNode));

        try {
          userMgr.Save(user);
        } catch (EJBException ex) {
          ex.printStackTrace(System.out);
        }
      }
    }
    return true;
  }
  @OnClick(R.id.sign_up)
  public void signUpClicked(View view) {
    Utils.hideKeyboard(this);
    Utils.showProgressBar(this, progress, "Signing Up...");

    User user = new User();
    user.setSuperDefaults();
    user.setUsername(username.getText().toString().trim());
    user.setPassword(password.getText().toString().trim());
    user.setEmail(email.getText().toString().trim());
    user.setPhone(phone.getText().toString().trim());
    user.setName(name.getText().toString().trim());
    user.signUpInBackground(
        new SignUpCallback() {
          @Override
          public void done(ParseException exception) {
            Utils.hideProgressBar(progress);
            if (exception == null) {
              Toast.makeText(
                      getApplicationContext(), "Sign up done successfully", Toast.LENGTH_SHORT)
                  .show();
            } else {
              new Builder(SignUpActivity.this)
                  .setTitle(R.string.error_title)
                  .setMessage(exception.getMessage())
                  .setPositiveButton(string.ok, null)
                  .create()
                  .show();
            }
            startActivity(
                new Intent(SignUpActivity.this, MainActivity.class)
                    .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK));
          }
        });
  }
Exemplo n.º 8
0
  public User getUserDetails(String userId) {

    PreparedStatement ps = null;
    ResultSet rs = null;
    User user = null;

    RegisterService registerService = new RegisterService();

    try {

      ps = connection.prepareStatement("SELECT * FROM user WHERE username=? LIMIT 1");
      ps.setString(1, username);
      rs = ps.executeQuery();

      if (rs != null && rs.next()) {
        user = new User(userId);
        user.setFirstName(rs.getString("firstname"));
        user.setLastName(rs.getString("lastname"));
        user.setEmail(rs.getString("email"));
        user.setPhoneNumber(rs.getString("primaryPhone"));
        user.setCellphone(rs.getString("secondaryPhone"));

        user.setAddress(registerService.createAddressFromID(rs.getInt("addressID")));
        user.setCard(registerService.createCardFromID(rs.getInt("creditCardID")));
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }

    return user;
  }
  @Test
  public void getForumThreadsByUserIdWithNotFound() {
    final User user = new User();
    user.setEmail("a");
    user.setRegistrationDate(new Date());
    persistance.putUser(user);

    DraftForum forum = new DraftForum();
    forum.setName("name");
    persistance.putItem(forum);

    SubForum subForum = new SubForum();
    subForum.setSubForumName("ffff");
    subForum.setSubForumDescription("ffff1");
    forum.addSubForum(subForum);
    persistance.putSubForum(subForum);

    ForumThread forumThread1 = new ForumThread();
    forumThread1.setThreadName("f");
    forumThread1.setThreadDescription("f2");
    forumThread1.setUpdateDate(new Date());
    forumThread1.setAuthor(user);
    subForum.addForumThread(forumThread1);
    persistance.putForumThread(forumThread1);

    List<ForumThread> forumThreads = persistance.getForumThreadsByUserId(user.getUserId() + 90);
    Assert.assertEquals(0, forumThreads.size());
  }
  public PagedResult<User> readUsers(String source) throws ReviewboardException {

    try {
      JSONObject rootObject = checkedGetJSonRootObject(source);

      int totalResults = rootObject.getInt("total_results");

      JSONArray jsonUsers = rootObject.getJSONArray("users");
      List<User> users = new ArrayList<User>();

      for (int i = 0; i < jsonUsers.length(); i++) {

        JSONObject jsonUser = jsonUsers.getJSONObject(i);

        User user = new User();
        user.setId(jsonUser.getInt("id"));
        user.setUrl(jsonUser.getString("url"));
        user.setUsername(jsonUser.getString("username"));
        // some fields are not set for private profiles
        user.setEmail(jsonUser.has("email") ? jsonUser.getString("email") : "");
        user.setFirstName(jsonUser.has("first_name") ? jsonUser.getString("first_name") : "");
        user.setLastName(jsonUser.has("last_name") ? jsonUser.getString("last_name") : "");

        users.add(user);
      }

      return PagedResult.create(users, totalResults);
    } catch (JSONException e) {
      throw new ReviewboardException(e.getMessage(), e);
    }
  }
  @Test
  public void getForumPostsByUserIdWithOther() {
    final User user = new User();
    user.setEmail("a");
    user.setRegistrationDate(new Date());
    persistance.putUser(user);

    DraftForum forum = new DraftForum();
    forum.setName("name");
    persistance.putItem(forum);

    SubForum subForum = new SubForum();
    subForum.setSubForumName("ffff");
    subForum.setSubForumDescription("ffff1");
    forum.addSubForum(subForum);
    persistance.putSubForum(subForum);

    ForumThread forumThread = new ForumThread();
    forumThread.setThreadName("f");
    forumThread.setThreadDescription("f2");
    forumThread.setUpdateDate(new Date());
    subForum.addForumThread(forumThread);
    persistance.putForumThread(forumThread);

    ForumPost forumPost = new ForumPost();
    forumPost.setText("bbb");
    forumPost.setAuthor(user);
    forumPost.setDateCreated(new Date(System.currentTimeMillis() * 2));
    forumThread.addForumPost(forumPost);
    persistance.putForumPost(forumPost);

    List<ForumPost> forumPosts = persistance.getForumPostsByUserId(user.getUserId() + 9);
    Assert.assertEquals(0, forumPosts.size());
  }
 private User makeUser(String name) {
   User u = new User();
   u.setId(nextId++);
   u.setFirstName(name);
   u.setLastName("Test");
   u.setEmail("*****@*****.**");
   return u;
 }
Exemplo n.º 13
0
  private User getUserWithEmailAndPasswordFromJson(final String body) {
    final User user = new Customer(); // The implementation does not matter

    final JsonObject jsonObject = JsonReader.readAsJsonObject(body);
    user.setEmail(JsonReader.getStringOrNull(jsonObject, "email"));
    user.setPassword(JsonReader.getStringOrNull(jsonObject, "password"));

    return user;
  }
Exemplo n.º 14
0
 private void addManager() throws UserNameExistsException {
   User manager = new User();
   manager.setUserName("root");
   manager.setPassword(Hash.hashString("root"));
   manager.setPhoneNumber("0123456789");
   manager.setEmail("*****@*****.**");
   manager.setAddress("Root street 42.");
   userDAO.insertUser(manager);
 }
Exemplo n.º 15
0
  public static Pair<Boolean, String> updateProject(
      ProjectDTO projectDTO, boolean changedProjectName, String originalProjectName) {
    try {
      // Additional duplication control
      Project existingProject;
      if (changedProjectName) {
        existingProject = ProxyManager.getProjectProxy().findProjectByName(projectDTO.getName());
      } else existingProject = null;

      if (existingProject != null && changedProjectName) {
        System.out.println("Existing project exists!");
        return Pair.of(false, "Project with this name already exists!");
      }

      Project p = ProxyManager.getProjectProxy().findProjectByName(originalProjectName);
      p.setProjectId(projectDTO.getProjectId());
      p.setName(projectDTO.getName());
      p.setDescription(projectDTO.getDescription());
      p.setStatus(projectDTO.getStatus());
      Team team = new Team();
      team.setTeamId(projectDTO.getTeamTeamId().getTeamId());
      team.setScrumMasterId(projectDTO.getTeamTeamId().getScrumMasterId());
      team.setProductOwnerId(projectDTO.getTeamTeamId().getProductOwnerId());

      List<User> userList = new ArrayList<User>();
      if (projectDTO.getTeamTeamId().getUserList() != null) {
        for (UserDTO userDTO : projectDTO.getTeamTeamId().getUserList()) {
          User user = new User();
          user.setUserId(userDTO.getUserId());
          user.setUsername(userDTO.getUsername());
          user.setPassword(userDTO.getPassword());
          user.setFirstName(userDTO.getFirstName());
          user.setLastName(userDTO.getLastName());
          user.setEmail(userDTO.getEmail());
          user.setIsAdmin(userDTO.isAdmin());
          user.setSalt(userDTO.getSalt());
          user.setIsActive(userDTO.isActive());
          user.setTimeCreated(userDTO.getTimeCreated());
          userList.add(user);
        }
        team.setUserList(userList);
      } else return Pair.of(false, "No project list when saving team.");
      p.setTeamTeamId(team);
      try {
        if (p == null) return Pair.of(false, "Data error!");
        ProxyManager.getProjectProxy().edit(p);

      } catch (Exception e) {
        System.err.println("Error: " + e.getMessage());
        return Pair.of(false, e.getMessage());
      }
    } catch (Exception e) {
      e.printStackTrace();
      return Pair.of(false, e.getMessage());
    }
    return Pair.of(true, "Project updated successfully.");
  }
Exemplo n.º 16
0
 public User getPersonalDetails(User user) {
   user.setUsername(sharedPreferences.getString("username", ""));
   user.setPassword(sharedPreferences.getString("password", ""));
   user.setName(sharedPreferences.getString("name", ""));
   user.setEmail(sharedPreferences.getString("email", ""));
   user.setAge(sharedPreferences.getString("age", ""));
   user.setPhone(sharedPreferences.getString("phone", ""));
   return user;
 }
Exemplo n.º 17
0
  /**
   * 사용자를 (ez_users)에서 보여준다
   *
   * @param groupID
   * @return
   * @throws DataAccessException
   */
  public User viewUser(String userID) throws DataAccessException {

    User user = new User();
    Map<String, Object> resultMap = null;
    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.viewuser"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.

    // 넘겨받은 파라미터를 세팅한다.
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("userID", userID);

    // SQL문이 실행된다.
    try {
      resultMap = getSimpleJdbcTemplate().queryForMap(sql, param);
    } catch (EmptyResultDataAccessException e1) {
    }

    if (resultMap != null) {

      user.setUserID((String) (resultMap.get("userID")));
      user.setUserPWD((String) (resultMap.get("userPWD")));
      user.setUserName((String) (resultMap.get("userName")));
      user.setGroupID((String) (resultMap.get("groupID")));
      user.setGroupName((String) (resultMap.get("groupName")));
      user.setUserLevel((String) (resultMap.get("userLevel")));
      user.setEmail((String) (resultMap.get("email") == null ? "" : resultMap.get("email")));
      user.setCellPhone(
          (String) (resultMap.get("cellPhone") == null ? "" : resultMap.get("cellPhone")));
      user.setDescription(
          (String) (resultMap.get("description") == null ? "" : resultMap.get("description")));
      user.setUseYN((String) (resultMap.get("useYN")));
      user.setRegistDate(String.valueOf(resultMap.get("registDate")));
      user.setIsAdmin((String) (resultMap.get("isAdmin")));
      user.setAuthCSV((String) (resultMap.get("auth_csv")));
      user.setAuthDirect((String) (resultMap.get("auth_direct")));
      user.setAuthRelated((String) (resultMap.get("auth_related")));
      user.setAuthQuery((String) (resultMap.get("auth_query")));
      user.setAuthSendMail((String) (resultMap.get("auth_send_mail")));
      user.setAuthWriteMail((String) (resultMap.get("auth_write_mail")));
      user.setIsHelper((String) (resultMap.get("isHelper")));
      user.setSenderName(
          (String) (resultMap.get("senderName") == null ? "" : resultMap.get("senderName")));
      user.setSenderEmail(
          (String) (resultMap.get("senderEmail") == null ? "" : resultMap.get("senderEmail")));
      user.setSenderCellPhone(
          (String)
              (resultMap.get("senderCellPhone") == null ? "" : resultMap.get("senderCellPhone")));
      user.setAuthSendSMS((String) (resultMap.get("auth_send_sms")));
      user.setAuthWriteSMS((String) (resultMap.get("auth_write_sms")));
      user.setFailCount(Integer.parseInt(String.valueOf(resultMap.get("failCount"))));
    } else {
      user.setUserID("");
    }
    return user;
  }
Exemplo n.º 18
0
 public User updateUser(int id, String login, String pwd, String email, User user) {
   Session session = sessionFactory.getCurrentSession();
   user.setEmail(email);
   user.setId(id);
   user.setLogin(login);
   user.setPwd(pwd);
   user.setLast_date_pwd(new Date());
   session.update(user);
   return user;
 }
Exemplo n.º 19
0
 @Test
 public void testValidator() {
   User user = new User();
   user.setEmail("s");
   user.setPassword("12345678");
   Set<ConstraintViolation<User>> errors = validator.validate(user);
   for (ConstraintViolation<User> error : errors) {
     System.out.println(error.getPropertyPath() + error.getMessage());
   }
 }
Exemplo n.º 20
0
  public static Pair<Boolean, String> saveNewProject(ProjectDTO projectDTO) {

    // check for project in database
    System.out.println("Project to check in base: " + projectDTO.getName());
    Project existingProject =
        ProxyManager.getProjectProxy().findProjectByName(projectDTO.getName());
    try {
      if (existingProject != null) {
        System.out.println("Existing project exists!");
        return Pair.of(false, "Project with this name already exists!");
      } else System.out.println("Project check passed, no existing project.");

      Project p = new Project();
      p.setName(projectDTO.getName());
      p.setDescription(projectDTO.getDescription());
      p.setStatus(projectDTO.getStatus());
      Team team = new Team();
      team.setTeamId(projectDTO.getTeamTeamId().getTeamId());
      team.setScrumMasterId(projectDTO.getTeamTeamId().getScrumMasterId());
      team.setProductOwnerId(projectDTO.getTeamTeamId().getProductOwnerId());

      List<User> userList = new ArrayList<User>();
      if (projectDTO.getTeamTeamId().getUserList() != null) {
        for (UserDTO userDTO : projectDTO.getTeamTeamId().getUserList()) {
          User user = new User();
          user.setUserId(userDTO.getUserId());
          user.setUsername(userDTO.getUsername());
          user.setPassword(userDTO.getPassword());
          user.setFirstName(userDTO.getFirstName());
          user.setLastName(userDTO.getLastName());
          user.setEmail(userDTO.getEmail());
          user.setIsAdmin(userDTO.isAdmin());
          user.setSalt(userDTO.getSalt());
          user.setIsActive(userDTO.isActive());
          user.setTimeCreated(userDTO.getTimeCreated());
          userList.add(user);
        }
        team.setUserList(userList);
      } else return Pair.of(false, "No user list when saving team.");
      p.setTeamTeamId(team);
      try {
        if (p == null) return Pair.of(false, "Data error!");

        ProxyManager.getProjectProxy().create(p);

      } catch (Exception e) {
        System.err.println("Error: " + e.getMessage());
        return Pair.of(false, e.getMessage());
      }
    } catch (Exception e) {
      e.printStackTrace();
      return Pair.of(false, e.getMessage());
    }
    return Pair.of(true, "Project saved successfully.");
  }
Exemplo n.º 21
0
 public User createUser(String login, String pwd, String email)
     throws MySQLIntegrityConstraintViolationException, ConstraintViolationException {
   Session session = sessionFactory.getCurrentSession();
   User user = new User();
   user.setEmail(email);
   user.setLogin(login);
   user.setPwd(pwd);
   user.setLast_date_pwd(new Date());
   session.persist(user);
   return user;
 }
Exemplo n.º 22
0
 @RequestMapping(value = "/admin/updateUser.html", method = RequestMethod.POST)
 public ModelAndView updateUser(
     String guid, String realName, String phoneNumber, String email, String roleText) {
   User user = userService.findUserByGuid(guid);
   user.setRealName(realName);
   user.setPhoneNumber(phoneNumber);
   user.setEmail(email);
   user.setRole(roleText);
   userService.updateUser(user);
   return index();
 }
  @Test
  public void getForumsByUserIdForEmpty() {
    User user = new User();
    user.setPassword("1");
    user.setEmail("a");
    user.setRegistrationDate(new Date());
    persistance.putUser(user);

    List<DraftItem> userForums =
        persistance.getDraftItemsByUserId(user.getUserId(), ItemType.FORUM);
    Assert.assertEquals(0, userForums.size());
  }
Exemplo n.º 24
0
  @Override
  public Offer mapRow(ResultSet rs, int rowNum) throws SQLException {
    User user = new User();
    user.setAuthority(rs.getString("authority"));
    user.setEmail(rs.getString("email"));
    user.setEnabled(true);
    user.setName(rs.getString("name"));
    user.setUsername(rs.getString("username"));

    Offer offer = new Offer();
    offer.setId(rs.getInt("id"));
    offer.setText(rs.getString("text"));
    offer.setUser(user);

    return offer;
  }
Exemplo n.º 25
0
  @Transactional
  public boolean createUser(final String username, final String password, final String email) {
    User user = new User();

    user.setUsername(username);
    user.setHash(hashPassword(password));
    user.setEmail(email);

    // todo - create user, remove empty strings check
    try {
      return userDao.createUser(user);
    } catch (Throwable t) {
      LOGGER.warn("Exception occurred while creating new user, error: " + t);
      return false;
    }
  }
Exemplo n.º 26
0
  @Test
  public void testFindByEmailFinder() {
    User user = new User();
    user.setEmail("*****@*****.**");
    user.setPassword("superSecretPassword");
    user.persist();

    // Se persisten cambios y se limpia la cache
    user.flush();
    user.entityManager.clear();

    // Se busca el usuario recien insertado
    User user2 = User.findUsersByEmailEquals("*****@*****.**").getSingleResult();
    assertEquals(user.getEmail(), user2.getEmail());
    assertEquals(user.getId(), user2.getId());
  }
Exemplo n.º 27
0
  public void testAddAndRemoveUser() throws Exception {
    User user = new User("testuser");
    user.setPassword("testpass");
    user.setFirstName("Test");
    user.setLastName("Last");
    Address address = new Address();
    address.setCity("Denver");
    address.setProvince("CO");
    address.setCountry("USA");
    address.setPostalCode("80210");
    user.setAddress(address);
    user.setEmail("*****@*****.**");
    user.setWebsite("http://tek42.com");
    user.setTimeZone("US/Central");

    // Here we are creating an org that should already be in the database...
    // Ideally, we somehow have an org object... from the other dao or whatever...
    /*
     * Account org = new Account(); org.setName("Tek42"); org.setId(1L);
     */
    Account org = adao.get(2L);
    System.out.println("Have org: " + org);
    user.setAccount(org);

    Role role = rdao.getRoleByName(Constants.USER_ROLE);
    assertNotNull(role.getId());
    user.addRole(role);

    user = dao.saveUser(user);

    assertNotNull(user.getId());

    user = dao.get(user.getId());

    assertEquals("Vigilant", user.getAccount().getName());
    assertEquals("testpass", user.getPassword());
    assertEquals("US/Central", user.getTimeZone());

    dao.remove(user.getId());

    try {
      dao.get(user.getId());
      fail("getUser didn't throw DataAccessException");
    } catch (DataAccessException d) {
      assertNotNull(d);
    }
  }
  @Test
  public void getFormFiltersByUserId_and_getFormFilterByNameAndUserId() {
    User user = new User();
    user.setPassword("1");
    user.setEmail("a");
    user.setRegistrationDate(new Date());
    persistance.putUser(user);

    Site site = new Site();
    site.getSitePaymentSettings().setUserId(-1);
    site.setSubDomain("$");
    site.getThemeId().setTemplateDirectory("f");
    site.getThemeId().setThemeCss("G");
    site.setTitle("F");
    persistance.putSite(site);

    UserOnSiteRight userOnUserRight = new UserOnSiteRight();
    userOnUserRight.setActive(true);
    userOnUserRight.setSiteAccessType(SiteAccessLevel.ADMINISTRATOR);
    user.addUserOnSiteRight(userOnUserRight);
    site.addUserOnSiteRight(userOnUserRight);
    persistance.putUserOnSiteRight(userOnUserRight);

    DraftForm form = new DraftCustomForm();
    form.setSiteId(site.getSiteId());
    form.setName("name");
    persistance.putItem(form);

    DraftFormFilter filter = new DraftFormFilter();
    filter.setForm(form);
    String filterName = "filter name " + System.currentTimeMillis();
    filter.setName(filterName);
    persistance.putFormFilter(filter);

    List<DraftFormFilter> userFitlers = persistance.getFormFiltersByUserId(user.getUserId());
    Assert.assertEquals(filter, userFitlers.get(0));

    DraftFormFilter namedUserFilter =
        persistance.getFormFilterByNameAndUserId(filterName, user.getUserId());
    Assert.assertEquals(filter, namedUserFilter);
  }
  private static void setupLibrary() {
    library = new Library();

    library.add(new Book("Pride and Prejudice", "Jane Austen", 1813));
    library.add(new Book("To Kill a Mockingbird", "Harper Lee", 1960));
    library.add(new Book("The Great Gatsby", "F. Scott Fitzgerald", 1922));
    library.add(new Book("Frankenstein", "Mary Shelley", 1818));

    library.add(new Movie("The Godfather", 1972, "Francis Ford Coppola", 9));
    library.add(new Movie("The Shawshank Redemption", 1994, "Frank Darabont", 10));
    library.add(new Movie("Sharktopus", 2006, "Declan O'Brien", 1));
    library.add(new Movie("Scooby Doo", 2002, "Raja Gosnell", 0));

    UserRegistry registry = UserRegistry.getInstance();
    User user = new User("123-4567", "password");
    user.setEmail("test@localhost");
    user.setPhone("+44 122 1111 444");
    user.setName("Joe Bloggs");
    registry.addUser(user);
    registry.addUser((new User("111-1111", "password", true)));
  }
Exemplo n.º 30
0
  /**
   * 사용자를 (ez_users)에서 보여준다
   *
   * @param groupID
   * @return
   * @throws DataAccessException
   */
  public User getHelperUser() throws DataAccessException {

    User user = new User();
    Map<String, Object> resultMap = null;
    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.helperuser"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.

    // SQL문이 실행된다.
    try {
      resultMap = getSimpleJdbcTemplate().queryForMap(sql);
    } catch (EmptyResultDataAccessException e1) {
    }

    if (resultMap != null) {

      user.setUserID((String) (resultMap.get("userID")));
      user.setUserPWD((String) (resultMap.get("userPWD")));
      user.setUserName((String) (resultMap.get("userName")));
      user.setGroupID((String) (resultMap.get("groupID")));
      user.setGroupName((String) (resultMap.get("groupName")));
      user.setUserLevel((String) (resultMap.get("userLevel")));
      user.setEmail((String) (resultMap.get("email")));
      user.setCellPhone((String) (resultMap.get("cellPhone")));
      user.setDescription((String) (resultMap.get("description")));
      user.setUseYN((String) (resultMap.get("useYN")));
      user.setRegistDate(String.valueOf(resultMap.get("registDate")));
      user.setIsAdmin((String) (resultMap.get("isAdmin")));
      user.setAuthCSV((String) (resultMap.get("auth_csv")));
      user.setAuthQuery((String) (resultMap.get("auth_query")));
      user.setAuthSendMail((String) (resultMap.get("auth_send_mail")));
      user.setAuthWriteMail((String) (resultMap.get("auth_write_mail")));
      user.setAuthSendSMS((String) (resultMap.get("auth_send_sms")));
      user.setAuthWriteSMS((String) (resultMap.get("auth_write_sms")));

    } else {
      user.setUserID("");
    }
    return user;
  }