/**
   * Return the ViewData formatted from theFolder.
   *
   * @param theGroup the group.
   * @return the ViewData
   */
  private ViewData getViewDataFormatted(final Group theGroup) {

    ViewData viewData = new ViewData();
    viewData.setTitle(theGroup.getDisplayExtension());

    String opt = "";
    String right = "";
    boolean optin = theGroup.isCanOptin();
    boolean optout = theGroup.isCanOptout();

    if (optin) {
      if (optout) {
        opt = GroupPrivilegeEnum.OPTIN.getName() + "_" + GroupPrivilegeEnum.OPTOUT.getName();
      } else {
        opt = GroupPrivilegeEnum.OPTIN.getName();
      }
    } else {
      if (optout) {
        opt = GroupPrivilegeEnum.OPTOUT.getName();
      } else {
        opt = "none";
      }
    }

    // theGroup.getUserRight() is not null here.
    right = theGroup.getUserRight().getName();

    viewData.setIcon(PropertyManager.find("group_" + right + "_" + opt).deType(String.class));

    return viewData;
  }
  /** {@inheritDoc} */
  public TreeNode wrap(final Group theObjectSource) throws ESCOWrapperException {

    TreeNode treeGroup = new TreeNode();
    Attributes attributes = new Attributes();

    attributes.setId(theObjectSource.getIdGroup());
    attributes.setName(theObjectSource.getName());
    attributes.setDisplayName(theObjectSource.getDisplayName());
    attributes.setType(TreeGroupWrapper.GROUP);
    attributes.setRight(theObjectSource.getUserRight().getName());
    if (theObjectSource.isCanOptin()) {
      attributes.setOptin(Boolean.TRUE.toString());
    } else {
      attributes.setOptin(Boolean.FALSE.toString());
    }
    if (theObjectSource.isCanOptout()) {
      attributes.setOptout(Boolean.TRUE.toString());
    } else {
      attributes.setOptout(Boolean.FALSE.toString());
    }

    treeGroup.setAttributes(attributes);
    treeGroup.setData(this.getViewDataFormatted(theObjectSource));
    treeGroup.setState("");

    return treeGroup;
  }
  /** {@inheritDoc} */
  public Sortable wrap(final Subject theObjectSource) throws ESCOWrapperException {
    Group newGroup = null;

    // If the object is not null
    if (null != theObjectSource) {

      newGroup = new Group();

      // Set if group is selected.
      newGroup.setSelected(theObjectSource.getSelected());
      // Set if group is added.
      newGroup.setAdded(theObjectSource.isAdded());
      // Set the id of the group.
      newGroup.setIdGroup(theObjectSource.getValueFormCol("id"));
      // Set if the group privilege is can optin.
      newGroup.setCanOptin(theObjectSource.getOptin());
      // Set if the group privilege is can optout.
      newGroup.setCanOptout(theObjectSource.getOptout());
      // Set the description of the group.
      newGroup.setDescription(theObjectSource.getValueFormCol("description"));
      // Set the display extension of the group.
      newGroup.setDisplayExtension(theObjectSource.getValueFormCol("displayExtension"));
      // Set the display name of the group.
      newGroup.setDisplayName(theObjectSource.getValueFormCol("displayName"));
      // Set the extension of the group.
      newGroup.setExtension(theObjectSource.getValueFormCol("extension"));
      // set the name of the group.
      newGroup.setName(theObjectSource.getValueFormCol("name"));
      // Set the user right of the group by mapping the value.
      newGroup.setUserRight(theObjectSource.getSubjectRight());
      // Set the type of sortable to group.s
      newGroup.setTypeEnum(SourceTypeEnum.GROUP);

      List<SimpleValue> list = theObjectSource.getAttributes();
      Map<String, Set<String>> theGroupAttr = new HashMap<String, Set<String>>();
      for (int i = 0; i < list.size(); i++) {
        Set<String> aux = new HashSet<String>();
        aux.add(list.get(i).getValue());
        theGroupAttr.put(list.get(i).getKey(), aux);
      }
      newGroup.setAttributes(theGroupAttr);
      // TODO: Voir pour les GoupDetails. Pas utils pour le moment.
    }

    return newGroup;
  }