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