Package edu.ubb.warp.model

Examples of edu.ubb.warp.model.User


            && ((telText.toString()).length() > 0)
            && ((addressText.toString()).length() > 0)
            && ((passwordText.toString()).length() > 0)) {
          try {

            User us = new User();
            us.setUserName(nameText.toString());
            us.setEmail(emailText.toString());
            us.setAddress(addressText.toString());
            us.setPhoneNumber(telText.toString());
            us.setPassword(Hash.hashString(passwordText.toString()));
            df.getUserDAO().insertUser(us);

            if (!manager.booleanValue()) {
              Resource res = new Resource();
              res.setActive(true);
View Full Code Here


      userList = userDao.getAllUsers();
      userTable.addContainerProperty("UserID", String.class, null);
      userTable.addContainerProperty("User Name", String.class, null);
      userTable.addContainerProperty("Active", String.class, null);
      for (int i = 0; i < userList.size(); i++) {
        User e = userList.get(i);
        Resource r = null;
        try {

          r = resDao.getResourceOfUser(e);
        } catch (ResourceNotFoundException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
        boolean active = false;
        if (r != null)
          active = r.isActive();
        userTable.addItem(
            new Object[] { Integer.toString(e.getUserID()),
                e.getUserName(), Boolean.toString(active) }, i);
      }
    } catch (DAOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      System.out.println("loading table failed");
    }

    //
    userTable.setSelectable(true);
    userTable.addListener(new ItemClickListener() {

      /**
       *
       */
      private static final long serialVersionUID = -141353553631857791L;

      public void itemClick(ItemClickEvent event) {

        /*
         * Space reserved for handling the proper event
         */

      }
    });

    changeButton.addListener(new ClickListener() {

      /**
       *
       */
      private static final long serialVersionUID = 2529988983021196127L;

      public void buttonClick(ClickEvent event) {

        Object o = userTable.getValue();
        String uid = userTable.getItem(o).getItemProperty("UserID")
            .toString();
        try {
          User changedUser = userDao.getUserByUserID(Integer
              .parseInt(uid));
          try {
            Resource changedResource = resDao
                .getResourceOfUser(changedUser);

            changedResource.setActive(!changedResource.isActive());
            resDao.updateResource(changedResource);
          } catch (ResourceHasActiveProjectException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();

          } catch (ResourceNotFoundException e) {
            me.getApplication()
                .getMainWindow()
                .showNotification(
                    "Selected user is not associated with a resource");
            e.printStackTrace();
          } catch (ResourceNameExistsException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        } catch (NumberFormatException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (DAOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (UserNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        me.getApplication().getMainWindow()
            .setContent(new DeleteUserPageUI(user));

      }
    });
   
    resetPassButton.addListener(new ClickListener() {
     
      /**
       *
       */
      private static final long serialVersionUID = 6620284795373485530L;

      public void buttonClick(ClickEvent event) {
       
        Object o = userTable.getValue();
        String uid = userTable.getItem(o).getItemProperty("UserID")
            .toString();
        try {
          User changedUser = userDao.getUserByUserID(Integer
              .parseInt(uid));
          changedUser.setPassword(Hash.hashString("1234"));
          userDao.updateUser(changedUser);
          me.getApplication().getMainWindow().showNotification("password set to 1234");
        } catch (Exception e) {
         
        }
View Full Code Here

public class UserInserter {
  public static void InsertUsers() {
    DAOFactory df = DAOFactory.getInstance();
    UserDAO uDao = df.getUserDAO();
    User u1 = new User();
    User u2 = new User();
    u1.setEmail("mail@mail.com");
    u1.setPassword(Hash.hashString("password"));
    u1.setPhoneNumber("0743288115");
    u1.setUserName("manager");
    u1.setAddress("Kolozsvar strada utca 12");
View Full Code Here

public class UserJdbcDAO implements UserDAO {

  public User getUserByUserID(int userID) throws DAOException,
      UserNotFoundException {
    User user = new User();
    try {
      String command = "SELECT * FROM `Users` WHERE `UserID` = ?";
      PreparedStatement statement = JdbcConnection.getConnection()
          .prepareStatement(command);
      statement.setInt(1, userID);
View Full Code Here

    return user;
  }

  public User getUserByUserName(String userName) throws DAOException,
      UserNotFoundException {
    User user = new User();
    try {
      String command = "SELECT * FROM `Users` WHERE `UserName` = ?";
      PreparedStatement statement = JdbcConnection.getConnection()
          .prepareStatement(command);
      statement.setString(1, userName);
View Full Code Here

      throw new DAOException();
    }
  }

  private User getUserFromResult(ResultSet result) throws SQLException {
    User user = new User();
    user.setUserID(result.getInt("UserID"));
    user.setUserName(result.getString("UserName"));
    user.setPassword(result.getBytes("Password"));
    user.setPhoneNumber(result.getString("PhoneNumber"));
    user.setEmail(result.getString("Email"));
    user.setAddress(result.getString("Address"));
    return user;
  }
View Full Code Here

TOP

Related Classes of edu.ubb.warp.model.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.