use of org.apache.hop.core.ICheckResult in project hop by apache.
the class DummyMeta method check.
@Override
public void check(List<ICheckResult> remarks, PipelineMeta pipelineMeta, TransformMeta transformMeta, IRowMeta prev, String[] input, String[] output, IRowMeta info, IVariables variables, IHopMetadataProvider metadataProvider) {
CheckResult cr;
if (prev == null || prev.size() == 0) {
cr = new CheckResult(ICheckResult.TYPE_RESULT_WARNING, BaseMessages.getString(PKG, "DummyMeta.CheckResult.NotReceivingFields"), transformMeta);
remarks.add(cr);
} else {
cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "DummyMeta.CheckResult.TransformRecevingData", prev.size() + ""), transformMeta);
remarks.add(cr);
}
// See if we have input streams leading to this transform!
if (input.length > 0) {
cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "DummyMeta.CheckResult.TransformRecevingData2"), transformMeta);
remarks.add(cr);
} else {
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "DummyMeta.CheckResult.NoInputReceivedFromOtherTransforms"), transformMeta);
remarks.add(cr);
}
}
use of org.apache.hop.core.ICheckResult in project hop by apache.
the class InjectorMeta method check.
@Override
public void check(List<ICheckResult> remarks, PipelineMeta pipelineMeta, TransformMeta transformMeta, IRowMeta prev, String[] input, String[] output, IRowMeta info, IVariables variables, IHopMetadataProvider metadataProvider) {
// See if we have input streams leading to this transform!
if (input.length > 0) {
CheckResult cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "InjectorMeta.CheckResult.TransformExpectingNoReadingInfoFromOtherTransforms"), transformMeta);
remarks.add(cr);
} else {
CheckResult cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "InjectorMeta.CheckResult.NoInputReceivedError"), transformMeta);
remarks.add(cr);
}
}
use of org.apache.hop.core.ICheckResult in project hop by apache.
the class ScriptValuesMeta method check.
@Override
public void check(List<ICheckResult> remarks, PipelineMeta pipelineMeta, TransformMeta transformMeta, IRowMeta prev, String[] input, String[] output, IRowMeta info, IVariables variables, IHopMetadataProvider metadataProvider) {
boolean errorFound = false;
String errorMessage = "";
CheckResult cr;
Context jscx;
Scriptable jsscope;
Script jsscript;
jscx = ContextFactory.getGlobal().enterContext();
jsscope = jscx.initStandardObjects(null, false);
try {
jscx.setOptimizationLevel(Integer.valueOf(variables.resolve(optimizationLevel)));
} catch (NumberFormatException nfe) {
errorMessage = "Error with optimization level. Could not convert the value of " + variables.resolve(optimizationLevel) + " to an integer.";
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta);
remarks.add(cr);
} catch (IllegalArgumentException iae) {
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, iae.getMessage(), transformMeta);
remarks.add(cr);
}
String strActiveStartScriptName = "";
String strActiveEndScriptName = "";
String strActiveScript = "";
String strActiveStartScript = "";
String strActiveEndScript = "";
// Building the Scripts
if (jsScripts.length > 0) {
for (int i = 0; i < jsScripts.length; i++) {
if (jsScripts[i].isTransformScript()) {
strActiveScript = jsScripts[i].getScript();
} else if (jsScripts[i].isStartScript()) {
strActiveStartScriptName = jsScripts[i].getScriptName();
strActiveStartScript = jsScripts[i].getScript();
} else if (jsScripts[i].isEndScript()) {
strActiveEndScriptName = jsScripts[i].getScriptName();
strActiveEndScript = jsScripts[i].getScript();
}
}
}
if (prev != null && strActiveScript.length() > 0) {
cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "ScriptValuesMetaMod.CheckResult.ConnectedTransformOK", String.valueOf(prev.size())), transformMeta);
remarks.add(cr);
// Adding the existing Scripts to the Context
for (int i = 0; i < getNumberOfJSScripts(); i++) {
Scriptable jsR = Context.toObject(jsScripts[i].getScript(), jsscope);
jsscope.put(jsScripts[i].getScriptName(), jsscope, jsR);
}
// Modification for Additional Script parsing
try {
if (getAddClasses() != null) {
for (int i = 0; i < getAddClasses().length; i++) {
Object jsOut = Context.javaToJS(getAddClasses()[i].getAddObject(), jsscope);
ScriptableObject.putProperty(jsscope, getAddClasses()[i].getJSName(), jsOut);
}
}
} catch (Exception e) {
errorMessage = ("Couldn't add JavaClasses to Context! Error:");
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta);
remarks.add(cr);
}
// Adding some default JavaScriptFunctions to the System
try {
Context.javaToJS(ScriptValuesAddedFunctions.class, jsscope);
((ScriptableObject) jsscope).defineFunctionProperties(ScriptValuesAddedFunctions.jsFunctionList, ScriptValuesAddedFunctions.class, ScriptableObject.DONTENUM);
} catch (Exception ex) {
errorMessage = "Couldn't add Default Functions! Error:" + Const.CR + ex.toString();
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta);
remarks.add(cr);
}
// Adding some Constants to the JavaScript
try {
jsscope.put("SKIP_PIPELINE", jsscope, Integer.valueOf(ScriptValues.SKIP_PIPELINE));
jsscope.put("ABORT_PIPELINE", jsscope, Integer.valueOf(ScriptValues.ABORT_PIPELINE));
jsscope.put("ERROR_PIPELINE", jsscope, Integer.valueOf(ScriptValues.ERROR_PIPELINE));
jsscope.put("CONTINUE_PIPELINE", jsscope, Integer.valueOf(ScriptValues.CONTINUE_PIPELINE));
} catch (Exception ex) {
errorMessage = "Couldn't add Pipeline Constants! Error:" + Const.CR + ex.toString();
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta);
remarks.add(cr);
}
try {
ScriptValuesDummy dummyTransform = new ScriptValuesDummy(prev, pipelineMeta.getTransformFields(variables, transformMeta));
Scriptable jsvalue = Context.toObject(dummyTransform, jsscope);
jsscope.put("_transform_", jsscope, jsvalue);
Object[] row = new Object[prev.size()];
Scriptable jsRowMeta = Context.toObject(prev, jsscope);
jsscope.put("rowMeta", jsscope, jsRowMeta);
for (int i = 0; i < prev.size(); i++) {
IValueMeta valueMeta = prev.getValueMeta(i);
Object valueData = null;
//
if (valueMeta.isDate()) {
valueData = new Date();
}
if (valueMeta.isString()) {
valueData = "test value test value test value test value test value " + "test value test value test value test value test value";
}
if (valueMeta.isInteger()) {
valueData = Long.valueOf(0L);
}
if (valueMeta.isNumber()) {
valueData = Double.valueOf(0.0);
}
if (valueMeta.isBigNumber()) {
valueData = BigDecimal.ZERO;
}
if (valueMeta.isBoolean()) {
valueData = Boolean.TRUE;
}
if (valueMeta.isBinary()) {
valueData = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
}
row[i] = valueData;
Scriptable jsarg = Context.toObject(valueData, jsscope);
jsscope.put(valueMeta.getName(), jsscope, jsarg);
}
Scriptable jsRow = Context.toObject(row, jsscope);
jsscope.put("row", jsscope, jsRow);
} catch (Exception ev) {
errorMessage = "Couldn't add Input fields to Script! Error:" + Const.CR + ev.toString();
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta);
remarks.add(cr);
}
try {
// Checking for StartScript
if (strActiveStartScript != null && strActiveStartScript.length() > 0) {
/* Object startScript = */
jscx.evaluateString(jsscope, strActiveStartScript, "pipeline_Start", 1, null);
errorMessage = "Found Start Script. " + strActiveStartScriptName + " Processing OK";
cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, errorMessage, transformMeta);
remarks.add(cr);
}
} catch (Exception e) {
errorMessage = "Couldn't process Start Script! Error:" + Const.CR + e.toString();
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta);
remarks.add(cr);
}
try {
jsscript = jscx.compileString(strActiveScript, "script", 1, null);
cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "ScriptValuesMetaMod.CheckResult.ScriptCompiledOK"), transformMeta);
remarks.add(cr);
try {
jsscript.exec(jscx, jsscope);
cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "ScriptValuesMetaMod.CheckResult.ScriptCompiledOK2"), transformMeta);
remarks.add(cr);
if (fieldname.length > 0) {
StringBuilder message = new StringBuilder(BaseMessages.getString(PKG, "ScriptValuesMetaMod.CheckResult.FailedToGetValues", String.valueOf(fieldname.length)) + Const.CR + Const.CR);
if (errorFound) {
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, message.toString(), transformMeta);
} else {
cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, message.toString(), transformMeta);
}
remarks.add(cr);
}
} catch (JavaScriptException jse) {
Context.exit();
errorMessage = BaseMessages.getString(PKG, "ScriptValuesMetaMod.CheckResult.CouldNotExecuteScript") + Const.CR + jse.toString();
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta);
remarks.add(cr);
} catch (Exception e) {
Context.exit();
errorMessage = BaseMessages.getString(PKG, "ScriptValuesMetaMod.CheckResult.CouldNotExecuteScript2") + Const.CR + e.toString();
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta);
remarks.add(cr);
}
// Checking End Script
try {
if (strActiveEndScript != null && strActiveEndScript.length() > 0) {
/* Object endScript = */
jscx.evaluateString(jsscope, strActiveEndScript, "pipeline_End", 1, null);
errorMessage = "Found End Script. " + strActiveEndScriptName + " Processing OK";
cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, errorMessage, transformMeta);
remarks.add(cr);
}
} catch (Exception e) {
errorMessage = "Couldn't process End Script! Error:" + Const.CR + e.toString();
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta);
remarks.add(cr);
}
} catch (Exception e) {
Context.exit();
errorMessage = BaseMessages.getString(PKG, "ScriptValuesMetaMod.CheckResult.CouldNotCompileScript") + Const.CR + e.toString();
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta);
remarks.add(cr);
}
} else {
Context.exit();
errorMessage = BaseMessages.getString(PKG, "ScriptValuesMetaMod.CheckResult.CouldNotGetFieldsFromPreviousTransform");
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta);
remarks.add(cr);
}
// See if we have input streams leading to this transform!
if (input.length > 0) {
cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "ScriptValuesMetaMod.CheckResult.ConnectedTransformOK2"), transformMeta);
remarks.add(cr);
} else {
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "ScriptValuesMetaMod.CheckResult.NoInputReceived"), transformMeta);
remarks.add(cr);
}
}
use of org.apache.hop.core.ICheckResult in project hop by apache.
the class JaninoMeta method check.
/**
* Checks the settings of this transform and puts the findings in a remarks List.
*
* @param remarks The list to put the remarks in @see org.apache.hop.core.CheckResult
* @param transformMeta The transformMeta to help checking
* @param prev The fields coming from the previous transform
* @param input The input transform names
* @param output The output transform names
* @param info The fields that are used as information by the transform
*/
@Override
public void check(List<ICheckResult> remarks, PipelineMeta pipelineMeta, TransformMeta transformMeta, IRowMeta prev, String[] input, String[] output, IRowMeta info, IVariables variables, IHopMetadataProvider metadataProvider) {
CheckResult cr;
if (prev == null || prev.size() == 0) {
cr = new CheckResult(CheckResult.TYPE_RESULT_WARNING, BaseMessages.getString(PKG, "JaninoMeta.CheckResult.ExpectedInputError"), transformMeta);
remarks.add(cr);
} else {
cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "JaninoMeta.CheckResult.FieldsReceived", "" + prev.size()), transformMeta);
remarks.add(cr);
}
// See if we have input streams leading to this transform!
if (input.length > 0) {
cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "JaninoMeta.CheckResult.ExpectedInputOk"), transformMeta);
remarks.add(cr);
} else {
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "JaninoMeta.CheckResult.ExpectedInputError"), transformMeta);
remarks.add(cr);
}
}
use of org.apache.hop.core.ICheckResult in project hop by apache.
the class ProcessFilesMeta method check.
@Override
public void check(List<ICheckResult> remarks, PipelineMeta pipelineMeta, TransformMeta transformMeta, IRowMeta prev, String[] input, String[] output, IRowMeta info, IVariables variables, IHopMetadataProvider metadataProvider) {
CheckResult cr;
String errorMessage = "";
// source filename
if (Utils.isEmpty(sourceFilenameField)) {
errorMessage = BaseMessages.getString(PKG, "ProcessFilesMeta.CheckResult.SourceFileFieldMissing");
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta);
remarks.add(cr);
} else {
errorMessage = BaseMessages.getString(PKG, "ProcessFilesMeta.CheckResult.TargetFileFieldOK");
cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, errorMessage, transformMeta);
remarks.add(cr);
}
if (operationType != OPERATION_TYPE_DELETE && Utils.isEmpty(targetFilenameField)) {
errorMessage = BaseMessages.getString(PKG, "ProcessFilesMeta.CheckResult.TargetFileFieldMissing");
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta);
remarks.add(cr);
} else {
errorMessage = BaseMessages.getString(PKG, "ProcessFilesMeta.CheckResult.SourceFileFieldOK");
cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, errorMessage, transformMeta);
remarks.add(cr);
}
// See if we have input streams leading to this transform!
if (input.length > 0) {
cr = new CheckResult(ICheckResult.TYPE_RESULT_OK, BaseMessages.getString(PKG, "ProcessFilesMeta.CheckResult.ReceivingInfoFromOtherTransforms"), transformMeta);
remarks.add(cr);
} else {
cr = new CheckResult(ICheckResult.TYPE_RESULT_ERROR, BaseMessages.getString(PKG, "ProcessFilesMeta.CheckResult.NoInpuReceived"), transformMeta);
remarks.add(cr);
}
}
Aggregations