Search in sources :

Example 1 with DetailedException

use of it.cnr.jada.DetailedException in project sigla-main by consiglionazionaledellericerche.

the class CRUDMissioneBP method initializeModelForEditAllegati.

@Override
public OggettoBulk initializeModelForEditAllegati(ActionContext actioncontext, OggettoBulk oggettobulk) throws BusinessProcessException {
    MissioneBulk allegatoParentBulk = (MissioneBulk) oggettobulk;
    try {
        if (allegatoParentBulk.getIdRimborsoMissione() != null) {
            List<StorageObject> files = missioniCMISService.getFilesOrdineMissione(allegatoParentBulk);
            if (files != null) {
                for (StorageObject storageObject : files) {
                    if (missioniCMISService.hasAspect(storageObject, StoragePropertyNames.SYS_ARCHIVED.value()))
                        continue;
                    if (excludeChild(storageObject))
                        continue;
                    if (storageObject.getPropertyValue(StoragePropertyNames.BASE_TYPE_ID.value()).equals(StoragePropertyNames.CMIS_DOCUMENT.value())) {
                        AllegatoMissioneBulk allegato = (AllegatoMissioneBulk) Introspector.newInstance(getAllegatoClass(), storageObject);
                        allegato.setContentType(storageObject.<String>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
                        allegato.setNome(storageObject.getPropertyValue(StoragePropertyNames.NAME.value()));
                        allegato.setDescrizione(storageObject.getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
                        allegato.setTitolo(storageObject.getPropertyValue(StoragePropertyNames.TITLE.value()));
                        completeAllegato(allegato, storageObject);
                        allegato.setCrudStatus(OggettoBulk.NORMAL);
                        allegatoParentBulk.addToArchivioAllegati(allegato);
                    }
                }
            }
            List<StorageObject> filesRimborso = missioniCMISService.getFilesRimborsoMissione(allegatoParentBulk);
            if (filesRimborso != null) {
                for (StorageObject storageObject : filesRimborso) {
                    if (missioniCMISService.hasAspect(storageObject, StoragePropertyNames.SYS_ARCHIVED.value()))
                        continue;
                    if (excludeChild(storageObject))
                        continue;
                    recuperoAllegatiDettaglioMissioneSigla(allegatoParentBulk, storageObject);
                    if (storageObject.getPropertyValue(StoragePropertyNames.BASE_TYPE_ID.value()).equals(StoragePropertyNames.CMIS_DOCUMENT.value())) {
                        AllegatoMissioneBulk allegato = (AllegatoMissioneBulk) Introspector.newInstance(getAllegatoClass(), storageObject);
                        allegato.setContentType(storageObject.<String>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
                        allegato.setNome(storageObject.getPropertyValue(StoragePropertyNames.NAME.value()));
                        allegato.setDescrizione(storageObject.getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
                        allegato.setTitolo(storageObject.getPropertyValue(StoragePropertyNames.TITLE.value()));
                        completeAllegato(allegato, storageObject);
                        allegato.setCrudStatus(OggettoBulk.NORMAL);
                        allegatoParentBulk.addToArchivioAllegati(allegato);
                    }
                }
            }
            if (allegatoParentBulk.getIdFlusso() != null) {
                StorageObject storageObject = missioniCMISService.recuperoFlows(allegatoParentBulk.getIdFlusso());
                if (storageObject != null) {
                    AllegatoMissioneBulk allegato = (AllegatoMissioneBulk) Introspector.newInstance(getAllegatoClass(), storageObject);
                    allegato.setContentType(storageObject.<String>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
                    allegato.setNome(storageObject.getPropertyValue(StoragePropertyNames.NAME.value()));
                    allegato.setDescrizione(storageObject.getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
                    allegato.setTitolo(storageObject.getPropertyValue(StoragePropertyNames.TITLE.value()));
                    allegato.setAspectName(AllegatoMissioneBulk.FLUSSO_RIMBORSO);
                    allegato.setCrudStatus(OggettoBulk.NORMAL);
                    allegatoParentBulk.addToArchivioAllegati(allegato);
                }
            }
            if (allegatoParentBulk.getIdFlussoOrdineMissione() != null) {
                StorageObject storageObject = missioniCMISService.recuperoFlows(allegatoParentBulk.getIdFlussoOrdineMissione());
                if (storageObject != null) {
                    AllegatoMissioneBulk allegato = (AllegatoMissioneBulk) Introspector.newInstance(getAllegatoClass(), storageObject);
                    allegato.setContentType(storageObject.<String>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
                    allegato.setNome(storageObject.getPropertyValue(StoragePropertyNames.NAME.value()));
                    allegato.setDescrizione(storageObject.getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
                    allegato.setTitolo(storageObject.getPropertyValue(StoragePropertyNames.TITLE.value()));
                    allegato.setAspectName(AllegatoMissioneBulk.FLUSSO_ORDINE);
                    allegato.setCrudStatus(OggettoBulk.NORMAL);
                    allegatoParentBulk.addToArchivioAllegati(allegato);
                }
            }
        } else {
            List<StorageObject> files = missioniCMISService.getFilesMissioneSigla(allegatoParentBulk);
            if (files != null) {
                for (StorageObject storageObject : files) {
                    if (missioniCMISService.hasAspect(storageObject, StoragePropertyNames.SYS_ARCHIVED.value()))
                        continue;
                    if (excludeChild(storageObject))
                        continue;
                    recuperoAllegatiDettaglioMissioneSigla(allegatoParentBulk, storageObject);
                    if (storageObject.getPropertyValue(StoragePropertyNames.BASE_TYPE_ID.value()).equals(StoragePropertyNames.CMIS_DOCUMENT.value())) {
                        AllegatoMissioneBulk allegato = (AllegatoMissioneBulk) Introspector.newInstance(getAllegatoClass(), storageObject);
                        allegato.setContentType(storageObject.<String>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
                        allegato.setNome(storageObject.getPropertyValue(StoragePropertyNames.NAME.value()));
                        allegato.setDescrizione(storageObject.getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
                        allegato.setTitolo(storageObject.getPropertyValue(StoragePropertyNames.TITLE.value()));
                        completeAllegato(allegato, storageObject);
                        allegato.setCrudStatus(OggettoBulk.NORMAL);
                        allegatoParentBulk.addToArchivioAllegati(allegato);
                    }
                }
            }
        }
    } catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | DetailedException e) {
        throw handleException(e);
    }
    return oggettobulk;
}
Also used : DetailedException(it.cnr.jada.DetailedException) StorageObject(it.cnr.si.spring.storage.StorageObject) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with DetailedException

use of it.cnr.jada.DetailedException in project sigla-main by consiglionazionaledellericerche.

the class ArchiviaStampaPdgVariazioneBP method initializeModelForEdit.

@Override
public OggettoBulk initializeModelForEdit(ActionContext actioncontext, OggettoBulk oggettobulk) throws BusinessProcessException {
    final ArchiviaStampaPdgVariazioneBulk archiviaStampaPdgVariazioneBulk = Optional.ofNullable(oggettobulk).filter(ArchiviaStampaPdgVariazioneBulk.class::isInstance).map(ArchiviaStampaPdgVariazioneBulk.class::cast).orElseGet(() -> {
        ArchiviaStampaPdgVariazioneBulk archiviaStampaPdgVariazione = new ArchiviaStampaPdgVariazioneBulk();
        archiviaStampaPdgVariazione.setToBeUpdated();
        archiviaStampaPdgVariazione.setPdg_variazioneForPrint((Pdg_variazioneBulk) oggettobulk);
        return archiviaStampaPdgVariazione;
    });
    try {
        final PdgVariazioneDocument pdgVariazioneDocument = Optional.ofNullable(archiviaStampaPdgVariazioneBulk.getPdgVariazioneDocument()).orElseGet(() -> {
            return pdgVariazioniService.getPdgVariazioneDocument(archiviaStampaPdgVariazioneBulk);
        });
        archiviaStampaPdgVariazioneBulk.setPdgVariazioneDocument(pdgVariazioneDocument);
        if (pdgVariazioneDocument.isSignedDocument())
            archiviaStampaPdgVariazioneBulk.setTiSigned(ArchiviaStampaPdgVariazioneBulk.VIEW_SIGNED);
        else
            archiviaStampaPdgVariazioneBulk.setTiSigned(ArchiviaStampaPdgVariazioneBulk.VIEW_NOT_SIGNED);
        archiviaStampaPdgVariazioneBulk.getArchivioAllegati().clear();
        archiviaStampaPdgVariazioneBulk.getArchivioAllegati().addAll(Optional.ofNullable(getPath(archiviaStampaPdgVariazioneBulk)).map(path -> pdgVariazioniService.getStorageObjectByPath(path)).map(storageObject -> pdgVariazioniService.getChildren(storageObject.getKey())).map(storageObjects -> storageObjects.stream()).orElse(Stream.empty()).filter(storageObject -> !pdgVariazioniService.hasAspect(storageObject, StoragePropertyNames.SYS_ARCHIVED.value())).filter(storageObject -> !pdgVariazioneDocument.getStorageObject().getKey().equals(storageObject.getKey())).map(storageObject -> {
            AllegatoPdGVariazioneDocumentBulk allegato = AllegatoPdGVariazioneDocumentBulk.construct(storageObject);
            allegato.setContentType(storageObject.<String>getPropertyValue(StoragePropertyNames.CONTENT_STREAM_MIME_TYPE.value()));
            allegato.setNome(storageObject.<String>getPropertyValue(StoragePropertyNames.NAME.value()));
            allegato.setDescrizione(storageObject.<String>getPropertyValue(StoragePropertyNames.DESCRIPTION.value()));
            allegato.setTitolo(storageObject.<String>getPropertyValue(StoragePropertyNames.TITLE.value()));
            allegato.setCrudStatus(OggettoBulk.NORMAL);
            return allegato;
        }).collect(Collectors.toList()));
    } catch (DetailedException e) {
        handleException(e);
    }
    return archiviaStampaPdgVariazioneBulk;
}
Also used : HttpActionContext(it.cnr.jada.action.HttpActionContext) UploadedFile(it.cnr.jada.util.upload.UploadedFile) OggettoBulk(it.cnr.jada.bulk.OggettoBulk) java.util(java.util) PdGVariazioniComponentSession(it.cnr.contab.pdg00.ejb.PdGVariazioniComponentSession) AllegatoPdGVariazioneDocumentBulk(it.cnr.contab.pdg00.bulk.storage.AllegatoPdGVariazioneDocumentBulk) ServletException(javax.servlet.ServletException) Utility(it.cnr.contab.util.Utility) PdgVariazioneDocument(it.cnr.contab.pdg00.bulk.storage.PdgVariazioneDocument) SIGLAStoragePropertyNames(it.cnr.contab.util.SIGLAStoragePropertyNames) ActionContext(it.cnr.jada.action.ActionContext) StorageException(it.cnr.si.spring.storage.StorageException) SimpleDetailCRUDController(it.cnr.jada.util.action.SimpleDetailCRUDController) SimpleCRUDBP(it.cnr.jada.util.action.SimpleCRUDBP) BigInteger(java.math.BigInteger) RemoteIterator(it.cnr.jada.util.RemoteIterator) PrintService(it.cnr.contab.reports.service.PrintService) ValidationException(it.cnr.jada.bulk.ValidationException) Pdg_variazioneBulk(it.cnr.contab.pdg00.bulk.Pdg_variazioneBulk) OutputStream(java.io.OutputStream) ApplicationException(it.cnr.jada.comp.ApplicationException) StorageObject(it.cnr.si.spring.storage.StorageObject) Print_spoolerBulk(it.cnr.contab.reports.bulk.Print_spoolerBulk) PdgVariazioniService(it.cnr.contab.pdg00.service.PdgVariazioniService) IOException(java.io.IOException) StorePath(it.cnr.contab.spring.service.StorePath) FileInputStream(java.io.FileInputStream) DetailedException(it.cnr.jada.DetailedException) EJBCommonServices(it.cnr.jada.util.ejb.EJBCommonServices) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) BusinessProcessException(it.cnr.jada.action.BusinessProcessException) Report(it.cnr.contab.reports.bulk.Report) StorageDriver(it.cnr.si.spring.storage.StorageDriver) DetailedRuntimeException(it.cnr.jada.DetailedRuntimeException) Stream(java.util.stream.Stream) ArchiviaStampaPdgVariazioneBulk(it.cnr.contab.pdg00.bulk.ArchiviaStampaPdgVariazioneBulk) StoragePropertyNames(it.cnr.si.spring.storage.config.StoragePropertyNames) ComponentException(it.cnr.jada.comp.ComponentException) SpringUtil(it.cnr.contab.service.SpringUtil) CompoundFindClause(it.cnr.jada.persistency.sql.CompoundFindClause) InputStream(java.io.InputStream) DetailedException(it.cnr.jada.DetailedException) PdgVariazioneDocument(it.cnr.contab.pdg00.bulk.storage.PdgVariazioneDocument) AllegatoPdGVariazioneDocumentBulk(it.cnr.contab.pdg00.bulk.storage.AllegatoPdGVariazioneDocumentBulk) ArchiviaStampaPdgVariazioneBulk(it.cnr.contab.pdg00.bulk.ArchiviaStampaPdgVariazioneBulk)

Aggregations

DetailedException (it.cnr.jada.DetailedException)2 StorageObject (it.cnr.si.spring.storage.StorageObject)2 ArchiviaStampaPdgVariazioneBulk (it.cnr.contab.pdg00.bulk.ArchiviaStampaPdgVariazioneBulk)1 Pdg_variazioneBulk (it.cnr.contab.pdg00.bulk.Pdg_variazioneBulk)1 AllegatoPdGVariazioneDocumentBulk (it.cnr.contab.pdg00.bulk.storage.AllegatoPdGVariazioneDocumentBulk)1 PdgVariazioneDocument (it.cnr.contab.pdg00.bulk.storage.PdgVariazioneDocument)1 PdGVariazioniComponentSession (it.cnr.contab.pdg00.ejb.PdGVariazioniComponentSession)1 PdgVariazioniService (it.cnr.contab.pdg00.service.PdgVariazioniService)1 Print_spoolerBulk (it.cnr.contab.reports.bulk.Print_spoolerBulk)1 Report (it.cnr.contab.reports.bulk.Report)1 PrintService (it.cnr.contab.reports.service.PrintService)1 SpringUtil (it.cnr.contab.service.SpringUtil)1 StorePath (it.cnr.contab.spring.service.StorePath)1 SIGLAStoragePropertyNames (it.cnr.contab.util.SIGLAStoragePropertyNames)1 Utility (it.cnr.contab.util.Utility)1 DetailedRuntimeException (it.cnr.jada.DetailedRuntimeException)1 ActionContext (it.cnr.jada.action.ActionContext)1 BusinessProcessException (it.cnr.jada.action.BusinessProcessException)1 HttpActionContext (it.cnr.jada.action.HttpActionContext)1 OggettoBulk (it.cnr.jada.bulk.OggettoBulk)1