use of org.mifos.reports.business.ReportsDataSource in project head by mifos.
the class ReportsDataSourceAction method createDataSource.
/**
* Controls the creation of DataSource
*/
public ActionForward createDataSource(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In ReportsDataSourceAction:createDataSource Method: ");
ReportsDataSourceActionForm actionForm = (ReportsDataSourceActionForm) form;
ReportsDataSource objDs = new ReportsDataSource();
objDs.setDriver(actionForm.getDriver());
objDs.setName(actionForm.getName());
objDs.setUrl(actionForm.getUrl());
objDs.setPassword(actionForm.getPassword());
objDs.setUsername(actionForm.getUsername());
reportsPersistence.createReportsDataSource(objDs);
return mapping.findForward("reportdatasource_path");
}
use of org.mifos.reports.business.ReportsDataSource in project head by mifos.
the class ReportsPersistence method viewDataSource.
public List<ReportsDataSource> viewDataSource(int dataSourceId) throws PersistenceException {
Map<String, String> queryParameters = new HashMap<String, String>();
List<ReportsDataSource> queryResult = null;
queryParameters.put("dataSourceId", dataSourceId + "");
queryResult = executeNamedQuery(ReportsConstants.VIEW_DATASOURCE, queryParameters);
Iterator itrQueryResult = queryResult.iterator();
while (itrQueryResult.hasNext()) {
ReportsDataSource objReportsDataSource = (ReportsDataSource) itrQueryResult.next();
objReportsDataSource.setPassword(ReportsConstants.HIDDEN_PASSWORD);
}
return queryResult;
}
use of org.mifos.reports.business.ReportsDataSource in project head by mifos.
the class ReportsPersistenceIntegrationTest method testViewDataSource.
@Test
public void testViewDataSource() throws Exception {
List<ReportsDataSource> queryResult = reportsPersistence.viewDataSource(1);
Iterator<ReportsDataSource> itrQueryResult = queryResult.iterator();
while (itrQueryResult.hasNext()) {
ReportsDataSource objReportsDataSource = itrQueryResult.next();
Assert.assertEquals(ReportsConstants.HIDDEN_PASSWORD, objReportsDataSource.getPassword());
}
}
use of org.mifos.reports.business.ReportsDataSource in project head by mifos.
the class ReportsParamQueryDAO method listValuesOfParameters.
/**
* This method lists all the values of parameter
*/
public List listValuesOfParameters(ReportsParams rps) throws Exception {
List<ReportsParamQuery> alValues = new ArrayList();
ReportsDataSource rds = rps.getReportsDataSource();
Connection con = null;
try {
String driver = rds.getDriver();
String url = rds.getUrl();
String username = rds.getUsername();
String password = rds.getPassword();
if (driver != null && !driver.equals("")) {
Class.forName(driver);
con = DriverManager.getConnection(url, username, password);
Statement stm = con.createStatement();
String data = rps.getData();
if (data != null && !data.equals("")) {
ResultSet rs = stm.executeQuery(data);
ResultSetMetaData rsmd = rs.getMetaData();
while (rs.next()) {
ReportsParamQuery obj = new ReportsParamQuery();
if (rsmd.getColumnCount() >= 2) {
obj.setValue1(rs.getString(1));
obj.setValue2(rs.getString(2));
} else if (rsmd.getColumnCount() == 1) {
obj.setValue1(rs.getString(1));
obj.setValue2(rs.getString(1));
}
alValues.add(obj);
}
}
}
} finally {
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return alValues;
}
use of org.mifos.reports.business.ReportsDataSource in project head by mifos.
the class ReportsDataSourceAction method deleteDataSource.
/**
* Controls the deletion of DataSource
*/
public ActionForward deleteDataSource(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In ReportsDataSourceAction:deleteDataSource Method: ");
ReportsDataSourceActionForm actionForm = (ReportsDataSourceActionForm) form;
ReportsDataSource objDs = new ReportsDataSource();
objDs.setDatasourceId(actionForm.getDatasourceId());
String error = reportsBusinessService.deleteReportsDataSource(objDs);
request.getSession().setAttribute("deleteError", error);
return mapping.findForward("reportdatasource_path");
}
Aggregations