Package edu.ubb.warp.dao

Examples of edu.ubb.warp.dao.UserDAO


    menuB.setWidth("100%");

    account.setIcon(new ThemeResource("icon.png"));

    DAOFactory df = DAOFactory.getInstance();
    UserDAO userDao = df.getUserDAO();
    ResourceDAO resourceDao = df.getResourceDAO();
    try {
      manager = userDao.userIsManager(user);
      String userName = resourceDao.getResourceByUser(user)
          .getResourceName();
      account.setText(userName);
    } catch (DAOException e) {
    } catch (UserNotFoundException e) {
View Full Code Here


  public DeleteUserPageUI(User u) {
    super(u);

    DAOFactory factory = DAOFactory.getInstance();
    final UserDAO userDao = factory.getUserDAO();
    ArrayList<User> userList = new ArrayList<User>();
    final ResourceDAO resDao = factory.getResourceDAO();
    // Space reserved for loading table with data

    try {
      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

import edu.ubb.warp.model.User;

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");
    try {
      uDao.insertUser(u1);
    } catch (UserNameExistsException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
View Full Code Here

TOP

Related Classes of edu.ubb.warp.dao.UserDAO

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.