Search in sources :

Example 1 with CMISAuthority

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)));
}
Also used : Color(java.awt.Color) Order(it.cnr.si.opencmis.criteria.Order) ApplicationService(it.cnr.si.cool.jconon.service.application.ApplicationService) Autowired(org.springframework.beans.factory.annotation.Autowired) GroupService(it.cnr.cool.security.service.GroupService) PrintDetailBulk(it.cnr.si.cool.jconon.model.PrintDetailBulk) PDType1Font(org.apache.pdfbox.pdmodel.font.PDType1Font) org.apache.poi.ss.usermodel(org.apache.poi.ss.usermodel) BigDecimal(java.math.BigDecimal) JSONException(org.json.JSONException) CriteriaFactory(it.cnr.si.opencmis.criteria.CriteriaFactory) SimpleXlsReportConfiguration(net.sf.jasperreports.export.SimpleXlsReportConfiguration) NumberStyleFormatter(org.springframework.format.number.NumberStyleFormatter) CoolPropertyIds(it.cnr.cool.cmis.model.CoolPropertyIds) BigInteger(java.math.BigInteger) HttpStatus(org.apache.commons.httpclient.HttpStatus) PrintParameterModel(it.cnr.si.cool.jconon.model.PrintParameterModel) ContentStream(org.apache.chemistry.opencmis.commons.data.ContentStream) PropertyDefinition(org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition) CompetitionFolderService(it.cnr.si.cool.jconon.service.cache.CompetitionFolderService) CMISAuthority(it.cnr.cool.security.service.impl.alfresco.CMISAuthority) PDDocument(org.apache.pdfbox.pdmodel.PDDocument) org.apache.chemistry.opencmis.commons.enums(org.apache.chemistry.opencmis.commons.enums) StandardCharsets(java.nio.charset.StandardCharsets) PropertyDecimalDefinition(org.apache.chemistry.opencmis.commons.definitions.PropertyDecimalDefinition) CMISUser(it.cnr.cool.security.service.impl.alfresco.CMISUser) MailService(it.cnr.cool.mail.MailService) IOUtils(org.apache.commons.io.IOUtils) Stream(java.util.stream.Stream) OperationContextImpl(org.apache.chemistry.opencmis.client.runtime.OperationContextImpl) PDPage(org.apache.pdfbox.pdmodel.PDPage) BarcodeFormat(com.google.zxing.BarcodeFormat) FieldProperty(it.cnr.bulkinfo.BulkInfoImpl.FieldProperty) JsonDataSource(net.sf.jasperreports.engine.data.JsonDataSource) JRXlsExporter(net.sf.jasperreports.engine.export.JRXlsExporter) JRPdfExporter(net.sf.jasperreports.engine.export.JRPdfExporter) CMISService(it.cnr.cool.cmis.service.CMISService) java.util(java.util) MimeTypes(it.cnr.cool.util.MimeTypes) InputStreamResource(net.sf.jasperreports.repo.InputStreamResource) SimpleDateFormat(java.text.SimpleDateFormat) SimpleExporterInput(net.sf.jasperreports.export.SimpleExporterInput) NumberFormat(java.text.NumberFormat) PDPageContentStream(org.apache.pdfbox.pdmodel.PDPageContentStream) PDFont(org.apache.pdfbox.pdmodel.font.PDFont) Value(org.springframework.beans.factory.annotation.Value) GroupsEnum(it.cnr.cool.security.GroupsEnum) Resource(net.sf.jasperreports.repo.Resource) Service(org.springframework.stereotype.Service) AttachmentBean(it.cnr.cool.mail.model.AttachmentBean) StatoDomanda(it.cnr.si.cool.jconon.service.application.ApplicationService.StatoDomanda) StreamSupport(java.util.stream.StreamSupport) Restrictions(it.cnr.si.opencmis.criteria.restrictions.Restrictions) RepositoryService(net.sf.jasperreports.repo.RepositoryService) PropertyDateTimeDefinition(org.apache.chemistry.opencmis.commons.definitions.PropertyDateTimeDefinition) UrlBuilder(org.apache.chemistry.opencmis.commons.impl.UrlBuilder) org.apache.chemistry.opencmis.client.api(org.apache.chemistry.opencmis.client.api) org.apache.poi.hssf.usermodel(org.apache.poi.hssf.usermodel) it.cnr.si.cool.jconon.cmis.model(it.cnr.si.cool.jconon.cmis.model) Pair(it.cnr.cool.util.Pair) com.google.gson(com.google.gson) UserService(it.cnr.cool.security.service.UserService) ReportResource(net.sf.jasperreports.repo.ReportResource) LoggerFactory(org.slf4j.LoggerFactory) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) SimpleOutputStreamExporterOutput(net.sf.jasperreports.export.SimpleOutputStreamExporterOutput) WriterException(com.google.zxing.WriterException) PDImageXObject(org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject) JcononGroups(it.cnr.si.cool.jconon.util.JcononGroups) JSONObject(org.json.JSONObject) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JRGzipVirtualizer(net.sf.jasperreports.engine.fill.JRGzipVirtualizer) ParseException(java.text.ParseException) DateFormat(java.text.DateFormat) PDFTextStripper(org.apache.pdfbox.text.PDFTextStripper) JRDocxExporter(net.sf.jasperreports.engine.export.ooxml.JRDocxExporter) Response(org.apache.chemistry.opencmis.client.bindings.spi.http.Response) ACLService(it.cnr.cool.cmis.service.ACLService) CMISApplicationException(it.cnr.cool.web.scripts.exception.CMISApplicationException) QrCodeUtil(it.cnr.si.cool.jconon.util.QrCodeUtil) StringUtil(it.cnr.cool.util.StringUtil) ACLType(it.cnr.cool.cmis.model.ACLType) Collectors(java.util.stream.Collectors) List(java.util.List) PropertyBooleanDefinition(org.apache.chemistry.opencmis.commons.definitions.PropertyBooleanDefinition) Type(java.lang.reflect.Type) PropertyIds(org.apache.chemistry.opencmis.commons.PropertyIds) BitMatrix(com.google.zxing.common.BitMatrix) CoolUserFactoryException(it.cnr.cool.exception.CoolUserFactoryException) NotImplementedException(org.apache.commons.lang3.NotImplementedException) CmisStreamNotSupportedException(org.apache.chemistry.opencmis.commons.exceptions.CmisStreamNotSupportedException) MatrixToImageWriter(com.google.zxing.client.j2se.MatrixToImageWriter) CMISPropertyIds(it.cnr.si.cool.jconon.util.CMISPropertyIds) ClassPathResource(org.springframework.core.io.ClassPathResource) ContentStreamImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl) ApplicationModel(it.cnr.si.cool.jconon.model.ApplicationModel) NodeVersionService(it.cnr.cool.cmis.service.NodeVersionService) Criteria(it.cnr.si.opencmis.criteria.Criteria) JPEGFactory(org.apache.pdfbox.pdmodel.graphics.image.JPEGFactory) AppendMode(org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode) Util(it.cnr.cool.rest.util.Util) net.sf.jasperreports.engine(net.sf.jasperreports.engine) CacheRepository(it.cnr.si.cool.jconon.repository.CacheRepository) Logger(org.slf4j.Logger) BindingSession(org.apache.chemistry.opencmis.client.bindings.spi.BindingSession) BulkInfo(it.cnr.bulkinfo.BulkInfo) ClientMessageException(it.cnr.cool.web.scripts.exception.ClientMessageException) Output(org.apache.chemistry.opencmis.client.bindings.spi.http.Output) Code39Writer(com.google.zxing.oned.Code39Writer) ApplicationContext(org.springframework.context.ApplicationContext) JRPdfExporterParameter(net.sf.jasperreports.engine.export.JRPdfExporterParameter) PDRectangle(org.apache.pdfbox.pdmodel.common.PDRectangle) EmailMessage(it.cnr.cool.mail.model.EmailMessage) java.io(java.io) FieldPropertySet(it.cnr.bulkinfo.BulkInfoImpl.FieldPropertySet) BulkInfoCoolService(it.cnr.cool.service.BulkInfoCoolService) SimpleDocxReportConfiguration(net.sf.jasperreports.export.SimpleDocxReportConfiguration) Bean(org.springframework.context.annotation.Bean) I18nService(it.cnr.cool.service.I18nService) StringUtils(org.springframework.util.StringUtils) CMISAuthority(it.cnr.cool.security.service.impl.alfresco.CMISAuthority) Criteria(it.cnr.si.opencmis.criteria.Criteria) BigInteger(java.math.BigInteger) Pair(it.cnr.cool.util.Pair)

Aggregations

com.google.gson (com.google.gson)1 BarcodeFormat (com.google.zxing.BarcodeFormat)1 WriterException (com.google.zxing.WriterException)1 MatrixToImageWriter (com.google.zxing.client.j2se.MatrixToImageWriter)1 BitMatrix (com.google.zxing.common.BitMatrix)1 Code39Writer (com.google.zxing.oned.Code39Writer)1 BulkInfo (it.cnr.bulkinfo.BulkInfo)1 FieldProperty (it.cnr.bulkinfo.BulkInfoImpl.FieldProperty)1 FieldPropertySet (it.cnr.bulkinfo.BulkInfoImpl.FieldPropertySet)1 ACLType (it.cnr.cool.cmis.model.ACLType)1 CoolPropertyIds (it.cnr.cool.cmis.model.CoolPropertyIds)1 ACLService (it.cnr.cool.cmis.service.ACLService)1 CMISService (it.cnr.cool.cmis.service.CMISService)1 NodeVersionService (it.cnr.cool.cmis.service.NodeVersionService)1 CoolUserFactoryException (it.cnr.cool.exception.CoolUserFactoryException)1 MailService (it.cnr.cool.mail.MailService)1 AttachmentBean (it.cnr.cool.mail.model.AttachmentBean)1 EmailMessage (it.cnr.cool.mail.model.EmailMessage)1 Util (it.cnr.cool.rest.util.Util)1 GroupsEnum (it.cnr.cool.security.GroupsEnum)1