Exemplo n.º 1
0
  /**
   * Go to detail page
   *
   * @return forward to DETAIL page
   */
  public String detail() {
    Integer id = Integer.parseInt(FacesUtils.getRequestParameter(ROW_ID));
    tag = manager.getEntityById(id);

    return SpringUtils.isAclPermissionGranted(tag, BasePermission.WRITE)
        ? NavigationResults.EDIT
        : NavigationResults.DETAIL;
  }
Exemplo n.º 2
0
  /**
   * Save bean and stay on it
   *
   * @return forward to list page
   */
  public String save() {

    doBeforeSave();

    if (tag.getId() == null) {
      manager.insertEntity(tag);
    } else {
      manager.updateEntity(tag);
    }

    // Calls an after save action
    String result = doAfterSave(NavigationResults.LIST);

    // Unselect object
    tag = null;

    return result;
  }
Exemplo n.º 3
0
 /**
  * Delete bean and go back to beans list
  *
  * @return forward to LIST page
  */
 public String delete() {
   try {
     manager.deleteEntity(tag);
     tag = null;
     return NavigationResults.LIST;
   } catch (Exception e) {
     FacesUtils.addErrorMessage(null, "tag.error.referenced");
     return null;
   }
 }
Exemplo n.º 4
0
 /**
  * List tags. Order depends on Faces parameter sort.
  *
  * @return the list of all tags sorted by requested criterion
  */
 public List<Tag> getAll() {
   return manager.getAllEntities(search, new SortCriteria(sortColumn, sortAscending));
 }
Exemplo n.º 5
0
public class TagBean extends BaseBean {

  private static final long serialVersionUID = -7427390897740849690L;

  /* Tag - generated by stajanov (do not edit/delete) */

  /** Logger */
  private static final Log log = LogFactory.getLog(TagBean.class);

  /** Active search object */
  private TagSearch search = new TagSearch();

  /** Manager */
  private static TagManager manager = TagManager.getDefault();

  /** Upload service */
  private static final Uploader uploader = UploaderFactory.getInstance("tag");

  /** Active Tag object */
  private Tag tag;

  /** Default sort column */
  private String sortColumn = "name";

  /** Default sort order */
  private boolean sortAscending = true;

  /**
   * List tags. Order depends on Faces parameter sort.
   *
   * @return the list of all tags sorted by requested criterion
   */
  public List<Tag> getAll() {
    return manager.getAllEntities(search, new SortCriteria(sortColumn, sortAscending));
  }

  // Getters to list possible values of related entities

  /**
   * Get the list of all contactTags selected
   *
   * @return the list of all contactTags selected
   */
  public List<SelectItem> getContactTagsSelected() {
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    List<Contact> refs = this.getContactTags();
    for (Contact ref : refs) {
      ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
  }

  /**
   * Get the list of all contactTagss
   *
   * @return the list of all contactTagss
   */
  public List<SelectItem> getContactTagss() {
    List<Contact> refs = ContactManager.getDefault().getAllEntities(null, new SortCriteria("name"));

    List<SelectItem> ret = new ArrayList<SelectItem>();
    for (Contact ref : refs) {
      ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
  }

  /**
   * Get the list of all positionTags selected
   *
   * @return the list of all positionTags selected
   */
  public List<SelectItem> getPositionTagsSelected() {
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    List<Position> refs = this.getPositionTags();
    for (Position ref : refs) {
      ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
  }

  /**
   * Get the list of all positionTagss
   *
   * @return the list of all positionTagss
   */
  public List<SelectItem> getPositionTagss() {
    List<Position> refs =
        PositionManager.getDefault().getAllEntities(null, new SortCriteria("name"));

    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    for (Position ref : refs) {
      ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
  }

  /**
   * Get the list of all departmentTags selected
   *
   * @return the list of all departmentTags selected
   */
  public List<SelectItem> getDepartmentTagsSelected() {
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    List<Department> refs = this.getDepartmentTags();
    for (Department ref : refs) {
      ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
  }

  /**
   * Get the list of all departmentTagss
   *
   * @return the list of all departmentTagss
   */
  public List<SelectItem> getDepartmentTagss() {
    List<Department> refs =
        DepartmentManager.getDefault().getAllEntities(null, new SortCriteria("name"));

    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    for (Department ref : refs) {
      ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
  }

  /**
   * Get the list of all organizationTags selected
   *
   * @return the list of all organizationTags selected
   */
  public List<SelectItem> getOrganizationTagsSelected() {
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    List<Organization> refs = this.getOrganizationTags();
    for (Organization ref : refs) {
      ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
  }

  /**
   * Get the list of all organizationTagss
   *
   * @return the list of all organizationTagss
   */
  public List<SelectItem> getOrganizationTagss() {
    List<Organization> refs =
        OrganizationManager.getDefault().getAllEntities(null, new SortCriteria("name"));

    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    for (Organization ref : refs) {
      ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
  }

  // Getters to list possible values of enum fields

  // Methods to create/remove instances of one-to-many entities (slave
  // entities)

  /**
   * Create a new empty instance of the one-to-many field
   *
   * @return forward to the same page
   */
  public String createContactTags() {
    Contact item = new Contact();

    if (tag.getContactTags() == null) {
      tag.setContactTags(new HashSet());
    }
    tag.getContactTags().add(item);
    return null;
  }

  /**
   * Create a new empty instance of the one-to-many field
   *
   * @return forward to the same page
   */
  public String editContactTags() {
    Contact item = new Contact();

    if (tag.getContactTags() == null) {
      tag.setContactTags(new HashSet());
    }
    tag.getContactTags().add(item);
    return null;
  }

  /**
   * Delete selected instance of the one-to-many field
   *
   * @return forward to the same page
   */
  public String deleteContactTags() {
    UIData table = (UIData) FacesUtils.getComponent("tag:contactTags");
    tag.getContactTags().remove(table.getRowData());
    return null;
  }

  /**
   * Create a new empty instance of the one-to-many field
   *
   * @return forward to the same page
   */
  public String createPositionTags() {
    Position item = new Position();

    if (tag.getPositionTags() == null) {
      tag.setPositionTags(new HashSet());
    }
    tag.getPositionTags().add(item);
    return null;
  }

  /**
   * Create a new empty instance of the one-to-many field
   *
   * @return forward to the same page
   */
  public String editPositionTags() {
    Position item = new Position();

    if (tag.getPositionTags() == null) {
      tag.setPositionTags(new HashSet());
    }
    tag.getPositionTags().add(item);
    return null;
  }

  /**
   * Delete selected instance of the one-to-many field
   *
   * @return forward to the same page
   */
  public String deletePositionTags() {
    UIData table = (UIData) FacesUtils.getComponent("tag:positionTags");
    tag.getPositionTags().remove(table.getRowData());
    return null;
  }

  /**
   * Create a new empty instance of the one-to-many field
   *
   * @return forward to the same page
   */
  public String createDepartmentTags() {
    Department item = new Department();

    if (tag.getDepartmentTags() == null) {
      tag.setDepartmentTags(new HashSet());
    }
    tag.getDepartmentTags().add(item);
    return null;
  }

  /**
   * Create a new empty instance of the one-to-many field
   *
   * @return forward to the same page
   */
  public String editDepartmentTags() {
    Department item = new Department();

    if (tag.getDepartmentTags() == null) {
      tag.setDepartmentTags(new HashSet());
    }
    tag.getDepartmentTags().add(item);
    return null;
  }

  /**
   * Delete selected instance of the one-to-many field
   *
   * @return forward to the same page
   */
  public String deleteDepartmentTags() {
    UIData table = (UIData) FacesUtils.getComponent("tag:departmentTags");
    tag.getDepartmentTags().remove(table.getRowData());
    return null;
  }

  /**
   * Create a new empty instance of the one-to-many field
   *
   * @return forward to the same page
   */
  public String createOrganizationTags() {
    Organization item = new Organization();

    if (tag.getOrganizationTags() == null) {
      tag.setOrganizationTags(new HashSet());
    }
    tag.getOrganizationTags().add(item);
    return null;
  }

  /**
   * Create a new empty instance of the one-to-many field
   *
   * @return forward to the same page
   */
  public String editOrganizationTags() {
    Organization item = new Organization();

    if (tag.getOrganizationTags() == null) {
      tag.setOrganizationTags(new HashSet());
    }
    tag.getOrganizationTags().add(item);
    return null;
  }

  /**
   * Delete selected instance of the one-to-many field
   *
   * @return forward to the same page
   */
  public String deleteOrganizationTags() {
    UIData table = (UIData) FacesUtils.getComponent("tag:organizationTags");
    tag.getOrganizationTags().remove(table.getRowData());
    return null;
  }

  /**
   * Whether or not create button is available for user
   *
   * @return true if user can create objects of type Tag
   */
  public boolean isCreateAvailable() {
    return SpringUtils.isRolePermissionGranted(Permission.Entity_Create(Tag.class));
  }

  /**
   * Whether or not edit button is available for user
   *
   * @return true if user can edit current object
   */
  public boolean isEditAvailable() {
    return SpringUtils.isAclPermissionGranted(tag, BasePermission.WRITE);
  }

  /**
   * Whether or not delete button is available for user
   *
   * @return true if user can delete current object
   */
  public boolean isDeleteAvailable() {
    return (tag.getId() != null) && SpringUtils.isAclPermissionGranted(tag, BasePermission.DELETE);
  }

  /**
   * Go to create page
   *
   * @return forward to CREATE page
   */
  public String create() {
    tag = new Tag();
    tag.setInsertDate(new Date());
    return NavigationResults.CREATE;
  }

  /**
   * Go to detail page
   *
   * @return forward to DETAIL page
   */
  public String detail() {
    Integer id = Integer.parseInt(FacesUtils.getRequestParameter(ROW_ID));
    tag = manager.getEntityById(id);

    return SpringUtils.isAclPermissionGranted(tag, BasePermission.WRITE)
        ? NavigationResults.EDIT
        : NavigationResults.DETAIL;
  }

  /**
   * Save bean and stay on it
   *
   * @return forward to list page
   */
  public String save() {

    doBeforeSave();

    if (tag.getId() == null) {
      manager.insertEntity(tag);
    } else {
      manager.updateEntity(tag);
    }

    // Calls an after save action
    String result = doAfterSave(NavigationResults.LIST);

    // Unselect object
    tag = null;

    return result;
  }

  /**
   * Delete bean and go back to beans list
   *
   * @return forward to LIST page
   */
  public String delete() {
    try {
      manager.deleteEntity(tag);
      tag = null;
      return NavigationResults.LIST;
    } catch (Exception e) {
      FacesUtils.addErrorMessage(null, "tag.error.referenced");
      return null;
    }
  }

  /**
   * Go back to beans list
   *
   * @return forward to LIST page
   */
  public String list() {
    return NavigationResults.LIST;
  }

  /**
   * Reset search criteria
   *
   * @return forward to LIST page
   */
  public String reset() {
    search.reset();
    return list();
  }

  /**
   * Go to search page
   *
   * @return forward to SEARCH page
   */
  public String search() {
    return NavigationResults.SEARCH;
  }

  /**
   * Check if we have an active object.
   *
   * @return true is an object is selected
   */
  public boolean isTagSelected() {
    return tag != null;
  }

  // Getters and setters to manipulate sorting
  public boolean isSortAscending() {
    return sortAscending;
  }

  public void setSortAscending(boolean sortAscending) {
    this.sortAscending = sortAscending;
  }

  public String getSortColumn() {
    return sortColumn;
  }

  public void setSortColumn(String sortColumn) {
    this.sortColumn = sortColumn;
  }

  // Getters and setters to handle search
  public TagSearch getSearch() {
    return search;
  }

  public String getSearchName() {
    return search.getName();
  }

  public void setSearchName(String val) {
    if (search.isNameSet()) {
      search.setName(val);
    }
  }

  public boolean isSearchNameValid() {
    return search.isNameSet();
  }

  public void setSearchNameValid(boolean val) {
    if (val) {
      search.setName(search.getName());
    } else {
      search.unsetName();
    }
  }

  public String getSearchDescription() {
    return search.getDescription();
  }

  public void setSearchDescription(String val) {
    if (search.isDescriptionSet()) {
      search.setDescription(val);
    }
  }

  public boolean isSearchDescriptionValid() {
    return search.isDescriptionSet();
  }

  public void setSearchDescriptionValid(boolean val) {
    if (val) {
      search.setDescription(search.getDescription());
    } else {
      search.unsetDescription();
    }
  }

  public Integer getSearchOwnerId() {
    return search.getOwnerId();
  }

  public void setSearchOwnerId(Integer val) {
    if (search.isOwnerIdSet()) {
      search.setOwnerId(val);
    }
  }

  public boolean isSearchOwnerIdValid() {
    return search.isOwnerIdSet();
  }

  public void setSearchOwnerIdValid(boolean val) {
    if (val) {
      search.setOwnerId(search.getOwnerId());
    } else {
      search.unsetOwnerId();
    }
  }

  public Integer getSearchDepartmentId() {
    return search.getDepartmentId();
  }

  public void setSearchDepartmentId(Integer val) {
    if (search.isDepartmentIdSet()) {
      search.setDepartmentId(val);
    }
  }

  public boolean isSearchDepartmentIdValid() {
    return search.isDepartmentIdSet();
  }

  public void setSearchDepartmentIdValid(boolean val) {
    if (val) {
      search.setDepartmentId(search.getDepartmentId());
    } else {
      search.unsetDepartmentId();
    }
  }

  public Date getSearchStartInsertDate() {
    return search.getStartInsertDate();
  }

  public void setSearchStartInsertDate(Date val) {
    if (val != null) {
      search.setStartInsertDate(val);
    } else {
      search.unsetStartInsertDate();
    }
  }

  public boolean isSearchStartInsertDateValid() {
    return search.isStartInsertDateSet();
  }

  public void setSearchStartInsertDateValid(boolean val) {
    if (val) {
      search.setStartInsertDate(search.getStartInsertDate());
    } else {
      search.unsetStartInsertDate();
    }
  }

  public Date getSearchEndInsertDate() {
    return search.getEndInsertDate();
  }

  public void setSearchEndInsertDate(Date val) {
    if (val != null) {
      search.setEndInsertDate(val);
    } else {
      search.unsetEndInsertDate();
    }
  }

  public boolean isSearchEndInsertDateValid() {
    return search.isEndInsertDateSet();
  }

  public void setSearchEndInsertDateValid(boolean val) {
    if (val) {
      search.setEndInsertDate(search.getEndInsertDate());
    } else {
      search.unsetEndInsertDate();
    }
  }

  public Date getSearchStartUpdateDate() {
    return search.getStartUpdateDate();
  }

  public void setSearchStartUpdateDate(Date val) {
    if (val != null) {
      search.setStartUpdateDate(val);
    } else {
      search.unsetStartUpdateDate();
    }
  }

  public boolean isSearchStartUpdateDateValid() {
    return search.isStartUpdateDateSet();
  }

  public void setSearchStartUpdateDateValid(boolean val) {
    if (val) {
      search.setStartUpdateDate(search.getStartUpdateDate());
    } else {
      search.unsetStartUpdateDate();
    }
  }

  public Date getSearchEndUpdateDate() {
    return search.getEndUpdateDate();
  }

  public void setSearchEndUpdateDate(Date val) {
    if (val != null) {
      search.setEndUpdateDate(val);
    } else {
      search.unsetEndUpdateDate();
    }
  }

  public boolean isSearchEndUpdateDateValid() {
    return search.isEndUpdateDateSet();
  }

  public void setSearchEndUpdateDateValid(boolean val) {
    if (val) {
      search.setEndUpdateDate(search.getEndUpdateDate());
    } else {
      search.unsetEndUpdateDate();
    }
  }

  public List<Contact> getSearchContactTags() {
    return search.getContactTags();
  }

  public void setSearchContactTags(List<Contact> val) {
    if (search.isContactTagsSet()) {
      search.setContactTags(val);
    }
  }

  public boolean isSearchContactTagsValid() {
    return search.isContactTagsSet();
  }

  public void setSearchContactTagsValid(boolean val) {
    if (val) {
      search.setContactTags(search.getContactTags());
    } else {
      search.unsetContactTags();
    }
  }

  public List<Position> getSearchPositionTags() {
    return search.getPositionTags();
  }

  public void setSearchPositionTags(List<Position> val) {
    if (search.isPositionTagsSet()) {
      search.setPositionTags(val);
    }
  }

  public boolean isSearchPositionTagsValid() {
    return search.isPositionTagsSet();
  }

  public void setSearchPositionTagsValid(boolean val) {
    if (val) {
      search.setPositionTags(search.getPositionTags());
    } else {
      search.unsetPositionTags();
    }
  }

  public List<Department> getSearchDepartmentTags() {
    return search.getDepartmentTags();
  }

  public void setSearchDepartmentTags(List<Department> val) {
    if (search.isDepartmentTagsSet()) {
      search.setDepartmentTags(val);
    }
  }

  public boolean isSearchDepartmentTagsValid() {
    return search.isDepartmentTagsSet();
  }

  public void setSearchDepartmentTagsValid(boolean val) {
    if (val) {
      search.setDepartmentTags(search.getDepartmentTags());
    } else {
      search.unsetDepartmentTags();
    }
  }

  public List<Organization> getSearchOrganizationTags() {
    return search.getOrganizationTags();
  }

  public void setSearchOrganizationTags(List<Organization> val) {
    if (search.isOrganizationTagsSet()) {
      search.setOrganizationTags(val);
    }
  }

  public boolean isSearchOrganizationTagsValid() {
    return search.isOrganizationTagsSet();
  }

  public void setSearchOrganizationTagsValid(boolean val) {
    if (val) {
      search.setOrganizationTags(search.getOrganizationTags());
    } else {
      search.unsetOrganizationTags();
    }
  }

  // Getters and setters to handle uploads

  // Getters and setters to manipulate active Tag object
  public java.lang.Integer getId() {
    return tag.getId();
  }

  public String getName() {
    return tag.getName();
  }

  public void setName(String name) {
    tag.setName(name);
  }

  public String getDescription() {
    return tag.getDescription();
  }

  public void setDescription(String description) {
    tag.setDescription(description);
  }

  public Integer getOwnerId() {
    return tag.getOwnerId();
  }

  public void setOwnerId(Integer ownerId) {
    tag.setOwnerId(ownerId);
  }

  public Integer getDepartmentId() {
    return tag.getDepartmentId();
  }

  public void setDepartmentId(Integer departmentId) {
    tag.setDepartmentId(departmentId);
  }

  public Date getInsertDate() {
    return tag.getInsertDate();
  }

  public void setInsertDate(Date insertDate) {
    tag.setInsertDate(insertDate);
  }

  public Date getUpdateDate() {
    return tag.getUpdateDate();
  }

  public void setUpdateDate(Date updateDate) {
    tag.setUpdateDate(updateDate);
  }

  public List<Contact> getContactTags() {
    List<Contact> contactTags = new ArrayList<Contact>();
    if (tag.getContactTags() != null && !tag.getContactTags().isEmpty()) {
      contactTags.addAll(tag.getContactTags());
    }
    return contactTags;
  }

  public void setContactTags(List<Contact> contactTags) {
    Set<Contact> result = new HashSet<Contact>();
    if (contactTags != null && !contactTags.isEmpty()) {
      result.addAll(contactTags);
    }
    tag.setContactTags(result);
  }

  public List<Position> getPositionTags() {
    List<Position> positionTags = new ArrayList<Position>();
    if (tag.getPositionTags() != null && !tag.getPositionTags().isEmpty()) {
      positionTags.addAll(tag.getPositionTags());
    }
    return positionTags;
  }

  public void setPositionTags(List<Position> positionTags) {
    Set<Position> result = new HashSet<Position>();
    if (positionTags != null && !positionTags.isEmpty()) {
      result.addAll(positionTags);
    }
    tag.setPositionTags(result);
  }

  public List<Department> getDepartmentTags() {
    List<Department> departmentTags = new ArrayList<Department>();
    if (tag.getDepartmentTags() != null && !tag.getDepartmentTags().isEmpty()) {
      departmentTags.addAll(tag.getDepartmentTags());
    }
    return departmentTags;
  }

  public void setDepartmentTags(List<Department> departmentTags) {
    Set<Department> result = new HashSet<Department>();
    if (departmentTags != null && !departmentTags.isEmpty()) {
      result.addAll(departmentTags);
    }
    tag.setDepartmentTags(result);
  }

  public List<Organization> getOrganizationTags() {
    List<Organization> organizationTags = new ArrayList<Organization>();
    if (tag.getOrganizationTags() != null && !tag.getOrganizationTags().isEmpty()) {
      organizationTags.addAll(tag.getOrganizationTags());
    }
    return organizationTags;
  }

  public void setOrganizationTags(List<Organization> organizationTags) {
    Set<Organization> result = new HashSet<Organization>();
    if (organizationTags != null && !organizationTags.isEmpty()) {
      result.addAll(organizationTags);
    }
    tag.setOrganizationTags(result);
  }

  // ----------------------
  // seleccion de contactos
  // ----------------------

  private Contact selectedContact;

  public Contact getSelectedContact() {
    return selectedContact;
  }

  public void setSelectedContact(Contact selectedContact) {
    this.selectedContact = selectedContact;
  }

  public List<SelectItem> getAllContacts() {
    final List<Contact> refs =
        ContactManager.getDefault().getAllEntities(null, new SortCriteria("name"));
    final List<SelectItem> ret = new ArrayList<SelectItem>();
    for (Contact ref : refs) {
      ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
  }

  public String addContact() {
    tag.getContactTags().add(getSelectedContact());
    return NavigationResults.EDIT;
  }

  public Set<Contact> getContacts() {
    return tag.getContactTags();
  }

  public void setContacts(Set<Contact> contacts) {
    tag.setContactTags(contacts);
  }

  public String deleteContact() {
    final UIData table = (UIData) FacesUtils.getComponent("tag:contacts");
    final Contact toDelete = (Contact) table.getRowData();
    tag.getContactTags().remove(toDelete);
    return NavigationResults.EDIT;
  }

  // --------------------
  // seleccion de puestos
  // --------------------

  private Position selectedPosition;

  public Position getSelectedPosition() {
    return selectedPosition;
  }

  public void setSelectedPosition(Position selectedPosition) {
    this.selectedPosition = selectedPosition;
  }

  public List<SelectItem> getAllPositions() {
    final PositionSearch positionSearch = new PositionSearch();
    positionSearch.setDeleted(false);
    final List<Position> refs =
        PositionManager.getDefault().getAllEntities(positionSearch, new SortCriteria("name"));
    final List<SelectItem> ret = new ArrayList<SelectItem>();
    for (Position ref : refs) {
      ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
  }

  public String addPosition() {
    tag.getPositionTags().add(getSelectedPosition());
    return NavigationResults.EDIT;
  }

  public Set<Position> getPosition() {
    return tag.getPositionTags();
  }

  public void setPosition(Set<Position> positions) {
    tag.setPositionTags(positions);
  }

  public String deletePosition() {
    final UIData table = (UIData) FacesUtils.getComponent("tag:positions");
    final Position toDelete = (Position) table.getRowData();
    tag.getPositionTags().remove(toDelete);
    return NavigationResults.EDIT;
  }

  // --------------------------
  // seleccion de departamentos
  // --------------------------

  private Department selectedDepartment;

  public Department getSelectedDepartment() {
    return selectedDepartment;
  }

  public void setSelectedDepartment(Department selectedDepartment) {
    this.selectedDepartment = selectedDepartment;
  }

  public List<SelectItem> getAllDepartments() {
    final List<Department> refs =
        DepartmentManager.getDefault().getAllEntities(null, new SortCriteria("name"));
    final List<SelectItem> ret = new ArrayList<SelectItem>();
    for (Department ref : refs) {
      ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
  }

  public String addDepartment() {
    tag.getDepartmentTags().add(getSelectedDepartment());
    return NavigationResults.EDIT;
  }

  public Set<Department> getDepartment() {
    return tag.getDepartmentTags();
  }

  public void setDepartment(Set<Department> departments) {
    tag.setDepartmentTags(departments);
  }

  public String deleteDepartment() {
    final UIData table = (UIData) FacesUtils.getComponent("tag:departments");
    final Department toDelete = (Department) table.getRowData();
    tag.getDepartmentTags().remove(toDelete);
    return NavigationResults.EDIT;
  }

  // ---------------------------
  // seleccion de organizaciones
  // ---------------------------

  private Organization selectedOrganization;

  public Organization getSelectedOrganization() {
    return selectedOrganization;
  }

  public void setSelectedOrganization(Organization selectedOrganization) {
    this.selectedOrganization = selectedOrganization;
  }

  public List<SelectItem> getAllOrganizations() {
    final List<Organization> refs =
        OrganizationManager.getDefault().getAllEntities(null, new SortCriteria("name"));
    final List<SelectItem> ret = new ArrayList<SelectItem>();
    for (Organization ref : refs) {
      ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
  }

  public String addOrganization() {
    tag.getOrganizationTags().add(getSelectedOrganization());
    return NavigationResults.EDIT;
  }

  public Set<Organization> getOrganization() {
    return tag.getOrganizationTags();
  }

  public void setOrganization(Set<Organization> organizations) {
    tag.setOrganizationTags(organizations);
  }

  public String deleteOrganization() {
    final UIData table = (UIData) FacesUtils.getComponent("tag:organizations");
    final Organization toDelete = (Organization) table.getRowData();
    tag.getOrganizationTags().remove(toDelete);
    return NavigationResults.EDIT;
  }
}