/** * 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; }
public static void updateParents(Collection<OrganisationUnit> organisationUnits) { Map<String, OrganisationUnit> organisationUnitMap = getOrganisationUnitMap(organisationUnits); for (OrganisationUnit organisationUnit : organisationUnits) { OrganisationUnit parent = organisationUnit.getParent(); if (parent != null) { if (parent.getUid() != null) { parent = organisationUnitMap.get(parent.getUid()); } else if (parent.getCode() != null) { parent = organisationUnitMap.get(parent.getCode()); } else if (parent.getName() != null) { parent = organisationUnitMap.get(parent.getName()); } else if (parent.getShortName() != null) { parent = organisationUnitMap.get(parent.getShortName()); } } if (parent != null) { organisationUnit.setParent(parent); } } }
private static Map<String, OrganisationUnit> getOrganisationUnitMap( Collection<OrganisationUnit> organisationUnits) { Map<String, OrganisationUnit> organisationUnitMap = new HashMap<String, OrganisationUnit>(); for (OrganisationUnit organisationUnit : organisationUnits) { if (organisationUnit.getUid() != null) { organisationUnitMap.put(organisationUnit.getUid(), organisationUnit); } if (organisationUnit.getCode() != null) { organisationUnitMap.put(organisationUnit.getCode(), organisationUnit); } if (organisationUnit.getName() != null) { organisationUnitMap.put(organisationUnit.getName(), organisationUnit); } if (organisationUnit.getShortName() != null) { organisationUnitMap.put(organisationUnit.getShortName(), organisationUnit); } } return organisationUnitMap; }
private Grid generateGrid() { final Grid orgUnitGrid = new ListGrid().setTitle("Organisation unit search result"); orgUnitGrid.addHeader(new GridHeader("Code", false, true)); orgUnitGrid.addHeader(new GridHeader("Name", false, true)); for (OrganisationUnitGroupSet groupSet : groupSets) { orgUnitGrid.addHeader(new GridHeader(groupSet.getName(), false, true)); } for (OrganisationUnit unit : organisationUnits) { orgUnitGrid.addRow(); orgUnitGrid.addValue(unit.getCode()); orgUnitGrid.addValue(unit.getName()); for (OrganisationUnitGroupSet groupSet : groupSets) { orgUnitGrid.addValue(unit.getGroupNameInGroupSet(groupSet)); } } return orgUnitGrid; }