Search in sources :

Example 6 with InquiryForm

use of org.kuali.kfs.kns.web.struts.form.InquiryForm in project cu-kfs by CU-CommunityApps.

the class KualiInquiryAction method downloadAttachment.

/**
 * Downloads the attachment to the user's browser
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 * @throws Exception
 */
public ActionForward downloadAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    InquiryForm inquiryForm = (InquiryForm) form;
    int line = getSelectedLine(request);
    BusinessObject bo = retrieveBOFromInquirable(inquiryForm);
    if (line < 0) {
        if (bo instanceof PersistableAttachment) {
            PersistableAttachment attachment = (PersistableAttachment) bo;
            if (StringUtils.isNotBlank(attachment.getFileName()) && attachment.getAttachmentContent() != null) {
                streamToResponse(attachment.getAttachmentContent(), attachment.getFileName(), attachment.getContentType(), response);
            }
        }
    } else {
        if (bo instanceof PersistableAttachmentList) {
            PersistableAttachmentList<PersistableAttachment> attachmentsBo = (PersistableAttachmentList<PersistableAttachment>) bo;
            if (CollectionUtils.isEmpty(attachmentsBo.getAttachments())) {
                return null;
            }
            List<? extends PersistableAttachment> attachments = attachmentsBo.getAttachments();
            if (CollectionUtils.isNotEmpty(attachments) && attachments.size() > line) {
                PersistableAttachment attachment = attachmentsBo.getAttachments().get(line);
                streamToResponse(attachment.getAttachmentContent(), attachment.getFileName(), attachment.getContentType(), response);
            }
        }
    }
    return null;
}
Also used : PersistableAttachment(org.kuali.kfs.krad.bo.PersistableAttachment) PersistableAttachmentList(org.kuali.kfs.krad.bo.PersistableAttachmentList) BusinessObject(org.kuali.kfs.krad.bo.BusinessObject) InquiryForm(org.kuali.kfs.kns.web.struts.form.InquiryForm)

Example 7 with InquiryForm

use of org.kuali.kfs.kns.web.struts.form.InquiryForm in project cu-kfs by CU-CommunityApps.

the class KualiInquiryAction method toggleInactiveRecordDisplay.

/**
 * Turns on (or off) the inactive record display for a maintenance collection.
 */
public ActionForward toggleInactiveRecordDisplay(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    InquiryForm inquiryForm = (InquiryForm) form;
    if (inquiryForm.getBusinessObjectClassName() == null) {
        LOG.error("Business object name not given.");
        throw new RuntimeException("Business object name not given.");
    }
    BusinessObject bo = retrieveBOFromInquirable(inquiryForm);
    checkBO(bo);
    Inquirable kualiInquirable = inquiryForm.getInquirable();
    // ////////////////////////////
    String collectionName = extractCollectionName(request, KRADConstants.TOGGLE_INACTIVE_METHOD);
    if (collectionName == null) {
        LOG.error("Unable to get find collection name in request.");
        throw new RuntimeException("Unable to get find collection class in request.");
    }
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    boolean showInactive = Boolean.parseBoolean(StringUtils.substringBetween(parameterName, KRADConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL, "."));
    kualiInquirable.setShowInactiveRecords(collectionName, showInactive);
    // ////////////////////////////
    populateSections(mapping, request, inquiryForm, bo);
    // toggling the display to be visible again, re-open any previously closed inactive records
    if (showInactive) {
        WebUtils.reopenInactiveRecords(inquiryForm.getSections(), inquiryForm.getTabStates(), collectionName);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : Inquirable(org.kuali.kfs.kns.inquiry.Inquirable) BusinessObject(org.kuali.kfs.krad.bo.BusinessObject) InquiryForm(org.kuali.kfs.kns.web.struts.form.InquiryForm)

Example 8 with InquiryForm

use of org.kuali.kfs.kns.web.struts.form.InquiryForm in project cu-kfs by CU-CommunityApps.

the class KualiInquiryAction method start.

/**
 * Gets an inquirable impl from the impl service name parameter. Then calls lookup service to retrieve the record
 * from the key/value parameters. Finally gets a list of Rows from the inquirable
 */
// CU Customization: Allow the KIM module to return custom Person and Role inquiry URL redirects.
public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    InquiryForm inquiryForm = (InquiryForm) form;
    if (inquiryForm.getBusinessObjectClassName() == null) {
        LOG.error("Business object name not given.");
        throw new RuntimeException("Business object name not given.");
    }
    Class boClass = Class.forName(inquiryForm.getBusinessObjectClassName());
    ModuleService responsibleModuleService = KRADServiceLocatorWeb.getKualiModuleService().getResponsibleModuleService(boClass);
    if (responsibleModuleService != null && responsibleModuleService.isExternalizable(boClass)) {
        String redirectUrl = responsibleModuleService.getExternalizableBusinessObjectInquiryUrl(boClass, request.getParameterMap());
        ActionForward redirectingActionForward = new RedirectingActionForward(redirectUrl);
        redirectingActionForward.setModule("/");
        return redirectingActionForward;
    } else if (responsibleModuleService instanceof KimModuleService) {
        KimModuleService kimModuleService = (KimModuleService) responsibleModuleService;
        if (kimModuleService.hasCustomInquiryUrl(boClass)) {
            String baseInquiryUrl = kimModuleService.getInquiryUrl(boClass);
            Map<String, String> urlParameters = kimModuleService.getUrlParameters(boClass.getName(), request.getParameterMap());
            String redirectUrl = UrlFactory.parameterizeUrl(baseInquiryUrl, urlParameters);
            ActionForward redirectingActionForward = new RedirectingActionForward(redirectUrl);
            redirectingActionForward.setModule("/");
            return redirectingActionForward;
        }
    }
    return continueWithInquiry(mapping, form, request, response);
}
Also used : KimModuleService(org.kuali.kfs.kim.service.impl.KimModuleService) ModuleService(org.kuali.kfs.krad.service.ModuleService) RedirectingActionForward(org.apache.struts.action.RedirectingActionForward) KimModuleService(org.kuali.kfs.kim.service.impl.KimModuleService) Map(java.util.Map) InquiryForm(org.kuali.kfs.kns.web.struts.form.InquiryForm) ActionForward(org.apache.struts.action.ActionForward) RedirectingActionForward(org.apache.struts.action.RedirectingActionForward)

Example 9 with InquiryForm

use of org.kuali.kfs.kns.web.struts.form.InquiryForm in project cu-kfs by CU-CommunityApps.

the class KualiInquiryAction method export.

/**
 * Handles exporting the BusinessObject for this Inquiry to XML if it has a custom XML exporter available.
 */
public ActionForward export(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    InquiryForm inquiryForm = (InquiryForm) form;
    if (inquiryForm.isCanExport()) {
        BusinessObject bo = retrieveBOFromInquirable(inquiryForm);
        checkBO(bo);
        if (bo != null) {
            BusinessObjectEntry businessObjectEntry = KNSServiceLocator.getBusinessObjectDictionaryService().getBusinessObjectEntry(inquiryForm.getBusinessObjectClassName());
            Class<? extends Exporter> exporterClass = businessObjectEntry.getExporterClass();
            if (exporterClass != null) {
                Exporter exporter = exporterClass.newInstance();
                response.setContentType(KRADConstants.XML_MIME_TYPE);
                response.setHeader("Content-disposition", "attachment; filename=export.xml");
                exporter.export(businessObjectEntry.getBusinessObjectClass(), Collections.singletonList(bo), KRADConstants.XML_FORMAT, response.getOutputStream());
            }
        } else {
            // show the empty section with error
            populateSections(mapping, request, inquiryForm, bo);
            return mapping.findForward(KFSConstants.MAPPING_BASIC);
        }
    }
    return null;
}
Also used : BusinessObjectEntry(org.kuali.kfs.kns.datadictionary.BusinessObjectEntry) Exporter(org.kuali.kfs.krad.bo.Exporter) BusinessObject(org.kuali.kfs.krad.bo.BusinessObject) InquiryForm(org.kuali.kfs.kns.web.struts.form.InquiryForm)

Aggregations

InquiryForm (org.kuali.kfs.kns.web.struts.form.InquiryForm)9 BusinessObject (org.kuali.kfs.krad.bo.BusinessObject)8 Method (java.lang.reflect.Method)1 Map (java.util.Map)1 ActionForward (org.apache.struts.action.ActionForward)1 RedirectingActionForward (org.apache.struts.action.RedirectingActionForward)1 KimModuleService (org.kuali.kfs.kim.service.impl.KimModuleService)1 BusinessObjectEntry (org.kuali.kfs.kns.datadictionary.BusinessObjectEntry)1 Inquirable (org.kuali.kfs.kns.inquiry.Inquirable)1 Exporter (org.kuali.kfs.krad.bo.Exporter)1 PersistableAttachment (org.kuali.kfs.krad.bo.PersistableAttachment)1 PersistableAttachmentList (org.kuali.kfs.krad.bo.PersistableAttachmentList)1 ModuleService (org.kuali.kfs.krad.service.ModuleService)1