Search in sources :

Example 1 with ParamInfo

use of org.pentaho.metaverse.impl.model.ParamInfo in project pentaho-metaverse by pentaho.

the class TransMetaJsonDeserializer method deserializeParameters.

protected void deserializeParameters(TransMeta transMeta, JsonNode node, ObjectMapper mapper) throws IOException {
    ArrayNode paramsArrayNode = (ArrayNode) node.get(TransMetaJsonSerializer.JSON_PROPERTY_PARAMETERS);
    for (int i = 0; i < paramsArrayNode.size(); i++) {
        JsonNode paramNode = paramsArrayNode.get(i);
        ParamInfo param = mapper.readValue(paramNode.toString(), ParamInfo.class);
        try {
            transMeta.addParameterDefinition(param.getName(), param.getDefaultValue(), param.getDescription());
        } catch (DuplicateParamException e) {
            LOGGER.warn(Messages.getString("WARNING.Deserialization.Trans.DuplicateParam", param.getName()), e);
        }
    }
}
Also used : DuplicateParamException(org.pentaho.di.core.parameters.DuplicateParamException) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ParamInfo(org.pentaho.metaverse.impl.model.ParamInfo)

Example 2 with ParamInfo

use of org.pentaho.metaverse.impl.model.ParamInfo in project pentaho-metaverse by pentaho.

the class TransMetaJsonDeserializer method deserializeVariables.

protected void deserializeVariables(TransMeta transMeta, JsonNode node, ObjectMapper mapper) throws IOException {
    ArrayNode varsArrayNode = (ArrayNode) node.get(TransMetaJsonSerializer.JSON_PROPERTY_VARIABLES);
    for (int i = 0; i < varsArrayNode.size(); i++) {
        JsonNode paramNode = varsArrayNode.get(i);
        ParamInfo param = mapper.readValue(paramNode.toString(), ParamInfo.class);
        transMeta.setVariable(param.getName(), param.getValue());
    }
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ParamInfo(org.pentaho.metaverse.impl.model.ParamInfo)

Example 3 with ParamInfo

use of org.pentaho.metaverse.impl.model.ParamInfo in project pentaho-metaverse by pentaho.

the class AbstractMetaJsonSerializer method serializeVariables.

protected void serializeVariables(T meta, JsonGenerator json) throws IOException {
    json.writeArrayFieldStart(JSON_PROPERTY_VARIABLES);
    List<String> variables = getUsedVariables(meta);
    if (variables != null) {
        for (String param : variables) {
            ParamInfo paramInfo = new ParamInfo(param, meta.getVariable(param));
            json.writeObject(paramInfo);
        }
    }
    json.writeEndArray();
}
Also used : ParamInfo(org.pentaho.metaverse.impl.model.ParamInfo)

Example 4 with ParamInfo

use of org.pentaho.metaverse.impl.model.ParamInfo in project pentaho-metaverse by pentaho.

the class AbstractMetaJsonSerializer method serializeParameters.

protected void serializeParameters(T meta, JsonGenerator json) throws IOException {
    json.writeArrayFieldStart(JSON_PROPERTY_PARAMETERS);
    String[] parameters = meta.listParameters();
    if (parameters != null) {
        for (String param : parameters) {
            try {
                ParamInfo paramInfo = new ParamInfo(param, null, meta.getParameterDefault(param), meta.getParameterDescription(param));
                json.writeObject(paramInfo);
            } catch (UnknownParamException e) {
                LOGGER.warn(Messages.getString("WARNING.Serialization.Trans.Param", param), e);
            }
        }
    }
    json.writeEndArray();
}
Also used : UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) ParamInfo(org.pentaho.metaverse.impl.model.ParamInfo)

Example 5 with ParamInfo

use of org.pentaho.metaverse.impl.model.ParamInfo 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.setEndTime(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());
    Result result = job.getResult();
    if (result != null) {
        executionData.setFailureCount(result.getNrErrors());
    }
    // 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));
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) KettleClientEnvironment(org.pentaho.di.core.KettleClientEnvironment) IParamInfo(org.pentaho.metaverse.api.model.IParamInfo) Timestamp(java.sql.Timestamp) KettleException(org.pentaho.di.core.exception.KettleException) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) Date(java.util.Date) Result(org.pentaho.di.core.Result) 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 Result (org.pentaho.di.core.Result)2 KettleException (org.pentaho.di.core.exception.KettleException)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