Package edu.ubb.warp.model

Examples of edu.ubb.warp.model.Resource


      ResourceNotFoundException {
    this.removeComponent(resourceTable);
    resourceTable = new Table();
    resourceList = resourceDao
        .getResourcesByProjectAndGroupAndType(p, g, r);
    Resource userResource = null;
    if (!manager) {
      try {
        userResource = resourceDao.getResourceByUser(user);
      } catch (Exception e) {
        manager = true;
      }
    }
    resourceTable.addContainerProperty("Resource name", Label.class, null);
    resourceTable.addContainerProperty("Resource type", String.class, null);
    for (int index = 0; index < resourceList.size(); index++) {
      Resource res = resourceList.get(index);
      Label label = null;
      if (!manager && res.getResourceID() == userResource.getResourceID()) {
        label = new Label("<b>" + res.getResourceName() + "</b>");
        label.setContentMode(Label.CONTENT_XHTML);
      } else {
        label = new Label(res.getResourceName());
        label.setContentMode(Label.CONTENT_XHTML);
      }
      resourceType = resourceTypeDao.getResourceTypeByResourceTypeID(res
          .getResourceTypeID());
      Object[] obj = new Object[2];
      obj[0] = label;
      obj[1] = resourceType.getResourceTypeName();
      resourceTable.addItem(obj, index);
    }

    resourceTable.addListener(new ItemClickListener() {

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

      public void itemClick(ItemClickEvent event) {

        int id = (Integer) event.getItemId();
        Resource r = resourceList.get(id);
        System.out.println(r.getResourceName());
        refresher.update(r);

      }
    });
   
    resourceTable.addActionHandler( new Handler() {
     
      /**
       *
       */
      private static final long serialVersionUID = -7637588286867019717L;

      public void handleAction(Action action, Object sender, Object target) {
     
          try {
            me.getApplication().getMainWindow().removeWindow(descriptionWindow);
          } catch (Exception e) {
           
          }
          descriptionWindow.removeAllComponents();
          int id = (Integer) target;
          Resource r = resourceList.get(id);
          Panel p = new Panel();
          Label l = new Label(r.getDescription());
          l.setWidth("350px");
          p.addComponent(l);
          descriptionWindow.addComponent(p);
          descriptionWindow.setWidth("400px");
          me.getApplication().getMainWindow().addWindow(descriptionWindow);
View Full Code Here


    rType = rTypeDao.getResourceTypeByResourceTypeName("human");
    resourceList = resourceDao.getResourcesByResourceType(rType);
    resourceTable.addContainerProperty("Resource name", String.class, null);
    resourceTable.addContainerProperty("Resource type", String.class, null);
    for (int index = 0; index < resourceList.size(); index++) {
      Resource r = resourceList.get(index);
      rType = rTypeDao.getResourceTypeByResourceTypeID(r
          .getResourceTypeID());
      String[] obj = new String[2];
      obj[0] = r.getResourceName();
      obj[1] = rType.getResourceTypeName();
      resourceTable.addItem(obj, index);
    }

    // Set table selectable and set listener
View Full Code Here

public class ResourceJdbcDAO implements ResourceDAO {

  public Resource getResourceByUser(User user) throws DAOException,
      ResourceNotFoundException {
    Resource resource = null;
    try {
      String command = "SELECT * FROM `Resources` WHERE `ResourceID` = (SELECT `ResourceID` FROM `ResourceIsUser` WHERE `UserID` = ?)";
      PreparedStatement statement = JdbcConnection.getConnection()
          .prepareStatement(command);
      statement.setInt(1, user.getUserID());
View Full Code Here

    return resource;
  }

  public Resource getResourceByResourceID(int resourceID)
      throws DAOException, ResourceNotFoundException {
    Resource resource = new Resource();
    try {
      String command = "SELECT * FROM `Resources` WHERE `ResourceID` = ?";
      PreparedStatement statement = JdbcConnection.getConnection()
          .prepareStatement(command);
      statement.setInt(1, resourceID);
View Full Code Here

    }
  }

  public Resource getResourceOfUser(User user)
      throws ResourceNotFoundException, DAOException {
    Resource resource = new Resource();
    try {
      String command = "SELECT * FROM `Resources`, `ResourceIsUser` WHERE ResourceIsUser.UserID = ? AND ResourceIsUser.ResourceID = Resources.ResourceID ";
      PreparedStatement statement = JdbcConnection.getConnection()
          .prepareStatement(command);
      statement.setInt(1, user.getUserID());
View Full Code Here

    }
  }

  private Resource getResourceFromResult(ResultSet result)
      throws SQLException {
    Resource resource = new Resource();
    resource.setResourceID(result.getInt("ResourceID"));
    resource.setResourceName(result.getString("ResourceName"));
    resource.setResourceTypeID(result.getInt("ResourceTypeID"));
    resource.setActive(result.getBoolean("Active"));
    resource.setDescription(result.getString("Description"));
    return resource;
  }
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.