use of org.pentaho.metaverse.api.model.IParamInfo in project pentaho-metaverse by pentaho.
the class JobRuntimeExtensionPoint method populateExecutionProfile.
protected void populateExecutionProfile(IExecutionProfile executionProfile, Job job) {
JobMeta jobMeta = job.getJobMeta();
String filename = getFilename(job);
String filePath = null;
if (job.getRep() == null) {
try {
filePath = KettleAnalyzerUtil.normalizeFilePath(filename);
} catch (Exception e) {
log.warn("Couldn't normalize file path: " + filename, e);
filePath = filename;
}
} else {
filePath = filename;
}
// Set artifact information (path, type, description, etc.)
executionProfile.setPath(filePath);
executionProfile.setName(jobMeta.getName());
executionProfile.setType(DictionaryConst.NODE_TYPE_JOB);
executionProfile.setDescription(jobMeta.getDescription());
// Set execution engine information
executionProfile.setExecutionEngine(getExecutionEngineInfo());
IExecutionData executionData = executionProfile.getExecutionData();
// Store execution information (client, server, user, etc.)
executionData.setStartTime(new Timestamp(new Date().getTime()));
KettleClientEnvironment.ClientType clientType = KettleClientEnvironment.getInstance().getClient();
executionData.setClientExecutor(clientType == null ? "DI Server" : clientType.name());
executionData.setExecutorUser(job.getExecutingUser());
executionData.setExecutorServer(job.getExecutingServer());
// Store variables
List<String> vars = jobMeta.getUsedVariables();
Map<Object, Object> variableMap = executionData.getVariables();
for (String var : vars) {
String value = job.getVariable(var);
if (value != null) {
variableMap.put(var, value);
}
}
// Store parameters
String[] params = job.listParameters();
List<IParamInfo<String>> paramList = executionData.getParameters();
if (params != null) {
for (String param : params) {
try {
ParamInfo paramInfo = new ParamInfo(param, job.getParameterDescription(param), job.getParameterDefault(param));
paramList.add(paramInfo);
} catch (UnknownParamException e) {
e.printStackTrace();
}
}
}
// Store arguments
String[] args = job.getArguments();
List<Object> argList = executionData.getArguments();
if (args != null) {
argList.addAll(Arrays.asList(args));
}
}
use of org.pentaho.metaverse.api.model.IParamInfo in project pentaho-metaverse by pentaho.
the class TransformationRuntimeExtensionPoint method populateExecutionProfile.
protected void populateExecutionProfile(IExecutionProfile executionProfile, Trans trans) {
TransMeta transMeta = trans.getTransMeta();
String filename = trans.getFilename();
if (filename == null) {
filename = transMeta.getPathAndName();
}
String filePath = null;
if (trans.getRepository() == null) {
try {
filePath = KettleAnalyzerUtil.normalizeFilePath(filename);
} catch (Exception e) {
log.warn("Couldn't normalize file path: " + filename, e);
filePath = filename;
}
} else {
filePath = filename;
}
// Set artifact information (path, type, description, etc.)
executionProfile.setPath(filePath);
executionProfile.setName(transMeta.getName());
executionProfile.setType(DictionaryConst.NODE_TYPE_TRANS);
executionProfile.setDescription(transMeta.getDescription());
// Set execution engine information
executionProfile.setExecutionEngine(getExecutionEngineInfo());
IExecutionData executionData = executionProfile.getExecutionData();
// Store execution information (client, server, user, etc.)
executionData.setStartTime(new Timestamp(new Date().getTime()));
KettleClientEnvironment.ClientType clientType = KettleClientEnvironment.getInstance().getClient();
executionData.setClientExecutor(clientType == null ? "DI Server" : clientType.name());
executionData.setExecutorUser(trans.getExecutingUser());
executionData.setExecutorServer(trans.getExecutingServer());
// Store variables
List<String> vars = transMeta.getUsedVariables();
Map<Object, Object> variableMap = executionData.getVariables();
for (String var : vars) {
String value = trans.getVariable(var);
if (var != null && value != null) {
variableMap.put(var, value);
}
}
// Store parameters
String[] params = trans.listParameters();
List<IParamInfo<String>> paramList = executionData.getParameters();
if (params != null) {
for (String param : params) {
try {
ParamInfo paramInfo = new ParamInfo(param, trans.getParameterDescription(param), trans.getParameterDefault(param));
paramList.add(paramInfo);
} catch (UnknownParamException e) {
log.error("Couldn't find transformation parameter: " + param, e);
}
}
}
// Store arguments
String[] args = trans.getArguments();
List<Object> argList = executionData.getArguments();
if (args != null) {
argList.addAll(Arrays.asList(args));
}
}
use of org.pentaho.metaverse.api.model.IParamInfo in project pentaho-metaverse by pentaho.
the class ExecutionDataTest method testGetSetAddParameters.
@Test
public void testGetSetAddParameters() {
List<IParamInfo<String>> parameters = new ArrayList<IParamInfo<String>>();
parameters.add(new ParamInfo("Larry", "fine"));
parameters.add(new ParamInfo("moe", "howard"));
parameters.add(new ParamInfo("curly", "fine"));
assertEquals(executionData.getParameters().size(), 0);
executionData.setParameters(parameters);
assertEquals(executionData.getParameters().size(), 3);
executionData.addParameter(new ParamInfo("Shemp", "Howard"));
}
Aggregations