private Document buildMetadata(Document document, Fiche fiche) { Agent a = fiche.getHistoriques().iterator().next().getUtilisateur().getAgent(); document.addAuthor(a.getNom() + " " + a.getPrenom()); document.addCreationDate(); document.addCreator( authHelper.getCurrentUser().getAgent().getNom() + " " + authHelper.getCurrentUser().getAgent().getPrenom()); document.addTitle("MAIN COURANTE " + fiche.getReference()); document.addSubject("MAIN COURANTE " + fiche.getReference()); StringBuilder keywords = new StringBuilder(); keywords.append(fiche.getReference()); keywords.append(","); keywords.append(fiche.getAdresse().getNomVoie().getLibelle()); keywords.append(","); for (Fait f : fiche.getFaits()) { keywords.append(f.getNature().getLibelleCourt()); keywords.append(","); } document.addKeywords(keywords.toString()); return document; }
private PdfPTable buildSaisine(Fiche fiche) { PdfPCell cell; PdfPTable table = new PdfPTable(new float[] {1, 2.6f, 1.2f, 1.2f}); table.setWidthPercentage(100); cell = new PdfPCell(new Phrase("1_ Saisine ", FONT_NORMAL)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("Agent Créateur: ", FONT_NORMAL)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); Agent a = fiche.getHistoriques().iterator().next().getUtilisateur().getAgent(); cell = new PdfPCell(new Phrase(a.getNom() + " " + a.getPrenom(), FONT_NORMAL)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(new Phrase("Cat. saisine: ", FONT_NORMAL)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); String catSaisine = fiche.getCategorieSaisine().getLibelleLong(); cell = new PdfPCell(new Phrase(catSaisine, FONT_NORMAL)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); cell = new PdfPCell(new Phrase("Contact interpolice: ", FONT_NORMAL)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); String contactInterpolice = fiche.getContactInterpolice().getLibelleLong(); cell = new PdfPCell(new Phrase(contactInterpolice, FONT_NORMAL)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); cell = new PdfPCell(new Phrase("Equipages: ", FONT_NORMAL)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); boolean premierePatrouille = true; if (fiche.getPatrouilles() == null || fiche.getPatrouilles().isEmpty()) { cell = new PdfPCell(new Phrase("", FONT_NORMAL)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(3); table.addCell(cell); } for (Patrouille patrouille : fiche.getPatrouilles()) { if (!premierePatrouille) { cell = new PdfPCell(new Phrase("", FONT_NORMAL)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); } else { premierePatrouille = false; } String libelleEquipage = patrouille.getIndicatif().getLibelleLong(); libelleEquipage = libelleEquipage.concat(" : "); if (patrouille.getAgents() != null && patrouille.getAgents().size() > 0) { int cpt = 1; for (Agent agentPatrouille : patrouille.getAgents()) { libelleEquipage = libelleEquipage.concat(agentPatrouille.getNom() + " " + agentPatrouille.getPrenom()); if (cpt != patrouille.getAgents().size()) { libelleEquipage = libelleEquipage.concat(", "); cpt++; } } } cell = new PdfPCell(new Phrase(libelleEquipage, FONT_NORMAL)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(2); table.addCell(cell); String vehicule = ""; if (patrouille.getVehicule() != null) { vehicule = patrouille.getVehicule().getImmatriculation(); } cell = new PdfPCell(new Phrase(vehicule, FONT_NORMAL)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); } table.setSpacingBefore(5); table.setSpacingAfter(5); return table; }