Skip to content

Commit

Permalink
aggiunta email CC
Browse files Browse the repository at this point in the history
  • Loading branch information
karimsaad91 committed Jan 31, 2022
1 parent a1316e1 commit 344999e
Show file tree
Hide file tree
Showing 21 changed files with 1,018 additions and 4,019 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>it.cnr.si.cool.jconon</groupId>
<artifactId>cool-jconon-parent</artifactId>
<version>4.10.5</version>
<version>4.10.7</version>
</parent>

<artifactId>cool-jconon-asp</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (C) 2021 Consiglio Nazionale delle Ricerche
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package it.cnr.si.cool.jconon.asp.service;

import it.cnr.si.cool.jconon.service.PrintService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Primary
@Service
public class ASPPrintService extends PrintService {
@Override
public void printApplication(String nodeRef, final String contextURL, final Locale locale, final boolean email) {
try {
LOGGER.info("Start print application width id: " + nodeRef);
Session cmisSession = cmisService.createAdminSession();
Folder application = (Folder) cmisSession.getObject(nodeRef);
Boolean confirmed = isConfirmed(application);
Folder call = (Folder) cmisSession.getObject(application.getParentId());
application.refresh();
CMISUser applicationUser;
try {
applicationUser = userService.loadUserForConfirm(
application.getPropertyValue(JCONONPropertyIds.APPLICATION_USER.value()));
} catch (CoolUserFactoryException e) {
throw new ClientMessageException("User not found of application " + nodeRef, e);
}
String nameRicevutaReportModel = getNameRicevutaReportModel(cmisSession, application, locale);
byte[] stampaByte = getRicevutaReportModel(cmisSession,
application, contextURL, nameRicevutaReportModel, false);
InputStream is = new ByteArrayInputStream(stampaByte);
archiviaRicevutaReportModel(cmisSession, application, is, nameRicevutaReportModel, confirmed);

/**
* Spedisco la mail con la stampa allegata
*/
if (email) {
Map<String, Object> mailModel = new HashMap<String, Object>();
List<String> emailList = new ArrayList<String>();
emailList.add(applicationUser.getEmail());
mailModel.put("contextURL", contextURL);
mailModel.put("folder", application);
mailModel.put("call", call);
mailModel.put("message", context.getBean("messageMethod", locale));
mailModel.put("email_comunicazione", applicationUser.getEmail());
EmailMessage message = new EmailMessage();
message.setRecipients(emailList);
String body;
if (confirmed) {
body = Util.processTemplate(mailModel, "/pages/application/application.registration.html.ftl");
message.setSubject(i18nService.getLabel("subject-info", locale) + i18nService.getLabel("subject-confirm-domanda", locale, call.getProperty(JCONONPropertyIds.CALL_CODICE.value()).getValueAsString()));
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(JCONONPropertyIds.APPLICATION_DUMMY.value(), "{\"stampa_archiviata\" : true}");
application.updateProperties(properties);
} else {
body = Util.processTemplate(mailModel, "/pages/application/application.print.html.ftl");
message.setSubject(i18nService.getLabel("subject-info", locale) +
i18nService.getLabel("subject-print-domanda", locale, call.getProperty(JCONONPropertyIds.CALL_CODICE.value()).getValueAsString()));
}
message.setBody(body);
message.setAttachments(Arrays.asList(new AttachmentBean(nameRicevutaReportModel, stampaByte)));
message.setCcRecipients(Arrays.asList("staffdirezione@aspbassaromagna.it"));
mailService.send(message);
}
if (LOGGER.isInfoEnabled())
LOGGER.info("End print application width id: " + nodeRef);
} catch (Exception t) {
LOGGER.error("Error while print application width id:" + nodeRef, t);
}
}
}
37 changes: 37 additions & 0 deletions src/main/resources/i18n/applications_it.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Copyright (C) 2019 Consiglio Nazionale delle Ricerche
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#

label.jconon_call_codice=Codice bando
label.jconon_call_da_data=scadenza
placeholder.jconon_call_da_data=dal
placeholder.jconon_call_a_data=al

actions.print=Stampa domanda
actions.attachments=Allegati Vari
actions.curriculum=Curriculum
actions.schedaAnonima=Scheda anonima sintetica
actions.copy=Duplica Riga
actions.productList=Elenco Prodotti
actions.productSelected=Prodotti Scelti
actions.reopen=Riapri domanda
actions.duplicate=Copia domanda
actions.paste=Incolla domanda
actions.paste_row=Incolla riga
actions.scheda_valutazione=Scheda di valutazione
actions.scheda_anonima=Scheda anonima sintetica
actions.reject=Escludi
actions.operations=Operazioni
title.call.active=Bandi Attivi

0 comments on commit 344999e

Please sign in to comment.