Exemple #1
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;
    }
  }
  /* 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;
  }
  /* 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;
  }
 /* 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;
 }
  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
  }
 protected void updateSelectedResource(NonHumanResource resource, boolean editing) {
   try {
     _sb.setSelectedNonHumanResource(resource, editing);
   } catch (CloneNotSupportedException cnse) {
     _msgPanel.error("Could not update form: cloning Exception");
   }
 }
 /* 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;
 }
Exemple #8
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();
  }
  /* 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;
  }
 /* saves a newly added resource or category to the org database */
 public boolean addNewItem(nonHumanMgt.SelType sType) {
   String newName = (String) txtName.getText();
   if ((newName == null) || (newName.length() == 0)) {
     _msgPanel.error("Please enter a name for the new Item.");
     return false;
   }
   switch (sType) {
     case resource:
       return addResource(newName);
     case category:
       return addCategory(newName);
   }
   return false;
 }
  /* saves updates to the values of the currently selected category */
  public boolean saveCategoryChanges(String id) {
    NonHumanCategory category = _orgDataSet.getNonHumanCategory(id);
    if (category == null) {
      _msgPanel.error("Invalid category id: " + id);
      return false;
    }

    // check that any name change is valid
    String name = (String) txtName.getText();
    if ((!name.equals(category.getName())) && _orgDataSet.isKnownNonHumanCategoryName(name)) {
      addDuplicationError("Category");
      return false;
    }

    storeSimpleFieldValues(category);
    _orgDataSet.updateNonHumanCategory(category);
    return true;
  }
 private void addDuplicationError(String type) {
   String dupErrMsg = "There is already a %s by that name - please choose another.";
   _msgPanel.error(String.format(dupErrMsg, type));
 }
Exemple #13
0
 private void completeWorkItem(WorkItemRecord wir, Participant p) {
   String result = _rm.checkinItem(p, wir);
   if (_rm.successful(result)) _sb.removeWarnedForNonEdit(wir.getID());
   else msgPanel.error(result);
 }