Added Logo ISTI and CNR to Credits
This commit is contained in:
parent
ed0e3b515f
commit
aca07cea92
|
@ -3,13 +3,11 @@ package org.gcube.application.geoportaldatamapper;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
|
@ -22,6 +20,8 @@ import java.util.stream.Collectors;
|
|||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.rest.TempFile;
|
||||
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
||||
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||||
|
@ -75,6 +75,7 @@ import com.itextpdf.layout.Document;
|
|||
import com.itextpdf.layout.Style;
|
||||
import com.itextpdf.layout.borders.Border;
|
||||
import com.itextpdf.layout.element.Cell;
|
||||
import com.itextpdf.layout.element.IElement;
|
||||
import com.itextpdf.layout.element.Image;
|
||||
import com.itextpdf.layout.element.Link;
|
||||
import com.itextpdf.layout.element.Paragraph;
|
||||
|
@ -86,6 +87,13 @@ import com.itextpdf.layout.renderer.CellRenderer;
|
|||
import com.itextpdf.layout.renderer.DrawContext;
|
||||
import com.itextpdf.layout.renderer.IRenderer;
|
||||
|
||||
/**
|
||||
* The Class Geoportal_PDF_Exporter.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 16, 2023
|
||||
*/
|
||||
public class Geoportal_PDF_Exporter {
|
||||
|
||||
private static final String PDF_EXPORTER_CREDITS_PROPERTIES_FILENAME = "pdf_exporter_credits.properties";
|
||||
|
@ -93,6 +101,8 @@ public class Geoportal_PDF_Exporter {
|
|||
private static final String PROPERTY_WWW_D4SCIENCE_ORG = "WWW_D4SCIENCE_ORG";
|
||||
private static final String PROPERTY_POWERED_BY_D4SCIENCE_LOGO = "POWERED_BY_D4SCIENCE_LOGO";
|
||||
private static final String PROPERTY_LOGO_D4GNA = "LOGO_D4GNA";
|
||||
private static final String PROPERTY_LOGO_ISTI = "LOGO_ISTI";
|
||||
private static final String PROPERTY_LOGO_CNR = "LOGO_CNR";
|
||||
|
||||
private static final int PARAGRAPH_MARGIN_TOP = 20;
|
||||
private static final int FONT_SIZE_SECTION_TITLE = 14;
|
||||
|
@ -102,47 +112,194 @@ public class Geoportal_PDF_Exporter {
|
|||
|
||||
private static Logger LOG = LoggerFactory.getLogger(Geoportal_PDF_Exporter.class);
|
||||
|
||||
|
||||
/**
|
||||
* Creates the PDF file.
|
||||
* The Class Exporter_PDF_Credits.
|
||||
*
|
||||
* @param exportSource the export source. // set ExporterProjectSource.username = null to test PUBLIC ACCESS
|
||||
* @return the string
|
||||
* @throws Exception the exception
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 16, 2023
|
||||
*/
|
||||
public String createPDFFile(ExporterProjectSource exportSource) throws Exception {
|
||||
static class Exporter_PDF_Credits {
|
||||
|
||||
String logoD4GNA = null;
|
||||
String poweredByD4Science = null;
|
||||
String wwwD4ScienceOrg = null;
|
||||
String gnaD4ScienceOrg = null;
|
||||
String logoPoweredByD4Science = null;
|
||||
String linkD4ScienceOrg = null;
|
||||
String linkGnaD4ScienceOrg = null;
|
||||
String logoISTI = null;
|
||||
String logoCNR = null;
|
||||
|
||||
String pdfFileURL = null;
|
||||
/**
|
||||
* Instantiates a new exporter PD F credits.
|
||||
*/
|
||||
public Exporter_PDF_Credits() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the logo D 4 GNA.
|
||||
*
|
||||
* @return the logo D 4 GNA
|
||||
*/
|
||||
public String getLogoD4GNA() {
|
||||
return logoD4GNA;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the logo powered by D 4 science.
|
||||
*
|
||||
* @return the logo powered by D 4 science
|
||||
*/
|
||||
public String getLogoPoweredByD4Science() {
|
||||
return logoPoweredByD4Science;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the link D 4 science org.
|
||||
*
|
||||
* @return the link D 4 science org
|
||||
*/
|
||||
public String getLinkD4ScienceOrg() {
|
||||
return linkD4ScienceOrg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the link gna D 4 science org.
|
||||
*
|
||||
* @return the link gna D 4 science org
|
||||
*/
|
||||
public String getLinkGnaD4ScienceOrg() {
|
||||
return linkGnaD4ScienceOrg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the logo ISTI.
|
||||
*
|
||||
* @return the logo ISTI
|
||||
*/
|
||||
public String getLogoISTI() {
|
||||
return logoISTI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the logo CNR.
|
||||
*
|
||||
* @return the logo CNR
|
||||
*/
|
||||
public String getLogoCNR() {
|
||||
return logoCNR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the logo D 4 GNA.
|
||||
*
|
||||
* @param logoD4GNA the new logo D 4 GNA
|
||||
*/
|
||||
public void setLogoD4GNA(String logoD4GNA) {
|
||||
this.logoD4GNA = logoD4GNA;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the logo powered by D 4 science.
|
||||
*
|
||||
* @param logoPoweredByD4Science the new logo powered by D 4 science
|
||||
*/
|
||||
public void setLogoPoweredByD4Science(String logoPoweredByD4Science) {
|
||||
this.logoPoweredByD4Science = logoPoweredByD4Science;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the link D 4 science org.
|
||||
*
|
||||
* @param linkD4ScienceOrg the new link D 4 science org
|
||||
*/
|
||||
public void setLinkD4ScienceOrg(String linkD4ScienceOrg) {
|
||||
this.linkD4ScienceOrg = linkD4ScienceOrg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the link gna D 4 science org.
|
||||
*
|
||||
* @param linkGnaD4ScienceOrg the new link gna D 4 science org
|
||||
*/
|
||||
public void setLinkGnaD4ScienceOrg(String linkGnaD4ScienceOrg) {
|
||||
this.linkGnaD4ScienceOrg = linkGnaD4ScienceOrg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the logo ISTI.
|
||||
*
|
||||
* @param logoISTI the new logo ISTI
|
||||
*/
|
||||
public void setLogoISTI(String logoISTI) {
|
||||
this.logoISTI = logoISTI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the logo CNR.
|
||||
*
|
||||
* @param logoCNR the new logo CNR
|
||||
*/
|
||||
public void setLogoCNR(String logoCNR) {
|
||||
this.logoCNR = logoCNR;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Read credits.
|
||||
*
|
||||
* @return the exporter PD F credits
|
||||
*/
|
||||
private Exporter_PDF_Credits readCredits() {
|
||||
|
||||
Exporter_PDF_Credits credits = null;
|
||||
|
||||
// Reading property file with credit references
|
||||
try (InputStream input = Geoportal_PDF_Exporter.class
|
||||
.getResourceAsStream(PDF_EXPORTER_CREDITS_PROPERTIES_FILENAME)) {
|
||||
|
||||
credits = new Geoportal_PDF_Exporter.Exporter_PDF_Credits();
|
||||
|
||||
Properties prop = new Properties();
|
||||
|
||||
// load a properties file
|
||||
prop.load(input);
|
||||
|
||||
logoD4GNA = prop.getProperty(PROPERTY_LOGO_D4GNA);
|
||||
poweredByD4Science = prop.getProperty(PROPERTY_POWERED_BY_D4SCIENCE_LOGO);
|
||||
wwwD4ScienceOrg = prop.getProperty(PROPERTY_WWW_D4SCIENCE_ORG);
|
||||
gnaD4ScienceOrg = prop.getProperty(PROPERTY_GNA_D4SCIENCE_ORG);
|
||||
credits.setLogoD4GNA(prop.getProperty(PROPERTY_LOGO_D4GNA));
|
||||
credits.setLogoPoweredByD4Science(prop.getProperty(PROPERTY_POWERED_BY_D4SCIENCE_LOGO));
|
||||
credits.setLinkD4ScienceOrg(prop.getProperty(PROPERTY_WWW_D4SCIENCE_ORG));
|
||||
credits.setLinkGnaD4ScienceOrg(prop.getProperty(PROPERTY_GNA_D4SCIENCE_ORG));
|
||||
credits.setLogoISTI(prop.getProperty(PROPERTY_LOGO_ISTI));
|
||||
credits.setLogoCNR(prop.getProperty(PROPERTY_LOGO_CNR));
|
||||
// get the property value and print it out
|
||||
LOG.trace(PROPERTY_LOGO_D4GNA + ": " + logoD4GNA);
|
||||
LOG.trace(PROPERTY_POWERED_BY_D4SCIENCE_LOGO + ": " + poweredByD4Science);
|
||||
LOG.trace(PROPERTY_WWW_D4SCIENCE_ORG + ": " + wwwD4ScienceOrg);
|
||||
LOG.trace(PROPERTY_GNA_D4SCIENCE_ORG + ": " + gnaD4ScienceOrg);
|
||||
LOG.trace(PROPERTY_LOGO_D4GNA + ": " + credits.getLogoD4GNA());
|
||||
LOG.trace(PROPERTY_POWERED_BY_D4SCIENCE_LOGO + ": " + credits.getLogoPoweredByD4Science());
|
||||
LOG.trace(PROPERTY_WWW_D4SCIENCE_ORG + ": " + credits.getLinkD4ScienceOrg());
|
||||
LOG.trace(PROPERTY_GNA_D4SCIENCE_ORG + ": " + credits.getLinkGnaD4ScienceOrg());
|
||||
LOG.trace(PROPERTY_LOGO_CNR + ": " + credits.getLogoCNR());
|
||||
LOG.trace(PROPERTY_LOGO_ISTI + ": " + credits.getLogoISTI());
|
||||
|
||||
} catch (IOException ex) {
|
||||
LOG.error("no file found: " + PDF_EXPORTER_CREDITS_PROPERTIES_FILENAME);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return credits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the PDF file.
|
||||
*
|
||||
* @param exportSource the export source. // set ExporterProjectSource.username
|
||||
* = null to test PUBLIC ACCESS
|
||||
* @return the string
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public String createPDFFile(ExporterProjectSource exportSource) throws Exception {
|
||||
|
||||
String pdfFileURL = null;
|
||||
|
||||
Exporter_PDF_Credits credits = readCredits();
|
||||
|
||||
ServiceAccessPoint sap = MapBoxEndpointReader.getMapBoxEndpoint();
|
||||
|
||||
PdfDocument pdfDocument = null;
|
||||
|
@ -170,18 +327,23 @@ public class Geoportal_PDF_Exporter {
|
|||
// silent
|
||||
}
|
||||
|
||||
// Creates a header for every page in the document
|
||||
pdfDocument.addEventHandler(PdfDocumentEvent.END_PAGE, new HeaderHandler());
|
||||
if (exportSource.isAddPageNumbers()) {
|
||||
// Creates a header for every page in the document. The HeaderHandler implements
|
||||
// add page numbers.
|
||||
pdfDocument.addEventHandler(PdfDocumentEvent.END_PAGE, new HeaderHandler());
|
||||
}
|
||||
|
||||
// Initialize document
|
||||
Document document = new Document(pdfDocument);
|
||||
|
||||
// Adding logo D4GNA
|
||||
Image image = toImageFromLink(logoD4GNA, 80);
|
||||
// image.setMaxHeight(150);
|
||||
image.setFixedPosition(document.getLeftMargin(),
|
||||
pdfDocument.getDefaultPageSize().getHeight() - image.getImageHeight() + 90);
|
||||
document.add(image);
|
||||
if (credits != null) {
|
||||
Image image = toImageFromLink(credits.getLogoD4GNA(), 80);
|
||||
// image.setMaxHeight(150);
|
||||
image.setFixedPosition(document.getLeftMargin(),
|
||||
pdfDocument.getDefaultPageSize().getHeight() - image.getImageHeight() + 90);
|
||||
document.add(image);
|
||||
}
|
||||
|
||||
// Project Name
|
||||
PdfFont bold = PdfFontFactory.createFont(StandardFonts.TIMES_BOLD);
|
||||
|
@ -239,20 +401,23 @@ public class Geoportal_PDF_Exporter {
|
|||
|
||||
for (SectionView section : projectView.getListSections()) {
|
||||
document = appendSubDocumentToPDF(document, section, section.getListSubDocuments(),
|
||||
exportSource.getGisLink(), sap);
|
||||
exportSource.getGisLink(), sap, credits);
|
||||
}
|
||||
|
||||
// TimeStamp - Created at
|
||||
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
PdfFont font = PdfFontFactory.createFont(StandardFonts.COURIER_OBLIQUE);
|
||||
Style style2 = new Style().setFont(font).setFontSize(8);
|
||||
Paragraph pt = new Paragraph().add("Created at " + now.format(dtf)).addStyle(style2);
|
||||
pt.setMarginTop(50);
|
||||
document.add(pt);
|
||||
// Add timestamp Created at...
|
||||
if (exportSource.isAddTimpestampCreatedAt()) {
|
||||
// TimeStamp - Created at
|
||||
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
PdfFont font = PdfFontFactory.createFont(StandardFonts.COURIER_OBLIQUE);
|
||||
Style style2 = new Style().setFont(font).setFontSize(8);
|
||||
Paragraph pt = new Paragraph().add("Created at " + now.format(dtf)).addStyle(style2);
|
||||
pt.setMarginTop(50);
|
||||
document.add(pt);
|
||||
}
|
||||
|
||||
// Credits
|
||||
Table tableCredits = getCredits(document, logoD4GNA, poweredByD4Science, wwwD4ScienceOrg, gnaD4ScienceOrg);
|
||||
Table tableCredits = addCredits(document, credits);
|
||||
document.add(tableCredits);
|
||||
document.close();
|
||||
|
||||
|
@ -261,20 +426,20 @@ public class Geoportal_PDF_Exporter {
|
|||
String projectTitleSanitized = projectTitle.replaceAll("[^a-zA-Z0-9]", "_");
|
||||
|
||||
// Save PDF on storage VOLATILE
|
||||
// StorageUtils storage = new StorageUtils();
|
||||
// TempFile tempFile = storage.putOntoStorage(in, projectTitleSanitized + ".pdf");
|
||||
// String storageURL = storage.getURL(tempFile.getId());
|
||||
// LOG.trace("mongo pdf ID: " + tempFile.getId());
|
||||
// LOG.trace("mongo pdf filename: " + tempFile.getFilename());
|
||||
//
|
||||
// pdfFileURL = String.format("%s?contentType=%s&fileName=%s&content-disposition=%s", storageURL,
|
||||
// "application/pdf", tempFile.getFilename(), "inline");
|
||||
// LOG.info("returning pdf URL: " + pdfFileURL);
|
||||
StorageUtils storage = new StorageUtils();
|
||||
TempFile tempFile = storage.putOntoStorage(in, projectTitleSanitized + ".pdf");
|
||||
String storageURL = storage.getURL(tempFile.getId());
|
||||
LOG.trace("mongo pdf ID: " + tempFile.getId());
|
||||
LOG.trace("mongo pdf filename: " + tempFile.getFilename());
|
||||
|
||||
pdfFileURL = String.format("%s?contentType=%s&fileName=%s&content-disposition=%s", storageURL,
|
||||
"application/pdf", tempFile.getFilename(), "inline");
|
||||
LOG.info("returning pdf URL: " + pdfFileURL);
|
||||
|
||||
// TEST save file locally
|
||||
File targetFile = new File(projectTitleSanitized + ".pdf");
|
||||
java.nio.file.Files.copy(in, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
LOG.info("targetFile at: " + targetFile.getAbsolutePath());
|
||||
// File targetFile = new File(projectTitleSanitized + ".pdf");
|
||||
// java.nio.file.Files.copy(in, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
// LOG.info("targetFile at: " + targetFile.getAbsolutePath());
|
||||
|
||||
IOUtils.closeQuietly(in);
|
||||
} catch (Exception e) {
|
||||
|
@ -317,10 +482,10 @@ public class Geoportal_PDF_Exporter {
|
|||
Rectangle pageSize = page.getPageSize();
|
||||
PdfCanvas pdfCanvas = new PdfCanvas(page.newContentStreamBefore(), page.getResources(), pdf);
|
||||
Canvas canvas = new Canvas(pdfCanvas, pageSize);
|
||||
Paragraph p = new Paragraph().add("Pg. ").add(String.valueOf(pageNumber));
|
||||
Paragraph p = new Paragraph().add("pg. ").add(String.valueOf(pageNumber));
|
||||
try {
|
||||
p.setFont(PdfFontFactory.createFont(StandardFonts.HELVETICA_OBLIQUE));
|
||||
p.setFontSize(7);
|
||||
p.setFont(PdfFontFactory.createFont(StandardFonts.TIMES_ITALIC));
|
||||
p.setFontSize(6);
|
||||
p.setFontColor(ColorConstants.DARK_GRAY);
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
|
@ -378,9 +543,9 @@ public class Geoportal_PDF_Exporter {
|
|||
/**
|
||||
* Link to map box static map.
|
||||
*
|
||||
* @param bbox the bbox
|
||||
* @param widthXheight the width xheight
|
||||
* @param accessTokenValue the access token value
|
||||
* @param bbox the bbox
|
||||
* @param widthXheight the width xheight
|
||||
* @param serviceAP the service AP
|
||||
* @return the string
|
||||
*/
|
||||
private static String linkToMapBoxStaticMap(String bbox, String widthXheight, ServiceAccessPoint serviceAP) {
|
||||
|
@ -402,52 +567,79 @@ public class Geoportal_PDF_Exporter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the credits.
|
||||
* Removes the border.
|
||||
*
|
||||
* @param document the document
|
||||
* @param logoD4GNA the logo D 4 GNA
|
||||
* @param logoPoweredByD4Science the logo powered by D 4 science
|
||||
* @return the credits
|
||||
* @param table the table
|
||||
*/
|
||||
private Table getCredits(Document document, String logoD4GNA, String logoPoweredByD4Science, String wwwD4ScienceOrg,
|
||||
String gnaD4ScienceOrg) {
|
||||
private static void removeBorder(Table table) {
|
||||
for (IElement iElement : table.getChildren()) {
|
||||
((Cell) iElement).setBorder(Border.NO_BORDER);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the credits.
|
||||
*
|
||||
* @param document the document
|
||||
* @param credits the credits
|
||||
* @return the table
|
||||
*/
|
||||
private Table addCredits(Document document, Exporter_PDF_Credits credits) {
|
||||
|
||||
if (credits == null)
|
||||
return null;
|
||||
|
||||
Table tableCredits = toTableFixedLayout(document, 4, false);
|
||||
tableCredits.setBorder(Border.NO_BORDER);
|
||||
tableCredits.setTextAlignment(TextAlignment.LEFT);
|
||||
// tableCredits.setFixedLayout();
|
||||
tableCredits.setFixedPosition(document.getLeftMargin() + 30, 15,
|
||||
document.getPdfDocument().getDefaultPageSize().getWidth() - 75);
|
||||
tableCredits.setFixedPosition(document.getLeftMargin() + 10, 5,
|
||||
document.getPdfDocument().getDefaultPageSize().getWidth() - 65);
|
||||
|
||||
// Adding logo D4GNA
|
||||
Image imageLogo = toImageFromLink(logoD4GNA, 40);
|
||||
Cell cell1 = new Cell();
|
||||
cell1.setBorder(Border.NO_BORDER);
|
||||
cell1.add(imageLogo);
|
||||
tableCredits.addCell(cell1);
|
||||
// Adding LINK D4GNA
|
||||
Cell cell2 = new Cell();
|
||||
Link theLinkD4GNA = getLinkFromURL(gnaD4ScienceOrg, gnaD4ScienceOrg, 0);
|
||||
Table tableD4GNA = new Table(1);
|
||||
tableD4GNA.setHorizontalBorderSpacing(0);
|
||||
Image imageLogo = toImageFromLink(credits.getLogoD4GNA(), 40);
|
||||
Cell cell1D4GNA = new Cell();
|
||||
cell1D4GNA.add(imageLogo);
|
||||
// Adding link D4GNA
|
||||
Cell cell2D4GNA = new Cell();
|
||||
Link theLinkD4GNA = getLinkFromURL(credits.getLinkGnaD4ScienceOrg(), credits.getLinkGnaD4ScienceOrg(), 0);
|
||||
theLinkD4GNA.setFontSize(5);
|
||||
Paragraph p3 = new Paragraph().add(theLinkD4GNA);
|
||||
cell2.setBorder(Border.NO_BORDER);
|
||||
cell2.add(p3);
|
||||
tableCredits.addCell(cell2);
|
||||
Paragraph p1 = new Paragraph().add(theLinkD4GNA);
|
||||
cell2D4GNA.add(p1);
|
||||
tableD4GNA.addCell(cell1D4GNA);
|
||||
tableD4GNA.addCell(cell2D4GNA);
|
||||
tableCredits.addCell(tableD4GNA);
|
||||
|
||||
// Adding logo Powered By D4Science
|
||||
Image poweredByLink = toImageFromLink(logoPoweredByD4Science, 80);
|
||||
Cell cell3 = new Cell();
|
||||
cell3.setBorder(Border.NO_BORDER);
|
||||
cell3.add(poweredByLink);
|
||||
tableCredits.addCell(cell3);
|
||||
// Adding logo Powered by D4Science
|
||||
Table tableD4Science = new Table(1);
|
||||
Image imageLogoPD4S = toImageFromLink(credits.getLogoPoweredByD4Science(), 80);
|
||||
Cell cell1PD4S = new Cell();
|
||||
cell1PD4S.add(imageLogoPD4S);
|
||||
// Adding link D4GNA
|
||||
Cell cell2PD4S = new Cell();
|
||||
Link theLinkPD4S = getLinkFromURL(credits.getLinkD4ScienceOrg(), credits.getLinkD4ScienceOrg(), 0);
|
||||
theLinkPD4S.setFontSize(5);
|
||||
Paragraph p4 = new Paragraph().add(theLinkPD4S);
|
||||
cell2PD4S.add(p4);
|
||||
tableD4Science.addCell(cell1PD4S);
|
||||
tableD4Science.addCell(cell2PD4S);
|
||||
tableCredits.addCell(tableD4Science);
|
||||
|
||||
// Adding LINK d4science
|
||||
Cell cell4 = new Cell();
|
||||
Link theLinkD4Science = getLinkFromURL(wwwD4ScienceOrg, wwwD4ScienceOrg, 0);
|
||||
theLinkD4Science.setFontSize(5);
|
||||
Paragraph p4 = new Paragraph().add(theLinkD4Science);
|
||||
cell4.setBorder(Border.NO_BORDER);
|
||||
cell4.add(p4);
|
||||
tableCredits.addCell(cell4);
|
||||
// Adding logo CNR
|
||||
Image imageLogoCNR = toImageFromLink(credits.getLogoCNR(), 40);
|
||||
Cell cellLogoCNR = new Cell();
|
||||
cellLogoCNR.add(imageLogoCNR);
|
||||
tableCredits.addCell(cellLogoCNR);
|
||||
|
||||
// Adding logo ISTI
|
||||
Image imageLogoISTI = toImageFromLink(credits.getLogoISTI(), 40);
|
||||
Cell cellLogoISTI = new Cell();
|
||||
cellLogoISTI.add(imageLogoISTI);
|
||||
tableCredits.addCell(cellLogoISTI);
|
||||
|
||||
removeBorder(tableD4GNA);
|
||||
removeBorder(tableD4Science);
|
||||
removeBorder(tableCredits);
|
||||
|
||||
return tableCredits;
|
||||
}
|
||||
|
@ -463,7 +655,7 @@ public class Geoportal_PDF_Exporter {
|
|||
* @return the document
|
||||
*/
|
||||
private static Document appendSubDocumentToPDF(Document document, SectionView sectionView,
|
||||
List<SubDocumentView> subDocuments, String gisLink, ServiceAccessPoint sap) {
|
||||
List<SubDocumentView> subDocuments, String gisLink, ServiceAccessPoint sap, Exporter_PDF_Credits credits) {
|
||||
try {
|
||||
|
||||
boolean displayAsGallery = false;
|
||||
|
@ -521,7 +713,9 @@ public class Geoportal_PDF_Exporter {
|
|||
}
|
||||
|
||||
tableContainer.addCell(tableMeta);
|
||||
removeBorder(tableMeta);
|
||||
tableContainer.addCell(tableI);
|
||||
removeBorder(tableI);
|
||||
document.add(tableContainer);
|
||||
|
||||
}
|
||||
|
@ -602,15 +796,19 @@ public class Geoportal_PDF_Exporter {
|
|||
}
|
||||
}
|
||||
|
||||
// Table tableInfo = toTableFixedLayout(document, 1, true);
|
||||
// tableInfo.setBorder(Border.NO_BORDER);
|
||||
PdfFont ho = PdfFontFactory.createFont(StandardFonts.HELVETICA_OBLIQUE);
|
||||
|
||||
Paragraph paragraph1 = new Paragraph();
|
||||
String alert = "NB. The layer preview could be scratched";
|
||||
String alert = "(i) The layer preview could be scratched";
|
||||
|
||||
if (gisLink != null)
|
||||
alert += "See the gis layer at " + gisLink;
|
||||
alert += ". See the gis layer at " + gisLink;
|
||||
else {
|
||||
try {
|
||||
alert += ". See the gis layer at " + credits.getLinkGnaD4ScienceOrg();
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
}
|
||||
|
||||
paragraph1.add(alert);
|
||||
|
||||
|
@ -618,10 +816,11 @@ public class Geoportal_PDF_Exporter {
|
|||
paragraph1.setBorder(Border.NO_BORDER);
|
||||
paragraph1.setFont(ho);
|
||||
|
||||
// Row with layers
|
||||
tableContainerL.addCell(tableI);
|
||||
// Row with alert message
|
||||
tableContainerL.addCell(paragraph1);
|
||||
// Row with layers
|
||||
tableContainerL.addCell(tableI);
|
||||
|
||||
// Row with layer metadata
|
||||
tableContainerL.addCell(tableMeta);
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
LOGO_D4GNA = https://data.d4science.org/shub/E_dmhxT0ZReFpXQ1ZXZUp0M2pXUGhtTEZicHNyMGZUVTB4cTkyc2xqMXFSWmo2Q3o4dWl0dTBmY1p1VTdPN29KMQ==
|
||||
POWERED_BY_D4SCIENCE_LOGO = https://data.d4science.org/shub/E_cndCWGYxbFc3QVBKUnFvS1g1dy9ULzNqLzB4SXVKMldhRUQzTjV3MmJUV0pjVUFnWndHNnJ4bGNtTHZTR1hlaA==
|
||||
WWW_D4SCIENCE_ORG = https://www.d4science.org
|
||||
GNA_D4SCIENCE_ORG = https://gna.d4science.org
|
||||
GNA_D4SCIENCE_ORG = https://gna.d4science.org
|
||||
LOGO_ISTI = https://data.d4science.org/shub/E_SnJDdURDbzFQRitXK2s0WEhSYjRVT0JTWUVNSm1McVpieEgzT0ZUR3ZBU1lyOEhjNVRsbHI2VUNhRVpCWm11Rg==
|
||||
LOGO_CNR = https://data.d4science.org/shub/E_N3hLRUtyaUZQQ1RzcWVzTVFMM3lsNTkzTWwyd1hxR1FOd29DSlhDVyt4UXlRUXhFTnVTdzFPbmRzQTN2WHhzcQ==
|
|
@ -7,11 +7,16 @@ import lombok.NoArgsConstructor;
|
|||
@NoArgsConstructor
|
||||
public class ExporterProjectSource {
|
||||
|
||||
//Required fields
|
||||
String profileID;
|
||||
String projectID;
|
||||
String profileTitle;
|
||||
String scope;
|
||||
//Optional fields
|
||||
String profileTitle;
|
||||
String accountname; //if null the exporter will use PUBLIC ACCESS
|
||||
String gisLink;
|
||||
|
||||
boolean addTimpestampCreatedAt = true;
|
||||
boolean addPageNumbers = true;
|
||||
|
||||
}
|
||||
|
|
|
@ -38,18 +38,20 @@ public class Geoportal_Export_To_PDF_Tests {
|
|||
|
||||
//private static String PROFILE_ID = "concessioni-estere";
|
||||
private static String PROFILE_ID = "profiledConcessioni";
|
||||
private static String PROJECT_ID = "64a2c5c6a827c620191599ff";
|
||||
private static String PROJECT_ID = "64537208d7fb4a4633022039";
|
||||
|
||||
// DEV
|
||||
// 654e07a75bdd5478cca320c0
|
||||
// 655489965bdd5478cca320ea
|
||||
|
||||
//PROD Concessioni
|
||||
// 6388e4f8a1e60e66b7b584ac Ficocle-Cervia Vecchia
|
||||
// 6388d9b3a1e60e66b7b5843a
|
||||
// 646353c5d7fb4a4633022803 Villa Romana del Capo di Sorrento
|
||||
// 63f8c481e9d6ac16f394f1e6
|
||||
//638888fba1e60e66b7b581dd
|
||||
|
||||
// PROD
|
||||
// PRE
|
||||
// 63d011c4dcac4551b9a6b930
|
||||
// //6442653ac6a0422d9e9042e0
|
||||
// //6399de3ca0a4545420373251
|
||||
|
@ -59,8 +61,8 @@ public class Geoportal_Export_To_PDF_Tests {
|
|||
// PROD concessione-estere
|
||||
// 64a2c5c6a827c620191599ff
|
||||
|
||||
|
||||
// IMPORTANT!!!! #NB SET USERNAME = null to test PUBLIC ACCESS
|
||||
|
||||
private static String USERNAME = null;
|
||||
|
||||
/**
|
||||
|
@ -125,6 +127,8 @@ public class Geoportal_Export_To_PDF_Tests {
|
|||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
Geoportal_PDF_Exporter pdfExporter = new Geoportal_PDF_Exporter();
|
||||
ExporterProjectSource exporterSource = new ExporterProjectSource();
|
||||
//#NB SET USERNAME = null to test PUBLIC ACCESS
|
||||
USERNAME = "francesco.mangiacrapa";
|
||||
exporterSource.setAccountname(USERNAME);
|
||||
exporterSource.setProfileID(PROFILE_ID);
|
||||
exporterSource.setProjectID(PROJECT_ID);
|
||||
|
|
Loading…
Reference in New Issue