List of usage examples for com.lowagie.text Anchor Anchor
public Anchor(float leading, String string)
Anchor
with a certain leading and a certain String
. From source file:com.slamd.report.PDFReportGenerator.java
License:Open Source License
/** * Writes information about the provided job to the document. * * @param document The document to which the job information should be * written.// w ww. j a va2 s .co m * @param job The job to include in the document. * * @throws DocumentException If a problem occurs while writing the contents. */ private void writeJob(Document document, Job job) throws DocumentException { Anchor anchor = new Anchor("Job " + job.getJobID(), FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD, Color.BLACK)); anchor.setName(job.getJobID()); Paragraph p = new Paragraph(anchor); document.add(p); // Write the general information to the document. p = new Paragraph("General Information", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK)); document.add(p); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); table.setWidths(new int[] { 30, 70 }); writeTableCell(table, "Job ID"); writeTableCell(table, job.getJobID()); String optimizingJobID = job.getOptimizingJobID(); if ((optimizingJobID != null) && (optimizingJobID.length() > 0)) { writeTableCell(table, "Optimizing Job ID"); writeTableCell(table, optimizingJobID); } String descriptionStr = job.getJobDescription(); if ((descriptionStr == null) || (descriptionStr.length() == 0)) { descriptionStr = "(Not Specified)"; } writeTableCell(table, "Job Description"); writeTableCell(table, descriptionStr); writeTableCell(table, "Job Type"); writeTableCell(table, job.getJobClassName()); writeTableCell(table, "Job Class"); writeTableCell(table, job.getJobClass().getClass().getName()); writeTableCell(table, "Job State"); writeTableCell(table, job.getJobStateString()); document.add(table); // Write the schedule config if appropriate. if (includeScheduleConfig) { document.add(new Paragraph(" ")); p = new Paragraph("Schedule Information", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK)); document.add(p); table = new PdfPTable(2); table.setWidthPercentage(100); table.setWidths(new int[] { 30, 70 }); Date startTime = job.getStartTime(); String startStr; if (startTime == null) { startStr = "(Not Available)"; } else { startStr = dateFormat.format(startTime); } writeTableCell(table, "Scheduled Start Time"); writeTableCell(table, startStr); Date stopTime = job.getStopTime(); String stopStr; if (stopTime == null) { stopStr = "(Not Specified)"; } else { stopStr = dateFormat.format(stopTime); } writeTableCell(table, "Scheduled Stop Time"); writeTableCell(table, stopStr); int duration = job.getDuration(); String durationStr; if (duration > 0) { durationStr = duration + " seconds"; } else { durationStr = "(Not Specified)"; } writeTableCell(table, "Scheduled Duration"); writeTableCell(table, durationStr); writeTableCell(table, "Number of Clients"); writeTableCell(table, String.valueOf(job.getNumberOfClients())); String[] requestedClients = job.getRequestedClients(); if ((requestedClients != null) && (requestedClients.length > 0)) { PdfPTable clientTable = new PdfPTable(1); for (int i = 0; i < requestedClients.length; i++) { PdfPCell clientCell = new PdfPCell(new Phrase(requestedClients[i])); clientCell.setBorder(0); clientTable.addCell(clientCell); } writeTableCell(table, "Requested Clients"); table.addCell(clientTable); } String[] monitorClients = job.getResourceMonitorClients(); if ((monitorClients != null) && (monitorClients.length > 0)) { PdfPTable clientTable = new PdfPTable(1); for (int i = 0; i < monitorClients.length; i++) { PdfPCell clientCell = new PdfPCell(new Phrase(monitorClients[i])); clientCell.setBorder(0); clientTable.addCell(clientCell); } writeTableCell(table, "Resource Monitor Clients"); table.addCell(clientTable); } writeTableCell(table, "Threads per Client"); writeTableCell(table, String.valueOf(job.getThreadsPerClient())); writeTableCell(table, "Thread Startup Delay"); writeTableCell(table, job.getThreadStartupDelay() + " milliseconds"); writeTableCell(table, "Statistics Collection Interval"); writeTableCell(table, job.getCollectionInterval() + " seconds"); document.add(table); } // Write the job-specific parameter information if appropriate. if (includeJobConfig) { document.add(new Paragraph(" ")); p = new Paragraph("Parameter Information", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK)); document.add(p); table = new PdfPTable(2); table.setWidthPercentage(100); table.setWidths(new int[] { 30, 70 }); Parameter[] params = job.getParameterList().getParameters(); for (int i = 0; i < params.length; i++) { writeTableCell(table, params[i].getDisplayName()); writeTableCell(table, params[i].getDisplayValue()); } document.add(table); } // Write the statistical data if appropriate. if (includeStats && job.hasStats()) { document.add(new Paragraph(" ")); p = new Paragraph("General Execution Data", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK)); document.add(p); table = new PdfPTable(2); table.setWidthPercentage(100); table.setWidths(new int[] { 30, 70 }); Date actualStartTime = job.getActualStartTime(); String startStr; if (actualStartTime == null) { startStr = "(Not Available)"; } else { startStr = dateFormat.format(actualStartTime); } writeTableCell(table, "Actual Start Time"); writeTableCell(table, startStr); Date actualStopTime = job.getActualStopTime(); String stopStr; if (actualStopTime == null) { stopStr = "(Not Available)"; } else { stopStr = dateFormat.format(actualStopTime); } writeTableCell(table, "Actual Stop Time"); writeTableCell(table, stopStr); int actualDuration = job.getActualDuration(); String durationStr; if (actualDuration > 0) { durationStr = actualDuration + " seconds"; } else { durationStr = "(Not Available)"; } writeTableCell(table, "Actual Duration"); writeTableCell(table, durationStr); String[] clients = job.getStatTrackerClientIDs(); if ((clients != null) && (clients.length > 0)) { PdfPTable clientTable = new PdfPTable(1); for (int i = 0; i < clients.length; i++) { PdfPCell clientCell = new PdfPCell(new Phrase(clients[i])); clientCell.setBorder(0); clientTable.addCell(clientCell); } writeTableCell(table, "Clients Used"); table.addCell(clientTable); } document.add(table); String[] trackerNames = job.getStatTrackerNames(); for (int i = 0; i < trackerNames.length; i++) { StatTracker[] trackers = job.getStatTrackers(trackerNames[i]); if ((trackers != null) && (trackers.length > 0)) { document.newPage(); StatTracker tracker = trackers[0].newInstance(); tracker.aggregate(trackers); document.add(new Paragraph(" ")); document.add(new Paragraph(trackerNames[i], FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK))); String[] summaryNames = tracker.getSummaryLabels(); String[] summaryValues = tracker.getSummaryData(); table = new PdfPTable(2); table.setWidthPercentage(100); table.setWidths(new int[] { 50, 50 }); for (int j = 0; j < summaryNames.length; j++) { writeTableCell(table, summaryNames[j]); writeTableCell(table, summaryValues[j]); } document.add(table); if (includeGraphs) { try { ParameterList params = tracker.getGraphParameterStubs(job); BufferedImage graphImage = tracker.createGraph(job, Constants.DEFAULT_GRAPH_WIDTH, Constants.DEFAULT_GRAPH_HEIGHT, params); Image image = Image.getInstance(imageToByteArray(graphImage)); image.scaleToFit(inchesToPoints(5.5), inchesToPoints(4.5)); document.add(image); } catch (Exception e) { } } } } } // Write the resource monitor data if appropriate. if (includeMonitorStats && job.hasResourceStats()) { String[] trackerNames = job.getResourceStatTrackerNames(); for (int i = 0; i < trackerNames.length; i++) { StatTracker[] trackers = job.getResourceStatTrackers(trackerNames[i]); if ((trackers != null) && (trackers.length > 0)) { document.newPage(); StatTracker tracker = trackers[0].newInstance(); tracker.aggregate(trackers); document.add(new Paragraph(" ")); document.add(new Paragraph(trackerNames[i], FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK))); String[] summaryNames = tracker.getSummaryLabels(); String[] summaryValues = tracker.getSummaryData(); table = new PdfPTable(2); table.setWidthPercentage(100); table.setWidths(new int[] { 50, 50 }); for (int j = 0; j < summaryNames.length; j++) { writeTableCell(table, summaryNames[j]); writeTableCell(table, summaryValues[j]); } document.add(table); if (includeGraphs) { try { ParameterList params = tracker.getGraphParameterStubs(job); BufferedImage graphImage = tracker.createMonitorGraph(job, Constants.DEFAULT_GRAPH_WIDTH, Constants.DEFAULT_MONITOR_GRAPH_HEIGHT, params); Image image = Image.getInstance(imageToByteArray(graphImage)); image.scaleToFit(inchesToPoints(5.5), inchesToPoints(4.5)); document.add(image); } catch (Exception e) { } } } } } }
From source file:com.slamd.report.PDFReportGenerator.java
License:Open Source License
/** * Writes information about the provided optimizing job to the document. * * @param document The document to which the job information should be * written./*from ww w.j a v a2s . c o m*/ * @param optimizingJob The optimizing job to include in the document. * * @throws DocumentException If a problem occurs while writing the contents. */ private void writeOptimizingJob(Document document, OptimizingJob optimizingJob) throws DocumentException { Anchor anchor = new Anchor("Optimizing Job " + optimizingJob.getOptimizingJobID(), FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD, Color.BLACK)); anchor.setName(optimizingJob.getOptimizingJobID()); Paragraph p = new Paragraph(anchor); document.add(p); // Write the general information to the document. p = new Paragraph("General Information", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK)); document.add(p); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); table.setWidths(new int[] { 30, 70 }); writeTableCell(table, "Optimizing Job ID"); writeTableCell(table, optimizingJob.getOptimizingJobID()); writeTableCell(table, "Job Type"); writeTableCell(table, optimizingJob.getJobClassName()); String descriptionStr = optimizingJob.getDescription(); if ((descriptionStr == null) || (descriptionStr.length() == 0)) { descriptionStr = "(Not Specified)"; } writeTableCell(table, "Base Description"); writeTableCell(table, descriptionStr); writeTableCell(table, "Include Thread Count in Description"); writeTableCell(table, String.valueOf(optimizingJob.includeThreadsInDescription())); writeTableCell(table, "Job State"); writeTableCell(table, Constants.jobStateToString(optimizingJob.getJobState())); document.add(table); // Write the schedule config to the document if appropriate. if (includeScheduleConfig) { document.add(new Paragraph(" ")); p = new Paragraph("Schedule Information", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK)); document.add(p); table = new PdfPTable(2); table.setWidthPercentage(100); table.setWidths(new int[] { 30, 70 }); Date startTime = optimizingJob.getStartTime(); String startStr; if (startTime == null) { startStr = "(Not Available)"; } else { startStr = dateFormat.format(startTime); } writeTableCell(table, "Scheduled Start Time"); writeTableCell(table, startStr); int duration = optimizingJob.getDuration(); String durationStr; if (duration > 0) { durationStr = duration + " seconds"; } else { durationStr = "(Not Specified)"; } writeTableCell(table, "Job Duration"); writeTableCell(table, durationStr); writeTableCell(table, "Delay Between Iterations"); writeTableCell(table, optimizingJob.getDelayBetweenIterations() + " seconds"); writeTableCell(table, "Number of Clients"); writeTableCell(table, String.valueOf(optimizingJob.getNumClients())); String[] requestedClients = optimizingJob.getRequestedClients(); if ((requestedClients != null) && (requestedClients.length > 0)) { PdfPTable clientTable = new PdfPTable(1); for (int i = 0; i < requestedClients.length; i++) { PdfPCell clientCell = new PdfPCell(new Phrase(requestedClients[i])); clientCell.setBorder(0); clientTable.addCell(clientCell); } writeTableCell(table, "Requested Clients"); table.addCell(clientTable); } String[] monitorClients = optimizingJob.getResourceMonitorClients(); if ((monitorClients != null) && (monitorClients.length > 0)) { PdfPTable clientTable = new PdfPTable(1); for (int i = 0; i < monitorClients.length; i++) { PdfPCell clientCell = new PdfPCell(new Phrase(monitorClients[i])); clientCell.setBorder(0); clientTable.addCell(clientCell); } writeTableCell(table, "Resource Monitor Clients"); table.addCell(clientTable); } writeTableCell(table, "Minimum Number of Threads"); writeTableCell(table, String.valueOf(optimizingJob.getMinThreads())); int maxThreads = optimizingJob.getMaxThreads(); String maxThreadsStr; if (maxThreads > 0) { maxThreadsStr = String.valueOf(maxThreads); } else { maxThreadsStr = "(Not Specified)"; } writeTableCell(table, "Maximum Number of Threads"); writeTableCell(table, maxThreadsStr); writeTableCell(table, "Thread Increment Between Iterations"); writeTableCell(table, String.valueOf(optimizingJob.getThreadIncrement())); writeTableCell(table, "Statistics Collection Interval"); writeTableCell(table, optimizingJob.getCollectionInterval() + " seconds"); document.add(table); } // Get the optimization algorithm used. OptimizationAlgorithm optimizationAlgorithm = optimizingJob.getOptimizationAlgorithm(); ParameterList paramList = optimizationAlgorithm.getOptimizationAlgorithmParameters(); Parameter[] optimizationParams = paramList.getParameters(); // Write the optimizing config to the document if appropriate. if (includeScheduleConfig) { document.add(new Paragraph(" ")); p = new Paragraph("Optimization Settings", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK)); document.add(p); table = new PdfPTable(2); table.setWidthPercentage(100); table.setWidths(new int[] { 30, 70 }); for (int i = 0; i < optimizationParams.length; i++) { writeTableCell(table, optimizationParams[i].getDisplayName()); writeTableCell(table, optimizationParams[i].getDisplayValue()); } writeTableCell(table, "Maximum Consecutive Non-Improving Iterations"); writeTableCell(table, String.valueOf(optimizingJob.getMaxNonImproving())); writeTableCell(table, "Re-Run Best Iteration"); writeTableCell(table, String.valueOf(optimizingJob.reRunBestIteration())); int reRunDuration = optimizingJob.getReRunDuration(); String durationStr; if (reRunDuration > 0) { durationStr = reRunDuration + " seconds"; } else { durationStr = "(Not Specified)"; } writeTableCell(table, "Re-Run Duration"); writeTableCell(table, durationStr); document.add(table); } // Write the job-specific config to the document if appropriate. if (includeJobConfig) { document.add(new Paragraph(" ")); p = new Paragraph("Parameter Information", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK)); document.add(p); table = new PdfPTable(2); table.setWidthPercentage(100); table.setWidths(new int[] { 30, 70 }); Parameter[] params = optimizingJob.getParameters().getParameters(); for (int i = 0; i < params.length; i++) { writeTableCell(table, params[i].getDisplayName()); writeTableCell(table, params[i].getDisplayValue()); } document.add(table); } // Write the statistical data to the document if appropriate. if (includeStats && optimizingJob.hasStats()) { document.add(new Paragraph(" ")); p = new Paragraph("Execution Data", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK)); document.add(p); table = new PdfPTable(2); table.setWidthPercentage(100); table.setWidths(new int[] { 30, 70 }); Date actualStartTime = optimizingJob.getActualStartTime(); String startTimeStr; if (actualStartTime == null) { startTimeStr = "(Not Available)"; } else { startTimeStr = dateFormat.format(actualStartTime); } writeTableCell(table, "Actual Start Time"); writeTableCell(table, startTimeStr); Date actualStopTime = optimizingJob.getActualStopTime(); String stopTimeStr; if (actualStopTime == null) { stopTimeStr = "(Not Available)"; } else { stopTimeStr = dateFormat.format(actualStopTime); } writeTableCell(table, "Actual Stop Time"); writeTableCell(table, stopTimeStr); Job[] iterations = optimizingJob.getAssociatedJobs(); if ((iterations != null) && (iterations.length > 0)) { writeTableCell(table, "Job Iterations Completed"); writeTableCell(table, String.valueOf(iterations.length)); int optimalThreadCount = optimizingJob.getOptimalThreadCount(); String threadStr; if (optimalThreadCount > 0) { threadStr = String.valueOf(optimalThreadCount); } else { threadStr = "(Not Available)"; } writeTableCell(table, "Optimal Thread Count"); writeTableCell(table, threadStr); double optimalValue = optimizingJob.getOptimalValue(); String valueStr; if (optimalThreadCount > 0) { valueStr = decimalFormat.format(optimalValue); } else { valueStr = "(Not Available)"; } writeTableCell(table, "Optimal Value"); writeTableCell(table, valueStr); String optimalID = optimizingJob.getOptimalJobID(); writeTableCell(table, "Optimal Job Iteration"); if ((optimalID == null) || (optimalID.length() == 0)) { writeTableCell(table, "(Not Available)"); } else if (includeOptimizingIterations) { anchor = new Anchor(optimalID, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, Color.BLUE)); anchor.setReference('#' + optimalID); table.addCell(new PdfPCell(anchor)); } else { writeTableCell(table, optimalID); } } Job reRunIteration = optimizingJob.getReRunIteration(); if (reRunIteration != null) { writeTableCell(table, "Re-Run Iteration"); if (includeOptimizingIterations) { anchor = new Anchor(reRunIteration.getJobID(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, Color.BLUE)); anchor.setReference('#' + reRunIteration.getJobID()); table.addCell(new PdfPCell(anchor)); } else { writeTableCell(table, reRunIteration.getJobID()); } String valueStr; try { double iterationValue = optimizationAlgorithm.getIterationOptimizationValue(reRunIteration); valueStr = decimalFormat.format(iterationValue); } catch (Exception e) { valueStr = "N/A"; } writeTableCell(table, "Re-Run Iteration Value"); writeTableCell(table, valueStr); } document.add(table); if (includeOptimizingIterations && (iterations != null) && (iterations.length > 0)) { document.add(new Paragraph(" ")); p = new Paragraph("Job Iterations", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK)); document.add(p); table = new PdfPTable(2); table.setWidthPercentage(100); table.setWidths(new int[] { 50, 50 }); for (int i = 0; i < iterations.length; i++) { String valueStr; try { double iterationValue = optimizationAlgorithm.getIterationOptimizationValue(iterations[i]); valueStr = decimalFormat.format(iterationValue); } catch (Exception e) { valueStr = "N/A"; } anchor = new Anchor(iterations[i].getJobID(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, Color.BLUE)); anchor.setReference('#' + iterations[i].getJobID()); table.addCell(new PdfPCell(anchor)); writeTableCell(table, valueStr); } document.add(table); } if (includeGraphs && (iterations != null) && (iterations.length > 0)) { String[] statNames = iterations[0].getStatTrackerNames(); for (int j = 0; j < statNames.length; j++) { StatTracker[] trackers = iterations[0].getStatTrackers(statNames[j]); if ((trackers != null) && (trackers.length > 0)) { StatTracker tracker = trackers[0].newInstance(); tracker.aggregate(trackers); try { document.newPage(); ParameterList params = tracker.getGraphParameterStubs(iterations); BufferedImage graphImage = tracker.createGraph(iterations, Constants.DEFAULT_GRAPH_WIDTH, Constants.DEFAULT_GRAPH_HEIGHT, params); Image image = Image.getInstance(imageToByteArray(graphImage)); image.scaleToFit(inchesToPoints(5.5), inchesToPoints(4.5)); document.add(image); } catch (Exception e) { } } } } if (includeOptimizingIterations && (iterations != null) && (iterations.length > 0)) { for (int i = 0; i < iterations.length; i++) { document.newPage(); writeJob(document, iterations[i]); } } if (includeOptimizingIterations && (reRunIteration != null)) { document.newPage(); writeJob(document, reRunIteration); } } }
From source file:de.xirp.report.ReportGenerator.java
License:Open Source License
/** * Adds the title page with the given header string to the PDF * {@link com.lowagie.text.Document}./*from ww w . j a v a2 s. c o m*/ * * @param heading * The header text. * @throws DocumentException * if something went wrong adding the page. * @see com.lowagie.text.Document */ private static void addTitle(String heading) throws DocumentException { para = getParagraph(heading, HEADER, Element.ALIGN_CENTER); document.add(para); addSkip(3); para = getParagraph(Constants.NON_UNICODE_APP_NAME, IMAGE, Image.ALIGN_CENTER); document.add(para); addSkip(); para = getParagraph(I18n.getString("ReportGenerator.report.header.website"), TEXT, //$NON-NLS-1$ Element.ALIGN_CENTER); document.add(para); para = getParagraph(Constants.LINE_SEPARATOR, TEXT, Element.ALIGN_CENTER); TEXT.setColor(new Color(0, 0, 255)); Anchor anchor = new Anchor(I18n.getString("ReportGenerator.report.websiteLink"), TEXT); //$NON-NLS-1$ anchor.setReference(I18n.getString("ReportGenerator.report.websiteLink")); //$NON-NLS-1$ anchor.setName("homepage"); //$NON-NLS-1$ para.add(anchor); document.add(para); document.newPage(); TEXT.setColor(new Color(0, 0, 0)); document.newPage(); }
From source file:it.govpay.web.console.pagamenti.gde.exporter.PdfExporter.java
License:Open Source License
private static void addContent(Document document, List<EventoBean> eventi, IEventiService eventiService) throws UtilsException, DocumentException { Anchor anchor = new Anchor("Eventi Selezionati", catFont); anchor.setName("Eventi Selezionati"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); for (EventoBean eventoBean : eventi) { Evento evento = eventoBean.getDTO(); Paragraph subPara = new Paragraph("Evento Id[" + evento.getId() + "]", subFont); Section subCatPart = catPart.addSection(subPara); addEmptyLine(subCatPart, 1);//from w w w . java 2 s.com createEventoTable(subCatPart, evento); addEmptyLine(subCatPart, 1); Infospcoop infospcoop = eventoBean.getInfospcoop() != null ? eventoBean.getInfospcoop().getDTO() : null; if (infospcoop != null) { // if(evento.getCategoria().equals(Categoria.INTERFACCIA) && evento.getIdEgov()!= null){ // Infospcoop infospcoop = eventiService.getInfospcoopByIdEgov(evento.getIdEgov()); Paragraph infoParg = new Paragraph("Infospcoop", subFont); subCatPart.addSection(infoParg); addEmptyLine(subCatPart, 1); createInfospcoopTable(subCatPart, infospcoop); //subCatPart.add(new Paragraph(infospcoop.toXml())); } addEmptyLine(subCatPart, 1); catPart.newPage(); } // now add all this to the document document.add(catPart); }
From source file:net.bull.javamelody.internal.web.pdf.PdfCacheInformationsReport.java
License:Apache License
private void addConfigurationReference() throws DocumentException { final Anchor ehcacheAnchor = new Anchor("Configuration reference", PdfFonts.BLUE.getFont()); ehcacheAnchor.setName("Ehcache configuration reference"); ehcacheAnchor.setReference(//from ww w. j av a2 s . c o m "http://ehcache.sourceforge.net/apidocs/net/sf/ehcache/config/CacheConfiguration.html#field_summary"); ehcacheAnchor.setFont(PdfFonts.BLUE.getFont()); final Paragraph ehcacheParagraph = new Paragraph(); ehcacheParagraph.add(ehcacheAnchor); ehcacheParagraph.setAlignment(Element.ALIGN_RIGHT); addToDocument(ehcacheParagraph); }
From source file:net.bull.javamelody.internal.web.pdf.PdfJavaInformationsReport.java
License:Apache License
private void writeDatabaseVersionAndDataSourceDetails(JavaInformations javaInformations) { if (!noDatabase && javaInformations.getDataBaseVersion() != null) { addCell(getString("Base_de_donnees") + ':'); addCell(javaInformations.getDataBaseVersion()); }/*w w w. jav a2 s. c o m*/ if (javaInformations.getDataSourceDetails() != null) { addCell(getString("DataSource_jdbc") + ':'); addCell(javaInformations.getDataSourceDetails()); addCell(""); final Anchor anchor = new Anchor("DataSource reference", PdfFonts.BLUE.getFont()); anchor.setName("DataSource reference"); anchor.setReference( "http://commons.apache.org/dbcp/apidocs/org/apache/commons/dbcp/BasicDataSource.html"); currentTable.addCell(anchor); } }
From source file:net.bull.javamelody.internal.web.pdf.PdfJobInformationsReport.java
License:Apache License
private void addConfigurationReference() throws DocumentException { final Anchor quartzAnchor = new Anchor("Configuration reference", PdfFonts.BLUE.getFont()); quartzAnchor.setName("Quartz configuration reference"); quartzAnchor.setReference("http://www.quartz-scheduler.org/docs/index.html"); quartzAnchor.setFont(PdfFonts.BLUE.getFont()); final Paragraph quartzParagraph = new Paragraph(); quartzParagraph.add(quartzAnchor);//from w ww. ja v a 2 s.c om quartzParagraph.setAlignment(Element.ALIGN_RIGHT); addToDocument(quartzParagraph); }
From source file:net.bull.javamelody.internal.web.pdf.PdfProcessInformationsReport.java
License:Apache License
private void addPsCommandReference() throws DocumentException { final Anchor psAnchor = new Anchor("ps command reference", PdfFonts.BLUE.getFont()); psAnchor.setName("ps command reference"); psAnchor.setReference("http://en.wikipedia.org/wiki/Ps_(Unix)"); psAnchor.setFont(PdfFonts.BLUE.getFont()); final Paragraph psParagraph = new Paragraph(); psParagraph.add(psAnchor);/*from w ww. ja v a 2 s.c om*/ psParagraph.setAlignment(Element.ALIGN_RIGHT); addToDocument(psParagraph); }
From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.CaseStudieSummaryPDF.java
License:Open Source License
/** * This method is used for add Outcomes in the project summary *///from ww w.ja v a 2 s . c o m private void addProjectOutcomes(String number) { try { Paragraph outcomesBlock = new Paragraph(); outcomesBlock.setAlignment(Element.ALIGN_JUSTIFIED); Paragraph title = new Paragraph(number + ". " + this.getText("summaries.project.outcome"), HEADING2_FONT); outcomesBlock.add(title); outcomesBlock.add(Chunk.NEWLINE); ; title = new Paragraph(); title.setFont(HEADING3_FONT); title.add(number + ".1 " + this.getText("summaries.project.outcomeNarrative")); outcomesBlock.add(title); outcomesBlock.add(Chunk.NEWLINE); ; // Project outcome statement Paragraph body = new Paragraph(); body.setFont(BODY_TEXT_BOLD_FONT); body.add(this.getText("summaries.project.outcomeStatement")); // body.setFont(BODY_TEXT_FONT); if (project.getOutcomes() == null || project.getOutcomes().get(String.valueOf(midOutcomeYear)) == null || project.getOutcomes().get(String.valueOf(midOutcomeYear)).getStatement() == null || project.getOutcomes().get(String.valueOf(midOutcomeYear)).getStatement().equals("")) { body.add(": "); body.setFont(BODY_TEXT_FONT); body.add(this.getText("summaries.project.empty")); } else { body.setFont(BODY_TEXT_FONT); body.add(Chunk.NEWLINE); body.add(this .messageReturn(project.getOutcomes().get(String.valueOf(midOutcomeYear)).getStatement())); } body.add(Chunk.NEWLINE); ; outcomesBlock.add(body); try { document.newPage(); // document.add(outcomesBlock); } catch (Exception e) { LOG.error("There was an error trying to add the project focuses to the project summary pdf", e); } Anchor anchor; ////////////////// Reporting PdfPTable table; // ********************************************************************************** // *************************** Outcome Case Studies ************************************* // ********************************************************************************** if (project.isReporting()) { document.newPage(); Paragraph cell; if (project.getCaseStudies().isEmpty()) { document.add( new Paragraph(this.getText("summaries.project.reporting.outcome.not.case.studies"))); } else { title = new Paragraph(); title.add(Chunk.NEWLINE); // document.add(title); } List<Project> lst = projectManager.getAllProjectsBasicInfo(APConstants.REPORTING_SECTION); Collections.sort(lst, new Comparator<Project>() { @Override public int compare(Project s1, Project s2) { Integer p1 = s1.getId(); Integer p2 = s2.getId(); return p1.compareTo(p2); } }); for (Project project : lst) { project = projectManager.getProject(project.getId()); if (project.isWorkplanRequired()) { String workPlanURL = this.getWorkplanURL(); if (workPlanURL != null || project.getWorkplanName() != null) { project.setWorkplanURL(workPlanURL + project.getWorkplanName()); } } // Get a route for the bilateral contract if (project.isBilateralProject()) { String bilateralContractURL = this.getBilateralContractURL(); if (bilateralContractURL != null || project.getBilateralContractProposalName() != null) { project.setWorkplanURL( bilateralContractURL + project.getBilateralContractProposalName()); } } // Getting the information of the Regions program project.setRegions( ipProgramManager.getProjectFocuses(project.getId(), APConstants.REGION_PROGRAM_TYPE)); // Getting the information of the Flagships program project.setFlagships( ipProgramManager.getProjectFocuses(project.getId(), APConstants.FLAGSHIP_PROGRAM_TYPE)); List<ProjectPartner> projectPartnerList = this.partnerManager.getProjectPartners(project, 0); for (ProjectPartner projectPartner : projectPartnerList) { projectPartner .setPartnerPersons(this.partnerPersonManager.getPartnerPersons(projectPartner)); projectPartner.setPartnerContributors( partnerManager.getProjectPartnerContributors(projectPartner)); } project.setProjectPartners(projectPartnerList); this.project = project; List<CasesStudies> caseStudiesList = caseStudiesManager.getCaseStudysByProject(project.getId()); List<IPIndicator> ipIndicatorList; IPIndicator ipIndicator; if (caseStudiesList != null) { if (!caseStudiesList.isEmpty()) { try { this.addProjectTitle(); this.addMainInformationTable(); } catch (Exception e) { System.out.println(project.getId()); e.printStackTrace(); } } for (CasesStudies caseStudie : caseStudiesList) { ipIndicatorList = new ArrayList<IPIndicator>(); for (CaseStudieIndicators indicatorCaseStudie : caseStudie .getCaseStudieIndicatorses()) { ipIndicator = indicatorManager .getIndicatorFlgship(indicatorCaseStudie.getIdIndicator()); ipIndicatorList.add(ipIndicator); } caseStudie.setCaseStudyIndicators(ipIndicatorList); } project.setCaseStudies(caseStudiesList); int counter = 0; for (CasesStudies caseStudy : project.getCaseStudies()) { counter++; table = new PdfPTable(1); table.setLockedWidth(true); table.setTotalWidth(500); // case study cell = new Paragraph( this.getText("summaries.project.reporting.outcome.case.study") + " #" + counter, TABLE_HEADER_FONT); this.addTableHeaderCell(table, cell); // this.addCustomTableCell(table, cell, Element.ALIGN_LEFT, BODY_TEXT_FONT, Color.WHITE, // table.getNumberOfColumns(), 0, false); // Title cell = new Paragraph( this.getText("summaries.project.reporting.outcome.casestudy.title"), TABLE_BODY_BOLD_FONT); cell.setFont(TABLE_BODY_FONT); cell.add(caseStudy.getTitle()); this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1); // Outcome statement cell = new Paragraph( this.getText("summaries.project.reporting.outcome.casestudy.outcomestatement"), TABLE_BODY_BOLD_FONT); cell.setFont(TABLE_BODY_FONT); cell.add(caseStudy.getOutcomeStatement()); this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1); // Research outputs cell = new Paragraph( this.getText("summaries.project.reporting.outcome.casestudy.researchoutputs"), TABLE_BODY_BOLD_FONT); cell.setFont(TABLE_BODY_FONT); cell.add(caseStudy.getResearchOutputs()); this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1); // Research partners cell = new Paragraph( this.getText("summaries.project.reporting.outcome.casestudy.researchPartners"), TABLE_BODY_BOLD_FONT); cell.setFont(TABLE_BODY_FONT); cell.add(caseStudy.getResearchPartners()); this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1); // activities Contributed cell = new Paragraph( this.getText( "summaries.project.reporting.outcome.casestudy.activitiesContributed"), TABLE_BODY_BOLD_FONT); cell.setFont(TABLE_BODY_FONT); cell.add(caseStudy.getActivities()); this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1); // Non Research Partners cell = new Paragraph( this.getText( "summaries.project.reporting.outcome.casestudy.nonResearchPartners"), TABLE_BODY_BOLD_FONT); cell.setFont(TABLE_BODY_FONT); cell.add(caseStudy.getNonResearchPartneres()); this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1); // Output Users cell = new Paragraph( this.getText("summaries.project.reporting.outcome.casestudy.outputUsers"), TABLE_BODY_BOLD_FONT); cell.setFont(TABLE_BODY_FONT); cell.add(caseStudy.getOutputUsers()); this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1); // Output Used cell = new Paragraph( this.getText("summaries.project.reporting.outcome.casestudy.outputWasUsed"), TABLE_BODY_BOLD_FONT); cell.setFont(TABLE_BODY_FONT); cell.add(caseStudy.getOutputUsed()); this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1); // Evidence cell = new Paragraph( this.getText("summaries.project.reporting.outcome.casestudy.evidenceOutcome"), TABLE_BODY_BOLD_FONT); cell.setFont(TABLE_BODY_FONT); cell.add(caseStudy.getEvidenceOutcome()); this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1); // References cell = new Paragraph( this.getText("summaries.project.reporting.outcome.casestudy.references"), TABLE_BODY_BOLD_FONT); cell.setFont(TABLE_BODY_FONT); cell.add(caseStudy.getReferencesCase()); this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1); // Outcome indicators cell = new Paragraph( this.getText("summaries.project.reporting.outcome.casestudy.primaryOutcome", new String[] { String.valueOf(this.midOutcomeYear) }), TABLE_BODY_BOLD_FONT); cell.setFont(TABLE_BODY_FONT); cell.add("\n"); for (IPIndicator _ipIndicator : caseStudy.getCaseStudyIndicators()) { if (_ipIndicator.getOutcome() != null) { cell.add(_ipIndicator.getOutcome().getDescription()); } cell.add(" " + _ipIndicator.getDescription() + "\n"); } this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1); // Explain link cell = new Paragraph( this.getText("summaries.project.reporting.outcome.casestudy.explainLink"), TABLE_BODY_BOLD_FONT); cell.setFont(TABLE_BODY_FONT); cell.add(caseStudy.getExplainIndicatorRelation()); this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1); // year cell = new Paragraph(this.getText("summaries.project.reporting.outcome.casestudy.year"), TABLE_BODY_BOLD_FONT); cell.setFont(TABLE_BODY_FONT); cell.add(String.valueOf(caseStudy.getYear())); this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1); // upload cell = new Paragraph( this.getText("summaries.project.reporting.outcome.casestudy.upload"), TABLE_BODY_BOLD_FONT); cell.setFont(TABLE_BODY_FONT); if (caseStudy.getFile() == null || caseStudy.getFile().equals("")) { cell.add(this.messageReturn(null)); } else { anchor = new Anchor(caseStudy.getFile(), TABLE_BODY_FONT_LINK); anchor.setReference(config.getDownloadURL() + "/projects/" + project.getId() + "/caseStudy/" + caseStudy.getFile()); cell.add(anchor); } this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1); document.add(table); document.add(new Paragraph(Chunk.NEWLINE)); } } document.newPage(); } } } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.ProjectSummaryPDF.java
License:Open Source License
/** * @param deliverable deliverable to add in the summary * @param counter number of deliverable// w w w .j a v a2s .c o m **/ private void addDelivable(Deliverable deliverable, int counter) { try { if (deliverable != null) { PdfPTable table = new PdfPTable(2); table.setTotalWidth(480); table.setLockedWidth(true); StringBuilder stringBuilder = new StringBuilder(); PdfPCell cell_new; // **** Expected Deliverable #********* Paragraph deliverableBlock = new Paragraph(); deliverableBlock.setFont(HEADING4_FONT); if (project.isReporting()) { deliverableBlock.add(this.getText("summaries.project.deliverable") + " #" + counter); } else { if (deliverable.getYear() < config.getPlanningCurrentYear()) { deliverableBlock.add(this.getText("summaries.project.deliverable") + " #" + counter); } else { deliverableBlock .add(this.getText("summaries.project.deliverable.expected") + " #" + counter); } } deliverableBlock.add(Chunk.NEWLINE); deliverableBlock.add(Chunk.NEWLINE); document.add(deliverableBlock); // **** Deliverable Information ********* deliverableBlock = new Paragraph(); deliverableBlock.setFont(BODY_TEXT_BOLD_FONT); deliverableBlock.setAlignment(Element.ALIGN_LEFT); deliverableBlock.setFont(TABLE_HEADER_FONT); deliverableBlock.add(this.getText("summaries.project.deliverable.information")); cell_new = new PdfPCell(deliverableBlock); cell_new.setHorizontalAlignment(Element.ALIGN_CENTER); cell_new.setVerticalAlignment(Element.ALIGN_MIDDLE); cell_new.setBackgroundColor(TABLE_HEADER_BACKGROUND); cell_new.setUseBorderPadding(true); cell_new.setPadding(3); cell_new.setBorderColor(TABLE_CELL_BORDER_COLOR); cell_new.setColspan(2); this.addTableHeaderCell(table, cell_new); // Title deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.deliverable.information.title") + ": "); deliverableBlock.setFont(TABLE_BODY_FONT); deliverableBlock.add(this.messageReturn(deliverable.getTitle())); deliverableBlock.add(Chunk.NEWLINE); ; // document.add(deliverableBlock); this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 2); // MOG deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); if (deliverable.getOutput() != null) { stringBuilder = new StringBuilder(); if (deliverable.getOutput().getProgram() != null && deliverable.getOutput().getProgram().getAcronym() != null) { stringBuilder.append(deliverable.getOutput().getProgram().getAcronym()); stringBuilder.append(" - MOG # "); } else { stringBuilder.append("MOG # "); } stringBuilder.append(this.getMOGIndex(deliverable.getOutput())); stringBuilder.append(": "); deliverableBlock.add(stringBuilder.toString()); deliverableBlock.setFont(TABLE_BODY_FONT); stringBuilder = new StringBuilder(); stringBuilder.append(deliverable.getOutput().getDescription()); } else { deliverableBlock.add("MOG :"); stringBuilder.append(this.getText("summaries.project.empty")); } deliverableBlock.add(stringBuilder.toString()); deliverableBlock.add(Chunk.NEWLINE); // document.add(deliverableBlock); this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 2); // Main Type deliverableBlock = new Paragraph(); stringBuilder = new StringBuilder(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); stringBuilder.append(this.getText("summaries.project.deliverable.information.main")); stringBuilder.append(": "); deliverableBlock.add(stringBuilder.toString()); deliverableBlock.setFont(TABLE_BODY_FONT); stringBuilder = new StringBuilder(); if (deliverable.getType() != null && deliverable.getType().getCategory() != null) { stringBuilder.append(this.messageReturn(deliverable.getType().getCategory().getName())); } else { stringBuilder.append(this.messageReturn("")); } deliverableBlock.add(stringBuilder.toString()); deliverableBlock.add(Chunk.NEWLINE); this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1); // Sub Type deliverableBlock = new Paragraph(); stringBuilder = new StringBuilder(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); stringBuilder.append(this.getText("summaries.project.deliverable.information.sub")); stringBuilder.append(": "); deliverableBlock.add(stringBuilder.toString()); deliverableBlock.setFont(TABLE_BODY_FONT); stringBuilder = new StringBuilder(); if (deliverable.getType() == null) { stringBuilder.append(this.messageReturn(this.getText("summaries.project.empty"))); } else if (deliverable.getType().getId() == 38) { stringBuilder.append(this.getText("summaries.project.deliverable.other.expected")); stringBuilder.append("("); stringBuilder.append(this.messageReturn(deliverable.getTypeOther())); stringBuilder.append(")"); } else { stringBuilder.append(this.messageReturn(deliverable.getType().getName())); } deliverableBlock.add(this.messageReturn(stringBuilder.toString())); deliverableBlock.add(Chunk.NEWLINE); ; // document.add(deliverableBlock); this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); // Year deliverableBlock = new Paragraph(); stringBuilder = new StringBuilder(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); stringBuilder.append(this.getText("summaries.project.deliverable.information.year")); stringBuilder.append(": "); deliverableBlock.add(stringBuilder.toString()); deliverableBlock.setFont(TABLE_BODY_FONT); stringBuilder = new StringBuilder(); stringBuilder.append(deliverable.getYear()); deliverableBlock.add(stringBuilder.toString()); deliverableBlock.add(Chunk.NEWLINE); // document.add(deliverableBlock); this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 2); // Status deliverableBlock = new Paragraph(); stringBuilder = new StringBuilder(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); stringBuilder.append(this.getText("summaries.project.deliverable.information.statuts")); deliverableBlock.add(stringBuilder.toString()); deliverableBlock.setFont(TABLE_BODY_FONT); stringBuilder = new StringBuilder(); if (deliverable.getStatus() != 0) { if (deliverable.getStatus() == Integer.parseInt(ProjectStatusEnum.Cancelled.getStatusId())) { deliverableBlock.setFont(TABLE_BODY_FONT_RED); } stringBuilder.append(this.statuses.get(String.valueOf(deliverable.getStatus()))); } else { stringBuilder.append(this.messageReturn(null)); } deliverableBlock.add(stringBuilder.toString()); deliverableBlock.add(Chunk.NEWLINE); // document.add(deliverableBlock); if (deliverable.isStatusCancelled() || deliverable.isStatusExtended() || deliverable.isStatusOnGoing()) { this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 1); // Justification deliverableBlock = new Paragraph(); stringBuilder = new StringBuilder(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); stringBuilder.append(this.getText("summaries.project.deliverable.information.justification")); deliverableBlock.add(stringBuilder.toString()); deliverableBlock.setFont(TABLE_BODY_FONT); deliverableBlock.add(this.messageReturn(deliverable.getStatusDescription())); deliverableBlock.add(Chunk.NEWLINE); this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 1); } else { this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 2); } document.add(table); deliverableBlock = new Paragraph(); deliverableBlock.add(Chunk.NEWLINE); document.add(deliverableBlock); // ********** Next Users************************************** counter = 1; List<NextUser> nextUsers = deliverable.getNextUsers(); for (NextUser nextUser : nextUsers) { if (nextUser != null) { table = new PdfPTable(1); table.setTotalWidth(480); table.setLockedWidth(true); // Next user title deliverableBlock = new Paragraph(); deliverableBlock.setAlignment(Element.ALIGN_LEFT); deliverableBlock.setFont(TABLE_HEADER_FONT); if (nextUsers.size() == 1) { deliverableBlock.add(this.getText("summaries.project.deliverable.next.user")); } else { deliverableBlock .add(this.getText("summaries.project.deliverable.next.user") + " #" + counter); } this.addTableHeaderCell(table, deliverableBlock); // Next user stringBuilder = new StringBuilder(); deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_FONT); stringBuilder.append(nextUser.getUser()); deliverableBlock.add(this.messageReturn(stringBuilder.toString())); this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1); // Expected Changes stringBuilder = new StringBuilder(); deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock .add(this.getText("summaries.project.deliverable.next.user.expected.change")); deliverableBlock.setFont(TABLE_BODY_FONT); stringBuilder.append(this.messageReturn(nextUser.getExpectedChanges())); deliverableBlock.add(stringBuilder.toString()); // document.add(deliverableBlock); this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1); // Strategies stringBuilder = new StringBuilder(); deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.deliverable.next.user.strategies")); deliverableBlock.setFont(TABLE_BODY_FONT); stringBuilder.append(this.messageReturn(nextUser.getStrategies())); deliverableBlock.add(stringBuilder.toString()); // document.add(deliverableBlock); this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1); document.add(table); deliverableBlock = new Paragraph(); deliverableBlock.add(Chunk.NEWLINE); document.add(deliverableBlock); counter++; } } // ********** Deliverable partnership**************************** // ******************Partner contributing counter = 1; table = new PdfPTable(1); table.setLockedWidth(true); table.setTotalWidth(480); // Title partners contributing deliverableBlock = new Paragraph(); deliverableBlock.setAlignment(Element.ALIGN_LEFT); deliverableBlock.setFont(TABLE_HEADER_FONT); deliverableBlock.add(this.getText("summaries.project.deliverable.partnership")); deliverableBlock.setFont(TABLE_HEADER_FONT); this.addTableHeaderCell(table, deliverableBlock); // Organization stringBuilder = new StringBuilder(); deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.deliverable.partnership.organization") + " #" + counter + " (Responsible)" + ": "); deliverableBlock.setFont(TABLE_BODY_FONT); DeliverablePartner deliverableResponsiblePartner = deliverable.getResponsiblePartner(); PartnerPerson partnerPersonResponsible = null; if (deliverableResponsiblePartner != null) { partnerPersonResponsible = deliverableResponsiblePartner.getPartner(); } if (deliverableResponsiblePartner != null && partnerPersonResponsible != null) { stringBuilder.append(this.messageReturn(partnerPersonResponsible.getComposedName())); stringBuilder.append(", "); stringBuilder .append(this.mapPartnerPersons.get(String.valueOf(partnerPersonResponsible.getId()))); } else { stringBuilder.append(this.getText("summaries.project.empty")); } deliverableBlock.add(stringBuilder.toString()); deliverableBlock.add(Chunk.NEWLINE); ; this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1); counter = 1; // ************** Other Partners List<DeliverablePartner> listOtherPartner = deliverable.getOtherPartners(); PartnerPerson otherResponsiblepartnerPerson = null; if (!listOtherPartner.isEmpty()) { for (DeliverablePartner deliverablePartner : listOtherPartner) { if (deliverablePartner != null) { counter++; // Title partners contributing deliverableBlock = new Paragraph(); deliverableBlock.setAlignment(Element.ALIGN_LEFT); deliverableBlock.setFont(BODY_TEXT_BOLD_FONT); if (listOtherPartner.size() == 1) { deliverableBlock.add(this.getText("summaries.project.deliverable.partnership")); } else { deliverableBlock.add( this.getText("summaries.project.deliverable.partnership") + " #" + counter); } // Organization stringBuilder = new StringBuilder(); deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock .add(this.getText("summaries.project.deliverable.partnership.organization") + " #" + counter + ": "); deliverableBlock.add(""); deliverableBlock.setFont(TABLE_BODY_FONT); otherResponsiblepartnerPerson = deliverablePartner.getPartner(); if (otherResponsiblepartnerPerson != null) { stringBuilder.append( this.messageReturn(otherResponsiblepartnerPerson.getComposedName())); stringBuilder.append(", "); stringBuilder.append(this.mapPartnerPersons .get(String.valueOf(otherResponsiblepartnerPerson.getId()))); } else { stringBuilder.append(this.getText("summaries.project.empty")); } deliverableBlock.add(stringBuilder.toString()); deliverableBlock.add(Chunk.NEWLINE); ; this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1); } } } document.add(table); deliverableBlock = new Paragraph(); deliverableBlock.add(Chunk.NEWLINE); document.add(deliverableBlock); } // ********** Ranking************************************** PdfPCell cell_new; if (project.isReporting()) { PdfPTable table = new PdfPTable(2); table.setLockedWidth(true); table.setTotalWidth(480); table.setWidths(new int[] { 7, 3 }); DeliverablesRanking deliverableRanking = deliverable.getRanking(); // summaries.project.reporting.deliverable.ranking Paragraph deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_HEADER_FONT); deliverableBlock.setAlignment(Element.ALIGN_LEFT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.ranking")); cell_new = new PdfPCell(deliverableBlock); cell_new.setHorizontalAlignment(Element.ALIGN_CENTER); cell_new.setVerticalAlignment(Element.ALIGN_MIDDLE); cell_new.setBackgroundColor(TABLE_HEADER_BACKGROUND); cell_new.setUseBorderPadding(true); cell_new.setPadding(3); cell_new.setBorderColor(TABLE_CELL_BORDER_COLOR); cell_new.setColspan(2); this.addTableHeaderCell(table, cell_new); // address gender deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.addres.gender")); this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_FONT); if (deliverableRanking != null && deliverableRanking.getAddress() != null) { deliverableBlock.add(this.messageReturn(deliverableRanking.getAddress().toString())); } else { deliverableBlock.add(this.messageReturn(null)); } this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_CENTER, 1); // Get Potential deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.contribution.outcome")); this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_FONT); if (deliverableRanking != null && deliverableRanking.getPotential() != null) { deliverableBlock.add(this.messageReturn(deliverableRanking.getPotential().toString())); } else { deliverableBlock.add(this.messageReturn(null)); } this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_CENTER, 1); // Level deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.shared.ownership")); this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_FONT); if (deliverableRanking != null && deliverableRanking.getLevel() != null) { deliverableBlock.add(this.messageReturn(deliverableRanking.getLevel().toString())); } else { deliverableBlock.add(this.messageReturn(null)); } this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_CENTER, 1); // Personal perspective deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.personal.prespective")); this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_FONT); if (deliverableRanking != null && deliverableRanking.getPersonalPerspective() != null) { deliverableBlock .add(this.messageReturn(String.valueOf(deliverableRanking.getPersonalPerspective()))); } else { deliverableBlock.add(this.messageReturn(null)); } this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_CENTER, 1); document.add(table); deliverableBlock = new Paragraph(); deliverableBlock.add(Chunk.NEWLINE); document.add(deliverableBlock); // ********** Deliverable Dissemination************************************** DeliverableDissemination deliverableDissemination = deliverable.getDissemination(); table = new PdfPTable(1); table.setLockedWidth(true); table.setTotalWidth(480); deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_HEADER_FONT); deliverableBlock.setAlignment(Element.ALIGN_LEFT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination")); this.addTableHeaderCell(table, deliverableBlock); // Open access deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination.open")); deliverableBlock.setFont(TABLE_BODY_FONT); if (deliverableDissemination != null) { if (deliverableDissemination.getIsOpenAccess() != null && deliverableDissemination.getIsOpenAccess().booleanValue()) { deliverableBlock.add("Yes"); } else if (deliverableDissemination.getIntellectualProperty() != null && deliverableDissemination.getIntellectualProperty().booleanValue()) { deliverableBlock.add( this.getText("summaries.project.reporting.deliverable.dissemination.intellectual")); } else if (deliverableDissemination.getLimitedExclusivity() != null && deliverableDissemination.getLimitedExclusivity().booleanValue()) { deliverableBlock .add(this.getText("summaries.project.reporting.deliverable.dissemination.limited")); } else if (deliverableDissemination.getRestrictedUseAgreement() != null && deliverableDissemination.getRestrictedUseAgreement().booleanValue()) { deliverableBlock.add( this.getText("summaries.project.reporting.deliverable.dissemination.restricted")); this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock .add(this.getText("summaries.project.reporting.deliverable.dissemination.access")); deliverableBlock.setFont(TABLE_BODY_FONT); deliverableBlock.add(deliverableDissemination.getRestrictedAccessUntilText()); } else if (deliverableDissemination.getEffectiveDateRestriction() != null && deliverableDissemination.getEffectiveDateRestriction().booleanValue()) { deliverableBlock.add( this.getText("summaries.project.reporting.deliverable.dissemination.effective")); this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add( this.getText("summaries.project.reporting.deliverable.dissemination.embargoed")); deliverableBlock.setFont(TABLE_BODY_FONT); deliverableBlock.add(deliverableDissemination.getRestrictedEmbargoedText()); } else { deliverableBlock.add(this.messageReturn(null)); } } else { deliverableBlock.add(this.messageReturn(null)); } this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); // License adopted deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination.license")); deliverableBlock.setFont(TABLE_BODY_FONT); if (deliverableDissemination != null) { if (deliverable .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_LICENSE) != null) { deliverableBlock.add(this.messageReturn(deliverable .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_LICENSE))); } else { deliverableBlock.add("No"); } } else { deliverableBlock.add(this.messageReturn(null)); } this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); // // Dissemination channel deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination.channel")); deliverableBlock.setFont(TABLE_BODY_FONT); if (deliverableDissemination != null) { deliverableBlock.add(this.messageReturn(deliverableDissemination.getDisseminationChannel())); } else { deliverableBlock.add(this.messageReturn(null)); } this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); // Dissemination URL deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination.url")); deliverableBlock.setFont(TABLE_BODY_FONT_LINK); if (deliverableDissemination != null) { deliverableBlock.add(this.messageReturn(deliverableDissemination.getDisseminationUrl())); } else { deliverableBlock.add(this.messageReturn(null)); } this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); document.add(table); deliverableBlock = new Paragraph(); deliverableBlock.add(Chunk.NEWLINE); document.add(deliverableBlock); // ********** Deliverable Metadata************************************** DeliverablePublicationMetadata deliverableMetadata = deliverable.getPublicationMetadata(); table = new PdfPTable(1); table.setLockedWidth(true); table.setTotalWidth(480); deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_HEADER_FONT); deliverableBlock.setAlignment(Element.ALIGN_LEFT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata")); this.addTableHeaderCell(table, deliverableBlock); // Description deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.description")); deliverableBlock.setFont(TABLE_BODY_FONT); if (deliverableMetadata != null) { deliverableBlock.add(this.messageReturn(deliverable .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_DESCRIPTION))); } else { deliverableBlock.add(this.messageReturn(null)); } this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); // creator deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.creator")); deliverableBlock.setFont(TABLE_BODY_FONT); if (deliverableMetadata != null) { deliverableBlock.add(this.messageReturn( deliverable.getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_CREATOR))); } else { deliverableBlock.add(this.messageReturn(null)); } this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); // authorID deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.authorID")); deliverableBlock.setFont(TABLE_BODY_FONT); if (deliverableMetadata != null) { deliverableBlock.add(this.messageReturn(deliverable .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_CREATOR_ID))); } else { deliverableBlock.add(this.messageReturn(null)); } this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); // Creation deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.creation")); deliverableBlock.setFont(TABLE_BODY_FONT); if (deliverableMetadata != null) { deliverableBlock.add(this.messageReturn(deliverable .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_PUBLICATION))); } else { deliverableBlock.add(this.messageReturn(null)); } this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); // Language deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.language")); deliverableBlock.setFont(TABLE_BODY_FONT); if (deliverableMetadata != null) { deliverableBlock.add(this.messageReturn(this.messageReturn(deliverable .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_LANGUAGE)))); } else { deliverableBlock.add(this.messageReturn(null)); } this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); // Coverage deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.coverage")); deliverableBlock.setFont(TABLE_BODY_FONT); if (deliverableMetadata != null) { deliverableBlock.add(this.messageReturn(deliverable .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_COVERAGE))); } else { deliverableBlock.add(this.messageReturn(null)); } this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); document.add(table); deliverableBlock = new Paragraph(); deliverableBlock.add(Chunk.NEWLINE); document.add(deliverableBlock); // ********** Deliverable Data Sharing************************************** table = new PdfPTable(1); table.setLockedWidth(true); table.setTotalWidth(480); deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_HEADER_FONT); deliverableBlock.setAlignment(Element.ALIGN_LEFT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.datasharing")); this.addTableHeaderCell(table, deliverableBlock); // Files deliverableBlock = new Paragraph(); deliverableBlock.setFont(TABLE_BODY_BOLD_FONT); deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.datasharing.files")); deliverableBlock.add("\n"); deliverableBlock.setFont(TABLE_BODY_FONT); List<DeliverableDataSharingFile> deliverableDataSharingFileList = deliverable.getDataSharingFile(); cell_new = new PdfPCell(deliverableBlock); cell_new.setHorizontalAlignment(Element.ALIGN_CENTER); cell_new.setVerticalAlignment(Element.ALIGN_MIDDLE); cell_new.setBackgroundColor(TABLE_BODY_ODD_ROW_BACKGROUND); cell_new.setUseBorderPadding(true); cell_new.setPadding(3); cell_new.setBorderColor(TABLE_CELL_BORDER_COLOR); cell_new.setColspan(2); Anchor anchor; Phrase myurl; counter = 0; if (deliverableDataSharingFileList != null) { for (DeliverableDataSharingFile deliverableDataSharingFile : deliverableDataSharingFileList) { if (deliverableDataSharingFile != null) { anchor = new Anchor(deliverableDataSharingFile.getFile(), TABLE_BODY_FONT_LINK); anchor.setReference(config.getDownloadURL() + "/projects/" + project.getId() + "/deliverableDataSharing/" + deliverableDataSharingFile.getFile()); myurl = new Phrase(); myurl.add(anchor); myurl.setFont(TABLE_BODY_FONT_LINK); cell_new.addElement(myurl); if (counter > 1) { cell_new.addElement(new Paragraph("\n")); } counter++; } } table.addCell(cell_new); } else { deliverableBlock.setFont(TABLE_BODY_FONT); deliverableBlock.add(this.messageReturn(null)); this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1); } document.add(table); deliverableBlock = new Paragraph(); deliverableBlock.add(Chunk.NEWLINE); deliverableBlock.add(Chunk.NEWLINE); document.add(deliverableBlock); } } catch (DocumentException e) { LOG.error( "-- generatePdf() > There was an error adding the table with content for case study summary. ", e); } }