use of org.mifos.reports.pentaho.params.AbstractPentahoParameter in project head by mifos.
the class PentahoParamParser method parseReportParams.
public List<AbstractPentahoParameter> parseReportParams(MasterReport report, HttpServletRequest request, Map<String, AbstractPentahoParameter> selectedValues, boolean update) {
ParameterContext paramContext = null;
try {
paramContext = new DefaultParameterContext(report);
ReportParameterDefinition paramDefinition = report.getParameterDefinition();
List<AbstractPentahoParameter> result = new ArrayList<AbstractPentahoParameter>();
for (ParameterDefinitionEntry paramDefEntry : paramDefinition.getParameterDefinitions()) {
result.add(parseParam(paramDefEntry, paramContext, selectedValues, update));
}
return result;
} catch (ReportDataFactoryException ex) {
throw new JNDIException("Problem with Pentaho Reports", request);
} catch (Exception ex) {
throw new MifosRuntimeException(ex);
} finally {
if (paramContext != null) {
try {
paramContext.close();
} catch (ReportDataFactoryException ex) {
logger.error("Exception while closing parameter context", ex);
}
}
}
}
use of org.mifos.reports.pentaho.params.AbstractPentahoParameter in project head by mifos.
the class PentahoReportsServiceImpl method addParametersToReport.
private void addParametersToReport(MasterReport report, Map<String, AbstractPentahoParameter> params) throws ReflectionException, IOException {
ReportParameterValues rptParamValues = report.getParameterValues();
ReportParameterDefinition paramsDefinition = report.getParameterDefinition();
params.put("mifosLogoPath", getLogoParameterForReport());
for (ParameterDefinitionEntry paramDefEntry : paramsDefinition.getParameterDefinitions()) {
String paramName = paramDefEntry.getName();
AbstractPentahoParameter parameter = params.get(paramName);
if (parameter != null) {
Object val = this.paramParser.parseParamValue(parameter, paramDefEntry);
if (val != null && (!val.getClass().isArray() || Array.getLength(val) > 0)) {
rptParamValues.put(paramName, val);
}
}
}
}
use of org.mifos.reports.pentaho.params.AbstractPentahoParameter in project head by mifos.
the class PentahoReportFormBean method getAllParameteres.
public Map<String, AbstractPentahoParameter> getAllParameteres() {
List<AbstractPentahoParameter> allParams = new ArrayList<AbstractPentahoParameter>();
allParams.addAll(this.reportDateParams);
allParams.addAll(this.reportInputParams);
allParams.addAll(this.reportSingleSelectParams);
allParams.addAll(this.reportMultiSelectParams);
Map<String, AbstractPentahoParameter> result = new HashMap<String, AbstractPentahoParameter>();
for (AbstractPentahoParameter param : allParams) {
result.put(param.getParamName(), param);
}
return result;
}
use of org.mifos.reports.pentaho.params.AbstractPentahoParameter in project head by mifos.
the class PentahoReportFormBean method setReportParameters.
public void setReportParameters(List<AbstractPentahoParameter> params) {
Map<String, AbstractPentahoParameter> formParams = getAllParameteres();
for (AbstractPentahoParameter param : params) {
String paramName = param.getParamName();
if (formParams.containsKey(paramName)) {
if (param instanceof PentahoSingleSelectParameter) {
PentahoSingleSelectParameter singleSelectParam = (PentahoSingleSelectParameter) param;
PentahoSingleSelectParameter singleSelectFormParam = (PentahoSingleSelectParameter) formParams.get(paramName);
singleSelectFormParam.setPossibleValues(singleSelectParam.getPossibleValues());
} else if (param instanceof PentahoMultiSelectParameter) {
PentahoMultiSelectParameter multiSelectParam = (PentahoMultiSelectParameter) param;
PentahoMultiSelectParameter multiSelectFormParam = (PentahoMultiSelectParameter) formParams.get(paramName);
multiSelectFormParam.setPossibleValuesOptions(multiSelectParam.getPossibleValuesOptions());
for (String val : multiSelectFormParam.getSelectedValues()) {
String text = multiSelectFormParam.getPossibleValuesOptions().get(val);
multiSelectFormParam.getPossibleValuesOptions().remove(val);
multiSelectFormParam.getSelectedValuesOptions().put(val, text);
}
}
} else if (!param.getParamName().equals("mifosLogoPath")) {
addParameter(param);
}
}
}
use of org.mifos.reports.pentaho.params.AbstractPentahoParameter 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();
}
}
}
Aggregations