Package org.fenixedu.academic.domain.serviceRequests

Examples of org.fenixedu.academic.domain.serviceRequests.RectorateSubmissionBatch


        return mapping.findForward("index");
    }

    public ActionForward viewBatch(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) {
        RectorateSubmissionBatch batch = getDomainObject(request, "batchOid");
        Set<String> actions = new HashSet<String>();
        Set<String> confirmActions = new HashSet<String>();
        switch (batch.getState()) {
        case UNSENT:
            if (!batch.getDocumentRequestSet().isEmpty()) {
                confirmActions.add("closeBatch");
            }
            break;
        case CLOSED:
            actions.add("generateMetadataForRegistry");
            actions.add("generateMetadataForDiplomas");
            actions.add("zipDocuments");
            confirmActions.add("markAsSent");
            break;
        case SENT:
            actions.add("generateMetadataForDiplomas");
            if (batch.allDocumentsReceived()) {
                confirmActions.add("markAsReceived");
            }
            break;
        case RECEIVED:
            break;
        }
        request.setAttribute("batch", batch);
        // Filter out canceled document requests, ticket: #248539
        Set<AcademicServiceRequest> requests = new HashSet<AcademicServiceRequest>();
        for (AcademicServiceRequest docRequest : batch.getDocumentRequestSet()) {
            if (!docRequest.isCancelled() && !docRequest.isRejected()) {
                requests.add(docRequest);
            }
        }
        request.setAttribute("requests", requests);
View Full Code Here


    }

    @Atomic
    public ActionForward closeBatch(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) {
        RectorateSubmissionBatch batch = getDomainObject(request, "batchOid");
        batch.closeBatch();
        return viewBatch(mapping, actionForm, request, response);
    }
View Full Code Here

    }

    @Atomic
    public ActionForward markAsSent(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) {
        RectorateSubmissionBatch batch = getDomainObject(request, "batchOid");
        batch.markAsSent();
        return viewBatch(mapping, actionForm, request, response);
    }
View Full Code Here

    }

    @Atomic
    public ActionForward markAsReceived(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) {
        RectorateSubmissionBatch batch = getDomainObject(request, "batchOid");
        batch.markAsReceived();
        return viewBatch(mapping, actionForm, request, response);
    }
View Full Code Here

        return viewBatch(mapping, actionForm, request, response);
    }

    public ActionForward generateMetadataForRegistry(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) {
        RectorateSubmissionBatch batch = getDomainObject(request, "batchOid");
        Set<AcademicServiceRequest> docs = new HashSet<AcademicServiceRequest>();
        for (AcademicServiceRequest document : batch.getDocumentRequestSet()) {
            // Filter out canceled document requests, ticket: #248539
            if (!document.isDiploma() && !document.isCancelled() && !document.isRejected()) {
                docs.add(document);
            }
        }
View Full Code Here

        return generateMetadata(docs, "registos-", request, response);
    }

    public ActionForward generateMetadataForDiplomas(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) {
        RectorateSubmissionBatch batch = getDomainObject(request, "batchOid");
        Set<AcademicServiceRequest> docs = new HashSet<AcademicServiceRequest>();
        for (AcademicServiceRequest document : batch.getDocumentRequestSet()) {
            // Filter out canceled document requests, ticket: #248539
            if (document.isDiploma() && !document.isCancelled() && !document.isRejected()) {
                docs.add(document);
            }
        }
View Full Code Here

    }

    public ActionForward zipDocuments(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) {
        try {
            RectorateSubmissionBatch batch = getDomainObject(request, "batchOid");
            Set<AcademicServiceRequest> requestsToZip = new HashSet<AcademicServiceRequest>();
            for (AcademicServiceRequest document : batch.getDocumentRequestSet()) {
                // Filter out canceled document requests, ticket: #248539
                if (!document.isDiploma() && !document.isCancelled() && !document.isRejected()) {
                    requestsToZip.add(document);
                }
            }
            if (!requestsToZip.isEmpty()) {
                ByteArrayOutputStream bout = new ByteArrayOutputStream();
                ZipOutputStream zip = new ZipOutputStream(bout);
                for (AcademicServiceRequest document : requestsToZip) {
                    zip.putNextEntry(new ZipEntry(document.getLastGeneratedDocument().getFilename()));
                    zip.write(document.getLastGeneratedDocument().getContents());
                    zip.closeEntry();
                }
                zip.close();
                response.setContentType("application/zip");
                response.addHeader("Content-Disposition", "attachment; filename=documentos-" + batch.getRange() + ".zip");
                ServletOutputStream writer = response.getOutputStream();
                writer.write(bout.toByteArray());
                writer.flush();
                writer.close();
                response.flushBuffer();
                return null;
            } else {
                addActionMessage(request, "error.rectorateSubmission.noDocumentsToZip");
                request.setAttribute("batchOid", batch.getExternalId());
                return viewBatch(mapping, actionForm, request, response);
            }
        } catch (IOException e) {
            throw new DomainException("error.rectorateSubmission.errorGeneratingMetadata", e);
        }
View Full Code Here

        AcademicServiceRequest document = getDomainObject(request, "academicServiceRequestOid");
        request.setAttribute("batchOid", document.getRectorateSubmissionBatch().getExternalId());
        if (document.isPiggyBackedOnRegistry()) {
            addActionMessage(request, "error.rectorateSubmissionBatch.cannotDelayPiggyBackedDocument");
        } else {
            RectorateSubmissionBatch target = document.getRectorateSubmissionBatch();
            while (!target.isUnsent()) {
                target = target.getNextRectorateSubmissionBatch();
            }
            if (document.isRegistryDiploma()) {
                IRegistryDiplomaRequest registry = (IRegistryDiplomaRequest) document;
                ((AcademicServiceRequest) registry.getDiplomaSupplement()).setRectorateSubmissionBatch(target);
            }
View Full Code Here

        return requests;
    }

    public ActionForward viewBatch(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) {
        RectorateSubmissionBatch batch = getDomainObject(request, "batchOid");
        Set<String> actions = new HashSet<String>();

        actions.add("generateMetadataForRegistry");
        actions.add("zipDocuments");

        request.setAttribute("batch", batch);

        Set<AcademicServiceRequest> requests = getRelevantDocuments(batch.getDocumentRequestSet());

        request.setAttribute("requests", requests);
        request.setAttribute("actions", actions);
        return mapping.findForward("viewBatch");
    }
View Full Code Here

    }

    public ActionForward zipDocuments(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) {

        RectorateSubmissionBatch batch = getDomainObject(request, "batchOid");
        Set<AcademicServiceRequest> requestsToZip = getRelevantDocuments(batch.getDocumentRequestSet());

        if (!requestsToZip.isEmpty()) {
            ZipUtils zipUtils = new ZipUtils();
            zipUtils.createAndFlushArchive(requestsToZip, response, batch);
            return null;
        }
        addActionMessage(request, "error.rectorateSubmission.noDocumentsToZip");
        request.setAttribute("batchOid", batch.getExternalId());
        return viewBatch(mapping, actionForm, request, response);
    }
View Full Code Here

TOP

Related Classes of org.fenixedu.academic.domain.serviceRequests.RectorateSubmissionBatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.