Search in sources :

Example 1 with ReportsDataSource

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");
}
Also used : ReportsDataSourceActionForm(org.mifos.reports.struts.actionforms.ReportsDataSourceActionForm) ReportsDataSource(org.mifos.reports.business.ReportsDataSource)

Example 2 with ReportsDataSource

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;
}
Also used : HashMap(java.util.HashMap) ReportsDataSource(org.mifos.reports.business.ReportsDataSource) Iterator(java.util.Iterator)

Example 3 with ReportsDataSource

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());
    }
}
Also used : ReportsDataSource(org.mifos.reports.business.ReportsDataSource) Test(org.junit.Test)

Example 4 with ReportsDataSource

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;
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) Statement(java.sql.Statement) ArrayList(java.util.ArrayList) ReportsParamQuery(org.mifos.reports.business.ReportsParamQuery) ReportsDataSource(org.mifos.reports.business.ReportsDataSource) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet)

Example 5 with ReportsDataSource

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");
}
Also used : ReportsDataSourceActionForm(org.mifos.reports.struts.actionforms.ReportsDataSourceActionForm) ReportsDataSource(org.mifos.reports.business.ReportsDataSource)

Aggregations

ReportsDataSource (org.mifos.reports.business.ReportsDataSource)5 ReportsDataSourceActionForm (org.mifos.reports.struts.actionforms.ReportsDataSourceActionForm)2 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 ResultSetMetaData (java.sql.ResultSetMetaData)1 Statement (java.sql.Statement)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Test (org.junit.Test)1 ReportsParamQuery (org.mifos.reports.business.ReportsParamQuery)1