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