Package edu.ubb.warp.model

Examples of edu.ubb.warp.model.Group


      groupsres.addContainerProperty("Group ID", String.class, null);
      groupsres.addContainerProperty("Group Name", String.class, null);
      // list.setVisibleColumns(new Object[] { "Type Name" });
      for (int i = 0; i < groupArray.size(); i++) {
        Group group = groupArray.get(i);
        groupsres.addItem(
            new Object[] { Integer.toString(group.getGroupID()),
                group.getGroupName() }, i);
        groupnumberres++;
      }
    } catch (DAOException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    groupsres.setVisibleColumns(new Object[] {"Group Name"});
    // Options
    resName.setMaxLength(45);
    resDescription.setMaxLength(250);
    resDescription.setRows(6);
    resDescription.setColumns(25);

    checb.setValue(true);
    groupsres.setSelectable(true);
    groupsres.setMultiSelect(true);
    groupsres.setHeight("300px");
    groupsres.setWidth("350px");
    groupsres.select(groupsres.firstItemId());
    groupsres.setNullSelectionAllowed(false);

    resLayout.setSizeFull();
    resLayout.setSpacing(true);

   
   
    HorizontalLayout nameLayout = new HorizontalLayout();
    nameLayout.addComponent(resLabe);
    resLayout.addComponent(nameLayout);
    resLayout.setComponentAlignment(nameLayout, Alignment.MIDDLE_RIGHT);
    HorizontalLayout layout1 = new  HorizontalLayout();
    layout1.addComponent(resName);
    layout1.addComponent(checb);
    layout1.setSpacing(true);
    resLayout.addComponent(layout1);


    HorizontalLayout descriptLayout = new HorizontalLayout();
    descriptLayout.addComponent(descriptionLabelres);
    resLayout.addComponent(descriptLayout);
    resLayout.setComponentAlignment(descriptLayout, Alignment.MIDDLE_RIGHT);
    resLayout.addComponent(resDescription);
    resLayout.setHeight("200");

    HorizontalLayout horizont = new HorizontalLayout();
    horizont.addComponent(resLayout);
    horizont.setComponentAlignment(resLayout, Alignment.MIDDLE_CENTER);
    horizont.addComponent(list);
    horizont.setSpacing(true);
   
    HorizontalLayout horizontlay = new HorizontalLayout();
    horizontlay.addComponent(horizont);
    horizontlay.setComponentAlignment(horizont, Alignment.MIDDLE_CENTER);
    horizontlay.setSizeFull();
   
    resPanel.addComponent(horizontlay);
   
    HorizontalLayout groupLayout = new HorizontalLayout();
    //groupLayout.addComponent(list);
    groupLayout.addComponent(groupsres);
    groupLayout.addComponent(editGroupRes);
    groupLayout.setSpacing(true);
    HorizontalLayout groupLayoutLayout = new HorizontalLayout();
    groupLayoutLayout.addComponent(groupLayout);
    groupLayoutLayout.setComponentAlignment(groupLayout,
        Alignment.MIDDLE_CENTER);
    groupLayoutLayout.setSizeFull();
    groupLayoutLayout.setSpacing(true);
    resPanel.addComponent(groupLayoutLayout);

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.addComponent(save);
    HorizontalLayout buttonLayoutLayout = new HorizontalLayout();
    buttonLayoutLayout.addComponent(buttonLayout);
    buttonLayoutLayout.setComponentAlignment(buttonLayout,
        Alignment.MIDDLE_CENTER);
    buttonLayoutLayout.setSizeFull();
    buttonLayoutLayout.setHeight("35");

    save.setWidth("150");
    resPanel.addComponent(buttonLayoutLayout);

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

      public void buttonClick(ClickEvent event) {

        if ((resName.toString().length() != 0)
            && (Integer.parseInt(list.getItem(list.getValue())
                .getItemProperty("Type ID").toString()) != 0)) {
          resource.setResourceTypeID(Integer.parseInt(list
              .getItem(list.getValue())
              .getItemProperty("Type ID").toString()));
          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();
                gr.setGroupID((Integer.parseInt(groups
                    .getItem(i).getItemProperty("Group ID")
                    .toString())));
                gr.setGroupName(groups.getItem(i)
                    .getItemProperty("Group Name")
                    .toString());
                df.getResourceDAO().addResourceToGroup(
                    resource, gr);

              }
            }
            me.getApplication().getMainWindow()
                .setContent(new HubPageUI(u));
          } catch (ResourceNameExistsException e) {
            e.printStackTrace();
            me.getApplication().getMainWindow()
                .showNotification("Database Error!");
          } catch (DAOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }

        } else {
          System.out.println("Ures!");
          me.getApplication().getMainWindow()
              .showNotification("Data error!");
        }
      }
    });

    editGroupRes.addListener(new ClickListener() {

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

      public void buttonClick(ClickEvent event) {
        final Window w = new Window();
        final TextField newGroup = new TextField();
        Button saveGroup = new Button("Save");
        w.addComponent(newGroup);
        w.addComponent(saveGroup);
        me.getApplication().getMainWindow().addWindow(w);
       
        saveGroup.addListener(new ClickListener() {
          /**
           *
           */
          private static final long serialVersionUID = -8351414499108265541L;

          public void buttonClick(ClickEvent event) {
            Group gr = new Group();
            gr.setGroupName(newGroup.getValue().toString());
            try {
              df.getGroupDAO().insertGroup(gr);
            } catch (GroupExistsException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
View Full Code Here


      groups.addContainerProperty("Group ID", String.class, null);
      groups.addContainerProperty("Group Name", String.class, null);
      // list.setVisibleColumns(new Object[] { "Type Name" });
      for (int i = 0; i < groupArray.size(); i++) {
        Group group = groupArray.get(i);
        groups.addItem(
            new Object[] { Integer.toString(group.getGroupID()),
                group.getGroupName() }, i);
        groupnumber++;
      }
    } catch (DAOException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

   
    editGroupUser.addListener(new ClickListener() {

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

      public void buttonClick(ClickEvent event) {
        final Window w = new Window();
        final TextField newGroup = new TextField();
        Button saveGroup = new Button("Save");
        w.addComponent(newGroup);
        w.addComponent(saveGroup);
        me.getApplication().getMainWindow().addWindow(w);
       
        saveGroup.addListener(new ClickListener() {
          /**
           *
           */
          private static final long serialVersionUID = 552144821556431589L;

          public void buttonClick(ClickEvent event) {
            Group gr = new Group();
            gr.setGroupName(newGroup.getValue().toString());
            try {
              df.getGroupDAO().insertGroup(gr);
            } catch (GroupExistsException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              me.getApplication().getMainWindow()
              .showNotification("This group exists!");
             
            }
            me.getApplication().getMainWindow().removeWindow(w);
            //a group tabla ujra feltoltese
           
            me.getApplication().getMainWindow().setContent(new NewResourcePageUI(user));
           
           
          }
        });
      }
    });
   
    groups.setVisibleColumns(new Object[] {"Group Name"});
    groups.select(groups.firstItemId());
    groups.setNullSelectionAllowed(false);

    HorizontalLayout groupLayout = new HorizontalLayout();
    groupLayout.addComponent(groups);
    groupLayout.addComponent(editGroupUser);
    groupLayout.setSpacing(true);
    HorizontalLayout groupLayoutLayout = new HorizontalLayout();
    groupLayoutLayout.addComponent(groupLayout);
    groupLayoutLayout.setSizeFull();
    groupLayoutLayout.setComponentAlignment(groupLayout,
        Alignment.MIDDLE_CENTER);
    userPanel.addComponent(groupLayoutLayout);

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.addComponent(saveUser);
    HorizontalLayout buttonLayoutLayout = new HorizontalLayout();
    buttonLayoutLayout.addComponent(buttonLayout);
    buttonLayoutLayout.setComponentAlignment(buttonLayout,
        Alignment.MIDDLE_CENTER);
    buttonLayoutLayout.setSizeFull();
    buttonLayoutLayout.setHeight("70");
    userPanel.addComponent(buttonLayoutLayout);

    saveUser.setWidth("150");
    // saveUser.setImmediate(true);
    saveUser.addListener(new ClickListener() {

      private static final long serialVersionUID = 1L;

      public void buttonClick(ClickEvent event) {

        if (((nameText.toString()).length() > 0)
            && ((emailText.toString()).length() > 0)
            && ((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);
              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++) {

                if (groups.isSelected(i)) {

                  Group gr = new Group();
                  gr.setGroupID((Integer.parseInt(groups
                      .getItem(i)
                      .getItemProperty("Group ID")
                      .toString())));
                  gr.setGroupName(groups.getItem(i)
                      .getItemProperty("Group Name")
                      .toString());
                  df.getResourceDAO().addResourceToGroup(res,
                      gr);

View Full Code Here

import edu.ubb.warp.model.Group;

public class GroupJdbcDAO implements GroupDAO {
  public Group getGroupByGroupID(int groupID) throws DAOException,
      GroupNotFoundException {
    Group group = null;
    try {
      String command = "SELECT * FROM `Groups` WHERE `GroupID` = ?";
      PreparedStatement statement = JdbcConnection.getConnection()
          .prepareStatement(command);
      statement.setInt(1, groupID);
View Full Code Here

    return group;
  }

  public Group getGroupByGroupName(String groupName) throws DAOException,
      GroupNotFoundException {
    Group group = null;
    try {
      String command = "SELECT * FROM `Groups` WHERE `GroupName` = ?";
      PreparedStatement statement = JdbcConnection.getConnection()
          .prepareStatement(command);
      statement.setString(1, groupName);
View Full Code Here

      throw new DAOException();
    }
  }

  private Group getGroupFromResult(ResultSet result) throws SQLException {
    Group group = new Group();
    group.setGroupID(result.getInt("GroupID"));
    group.setGroupName(result.getString("GroupName"));
    return group;
  }
View Full Code Here

TOP

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

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.