protected void createCommentLink(
      CurricularCourseResumeResult courseResumeResult,
      HtmlInlineContainer container,
      ResultClassification forAudit) {
    container.addChild(new HtmlText(" | ", false));

    String commentLinkText =
        RenderUtils.getResourceString("INQUIRIES_RESOURCES", "link.inquiry.comment");
    if (courseResumeResult.isShowAllComments() || !courseResumeResult.isAllowComment()) {
      commentLinkText =
          RenderUtils.getResourceString("INQUIRIES_RESOURCES", "link.inquiry.viewResults");
    } else if (hasQucGlobalCommentsMadeBy(
        courseResumeResult.getExecutionCourse(),
        courseResumeResult.getPerson(),
        courseResumeResult.getExecutionDegree(),
        courseResumeResult.getPersonCategory())) {
      commentLinkText =
          RenderUtils.getResourceString("INQUIRIES_RESOURCES", "link.inquiry.viewComment");
    }

    String fillInParameters = buildFillInParameters(courseResumeResult);
    HtmlLink commentLink = new HtmlLink();
    commentLink.setUrl(getAction() + "?method=" + getMethod() + fillInParameters);
    commentLink.setText(commentLinkText);
    container.addChild(commentLink);

    if (courseResumeResult.getExecutionCourse().getExecutionCourseAudit() != null
        && courseResumeResult.getExecutionCourse().getExecutionCourseAudit().isProcessAvailable()) {
      container.addChild(new HtmlText(" | ", false));
      HtmlLink auditLink = new HtmlLink();
      auditLink.setUrl(
          "/auditResult.do?method=viewProcessDetails&"
              + buildParametersForAudit(courseResumeResult));
      auditLink.setText("Ver processo auditoria");
      container.addChild(auditLink);

    } else {
      if (forAudit != null) {
        if (forAudit.equals(ResultClassification.RED)) {
          container.addChild(
              new HtmlText(
                  " ("
                      + RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.audit")
                      + ")"));
        } else if (forAudit.equals(ResultClassification.YELLOW)) {
          container.addChild(
              new HtmlText(
                  " ("
                      + RenderUtils.getResourceString(
                          "INQUIRIES_RESOURCES", "label.inquiry.inObservation")
                      + ")"));
        }
      }
    }
  }
  private HtmlMenuOption createOtherOption(HtmlMenu menu) {
    String title = RenderUtils.getResourceString("renderers.menu.other.title");
    HtmlMenuOption otherOption = menu.createOption(title);
    otherOption.setValue(OPTION_KEY);

    return otherOption;
  }
    @Override
    protected HtmlComponent getComponent(int rowIndex, int columnIndex) {
      Object object = this.objects.get(rowIndex);

      Schema schema = RenderKit.getInstance().findSchema(getEachSchema());
      String layout = getEachLayout();

      MetaObject metaObject = MetaObjectFactory.createObject(object, schema);

      if (columnIndex == 0) {
        this.hiddenValues.addValue(metaObject.getKey().toString());

        PresentationContext newContext = getContext().createSubContext(metaObject);
        newContext.setLayout(layout);
        newContext.setRenderMode(RenderMode.getMode("output"));

        RenderKit kit = RenderKit.getInstance();
        return kit.render(newContext, object);
      } else {
        HtmlActionLink link = new HtmlActionLink();

        String prefix = getInputContext().getMetaObject().getKey().toString();
        link.setName(prefix + "/delete/" + rowIndex);
        link.setText(RenderUtils.getResourceString("renderers.list.management.delete"));

        HtmlTableRow row = getTable().getRows().get(rowIndex);
        link.setController(new RemoveLineController(getTable(), this.hiddenValues, row, prefix));
        return link;
      }
    }
  @Override
  protected void createFinalCells(HtmlTableRow tableRow, BlockResumeResult blockResumeResult) {
    CurricularCourseResumeResult courseResumeResult =
        (CurricularCourseResumeResult) blockResumeResult;

    HtmlInlineContainer container = new HtmlInlineContainer();
    HtmlTableCell linksCell = tableRow.createCell();
    HtmlMenu menu = new HtmlMenu();
    menu.setOnChange(
        "var value=this.options[this.selectedIndex].value; this.selectedIndex=0; if(value!= ''){ window.open(value,'_blank'); }");
    menu.setStyle("width: 150px");
    HtmlMenuOption optionEmpty =
        menu.createOption(
            RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.emptyOption"));

    createResultsGroup(courseResumeResult, menu);
    createReportsGroup(courseResumeResult, menu);

    container.addChild(menu);
    ResultClassification forAudit =
        ResultClassification.getForAudit(
            courseResumeResult.getExecutionCourse(), courseResumeResult.getExecutionDegree());
    createCommentLink(courseResumeResult, container, forAudit);

    linksCell.setBody(container);
    linksCell.setClasses("col-actions");
  }
Пример #5
0
 @Override
 protected String getResourceMessage(String message) {
   if (this.arguments == null || this.arguments.length == 0) {
     return RenderUtils.getResourceString(getBundle(), message);
   } else {
     return RenderUtils.getFormatedResourceString(getBundle(), message, this.arguments);
   }
 }
  private void createResultsGroup(CurricularCourseResumeResult courseResumeResult, HtmlMenu menu) {
    HtmlMenuGroup resultsGroup =
        menu.createGroup(
            RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.results"));
    HtmlMenuOption optionUC = resultsGroup.createOption();
    optionUC.setText(
        RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.ucResults"));
    String resultsParameters = buildParametersForResults(courseResumeResult);
    HtmlLink link = new HtmlLink();
    link.setModule("/publico");
    link.setUrl("/viewCourseResults.do?" + resultsParameters);
    link.setEscapeAmpersand(false);
    String calculatedUrl = link.calculateUrl();
    optionUC.setValue(
        calculatedUrl
            + "&_request_checksum_="
            + GenericChecksumRewriter.calculateChecksum(calculatedUrl, getSession()));

    for (TeacherShiftTypeResultsBean teacherShiftTypeResultsBean :
        courseResumeResult.getTeachersResults()) {
      String teacherResultsParameters =
          buildParametersForTeacherResults(teacherShiftTypeResultsBean);
      HtmlLink teacherLink = new HtmlLink();
      teacherLink.setEscapeAmpersand(false);
      teacherLink.setModule("/publico");
      teacherLink.setUrl("/viewTeacherResults.do?" + teacherResultsParameters);
      calculatedUrl = teacherLink.calculateUrl();

      HtmlMenuOption optionTeacher = resultsGroup.createOption();
      optionTeacher.setText(
          teacherShiftTypeResultsBean.getShiftType().getFullNameTipoAula()
              + " - "
              + teacherShiftTypeResultsBean.getProfessorship().getPerson().getName());
      optionTeacher.setValue(
          calculatedUrl
              + "&_request_checksum_="
              + GenericChecksumRewriter.calculateChecksum(calculatedUrl, getSession()));
    }
  }
    @Override
    public HtmlComponent createComponent(Object object, Class type) {
      HtmlComponent component = super.createComponent(object, type);

      HtmlContainer container = new HtmlBlockContainer();

      container.addChild(component);
      container.addChild(this.hiddenValues);

      HtmlActionLink link = new HtmlActionLink();
      link.setName(getInputContext().getMetaObject().getKey().toString() + "/add");
      link.setText(RenderUtils.getResourceString("renderers.list.management.add"));
      link.setController(
          new FollowDestinationController((MetaSlot) getInputContext().getMetaObject()));

      container.addChild(link);

      return container;
    }
  private void createReportsGroup(CurricularCourseResumeResult courseResumeResult, HtmlMenu menu) {
    String calculatedUrl;
    HtmlMenuGroup reportsGroup =
        menu.createGroup(
            RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.reports"));
    for (InquiryDelegateAnswer inquiryDelegateAnswer :
        courseResumeResult.getExecutionCourse().getInquiryDelegatesAnswersSet()) {
      if (inquiryDelegateAnswer.getExecutionDegree() == courseResumeResult.getExecutionDegree()) {
        String delegateInquiryParameters = buildParametersForDelegateInquiry(inquiryDelegateAnswer);
        HtmlLink delegateLink = new HtmlLink();
        delegateLink.setEscapeAmpersand(false);
        delegateLink.setModule("/publico");
        delegateLink.setUrl("/viewQUCInquiryAnswers.do?" + delegateInquiryParameters);
        calculatedUrl = delegateLink.calculateUrl();

        HtmlMenuOption optionDelegate = reportsGroup.createOption();
        optionDelegate.setText(
            RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.delegate"));
        optionDelegate.setValue(
            calculatedUrl
                + "&_request_checksum_="
                + GenericChecksumRewriter.calculateChecksum(calculatedUrl, getSession()));
      }
    }

    for (Professorship professorship :
        courseResumeResult.getExecutionCourse().getProfessorshipsSet()) {
      if (professorship.getInquiryTeacherAnswer() != null) {
        HtmlLink teacherLink = new HtmlLink();
        teacherLink.setEscapeAmpersand(false);
        teacherLink.setModule("/publico");
        teacherLink.setUrl(
            "/viewQUCInquiryAnswers.do?method=showTeacherInquiry&professorshipOID="
                + professorship.getExternalId());
        calculatedUrl = teacherLink.calculateUrl();
        HtmlMenuOption optionTeacher = reportsGroup.createOption();
        optionTeacher.setText(
            RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.teacher")
                + " ("
                + professorship.getPerson().getName()
                + ")");
        optionTeacher.setValue(
            calculatedUrl
                + "&_request_checksum_="
                + GenericChecksumRewriter.calculateChecksum(calculatedUrl, getSession()));
      }
    }

    for (Professorship professorship :
        courseResumeResult.getExecutionCourse().getProfessorshipsSet()) {
      if (professorship.getInquiryRegentAnswer() != null) {
        HtmlLink regentLink = new HtmlLink();
        regentLink.setEscapeAmpersand(false);
        regentLink.setModule("/publico");
        regentLink.setUrl(
            "/viewQUCInquiryAnswers.do?method=showRegentInquiry&professorshipOID="
                + professorship.getExternalId());
        calculatedUrl = regentLink.calculateUrl();
        HtmlMenuOption optionRegent = reportsGroup.createOption();
        optionRegent.setText(
            RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.regent")
                + " ("
                + professorship.getPerson().getName()
                + ")");
        optionRegent.setValue(
            calculatedUrl
                + "&_request_checksum_="
                + GenericChecksumRewriter.calculateChecksum(calculatedUrl, getSession()));
      }
    }
  }