Mattia Gosetto 3 anni fa
parent
commit
2ada8c0598
  1. 94
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/AsseverazioniUtil.java
  2. 1
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/verify_fine-lavori.jsp
  3. 71
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/util/MailManagerUtil.java
  4. 4
      liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/service.properties
  5. 1
      liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/constants/ReportConstants.java
  6. 18
      liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/dto/ReportDto.java
  7. 14
      liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/dto/ReportResultDto.java
  8. 83
      liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/util/PdfUtil.java
  9. 32
      liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/util/VelocityUtil.java

94
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/AsseverazioniUtil.java

@ -1,6 +1,7 @@
package it.tref.liferay.portos.bo.util;
import it.tref.liferay.portos.bo.model.Asseverazione;
import it.tref.liferay.portos.bo.model.Delega;
import it.tref.liferay.portos.bo.model.DettPratica;
import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.Soggetto;
@ -114,7 +115,7 @@ public class AsseverazioniUtil {
public static final String ASSEVERAZIONI_INTEGRAZIONE = "asseverazioni_integrazione";
@SuppressWarnings("serial")
private static final Map<String, List<String>> required = new HashMap<String, List<String>>(15) {
private static final Map<String, List<String>> REQUIRED = new HashMap<String, List<String>>(15) {
{
put(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A02,
Arrays.asList(TipoSoggettoUtil.PROGETTISTA, TipoSoggettoUtil.DIRETTORE_LAVORI));
@ -152,7 +153,7 @@ public class AsseverazioniUtil {
};
@SuppressWarnings("serial")
private static final Map<String, List<String>> recommended = new HashMap<String, List<String>>(3) {
private static final Map<String, List<String>> RECOMMENDED = new HashMap<String, List<String>>(3) {
{
put(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A04, Arrays.asList(TipoSoggettoUtil.DITTA));
put(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A10, Arrays.asList(TipoSoggettoUtil.DITTA));
@ -160,7 +161,7 @@ public class AsseverazioniUtil {
}
};
private static final List<String> oneIsEnough = Arrays.asList(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A11,
private static final List<String> ONE_IS_ENOUGH = Arrays.asList(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A11,
DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A12, DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A17,
DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_ALTRI, DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_DELEGA);
@ -226,8 +227,8 @@ public class AsseverazioniUtil {
} else if (TipoSoggettoUtil.COMMITTENTE.equalsIgnoreCase(tipoSoggetto)) {
return !ValidazionePraticaUtil.isA98Required(dettPratica);
// ADT: RIMOZIONE IF NON NECESSARI
} else if (required.containsKey(ASSEVERAZIONI_DOMANDA)) {
return required.get(ASSEVERAZIONI_DOMANDA).contains(tipoSoggetto);
} else if (REQUIRED.containsKey(ASSEVERAZIONI_DOMANDA)) {
return REQUIRED.get(ASSEVERAZIONI_DOMANDA).contains(tipoSoggetto);
}
}
return false;
@ -241,32 +242,32 @@ public class AsseverazioniUtil {
|| TipoIntegrazioneUtil.VARIANTE.equalsIgnoreCase(dettPratica.getTipoIntegrazione())) {
return false;
}
if (recommended.containsKey(ASSEVERAZIONI_DOMANDA)) {
return recommended.get(ASSEVERAZIONI_DOMANDA).contains(tipoSoggetto);
if (RECOMMENDED.containsKey(ASSEVERAZIONI_DOMANDA)) {
return RECOMMENDED.get(ASSEVERAZIONI_DOMANDA).contains(tipoSoggetto);
}
return false;
}
public static boolean isAsseverazioneRequiredByCodiceDoc(String codiceDoc, String tipoSoggetto) {
if (required.containsKey(codiceDoc)) {
return required.get(codiceDoc).contains(tipoSoggetto);
if (REQUIRED.containsKey(codiceDoc)) {
return REQUIRED.get(codiceDoc).contains(tipoSoggetto);
}
return false;
}
public static boolean isAsseverazioneRecommendedByCodiceDoc(String codiceDoc, String tipoSoggetto) {
if (recommended.containsKey(codiceDoc)) {
return recommended.get(codiceDoc).contains(tipoSoggetto);
if (RECOMMENDED.containsKey(codiceDoc)) {
return RECOMMENDED.get(codiceDoc).contains(tipoSoggetto);
}
return false;
}
public static List<String> getRequiredSubjectsByCodiceDoc(String codiceDoc) {
if (required.containsKey(codiceDoc)) {
return required.get(codiceDoc);
if (REQUIRED.containsKey(codiceDoc)) {
return REQUIRED.get(codiceDoc);
}
return Collections.emptyList();
}
@ -285,42 +286,43 @@ public class AsseverazioniUtil {
if (asseverazioniEseguite.size() == 0) {
return false;
}
List<String> nuoviSoggetti = new ArrayList<String>(
SoggettoLocalServiceUtil.getCfValidTmpByDettPratica(dettPraticaId));
List<String> nuoviDelegati = new ArrayList<String>(
DelegaLocalServiceUtil.findCfByDettPratica_Tipologia_InEsito(dettPraticaId, new String[] {
TipoSoggettoUtil.COMMITTENTE, TipoSoggettoUtil.DIRETTORE_LAVORI, TipoSoggettoUtil.GEOLOGO,
TipoSoggettoUtil.DITTA, TipoSoggettoUtil.PROGETTISTA },
new String[] { AsseverazioniUtil.STATO_ESEGUITA }));
Set<String> cfNuoviSoggetti = new HashSet<>();
for (Soggetto soggetto : SoggettoLocalServiceUtil.getValidTmpByDettPratica(dettPraticaId)) {
if (!TipoSoggettoUtil.COLLAUDATORE.equals(soggetto.getTipologiaSoggetto())
|| soggetto.getCodiceFiscale().equalsIgnoreCase(
dettPratica.getCodiceFiscalePrincipaleCollaudatore())) {
cfNuoviSoggetti.add(soggetto.getCodiceFiscale().toLowerCase());
}
}
Set<String> cfNuoviDelegati = new HashSet<>();
for (Delega delega : DelegaLocalServiceUtil.findByDettPratica_Tipologia_InEsito(dettPraticaId,
new String[] { TipoSoggettoUtil.COMMITTENTE, TipoSoggettoUtil.DIRETTORE_LAVORI,
TipoSoggettoUtil.GEOLOGO, TipoSoggettoUtil.DITTA, TipoSoggettoUtil.PROGETTISTA },
new String[] { AsseverazioniUtil.STATO_ESEGUITA })) {
cfNuoviDelegati.add(delega.getCodiceFiscale().toLowerCase());
}
Set<String> cfAsseverazioni = new HashSet<>();
for (Asseverazione asseverazione : asseverazioniEseguite) {
cfAsseverazioni.add(asseverazione.getCodiceFiscale());
cfAsseverazioni.add(asseverazione.getCodiceFiscale().toLowerCase());
}
if (TipoIntegrazioneUtil.RICHIESTA_INTEGRAZIONE.equalsIgnoreCase(dettPratica.getTipoIntegrazione())) {
boolean titolareDigitale = false;
User titolaredigitaleUser = UserLocalServiceUtil.getUser(intPratica.getUserId());
if (cfAsseverazioni.contains(titolaredigitaleUser.getScreenName())) {
titolareDigitale = true;
}
if (cfAsseverazioni.containsAll(nuoviSoggetti)) {
soggetti = true;
} else {
boolean titolareDigitale = cfAsseverazioni.contains(titolaredigitaleUser.getScreenName().toLowerCase());
if (ValidazionePraticaUtil.isA98Required(dettPratica)) {
List<String> committentiToRemove = SoggettoLocalServiceUtil
.getCfValidTmpByDettPratica_TipologiaSoggetto(dettPraticaId,
TipoSoggettoUtil.COMMITTENTE);
nuoviSoggetti.removeAll(committentiToRemove);
if (cfAsseverazioni.containsAll(nuoviSoggetti)) {
soggetti = true;
for (Soggetto soggetto : SoggettoLocalServiceUtil.getValidTmpByDettPratica_TipologiaSoggetto(
dettPraticaId, TipoSoggettoUtil.COMMITTENTE)) {
cfNuoviSoggetti.remove(soggetto.getCodiceFiscale().toLowerCase());
}
}
if (cfAsseverazioni.containsAll(cfNuoviSoggetti)) {
soggetti = true;
}
nuoviDelegati.removeAll(nuoviSoggetti);
if (cfAsseverazioni.containsAll(nuoviDelegati)) {
cfNuoviDelegati.removeAll(cfNuoviSoggetti);
if (cfAsseverazioni.containsAll(cfNuoviDelegati)) {
delegati = true;
}
if (!soggetti && delegati) {
if (cfAsseverazioni.containsAll(nuoviSoggetti)) {
if (cfAsseverazioni.containsAll(cfNuoviSoggetti)) {
soggetti = true;
}
}
@ -338,29 +340,29 @@ public class AsseverazioniUtil {
if (cfAsseverazioni.containsAll(cfSoggettiPrincipali)) {
soggettiPrincipali = true;
}
nuoviSoggetti.removeAll(cfSoggettiPrincipali);
if (cfAsseverazioni.containsAll(nuoviSoggetti)) {
cfNuoviSoggetti.removeAll(cfSoggettiPrincipali);
if (cfAsseverazioni.containsAll(cfNuoviSoggetti)) {
soggetti = true;
} else {
if (ValidazionePraticaUtil.isA98Required(dettPratica)) {
List<String> committentiToRemove = SoggettoLocalServiceUtil
.getCfValidTmpByDettPratica_TipologiaSoggetto(dettPraticaId,
TipoSoggettoUtil.COMMITTENTE);
nuoviSoggetti.removeAll(committentiToRemove);
if (cfAsseverazioni.containsAll(nuoviSoggetti)) {
cfNuoviSoggetti.removeAll(committentiToRemove);
if (cfAsseverazioni.containsAll(cfNuoviSoggetti)) {
soggetti = true;
}
}
}
nuoviDelegati.removeAll(cfSoggettiPrincipali);
nuoviDelegati.removeAll(nuoviSoggetti);
if (cfAsseverazioni.containsAll(nuoviDelegati)) {
cfNuoviDelegati.removeAll(cfSoggettiPrincipali);
cfNuoviDelegati.removeAll(cfNuoviSoggetti);
if (cfAsseverazioni.containsAll(cfNuoviDelegati)) {
delegati = true;
}
return soggettiPrincipali && soggetti && delegati;
}
} else {
for (String tipoSoggetto : required.get(ASSEVERAZIONI_DOMANDA)) {
for (String tipoSoggetto : REQUIRED.get(ASSEVERAZIONI_DOMANDA)) {
// Se committente e c'è delega => true
if (TipoSoggettoUtil.COMMITTENTE.equalsIgnoreCase(tipoSoggetto)
&& ValidazionePraticaUtil.isA98Required(dettPratica)) {
@ -388,7 +390,7 @@ public class AsseverazioniUtil {
public static boolean isEnoughOne(String codiceDoc) {
return oneIsEnough.contains(codiceDoc);
return ONE_IS_ENOUGH.contains(codiceDoc);
}
public static boolean signaturesContains(long intPraticaId, String tipoSoggetto, List<String> signatures)

1
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/verify_fine-lavori.jsp

@ -66,7 +66,6 @@
/>
</c:if>
<c:if test="<%= !isEsente %>">
<% System.out.println("################################# fineLavoriId = " + fineLavoriId); %>
<liferay-ui:icon
linkCssClass='<%=ValidazionePraticaUtil.pagamentoFineLavoriIsEnable(fineLavoriId)?"btn btn-primary":"btn btn-primary disabled" %>'
iconCssClass="fa fa-cogs"

71
liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/util/MailManagerUtil.java

@ -1,9 +1,16 @@
package it.tref.liferay.portos.mailmanager.util;
import it.tref.liferay.portos.mailmanager.model.Email;
import it.tref.liferay.portos.mailmanager.model.EmailTemplate;
import it.tref.liferay.portos.mailmanager.service.EmailLocalServiceUtil;
import it.tref.liferay.portos.mailmanager.service.EmailTemplateLocalServiceUtil;
import it.tref.liferay.portos.mailmanager.shared.util.MailManagerConstants;
import it.tref.liferay.portos.mailmanager.shared.util.MailUtil;
import java.util.List;
import com.liferay.mail.model.FileAttachment;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.mail.MailMessage;
import com.liferay.portal.kernel.mail.SMTPAccount;
import com.liferay.portal.kernel.util.StringPool;
@ -13,50 +20,43 @@ import com.liferay.portal.model.Company;
import com.liferay.portal.service.CompanyLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import it.tref.liferay.portos.mailmanager.model.Email;
import it.tref.liferay.portos.mailmanager.model.EmailTemplate;
import it.tref.liferay.portos.mailmanager.service.EmailLocalServiceUtil;
import it.tref.liferay.portos.mailmanager.service.EmailTemplateLocalServiceUtil;
import it.tref.liferay.portos.mailmanager.shared.util.MailManagerConstants;
import it.tref.liferay.portos.mailmanager.shared.util.MailUtil;
import java.util.List;
public class MailManagerUtil {
public static Email addEmailByTemplate(String className, long classPK, long emailTemplateId,
JSONObject templateParamJSON, List<FileAttachment> fileAttachments, ServiceContext serviceContext)
throws Exception {
return addEmailByTemplate(className, classPK, emailTemplateId, templateParamJSON, fileAttachments,
false, serviceContext);
return addEmailByTemplate(className, classPK, emailTemplateId, templateParamJSON, fileAttachments, false,
serviceContext);
}
public static Email addEmailByTemplate(String className, long classPK, long emailTemplateId,
JSONObject templateParamJSON, ServiceContext serviceContext) throws Exception {
return addEmailByTemplate(className, classPK, emailTemplateId, templateParamJSON, null, false,
serviceContext);
return addEmailByTemplate(className, classPK, emailTemplateId, templateParamJSON, null, false, serviceContext);
}
public static Email addEmailByTemplate(String className, long classPK, long emailTemplateId,
JSONObject templateParamJSON, List<FileAttachment> fileAttachments, boolean sendSync,
ServiceContext serviceContext) throws Exception {
EmailTemplate emailTemplate = EmailTemplateLocalServiceUtil.getEmailTemplate(emailTemplateId);
return addEmailByTemplate(className, classPK, emailTemplate, templateParamJSON, fileAttachments,
sendSync, serviceContext);
return addEmailByTemplate(className, classPK, emailTemplate, templateParamJSON, fileAttachments, sendSync,
serviceContext);
}
public static Email addEmailByTemplate(String className, long classPK, String emailTemplateName,
JSONObject templateParamJSON, List<FileAttachment> fileAttachments, ServiceContext serviceContext)
throws Exception {
return addEmailByTemplate(className, classPK, emailTemplateName, templateParamJSON, fileAttachments,
false, serviceContext);
return addEmailByTemplate(className, classPK, emailTemplateName, templateParamJSON, fileAttachments, false,
serviceContext);
}
public static Email addEmailByTemplate(String className, long classPK, String emailTemplateName,
JSONObject templateParamJSON, ServiceContext serviceContext) throws Exception {
return addEmailByTemplate(className, classPK, emailTemplateName, templateParamJSON, null, false,
serviceContext);
return addEmailByTemplate(className, classPK, emailTemplateName, templateParamJSON, null, false, serviceContext);
}
public static Email addEmailByTemplate(String className, long classPK, String emailTemplateName,
@ -65,15 +65,13 @@ public class MailManagerUtil {
EmailTemplate emailTemplate = EmailTemplateLocalServiceUtil.fetchByC_GroupId_Name(
serviceContext.getCompanyId(), serviceContext.getScopeGroupId(), emailTemplateName);
if (Validator.isNull(emailTemplate)) {
Company company = CompanyLocalServiceUtil.getCompany(serviceContext.getCompanyId());
emailTemplate = EmailTemplateLocalServiceUtil.findByC_GroupId_Name(serviceContext.getCompanyId(),
company.getGroupId(), emailTemplateName);
}
return addEmailByTemplate(className, classPK, emailTemplate, templateParamJSON, fileAttachments,
sendSync, serviceContext);
return addEmailByTemplate(className, classPK, emailTemplate, templateParamJSON, fileAttachments, sendSync,
serviceContext);
}
public static Email addEmailByTemplate(String className, long classPK, EmailTemplate emailTemplate,
@ -84,7 +82,6 @@ public class MailManagerUtil {
templateParamJSON.getJSONObject(MailManagerConstants.TEMPLATE_PARAMETER_VARIABLES_KEY));
String body = VelocityUtil.evaluate(emailTemplate.getBody(),
templateParamJSON.getJSONObject(MailManagerConstants.TEMPLATE_PARAMETER_VARIABLES_KEY));
String to = templateParamJSON.getString(MailManagerConstants.TEMPLATE_PARAMETER_TO_KEY);
if (Validator.isNull(to)) {
to = emailTemplate.getTo();
@ -97,16 +94,15 @@ public class MailManagerUtil {
if (Validator.isNull(ccn)) {
ccn = emailTemplate.getCcn();
}
return EmailLocalServiceUtil.addEmail(className, classPK, emailTemplate.getFrom(),
StringUtil.split(to, StringPool.COMMA), StringUtil.split(cc, StringPool.COMMA),
StringUtil.split(ccn, StringPool.COMMA), subject, body, true, fileAttachments, sendSync,
emailTemplate.getTemplateName(), serviceContext);
}
public static Email addEmail(String className, long classPK, MailMessage mailMessage,
ServiceContext serviceContext) throws Exception {
public static Email addEmail(String className, long classPK, MailMessage mailMessage, ServiceContext serviceContext)
throws Exception {
return addEmail(className, classPK, mailMessage, false, serviceContext);
}
@ -118,37 +114,28 @@ public class MailManagerUtil {
String[] cc = MailUtil.fromInternetAddresses(mailMessage.getCC());
String[] bcc = MailUtil.fromInternetAddresses(mailMessage.getBCC());
String[] bulkAddresses = MailUtil.fromInternetAddresses(mailMessage.getBulkAddresses());
String subject = mailMessage.getSubject();
String body = mailMessage.getBody();
boolean htmlFormat = mailMessage.getHTMLFormat();
String[] replyTo = MailUtil.fromInternetAddresses(mailMessage.getReplyTo());
String messageId = mailMessage.getMessageId();
String inReplyTo = mailMessage.getInReplyTo();
List<FileAttachment> fileAttachments = mailMessage.getFileAttachments();
SMTPAccount smtpAccount = mailMessage.getSMTPAccount();
String smtpHost = null;
int smtpPort = 0;
boolean smtpSecure = false;
String smtpUsername = null;
String smtpPassword = null;
if (smtpAccount != null) {
smtpHost = smtpAccount.getHost();
smtpPort = smtpAccount.getPort();
smtpSecure = smtpAccount.isSecure();
smtpUsername = smtpAccount.getUser();
smtpPassword = smtpAccount.getPassword();
}
return EmailLocalServiceUtil.addEmail(className, classPK, from, to, cc, bcc, bulkAddresses, subject,
body, htmlFormat, replyTo, messageId, inReplyTo, smtpHost, smtpPort, smtpSecure,
smtpUsername, smtpPassword, fileAttachments, sendSync, null, serviceContext);
return EmailLocalServiceUtil.addEmail(className, classPK, from, to, cc, bcc, bulkAddresses, subject, body,
htmlFormat, replyTo, messageId, inReplyTo, smtpHost, smtpPort, smtpSecure, smtpUsername, smtpPassword,
fileAttachments, sendSync, null, serviceContext);
}
}

4
liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/service.properties

@ -13,8 +13,8 @@
##
build.namespace=portos_rep
build.number=32
build.date=1631888946526
build.number=33
build.date=1634829831564
build.auto.upgrade=true
##

1
liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/constants/ReportConstants.java

@ -1,6 +1,7 @@
package it.tref.liferay.portos.report.shared.constants;
public class ReportConstants {
public enum ReportProcessMode {
ASYNC, SYNC
}

18
liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/dto/ReportDto.java

@ -1,11 +1,11 @@
package it.tref.liferay.portos.report.shared.dto;
import com.liferay.portal.kernel.util.Validator;
import it.tref.liferay.portos.report.shared.constants.ReportConstants.ReportType;
import java.util.Map;
import com.liferay.portal.kernel.util.Validator;
public class ReportDto {
private String type;
@ -27,8 +27,8 @@ public class ReportDto {
}
public ReportDto(String type, long folderId, long[] fileEntryIds, String fileName, String[] css, String portalURL,
boolean showNumberOfPage, Object dataSource, Map<String, Object> parameters, String header, int headerHeight,
String footer, int footerHeight) {
boolean showNumberOfPage, Object dataSource, Map<String, Object> parameters, String header,
int headerHeight, String footer, int footerHeight) {
this();
this.type = type;
@ -116,15 +116,6 @@ public class ReportDto {
this.showNumberOfPage = showNumberOfPage;
}
/*
* public Object getDataSource() {
*
* return dataSource; }
*
* public void setDataSource(Object dataSource) {
*
* this.dataSource = dataSource; }
*/
public Map<String, Object> getParameters() {
return parameters;
@ -180,7 +171,6 @@ public class ReportDto {
if (Validator.isNotNull(getType())) {
return ReportType.valueOf(getType());
}
return null;
}
}

14
liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/dto/ReportResultDto.java

@ -1,12 +1,11 @@
package it.tref.liferay.portos.report.shared.dto;
import com.liferay.portal.kernel.util.Validator;
import it.tref.liferay.portos.report.shared.constants.ReportConstants.ReportResult;
import java.io.Serializable;
import com.liferay.portal.kernel.util.Validator;
public class ReportResultDto implements Serializable {
private static final long serialVersionUID = -5807088639699043383L;
@ -16,13 +15,9 @@ public class ReportResultDto implements Serializable {
private String result;
private String resultMessage;
public ReportResultDto() {
}
public ReportResultDto() {}
public ReportResultDto(
long reportTaskId, long[] fileEntryIds, String result,
String resultMessage) {
public ReportResultDto(long reportTaskId, long[] fileEntryIds, String result, String resultMessage) {
this();
this.reportTaskId = reportTaskId;
@ -76,7 +71,6 @@ public class ReportResultDto implements Serializable {
if (Validator.isNotNull(getResult())) {
return ReportResult.valueOf(getResult());
}
return null;
}
}

83
liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/util/PdfUtil.java

@ -1,6 +1,13 @@
package it.tref.liferay.portos.report.shared.util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
@ -21,14 +28,6 @@ import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.Validator;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
public class PdfUtil {
private final static Log _log = LogFactoryUtil.getLog(PdfUtil.class);
@ -36,17 +35,13 @@ public class PdfUtil {
public static byte[] merge(InputStream pdf1, InputStream pdf2) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
List<InputStream> pdfs = new ArrayList<InputStream>();
pdfs.add(pdf1);
pdfs.add(pdf2);
Document document = new Document();
try {
List<PdfReader> readers = new ArrayList<PdfReader>();
Iterator<InputStream> iteratorPDFs = pdfs.iterator();
// Create Readers for the pdfs.
while (iteratorPDFs.hasNext()) {
InputStream pdf = iteratorPDFs.next();
@ -55,109 +50,74 @@ public class PdfUtil {
}
// Create a writer for the outputstream
PdfWriter writer = PdfWriter.getInstance(document, outputStream);
document.open();
PdfContentByte cb = writer.getDirectContent();
PdfImportedPage page;
int pageOfCurrentReaderPDF = 0;
Iterator<PdfReader> iteratorPDFReader = readers.iterator();
while (iteratorPDFReader.hasNext()) {
PdfReader pdfReader = iteratorPDFReader.next();
// Create a new page in the target for each source page.
while (pageOfCurrentReaderPDF < pdfReader.getNumberOfPages()) {
document.newPage();
pageOfCurrentReaderPDF++;
page =
writer.getImportedPage(
pdfReader, pageOfCurrentReaderPDF);
page = writer.getImportedPage(pdfReader, pageOfCurrentReaderPDF);
cb.addTemplate(page, 0, 0);
}
pageOfCurrentReaderPDF = 0;
}
iteratorPDFReader = readers.iterator();
// Loop through the PDF files and add to the output.
while (iteratorPDFReader.hasNext()) {
}
while (iteratorPDFReader.hasNext()) {}
outputStream.flush();
document.close();
outputStream.close();
return outputStream.toByteArray();
}
catch (Exception e) {
} catch (Exception e) {
_log.error("Errore", e);
return null;
}
finally {
} finally {
if (document.isOpen()) {
document.close();
}
}
}
public static byte[] mergePdf(List<byte[]> reports, boolean showNumberOfPage)
throws Exception {
public static byte[] mergePdf(List<byte[]> reports, boolean showNumberOfPage) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document document = new Document();
PdfCopy pdfCopy = new PdfCopy(document, baos);
document.open();
List<HashMap<String, Object>> outlines =
new ArrayList<HashMap<String, Object>>();
List<HashMap<String, Object>> outlines = new ArrayList<HashMap<String, Object>>();
int totalPage = 0;
for (byte[] report : reports) {
PdfReader pdfReader = new PdfReader(report);
totalPage += pdfReader.getNumberOfPages();
pdfReader.close();
}
int curentPageNumber = 0;
for (byte[] report : reports) {
PdfReader pdfReader = new PdfReader(report);
pdfCopy.setOutlines(outlines);
int n = pdfReader.getNumberOfPages();
for (int page = 0; page < n;) {
curentPageNumber++;
PdfImportedPage pdfImportedPage =
pdfCopy.getImportedPage(pdfReader, ++page);
PdfImportedPage pdfImportedPage = pdfCopy.getImportedPage(pdfReader, ++page);
PageStamp stamp = pdfCopy.createPageStamp(pdfImportedPage);
if (showNumberOfPage) {
// add page numbers
ColumnText.showTextAligned(
stamp.getUnderContent(),
Element.ALIGN_CENTER,
new Phrase(String.format(
"%d / %d", curentPageNumber, totalPage)),
ColumnText.showTextAligned(stamp.getUnderContent(), Element.ALIGN_CENTER,
new Phrase(String.format("%d / %d", curentPageNumber, totalPage)),
pdfImportedPage.getHeight() / 2, 20, 0);
}
stamp.alterContents();
pdfCopy.addPage(pdfImportedPage);
}
pdfCopy.freeReader(pdfReader);
pdfReader.close();
}
document.close();
return baos.toByteArray();
}
@ -166,13 +126,11 @@ public class PdfUtil {
protected ElementList header;
protected ElementList footer;
public HeaderFooter(String headerHtml, String footerHtml)
throws IOException {
public HeaderFooter(String headerHtml, String footerHtml) throws IOException {
if (Validator.isNotNull(headerHtml)) {
header = XMLWorkerHelper.parseToElementList(headerHtml, null);
}
if (Validator.isNotNull(footerHtml)) {
footer = XMLWorkerHelper.parseToElementList(footerHtml, null);
}
@ -183,7 +141,6 @@ public class PdfUtil {
try {
ColumnText ct = new ColumnText(writer.getDirectContent());
if (Validator.isNotNull(header)) {
ct.setSimpleColumn(new Rectangle(36, 832, 559, 810));
for (Element e : header) {
@ -191,7 +148,6 @@ public class PdfUtil {
}
ct.go();
}
if (Validator.isNotNull(footer)) {
ct.setSimpleColumn(new Rectangle(36, 10, 559, 32));
for (Element e : footer) {
@ -199,8 +155,7 @@ public class PdfUtil {
}
ct.go();
}
}
catch (DocumentException de) {
} catch (DocumentException de) {
throw new ExceptionConverter(de);
}
}

32
liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/util/VelocityUtil.java

@ -1,28 +1,22 @@
/**
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
*
* The contents of this file are subject to the terms of the Liferay Enterprise Subscription License
* ("License"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License by contacting Liferay, Inc. See the License for the specific language
* governing permissions and limitations under the License, including but not limited to
* distribution rights of the Software.
*
*
*
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. The contents of this file are subject to the terms of the
* Liferay Enterprise Subscription License ("License"). You may not use this file except in compliance with the License.
* You can obtain a copy of the License by contacting Liferay, Inc. See the License for the specific language governing
* permissions and limitations under the License, including but not limited to distribution rights of the Software.
*/
package it.tref.liferay.portos.report.shared.util;
import com.liferay.portal.kernel.io.unsync.UnsyncStringWriter;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.Validator;
import java.util.Map;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.RuntimeConstants;
import com.liferay.portal.kernel.io.unsync.UnsyncStringWriter;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.Validator;
/**
* @author Brian Wing Shun Chan
*/
@ -36,33 +30,23 @@ public class VelocityUtil {
public static String evaluate(String input, Map<String, Object> variables) throws Exception {
VelocityEngine velocityEngine = new VelocityEngine();
velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
com.liferay.portal.kernel.util.PropsUtil.get(PropsKeys.VELOCITY_ENGINE_LOGGER));
velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.category",
com.liferay.portal.kernel.util.PropsUtil.get(PropsKeys.VELOCITY_ENGINE_LOGGER_CATEGORY));
velocityEngine.init();
VelocityContext velocityContext = new VelocityContext();
if (variables != null) {
for (Map.Entry<String, Object> entry : variables.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (Validator.isNotNull(key)) {
velocityContext.put(key, value);
}
}
}
UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter();
velocityEngine.evaluate(velocityContext, unsyncStringWriter, VelocityUtil.class.getName(), input);
return unsyncStringWriter.toString();
}
}

Caricamento…
Annulla
Salva