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; package it.tref.liferay.portos.bo.util;
import it.tref.liferay.portos.bo.model.Asseverazione; 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.DettPratica;
import it.tref.liferay.portos.bo.model.IntPratica; import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.Soggetto; import it.tref.liferay.portos.bo.model.Soggetto;
@ -114,7 +115,7 @@ public class AsseverazioniUtil {
public static final String ASSEVERAZIONI_INTEGRAZIONE = "asseverazioni_integrazione"; public static final String ASSEVERAZIONI_INTEGRAZIONE = "asseverazioni_integrazione";
@SuppressWarnings("serial") @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, put(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A02,
Arrays.asList(TipoSoggettoUtil.PROGETTISTA, TipoSoggettoUtil.DIRETTORE_LAVORI)); Arrays.asList(TipoSoggettoUtil.PROGETTISTA, TipoSoggettoUtil.DIRETTORE_LAVORI));
@ -152,7 +153,7 @@ public class AsseverazioniUtil {
}; };
@SuppressWarnings("serial") @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_A04, Arrays.asList(TipoSoggettoUtil.DITTA));
put(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A10, 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_A12, DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A17,
DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_ALTRI, DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_DELEGA); DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_ALTRI, DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_DELEGA);
@ -226,8 +227,8 @@ public class AsseverazioniUtil {
} else if (TipoSoggettoUtil.COMMITTENTE.equalsIgnoreCase(tipoSoggetto)) { } else if (TipoSoggettoUtil.COMMITTENTE.equalsIgnoreCase(tipoSoggetto)) {
return !ValidazionePraticaUtil.isA98Required(dettPratica); return !ValidazionePraticaUtil.isA98Required(dettPratica);
// ADT: RIMOZIONE IF NON NECESSARI // ADT: RIMOZIONE IF NON NECESSARI
} else if (required.containsKey(ASSEVERAZIONI_DOMANDA)) { } else if (REQUIRED.containsKey(ASSEVERAZIONI_DOMANDA)) {
return required.get(ASSEVERAZIONI_DOMANDA).contains(tipoSoggetto); return REQUIRED.get(ASSEVERAZIONI_DOMANDA).contains(tipoSoggetto);
} }
} }
return false; return false;
@ -241,32 +242,32 @@ public class AsseverazioniUtil {
|| TipoIntegrazioneUtil.VARIANTE.equalsIgnoreCase(dettPratica.getTipoIntegrazione())) { || TipoIntegrazioneUtil.VARIANTE.equalsIgnoreCase(dettPratica.getTipoIntegrazione())) {
return false; return false;
} }
if (recommended.containsKey(ASSEVERAZIONI_DOMANDA)) { if (RECOMMENDED.containsKey(ASSEVERAZIONI_DOMANDA)) {
return recommended.get(ASSEVERAZIONI_DOMANDA).contains(tipoSoggetto); return RECOMMENDED.get(ASSEVERAZIONI_DOMANDA).contains(tipoSoggetto);
} }
return false; return false;
} }
public static boolean isAsseverazioneRequiredByCodiceDoc(String codiceDoc, String tipoSoggetto) { public static boolean isAsseverazioneRequiredByCodiceDoc(String codiceDoc, String tipoSoggetto) {
if (required.containsKey(codiceDoc)) { if (REQUIRED.containsKey(codiceDoc)) {
return required.get(codiceDoc).contains(tipoSoggetto); return REQUIRED.get(codiceDoc).contains(tipoSoggetto);
} }
return false; return false;
} }
public static boolean isAsseverazioneRecommendedByCodiceDoc(String codiceDoc, String tipoSoggetto) { public static boolean isAsseverazioneRecommendedByCodiceDoc(String codiceDoc, String tipoSoggetto) {
if (recommended.containsKey(codiceDoc)) { if (RECOMMENDED.containsKey(codiceDoc)) {
return recommended.get(codiceDoc).contains(tipoSoggetto); return RECOMMENDED.get(codiceDoc).contains(tipoSoggetto);
} }
return false; return false;
} }
public static List<String> getRequiredSubjectsByCodiceDoc(String codiceDoc) { public static List<String> getRequiredSubjectsByCodiceDoc(String codiceDoc) {
if (required.containsKey(codiceDoc)) { if (REQUIRED.containsKey(codiceDoc)) {
return required.get(codiceDoc); return REQUIRED.get(codiceDoc);
} }
return Collections.emptyList(); return Collections.emptyList();
} }
@ -285,42 +286,43 @@ public class AsseverazioniUtil {
if (asseverazioniEseguite.size() == 0) { if (asseverazioniEseguite.size() == 0) {
return false; return false;
} }
List<String> nuoviSoggetti = new ArrayList<String>( Set<String> cfNuoviSoggetti = new HashSet<>();
SoggettoLocalServiceUtil.getCfValidTmpByDettPratica(dettPraticaId)); for (Soggetto soggetto : SoggettoLocalServiceUtil.getValidTmpByDettPratica(dettPraticaId)) {
List<String> nuoviDelegati = new ArrayList<String>( if (!TipoSoggettoUtil.COLLAUDATORE.equals(soggetto.getTipologiaSoggetto())
DelegaLocalServiceUtil.findCfByDettPratica_Tipologia_InEsito(dettPraticaId, new String[] { || soggetto.getCodiceFiscale().equalsIgnoreCase(
TipoSoggettoUtil.COMMITTENTE, TipoSoggettoUtil.DIRETTORE_LAVORI, TipoSoggettoUtil.GEOLOGO, dettPratica.getCodiceFiscalePrincipaleCollaudatore())) {
TipoSoggettoUtil.DITTA, TipoSoggettoUtil.PROGETTISTA }, cfNuoviSoggetti.add(soggetto.getCodiceFiscale().toLowerCase());
new String[] { AsseverazioniUtil.STATO_ESEGUITA })); }
}
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<>(); Set<String> cfAsseverazioni = new HashSet<>();
for (Asseverazione asseverazione : asseverazioniEseguite) { for (Asseverazione asseverazione : asseverazioniEseguite) {
cfAsseverazioni.add(asseverazione.getCodiceFiscale()); cfAsseverazioni.add(asseverazione.getCodiceFiscale().toLowerCase());
} }
if (TipoIntegrazioneUtil.RICHIESTA_INTEGRAZIONE.equalsIgnoreCase(dettPratica.getTipoIntegrazione())) { if (TipoIntegrazioneUtil.RICHIESTA_INTEGRAZIONE.equalsIgnoreCase(dettPratica.getTipoIntegrazione())) {
boolean titolareDigitale = false;
User titolaredigitaleUser = UserLocalServiceUtil.getUser(intPratica.getUserId()); User titolaredigitaleUser = UserLocalServiceUtil.getUser(intPratica.getUserId());
if (cfAsseverazioni.contains(titolaredigitaleUser.getScreenName())) { boolean titolareDigitale = cfAsseverazioni.contains(titolaredigitaleUser.getScreenName().toLowerCase());
titolareDigitale = true;
}
if (cfAsseverazioni.containsAll(nuoviSoggetti)) {
soggetti = true;
} else {
if (ValidazionePraticaUtil.isA98Required(dettPratica)) { if (ValidazionePraticaUtil.isA98Required(dettPratica)) {
List<String> committentiToRemove = SoggettoLocalServiceUtil for (Soggetto soggetto : SoggettoLocalServiceUtil.getValidTmpByDettPratica_TipologiaSoggetto(
.getCfValidTmpByDettPratica_TipologiaSoggetto(dettPraticaId, dettPraticaId, TipoSoggettoUtil.COMMITTENTE)) {
TipoSoggettoUtil.COMMITTENTE); cfNuoviSoggetti.remove(soggetto.getCodiceFiscale().toLowerCase());
nuoviSoggetti.removeAll(committentiToRemove);
if (cfAsseverazioni.containsAll(nuoviSoggetti)) {
soggetti = true;
} }
} }
if (cfAsseverazioni.containsAll(cfNuoviSoggetti)) {
soggetti = true;
} }
nuoviDelegati.removeAll(nuoviSoggetti); cfNuoviDelegati.removeAll(cfNuoviSoggetti);
if (cfAsseverazioni.containsAll(nuoviDelegati)) { if (cfAsseverazioni.containsAll(cfNuoviDelegati)) {
delegati = true; delegati = true;
} }
if (!soggetti && delegati) { if (!soggetti && delegati) {
if (cfAsseverazioni.containsAll(nuoviSoggetti)) { if (cfAsseverazioni.containsAll(cfNuoviSoggetti)) {
soggetti = true; soggetti = true;
} }
} }
@ -338,29 +340,29 @@ public class AsseverazioniUtil {
if (cfAsseverazioni.containsAll(cfSoggettiPrincipali)) { if (cfAsseverazioni.containsAll(cfSoggettiPrincipali)) {
soggettiPrincipali = true; soggettiPrincipali = true;
} }
nuoviSoggetti.removeAll(cfSoggettiPrincipali); cfNuoviSoggetti.removeAll(cfSoggettiPrincipali);
if (cfAsseverazioni.containsAll(nuoviSoggetti)) { if (cfAsseverazioni.containsAll(cfNuoviSoggetti)) {
soggetti = true; soggetti = true;
} else { } else {
if (ValidazionePraticaUtil.isA98Required(dettPratica)) { if (ValidazionePraticaUtil.isA98Required(dettPratica)) {
List<String> committentiToRemove = SoggettoLocalServiceUtil List<String> committentiToRemove = SoggettoLocalServiceUtil
.getCfValidTmpByDettPratica_TipologiaSoggetto(dettPraticaId, .getCfValidTmpByDettPratica_TipologiaSoggetto(dettPraticaId,
TipoSoggettoUtil.COMMITTENTE); TipoSoggettoUtil.COMMITTENTE);
nuoviSoggetti.removeAll(committentiToRemove); cfNuoviSoggetti.removeAll(committentiToRemove);
if (cfAsseverazioni.containsAll(nuoviSoggetti)) { if (cfAsseverazioni.containsAll(cfNuoviSoggetti)) {
soggetti = true; soggetti = true;
} }
} }
} }
nuoviDelegati.removeAll(cfSoggettiPrincipali); cfNuoviDelegati.removeAll(cfSoggettiPrincipali);
nuoviDelegati.removeAll(nuoviSoggetti); cfNuoviDelegati.removeAll(cfNuoviSoggetti);
if (cfAsseverazioni.containsAll(nuoviDelegati)) { if (cfAsseverazioni.containsAll(cfNuoviDelegati)) {
delegati = true; delegati = true;
} }
return soggettiPrincipali && soggetti && delegati; return soggettiPrincipali && soggetti && delegati;
} }
} else { } else {
for (String tipoSoggetto : required.get(ASSEVERAZIONI_DOMANDA)) { for (String tipoSoggetto : REQUIRED.get(ASSEVERAZIONI_DOMANDA)) {
// Se committente e c'è delega => true // Se committente e c'è delega => true
if (TipoSoggettoUtil.COMMITTENTE.equalsIgnoreCase(tipoSoggetto) if (TipoSoggettoUtil.COMMITTENTE.equalsIgnoreCase(tipoSoggetto)
&& ValidazionePraticaUtil.isA98Required(dettPratica)) { && ValidazionePraticaUtil.isA98Required(dettPratica)) {
@ -388,7 +390,7 @@ public class AsseverazioniUtil {
public static boolean isEnoughOne(String codiceDoc) { 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) 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>
<c:if test="<%= !isEsente %>"> <c:if test="<%= !isEsente %>">
<% System.out.println("################################# fineLavoriId = " + fineLavoriId); %>
<liferay-ui:icon <liferay-ui:icon
linkCssClass='<%=ValidazionePraticaUtil.pagamentoFineLavoriIsEnable(fineLavoriId)?"btn btn-primary":"btn btn-primary disabled" %>' linkCssClass='<%=ValidazionePraticaUtil.pagamentoFineLavoriIsEnable(fineLavoriId)?"btn btn-primary":"btn btn-primary disabled" %>'
iconCssClass="fa fa-cogs" 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; 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.mail.model.FileAttachment;
import com.liferay.portal.kernel.json.JSONObject; 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.MailMessage;
import com.liferay.portal.kernel.mail.SMTPAccount; import com.liferay.portal.kernel.mail.SMTPAccount;
import com.liferay.portal.kernel.util.StringPool; 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.CompanyLocalServiceUtil;
import com.liferay.portal.service.ServiceContext; 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 class MailManagerUtil {
public static Email addEmailByTemplate(String className, long classPK, long emailTemplateId, public static Email addEmailByTemplate(String className, long classPK, long emailTemplateId,
JSONObject templateParamJSON, List<FileAttachment> fileAttachments, ServiceContext serviceContext) JSONObject templateParamJSON, List<FileAttachment> fileAttachments, ServiceContext serviceContext)
throws Exception { 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, public static Email addEmailByTemplate(String className, long classPK, long emailTemplateId,
JSONObject templateParamJSON, ServiceContext serviceContext) throws Exception { 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, public static Email addEmailByTemplate(String className, long classPK, long emailTemplateId,
JSONObject templateParamJSON, List<FileAttachment> fileAttachments, boolean sendSync, JSONObject templateParamJSON, List<FileAttachment> fileAttachments, boolean sendSync,
ServiceContext serviceContext) throws Exception { ServiceContext serviceContext) throws Exception {
EmailTemplate emailTemplate = EmailTemplateLocalServiceUtil.getEmailTemplate(emailTemplateId); EmailTemplate emailTemplate = EmailTemplateLocalServiceUtil.getEmailTemplate(emailTemplateId);
return addEmailByTemplate(className, classPK, emailTemplate, templateParamJSON, fileAttachments, return addEmailByTemplate(className, classPK, emailTemplate, templateParamJSON, fileAttachments, sendSync,
sendSync, serviceContext); serviceContext);
} }
public static Email addEmailByTemplate(String className, long classPK, String emailTemplateName, public static Email addEmailByTemplate(String className, long classPK, String emailTemplateName,
JSONObject templateParamJSON, List<FileAttachment> fileAttachments, ServiceContext serviceContext) JSONObject templateParamJSON, List<FileAttachment> fileAttachments, ServiceContext serviceContext)
throws Exception { throws Exception {
return addEmailByTemplate(className, classPK, emailTemplateName, templateParamJSON, fileAttachments, return addEmailByTemplate(className, classPK, emailTemplateName, templateParamJSON, fileAttachments, false,
false, serviceContext); serviceContext);
} }
public static Email addEmailByTemplate(String className, long classPK, String emailTemplateName, public static Email addEmailByTemplate(String className, long classPK, String emailTemplateName,
JSONObject templateParamJSON, ServiceContext serviceContext) throws Exception { 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, public static Email addEmailByTemplate(String className, long classPK, String emailTemplateName,
@ -65,15 +65,13 @@ public class MailManagerUtil {
EmailTemplate emailTemplate = EmailTemplateLocalServiceUtil.fetchByC_GroupId_Name( EmailTemplate emailTemplate = EmailTemplateLocalServiceUtil.fetchByC_GroupId_Name(
serviceContext.getCompanyId(), serviceContext.getScopeGroupId(), emailTemplateName); serviceContext.getCompanyId(), serviceContext.getScopeGroupId(), emailTemplateName);
if (Validator.isNull(emailTemplate)) { if (Validator.isNull(emailTemplate)) {
Company company = CompanyLocalServiceUtil.getCompany(serviceContext.getCompanyId()); Company company = CompanyLocalServiceUtil.getCompany(serviceContext.getCompanyId());
emailTemplate = EmailTemplateLocalServiceUtil.findByC_GroupId_Name(serviceContext.getCompanyId(), emailTemplate = EmailTemplateLocalServiceUtil.findByC_GroupId_Name(serviceContext.getCompanyId(),
company.getGroupId(), emailTemplateName); company.getGroupId(), emailTemplateName);
} }
return addEmailByTemplate(className, classPK, emailTemplate, templateParamJSON, fileAttachments, sendSync,
return addEmailByTemplate(className, classPK, emailTemplate, templateParamJSON, fileAttachments, serviceContext);
sendSync, serviceContext);
} }
public static Email addEmailByTemplate(String className, long classPK, EmailTemplate emailTemplate, public static Email addEmailByTemplate(String className, long classPK, EmailTemplate emailTemplate,
@ -84,7 +82,6 @@ public class MailManagerUtil {
templateParamJSON.getJSONObject(MailManagerConstants.TEMPLATE_PARAMETER_VARIABLES_KEY)); templateParamJSON.getJSONObject(MailManagerConstants.TEMPLATE_PARAMETER_VARIABLES_KEY));
String body = VelocityUtil.evaluate(emailTemplate.getBody(), String body = VelocityUtil.evaluate(emailTemplate.getBody(),
templateParamJSON.getJSONObject(MailManagerConstants.TEMPLATE_PARAMETER_VARIABLES_KEY)); templateParamJSON.getJSONObject(MailManagerConstants.TEMPLATE_PARAMETER_VARIABLES_KEY));
String to = templateParamJSON.getString(MailManagerConstants.TEMPLATE_PARAMETER_TO_KEY); String to = templateParamJSON.getString(MailManagerConstants.TEMPLATE_PARAMETER_TO_KEY);
if (Validator.isNull(to)) { if (Validator.isNull(to)) {
to = emailTemplate.getTo(); to = emailTemplate.getTo();
@ -97,16 +94,15 @@ public class MailManagerUtil {
if (Validator.isNull(ccn)) { if (Validator.isNull(ccn)) {
ccn = emailTemplate.getCcn(); ccn = emailTemplate.getCcn();
} }
return EmailLocalServiceUtil.addEmail(className, classPK, emailTemplate.getFrom(), return EmailLocalServiceUtil.addEmail(className, classPK, emailTemplate.getFrom(),
StringUtil.split(to, StringPool.COMMA), StringUtil.split(cc, StringPool.COMMA), StringUtil.split(to, StringPool.COMMA), StringUtil.split(cc, StringPool.COMMA),
StringUtil.split(ccn, StringPool.COMMA), subject, body, true, fileAttachments, sendSync, StringUtil.split(ccn, StringPool.COMMA), subject, body, true, fileAttachments, sendSync,
emailTemplate.getTemplateName(), serviceContext); emailTemplate.getTemplateName(), serviceContext);
} }
public static Email addEmail(String className, long classPK, MailMessage mailMessage, public static Email addEmail(String className, long classPK, MailMessage mailMessage, ServiceContext serviceContext)
ServiceContext serviceContext) throws Exception { throws Exception {
return addEmail(className, classPK, mailMessage, false, serviceContext); return addEmail(className, classPK, mailMessage, false, serviceContext);
} }
@ -118,37 +114,28 @@ public class MailManagerUtil {
String[] cc = MailUtil.fromInternetAddresses(mailMessage.getCC()); String[] cc = MailUtil.fromInternetAddresses(mailMessage.getCC());
String[] bcc = MailUtil.fromInternetAddresses(mailMessage.getBCC()); String[] bcc = MailUtil.fromInternetAddresses(mailMessage.getBCC());
String[] bulkAddresses = MailUtil.fromInternetAddresses(mailMessage.getBulkAddresses()); String[] bulkAddresses = MailUtil.fromInternetAddresses(mailMessage.getBulkAddresses());
String subject = mailMessage.getSubject(); String subject = mailMessage.getSubject();
String body = mailMessage.getBody(); String body = mailMessage.getBody();
boolean htmlFormat = mailMessage.getHTMLFormat(); boolean htmlFormat = mailMessage.getHTMLFormat();
String[] replyTo = MailUtil.fromInternetAddresses(mailMessage.getReplyTo()); String[] replyTo = MailUtil.fromInternetAddresses(mailMessage.getReplyTo());
String messageId = mailMessage.getMessageId(); String messageId = mailMessage.getMessageId();
String inReplyTo = mailMessage.getInReplyTo(); String inReplyTo = mailMessage.getInReplyTo();
List<FileAttachment> fileAttachments = mailMessage.getFileAttachments(); List<FileAttachment> fileAttachments = mailMessage.getFileAttachments();
SMTPAccount smtpAccount = mailMessage.getSMTPAccount(); SMTPAccount smtpAccount = mailMessage.getSMTPAccount();
String smtpHost = null; String smtpHost = null;
int smtpPort = 0; int smtpPort = 0;
boolean smtpSecure = false; boolean smtpSecure = false;
String smtpUsername = null; String smtpUsername = null;
String smtpPassword = null; String smtpPassword = null;
if (smtpAccount != null) { if (smtpAccount != null) {
smtpHost = smtpAccount.getHost(); smtpHost = smtpAccount.getHost();
smtpPort = smtpAccount.getPort(); smtpPort = smtpAccount.getPort();
smtpSecure = smtpAccount.isSecure(); smtpSecure = smtpAccount.isSecure();
smtpUsername = smtpAccount.getUser(); smtpUsername = smtpAccount.getUser();
smtpPassword = smtpAccount.getPassword(); smtpPassword = smtpAccount.getPassword();
} }
return EmailLocalServiceUtil.addEmail(className, classPK, from, to, cc, bcc, bulkAddresses, subject, body,
return EmailLocalServiceUtil.addEmail(className, classPK, from, to, cc, bcc, bulkAddresses, subject, htmlFormat, replyTo, messageId, inReplyTo, smtpHost, smtpPort, smtpSecure, smtpUsername, smtpPassword,
body, htmlFormat, replyTo, messageId, inReplyTo, smtpHost, smtpPort, smtpSecure, fileAttachments, sendSync, null, serviceContext);
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.namespace=portos_rep
build.number=32 build.number=33
build.date=1631888946526 build.date=1634829831564
build.auto.upgrade=true 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; package it.tref.liferay.portos.report.shared.constants;
public class ReportConstants { public class ReportConstants {
public enum ReportProcessMode { public enum ReportProcessMode {
ASYNC, SYNC 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; 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 it.tref.liferay.portos.report.shared.constants.ReportConstants.ReportType;
import java.util.Map; import java.util.Map;
import com.liferay.portal.kernel.util.Validator;
public class ReportDto { public class ReportDto {
private String type; private String type;
@ -27,8 +27,8 @@ public class ReportDto {
} }
public ReportDto(String type, long folderId, long[] fileEntryIds, String fileName, String[] css, String portalURL, 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, boolean showNumberOfPage, Object dataSource, Map<String, Object> parameters, String header,
String footer, int footerHeight) { int headerHeight, String footer, int footerHeight) {
this(); this();
this.type = type; this.type = type;
@ -116,15 +116,6 @@ public class ReportDto {
this.showNumberOfPage = showNumberOfPage; this.showNumberOfPage = showNumberOfPage;
} }
/*
* public Object getDataSource() {
*
* return dataSource; }
*
* public void setDataSource(Object dataSource) {
*
* this.dataSource = dataSource; }
*/
public Map<String, Object> getParameters() { public Map<String, Object> getParameters() {
return parameters; return parameters;
@ -180,7 +171,6 @@ public class ReportDto {
if (Validator.isNotNull(getType())) { if (Validator.isNotNull(getType())) {
return ReportType.valueOf(getType()); return ReportType.valueOf(getType());
} }
return null; 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; 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 it.tref.liferay.portos.report.shared.constants.ReportConstants.ReportResult;
import java.io.Serializable; import java.io.Serializable;
import com.liferay.portal.kernel.util.Validator;
public class ReportResultDto implements Serializable { public class ReportResultDto implements Serializable {
private static final long serialVersionUID = -5807088639699043383L; private static final long serialVersionUID = -5807088639699043383L;
@ -16,13 +15,9 @@ public class ReportResultDto implements Serializable {
private String result; private String result;
private String resultMessage; private String resultMessage;
public ReportResultDto() { public ReportResultDto() {}
}
public ReportResultDto( public ReportResultDto(long reportTaskId, long[] fileEntryIds, String result, String resultMessage) {
long reportTaskId, long[] fileEntryIds, String result,
String resultMessage) {
this(); this();
this.reportTaskId = reportTaskId; this.reportTaskId = reportTaskId;
@ -76,7 +71,6 @@ public class ReportResultDto implements Serializable {
if (Validator.isNotNull(getResult())) { if (Validator.isNotNull(getResult())) {
return ReportResult.valueOf(getResult()); return ReportResult.valueOf(getResult());
} }
return null; 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; 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.Document;
import com.itextpdf.text.DocumentException; import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element; 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.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.Validator; 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 { public class PdfUtil {
private final static Log _log = LogFactoryUtil.getLog(PdfUtil.class); private final static Log _log = LogFactoryUtil.getLog(PdfUtil.class);
@ -36,17 +35,13 @@ public class PdfUtil {
public static byte[] merge(InputStream pdf1, InputStream pdf2) { public static byte[] merge(InputStream pdf1, InputStream pdf2) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
List<InputStream> pdfs = new ArrayList<InputStream>(); List<InputStream> pdfs = new ArrayList<InputStream>();
pdfs.add(pdf1); pdfs.add(pdf1);
pdfs.add(pdf2); pdfs.add(pdf2);
Document document = new Document(); Document document = new Document();
try { try {
List<PdfReader> readers = new ArrayList<PdfReader>(); List<PdfReader> readers = new ArrayList<PdfReader>();
Iterator<InputStream> iteratorPDFs = pdfs.iterator(); Iterator<InputStream> iteratorPDFs = pdfs.iterator();
// Create Readers for the pdfs. // Create Readers for the pdfs.
while (iteratorPDFs.hasNext()) { while (iteratorPDFs.hasNext()) {
InputStream pdf = iteratorPDFs.next(); InputStream pdf = iteratorPDFs.next();
@ -55,109 +50,74 @@ public class PdfUtil {
} }
// Create a writer for the outputstream // Create a writer for the outputstream
PdfWriter writer = PdfWriter.getInstance(document, outputStream); PdfWriter writer = PdfWriter.getInstance(document, outputStream);
document.open(); document.open();
PdfContentByte cb = writer.getDirectContent(); PdfContentByte cb = writer.getDirectContent();
PdfImportedPage page; PdfImportedPage page;
int pageOfCurrentReaderPDF = 0; int pageOfCurrentReaderPDF = 0;
Iterator<PdfReader> iteratorPDFReader = readers.iterator(); Iterator<PdfReader> iteratorPDFReader = readers.iterator();
while (iteratorPDFReader.hasNext()) { while (iteratorPDFReader.hasNext()) {
PdfReader pdfReader = iteratorPDFReader.next(); PdfReader pdfReader = iteratorPDFReader.next();
// Create a new page in the target for each source page. // Create a new page in the target for each source page.
while (pageOfCurrentReaderPDF < pdfReader.getNumberOfPages()) { while (pageOfCurrentReaderPDF < pdfReader.getNumberOfPages()) {
document.newPage(); document.newPage();
pageOfCurrentReaderPDF++; pageOfCurrentReaderPDF++;
page = page = writer.getImportedPage(pdfReader, pageOfCurrentReaderPDF);
writer.getImportedPage(
pdfReader, pageOfCurrentReaderPDF);
cb.addTemplate(page, 0, 0); cb.addTemplate(page, 0, 0);
} }
pageOfCurrentReaderPDF = 0; pageOfCurrentReaderPDF = 0;
} }
iteratorPDFReader = readers.iterator(); iteratorPDFReader = readers.iterator();
// Loop through the PDF files and add to the output. // Loop through the PDF files and add to the output.
while (iteratorPDFReader.hasNext()) { while (iteratorPDFReader.hasNext()) {}
}
outputStream.flush(); outputStream.flush();
document.close(); document.close();
outputStream.close(); outputStream.close();
return outputStream.toByteArray(); return outputStream.toByteArray();
} } catch (Exception e) {
catch (Exception e) {
_log.error("Errore", e); _log.error("Errore", e);
return null; return null;
} } finally {
finally {
if (document.isOpen()) { if (document.isOpen()) {
document.close(); document.close();
} }
} }
} }
public static byte[] mergePdf(List<byte[]> reports, boolean showNumberOfPage) public static byte[] mergePdf(List<byte[]> reports, boolean showNumberOfPage) throws Exception {
throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document document = new Document(); Document document = new Document();
PdfCopy pdfCopy = new PdfCopy(document, baos); PdfCopy pdfCopy = new PdfCopy(document, baos);
document.open(); 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; int totalPage = 0;
for (byte[] report : reports) { for (byte[] report : reports) {
PdfReader pdfReader = new PdfReader(report); PdfReader pdfReader = new PdfReader(report);
totalPage += pdfReader.getNumberOfPages(); totalPage += pdfReader.getNumberOfPages();
pdfReader.close(); pdfReader.close();
} }
int curentPageNumber = 0; int curentPageNumber = 0;
for (byte[] report : reports) { for (byte[] report : reports) {
PdfReader pdfReader = new PdfReader(report); PdfReader pdfReader = new PdfReader(report);
pdfCopy.setOutlines(outlines); pdfCopy.setOutlines(outlines);
int n = pdfReader.getNumberOfPages(); int n = pdfReader.getNumberOfPages();
for (int page = 0; page < n;) { for (int page = 0; page < n;) {
curentPageNumber++; curentPageNumber++;
PdfImportedPage pdfImportedPage = pdfCopy.getImportedPage(pdfReader, ++page);
PdfImportedPage pdfImportedPage =
pdfCopy.getImportedPage(pdfReader, ++page);
PageStamp stamp = pdfCopy.createPageStamp(pdfImportedPage); PageStamp stamp = pdfCopy.createPageStamp(pdfImportedPage);
if (showNumberOfPage) { if (showNumberOfPage) {
// add page numbers // add page numbers
ColumnText.showTextAligned( ColumnText.showTextAligned(stamp.getUnderContent(), Element.ALIGN_CENTER,
stamp.getUnderContent(), new Phrase(String.format("%d / %d", curentPageNumber, totalPage)),
Element.ALIGN_CENTER,
new Phrase(String.format(
"%d / %d", curentPageNumber, totalPage)),
pdfImportedPage.getHeight() / 2, 20, 0); pdfImportedPage.getHeight() / 2, 20, 0);
} }
stamp.alterContents(); stamp.alterContents();
pdfCopy.addPage(pdfImportedPage); pdfCopy.addPage(pdfImportedPage);
} }
pdfCopy.freeReader(pdfReader); pdfCopy.freeReader(pdfReader);
pdfReader.close(); pdfReader.close();
} }
document.close(); document.close();
return baos.toByteArray(); return baos.toByteArray();
} }
@ -166,13 +126,11 @@ public class PdfUtil {
protected ElementList header; protected ElementList header;
protected ElementList footer; protected ElementList footer;
public HeaderFooter(String headerHtml, String footerHtml) public HeaderFooter(String headerHtml, String footerHtml) throws IOException {
throws IOException {
if (Validator.isNotNull(headerHtml)) { if (Validator.isNotNull(headerHtml)) {
header = XMLWorkerHelper.parseToElementList(headerHtml, null); header = XMLWorkerHelper.parseToElementList(headerHtml, null);
} }
if (Validator.isNotNull(footerHtml)) { if (Validator.isNotNull(footerHtml)) {
footer = XMLWorkerHelper.parseToElementList(footerHtml, null); footer = XMLWorkerHelper.parseToElementList(footerHtml, null);
} }
@ -183,7 +141,6 @@ public class PdfUtil {
try { try {
ColumnText ct = new ColumnText(writer.getDirectContent()); ColumnText ct = new ColumnText(writer.getDirectContent());
if (Validator.isNotNull(header)) { if (Validator.isNotNull(header)) {
ct.setSimpleColumn(new Rectangle(36, 832, 559, 810)); ct.setSimpleColumn(new Rectangle(36, 832, 559, 810));
for (Element e : header) { for (Element e : header) {
@ -191,7 +148,6 @@ public class PdfUtil {
} }
ct.go(); ct.go();
} }
if (Validator.isNotNull(footer)) { if (Validator.isNotNull(footer)) {
ct.setSimpleColumn(new Rectangle(36, 10, 559, 32)); ct.setSimpleColumn(new Rectangle(36, 10, 559, 32));
for (Element e : footer) { for (Element e : footer) {
@ -199,8 +155,7 @@ public class PdfUtil {
} }
ct.go(); ct.go();
} }
} } catch (DocumentException de) {
catch (DocumentException de) {
throw new ExceptionConverter(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. * 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.
* The contents of this file are subject to the terms of the Liferay Enterprise Subscription License * You can obtain a copy of the License by contacting Liferay, Inc. See the License for the specific language governing
* ("License"). You may not use this file except in compliance with the License. You can obtain a * permissions and limitations under the License, including but not limited to distribution rights of the Software.
* 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; 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 java.util.Map;
import org.apache.velocity.VelocityContext; import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.RuntimeConstants; 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 * @author Brian Wing Shun Chan
*/ */
@ -36,33 +30,23 @@ public class VelocityUtil {
public static String evaluate(String input, Map<String, Object> variables) throws Exception { public static String evaluate(String input, Map<String, Object> variables) throws Exception {
VelocityEngine velocityEngine = new VelocityEngine(); VelocityEngine velocityEngine = new VelocityEngine();
velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
com.liferay.portal.kernel.util.PropsUtil.get(PropsKeys.VELOCITY_ENGINE_LOGGER)); com.liferay.portal.kernel.util.PropsUtil.get(PropsKeys.VELOCITY_ENGINE_LOGGER));
velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.category", velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.category",
com.liferay.portal.kernel.util.PropsUtil.get(PropsKeys.VELOCITY_ENGINE_LOGGER_CATEGORY)); com.liferay.portal.kernel.util.PropsUtil.get(PropsKeys.VELOCITY_ENGINE_LOGGER_CATEGORY));
velocityEngine.init(); velocityEngine.init();
VelocityContext velocityContext = new VelocityContext(); VelocityContext velocityContext = new VelocityContext();
if (variables != null) { if (variables != null) {
for (Map.Entry<String, Object> entry : variables.entrySet()) { for (Map.Entry<String, Object> entry : variables.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
Object value = entry.getValue(); Object value = entry.getValue();
if (Validator.isNotNull(key)) { if (Validator.isNotNull(key)) {
velocityContext.put(key, value); velocityContext.put(key, value);
} }
} }
} }
UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter(); UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter();
velocityEngine.evaluate(velocityContext, unsyncStringWriter, VelocityUtil.class.getName(), input); velocityEngine.evaluate(velocityContext, unsyncStringWriter, VelocityUtil.class.getName(), input);
return unsyncStringWriter.toString(); return unsyncStringWriter.toString();
} }
} }

Caricamento…
Annulla
Salva