use of org.mifos.reports.pentaho.params.PentahoInputParameter in project head by mifos.
the class PentahoParamParser method parseInputParameter.
private PentahoInputParameter parseInputParameter(PlainParameter paramDefEntry) {
PentahoInputParameter result = new PentahoInputParameter();
String defaultValue = String.valueOf(paramDefEntry.getDefaultValue());
result.setValue(defaultValue);
return result;
}
use of org.mifos.reports.pentaho.params.PentahoInputParameter in project head by mifos.
the class PentahoReportsServiceImpl method getLogoParameterForReport.
private PentahoInputParameter getLogoParameterForReport() throws IOException {
ConfigurationLocator configurationLocator = new ConfigurationLocator();
org.springframework.core.io.Resource logo = configurationLocator.getUploadedMifosLogo();
PentahoInputParameter logoParameter = new PentahoInputParameter();
logoParameter.setParamName("mifosLogoPath");
logoParameter.setLabelName("mifosLogoPath");
String logoPath = logo.getFile().getAbsolutePath();
logoParameter.setValue(logoPath);
return logoParameter;
}
use of org.mifos.reports.pentaho.params.PentahoInputParameter in project head by mifos.
the class PentahoReportsServiceIntegrationTest method testGetAdminReport.
@Test
public void testGetAdminReport() throws Exception {
String adminDocumentUploadPath = viewOrganizationSettingsServiceFacade.getAdminDocumentStorageDirectory();
String adminDocumentPath = "IntegrationTest_Loan_template.prpt";
File adminDocumentSrc = new File(this.getClass().getResource("/Loan_template.prpt").toString().replace("file:", ""));
File adminDocumentDst = new File(adminDocumentUploadPath + "/" + adminDocumentPath);
try {
FileUtils.copyFile(adminDocumentSrc, adminDocumentDst);
AdminDocumentBO adminDocumentBO = new AdminDocumentBO();
adminDocumentBO.setAdmindocId(Short.valueOf("1"));
adminDocumentBO.setAdminDocumentName("IntegrationTest_Loan_template");
adminDocumentBO.setIsActive(Short.valueOf("1"));
adminDocumentBO.setAdminDocumentIdentifier(adminDocumentPath);
AdminDocAccStateMixBO adminDocAccStateMixBO = new AdminDocAccStateMixBO();
AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.LOAN_APPROVED);
adminDocAccStateMixBO.setAccountStateID(accountStateEntity);
adminDocAccStateMixBO.setAdminDocumentID(adminDocumentBO);
legacyAdminDocumentDao.createOrUpdate(adminDocumentBO);
Map<String, AbstractPentahoParameter> params = new HashMap<String, AbstractPentahoParameter>();
PentahoInputParameter entityIdParameter = new PentahoInputParameter();
entityIdParameter.setParamName("entity_id");
entityIdParameter.setValue("000100000000002");
params.put("entity_id", entityIdParameter);
Integer adminDocId = Integer.parseInt(adminDocumentBO.getAdmindocId().toString());
for (PentahoOutputType outputType : PentahoOutputType.values()) {
PentahoReport report = pentahoReportsServiceImpl.getAdminReport(adminDocId, outputType.getId(), params);
Assert.assertTrue(report.getFileExtension() == outputType.getFileExtension());
Assert.assertTrue(report.getContentType() == outputType.getContentType());
Assert.assertTrue(report.getErrors().isEmpty());
}
} catch (Exception e) {
throw e;
} finally {
if (adminDocumentDst.exists()) {
adminDocumentDst.delete();
}
}
}
use of org.mifos.reports.pentaho.params.PentahoInputParameter in project head by mifos.
the class AdminDocumentController method executeAdminDocument.
@RequestMapping(value = "/executeAdminDocument.ftl", method = RequestMethod.GET)
public ModelAndView executeAdminDocument(final HttpServletRequest request, HttpServletResponse response, @RequestParam Integer adminDocumentId, @RequestParam String entityId, @RequestParam Integer outputTypeId) throws IOException {
ModelAndView mav = null;
String fileName = pentahoReportsService.getAdminReportFileName(adminDocumentId);
if (fileName.endsWith(".rptdesign")) {
response.sendRedirect(String.format(LEGACY_BIRT_ADMIN_DOCUMENT_LOAD_PATH, adminDocumentId.toString(), entityId));
} else {
Map<String, AbstractPentahoParameter> params = new HashMap<String, AbstractPentahoParameter>();
PentahoInputParameter entityIdParameter = new PentahoInputParameter();
entityIdParameter.setParamName("entity_id");
entityIdParameter.setValue(entityId);
params.put("entity_id", entityIdParameter);
PentahoReport report = pentahoReportsService.getAdminReport(adminDocumentId, outputTypeId, params);
if (!outputTypeId.equals(PENTAHO_OUTPUT_TYPE_HTML_ID)) {
response.setHeader("Content-Disposition", "attachment; filename=\"" + report.getFilename() + "\"");
}
response.setContentType(report.getContentType());
response.setContentLength(report.getContentSize());
response.getOutputStream().write(report.getContent());
}
return mav;
}
use of org.mifos.reports.pentaho.params.PentahoInputParameter in project head by mifos.
the class PentahoParamParser method parseParamValue.
public Object parseParamValue(AbstractPentahoParameter param, ParameterDefinitionEntry paramDefEntry) throws ReflectionException {
Object result = null;
Class<?> clazz = paramDefEntry.getValueType();
if (param instanceof PentahoDateParameter) {
PentahoDateParameter dateParam = (PentahoDateParameter) param;
LocalDate date = dateParam.getDate();
Date javaDate = (date == null) ? null : date.toDateMidnight().toDate();
result = ReflectionUtil.parseDateToClass(javaDate, clazz);
} else if (param instanceof PentahoInputParameter) {
PentahoInputParameter inputParam = (PentahoInputParameter) param;
result = ReflectionUtil.parseStringToClass(inputParam.getValue(), clazz);
} else if (param instanceof PentahoSingleSelectParameter) {
PentahoSingleSelectParameter singleSelectParam = (PentahoSingleSelectParameter) param;
result = ReflectionUtil.parseStringToClass(singleSelectParam.getSelectedValue(), clazz);
} else if (param instanceof PentahoMultiSelectParameter) {
PentahoMultiSelectParameter multiSelectParam = (PentahoMultiSelectParameter) param;
Class<?> componentType = (clazz.isArray()) ? clazz.getComponentType() : clazz;
result = ReflectionUtil.parseStringsToClass(multiSelectParam.getSelectedValues(), componentType);
}
return result;
}
Aggregations