Search in sources :

Example 1 with ReportsParams

use of org.mifos.reports.business.ReportsParams in project head by mifos.

the class ReportsPersistenceIntegrationTest method testGetAllParameters.

@Test
public void testGetAllParameters() throws Exception {
    {
        List<ReportsParams> parameters = reportsPersistence.getAllReportParams();
        Assert.assertEquals(0, parameters.size());
    }
    String sql = "insert into report_parameter(name, type, classname)" + "values('my_report', 'my_type', 'my_class')";
    session.connection().createStatement().execute(sql);
    List<ReportsParams> moreParameters = reportsPersistence.getAllReportParams(session);
    Assert.assertEquals(1, moreParameters.size());
    ReportsParams parameter = moreParameters.get(0);
    Assert.assertEquals("my_report", parameter.getName());
    Assert.assertEquals("my_type", parameter.getType());
    Assert.assertEquals("my_class", parameter.getClassname());
}
Also used : ReportsParams(org.mifos.reports.business.ReportsParams) List(java.util.List) Test(org.junit.Test)

Example 2 with ReportsParams

use of org.mifos.reports.business.ReportsParams in project head by mifos.

the class ReportsBusinessService method createReportsParams.

/**
     * Create Report Parameter
     */
public String createReportsParams(ReportsParamsValue objParams) throws ApplicationException {
    String error = "";
    boolean isInUse = false;
    List<ReportsParams> reportsParams = new ReportsPersistence().getAllReportParams();
    Object[] obj = reportsParams.toArray();
    if (obj != null && obj.length > 0) {
        for (Object element : obj) {
            ReportsParams rp = (ReportsParams) element;
            if (rp.getName().equalsIgnoreCase(objParams.getName())) {
                isInUse = true;
                break;
            }
        }
    }
    if (objParams.getName() == null || objParams.getName().equals("") || isInUse) {
        error = "Parameter Name is blank or has been already Used";
    } else if (objParams.getDescription() == null || objParams.getDescription().equals("") || isInUse) {
        error = "Description cannot be blank";
    } else {
        reportsPersistence.createReportParams(objParams);
    }
    return error;
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsParams(org.mifos.reports.business.ReportsParams) AbstractBusinessObject(org.mifos.framework.business.AbstractBusinessObject)

Aggregations

ReportsParams (org.mifos.reports.business.ReportsParams)2 List (java.util.List)1 Test (org.junit.Test)1 AbstractBusinessObject (org.mifos.framework.business.AbstractBusinessObject)1 ReportsPersistence (org.mifos.reports.persistence.ReportsPersistence)1