use of org.pentaho.actionsequence.dom.IActionInput in project pentaho-platform by pentaho.
the class JFreeReportComponent method getJarDataFactory.
private PentahoTableDataFactory getJarDataFactory() throws Exception {
PentahoTableDataFactory factory = null;
JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
try {
org.pentaho.actionsequence.dom.IActionResource actionResource = jFreeReportAction.getDataJar().getJar();
if (actionResource != null) {
DataSource dataSource = new ActivationHelper.PentahoStreamSourceWrapper(actionResource.getDataSource());
InputStream in = dataSource.getInputStream();
try {
// not being able to read a single char is definitly a big boo ..
if (in.read() == -1) {
// $NON-NLS-1$
throw new Exception(Messages.getInstance().getErrorString("JFreeReport.ERROR_0009_REPORT_JAR_UNREADABLE"));
} else {
final ClassLoader loader = ReportUtils.createJarLoader(getSession(), getResource(actionResource.getName()));
if (loader == null) {
throw new Exception(Messages.getInstance().getString(// $NON-NLS-1$
"JFreeReportDataComponent.ERROR_0035_COULD_NOT_CREATE_CLASSLOADER"));
} else if (!isDefinedInput(AbstractJFreeReportComponent.DATACOMPONENT_CLASSLOCINPUT)) {
throw new Exception(Messages.getInstance().getErrorString(// $NON-NLS-1$
"JFreeReport.ERROR_0012_CLASS_LOCATION_MISSING"));
} else {
// Get input parameters, and set them as properties in the report
// object.
final ReportParameterValues reportProperties = new ReportParameterValues();
IActionInput[] actionInputs = jFreeReportAction.getInputs();
for (IActionInput element : actionInputs) {
final Object paramValue = element.getValue();
if (paramValue instanceof Object[]) {
final Object[] values = (Object[]) paramValue;
final StringBuffer valuesBuffer = new StringBuffer();
// TODO support non-string items
for (int z = 0; z < values.length; z++) {
if (z == 0) {
valuesBuffer.append(values[z].toString());
} else {
valuesBuffer.append(',').append(values[z].toString());
}
}
reportProperties.put(element.getName(), valuesBuffer.toString());
} else {
reportProperties.put(element.getName(), paramValue);
}
}
final DataFactory dataFactory = new PentahoDataFactory(loader);
final TableModel model = dataFactory.queryData(jFreeReportAction.getDataJar().getDataClass(), new ParameterDataRow(reportProperties));
factory = new PentahoTableDataFactory(AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT, model);
}
}
} catch (Exception e) {
// $NON-NLS-1$
throw new Exception(Messages.getInstance().getErrorString("JFreeReport.ERROR_0009_REPORT_JAR_UNREADABLE"));
}
}
} catch (FileNotFoundException e1) {
throw new Exception(Messages.getInstance().getErrorString("JFreeReport.ERROR_0010_REPORT_JAR_MISSING", // $NON-NLS-1$
jFreeReportAction.getDataJar().toString()));
}
return factory;
}
use of org.pentaho.actionsequence.dom.IActionInput in project pentaho-platform by pentaho.
the class UtilityComponent method executeGetMapValuesAction.
private boolean executeGetMapValuesAction(final PrintMapValsAction getMapValsAction) {
IActionInput propertyMap = getMapValsAction.getPropertyMap();
IActionInput[] keys = getMapValsAction.getKeys();
boolean result = true;
try {
if (!(propertyMap.getValue() instanceof Map)) {
// $NON-NLS-1$ //$NON-NLS-2$
error(Messages.getInstance().getErrorString("UtilityComponent.ERROR_0004_PARAMETER_NOT_MAP", "property-map"));
result = false;
} else {
Map srcMap = (Map) propertyMap.getValue();
for (IActionInput element : keys) {
String key = element.getStringValue();
getMapValsAction.getOutput(key).setValue(srcMap.get(key));
}
}
} catch (Exception e) {
// $NON-NLS-1$
error(Messages.getInstance().getString("UtilityComponent.ERROR_0005_GET_MAP_VALUES_ERROR"));
result = false;
}
return result;
}
use of org.pentaho.actionsequence.dom.IActionInput in project pentaho-platform by pentaho.
the class UtilityComponent method executeCopyAction.
private boolean executeCopyAction(final CopyParamAction copyParamAction) {
boolean result = true;
IActionInput actionInput = copyParamAction.getCopyFrom();
IActionOutput actionOutput = copyParamAction.getOutputCopy();
if ((actionInput instanceof ActionInput) && (actionOutput != null)) {
try {
actionOutput.setValue(actionInput.getValue());
} catch (Exception ex) {
result = false;
}
}
return result;
}
use of org.pentaho.actionsequence.dom.IActionInput in project pentaho-platform by pentaho.
the class UtilityComponent method executePrintParamAction.
private boolean executePrintParamAction(final PrintParamAction printParamAction) {
// $NON-NLS-1$
String delimiter = printParamAction.getDelimiter().getStringValue("");
IActionInput[] inputsToPrint = printParamAction.getInputsToPrint();
boolean result = true;
try {
// $NON-NLS-1$
StringBuffer sb = new StringBuffer("\n***************************************************************\n");
for (IActionInput element : inputsToPrint) {
// $NON-NLS-1$
sb.append(element.getStringValue("")).append(delimiter);
}
// $NON-NLS-1$
sb.append("\n***************************************************************\n");
info(sb.toString());
} catch (Exception e) {
// $NON-NLS-1$
error(Messages.getInstance().getString("UtilityComponent.ERROR_0002_MESSAGE_LOG_ERROR"));
result = false;
}
return result;
}
use of org.pentaho.actionsequence.dom.IActionInput in project pentaho-platform by pentaho.
the class EmailComponent method validateAction.
@Override
public boolean validateAction() {
boolean result = true;
// make sure that we can get a "to" email address
if (!(getActionDefinition() instanceof EmailAction)) {
error(Messages.getInstance().getErrorString("ComponentBase.ERROR_0001_UNKNOWN_ACTION_TYPE", // $NON-NLS-1$
getActionDefinition().getElement().asXML()));
result = false;
} else {
EmailAction emailAction = (EmailAction) getActionDefinition();
IActionInput to = emailAction.getTo();
IActionInput subject = emailAction.getSubject();
IActionInput plainMsg = emailAction.getMessagePlain();
IActionInput htmlMsg = emailAction.getMessageHtml();
if (to == ActionInputConstant.NULL_INPUT) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("Email.ERROR_0001_TO_NOT_DEFINED", getActionName()));
result = false;
} else if (subject == ActionInputConstant.NULL_INPUT) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("Email.ERROR_0002_SUBJECT_NOT_DEFINED", getActionName()));
result = false;
} else if ((plainMsg == ActionInputConstant.NULL_INPUT) && (htmlMsg == ActionInputConstant.NULL_INPUT)) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("Email.ERROR_0003_BODY_NOT_DEFINED", getActionName()));
result = false;
}
}
return result;
}
Aggregations