Exemplo n.º 1
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;
  }
  protected void addValues(Object object) {
    OrganisationUnit unit = (OrganisationUnit) object;

    statementBuilder.setInt(unit.getId());
    statementBuilder.setString(unit.getUuid());
    statementBuilder.setString(unit.getName());
    statementBuilder.setString(
        unit.getParent() != null ? String.valueOf(unit.getParent().getId()) : null);
    statementBuilder.setString(unit.getShortName());
    statementBuilder.setString(unit.getOrganisationUnitCode());
    statementBuilder.setDate(unit.getOpeningDate());
    statementBuilder.setDate(unit.getClosedDate());
    statementBuilder.setBoolean(unit.isActive());
    statementBuilder.setString(unit.getComment());
    statementBuilder.setString(unit.getGeoCode());
    statementBuilder.setString(unit.getLatitude());
    statementBuilder.setString(unit.getLongitude());
  }