Search in sources :

Example 1 with PentahoInputParameter

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;
}
Also used : PentahoInputParameter(org.mifos.reports.pentaho.params.PentahoInputParameter)

Example 2 with PentahoInputParameter

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;
}
Also used : PentahoInputParameter(org.mifos.reports.pentaho.params.PentahoInputParameter) ConfigurationLocator(org.mifos.framework.util.ConfigurationLocator)

Example 3 with PentahoInputParameter

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();
        }
    }
}
Also used : PentahoReport(org.mifos.reports.pentaho.PentahoReport) AbstractPentahoParameter(org.mifos.reports.pentaho.params.AbstractPentahoParameter) HashMap(java.util.HashMap) AdminDocAccStateMixBO(org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) PentahoOutputType(org.mifos.reports.pentaho.util.PentahoOutputType) AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) PentahoInputParameter(org.mifos.reports.pentaho.params.PentahoInputParameter) File(java.io.File) Test(org.junit.Test)

Example 4 with PentahoInputParameter

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;
}
Also used : PentahoReport(org.mifos.reports.pentaho.PentahoReport) AbstractPentahoParameter(org.mifos.reports.pentaho.params.AbstractPentahoParameter) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) PentahoInputParameter(org.mifos.reports.pentaho.params.PentahoInputParameter) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with PentahoInputParameter

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;
}
Also used : PentahoDateParameter(org.mifos.reports.pentaho.params.PentahoDateParameter) PentahoSingleSelectParameter(org.mifos.reports.pentaho.params.PentahoSingleSelectParameter) PentahoInputParameter(org.mifos.reports.pentaho.params.PentahoInputParameter) PentahoMultiSelectParameter(org.mifos.reports.pentaho.params.PentahoMultiSelectParameter) LocalDate(org.joda.time.LocalDate) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Aggregations

PentahoInputParameter (org.mifos.reports.pentaho.params.PentahoInputParameter)5 HashMap (java.util.HashMap)2 PentahoReport (org.mifos.reports.pentaho.PentahoReport)2 AbstractPentahoParameter (org.mifos.reports.pentaho.params.AbstractPentahoParameter)2 File (java.io.File)1 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1 LocalDate (org.joda.time.LocalDate)1 Test (org.junit.Test)1 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)1 ConfigurationLocator (org.mifos.framework.util.ConfigurationLocator)1 AdminDocAccStateMixBO (org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO)1 AdminDocumentBO (org.mifos.reports.admindocuments.business.AdminDocumentBO)1 PentahoDateParameter (org.mifos.reports.pentaho.params.PentahoDateParameter)1 PentahoMultiSelectParameter (org.mifos.reports.pentaho.params.PentahoMultiSelectParameter)1 PentahoSingleSelectParameter (org.mifos.reports.pentaho.params.PentahoSingleSelectParameter)1 PentahoOutputType (org.mifos.reports.pentaho.util.PentahoOutputType)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1