本文整理汇总了Java中org.pentaho.di.core.util.EnvUtil.environmentInit方法的典型用法代码示例。如果您正苦于以下问题:Java EnvUtil.environmentInit方法的具体用法?Java EnvUtil.environmentInit怎么用?Java EnvUtil.environmentInit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.core.util.EnvUtil
的用法示例。
在下文中一共展示了EnvUtil.environmentInit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
@Override
public void init(AppView app) throws BeanFactoryException {
this.app = app;
// dlSystem = (DataLogicSystem) app.getBean(DataLogicSystem.class.getName());
// hostProp = dlSystem.getResourceAsProperties(app.getProperties() + "/properties");
this.app.waitCursorBegin();
try {
KettleEnvironment.init(false);
EnvUtil.environmentInit();
} catch (KettleException ex) {
MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.syncerror"), ex);
msg.show(this);
}
this.app.waitCursorEnd();
}
示例2: main
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
/**
* 1) create a new transformation <br>
* 2) Express the transformation as XML file <br>
* 3) Execute the transformation <br>
* <br>
* @param args
*/
public static void main(String[] args) throws Exception
{
EnvUtil.environmentInit();
// Init the logging...
//
LogWriter.getInstance("TransBuilderFilter.log", true, LogWriter.LOG_LEVEL_DETAILED);
// Load the Kettle steps & plugins
StepLoader.init();
// The parameters we want, optionally this can be
String transformationName = "Filter test Transformation";
TransMeta transMeta = buildFilterSample(transformationName);
System.out.println(transMeta.getXML());
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.execute(null);
trans.waitUntilFinished();
}
示例3: init
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
public static synchronized void init() throws KettleException {
if (initialized!=null) {
return;
}
createKettleHome();
// Read the kettle.properties file before anything else
//
EnvUtil.environmentInit();
// Load value meta data plugins
//
PluginRegistry.addPluginType(ValueMetaPluginType.getInstance());
PluginRegistry.init(true);
initialized=new Boolean(true);
}
示例4: testCaseInsensitiveNoPreviousSort
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
public void testCaseInsensitiveNoPreviousSort() throws Exception
{
EnvUtil.environmentInit();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("uniquerowstest");
StepLoader steploader = StepLoader.getInstance();
//
// create an injector step...
//
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = steploader.getStepPluginID(im);
StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)im);
transMeta.addStep(injectorStep);
//
// Create a unique rows step
//
String uniqueRowsStepname = "unique rows step";
UniqueRowsMeta urm = new UniqueRowsMeta();
urm.setCompareFields(new String[] {"KEY"});
urm.setCaseInsensitive(new boolean[] {true});
String uniqueRowsStepPid = steploader.getStepPluginID(urm);
StepMeta uniqueRowsStep = new StepMeta(uniqueRowsStepPid, uniqueRowsStepname, (StepMetaInterface)urm);
transMeta.addStep(uniqueRowsStep);
transMeta.addTransHop(new TransHopMeta(injectorStep, uniqueRowsStep));
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = steploader.getStepPluginID(dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
transMeta.addStep(dummyStep);
transMeta.addTransHop(new TransHopMeta(uniqueRowsStep, dummyStep));
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector dummyRc = new RowStepCollector();
si.addRowListener(dummyRc);
RowProducer rp = trans.addRowProducer(injectorStepname, 0);
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
for ( RowMetaAndData rm : inputList )
{
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
trans.waitUntilFinished();
List<RowMetaAndData> resultRows = dummyRc.getRowsWritten();
checkRows(createResultDataCaseInsensitiveNoPreviousSort(), resultRows);
}
示例5: validateAndInitialiseKettelEngine
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
private void validateAndInitialiseKettelEngine() throws GraphGeneratorException {
File file = new File(
outputLocation + File.separator + schemaInfo.getDatabaseName() + File.separator
+ this.tableName + File.separator + this.segmentId + File.separator + this.taskNo
+ File.separator);
boolean isDirCreated = false;
if (!file.exists()) {
isDirCreated = file.mkdirs();
if (!isDirCreated) {
LOGGER.error(
"Unable to create directory or directory already exist" + file.getAbsolutePath());
throw new GraphGeneratorException("INTERNAL_SYSTEM_ERROR");
}
}
synchronized (DRIVERS) {
try {
if (!kettleInitialized) {
EnvUtil.environmentInit();
KettleEnvironment.init();
kettleInitialized = true;
}
} catch (KettleException kettlExp) {
LOGGER.error(kettlExp);
throw new GraphGeneratorException("Error While Initializing the Kettel Engine ", kettlExp);
}
}
}
示例6: testTransformationDependencyList
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
public void testTransformationDependencyList() throws Exception {
EnvUtil.environmentInit();
LogWriter.getInstance(LogWriter.LOG_LEVEL_BASIC);
StepLoader.init();
TransMeta transMeta = new TransMeta("test/org/pentaho/di/resource/trans/General - Change log processing.ktr"); //$NON-NLS-1$
List<ResourceReference> resourceReferences = transMeta.getResourceDependencies();
// printResourceReferences(resourceReferences);
assertEquals(2, resourceReferences.size());
ResourceReference genRef = null;
for (ResourceReference look : resourceReferences) {
if (look.getReferenceHolder().getTypeId().equals("TextFileInput")) {
genRef = look;
}
}
assertNotNull(genRef);
// System.out.println(genRef.toXml());
ResourceHolderInterface refHolder = genRef.getReferenceHolder();
assertEquals("TextFileInput", refHolder.getTypeId()); //$NON-NLS-1$
List<ResourceEntry> entries = genRef.getEntries();
assertEquals(1, entries.size());
ResourceEntry theEntry = entries.get(0);
assertEquals(ResourceType.FILE, theEntry.getResourcetype());
assertTrue(theEntry.getResource().endsWith("changelog.txt")); //$NON-NLS-1$
}
示例7: testJobExport
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
public void testJobExport() throws Exception {
EnvUtil.environmentInit();
LogWriter.getInstance(LogWriter.LOG_LEVEL_BASIC);
StepLoader.init();
JobEntryLoader.init();
// Load the job metadata
//
String filename = "test/org/pentaho/di/resource/top-job.kjb";
JobMeta jobMeta = new JobMeta(LogWriter.getInstance(), filename, null, null);
// This job meta object references a few transformations, another job and a mapping
// All these need to be exported
// To handle the file-naming, we need a renaming service...
//
UUIDResourceNaming resourceNaming = new UUIDResourceNaming();
// We need a storage facility to keep all the generated code, the filenames, etc.
//
Map<String, ResourceDefinition> definitions = new Hashtable<String, ResourceDefinition>();
// We get back the top-level filename: it's the starting point...
//
String topLevelFilename = jobMeta.exportResources(jobMeta, definitions, resourceNaming, null);
System.out.println("Top level filename = "+topLevelFilename);
for (ResourceDefinition resourceDefinition : definitions.values()) {
System.out.println("Found resource definition: "+resourceDefinition.getFilename());
}
assertEquals(definitions.size(), 3);
}
示例8: init
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
protected void init() throws Exception {
EnvUtil.environmentInit();
LogWriter.getInstance( LogWriter.LOG_LEVEL_ERROR);
StepLoader.init();
JobEntryLoader.init();
}
示例9: setupDatabase
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
public Database setupDatabase() throws Exception
{
Database database = null;
// LogWriter log = LogWriter.getInstance();
EnvUtil.environmentInit();
try
{
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("transname");
// Add the database connections
for (int i=0;i<databasesXML.length;i++)
{
DatabaseMeta databaseMeta = new DatabaseMeta(databasesXML[i]);
transMeta.addDatabase(databaseMeta);
}
DatabaseMeta dbInfo = transMeta.findDatabase("db");
database = new Database(dbInfo);
database.connect();
}
finally { };
return database;
}
示例10: postConstruct
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
@PostConstruct
public void postConstruct() throws KettleException, IOException {
// First, set plugin dir
Path pluginDir = config.getApplicationHomeDirectory().resolve("kettle/plugins");
System.setProperty("KETTLE_PLUGIN_BASE_FOLDERS", pluginDir.toString());
// Second, configure Kettle env
KettleEnvironment.init(false);
EnvUtil.environmentInit();
// Lastly, configure shared objects
configureSharedObjects();
}
开发者ID:Apereo-Learning-Analytics-Initiative,项目名称:LearningAnalyticsProcessor,代码行数:14,代码来源:KettleConfiguration.java
示例11: executeTransformation
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
public Map<String, Object> executeTransformation(String ktrPath) {
Map<String, Object> executionResult = new HashMap<String, Object>();
try {
KettleEnvironment.init();
EnvUtil.environmentInit();
TransMeta transMeta = new TransMeta(ktrPath);
List<DatabaseMeta> dbMetaList = transMeta.getDatabases();
for (DatabaseMeta dbMeta : dbMetaList) {
if (dbMeta.getName().equals(this.connectionName)) {
dbMeta.setHostname(this.dbHostName);
dbMeta.setUsername(this.dbUerName);
dbMeta.setPassword(this.dbPassword);
dbMeta.setDBPort(this.dbPort);
dbMeta.setDBName(this.dbName);
}
}
Trans transformation = new Trans(transMeta);
if (this.parameters != null) {
for (Map.Entry<String, String> entry : this.parameters.entrySet()) {
transformation.setParameterValue((String) entry.getKey(), (String) entry.getValue());
}
}
transformation.execute(null);
transformation.waitUntilFinished();
for (StepMetaDataCombi combi : transformation.getSteps()) {
StepDTO stepDTO = new StepDTO();
stepDTO.setStepName(combi.step.getStepname());
stepDTO.setLinesInput(Long.valueOf(combi.step.getLinesInput()));
stepDTO.setLinesOutput(Long.valueOf(combi.step.getLinesOutput()));
stepDTO.setLinesRead(Long.valueOf(combi.step.getLinesRead()));
stepDTO.setLinesRejected(Long.valueOf(combi.step.getLinesRejected()));
stepDTO.setLinesUpdated(Long.valueOf(combi.step.getLinesUpdated()));
stepDTO.setStepDestinationNameList(new ArrayList<String>());
for (RowSet rowSet : combi.step.getOutputRowSets()) {
stepDTO.getStepDestinationNameList().add(rowSet.getDestinationStepName());
}
this.getStepDTOList().add(stepDTO);
}
if (transformation.getErrors() > 0) {
System.out.println("Erroruting Transformation");
executionResult.put("transformationExecuted", false);
return executionResult;
} else {
executionResult.put("transformationExecuted", true);
return executionResult;
}
} catch (Exception e) {
e.printStackTrace();
executionResult.put("transformationExecuted", false);
return executionResult;
}
}
示例12: main
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
/**
* This is the main procedure for Spoon.
*
* @param a
* Arguments are available in the "Get System Info" step.
*/
public static void main(String[] a) throws KettleException {
try {
// Do some initialization of environment variables
EnvUtil.environmentInit();
List<String> args = new ArrayList<String>(java.util.Arrays.asList(a));
Display display = new Display();
Splash splash = new Splash(display);
CommandLineOption[] commandLineOptions = getCommandLineArgs(args);
initLogging(commandLineOptions);
initPlugins();
PropsUI.init(display, Props.TYPE_PROPERTIES_SPOON); // things to //
// remember...
staticSpoon = new Spoon(display);
staticSpoon.init(null);
SpoonFactory.setSpoonInstance(staticSpoon);
staticSpoon.setDestroy(true);
GUIFactory.setThreadDialogs(new ThreadGuiResources());
if (LogWriter.getInstance().isBasic()) {
LogWriter.getInstance().logBasic(APP_NAME, Messages.getString("Spoon.Log.MainWindowCreated"));// Main window is created.
}
// listeners
//
try {
staticSpoon.lcsup.onStart(staticSpoon);
} catch (LifecycleException e) {
// if severe, we have to quit
MessageBox box = new MessageBox(staticSpoon.shell, (e.isSevere() ? SWT.ICON_ERROR : SWT.ICON_WARNING) | SWT.OK);
box.setMessage(e.getMessage());
box.open();
}
staticSpoon.setArguments(args.toArray(new String[args.size()]));
staticSpoon.start(splash, commandLineOptions);
} catch (Throwable t) {
// avoid calls to Messages i18n method getString() in this block
// We do this to (hopefully) also catch Out of Memory Exceptions
//
LogWriter.getInstance().logError(APP_NAME, "Fatal error : " + Const.NVL(t.toString(), Const.NVL(t.getMessage(), "Unknown error"))); //$NON-NLS-1$ //$NON-NLS-2$
LogWriter.getInstance().logError(APP_NAME, Const.getStackTracker(t));
// inform the user with a dialog when possible
new ErrorDialog(staticSpoon.shell, Messages.getString("Spoon.Dialog.FatalError"), "Fatal error : " + Const.NVL(t.toString(), Const.NVL(t.getMessage(), "Unknown error")), t); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
// Kill all remaining things in this VM!
System.exit(0);
}
示例13: testCombinationLookup
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
/**
* Test case for Combination lookup/update.
*/
public void testCombinationLookup() throws Exception
{
EnvUtil.environmentInit();
try
{
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("transname");
// Add the database connections
for (int i=0;i<databasesXML.length;i++)
{
DatabaseMeta databaseMeta = new DatabaseMeta(databasesXML[i]);
transMeta.addDatabase(databaseMeta);
}
DatabaseMeta lookupDBInfo = transMeta.findDatabase("lookup");
// Execute our setup SQLs in the database.
Database lookupDatabase = new Database(lookupDBInfo);
lookupDatabase.connect();
createTables(lookupDatabase);
createData(lookupDatabase);
StepLoader steploader = StepLoader.getInstance();
//
// create the source step...
//
String fromstepname = "read from [" + source_table + "]";
TableInputMeta tii = new TableInputMeta();
tii.setDatabaseMeta(transMeta.findDatabase("lookup"));
String selectSQL = "SELECT "+Const.CR;
selectSQL+="DLR_CD, DLR_NM, DLR_DESC ";
selectSQL+="FROM " + source_table + " ORDER BY ORDNO;";
tii.setSQL(selectSQL);
String fromstepid = steploader.getStepPluginID(tii);
StepMeta fromstep = new StepMeta(fromstepid, fromstepname, (StepMetaInterface) tii);
fromstep.setLocation(150, 100);
fromstep.setDraw(true);
fromstep.setDescription("Reads information from table [" + source_table + "] on database [" + lookupDBInfo + "]");
transMeta.addStep(fromstep);
//
// create the combination lookup/update step...
//
String lookupstepname = "lookup from [lookup]";
CombinationLookupMeta clm = new CombinationLookupMeta();
String lookupKey[] = { "DLR_CD" };
clm.setTablename(target_table);
clm.setKeyField(lookupKey);
clm.setKeyLookup(lookupKey);
clm.setTechnicalKeyField("ID");
clm.setTechKeyCreation(CombinationLookupMeta.CREATION_METHOD_TABLEMAX);
clm.setDatabaseMeta(lookupDBInfo);
String lookupstepid = steploader.getStepPluginID(clm);
StepMeta lookupstep = new StepMeta(lookupstepid, lookupstepname, (StepMetaInterface) clm);
lookupstep.setDescription("Looks up information from table [lookup] on database [" + lookupDBInfo + "]");
transMeta.addStep(lookupstep);
TransHopMeta hi = new TransHopMeta(fromstep, lookupstep);
transMeta.addTransHop(hi);
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.execute(null);
trans.waitUntilFinished();
checkResults(lookupDatabase);
}
finally {}
}
示例14: testStringsNum
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
public void testStringsNum() throws Exception
{
EnvUtil.environmentInit();
Locale.setDefault(Locale.ENGLISH);
//
// Create a javascript step
//
ScriptValuesMetaMod svm = new ScriptValuesMetaMod();
ScriptValuesScript[] js = new ScriptValuesScript[] {new ScriptValuesScript(ScriptValuesScript.TRANSFORM_SCRIPT,
"script",
"var numb1 = str2num(trim(string.getString()), \"#.#\", \"en\");\n" +
"var bool1 = isNum(string.getString());\n" +
"var str1 = num2str(numb1);\n") };
svm.setJSScripts(js);
svm.setName(new String[] { "numb1", "bool1", "str1" });
svm.setRename(new String[] { "", "", "" });
svm.setType(new int[] { ValueMetaInterface.TYPE_NUMBER,
ValueMetaInterface.TYPE_BOOLEAN,
ValueMetaInterface.TYPE_STRING});
svm.setLength(new int[] { -1, -1, -1 });
svm.setPrecision(new int[] { -1, -1, -1 });
svm.setReplace(new boolean[] { false, false, false, });
svm.setCompatible(true);
// Generate a test transformation with an injector and a dummy:
//
String testStepname = "javascript";
TransMeta transMeta = TransTestFactory.generateTestTransformation(new Variables(), svm, testStepname);
// Now execute the transformation and get the result from the dummy step.
//
List<RowMetaAndData> result = TransTestFactory.executeTestTransformation(
transMeta,
TransTestFactory.INJECTOR_STEPNAME,
testStepname,
TransTestFactory.DUMMY_STEPNAME,
createData3()
);
// Verify that this is what we expected...
//
checkRows(result, createResultData3());
}
示例15: testIndexOf
import org.pentaho.di.core.util.EnvUtil; //导入方法依赖的package包/类
/**
* Test case for javascript functionality: indexOf().
*/
public void testIndexOf() throws Exception
{
EnvUtil.environmentInit();
//
// Create a javascript step
//
String javaScriptStepname = "javascript step";
ScriptValuesMetaMod svm = new ScriptValuesMetaMod();
ScriptValuesScript[] js = new ScriptValuesScript[] {new ScriptValuesScript(ScriptValuesScript.TRANSFORM_SCRIPT,
"script",
"var index1 = indexOf(string.getString(), search.getString());\n" +
"var index2 = indexOf(string.getString(), search.getString(), offset1.getInteger());\n" +
"var index3 = indexOf(string.getString(), search.getString(), offset2.getInteger());\n") };
svm.setJSScripts(js);
svm.setName(new String[] { "index1", "index2", "index3" });
svm.setRename(new String[] { "", "", "" });
svm.setType(new int[] { ValueMetaInterface.TYPE_INTEGER,
ValueMetaInterface.TYPE_INTEGER,
ValueMetaInterface.TYPE_INTEGER});
svm.setLength(new int[] { -1, -1, -1 });
svm.setPrecision(new int[] { -1, -1, -1 });
svm.setReplace(new boolean[] { false, false, false, });
svm.setCompatible(true);
// Generate a test transformation with an injector and a dummy:
//
TransMeta transMeta = TransTestFactory.generateTestTransformation(new Variables(), svm, javaScriptStepname);
// Now execute the transformation and get the result from the dummy step.
//
List<RowMetaAndData> result = TransTestFactory.executeTestTransformation
(
transMeta,
TransTestFactory.INJECTOR_STEPNAME,
javaScriptStepname,
TransTestFactory.DUMMY_STEPNAME,
createData4()
);
// Verify that this is what we expected...
//
checkRows(result, createResultData4());
}