use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class TransTestFactory method generateTestTransformationError.
public static TransMeta generateTestTransformationError(VariableSpace parent, StepMetaInterface oneMeta, String oneStepname) {
TransMeta previewMeta = new TransMeta(parent);
if (parent == null) {
parent = new Variables();
}
// First the injector step...
StepMeta zero = getInjectorStepMeta();
previewMeta.addStep(zero);
// Then the middle step to test...
//
StepMeta one = new StepMeta(registry.getPluginId(StepPluginType.class, oneMeta), oneStepname, oneMeta);
one.setLocation(150, 50);
one.setDraw(true);
previewMeta.addStep(one);
// Then we add the dummy step to read the results from
StepMeta two = getReadStepMeta();
previewMeta.addStep(two);
// error handling step
StepMeta err = getReadStepMeta(ERROR_STEPNAME);
previewMeta.addStep(err);
// Add the hops between the 3 steps.
TransHopMeta zeroOne = new TransHopMeta(zero, one);
previewMeta.addTransHop(zeroOne);
TransHopMeta oneTwo = new TransHopMeta(one, two);
previewMeta.addTransHop(oneTwo);
StepErrorMeta errMeta = new StepErrorMeta(parent, one, err);
errMeta.setEnabled(true);
errMeta.setNrErrorsValuename(NUMBER_ERRORS_FIELD);
errMeta.setErrorDescriptionsValuename(ERROR_DESC_FIELD);
errMeta.setErrorFieldsValuename(ERROR_FIELD_VALUE);
errMeta.setErrorCodesValuename(ERROR_CODE_VALUE);
one.setStepErrorMeta(errMeta);
TransHopMeta oneErr = new TransHopMeta(one, err);
previewMeta.addTransHop(oneErr);
return previewMeta;
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class MessagesSourceCrawler method crawl.
public void crawl() throws Exception {
for (final String sourceDirectory : sourceDirectories) {
FileObject folder = KettleVFS.getFileObject(sourceDirectory);
FileObject[] javaFiles = folder.findFiles(new FileSelector() {
@Override
public boolean traverseDescendents(FileSelectInfo info) throws Exception {
return true;
}
@Override
public boolean includeFile(FileSelectInfo info) throws Exception {
return info.getFile().getName().getExtension().equals("java");
}
});
for (FileObject javaFile : javaFiles) {
/**
* We don't want the Messages.java files, there is nothing in there for us.
*/
boolean skip = false;
for (String filename : filesToAvoid) {
if (javaFile.getName().getBaseName().equals(filename)) {
skip = true;
}
}
if (skip) {
// don't process this file.
continue;
}
// For each of these files we look for keys...
//
lookForOccurrencesInFile(sourceDirectory, javaFile);
}
}
//
for (SourceCrawlerXMLFolder xmlFolder : xmlFolders) {
String[] xmlDirs = { xmlFolder.getFolder() };
String[] xmlMasks = { xmlFolder.getWildcard() };
String[] xmlReq = { "N" };
// search sub-folders too
boolean[] xmlSubdirs = { true };
FileInputList xulFileInputList = FileInputList.createFileList(new Variables(), xmlDirs, xmlMasks, xmlReq, xmlSubdirs);
for (FileObject fileObject : xulFileInputList.getFiles()) {
try {
Document doc = XMLHandler.loadXMLFile(fileObject);
//
for (SourceCrawlerXMLElement xmlElement : xmlFolder.getElements()) {
addLabelOccurrences(xmlFolder.getDefaultSourceFolder(), fileObject, doc.getElementsByTagName(xmlElement.getSearchElement()), xmlFolder.getKeyPrefix(), xmlElement.getKeyTag(), xmlElement.getKeyAttribute(), xmlFolder.getDefaultPackage(), xmlFolder.getPackageExceptions());
}
} catch (KettleXMLException e) {
log.logError("Unable to open XUL / XML document: " + fileObject);
}
}
}
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class EnvUtil method applyKettleProperties.
public static void applyKettleProperties(Map<?, ?> kettleProperties, boolean override) {
Variables variables = new Variables();
for (Object key : kettleProperties.keySet()) {
String variable = (String) key;
String value = variables.environmentSubstitute((String) kettleProperties.get(key));
variables.setVariable(variable, value);
}
Properties systemProperties = System.getProperties();
//
for (String variable : variables.listVariables()) {
String value = variables.getVariable(variable);
//
if (variable.equals(Const.KETTLE_PLUGIN_CLASSES) || variable.equals(Const.KETTLE_PLUGIN_PACKAGES)) {
String jvmValue = System.getProperty(variable);
if (!Utils.isEmpty(jvmValue)) {
if (!Utils.isEmpty(value)) {
value += "," + jvmValue;
} else {
value = jvmValue;
}
}
} else {
if (!override && systemProperties.containsKey(variable)) {
continue;
}
}
System.setProperty(variable, value);
}
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class KettleVFS method reset.
public void reset() {
defaultVariableSpace = new Variables();
defaultVariableSpace.initializeVariablesFrom(null);
fsm.close();
try {
fsm.setFilesCache(new WeakRefFilesCache());
fsm.init();
} catch (FileSystemException ignored) {
}
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class UtilsTest method testResolvePasswordVariable.
@Test
public void testResolvePasswordVariable() {
String passwordKey = "PASS_VAR";
String passwordVar = "${" + passwordKey + "}";
String passwordValue = "password";
Variables vars = new Variables();
vars.setVariable(passwordKey, passwordValue);
// resolvePassword gets variable
assertSame(passwordValue, Utils.resolvePassword(vars, passwordVar).intern());
}
Aggregations