use of it.cnr.cool.mail.model.EmailMessage in project cool-jconon by consiglionazionaledellericerche.
the class PrintService method generaSchedeValutazione.
private void generaSchedeValutazione(String nodeRef, final String contextURL, final Locale locale, final String indirizzoEmail, final String userId) {
try {
Session adminCMISSession = cmisService.createAdminSession();
Folder bando = (Folder) adminCMISSession.getObject(nodeRef);
Criteria criteriaDomande = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_APPLICATION.queryName());
criteriaDomande.add(Restrictions.inTree(nodeRef));
criteriaDomande.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), ApplicationService.StatoDomanda.CONFERMATA.getValue()));
criteriaDomande.add(Restrictions.isNull(JCONONPropertyIds.APPLICATION_ESCLUSIONE_RINUNCIA.value()));
OperationContext context = adminCMISSession.getDefaultContext();
context.setMaxItemsPerPage(10000);
ItemIterable<QueryResult> domande = criteriaDomande.executeQuery(adminCMISSession, false, context);
int domandeEstratte = 0;
for (QueryResult queryResultDomande : domande) {
String applicationAttach = competitionService.findAttachmentId(adminCMISSession, (String) queryResultDomande.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue(), JCONONDocumentType.JCONON_ATTACHMENT_SCHEDA_VALUTAZIONE);
if (applicationAttach != null) {
Document scheda = (Document) adminCMISSession.getObject(applicationAttach);
if (scheda.getVersionLabel().equalsIgnoreCase("1.0")) {
scheda.deleteAllVersions();
} else {
continue;
}
}
try {
printSchedaValutazione(adminCMISSession, (String) queryResultDomande.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue(), contextURL, userId, locale);
domandeEstratte++;
} catch (IOException e) {
LOGGER.error("Error while generaSchedeValutazione", e);
}
}
EmailMessage message = new EmailMessage();
message.setBody("Il processo di estrazione delle schede relative bando " + bando.getProperty(JCONONPropertyIds.CALL_CODICE.value()).getValueAsString() + " è terminato.<br>Sono state estratte " + domandeEstratte + " schede.");
message.setHtmlBody(true);
message.setSubject(i18nService.getLabel("subject-info", locale) + "Schede di valutazione");
message.setRecipients(Arrays.asList(indirizzoEmail));
mailService.send(message);
} catch (Exception e) {
LOGGER.error("Error on Message for generaSchedeValutazione with id:" + nodeRef, e);
}
}
use of it.cnr.cool.mail.model.EmailMessage in project cool-jconon by consiglionazionaledellericerche.
the class PrintService method generaSchedeAnonima.
private void generaSchedeAnonima(String nodeRef, final String contextURL, final Locale locale, final String indirizzoEmail, final String userId) {
try {
Session adminCMISSession = cmisService.createAdminSession();
Folder bando = (Folder) adminCMISSession.getObject(nodeRef);
Criteria criteriaDomande = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_APPLICATION.queryName());
criteriaDomande.add(Restrictions.inTree(nodeRef));
criteriaDomande.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), ApplicationService.StatoDomanda.CONFERMATA.getValue()));
OperationContext context = adminCMISSession.getDefaultContext();
context.setMaxItemsPerPage(10000);
ItemIterable<QueryResult> domande = criteriaDomande.executeQuery(adminCMISSession, false, context);
int schedeEstratte = 0, numeroScheda = getNumberOfSchedeAnonime(nodeRef, adminCMISSession).intValue();
String messaggio = "";
for (QueryResult queryResultDomande : domande) {
String applicationAttach = competitionService.findAttachmentId(adminCMISSession, (String) queryResultDomande.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue(), JCONONDocumentType.JCONON_ATTACHMENT_SCHEDA_ANONIMA_SINTETICA_GENERATED);
if (queryResultDomande.getPropertyById(JCONONPropertyIds.APPLICATION_ESCLUSIONE_RINUNCIA.value()) != null && queryResultDomande.getPropertyById(JCONONPropertyIds.APPLICATION_ESCLUSIONE_RINUNCIA.value()).getFirstValue() != null) {
if (applicationAttach != null)
adminCMISSession.getObject(applicationAttach).delete();
continue;
}
if (applicationAttach != null) {
if (adminCMISSession.getObject(applicationAttach).getPropertyValue(JCONONPropertyIds.SCHEDA_ANONIMA_VALUTAZIONE_ESITO.value()) != null) {
messaggio = "<BR><b>Alcune schede risultano già valutate, pertanto non sono state estratte nuovamente.</b>";
continue;
} else {
adminCMISSession.getObject(applicationAttach).delete();
}
}
try {
numeroScheda++;
printSchedaAnonimaDiValutazione(adminCMISSession, (String) queryResultDomande.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue(), contextURL, userId, locale, numeroScheda);
schedeEstratte++;
} catch (IOException e) {
LOGGER.error("Error while generaSchedeValutazione", e);
}
}
EmailMessage message = new EmailMessage();
message.setBody("Il processo di estrazione delle schede sintetiche anonime relative bando " + bando.getProperty(JCONONPropertyIds.CALL_CODICE.value()).getValueAsString() + " è terminato.<br>Sono state estratte " + schedeEstratte + " schede." + messaggio);
message.setHtmlBody(true);
message.setSubject(i18nService.getLabel("subject-info", locale) + "Schede Sintetiche Anonime");
message.setRecipients(Arrays.asList(indirizzoEmail));
mailService.send(message);
} catch (Exception e) {
LOGGER.error("Error on Message for generaSchedeValutazione with id:" + nodeRef, e);
}
}
use of it.cnr.cool.mail.model.EmailMessage in project cool-jconon by consiglionazionaledellericerche.
the class CallService method sollecitaApplication.
public void sollecitaApplication(Session cmisSession) {
Criteria criteria = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_CALL.queryName());
criteria.add(Restrictions.inTree(competitionService.getCompetitionFolder().getString("id")));
ItemIterable<QueryResult> bandi = criteria.executeQuery(cmisSession, false, cmisSession.getDefaultContext());
for (QueryResult queryResult : bandi.getPage(Integer.MAX_VALUE)) {
BigInteger numGiorniSollecito = (BigInteger) queryResult.getPropertyById(JCONONPropertyIds.CALL_NUM_GIORNI_MAIL_SOLLECITO.value()).getFirstValue();
if (numGiorniSollecito == null)
numGiorniSollecito = new BigInteger("8");
Calendar dataLimite = Calendar.getInstance();
dataLimite.add(Calendar.DAY_OF_YEAR, numGiorniSollecito.intValue());
Calendar dataFineDomande = (Calendar) queryResult.getPropertyById(JCONONPropertyIds.CALL_DATA_FINE_INVIO_DOMANDE.value()).getFirstValue();
if (dataFineDomande == null)
continue;
if (dataFineDomande.before(dataLimite) && dataFineDomande.after(Calendar.getInstance())) {
Criteria criteriaDomande = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_APPLICATION.queryName());
criteriaDomande.addColumn(JCONONPropertyIds.APPLICATION_USER.value());
criteriaDomande.addColumn(JCONONPropertyIds.APPLICATION_NOME.value());
criteriaDomande.addColumn(JCONONPropertyIds.APPLICATION_COGNOME.value());
criteriaDomande.add(Restrictions.inFolder((String) queryResult.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue()));
criteriaDomande.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), ApplicationService.StatoDomanda.PROVVISORIA.getValue()));
ItemIterable<QueryResult> domande = criteriaDomande.executeQuery(cmisSession, false, cmisSession.getDefaultContext());
for (QueryResult queryResultDomande : domande.getPage(Integer.MAX_VALUE)) {
EmailMessage message = new EmailMessage();
List<String> emailList = new ArrayList<String>();
try {
CMISUser user = userService.loadUserForConfirm((String) queryResultDomande.getPropertyById(JCONONPropertyIds.APPLICATION_USER.value()).getFirstValue());
if (user != null && user.getEmail() != null) {
emailList.add(user.getEmail());
message.setRecipients(emailList);
message.setSubject(i18NService.getLabel("subject-info", Locale.ITALY) + i18NService.getLabel("subject-reminder-domanda", Locale.ITALY, queryResult.getPropertyById(JCONONPropertyIds.CALL_CODICE.value()).getFirstValue(), removeHtmlFromString((String) queryResult.getPropertyById(JCONONPropertyIds.CALL_DESCRIZIONE.value()).getFirstValue())));
Map<String, Object> templateModel = new HashMap<String, Object>();
templateModel.put("call", queryResult);
templateModel.put("folder", queryResultDomande);
templateModel.put("message", context.getBean("messageMethod", Locale.ITALY));
String body = Util.processTemplate(templateModel, "/pages/call/call.reminder.application.html.ftl");
message.setBody(body);
mailService.send(message);
LOGGER.info("Spedita mail a {} per il bando {}", user.getEmail(), message.getSubject());
}
} catch (Exception e) {
LOGGER.error("Cannot send email for scheduler reminder application for call", e);
}
}
}
}
}
use of it.cnr.cool.mail.model.EmailMessage in project cool-jconon by consiglionazionaledellericerche.
the class CallService method esclusioniAsync.
@Async("threadPoolTaskExecutor")
public Long esclusioniAsync(Session session, MultipartHttpServletRequest mRequest, BindingSession bindingSession, String contextURL, Locale locale, String userId) throws IOException {
final Long aLong = internalEsclusioni(session, mRequest, bindingSession, contextURL, locale, userId);
CMISUser user = userService.loadUserForConfirm(userId);
EmailMessage message = new EmailMessage();
message.setBody(i18NService.getLabel("message.esclusioni.async.email.body", locale, aLong));
message.setHtmlBody(true);
message.setSubject(i18NService.getLabel("subject-info", locale));
message.setRecipients(Arrays.asList(user.getEmail()));
mailService.send(message);
return aLong;
}
use of it.cnr.cool.mail.model.EmailMessage in project cool-jconon by consiglionazionaledellericerche.
the class CallService method sollecitaProdotti.
public void sollecitaProdotti(Session cmisSession) {
Criteria criteria = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_CALL.queryName());
Criteria criteriaProfile = criteria.createCriteria(JCONONPolicyType.JCONON_CALL_ASPECT_PRODUCTS_AFTER_COMMISSION.queryName(), JCONONPolicyType.JCONON_CALL_ASPECT_PRODUCTS_AFTER_COMMISSION.queryName());
criteriaProfile.addJoinCriterion(Restrictions.eqProperty(criteria.prefix(PropertyIds.OBJECT_ID), criteriaProfile.prefix(PropertyIds.OBJECT_ID)));
ItemIterable<QueryResult> bandi = criteria.executeQuery(cmisSession, false, cmisSession.getDefaultContext());
for (QueryResult queryResult : bandi.getPage(Integer.MAX_VALUE)) {
Calendar dataInizioCaricamento = queryResult.<Calendar>getPropertyValueById(JCONONPropertyIds.CALL_SELECTED_PRODUCT_START_DATE.value());
Calendar dataFineCaricamento = queryResult.<Calendar>getPropertyValueById(JCONONPropertyIds.CALL_SELECTED_PRODUCT_END_DATE.value());
if (dataFineCaricamento == null || dataInizioCaricamento == null)
continue;
Calendar dataLimite = Calendar.getInstance();
dataLimite.add(Calendar.DAY_OF_YEAR, 3);
if (dataFineCaricamento.before(dataLimite) && dataFineCaricamento.after(Calendar.getInstance())) {
Criteria criteriaDomande = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_APPLICATION.queryName());
criteriaDomande.add(Restrictions.inFolder((String) queryResult.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue()));
criteriaDomande.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), ApplicationService.StatoDomanda.CONFERMATA.getValue()));
criteriaDomande.add(Restrictions.isNull(JCONONPropertyIds.APPLICATION_ESCLUSIONE_RINUNCIA.value()));
ItemIterable<QueryResult> domande = criteriaDomande.executeQuery(cmisSession, false, cmisSession.getDefaultContext());
for (QueryResult queryResultDomande : domande.getPage(Integer.MAX_VALUE)) {
if (!Optional.ofNullable(competitionService.findAttachmentId(cmisSession, queryResultDomande.getPropertyValueById(PropertyIds.OBJECT_ID), JCONONDocumentType.JCONON_ATTACHMENT_CURRICULUM_PROD_SCELTI_MULTIPLO)).isPresent()) {
EmailMessage message = new EmailMessage();
List<String> emailList = new ArrayList<String>();
try {
CMISUser user = userService.loadUserForConfirm((String) queryResultDomande.getPropertyById(JCONONPropertyIds.APPLICATION_USER.value()).getFirstValue());
if (user != null && user.getEmail() != null) {
emailList.add(user.getEmail());
message.setRecipients(emailList);
message.setSubject(i18NService.getLabel("subject-info", Locale.ITALY) + i18NService.getLabel("subject-reminder-selectedproducts", Locale.ITALY, queryResult.getPropertyById(JCONONPropertyIds.CALL_CODICE.value()).getFirstValue(), removeHtmlFromString((String) queryResult.getPropertyById(JCONONPropertyIds.CALL_DESCRIZIONE.value()).getFirstValue())));
Map<String, Object> templateModel = new HashMap<String, Object>();
templateModel.put("call", queryResult);
templateModel.put("folder", queryResultDomande);
templateModel.put("message", context.getBean("messageMethod", Locale.ITALY));
String body = Util.processTemplate(templateModel, "/pages/call/call.reminder.selectedproducts.html.ftl");
message.setBody(body);
mailService.send(message);
LOGGER.info("Spedita mail a {} per il bando {} con testo {}", user.getEmail(), message.getSubject(), body);
}
} catch (Exception e) {
LOGGER.error("Cannot send email for scheduler reminder application for call", e);
}
}
}
}
}
}
Aggregations