示例#1
0
  /**
   * Creates a table with the given indicator
   *
   * @param indicator The indicator
   * @param i18n i18n object
   * @param expressionService The expression service
   * @param HEADER3 The header3 font
   * @param ITALIC The italic font
   * @param TEXT The text font
   * @param keepTogether Indicates whether the table could be broken across multiple pages or should
   *     be kept at one page.
   * @param columnWidths The column widths.
   */
  public static PdfPTable printIndicator(
      Indicator indicator,
      I18n i18n,
      ExpressionService expressionService,
      boolean keepTogether,
      float... columnWidths) {
    PdfPTable table = getPdfPTable(keepTogether, columnWidths);

    table.addCell(getHeaderCell(indicator.getName(), 2));

    table.addCell(getEmptyCell(2, 15));

    table.addCell(getItalicCell(i18n.getString("short_name")));
    table.addCell(getTextCell(indicator.getShortName()));

    if (nullIfEmpty(indicator.getCode()) != null) {
      table.addCell(getItalicCell(i18n.getString("code")));
      table.addCell(getTextCell(indicator.getCode()));
    }
    if (nullIfEmpty(indicator.getDescription()) != null) {
      table.addCell(getItalicCell(i18n.getString("description")));
      table.addCell(getTextCell(indicator.getDescription()));
    }

    table.addCell(getItalicCell(i18n.getString("annualized")));
    table.addCell(getTextCell(i18n.getString(getBoolean().get(indicator.isAnnualized()))));

    table.addCell(getItalicCell(i18n.getString("indicator_type")));
    table.addCell(getTextCell(indicator.getIndicatorType().getName()));

    table.addCell(getItalicCell(i18n.getString("numerator_description")));
    table.addCell(getTextCell(indicator.getNumeratorDescription()));

    table.addCell(getItalicCell(i18n.getString("numerator_formula")));
    table.addCell(
        getTextCell(expressionService.getExpressionDescription(indicator.getNumerator())));

    table.addCell(getItalicCell(i18n.getString("denominator_description")));
    table.addCell(getTextCell(indicator.getDenominatorDescription()));

    table.addCell(getItalicCell(i18n.getString("denominator_formula")));
    table.addCell(
        getTextCell(expressionService.getExpressionDescription(indicator.getDenominator())));

    for (AttributeValue value : indicator.getAttributeValues()) {
      table.addCell(getItalicCell(value.getAttribute().getName()));
      table.addCell(getTextCell(value.getValue()));
    }

    table.addCell(getEmptyCell(2, 30));

    return table;
  }
示例#2
0
  /**
   * Creates a table with the given unit
   *
   * @param unit The organization unit
   * @param i18n i18n object
   * @param format
   * @param HEADER3 The header3 font
   * @param ITALIC The italic font
   * @param TEXT The text font
   * @param keepTogether Indicates whether the table could be broken across multiple pages or should
   *     be kept at one page.
   * @param columnWidths The column widths.
   */
  public static PdfPTable printOrganisationUnit(
      OrganisationUnit unit,
      I18n i18n,
      I18nFormat format,
      boolean keepTogether,
      float... columnWidths) {
    PdfPTable table = getPdfPTable(keepTogether, columnWidths);

    table.addCell(getHeaderCell(unit.getName(), 2));

    table.addCell(getEmptyCell(2, 15));

    table.addCell(getItalicCell(i18n.getString("short_name")));
    table.addCell(getTextCell(unit.getShortName()));

    if (nullIfEmpty(unit.getCode()) != null) {
      table.addCell(getItalicCell(i18n.getString("code")));
      table.addCell(getTextCell(unit.getCode()));
    }

    table.addCell(getItalicCell(i18n.getString("opening_date")));
    table.addCell(
        getTextCell(
            unit.getOpeningDate() != null ? format.formatDate(unit.getOpeningDate()) : EMPTY));

    if (unit.getClosedDate() != null) {
      table.addCell(getItalicCell(i18n.getString("closed_date")));
      table.addCell(getTextCell(format.formatDate(unit.getClosedDate())));
    }

    table.addCell(getItalicCell(i18n.getString("active")));

    if (nullIfEmpty(unit.getComment()) != null) {
      table.addCell(getItalicCell(i18n.getString("comment")));
      table.addCell(getTextCell(unit.getComment()));
    }

    for (AttributeValue value : unit.getAttributeValues()) {
      table.addCell(getItalicCell(value.getAttribute().getName()));
      table.addCell(getTextCell(value.getValue()));
    }

    table.addCell(getEmptyCell(2, 30));

    return table;
  }
示例#3
0
  /**
   * Creates a table with the given data element
   *
   * @param element The data element
   * @param i18n i18n object
   * @param HEADER3 The header3 font
   * @param ITALIC The italic font
   * @param TEXT The text font
   * @param keepTogether Indicates whether the table could be broken across multiple pages or should
   *     be kept at one page.
   * @param columnWidths The column widths.
   */
  public static PdfPTable printDataElement(
      DataElement element, I18n i18n, boolean keepTogether, float... columnWidths) {
    PdfPTable table = getPdfPTable(keepTogether, columnWidths);

    table.addCell(getHeaderCell(element.getName(), 2));

    table.addCell(getEmptyCell(2, 15));

    table.addCell(getItalicCell(i18n.getString("short_name")));
    table.addCell(getTextCell(element.getShortName()));

    if (nullIfEmpty(element.getCode()) != null) {
      table.addCell(getItalicCell(i18n.getString("code")));
      table.addCell(getTextCell(element.getCode()));
    }
    if (nullIfEmpty(element.getDescription()) != null) {
      table.addCell(getItalicCell(i18n.getString("description")));
      table.addCell(getTextCell(element.getDescription()));
    }

    if (nullIfEmpty(element.getType()) != null) {
      table.addCell(getItalicCell(i18n.getString("value_type")));
      table.addCell(getTextCell(i18n.getString(getType().get(element.getType()))));
    }
    if (nullIfEmpty(element.getAggregationOperator()) != null) {
      table.addCell(getItalicCell(i18n.getString("aggregation_operator")));
      table.addCell(
          getTextCell(
              i18n.getString(getAggregationOperator().get(element.getAggregationOperator()))));
    }

    for (AttributeValue value : element.getAttributeValues()) {
      table.addCell(getItalicCell(value.getAttribute().getName()));
      table.addCell(getTextCell(value.getValue()));
    }

    table.addCell(getEmptyCell(2, 30));

    return table;
  }
示例#4
0
  /**
   * Creates a table with the given validation rule
   *
   * @param user The User
   * @param i18n i18n object
   * @param format I18nFormat object
   * @param keepTogether Indicates whether the table could be broken across multiple pages or should
   *     be kept at one page.
   * @param columnWidths The column widths.
   */
  public static PdfPTable printUser(
      UserCredentials userCredentials,
      I18n i18n,
      I18nFormat format,
      boolean keepTogether,
      float... columnWidths) {
    User user = userCredentials.getUser();

    PdfPTable table = getPdfPTable(keepTogether, columnWidths);

    table.addCell(getHeaderCell(user.getFirstName() + ", " + user.getSurname(), 2));

    table.addCell(getEmptyCell(2, 15));

    table.addCell(getItalicCell(i18n.getString("username")));
    table.addCell(getTextCell(userCredentials.getUsername()));

    if (nullIfEmpty(user.getEmail()) != null) {
      table.addCell(getItalicCell(i18n.getString("email")));
      table.addCell(getTextCell(user.getEmail()));
    }

    if (nullIfEmpty(user.getPhoneNumber()) != null) {
      table.addCell(getItalicCell(i18n.getString("phone_number")));
      table.addCell(getTextCell(user.getPhoneNumber()));
    }

    table.addCell(getItalicCell(i18n.getString("last_login")));
    table.addCell(
        getTextCell(
            userCredentials.getLastLogin() != null
                ? format.formatDate(userCredentials.getLastLogin())
                : EMPTY));

    String temp = "";

    for (OrganisationUnit unit : user.getOrganisationUnits()) {
      temp += unit.getName().concat(", ");
    }

    temp = temp.trim();
    temp = temp.substring(0, temp.isEmpty() ? 0 : temp.length() - 1);

    table.addCell(getItalicCell(i18n.getString("organisation_units")));
    table.addCell(getTextCell(temp));

    temp = "";

    for (UserAuthorityGroup role : userCredentials.getUserAuthorityGroups()) {
      temp += role.getName().concat(", ");
    }

    temp = temp.trim();
    temp = temp.substring(0, temp.isEmpty() ? 0 : temp.length() - 1);

    table.addCell(getItalicCell(i18n.getString("roles")));
    table.addCell(getTextCell(temp));

    for (AttributeValue value : user.getAttributeValues()) {
      table.addCell(getItalicCell(value.getAttribute().getName()));
      table.addCell(getTextCell(value.getValue()));
    }

    table.addCell(getEmptyCell(2, 30));

    return table;
  }