public IPentahoResultSet getResultSet(final ReportSpec reportSpec) throws Exception {
    String jndiName = reportSpec.getReportSpecChoice().getJndiSource();
    IPentahoConnection connection = null;
    if (reportSpec.getIsMDX()) {
      // did this ever work??
      String connectStr = ""; // $NON-NLS-1$
      IDBDatasourceService datasourceService =
          PentahoSystem.getObjectFactory().get(IDBDatasourceService.class, null);
      String dsName = datasourceService.getDSBoundName(jndiName);
      if (dsName != null) {
        connectStr = "dataSource=" + dsName + "; Catalog=mondrian"; // $NON-NLS-1$ //$NON-NLS-2$
      } else {
        error(
            Messages.getInstance()
                .getErrorString("MDXBaseComponent.ERROR_0005_INVALID_CONNECTION")); // $NON-NLS-1$
        return null;
      }
      Properties props = new Properties();
      props.setProperty(IPentahoConnection.CONNECTION, connectStr);
      props.setProperty(IPentahoConnection.PROVIDER, reportSpec.getMondrianCubeDefinitionPath());

      connection =
          PentahoConnectionFactory.getConnection(
              IPentahoConnection.MDX_DATASOURCE, props, getSession(), this);
    } else {
      connection =
          PentahoConnectionFactory.getConnection(
              IPentahoConnection.SQL_DATASOURCE, jndiName, getSession(), this);
    }
    String query = ReportParameterUtility.setupParametersForActionSequence(reportSpec.getQuery());
    query = setupQueryParameters(query);
    IPentahoResultSet res = connection.executeQuery(query);
    return res;
  }
コード例 #2
0
 @Override
 protected PentahoTableDataFactory getDataFactory()
     throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception {
   PentahoTableDataFactory factory = null;
   if (reportSpec != null) {
     if (!isDefinedInput(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTTEMP_PERFQRY)
         || "true"
             .equals(
                 getInputParameter(
                     AbstractJFreeReportComponent
                         .REPORTGENERATEDEFN_REPORTTEMP_PERFQRY))) { //$NON-NLS-1$
       if (reportSpec.getReportSpecChoice().getXqueryUrl() != null) {
         // handle xquery
       } else {
         IPentahoResultSet pentahoResultSet = getResultSet(getReportSpec());
         factory = new PentahoTableDataFactory();
         pentahoResultSet.beforeFirst();
         factory.addTable(
             AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT,
             new PentahoTableModel(pentahoResultSet));
       }
     } else {
       factory = super.getDataFactory();
     }
   } else {
     factory = super.getDataFactory();
   }
   return factory;
 }
  @Override
  protected boolean executeAction() {
    boolean result = true;
    try {
      ReportSpec reportSpec = getReportSpec();
      if (reportSpec != null) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ReportGenerationUtility.createJFreeReportXML(
            reportSpec, outputStream, 0, 0, false, "", 0, 0); // $NON-NLS-1$
        String reportDefinition = new String(outputStream.toByteArray());
        addTempParameterObject(
            AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTDEFN, reportDefinition);

        // if that parameter is not defined, we do query for backward compatibility.
        if (!isDefinedInput(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTTEMP_PERFQRY)
            || "true"
                .equals(
                    getInputParameter(
                        AbstractJFreeReportComponent
                            .REPORTGENERATEDEFN_REPORTTEMP_PERFQRY))) { //$NON-NLS-1$
          if (reportSpec.getReportSpecChoice().getXqueryUrl() != null) {
            // handle xquery
          } else {
            try {
              addTempParameterObject(
                  AbstractJFreeReportComponent.DATACOMPONENT_DATAINPUT, getResultSet(reportSpec));
            } catch (Exception e) {
              result = false;
            }
          }
        }
      }
    } catch (FileNotFoundException ex) {
      error(ex.getLocalizedMessage());
      result = false;
    }
    return result;
  }