use of it.cnr.cool.security.service.impl.alfresco.CMISAuthority in project cool-jconon by consiglionazionaledellericerche.
the class PrintService method getRecordCSVCall.
private void getRecordCSVCall(Session session, Folder callObject, CMISUser user, String contexURL, HSSFSheet sheet, int index) {
int column = 0;
HSSFRow row = sheet.createRow(index);
row.createCell(column++).setCellValue(Optional.ofNullable(i18nService.getLabel(callObject.getType().getId(), Locale.ITALY)).orElse(callObject.getType().getDisplayName()));
row.createCell(column++).setCellValue(callObject.<String>getPropertyValue(JCONONPropertyIds.CALL_CODICE.value()));
row.createCell(column++).setCellValue(callObject.<String>getPropertyValue(JCONONPropertyIds.CALL_STRUTTURA_DESTINATARIA.value()));
row.createCell(column++).setCellValue(callObject.<String>getPropertyValue(JCONONPropertyIds.CALL_SEDE.value()));
row.createCell(column++).setCellValue(callObject.<String>getPropertyValue(JCONONPropertyIds.CALL_NUMERO_GU.value()));
row.createCell(column++).setCellValue(Optional.ofNullable(callObject.getPropertyValue(JCONONPropertyIds.CALL_DATA_GU.value())).map(map -> dateFormat.format(((Calendar) map).getTime())).orElse(""));
row.createCell(column++).setCellValue(Optional.ofNullable(callObject.getPropertyValue(JCONONPropertyIds.CALL_DATA_FINE_INVIO_DOMANDE.value())).map(map -> dateFormat.format(((Calendar) map).getTime())).orElse(""));
final List<CMISAuthority> users = groupService.children(callObject.getPropertyValue(JCONONPropertyIds.CALL_RDP.value()), cmisService.getAdminSession()).stream().collect(Collectors.toList());
row.createCell(column++).setCellValue(Optional.ofNullable(users).filter(strings -> !strings.isEmpty()).orElse(Collections.emptyList()).stream().map(CMISAuthority::getFullName).collect(Collectors.joining(",")));
row.createCell(column++).setCellValue(Optional.ofNullable(users).filter(strings -> !strings.isEmpty()).orElse(Collections.emptyList()).stream().map(CMISAuthority::getShortName).map(s -> userService.loadUserForConfirm(s).getEmail()).collect(Collectors.joining(",")));
row.createCell(column++).setCellValue(Optional.ofNullable(callObject.<BigInteger>getPropertyValue(JCONONPropertyIds.CALL_NUMERO_POSTI.value())).map(BigInteger::toString).orElse(""));
row.createCell(column++).setCellValue(Optional.ofNullable(callObject.<String>getPropertyValue(JCONONPropertyIds.CALL_PROFILO.value())).orElse(""));
final Map<JCONONDocumentType, Pair<String, String>> protocollo = getProtocollo(session, callObject);
final Pair<String, String> protocolloBando = protocollo.getOrDefault(JCONONDocumentType.JCONON_ATTACHMENT_CALL_IT, new Pair<String, String>("", ""));
row.createCell(column++).setCellValue(protocolloBando.getFirst());
row.createCell(column++).setCellValue(protocolloBando.getSecond());
final Pair<String, String> protocolloCommissione = protocollo.getOrDefault(JCONONDocumentType.JCONON_ATTACHMENT_CALL_COMMISSION, new Pair<String, String>("", ""));
row.createCell(column++).setCellValue(protocolloCommissione.getFirst());
row.createCell(column++).setCellValue(protocolloCommissione.getSecond());
final Pair<String, String> protocolloModificaCommissione = protocollo.getOrDefault(JCONONDocumentType.JCONON_ATTACHMENT_CALL_COMMISSION_MODIFICATION, new Pair<String, String>("", ""));
row.createCell(column++).setCellValue(protocolloModificaCommissione.getFirst());
row.createCell(column++).setCellValue(protocolloModificaCommissione.getSecond());
final Pair<String, String> protocolloNominaSegretario = protocollo.getOrDefault(JCONONDocumentType.JCONON_ATTACHMENT_CALL_NOMINA_SEGRETARIO, new Pair<String, String>("", ""));
row.createCell(column++).setCellValue(protocolloNominaSegretario.getFirst());
row.createCell(column++).setCellValue(protocolloNominaSegretario.getSecond());
final Pair<String, String> protocolloGraduatoria = protocollo.getOrDefault(JCONONDocumentType.JCONON_ATTACHMENT_CALL_CLASSIFICATION, new Pair<String, String>("", ""));
row.createCell(column++).setCellValue(protocolloGraduatoria.getFirst());
row.createCell(column++).setCellValue(protocolloGraduatoria.getSecond());
Criteria criteria = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_APPLICATION.queryName());
criteria.addColumn(PropertyIds.OBJECT_ID);
criteria.addColumn(PropertyIds.NAME);
criteria.add(Restrictions.inTree(callObject.getId()));
criteria.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), StatoDomanda.CONFERMATA.getValue()));
ItemIterable<QueryResult> iterable = criteria.executeQuery(session, false, session.getDefaultContext());
final long totalNumItems = iterable.getTotalNumItems();
row.createCell(column++).setCellValue(Optional.ofNullable(totalNumItems).orElse(Long.valueOf(0)));
Criteria criteriaAttive = CriteriaFactory.createCriteria(JCONONFolderType.JCONON_APPLICATION.queryName());
criteriaAttive.addColumn(PropertyIds.OBJECT_ID);
criteriaAttive.addColumn(PropertyIds.NAME);
criteriaAttive.add(Restrictions.inTree(callObject.getId()));
criteriaAttive.add(Restrictions.eq(JCONONPropertyIds.APPLICATION_STATO_DOMANDA.value(), StatoDomanda.CONFERMATA.getValue()));
criteriaAttive.add(Restrictions.isNull(JCONONPropertyIds.APPLICATION_ESCLUSIONE_RINUNCIA.value()));
ItemIterable<QueryResult> iterableAttive = criteriaAttive.executeQuery(session, false, session.getDefaultContext());
final long totalNumItemsAttive = iterableAttive.getTotalNumItems();
row.createCell(column++).setCellValue(Optional.ofNullable(totalNumItemsAttive).orElse(Long.valueOf(0)));
row.createCell(column++).setCellValue(Optional.ofNullable(totalNumItems - totalNumItemsAttive).orElse(Long.valueOf(0)));
}
Aggregations