use of it.cnr.si.opencmis.criteria.Criteria in project cool-jconon by consiglionazionaledellericerche.
the class CallService method findAttachmentName.
public String findAttachmentName(Session cmisSession, String source, String name) {
Criteria criteria = CriteriaFactory.createCriteria(BaseTypeId.CMIS_DOCUMENT.value());
criteria.addColumn(PropertyIds.OBJECT_ID);
criteria.addColumn(PropertyIds.NAME);
criteria.add(Restrictions.inFolder(source));
criteria.add(Restrictions.eq(PropertyIds.NAME, name));
ItemIterable<QueryResult> iterable = criteria.executeQuery(cmisSession, false, cmisSession.getDefaultContext());
for (QueryResult queryResult : iterable) {
return (String) queryResult.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue();
}
return null;
}
use of it.cnr.si.opencmis.criteria.Criteria 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.si.opencmis.criteria.Criteria 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