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);
}
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;
}
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);
}
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;
}
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;
}
Aggregations