use of org.pentaho.platform.engine.core.output.SimpleOutputHandler in project pentaho-platform by pentaho.
the class XQConnectionIT method testXQConnection.
public void testXQConnection() {
SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
StandaloneSession session = // $NON-NLS-1$
new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
// $NON-NLS-1$ //$NON-NLS-2$
OutputStream outputStream = getOutputStream("DatasourceTest.XQ_Datasource", ".html");
SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true);
IRuntimeContext context = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
run("/test/datasource/XQ_Datasource.xaction", null, false, parameterProvider, outputHandler, session);
assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
context.getStatus());
// TODO need some validation of success
}
use of org.pentaho.platform.engine.core.output.SimpleOutputHandler in project pentaho-platform by pentaho.
the class XQConnectionIT method testJFreeReportParameterPage2.
/*
* public void testXQConnection_JFreeXQuery() { SimpleParameterProvider parameterProvider = new
* SimpleParameterProvider(); parameterProvider.setParameter("type", "html"); //$NON-NLS-1$ //$NON-NLS-2$
* StandaloneSession session = new
* StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$ OutputStream
* outputStream = getOutputStream("DatasourceTest.XQ_Datasource", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
* SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); IRuntimeContext context =
* run("test", "reporting", "JFree_XQuery_report.xaction", null, false, parameterProvider, outputHandler, session);
* //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
* Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
* context.getStatus()); //$NON-NLS-1$ // TODO need some validation of success }
*/
public void testJFreeReportParameterPage2() {
startTest();
SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
// $NON-NLS-1$ //$NON-NLS-2$
parameterProvider.setParameter("type", "html");
// $NON-NLS-1$ //$NON-NLS-2$
OutputStream outputStream = getOutputStream("ReportingTest.testJFreeReportParameterPage2", ".html");
SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true);
StandaloneSession session = // $NON-NLS-1$
new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
IRuntimeContext context = run("/test/reporting/jfreereport-reports-test-param2.xaction", null, false, parameterProvider, outputHandler, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
session);
assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
context.getStatus());
// TODO need some validation of success
finishTest();
}
use of org.pentaho.platform.engine.core.output.SimpleOutputHandler in project pentaho-platform by pentaho.
the class FileResource method doIsParameterizable.
/**
* Determines whether a selected file supports parameters or not
*
* @param pathId Colon separated path for the repository file.
*
* @return ("true" or "false")
* @throws FileNotFoundException
*/
@GET
@Path("{pathId : .+}/parameterizable")
@Produces(MediaType.TEXT_PLAIN)
@Facet(name = "Unsupported")
@StatusCodes({ @ResponseCode(code = 200, condition = "Successfully get the file or directory."), @ResponseCode(code = 404, condition = "Failed to find the file or resource.") })
public // have to accept anything for browsers to work
String doIsParameterizable(@PathParam("pathId") String pathId) throws FileNotFoundException {
boolean hasParameterUi = false;
RepositoryFile repositoryFile = getRepository().getFile(fileService.idToPath(pathId));
if (repositoryFile != null) {
try {
hasParameterUi = hasParameterUi(repositoryFile);
} catch (NoSuchBeanDefinitionException e) {
// Do nothing.
}
}
boolean hasParameters = false;
if (hasParameterUi) {
try {
IContentGenerator parameterContentGenerator = getContentGenerator(repositoryFile);
if (parameterContentGenerator != null) {
ByteArrayOutputStream outputStream = getByteArrayOutputStream();
parameterContentGenerator.setOutputHandler(new SimpleOutputHandler(outputStream, false));
parameterContentGenerator.setMessagesList(new ArrayList<String>());
Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();
SimpleParameterProvider parameterProvider = getSimpleParameterProvider();
parameterProvider.setParameter("path", encode(repositoryFile.getPath()));
parameterProvider.setParameter("renderMode", "PARAMETER");
parameterProviders.put(IParameterProvider.SCOPE_REQUEST, parameterProvider);
parameterContentGenerator.setParameterProviders(parameterProviders);
parameterContentGenerator.setSession(getSession());
parameterContentGenerator.createContent();
if (outputStream.size() > 0) {
Document document = parseText(outputStream.toString());
// exclude all parameters that are of type "system", xactions set system params that have to be ignored.
@SuppressWarnings("rawtypes") List nodes = document.selectNodes("parameters/parameter");
for (int i = 0; i < nodes.size() && !hasParameters; i++) {
Element elem = (Element) nodes.get(i);
if (elem.attributeValue("name").equalsIgnoreCase("output-target") && elem.attributeValue("is-mandatory").equalsIgnoreCase("true")) {
hasParameters = true;
continue;
}
Element attrib = (Element) elem.selectSingleNode("attribute[@namespace='http://reporting.pentaho" + ".org/namespaces/engine/parameter-attributes/core' and @name='role']");
if (attrib == null || !"system".equals(attrib.attributeValue("value"))) {
hasParameters = true;
}
}
}
}
} catch (Exception e) {
logger.error(getMessagesInstance().getString("FileResource.PARAM_FAILURE", e.getMessage()), e);
}
}
return Boolean.toString(hasParameters);
}
Aggregations