Esempio n. 1
0
 private void logout() {
   if (!sb.isRssAlreadyLoggedOn()) {
     sb.doLogout();
   } else {
     sb.setRssAlreadyLoggedOn(false);
   }
 }
Esempio n. 2
0
  public String btnView_action() {
    String itemID = (String) hdnSelectedItemID.getValue();
    if (itemID == null) {
      msgPanel.error("No work item selected. Please select a work item to view.");
      return null;
    }

    WorkItemRecord selectedWIR = getSelectedWIR(itemID);

    // maybe the wir isn't started or was part of a cancellation set and now it's gone
    if (selectedWIR == null) {
      msgPanel.error(
          "Cannot view item contents - it appears that the "
              + "selected item may have been removed or cancelled. "
              + "Please see the log files for details.");
      return null;
    }

    _sb.setDynFormType(ApplicationBean.DynFormType.tasklevel);
    DynamicForm df = (DynamicForm) getBean("DynFormFactory");
    String title = "YAWL 3.0 - Edit Work Item";
    String header = "Edit Work Item: " + selectedWIR.getCaseID();
    if (df.makeForm(title, header, _sb.getTaskSchema(selectedWIR), selectedWIR)) {
      _sb.setVisualiserReferred(true);
      _sb.setVisualiserEditedWIR(selectedWIR);
      return "showDynForm";
    } else {
      msgPanel.error(
          "Cannot view item contents - problem initialising "
              + "dynamic form from task specification. "
              + "Please see the log files for details.");
      return null;
    }
  }
  public void sendOffer() {
    Trade trade = new Trade();
    if (handtohand == true) {
      trade.setStatus("handtohand");
    } else {
      trade.setStatus("opened");
    }
    trade.setOfferingUser(userService.getUserById(SessionBean.getUserId()));
    trade.setReceivingUser(userService.getUserById(SessionBean.getUserForTradeId()));
    trade.setOfferingUserPay(false);
    trade.setReceivingUserPay(false);
    trade.setReceivedByOfferingUser(false);
    trade.setReceivedByReceivingUser(false);
    trade.setDeposit(deposit);
    tradeService.create(trade);
    Trade currentTrade = tradeService.getLastTradeByOfferingUserId(SessionBean.getUserId());
    for (Game g : myGames.getTarget()) {
      OfferingUserTrade out = new OfferingUserTrade();
      out.setOfferingGame(g);
      out.setOfferingTrade(currentTrade);
      offeringUserTradeService.create(out);
    }

    for (Game g : tradeUserGames.getTarget()) {
      ReceivingUserTrade rut = new ReceivingUserTrade();
      rut.setReceivingGame(g);
      rut.setReceivingTrade(currentTrade);
      receivingUserTradeService.create(rut);
    }

    SessionBean.getSession().removeAttribute("tradeuser");
    RequestContext.getCurrentInstance().closeDialog("tradeOffer");
    FacesContext.getCurrentInstance()
        .addMessage(null, new FacesMessage("Trade offer has been sent"));
  }
Esempio n. 4
0
 /**
  * Initialise session data in the session bean
  *
  * @param userid the userid
  * @param handle the session handle supplied by the service
  */
 private void initSession(Participant p, String userid, String handle) {
   sb.setSessionhandle(handle);
   sb.setUserid(userid);
   if (!userid.equals("admin")) {
     sb.setParticipant(p);
     getApplicationBean().addLiveUser(userid);
   }
 }
Esempio n. 5
0
 public void clearAllFieldsAndLists() {
   clearTextFields();
   clearCombos();
   _sb.setNhResourcesCategoryItems(null);
   _sb.setNhResourcesSubcategoryItems(null); // resource tab combo box
   _sb.setNhResourcesSubcategoryList(null); // category tab list box
   lblMembers.setText("Members (0)");
 }
Esempio n. 6
0
 /* fills ui with the selected category's values */
 private void populateGUI(NonHumanCategory category) {
   if (category != null) {
     populateSimpleFields(category);
     _sb.setNhResourcesSubcategoryList(getSubCategoryList(category));
     int membership = _sb.setCategoryMembers(category);
     lblMembers.setText("Members (" + membership + ")");
   }
   _sb.setNhResourcesSubcategoryItems(null); // empty the resource tab combo box
 }
Esempio n. 7
0
 /* removes a subcategory - triggered by categories tab only */
 public String btnRemoveSubCat_action() {
   NonHumanCategory category = getCurrentlySelectedCategory();
   if (category != null) {
     if (category.removeSubCategory(_sb.getNhResourcesSubcategoryChoice())) {
       _orgDataSet.updateNonHumanCategory(category);
       _sb.setNhResourcesSubcategoryChoice("None");
     } else _msgPanel.error("Failed to remove subcategory.");
   }
   return null;
 }
Esempio n. 8
0
 private void showForm(WorkItemRecord wir) {
   FormViewer form = new FormViewer(sb);
   String formURI = form.display(wir);
   if (formURI.startsWith("<failure>")) {
     showMessage(unwrap(formURI));
   } else {
     sb.setFormViewerInstance(form);
     sb.setRssFormWIR(wir);
     sb.setRssFormDisplay(true);
     if (formURI.equals("showDynForm")) formURI = "dynForm.jsp";
     redirect(formURI);
   }
 }
Esempio n. 9
0
  private String validateCredentials(String userid, String password) {
    if (userid == null) {
      return "No userid was specified.";
    }
    if (password == null) {
      return "No password was specified.";
    }

    String loggedOnUserID = sb.getUserid();
    if (loggedOnUserID != null) {
      if (!loggedOnUserID.equals(userid)) {
        return "User '"
            + loggedOnUserID
            + "' is already logged on in this"
            + " browser instance (in another tab or window)."
            + " Only one user logon per browser "
            + " instance is possible. If you wish to view you work"
            + " queued items via your iGoogle Gadget, please "
            + " logout the currently logged on user first.";
      } else sb.setRssAlreadyLoggedOn(true);
    } else {
      if (rm == null) {
        return "Could not connect to work queue, service unavailable.";
      }
      Participant p = rm.getParticipantFromUserID(userid);
      if (p == null) {
        return "Unknown userid: " + userid;
      }
      if (!p.getPassword().equals(password)) {
        return "Incorrect password.";
      }
      if (!rm.hasOrgDataSource()) {
        msgPanel.error(
            "Missing or invalid organisational data source. The resource"
                + " service requires a connection to a valid data source"
                + " that contains organisational data. Please check the"
                + " settings of the 'OrgDataSource' parameter in the service's"
                + " web.xml to ensure a valid data source is set, and/or check"
                + " the configuration properties set for the data source.");
      }
      String handle = rm.login(userid, password, sb.getExternalSessionID());
      if (!rm.successful(handle)) {
        return (msgPanel.format(handle));
      }

      initSession(p, userid, handle);
    }
    return success; // successful login
  }
Esempio n. 10
0
  /* saves updates to the values of the selected resource or category */
  public boolean saveChanges(String id) {
    String activeTab = _sb.getActiveTab();
    if (activeTab.equals("tabResources")) return saveResourceChanges(id);
    else if (activeTab.equals("tabCategories")) return saveCategoryChanges(id);

    return false;
  }
Esempio n. 11
0
  // it was necessary to do it this way rather than using 'jsp:plugin' in the
  // jsf because the 'codebase' parameter does not support dynamic value setting
  public String getAppletHtml() {
    String baseURI = getApplicationBean().getResServiceBaseURI();
    Participant p = _sb.getParticipant();
    Dimension view = getViewSize();
    StringBuilder result = new StringBuilder("<applet width=\"");
    result
        .append(view.width)
        .append("\" height=\"")
        .append(view.height)
        .append("\"")
        .append(" archive=\"visualiser.jar,javax.servlet.jar,jdom-2.0.5.jar,")
        .append(" resourceService.jar,saxon9.jar,log4j-1.2.16.jar,commons-codec-1.9.jar\"")
        .append(" codebase=\"../../visualiserApplet\"")
        .append(" code=\"worklist.WRKLApplet.class\" MAYSCRIPT>")
        .append(" <param name=\"user\" value=\"")
        .append(p.getUserID())
        .append("\"/>")
        .append(" <param name=\"pass\" value=\"")
        .append(p.getPassword())
        .append("\"/>")
        .append(" <param name=\"urYAWL\" value=\"")
        .append(baseURI)
        .append("\"/>")
        .append("</applet>");

    return result.toString();
  }
Esempio n. 12
0
  /* saves updates to the values of the currently selected resource */
  public boolean saveResourceChanges(String id) {
    NonHumanResource cloned = _sb.getSelectedNonHumanResource();
    if (cloned == null) {
      _msgPanel.error("Could not retrieve changes from session");
      return false;
    }
    NonHumanResource resource = _orgDataSet.getNonHumanResource(id);
    if (resource == null) {
      _msgPanel.error("Invalid resource id: " + id);
      return false;
    }

    // check that any name change is valid
    String name = (String) txtName.getText();
    if ((!name.equals(resource.getName())) && _orgDataSet.isKnownNonHumanResourceName(name)) {
      addDuplicationError("Resource");
      return false;
    }
    storeSimpleFieldValues(cloned);
    resource.merge(cloned); // update resource with clone's values
    cloned.clearCategory(); // remove cloned from its category
    _orgDataSet.updateNonHumanResource(resource);
    updateSelectedResource(resource);
    return true;
  }
Esempio n. 13
0
 protected void updateSelectedResource(NonHumanResource resource, boolean editing) {
   try {
     _sb.setSelectedNonHumanResource(resource, editing);
   } catch (CloneNotSupportedException cnse) {
     _msgPanel.error("Could not update form: cloning Exception");
   }
 }
Esempio n. 14
0
 /* triggered by resources tab only */
 public void cbbSubCategory_processValueChange(ValueChangeEvent event) {
   NonHumanResource resource = _sb.getSelectedNonHumanResource();
   if (resource != null) {
     storeSimpleFieldValues(resource);
     resource.setSubCategory((String) event.getNewValue());
   }
 }
Esempio n. 15
0
 /* returns the value of the first listed category, sorted */
 private NonHumanCategory getFirstListedCategory() {
   Option[] catItems = _sb.getNhResourcesCategoryList();
   if ((catItems != null) && (catItems.length > 0)) {
     String catID = (String) catItems[0].getValue();
     return _orgDataSet.getNonHumanCategory(catID);
   }
   return null;
 }
 public void openOfferDialog(User u) {
   SessionBean.getSession().setAttribute("tradeuser", u.getId());
   Map<String, Object> options = new HashMap<String, Object>();
   options.put("resizable", false);
   options.put("draggable", false);
   options.put("contentWidth", 1400);
   options.put("contentHeight", 800);
   options.put("modal", true);
   RequestContext.getCurrentInstance().openDialog("tradeOffer", options, null);
 }
Esempio n. 17
0
 private WorkItemRecord getSelectedWIR(String itemID) {
   Set<WorkItemRecord> wirSet = _sb.getQueue(WorkQueue.STARTED);
   WorkItemRecord selectedWIR = null;
   for (WorkItemRecord wir : wirSet) {
     if (wir.getID().equals(itemID)) {
       selectedWIR = wir;
       break;
     }
   }
   return selectedWIR;
 }
Esempio n. 18
0
 protected void populateGUI(String id, nonHumanMgt.SelType type) {
   switch (type) {
     case resource:
       populateGUI(_sb.getSelectedNonHumanResource(), id);
       break;
     case category:
       populateGUI(_orgDataSet.getNonHumanCategory(id));
       break;
   }
   lbxItems.setSelected(id);
 }
 public DualListModel<Game> getMyGames() {
   myWantedGamesSource = new ArrayList<Game>();
   myWantedGamesTarget = new ArrayList<Game>();
   List<UserGame> wantedUserGameList =
       userGameService.getCanExchangeUserGamesByUserId(SessionBean.getUserId());
   for (UserGame ug : wantedUserGameList) {
     myWantedGamesSource.add(ug.getGame());
   }
   setMyGames((DualListModel<Game>) new DualListModel(myWantedGamesSource, myWantedGamesTarget));
   return myGames;
 }
Esempio n. 20
0
 /* triggered by resources tab only */
 public void cbbCategory_processValueChange(ValueChangeEvent event) {
   NonHumanResource resource = _sb.getSelectedNonHumanResource();
   if (resource != null) {
     storeSimpleFieldValues(resource);
     NonHumanCategory category = _orgDataSet.getNonHumanCategory((String) event.getNewValue());
     if (category != null) {
       resource.setCategory(category);
       resource.setSubCategory("None");
     }
   }
 }
  public String commentPass() {
    /////// Session
    // Bean/////////////////////////////////////////////////////////////////////////////
    Users e = (Users) ActionContext.getContext().getSession().get("user");
    if (e == null) {
      return ERROR;
    }

    SessionBean session = new SessionBean();
    l1 = session.getLecture(lectureID);
    Comment comment = new Comment();
    comment.setUser(e);
    comment.setComment(this.userComment);
    comment.setLecture(l1);

    Comment = session.findCommentByLectureId(lectureID);
    Comment.add(comment);
    session.updateLecture(l1);
    session.saveComment(comment);

    return SUCCESS;
  }
Esempio n. 22
0
  /* fills ui with the selected resource's values */
  private void populateGUI(NonHumanResource resource, String id) {

    // selected resource is null after a selection change
    if (resource == null) {
      resource = _orgDataSet.getNonHumanResource(id);
      updateSelectedResource(resource);
    }
    if (resource != null) {
      populateSimpleFields(resource);
      NonHumanCategory category = resource.getCategory();
      String subCatName = resource.getSubCategoryName();
      if (category == null) {
        category = getFirstListedCategory(); // default
      }
      if (subCatName == null) subCatName = "None";
      if (category != null) {
        cbbCategory.setSelected(category.getID());
        _sb.setNhResourcesSubcategoryItems(getSubCategoryList(category));
        cbbSubCategory.setSelected(subCatName);
      } else _sb.setNhResourcesSubcategoryItems(null); // no categories defined
    }
    _sb.setNhResourcesSubcategoryList(null); // empty the category tab list box
  }
Esempio n. 23
0
 /* adds a new subcategory - triggered by categories tab only */
 public String btnConfirmAddSubCat_action() {
   String name = (String) txtSubCat.getText();
   if ((name != null) && (name.length() > 0)) {
     NonHumanCategory category = getCurrentlySelectedCategory();
     if (category != null) {
       if (category.addSubCategory(name)) { // won't add if duplicate
         _orgDataSet.updateNonHumanCategory(category);
         _sb.setSubCatAddMode(false);
         txtSubCat.setText(null);
       } else _msgPanel.error("Subcategory already exists: " + name);
     }
   } else _msgPanel.error("Please enter a subcategory to add.");
   return null;
 }
Esempio n. 24
0
  /* saves a newly added category to the org database */
  public boolean addCategory(String name) {
    if (!_orgDataSet.isKnownNonHumanCategoryName(name)) {
      NonHumanCategory category = new NonHumanCategory(name);
      storeSimpleFieldValues(category);
      category.addSubCategory("None");
      String newID = _orgDataSet.addNonHumanCategory(category);
      if (_rm.successful(newID)) {
        _sb.setNhResourcesChoice(newID);
        return true;
      } else _msgPanel.error(_msgPanel.format(newID));
    } else addDuplicationError("Category");

    return false;
  }
Esempio n. 25
0
  /* saves a newly added resource to the org database */
  public boolean addResource(String name) {
    if (!_orgDataSet.isKnownNonHumanResourceName(name)) {
      String catID = (String) cbbCategory.getSelected();
      NonHumanCategory category = _orgDataSet.getNonHumanCategory(catID);
      String subCat = (String) cbbSubCategory.getSelected();

      NonHumanResource resource = _sb.getSelectedNonHumanResource();
      if (resource == null) resource = new NonHumanResource();
      resource.setName(name);
      resource.setCategory(category);
      resource.setSubCategory(subCat);
      resource.setDescription((String) txtDesc.getText());
      resource.setNotes((String) txtNotes.getText());
      String newID = _orgDataSet.addNonHumanResource(resource);
      if (_rm.successful(newID)) {
        updateSelectedResource(resource, false);
        _sb.setNhResourcesChoice(newID);
        return true;
      } else _msgPanel.error(_msgPanel.format(newID));
    } else addDuplicationError("Resource");

    return false;
  }
Esempio n. 26
0
 /* enable or disable fields depending on whether we are in browse/edit or add mode */
 public void setAddMode(boolean adding, String selectedTab) {
   lbxItems.setDisabled(adding);
   if (selectedTab.equals("tabCategories")) {
     lbxSubCatItems.setDisabled(adding);
     btnAddSubCat.setDisabled(adding);
     btnRemoveSubCat.setDisabled(adding);
     disableInputFields(!adding);
     disableSubCatButtons(adding);
     _sb.setCategoryMembers(null);
   }
   if (adding) clearTextFields();
   txtName.setText("");
   lblMembers.setText("Members (0)");
 }
Esempio n. 27
0
  public void prerender() {
    if (sb.isRssFormDisplay()) {
      String msg = "";
      FormViewer form = sb.getFormViewerInstance();
      if (form != null) {
        msg = form.postDisplay(sb.getRssFormWIR());
        sb.resetPostFormDisplay();
        if (successful(msg)) {
          msg = "Work Item successfully processed.";
        }
      } else {
        msg = "Unsuccessful form completion - could not finalise form.";
      }
      showMessage(msg + " Please click the button below to close this window/tab.");
    } else {
      HttpServletRequest request = getRequest();
      String userid = request.getParameter("userid");
      String password = request.getParameter("password");
      String itemid = request.getParameter("itemid");

      String msg = validateCredentials(userid, password);
      WorkItemRecord wir = null;
      if (successful(msg)) {
        wir = rm.getWorkItemRecord(itemid);
        if (wir == null) {
          msg =
              "Unknown Work Item ID - perhaps it has already been actioned"
                  + " and/or moved to another queue. Please refresh your worklist.";
        }
      }
      if (successful(msg)) {
        startAndShow(userid, wir);
      } else {
        showMessage(msg);
      }
    }
  }
  public String login() {
    int userId = UserHandler.loginUser(username, password);

    if (userId > -1) {
      setLoggedIn(true);

      HttpSession session = SessionBean.getSession();

      session.setAttribute("userId", userId);
      session.setAttribute("username", username);

      return "timeline.xhtml";
    }

    return "index.xhtml";
  }
  public boolean isLoggedIn() {
    HttpSession session = SessionBean.getSession();

    if (session != null) {
      System.out.println("session");
      String user = (String) session.getAttribute("username");
      if (user != null) {
        System.out.println("user");
        System.out.println("LoginBean: found session");
        System.out.println("LoginBean: session username = "******"username"));
        return true;
      }
    }

    System.out.println("LoginBean: didn't find session");
    return false;
  }
Esempio n. 30
0
  /** updates a workitem after editing on a dynamic form */
  private void postEditWIR() {
    if (_sb.isWirEdit()) {
      WorkItemRecord wir = _sb.getVisualiserEditedWIR();
      if (wir != null) {
        Element data =
            JDOMUtil.stringToElement(((DynFormFactory) getBean("DynFormFactory")).getDataList());
        wir.setUpdatedData(data);
        _rm.getWorkItemCache().update(wir);

        if (_sb.isCompleteAfterEdit()) {
          completeWorkItem(wir, _sb.getParticipant());
        }
      } else {
        msgPanel.error("Could not complete workitem. Check log for details.");
      }
    }
    _sb.setWirEdit(false);
    _sb.setCompleteAfterEdit(false);
    _sb.setVisualiserReferred(false);
    _sb.setVisualiserEditedWIR(null);
    if (msgPanel.hasMessage()) forceRefresh();
  }