Search in sources :

Example 6 with StepLogTable

use of org.pentaho.di.core.logging.StepLogTable in project pentaho-kettle by pentaho.

the class PurRepositoryUnitTest method onlyGlobalVariablesOfLogTablesSetToNull.

@Test
public void onlyGlobalVariablesOfLogTablesSetToNull() {
    try {
        System.setProperty(Const.KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT, "true");
        PurRepositoryExporter purRepoExporter = new PurRepositoryExporter(mock(PurRepository.class));
        String hardcodedString = "hardcoded";
        String globalParam = "${" + Const.KETTLE_TRANS_LOG_TABLE + "}";
        StepLogTable stepLogTable = StepLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
        stepLogTable.setConnectionName(hardcodedString);
        stepLogTable.setSchemaName(hardcodedString);
        stepLogTable.setTimeoutInDays(hardcodedString);
        stepLogTable.setTableName(globalParam);
        JobEntryLogTable jobEntryLogTable = JobEntryLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
        jobEntryLogTable.setConnectionName(hardcodedString);
        jobEntryLogTable.setSchemaName(hardcodedString);
        jobEntryLogTable.setTimeoutInDays(hardcodedString);
        jobEntryLogTable.setTableName(globalParam);
        List<LogTableInterface> logTables = new ArrayList<>();
        logTables.add(jobEntryLogTable);
        logTables.add(stepLogTable);
        purRepoExporter.setGlobalVariablesOfLogTablesNull(logTables);
        for (LogTableInterface logTable : logTables) {
            assertEquals(logTable.getConnectionName(), hardcodedString);
            assertEquals(logTable.getSchemaName(), hardcodedString);
            assertEquals(logTable.getTimeoutInDays(), hardcodedString);
            assertEquals(logTable.getTableName(), null);
        }
    } finally {
        System.setProperty(Const.KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT, "false");
    }
}
Also used : LogTableInterface(org.pentaho.di.core.logging.LogTableInterface) StepLogTable(org.pentaho.di.core.logging.StepLogTable) ArrayList(java.util.ArrayList) JobEntryLogTable(org.pentaho.di.core.logging.JobEntryLogTable) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 7 with StepLogTable

use of org.pentaho.di.core.logging.StepLogTable in project pentaho-kettle by pentaho.

the class PurRepositoryUnitTest method globalVariablesOfLogTablesNotSetToNull.

@Test
public void globalVariablesOfLogTablesNotSetToNull() {
    PurRepositoryExporter purRepoExporter = new PurRepositoryExporter(mock(PurRepository.class));
    String globalParam = "${" + Const.KETTLE_TRANS_LOG_TABLE + "}";
    StepLogTable stepLogTable = StepLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
    stepLogTable.setConnectionName(globalParam);
    stepLogTable.setSchemaName(globalParam);
    stepLogTable.setTimeoutInDays(globalParam);
    stepLogTable.setTableName(globalParam);
    JobEntryLogTable jobEntryLogTable = JobEntryLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
    jobEntryLogTable.setConnectionName(globalParam);
    jobEntryLogTable.setSchemaName(globalParam);
    jobEntryLogTable.setTimeoutInDays(globalParam);
    jobEntryLogTable.setTableName(globalParam);
    List<LogTableInterface> logTables = new ArrayList<>();
    logTables.add(jobEntryLogTable);
    logTables.add(stepLogTable);
    purRepoExporter.setGlobalVariablesOfLogTablesNull(logTables);
    for (LogTableInterface logTable : logTables) {
        assertEquals(logTable.getConnectionName(), globalParam);
        assertEquals(logTable.getSchemaName(), globalParam);
        assertEquals(logTable.getTimeoutInDays(), globalParam);
        assertEquals(logTable.getTableName(), globalParam);
    }
}
Also used : LogTableInterface(org.pentaho.di.core.logging.LogTableInterface) StepLogTable(org.pentaho.di.core.logging.StepLogTable) ArrayList(java.util.ArrayList) JobEntryLogTable(org.pentaho.di.core.logging.JobEntryLogTable) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 8 with StepLogTable

use of org.pentaho.di.core.logging.StepLogTable in project pentaho-kettle by pentaho.

the class XmlExportHelper method swapTables.

/**
 * When exporting meta we should not export user global parameters.
 * Method makes clone for each table and deletes all global parameters.
 * We have to make clones of each table, because we don't want to change real tables content.
 *
 * @param transMeta
 *              meta, that contains log tables to be refactored before export
 */
public static void swapTables(TransMeta transMeta) {
    TransLogTable transLogTable = transMeta.getTransLogTable();
    if (transLogTable != null) {
        TransLogTable cloneTransLogTable = (TransLogTable) transLogTable.clone();
        cloneTransLogTable.setAllGlobalParametersToNull();
        transMeta.setTransLogTable(cloneTransLogTable);
    }
    StepLogTable stepLogTable = transMeta.getStepLogTable();
    if (stepLogTable != null) {
        StepLogTable cloneStepLogTable = (StepLogTable) stepLogTable.clone();
        cloneStepLogTable.setAllGlobalParametersToNull();
        transMeta.setStepLogTable(cloneStepLogTable);
    }
    PerformanceLogTable performanceLogTable = transMeta.getPerformanceLogTable();
    if (performanceLogTable != null) {
        PerformanceLogTable clonePerformanceLogTable = (PerformanceLogTable) performanceLogTable.clone();
        clonePerformanceLogTable.setAllGlobalParametersToNull();
        transMeta.setPerformanceLogTable(clonePerformanceLogTable);
    }
    ChannelLogTable channelLogTable = transMeta.getChannelLogTable();
    if (channelLogTable != null) {
        ChannelLogTable cloneChannelLogTable = (ChannelLogTable) channelLogTable.clone();
        cloneChannelLogTable.setAllGlobalParametersToNull();
        transMeta.setChannelLogTable(cloneChannelLogTable);
    }
    MetricsLogTable metricsLogTable = transMeta.getMetricsLogTable();
    if (metricsLogTable != null) {
        MetricsLogTable cloneMetricsLogTable = (MetricsLogTable) metricsLogTable.clone();
        cloneMetricsLogTable.setAllGlobalParametersToNull();
        transMeta.setMetricsLogTable(cloneMetricsLogTable);
    }
}
Also used : PerformanceLogTable(org.pentaho.di.core.logging.PerformanceLogTable) MetricsLogTable(org.pentaho.di.core.logging.MetricsLogTable) ChannelLogTable(org.pentaho.di.core.logging.ChannelLogTable) StepLogTable(org.pentaho.di.core.logging.StepLogTable) TransLogTable(org.pentaho.di.core.logging.TransLogTable)

Example 9 with StepLogTable

use of org.pentaho.di.core.logging.StepLogTable in project pentaho-kettle by pentaho.

the class SpoonExportXmlTest method initTables.

private void initTables(TransMeta transMeta) {
    TransLogTable transLogTable = TransLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface, null);
    initTableWithSampleParams(transLogTable);
    transLogTable.setLogInterval(GLOBAL_PARAM);
    transLogTable.setLogSizeLimit(GLOBAL_PARAM);
    transMeta.setTransLogTable(transLogTable);
    StepLogTable stepLogTable = StepLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
    initTableWithSampleParams(stepLogTable);
    transMeta.setStepLogTable(stepLogTable);
    PerformanceLogTable performanceLogTable = PerformanceLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
    initTableWithSampleParams(performanceLogTable);
    performanceLogTable.setLogInterval(GLOBAL_PARAM);
    transMeta.setPerformanceLogTable(performanceLogTable);
    ChannelLogTable channelLogTable = ChannelLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
    initTableWithSampleParams(channelLogTable);
    transMeta.setChannelLogTable(channelLogTable);
    MetricsLogTable metricsLogTable = MetricsLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
    initTableWithSampleParams(metricsLogTable);
    transMeta.setMetricsLogTable(metricsLogTable);
}
Also used : PerformanceLogTable(org.pentaho.di.core.logging.PerformanceLogTable) MetricsLogTable(org.pentaho.di.core.logging.MetricsLogTable) ChannelLogTable(org.pentaho.di.core.logging.ChannelLogTable) StepLogTable(org.pentaho.di.core.logging.StepLogTable) TransLogTable(org.pentaho.di.core.logging.TransLogTable)

Example 10 with StepLogTable

use of org.pentaho.di.core.logging.StepLogTable in project pentaho-kettle by pentaho.

the class Spoon method saveTransAsXmlFile.

private boolean saveTransAsXmlFile(TransMeta transMeta, boolean export) {
    TransLogTable origTransLogTable = transMeta.getTransLogTable();
    StepLogTable origStepLogTable = transMeta.getStepLogTable();
    PerformanceLogTable origPerformanceLogTable = transMeta.getPerformanceLogTable();
    ChannelLogTable origChannelLogTable = transMeta.getChannelLogTable();
    MetricsLogTable origMetricsLogTable = transMeta.getMetricsLogTable();
    try {
        XmlExportHelper.swapTables(transMeta);
        return saveXMLFile(transMeta, export);
    } finally {
        transMeta.setTransLogTable(origTransLogTable);
        transMeta.setStepLogTable(origStepLogTable);
        transMeta.setPerformanceLogTable(origPerformanceLogTable);
        transMeta.setChannelLogTable(origChannelLogTable);
        transMeta.setMetricsLogTable(origMetricsLogTable);
    }
}
Also used : PerformanceLogTable(org.pentaho.di.core.logging.PerformanceLogTable) MetricsLogTable(org.pentaho.di.core.logging.MetricsLogTable) ChannelLogTable(org.pentaho.di.core.logging.ChannelLogTable) StepLogTable(org.pentaho.di.core.logging.StepLogTable) TransLogTable(org.pentaho.di.core.logging.TransLogTable)

Aggregations

StepLogTable (org.pentaho.di.core.logging.StepLogTable)10 ChannelLogTable (org.pentaho.di.core.logging.ChannelLogTable)6 PerformanceLogTable (org.pentaho.di.core.logging.PerformanceLogTable)6 TransLogTable (org.pentaho.di.core.logging.TransLogTable)6 Test (org.junit.Test)4 MetricsLogTable (org.pentaho.di.core.logging.MetricsLogTable)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 Matchers.anyString (org.mockito.Matchers.anyString)2 Database (org.pentaho.di.core.database.Database)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)2 KettleException (org.pentaho.di.core.exception.KettleException)2 KettleFileException (org.pentaho.di.core.exception.KettleFileException)2 KettleTransException (org.pentaho.di.core.exception.KettleTransException)2 KettleValueException (org.pentaho.di.core.exception.KettleValueException)2 JobEntryLogTable (org.pentaho.di.core.logging.JobEntryLogTable)2 LogTableInterface (org.pentaho.di.core.logging.LogTableInterface)2 DuplicateParamException (org.pentaho.di.core.parameters.DuplicateParamException)2 UnknownParamException (org.pentaho.di.core.parameters.UnknownParamException)2