Package edu.ubb.warp.dao

Examples of edu.ubb.warp.dao.ResourceDAO


  }
 
  public void init_tab2() throws DAOException, ResourceNotFoundException, ResourceNotBookedException {
    DAOFactory df = DAOFactory.getInstance();
    BookingDAO bookDAO = df.getBookingDAO();
    ResourceDAO resourceDAO = df.getResourceDAO();
    ProjectDAO proDAO = df.getProjectDAO();
    ArrayList<Project> projectList = proDAO.getProjectsByUser(user);
    Resource userResource = resourceDAO.getResourceByUser(user);
    int min,max = 0;
    Booking bMinMax = bookDAO.getMinBookingByResource(userResource);
    min = bMinMax.getWeek();
    bMinMax = bookDAO.getMaxBookingByResource(userResource);
    max = bMinMax.getWeek();
View Full Code Here


          resource.setActive(checb.booleanValue());
          resource.setResourceName(resName.toString());
          resource.setDescription(resDescription.toString());

          try {
            ResourceDAO resDao = df.getResourceDAO();
            resDao.insertResource(resource);
            for (int i = 0; i <= groupnumber; i++) {

              if (groups.isSelected(i)) {

                Group gr = new Group();
View Full Code Here

    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) {
    } catch (ResourceNotFoundException e) {
View Full Code Here

  protected void initUser() {
   
    menuB.setHtmlContentAllowed(true);
    DAOFactory df = DAOFactory.getInstance();
    RequestDAO rd = df.getRequestDAO();
    ResourceDAO resDao = df.getResourceDAO();
    try {
      if (rd.resourceHasRequests(resDao.getResourceByUser(user).getResourceID())) {
        request.setText(Colorizer.colorHTML("Request", Color.YELLOW));
      }
    } catch (DAOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

    user.setImmediate(true);
    user.setSelectable(true);

    ArrayList<Resource> userArray = null;

    final ResourceDAO userDAO = df.getResourceDAO();

    try {
      userArray = userDAO.getWorkersByProject(p);
      user.addContainerProperty("User ID", String.class, null);
      user.addContainerProperty("User Name", String.class, null);
      // list.setVisibleColumns(new Object[] { "Type Name" });
      for (int i = 0; i < userArray.size(); i++) {
        Resource resUser = userArray.get(i);
        user.addItem(
            new Object[] {
                Integer.toString(resUser.getResourceID()),
                resUser.getResourceName() }, i);
      }

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

    leader.setHeight("100px");
    leader.setImmediate(true);
    leader.setSelectable(true);

    ArrayList<Resource> leaderArray = null;

    final ResourceDAO leaderDAO = df.getResourceDAO();

    try {
      leaderArray = userDAO.getLeadersByProject(p);
      leader.addContainerProperty("Leader ID", String.class, null);
      leader.addContainerProperty("Leader Name", String.class, null);
      // list.setVisibleColumns(new Object[] { "Type Name" });
      for (int i = 0; i < leaderArray.size(); i++) {
        Resource resLeader = leaderArray.get(i);
        leader.addItem(
            new Object[] {
                Integer.toString(resLeader.getResourceID()),
                resLeader.getResourceName() }, i);
      }

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

    add.addListener(new ClickListener() {
      /**
       *
       */
      private static final long serialVersionUID = 1200365843348797837L;

      public void buttonClick(ClickEvent event) {

        try {

          userDAO.updateUserTask(
              Integer.parseInt(user.getItem(user.getValue())
                  .getItemProperty("User ID").toString()),
              p.getProjectID(), true);
          // me.getApplication().getMainWindow().setContent(new
          // ProjectOptionsPageUI(u, p));

          leader.removeAllItems();

          ArrayList<Resource> leaderArray2 = null;

          try {
            leaderArray2 = userDAO.getLeadersByProject(p);
            leader.addContainerProperty("Leader ID", String.class,
                null);
            leader.addContainerProperty("Leader Name",
                String.class, null);
            // list.setVisibleColumns(new Object[] { "Type Name" });
            for (int i = 0; i < leaderArray2.size(); i++) {
              Resource resLeader = leaderArray2.get(i);
              leader.addItem(
                  new Object[] {
                      Integer.toString(resLeader
                          .getResourceID()),
                      resLeader.getResourceName() }, i);
            }

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

          user.removeAllItems();

          ArrayList<Resource> userArray2 = null;

          try {
            userArray2 = userDAO.getWorkersByProject(p);
            user.addContainerProperty("User ID", String.class, null);
            user.addContainerProperty("User Name", String.class,
                null);
            // list.setVisibleColumns(new Object[] { "Type Name" });
            for (int i = 0; i < userArray2.size(); i++) {
              Resource resUser = userArray2.get(i);
              user.addItem(
                  new Object[] {
                      Integer.toString(resUser
                          .getResourceID()),
                      resUser.getResourceName() }, i);
            }

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

        } catch (NumberFormatException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (DAOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (ProjectNeedsActiveLeaderException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }

      }
    });

    remove.addListener(new ClickListener() {
      /**
       *
       */
      private static final long serialVersionUID = -8636303013936005088L;

      public void buttonClick(ClickEvent event) {

        try {
          leaderDAO.updateUserTask(
              Integer.parseInt(leader.getItem(leader.getValue())
                  .getItemProperty("Leader ID").toString()),
              p.getProjectID(), false);
          leader.removeAllItems();

View Full Code Here

    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) {
View Full Code Here

    }else
    {
      projectName = new Label("<b>"+p.getProjectName()+"</b> - close",Label.CONTENT_XHTML)
    }
    ArrayList<Resource> leaderArray = null;
    ResourceDAO resDao = df.getResourceDAO();
   
   
   
    try {
      leaderArray = resDao.getLeadersByProject(p);
      projectLeader.setValue(leaderArray.get(0).getResourceName());
      for (int i = 1; i < leaderArray.size(); i++)
      {
        String s = projectLeader.getValue().toString();
        projectLeader.setValue(s +", " + leaderArray.get(i).getResourceName());
      }
    } catch (DAOException e) {
      e.printStackTrace();
    }
   
   
    Panel panelName = new Panel();
    HorizontalLayout panelButton = new HorizontalLayout();
   
    panelName.addComponent(projectName);
    panelName.addComponent(projectLeader);
    panelName.addComponent(projectTable);
   
    panelButton.addComponent(closeProject);
    panelButton.addComponent(optionProject);
    panelButton.addComponent(request);
   
    HorizontalLayout layout = new HorizontalLayout();
    layout.addComponent(panelName);
    layout.addComponent(panelButton);
    layout.setSizeFull();
    layout.setSpacing(true);
   
   
    projectPanel.setSizeFull();
    projectPanel.addComponent(panelButton);
    projectPanel.addComponent(panelName);

    projectTable.setHeight("200");
    closeProject.addListener(new ClickListener() {
      /**
       *
       */
      private static final long serialVersionUID = -1360875811056001870L;

      public void buttonClick(ClickEvent event) {
        me.getApplication().getMainWindow().setContent(new CloseProjectPageUI(u, p));
      }
    });
    optionProject.addListener(new ClickListener() {
      /**
       *
       */
      private static final long serialVersionUID = -4581378782471898678L;

      public void buttonClick(ClickEvent event) {
        me.getApplication().getMainWindow().setContent(new ProjectOptionsPageUI(u, p));
      }
    });
   
    request.addListener(new ClickListener() {
      /**
       *
       */
      private static final long serialVersionUID = 8725189226720674211L;

      public void buttonClick(ClickEvent event) {
        me.getApplication().getMainWindow().setContent(new MakeRequestPageUI(u,p));
      }
    });
 
    try {
      BookingDAO bookDAO = df.getBookingDAO();
      ResourceDAO resourceDAO = df.getResourceDAO();
      ArrayList<Resource> resourceList;
     
      resourceList = resourceDAO.getResourcesByProject(p);
   
      int min,max = 0;
      Booking bMinMax = bookDAO.getMinBookingByProject(p);
      min = bMinMax.getWeek();
      bMinMax = bookDAO.getMaxBookingByProject(p);
View Full Code Here

  private void initTable(Date start, Date end) throws DAOException,
      ResourceNotFoundException {
    DAOFactory df = DAOFactory.getInstance();
    final ProjectDAO projectDao = df.getProjectDAO();
    ResourceDAO resourceDao = df.getResourceDAO();

    int startNum = Timestamp.toInt(start);
    int endNum = Timestamp.toInt(end);

    historyTable.addContainerProperty("ProjectID", Integer.class, null);
    historyTable.addContainerProperty("Project Name", String.class, null);
    historyTable.addContainerProperty("StartDate", String.class, null);
    historyTable.addContainerProperty("Deadline", String.class, null);
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MMM/yyyy");
    Resource u = null;
    try {
    u = resourceDao.getResourceByUser(user);
    } catch (Exception e) {
     
    }
    ArrayList<Project> projectList = null;
    if (manager) {
View Full Code Here

       
        int projectEnd = Timestamp.toInt((Date)date.getValue());
        int projectStart = Timestamp.toInt(new Date());
       
        ProjectDAO prdao = df.getProjectDAO();
        ResourceDAO res = df.getResourceDAO();
        if ((projectName.toString().length() != 0) &&
            (projectEnd > projectStart) &&
            (Integer.parseInt(list.getItem(list.getValue()).getItemProperty("Status ID").toString()) != 0))
        { 
          p.setDescription(projectDescription.toString());
          p.setOpenedStatus(true);
          p.setStartWeek(projectStart);
          p.setProjectName(projectName.toString());
          p.setDeadLine(projectEnd);
          p.setCurrentStatusID(Integer.parseInt(list.getItem(list.getValue()).getItemProperty("Status ID").toString()));
          p.setNextRelease(release.toString());
         
         
              try {
                prdao.insertProject(p);
                ResourceDAO resDao = df.getResourceDAO();
                res.insertUserTask(resDao.getResourceByUser(u).getResourceID(), p.getProjectID(), true);
              } catch (ProjectNameExistsException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                me.getApplication().getMainWindow()
                .showNotification("Database Error!");
View Full Code Here

TOP

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

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.