Search in sources :

Example 26 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class ActionSequenceParameterContentGenerator method getRequestParameters.

@SuppressWarnings("unchecked")
private IParameterProvider getRequestParameters() {
    if (this.requestParameters != null) {
        return this.requestParameters;
    }
    if (this.parameterProviders == null) {
        return new SimpleParameterProvider();
    }
    // $NON-NLS-1$
    IParameterProvider requestParams = this.parameterProviders.get("request");
    SimpleParameterSetter parameters = new SimpleParameterSetter();
    Iterator requestParamIterator = requestParams.getParameterNames();
    while (requestParamIterator.hasNext()) {
        String param = (String) requestParamIterator.next();
        parameters.setParameter(param, requestParams.getParameter(param));
    }
    this.requestParameters = parameters;
    return parameters;
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) SimpleParameterSetter(org.pentaho.platform.engine.services.solution.SimpleParameterSetter) Iterator(java.util.Iterator) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 27 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class ActionSequenceParameterUiContentGenerator method getRequestParameters.

@SuppressWarnings("unchecked")
private IParameterProvider getRequestParameters() {
    if (this.parameterProviders == null) {
        return new SimpleParameterProvider();
    }
    // $NON-NLS-1$
    IParameterProvider requestParams = this.parameterProviders.get("request");
    SimpleParameterSetter parameters = new SimpleParameterSetter();
    Iterator requestParamIterator = requestParams.getParameterNames();
    while (requestParamIterator.hasNext()) {
        String param = (String) requestParamIterator.next();
        parameters.setParameter(param, requestParams.getParameter(param));
    }
    this.requestParameters = parameters;
    return parameters;
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) SimpleParameterSetter(org.pentaho.platform.engine.services.solution.SimpleParameterSetter) Iterator(java.util.Iterator) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 28 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class WsdlPageTest method testBadServiceName.

@Test
public void testBadServiceName() throws Exception {
    // $NON-NLS-1$
    assertNotNull("Logger is null", contentGenerator.getLogger());
    Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();
    parameterProviders.put(IParameterProvider.SCOPE_REQUEST, new SimpleParameterProvider());
    SimpleParameterProvider pathParams = new SimpleParameterProvider();
    // $NON-NLS-1$//$NON-NLS-2$
    pathParams.setParameter("path", "/bogus");
    // $NON-NLS-1$
    parameterProviders.put("path", pathParams);
    contentGenerator.setParameterProviders(parameterProviders);
    contentGenerator.createContent();
    String content = new String(out.toByteArray());
    assertTrue(content, content.contains(Messages.getInstance().getErrorString("WebServiceContentGenerator.ERROR_0006_SERVICE_IS_INVALID", // $NON-NLS-1$ //$NON-NLS-2$
    "bogus")));
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HashMap(java.util.HashMap) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider) Test(org.junit.Test)

Example 29 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class ChartIT method testChartHelper_Null.

/*
   * public void testCategoryAreaChart() { runCategoryChartTest(JFreeChartEngine.AREA_CHART_TYPE,
   * "test/charts/areaChart.xml", "testAreaChart"); //$NON-NLS-1$ //$NON-NLS-2$ }
   * 
   * public void testCategoryBarChart() { runCategoryChartTest(JFreeChartEngine.BAR_CHART_TYPE,
   * "test/charts/barChart.xml", "testBarChart"); //$NON-NLS-1$ //$NON-NLS-2$ }
   * 
   * public void testCategoryLineChart() { runCategoryChartTest(JFreeChartEngine.LINE_CHART_TYPE,
   * "test/charts/lineChart.xml", "testLineChart"); //$NON-NLS-1$ //$NON-NLS-2$ }
   * 
   * public void testPieChart() { runPieChartTest(JFreeChartEngine.PIE_CHART_TYPE, "test/charts/pieChart.xml",
   * "testPieChart"); //$NON-NLS-1$ //$NON-NLS-2$ }
   */
/*
   * public void testChartHelper_DialChart() { String region = "Central"; //$NON-NLS-1$ ArrayList messages = new
   * ArrayList(); SimpleParameterProvider parameters = new SimpleParameterProvider();
   * parameters.setParameter("image-width", "450"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("image-height",
   * "300"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("REGION", region); //$NON-NLS-1$
   * parameters.setParameter("outer-params", "REGION"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameters.setParameter("inner-param", "DEPARTMENT"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter(
   * "drill-url", "SampleDashboard.jsp?region=" + region + "&amp;department={DEPARTMENT}&amp;measure={measure}");
   * //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ parameters.setParameter("series-name", "measure"); //$NON-NLS-1$
   * //$NON-NLS-2$ parameters.setParameter("chart-type", "DialChart"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameters.setParameter("value", "550"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer content = new StringBuffer();
   * StandaloneSession session = new StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION"));
   * //$NON-NLS-1$ ChartHelper.doChart("/test-src/solutions/samples/dashboard/departments.widget.xml", parameters,
   * content, session, messages, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { OutputStream os =
   * getOutputStream(SOLUTION_PATH, "ChartTest.testChartHelper_DialChart", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
   * os.write(content.toString().getBytes()); } catch (Exception e) {
   * 
   * } }
   * 
   * public void testChartHelper_PieChart() { String region = "Central"; //$NON-NLS-1$ ArrayList messages = new
   * ArrayList(); SimpleParameterProvider parameters = new SimpleParameterProvider();
   * parameters.setParameter("image-width", "450"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("image-height",
   * "300"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("REGION", region); //$NON-NLS-1$
   * parameters.setParameter("outer-params", "REGION"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameters.setParameter("inner-param", "DEPARTMENT"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter(
   * "drill-url", "SampleDashboard.jsp?region=" + region + "&amp;department={DEPARTMENT}&amp;measure={measure}");
   * //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ parameters.setParameter("series-name", "measure"); //$NON-NLS-1$
   * //$NON-NLS-2$ parameters.setParameter("chart-type", "PieChart"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer content =
   * new StringBuffer(); StandaloneSession session = new
   * StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * ChartHelper.doChart("/test-src/solutions/samples/dashboard/departments.widget.xml", parameters, content, session,
   * messages, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { OutputStream os = getOutputStream(SOLUTION_PATH,
   * "ChartTest.testChartHelper_PieChart", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
   * os.write(content.toString().getBytes()); } catch (Exception e) {
   * 
   * } }
   * 
   * public void testChartHelper_PieGrid() { String region = "Central"; //$NON-NLS-1$ ArrayList messages = new
   * ArrayList(); SimpleParameterProvider parameters = new SimpleParameterProvider();
   * parameters.setParameter("image-width", "450"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("image-height",
   * "300"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("REGION", region); //$NON-NLS-1$
   * parameters.setParameter("outer-params", "REGION"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameters.setParameter("inner-param", "DEPARTMENT"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter(
   * "drill-url", "SampleDashboard.jsp?region=" + region + "&amp;department={DEPARTMENT}&amp;measure={measure}");
   * //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ parameters.setParameter("series-name", "measure"); //$NON-NLS-1$
   * //$NON-NLS-2$ parameters.setParameter("chart-type", "PieGrid"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer content =
   * new StringBuffer(); StandaloneSession session = new
   * StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * ChartHelper.doChart(/test-src/solutions/samples/dashboard/departments.widget.xml", parameters, content, session,
   * messages, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { OutputStream os = getOutputStream(SOLUTION_PATH,
   * "ChartTest.testChartHelper_PieGrid", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ os.write(content.toString().getBytes());
   * } catch (Exception e) {
   * 
   * } }
   * 
   * public void testChartHelper_BarChart() { String region = "Central"; //$NON-NLS-1$ ArrayList messages = new
   * ArrayList(); SimpleParameterProvider parameters = new SimpleParameterProvider();
   * parameters.setParameter("image-width", "450"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("image-height",
   * "300"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("REGION", region); //$NON-NLS-1$
   * parameters.setParameter("outer-params", "REGION"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameters.setParameter("inner-param", "DEPARTMENT"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter(
   * "drill-url", "SampleDashboard.jsp?region=" + region + "&amp;department={DEPARTMENT}&amp;measure={measure}");
   * //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ parameters.setParameter("series-name", "measure"); //$NON-NLS-1$
   * //$NON-NLS-2$ parameters.setParameter("chart-type", "BarChart"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer content =
   * new StringBuffer(); StandaloneSession session = new
   * StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * ChartHelper.doChart("/test-src/solutions/samples/dashboard/departments.widget.xml", parameters, content, session,
   * messages, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { OutputStream os = getOutputStream(SOLUTION_PATH,
   * "ChartTest.testChartHelper_BarChart", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
   * os.write(content.toString().getBytes()); } catch (Exception e) {
   * 
   * } }
   */
/*
   * public void testChartHelper_LineChart() { String region = "Central"; //$NON-NLS-1$ ArrayList messages = new
   * ArrayList(); SimpleParameterProvider parameters = new SimpleParameterProvider();
   * parameters.setParameter("image-width", "450"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("image-height",
   * "300"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("REGION", region); //$NON-NLS-1$
   * parameters.setParameter("outer-params", "REGION"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameters.setParameter("inner-param", "DEPARTMENT"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter(
   * "drill-url", "SampleDashboard.jsp?region=" + region + "&amp;department={DEPARTMENT}&amp;measure={measure}");
   * //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ parameters.setParameter("series-name", "measure"); //$NON-NLS-1$
   * //$NON-NLS-2$ parameters.setParameter("chart-type", "LineChart"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer content
   * = new StringBuffer(); StandaloneSession session = new
   * StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * ChartHelper.doChart("/test-src/solutions/samples/dashboard/departments.widget.xml", parameters, content, session,
   * messages, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { OutputStream os = getOutputStream(SOLUTION_PATH,
   * "ChartTest.testChartHelper_LineChart", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
   * os.write(content.toString().getBytes()); } catch (Exception e) {
   * 
   * } }
   */
/*
   * public void testChartHelper_AreaChart() { String region = "Central"; //$NON-NLS-1$ ArrayList messages = new
   * ArrayList(); SimpleParameterProvider parameters = new SimpleParameterProvider();
   * parameters.setParameter("image-width", "450"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("image-height",
   * "300"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("REGION", region); //$NON-NLS-1$
   * parameters.setParameter("outer-params", "REGION"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameters.setParameter("inner-param", "DEPARTMENT"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameters.setParameter("connection", "SampleData"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("query",
   * "select REGION, DEPARTMENT, MANAGER_NAME, EMAIL from DEPARTMENT_MANAGERS"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameters.setParameter( "drill-url", "SampleDashboard.jsp?region=" + region +
   * "&amp;department={DEPARTMENT}&amp;measure={measure}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
   * parameters.setParameter("series-name", "measure"); //$NON-NLS-1$ //$NON-NLS-2$
   * parameters.setParameter("chart-type", "AreaChart"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer content = new
   * StringBuffer(); StandaloneSession session = new
   * StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
   * ChartHelper.doChart("/test-src/solutions/samples/dashboard/departments.widget.xml", parameters, content, session,
   * messages, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { OutputStream os = getOutputStream(SOLUTION_PATH,
   * "ChartTest.testChartHelper_AreaChart", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
   * os.write(content.toString().getBytes()); } catch (Exception e) {
   * 
   * } }
   */
public void testChartHelper_Null() {
    // $NON-NLS-1$
    String region = "Central";
    ArrayList messages = new ArrayList();
    SimpleParameterProvider parameters = new SimpleParameterProvider();
    // $NON-NLS-1$ //$NON-NLS-2$
    parameters.setParameter("image-width", "450");
    // $NON-NLS-1$ //$NON-NLS-2$
    parameters.setParameter("image-height", "300");
    // $NON-NLS-1$
    parameters.setParameter("REGION", region);
    // $NON-NLS-1$ //$NON-NLS-2$
    parameters.setParameter("outer-params", "REGION");
    // $NON-NLS-1$ //$NON-NLS-2$
    parameters.setParameter("inner-param", "DEPARTMENT");
    parameters.setParameter("drill-url", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    "SampleDashboard.jsp?region=" + region + "&amp;department={DEPARTMENT}&amp;measure={measure}");
    // $NON-NLS-1$ //$NON-NLS-2$
    parameters.setParameter("series-name", "measure");
    // $NON-NLS-1$ //$NON-NLS-2$
    parameters.setParameter("chart-type", "");
    StringBuffer content = new StringBuffer();
    StandaloneSession session = // $NON-NLS-1$
    new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    PentahoSessionHolder.setSession(session);
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    ChartHelper.doChart("/samples/dashboard/departments.widget.xml", parameters, content, session, messages, null);
    try {
        // $NON-NLS-1$ //$NON-NLS-2$
        OutputStream os = getOutputStream("ChartTest.testChartHelper_Null", ".html");
        os.write(content.toString().getBytes());
    } catch (Exception e) {
    // ignore
    }
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) IOException(java.io.IOException) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 30 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class ChartbeansIT method testChartbeansActionComponentOFC.

@SuppressWarnings("deprecation")
@Test
public void testChartbeansActionComponentOFC() {
    microPlatform.init();
    IPentahoUrlFactory urlFactory = new SimpleUrlFactory("");
    ArrayList messages = new ArrayList();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    // $NON-NLS-1$ //$NON-NLS-2$
    parameterProvider.setParameter("solution", "test");
    // $NON-NLS-1$ //$NON-NLS-2$
    parameterProvider.setParameter("path", "chartbeans");
    // $NON-NLS-1$ //$NON-NLS-2$
    parameterProvider.setParameter("action", "Chartbeans_All_Inclusive_OFC.xaction");
    ActionComponent component = new ActionComponent("test/chartbeans/Chartbeans_All_Inclusive_OFC.xaction", null, IOutputHandler.OUTPUT_TYPE_DEFAULT, urlFactory, // $NON-NLS-1$
    messages);
    component.setParameterProvider(IParameterProvider.SCOPE_REQUEST, parameterProvider);
    component.validate(session, null);
    // $NON-NLS-1$ //$NON-NLS-2$
    OutputStream outputStream = getOutputStream("Chartbeans.testChartbeansAllInclusive_OFC", ".html");
    // $NON-NLS-1$
    String result = component.getContent("text/html");
    try {
        outputStream.write(result.getBytes());
        // $NON-NLS-1$
        assertTrue(result.startsWith("<html><head>"));
        // $NON-NLS-1$
        assertTrue(result.indexOf("function getChartData") > 0);
        // $NON-NLS-1$
        assertTrue(result.indexOf("/*JSON*/") > 0);
        // $NON-NLS-1$
        assertTrue(result.indexOf("/*END_JSON*/") > 0);
        // $NON-NLS-1$
        assertTrue(result.indexOf("</body></html>") > 0);
    } catch (Exception e) {
        // $NON-NLS-1$
        assertTrue("An exception has been thrown: " + e.getMessage(), false);
    }
}
Also used : IPentahoUrlFactory(org.pentaho.platform.api.engine.IPentahoUrlFactory) ActionComponent(org.pentaho.platform.uifoundation.component.ActionComponent) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) ArrayList(java.util.ArrayList) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) FileNotFoundException(java.io.FileNotFoundException) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider) Test(org.junit.Test)

Aggregations

SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)72 HashMap (java.util.HashMap)32 ArrayList (java.util.ArrayList)23 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)23 OutputStream (java.io.OutputStream)21 IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)21 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)21 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)21 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)16 Test (org.junit.Test)13 IOException (java.io.IOException)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 MockHttpServletRequest (com.mockrunner.mock.web.MockHttpServletRequest)7 MockHttpServletResponse (com.mockrunner.mock.web.MockHttpServletResponse)7 Map (java.util.Map)5 IPentahoRequestContext (org.pentaho.platform.api.engine.IPentahoRequestContext)5 IPentahoUrlFactory (org.pentaho.platform.api.engine.IPentahoUrlFactory)5 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)5 BaseRequestHandler (org.pentaho.platform.engine.services.BaseRequestHandler)5 Iterator (java.util.Iterator)4