Package edu.ubb.warp.model

Examples of edu.ubb.warp.model.Resource


    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();
   
    {
      jobs.addContainerProperty("Project", String.class, null);
      for(int i = min; i <= max; i++) {
        String s = "Week " + Integer.toString(i);
        jobs.addContainerProperty(s, String.class, null);
      }
     

     
      for(int j = 0; j < projectList.size(); j++) {
        String[] obj = new String[max - min + 2];
        obj[0] = projectList.get(j).getProjectName();
        int i = 1;
        for(int it = min; it <= max; it++) {
          Booking b = bookDAO.getBookingByResourceIDAndProjectIDAndWeek(userResource.getResourceID(),projectList.get(j).getProjectID(), i);
          obj[i] = Float.toString(b.getRatio());
          i++;
        }
        jobs.addItem(obj,j);
      }
View Full Code Here


            us.setPhoneNumber(telText.toString());
            us.setPassword(Hash.hashString(passwordText.toString()));
            df.getUserDAO().insertUser(us);

            if (!manager.booleanValue()) {
              Resource res = new Resource();
              res.setActive(true);
              res.setDescription(descriptionText.toString());
              res.setResourceName(nameText.toString());
              res.setResourceTypeID(1);
              df.getResourceDAO().insertResource(res);
              df.getResourceDAO().linkResourceToUser(res, us);

              for (int i = 0; i <= groupnumber; i++) {
View Full Code Here

  private void initTable2() throws DAOException, BookingNotFoundException {
    // Necessary for update;
    hl.removeComponent(clusterFuck);
    // Get our resource;
    Resource r = selectedResource;
    // set our date variables and index variable;
    todayInt = Timestamp.toInt(today);
    deadlineInt = project.getDeadLine();
    int index = deadlineInt - todayInt;
    // create a new Table;
    clusterFuck = new Table();
    clusterFuck.addContainerProperty("Date", String.class, null);
    clusterFuck.addContainerProperty("Our ratio", Label.class, null);
    clusterFuck.addContainerProperty("Total Ratio", Label.class, null);
    clusterFuck
        .addContainerProperty("Value we want", TextField.class, null);

    fieldList = new ArrayList<TextField>();

    for (int i = 0; i <= index; i++) {
      Object[] obj = new Object[4];
      obj[0] = formatter.format(Timestamp.toDate(i + todayInt));
      Float f = bookingDao.getBookingByResourceIDAndProjectIDAndWeek(
          r.getResourceID(), project.getProjectID(), i + todayInt)
          .getRatio();
      Label l = new Label(Colorizer.floatToHTML(f));
      l.setContentMode(Label.CONTENT_XHTML);
      obj[1] = l;
      Float q = bookingDao.getBookingsSumByResourceIDandWeek(
          r.getResourceID(), i + todayInt);
      l = new Label(Colorizer.floatToHTML(q));
      l.setContentMode(Label.CONTENT_XHTML);
      obj[2] = l;
      fieldList.add(new TextField());
      fieldList.get(i).setValue("");
View Full Code Here

    bookButton.addListener(new ClickListener() {

      public void buttonClick(ClickEvent event) {
        TreeMap<Integer, Float> tm = getValues();
        if (tm != null) {
          Resource r = selectedResource;
          try {
            System.out.println("Booking resource");
            bookingDao.insertBookings(project.getProjectID(),
                r.getResourceID(), tm);
            initTable2();
          } catch (DAOException e) {
            me.getApplication().getMainWindow()
                .showNotification("Try updating");
            e.printStackTrace();
          } catch (RatioOutOfBoundsException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          } catch (BookingNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }
    });

    updateButton.addListener(new ClickListener() {

      public void buttonClick(ClickEvent event) {
        TreeMap<Integer, Float> tm = getValues();
        if (tm != null) {
          Resource r = selectedResource;
          try {
            System.out.println("Booking resource");
            bookingDao.updateBookings(project.getProjectID(),
                r.getResourceID(), tm);

          } catch (DAOException e) {
            me.getApplication().getMainWindow()
                .showNotification("Try updating");
            e.printStackTrace();
          } catch (RatioOutOfBoundsException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
          try {
            initTable2();
          } catch (DAOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          } catch (BookingNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }
    });

    requestButton.addListener(new ClickListener() {

      public void buttonClick(ClickEvent event) {
        Resource userRes = null;
        try {
          userRes = resourceDao.getResourceByUser(user);
        } catch (DAOException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        } catch (ResourceNotFoundException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
        Resource res = selectedResource;
        TreeMap<Integer, Float> tm = getValues();
        for (Map.Entry<Integer, Float> e : tm.entrySet()) {
          Request r = new Request();
          r.setProjectID(project.getProjectID());
          r.setRejected(false);
          r.setResourceID(res.getResourceID());
          r.setSenderID(userRes.getResourceID());
          r.setWeek(e.getKey());
          r.setRatio(e.getValue());
          try {
            requestDao.insertRequest(r);
View Full Code Here

      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();

          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();
          }
View Full Code Here

  }

  public void init() throws DAOException, ResourceNotFoundException {

    Resource res = rd.getResourceByResourceID(1);
    resourceTable.addContainerProperty("ResourceID", String.class, null);
    resourceTable.addContainerProperty("Resource", String.class, null);
    int start = project.getStartWeek();
    int end = project.getDeadLine();
    int diff = end - start + 3;
View Full Code Here

      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();

View Full Code Here

    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) {
      projectList = projectDao.getAllProjectsByTimeFrame(startNum, endNum);
    } else {
      projectList = projectDao
          .getAllProjectsByResourceInTimeFrame(startNum, endNum,
              u.getResourceID());
    }
    for (Project p : projectList) {
      Object o[] = new Object[] { p.getProjectID(), p.getProjectName(),
          formatter.format(p.getStartDate()),
          formatter.format(p.getDeadLineDate()), };
View Full Code Here

      obj[0] = userResource.getResourceName();
     
      Project p = projectDao.getProjectByProjectID(r.getProjectID());
      obj[1] = p.getProjectName();
     
      Resource res = resourceDao.getResourceByResourceID(r.getResourceID());
      obj[2] = res.getResourceName();
     
      String date = formatter.format(Timestamp.toDate(r.getWeek()));
      obj[3] = date;
      Label l = new Label(Colorizer.floatToHTML(r.getRatio()));
      l.setContentMode(Label.CONTENT_XHTML);
View Full Code Here

    }
   
  }
 
  private void initOtherRequestsTable() throws DAOException, ProjectNotFoundException, ResourceNotFoundException, BookingNotFoundException {
    Resource u;
    otherRequestsTab.removeComponent(otherRequestsTable);
    otherRequestsTable = new Table();
    otherRequestsTab.addComponent(otherRequestsTable);
    u = resourceDao.getResourceByUser(user);
    otherRequestsList = requestDao.getRequestsByProjectLeader(u.getResourceID());
   
    otherRequestsTable.setSelectable(true);
    otherRequestsTable.addActionHandler(new Handler() {
     
      /**
       *
       */
      private static final long serialVersionUID = 4199041679593834096L;

      public void handleAction(Action action, Object sender, Object target) {
        if (ACTION_HIDE.equals(action)) {
          Request r = otherRequestsList.get((Integer)target);
          try {
            requestDao.setRequestVisible(userResource.getResourceID(), r.getRequestID(), false);
            initOtherRequestsTable();
            otherRequestsTab.setImmediate(true);
          } catch (DAOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          } catch (ProjectNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          } catch (ResourceNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          } catch (BookingNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }
     
      public Action[] getActions(Object target, Object sender) {
        return ACTIONS2;
      }
    });
   
    otherRequestsTable.addContainerProperty("Sender", String.class, null);
    otherRequestsTable.addContainerProperty("Project", String.class, null);
    otherRequestsTable.addContainerProperty("Resource", String.class, null);
    otherRequestsTable.addContainerProperty("Date", String.class, null);
    otherRequestsTable.addContainerProperty("Ratio wanted", String.class, null);
    otherRequestsTable.addContainerProperty("Current ratio", String.class, null);
   

    for (int i = 0; i < otherRequestsList.size(); i++) {
      Request r = otherRequestsList.get(i);
      if (r.getWeek() < todayInt) {
        r.setRejected(true);
        requestDao.updateRequest(r);
        continue;
      }
      String[] obj = new String[6];
     
      u = resourceDao.getResourceByResourceID(r.getSenderID());
      obj[0] = u.getResourceName();
     
      Project p = projectDao.getProjectByProjectID(r.getProjectID());
      obj[1] = p.getProjectName();
     
      Resource res = resourceDao.getResourceByResourceID(r.getResourceID());
      obj[2] = res.getResourceName();
     
      String date = formatter.format(Timestamp.toDate(r.getWeek()));
      obj[3] = date;
     
      obj[4] = decFormatter.format(r.getRatio());
View Full Code Here

TOP

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

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.