use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class BlackBoxIT method runTrans.
public Result runTrans(String fileName, LogChannelInterface log) throws KettleException {
// Bootstrap the Kettle API...
//
KettleEnvironment.init();
TransMeta transMeta = new TransMeta(fileName);
Trans trans = new Trans(transMeta);
Result result;
try {
trans.setLogLevel(LogLevel.ERROR);
result = trans.getResult();
} catch (Exception e) {
result = trans.getResult();
String message = "Processing has stopped because of an error: " + getPath(fileName);
addFailure(message);
log.logError(message, e);
fail(message);
return result;
}
try {
trans.initializeVariablesFrom(null);
trans.getTransMeta().setInternalKettleVariables(trans);
trans.setSafeModeEnabled(true);
// see if the transformation checks ok
List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
trans.getTransMeta().checkSteps(remarks, false, null, new Variables(), null, null);
for (CheckResultInterface remark : remarks) {
if (remark.getType() == CheckResultInterface.TYPE_RESULT_ERROR) {
// add this to the log
addFailure("Check error: " + getPath(fileName) + ", " + remark.getErrorCode());
log.logError("BlackBoxTest", "Check error: " + getPath(fileName) + ", " + remark.getErrorCode());
}
}
// allocate & run the required sub-threads
try {
trans.execute(null);
} catch (Exception e) {
addFailure("Unable to prepare and initialize this transformation: " + getPath(fileName));
log.logError("BlackBoxTest", "Unable to prepare and initialize this transformation: " + getPath(fileName));
fail("Unable to prepare and initialize this transformation: " + getPath(fileName));
return null;
}
trans.waitUntilFinished();
result = trans.getResult();
// The result flag is not set to true by a transformation - set it to true if got no errors
// FIXME: Find out if there is a better way to check if a transformation has thrown an error
result.setResult(result.getNrErrors() == 0);
return result;
} catch (Exception e) {
addFailure("Unexpected error occurred: " + getPath(fileName));
log.logError("BlackBoxTest", "Unexpected error occurred: " + getPath(fileName), e);
result.setResult(false);
result.setNrErrors(1);
fail("Unexpected error occurred: " + getPath(fileName));
return result;
}
}
use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class BaseStreamStep method init.
public boolean init(StepMetaInterface stepMetaInterface, StepDataInterface stepDataInterface) {
Preconditions.checkNotNull(stepMetaInterface);
stepMeta = (BaseStreamStepMeta) stepMetaInterface;
stepMeta.setParentStepMeta(getStepMeta());
stepMeta.setFileName(stepMeta.getTransformationPath());
boolean superInit = super.init(stepMetaInterface, stepDataInterface);
try {
TransMeta transMeta = TransExecutorMeta.loadMappingMeta(stepMeta, getTransMeta().getRepository(), getTransMeta().getMetaStore(), getParentVariableSpace());
subtransExecutor = new SubtransExecutor(getStepname(), getTrans(), transMeta, true, new TransExecutorParameters(), environmentSubstitute(stepMeta.getSubStep()));
} catch (KettleException e) {
log.logError(e.getLocalizedMessage(), e);
return false;
}
List<CheckResultInterface> remarks = new ArrayList<>();
stepMeta.check(remarks, getTransMeta(), stepMeta.getParentStepMeta(), // these parameters are not used inside the method
null, // these parameters are not used inside the method
null, // these parameters are not used inside the method
null, // these parameters are not used inside the method
null, variables, getRepository(), getMetaStore());
boolean errorsPresent = remarks.stream().filter(result -> result.getType() == CheckResultInterface.TYPE_RESULT_ERROR).peek(result -> logError(result.getText())).count() > 0;
if (errorsPresent) {
return false;
}
return superInit;
}
use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class RowGenerator method init.
@Override
public boolean init(StepMetaInterface smi, StepDataInterface sdi) {
try {
meta = (RowGeneratorMeta) smi;
data = (RowGeneratorData) sdi;
if (super.init(smi, sdi)) {
// Determine the number of rows to generate...
data.rowLimit = Const.toLong(environmentSubstitute(meta.getRowLimit()), -1L);
data.rowsWritten = 0L;
data.delay = Const.toLong(environmentSubstitute(meta.getIntervalInMs()), -1L);
if (data.rowLimit < 0L) {
// Unable to parse
logError(BaseMessages.getString(PKG, "RowGenerator.Wrong.RowLimit.Number"));
// fail
return false;
}
// Create a row (constants) with all the values in it...
// stores the errors...
List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
RowMetaAndData outputRow = buildRow(meta, remarks, getStepname());
if (!remarks.isEmpty()) {
for (int i = 0; i < remarks.size(); i++) {
CheckResult cr = (CheckResult) remarks.get(i);
logError(cr.getText());
}
return false;
}
data.outputRowData = outputRow.getData();
data.outputRowMeta = outputRow.getRowMeta();
return true;
}
return false;
} catch (Exception e) {
setErrors(1L);
logError("Error initializing step", e);
return false;
}
}
use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class RowGeneratorMeta method getFields.
public void getFields(RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
try {
List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
RowMetaAndData rowMetaAndData = RowGenerator.buildRow(this, remarks, origin);
if (!remarks.isEmpty()) {
StringBuilder stringRemarks = new StringBuilder();
for (CheckResultInterface remark : remarks) {
stringRemarks.append(remark.toString()).append(Const.CR);
}
throw new KettleStepException(stringRemarks.toString());
}
for (ValueMetaInterface valueMeta : rowMetaAndData.getRowMeta().getValueMetaList()) {
valueMeta.setOrigin(origin);
}
row.mergeRowMeta(rowMetaAndData.getRowMeta());
} catch (Exception e) {
throw new KettleStepException(e);
}
}
use of org.pentaho.di.core.CheckResultInterface in project pdi-dataservice-server-plugin by pentaho.
the class MongoDbBasicValidation method checkStep.
@Override
public void checkStep(CheckStepsExtension checkStepExtension, DataServiceMeta dataServiceMeta, LogChannelInterface log) {
StepMeta stepMeta = checkStepExtension.getStepMetas()[0];
List<CheckResultInterface> remarks = checkStepExtension.getRemarks();
MongoDbInputMeta mongoDbMeta = (MongoDbInputMeta) checkStepExtension.getStepMetas()[0].getStepMetaInterface();
VariableSpace space = checkStepExtension.getVariableSpace();
checkOutputJson(stepMeta, remarks, mongoDbMeta);
checkPushdownParameter(stepMeta, remarks, mongoDbMeta, space);
checkParameterGenerationOptimizedMeta(checkStepExtension, dataServiceMeta, log);
}
Aggregations