コード例 #1
0
 public Map<String, String> getNonHumanCategoryIdentifiers() {
   Map<String, String> idMap = new Hashtable<String, String>();
   for (NonHumanCategory r : getNonHumanCategories()) {
     idMap.put(r.getID(), r.getName());
   }
   return idMap;
 }
コード例 #2
0
 public Set<NonHumanSubCategory> getNonHumanSubCategories() {
   Set<NonHumanSubCategory> set = new HashSet<NonHumanSubCategory>();
   for (NonHumanCategory c : nonHumanCategoryMap.values()) {
     set.addAll(c.getSubCategories());
   }
   return set;
 }
コード例 #3
0
 public String getNonHumanCategoryNames() {
   XNode node = new XNode("nonHumanCategoryNames");
   for (NonHumanCategory r : nonHumanCategoryMap.values()) {
     node.addChild("name", r.getName());
   }
   return node.toString();
 }
コード例 #4
0
  public String getNonHumanCategoriesAsXML() {
    Set<NonHumanCategory> rList = new TreeSet<NonHumanCategory>(nonHumanCategoryMap.values());

    StringBuilder xml = new StringBuilder("<nonhumancategories>");
    for (NonHumanCategory r : rList) xml.append(r.toXML());
    xml.append("</nonhumancategories>");
    return xml.toString();
  }
コード例 #5
0
 /* gets the full list of subcategories for a given category as listbox items */
 private Option[] getSubCategoryList(NonHumanCategory category) {
   Option[] subCatList = new Option[category.getSubCategoryCount()];
   int i = 0;
   for (NonHumanSubCategory subCat : category.getSubCategories()) {
     subCatList[i++] = new Option(subCat.getName());
   }
   Arrays.sort(subCatList, new OptionComparator());
   return subCatList;
 }
コード例 #6
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;
 }
コード例 #7
0
 public String getNonHumanCategorySet() {
   XNode node = new XNode("nonHumanCategorySet");
   for (NonHumanCategory category : nonHumanCategoryMap.values()) {
     XNode categoryNode = node.addChild("category");
     categoryNode.addAttribute("name", category.getName());
     for (String subcategory : category.getSubCategoryNames()) {
       categoryNode.addChild("subcategory", subcategory);
     }
   }
   return node.toString();
 }
コード例 #8
0
 public String getNonHumanSubCategoriesAsXML(String categoryID) {
   XNode node = new XNode("nonHumanSubCategories");
   NonHumanCategory nhCategory = getNonHumanCategory(categoryID);
   if (nhCategory != null) {
     node.addAttribute("category", categoryID);
     for (String subcategory : nhCategory.getSubCategoryNames()) {
       node.addChild("subcategory", subcategory);
     }
   }
   return node.toString();
 }
コード例 #9
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;
  }
コード例 #10
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;
 }
コード例 #11
0
 public Set<NonHumanResource> getNonHumanResources(NonHumanCategory category, String subcategory) {
   Set<NonHumanResource> resources = new HashSet<NonHumanResource>();
   if (category != null) {
     resources = category.getSubCategoryResources(subcategory);
   }
   return resources;
 }
コード例 #12
0
 public String addNonHumanCategory(NonHumanCategory c) {
   if (isDataEditable(ResUnit.NonHumanCategory)) {
     String newID = getDataSource(ResUnit.NonHumanCategory).insert(c);
     if (!hasDefaultDataSource(ResUnit.NonHumanCategory)) c.setID(newID);
     putNonHumanCategory(c);
     return newID;
   } else return fail("External NonHumanCategory dataset is read-only");
 }
コード例 #13
0
  /* 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;
  }
コード例 #14
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
  }
コード例 #15
0
 private void populateSimpleFields(NonHumanCategory category) {
   populateSimpleFields(category.getName(), category.getDescription(), category.getNotes());
 }
コード例 #16
0
 private void storeSimpleFieldValues(NonHumanCategory category) {
   String name = (String) txtName.getText();
   if (name.length() > 0) category.setName(name);
   category.setDescription((String) txtDesc.getText());
   category.setNotes((String) txtNotes.getText());
 }
コード例 #17
0
ファイル: NonHumanCategory.java プロジェクト: adamsmj/yawl
 public int compareTo(NonHumanCategory other) {
   if (other == null) return 1;
   return this.getName().compareTo(other.getName());
 }
コード例 #18
0
 public boolean isKnownNonHumanCategory(NonHumanCategory c) {
   return isKnownNonHumanCategory(c.getID());
 }
コード例 #19
0
 public void putNonHumanCategory(NonHumanCategory r) {
   nonHumanCategoryMap.put(r.getID(), r);
   setChangeStamp(ResUnit.NonHumanCategory);
 }
コード例 #20
0
 public NonHumanCategory getNonHumanCategoryByName(String name) {
   for (NonHumanCategory r : nonHumanCategoryMap.values()) {
     if (r.getName().equalsIgnoreCase(name)) return r;
   }
   return null; // no match
 }
コード例 #21
0
 public void delNonHumanCategory(NonHumanCategory r) {
   nonHumanCategoryMap.remove(r.getID());
   setChangeStamp(ResUnit.NonHumanCategory);
 }