Exemplo n.º 1
0
  public Document getXML(SecurityAdvisor secAdvisor, DictionaryHelper dictionaryHelper)
      throws UnknownPermissionException {
    Document doc = new Document(new Element("Topic"));
    Element root = doc.getRootElement();

    root.setAttribute("label", this.getName());
    root.setAttribute("idTopic", this.getIdTopic().toString());
    root.setAttribute("name", this.getName());
    root.setAttribute(
        "idParentTopic", this.getIdParentTopic() != null ? this.getIdParentTopic().toString() : "");
    root.setAttribute("description", this.getDescription() != null ? this.getDescription() : "");
    root.setAttribute(
        "lab",
        this.getIdLab() != null ? dictionaryHelper.getLabObject(this.getIdLab()).getName() : "");
    root.setAttribute("idLab", this.getIdLab() != null ? this.getIdLab().toString() : "");
    root.setAttribute(
        "appUser",
        this.getIdAppUser() != null
            ? dictionaryHelper.getAppUserObject(this.getIdAppUser()).getDisplayName()
            : "");
    root.setAttribute(
        "idAppUser", this.getIdAppUser() != null ? this.getIdAppUser().toString() : "");
    root.setAttribute("codeVisibility", this.getNonNullString(this.getCodeVisibility()));
    root.setAttribute(
        "idInstitution", this.getIdInstitution() != null ? this.getIdInstitution().toString() : "");
    root.setAttribute("createdBy", this.getCreatedBy() != null ? this.getCreatedBy() : "");
    root.setAttribute(
        "createDate",
        this.getCreateDate() != null ? DataTrackUtil.formatDate(this.getCreateDate()) : "");

    root.setAttribute("canWrite", secAdvisor.canUpdate(this) ? "Y" : "N");

    if (root.getAttributeValue("codeVisibility").equals(Visibility.VISIBLE_TO_PUBLIC)) {
      root.setAttribute("topicPublicNote", "(Public) ");
    } else {
      root.setAttribute("topicPublicNote", "");
    }
    root.setAttribute(
        "canUpdateVisibility", secAdvisor.canUpdateVisibility(idLab, idAppUser) ? "Y" : "N");

    return doc;
  }