当前位置: 首页>>代码示例>>Java>>正文


Java JobExecutionConfiguration.setVariables方法代码示例

本文整理汇总了Java中org.pentaho.di.job.JobExecutionConfiguration.setVariables方法的典型用法代码示例。如果您正苦于以下问题:Java JobExecutionConfiguration.setVariables方法的具体用法?Java JobExecutionConfiguration.setVariables怎么用?Java JobExecutionConfiguration.setVariables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pentaho.di.job.JobExecutionConfiguration的用法示例。


在下文中一共展示了JobExecutionConfiguration.setVariables方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeJob

import org.pentaho.di.job.JobExecutionConfiguration; //导入方法依赖的package包/类
public void executeJob(JobMeta jobMeta, boolean local, boolean remote, Date replayDate, boolean safe) throws KettleException {
	
	if (jobMeta == null) {
		return;
	}
	
	JobExecutionConfiguration executionConfiguration = spoon.getJobExecutionConfiguration();

	// Remember the variables set previously
	//
	Object data[] = spoon.variables.getData();
	String fields[] = spoon.variables.getRowMeta().getFieldNames();
	Map<String, String> variableMap = new HashMap<String, String>();
	for (int idx = 0; idx < fields.length; idx++) {
		variableMap.put(fields[idx], data[idx].toString());
	}
	
	executionConfiguration.setVariables(variableMap);
	executionConfiguration.getUsedVariables(jobMeta);
	executionConfiguration.setReplayDate(replayDate);
	executionConfiguration.setRepository(spoon.rep);
	executionConfiguration.setSafeModeEnabled(safe);

	executionConfiguration.setLogLevel(spoon.getLog().getLogLevel());

	JobExecutionConfigurationDialog dialog = new JobExecutionConfigurationDialog(spoon.getShell(), executionConfiguration, jobMeta);
	if (dialog.open()) {
		// addJobLog(jobMeta);
		JobGraph jobGraph = spoon.getActiveJobGraph();

		LogWriter.getInstance().setLogLevel(executionConfiguration.getLogLevel());

		// Set the variables that where specified...
		//
		for (String varName : executionConfiguration.getVariables().keySet())
		{
			String varValue = executionConfiguration.getVariables().get(varName);
			jobMeta.setVariable(varName, varValue);
		}
		
		// Set and activate the parameters...
		//
		for (String paramName : executionConfiguration.getParams().keySet()) 
		{
			String paramValue = executionConfiguration.getParams().get(paramName);
			jobMeta.setParameterValue(paramName, paramValue);
		}
		
		// Set the arguments too...
		//
		jobMeta.setArguments(executionConfiguration.getArgumentStrings());

		// Is this a local execution?
		//
		if (executionConfiguration.isExecutingLocally()) {
			jobGraph.startJob(executionConfiguration);
		}
			
		// Are we executing remotely?
		//
		else if (executionConfiguration.isExecutingRemotely()) {
			
			// Activate the parameters, turn them into variables...
			//
			jobMeta.activateParameters();
			
			if (executionConfiguration.getRemoteServer() != null) {
				Job.sendToSlaveServer(jobMeta, executionConfiguration, spoon.rep);
				spoon.delegates.slaves.addSpoonSlave(executionConfiguration.getRemoteServer());
			} else {
				MessageBox mb = new MessageBox(spoon.getShell(), SWT.OK | SWT.ICON_ERROR);
				mb.setMessage(Messages.getString("Spoon.Dialog.NoRemoteServerSpecified.Message"));
				mb.setText(Messages.getString("Spoon.Dialog.NoRemoteServerSpecified.Title"));
				mb.open();
			}
		}
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:79,代码来源:SpoonJobDelegate.java

示例2: executeJob

import org.pentaho.di.job.JobExecutionConfiguration; //导入方法依赖的package包/类
public void executeJob(JobMeta jobMeta, boolean local, boolean remote, Date replayDate, boolean safe, String startCopyName, int startCopyNr) throws KettleException {
	
	if (jobMeta == null) {
		return;
	}
	
	JobExecutionConfiguration executionConfiguration = spoon.getJobExecutionConfiguration();

	// Remember the variables set previously
	//
	Object data[] = spoon.variables.getData();
	String fields[] = spoon.variables.getRowMeta().getFieldNames();
	Map<String, String> variableMap = new HashMap<String, String>();
	for (int idx = 0; idx < fields.length; idx++) {
		variableMap.put(fields[idx], data[idx].toString());
	}
	
	executionConfiguration.setVariables(variableMap);
	executionConfiguration.getUsedVariables(jobMeta);
	executionConfiguration.setReplayDate(replayDate);
	executionConfiguration.setRepository(spoon.rep);
	executionConfiguration.setSafeModeEnabled(safe);
	executionConfiguration.setStartCopyName(startCopyName);
	executionConfiguration.setStartCopyNr(startCopyNr);
   
	executionConfiguration.setLogLevel(DefaultLogLevel.getLogLevel());

	JobExecutionConfigurationDialog dialog = new JobExecutionConfigurationDialog(spoon.getShell(), executionConfiguration, jobMeta);
	if (dialog.open()) {
		// addJobLog(jobMeta);
		JobGraph jobGraph = spoon.getActiveJobGraph();

		// Set the variables that where specified...
		//
		for (String varName : executionConfiguration.getVariables().keySet())
		{
			String varValue = executionConfiguration.getVariables().get(varName);
			jobMeta.setVariable(varName, varValue);
		}
		
		// Set and activate the parameters...
		//
		for (String paramName : executionConfiguration.getParams().keySet()) 
		{
			String paramValue = executionConfiguration.getParams().get(paramName);
			jobMeta.setParameterValue(paramName, paramValue);
		}
		
		// Set the arguments too...
		//
		jobMeta.setArguments(executionConfiguration.getArgumentStrings());

		// Is this a local execution?
		//
		if (executionConfiguration.isExecutingLocally()) {
			jobGraph.startJob(executionConfiguration);
		}
			
		// Are we executing remotely?
		//
		else if (executionConfiguration.isExecutingRemotely()) {
			
			// Activate the parameters, turn them into variables...
			//
			jobMeta.activateParameters();
			
			if (executionConfiguration.getRemoteServer() != null) {
				Job.sendToSlaveServer(jobMeta, executionConfiguration, spoon.rep);
				spoon.delegates.slaves.addSpoonSlave(executionConfiguration.getRemoteServer());
			} else {
				MessageBox mb = new MessageBox(spoon.getShell(), SWT.OK | SWT.ICON_ERROR);
				mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.NoRemoteServerSpecified.Message")); //$NON-NLS-1$
				mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.NoRemoteServerSpecified.Title")); //$NON-NLS-1$
				mb.open();
			}
		}
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:79,代码来源:SpoonJobDelegate.java


注:本文中的org.pentaho.di.job.JobExecutionConfiguration.setVariables方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。