Search in sources :

Example 6 with ParamInfo

use of org.pentaho.metaverse.impl.model.ParamInfo 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));
    }
}
Also used : KettleClientEnvironment(org.pentaho.di.core.KettleClientEnvironment) IParamInfo(org.pentaho.metaverse.api.model.IParamInfo) TransMeta(org.pentaho.di.trans.TransMeta) Timestamp(java.sql.Timestamp) KettleException(org.pentaho.di.core.exception.KettleException) MetaverseException(org.pentaho.metaverse.api.MetaverseException) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) Date(java.util.Date) IExecutionData(org.pentaho.metaverse.api.model.IExecutionData) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) IParamInfo(org.pentaho.metaverse.api.model.IParamInfo) ParamInfo(org.pentaho.metaverse.impl.model.ParamInfo)

Aggregations

ParamInfo (org.pentaho.metaverse.impl.model.ParamInfo)6 UnknownParamException (org.pentaho.di.core.parameters.UnknownParamException)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 IOException (java.io.IOException)2 Timestamp (java.sql.Timestamp)2 Date (java.util.Date)2 ExecutionException (java.util.concurrent.ExecutionException)2 KettleClientEnvironment (org.pentaho.di.core.KettleClientEnvironment)2 KettleException (org.pentaho.di.core.exception.KettleException)2 MetaverseException (org.pentaho.metaverse.api.MetaverseException)2 IExecutionData (org.pentaho.metaverse.api.model.IExecutionData)2 IParamInfo (org.pentaho.metaverse.api.model.IParamInfo)2 DuplicateParamException (org.pentaho.di.core.parameters.DuplicateParamException)1 JobMeta (org.pentaho.di.job.JobMeta)1 TransMeta (org.pentaho.di.trans.TransMeta)1