Search in sources :

Example 11 with BusinessObject

use of org.kuali.kfs.krad.bo.BusinessObject in project cu-kfs by CU-CommunityApps.

the class KualiInquiryAction method hideAllTabs.

@Override
public ActionForward hideAllTabs(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    // KULRICE-2852: Overrides hideAllTabs() so that it also calls the populateSections() method.
    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);
    populateSections(mapping, request, inquiryForm, bo);
    return super.hideAllTabs(mapping, form, request, response);
}
Also used : BusinessObject(org.kuali.kfs.krad.bo.BusinessObject) InquiryForm(org.kuali.kfs.kns.web.struts.form.InquiryForm)

Example 12 with BusinessObject

use of org.kuali.kfs.krad.bo.BusinessObject 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 13 with BusinessObject

use of org.kuali.kfs.krad.bo.BusinessObject 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 14 with BusinessObject

use of org.kuali.kfs.krad.bo.BusinessObject in project cu-kfs by CU-CommunityApps.

the class KualiInquiryAction method retrieveBOFromInquirable.

protected BusinessObject retrieveBOFromInquirable(InquiryForm inquiryForm) {
    Inquirable kualiInquirable = inquiryForm.getInquirable();
    // retrieve the business object
    BusinessObject bo = kualiInquirable.getBusinessObject(inquiryForm.retrieveInquiryDecryptedPrimaryKeys());
    if (bo == null) {
        LOG.error("No records found in inquiry action.");
        GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, KFSKeyConstants.ERROR_INQUIRY);
    }
    return bo;
}
Also used : Inquirable(org.kuali.kfs.kns.inquiry.Inquirable) BusinessObject(org.kuali.kfs.krad.bo.BusinessObject)

Example 15 with BusinessObject

use of org.kuali.kfs.krad.bo.BusinessObject 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

BusinessObject (org.kuali.kfs.krad.bo.BusinessObject)19 InquiryForm (org.kuali.kfs.kns.web.struts.form.InquiryForm)8 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Inquirable (org.kuali.kfs.kns.inquiry.Inquirable)2 DisbursementVoucherBatchDefault (com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchDefault)1 CuDisbursementPayee (edu.cornell.kfs.fp.businessobject.CuDisbursementPayee)1 Method (java.lang.reflect.Method)1 Map (java.util.Map)1 Account (org.kuali.kfs.coa.businessobject.Account)1 DocumentDictionaryService (org.kuali.kfs.datadictionary.legacy.DocumentDictionaryService)1 DisbursementPayee (org.kuali.kfs.fp.businessobject.DisbursementPayee)1 DocumentAttributeString (org.kuali.kfs.kew.api.document.attribute.DocumentAttributeString)1 WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)1 BusinessObjectEntry (org.kuali.kfs.kns.datadictionary.BusinessObjectEntry)1 DocumentEntry (org.kuali.kfs.kns.datadictionary.DocumentEntry)1 LookupableHelperService (org.kuali.kfs.kns.lookup.LookupableHelperService)1 Field (org.kuali.kfs.kns.web.ui.Field)1 Row (org.kuali.kfs.kns.web.ui.Row)1 Exporter (org.kuali.kfs.krad.bo.Exporter)1