Search in sources :

Example 6 with IExecutionData

use of org.pentaho.metaverse.api.model.IExecutionData in project pentaho-metaverse by pentaho.

the class VfsLineageWriterTest method setUp.

@Before
public void setUp() throws Exception {
    String basePath = new File(".").getCanonicalPath();
    writer = new VfsLineageWriter();
    writer = spy(writer);
    holder = new LineageHolder();
    IExecutionProfile profile = new ExecutionProfile();
    profile.setName("test");
    IExecutionData data = new ExecutionData();
    data.setStartTime(now);
    profile.setExecutionData(data);
    holder.setExecutionProfile(profile);
    BAD_OUTPUT_FOLDER = FilenameUtils.separatorsToSystem("file://" + basePath + BAD_OUTPUT_FOLDER_DEFAULT + random.nextInt());
    GOOD_OUTPUT_FOLDER = FilenameUtils.separatorsToSystem("file://" + basePath + GOOD_OUTPUT_FOLDER_DEFAULT + random.nextInt());
    writer.setOutputFolder(GOOD_OUTPUT_FOLDER);
}
Also used : IExecutionData(org.pentaho.metaverse.api.model.IExecutionData) IExecutionProfile(org.pentaho.metaverse.api.model.IExecutionProfile) File(java.io.File) ExecutionProfile(org.pentaho.metaverse.impl.model.ExecutionProfile) IExecutionProfile(org.pentaho.metaverse.api.model.IExecutionProfile) LineageHolder(org.pentaho.metaverse.api.model.LineageHolder) IExecutionData(org.pentaho.metaverse.api.model.IExecutionData) ExecutionData(org.pentaho.metaverse.impl.model.ExecutionData) Before(org.junit.Before)

Example 7 with IExecutionData

use of org.pentaho.metaverse.api.model.IExecutionData in project pentaho-metaverse by pentaho.

the class ExecutionProfileTest method testGetSetExecutionData.

@Test
public void testGetSetExecutionData() throws Exception {
    IExecutionData mockData = mock(IExecutionData.class);
    when(mockData.getExecutorUser()).thenReturn("myUser");
    assertNotNull(executionProfile.getExecutionData());
    assertNull(executionProfile.getExecutionData().getExecutorUser());
    executionProfile.setExecutionData(mockData);
    assertNotNull(executionProfile.getExecutionData());
    assertEquals("myUser", executionProfile.getExecutionData().getExecutorUser());
}
Also used : IExecutionData(org.pentaho.metaverse.api.model.IExecutionData) Test(org.junit.Test)

Example 8 with IExecutionData

use of org.pentaho.metaverse.api.model.IExecutionData 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));
    }
}
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) 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)

Example 9 with IExecutionData

use of org.pentaho.metaverse.api.model.IExecutionData 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)

Example 10 with IExecutionData

use of org.pentaho.metaverse.api.model.IExecutionData in project pentaho-metaverse by pentaho.

the class JobRuntimeExtensionPointTest method createExecutionProfile.

private void createExecutionProfile(Job job) {
    IExecutionProfile executionProfile = mock(IExecutionProfile.class);
    IExecutionData executionData = mock(IExecutionData.class);
    when(executionProfile.getExecutionData()).thenReturn(executionData);
    JobLineageHolderMap.getInstance().getLineageHolder(job).setExecutionProfile(executionProfile);
}
Also used : IExecutionData(org.pentaho.metaverse.api.model.IExecutionData) IExecutionProfile(org.pentaho.metaverse.api.model.IExecutionProfile)

Aggregations

IExecutionData (org.pentaho.metaverse.api.model.IExecutionData)12 IExecutionProfile (org.pentaho.metaverse.api.model.IExecutionProfile)9 Test (org.junit.Test)5 LineageHolder (org.pentaho.metaverse.api.model.LineageHolder)5 Before (org.junit.Before)3 JobMeta (org.pentaho.di.job.JobMeta)3 ExecutionData (org.pentaho.metaverse.impl.model.ExecutionData)3 ExecutionProfile (org.pentaho.metaverse.impl.model.ExecutionProfile)3 IOException (java.io.IOException)2 Timestamp (java.sql.Timestamp)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 ExecutionException (java.util.concurrent.ExecutionException)2 KettleClientEnvironment (org.pentaho.di.core.KettleClientEnvironment)2 ResultFile (org.pentaho.di.core.ResultFile)2 KettleException (org.pentaho.di.core.exception.KettleException)2 UnknownParamException (org.pentaho.di.core.parameters.UnknownParamException)2 Job (org.pentaho.di.job.Job)2 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)2 ResourceEntry (org.pentaho.di.resource.ResourceEntry)2