Search in sources :

Example 11 with JobLogTable

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

the class JobDelegateTest method testElementToDataNodeSavesAttributes.

@Test
public void testElementToDataNodeSavesAttributes() throws KettleException {
    JobMeta mockJobMeta = mock(JobMeta.class);
    IUnifiedRepository mockUnifiedRepository = mock(IUnifiedRepository.class);
    JobDelegate jobDelegate = new JobDelegate(mockPurRepository, mockUnifiedRepository);
    JobLogTable mockJobLogTable = mock(JobLogTable.class);
    JobEntryCopy mockJobEntryCopy = mock(JobEntryCopy.class);
    Map<String, Map<String, String>> attributes = new HashMap<String, Map<String, String>>();
    Map<String, String> group = new HashMap<String, String>();
    final String mockGroup = "MOCK_GROUP";
    final String mockProperty = "MOCK_PROPERTY";
    final String mockValue = "MOCK_VALUE";
    group.put(mockProperty, mockValue);
    attributes.put(mockGroup, group);
    JobEntryBaseAndInterface mockJobEntry = mock(JobEntryBaseAndInterface.class);
    when(mockJobEntry.getAttributesMap()).thenReturn(attributes);
    when(mockJobMeta.listParameters()).thenReturn(new String[] {});
    when(mockJobMeta.getJobLogTable()).thenReturn(mockJobLogTable);
    when(mockJobMeta.nrJobEntries()).thenReturn(1);
    when(mockJobMeta.getJobEntry(0)).thenReturn(mockJobEntryCopy);
    when(mockJobEntryCopy.getName()).thenReturn("MOCK_NAME");
    when(mockJobEntryCopy.getLocation()).thenReturn(new Point(0, 0));
    when(mockJobEntryCopy.getEntry()).thenReturn(mockJobEntry);
    DataNode dataNode = jobDelegate.elementToDataNode(mockJobMeta);
    DataNode groups = dataNode.getNode("entries").getNodes().iterator().next().getNode(AttributesMapUtil.NODE_ATTRIBUTE_GROUPS);
    DataNode mockGroupNode = groups.getNode(mockGroup);
    assertEquals(mockValue, mockGroupNode.getProperty(mockProperty).getString());
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobLogTable(org.pentaho.di.core.logging.JobLogTable) HashMap(java.util.HashMap) Point(org.pentaho.di.core.gui.Point) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) HashMap(java.util.HashMap) Map(java.util.Map) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Example 12 with JobLogTable

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

the class JobDialog method getLogInfo.

private void getLogInfo(int previousLogTableIndex) {
    if (previousLogTableIndex < 0) {
        return;
    }
    // Remember the that was entered data...
    // 
    LogTableInterface modifiedLogTable = logTables.get(previousLogTableIndex);
    LogTableUserInterface logTableUserInterface = logTableUserInterfaces.get(previousLogTableIndex);
    if (logTableUserInterface != null) {
        logTableUserInterface.retrieveLogTableOptions(modifiedLogTable);
    } else {
        if (modifiedLogTable instanceof JobLogTable) {
            getJobLogTableOptions((JobLogTable) modifiedLogTable);
        } else if (modifiedLogTable instanceof ChannelLogTable) {
            getChannelLogTableOptions((ChannelLogTable) modifiedLogTable);
        } else if (modifiedLogTable instanceof JobEntryLogTable) {
            getJobEntryLogTableOptions((JobEntryLogTable) modifiedLogTable);
        }
    }
}
Also used : LogTableInterface(org.pentaho.di.core.logging.LogTableInterface) JobLogTable(org.pentaho.di.core.logging.JobLogTable) ChannelLogTable(org.pentaho.di.core.logging.ChannelLogTable) JobEntryLogTable(org.pentaho.di.core.logging.JobEntryLogTable)

Example 13 with JobLogTable

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

the class SpoonExportXmlTest method initTables.

private void initTables(JobMeta jobMeta) {
    JobLogTable jobLogTable = JobLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
    initTableWithSampleParams(jobLogTable);
    jobLogTable.setLogInterval(GLOBAL_PARAM);
    jobLogTable.setLogSizeLimit(GLOBAL_PARAM);
    jobMeta.setJobLogTable(jobLogTable);
    JobEntryLogTable jobEntryLogTable = JobEntryLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
    initTableWithSampleParams(jobEntryLogTable);
    jobMeta.setJobEntryLogTable(jobEntryLogTable);
    ChannelLogTable channelLogTable = ChannelLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
    initTableWithSampleParams(channelLogTable);
    jobMeta.setChannelLogTable(channelLogTable);
    jobMeta.setExtraLogTables(null);
}
Also used : JobLogTable(org.pentaho.di.core.logging.JobLogTable) ChannelLogTable(org.pentaho.di.core.logging.ChannelLogTable) JobEntryLogTable(org.pentaho.di.core.logging.JobEntryLogTable)

Example 14 with JobLogTable

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

the class Spoon method saveJobAsXmlFile.

private boolean saveJobAsXmlFile(JobMeta jobMeta, boolean export) {
    JobLogTable origJobLogTable = jobMeta.getJobLogTable();
    JobEntryLogTable originEntryLogTable = jobMeta.getJobEntryLogTable();
    ChannelLogTable originChannelLogTable = jobMeta.getChannelLogTable();
    List<LogTableInterface> originExtraLogTables = jobMeta.getExtraLogTables();
    try {
        XmlExportHelper.swapTables(jobMeta);
        return saveXMLFile(jobMeta, export);
    } finally {
        jobMeta.setJobLogTable(origJobLogTable);
        jobMeta.setJobEntryLogTable(originEntryLogTable);
        jobMeta.setChannelLogTable(originChannelLogTable);
        jobMeta.setExtraLogTables(originExtraLogTables);
    }
}
Also used : LogTableInterface(org.pentaho.di.core.logging.LogTableInterface) JobLogTable(org.pentaho.di.core.logging.JobLogTable) ChannelLogTable(org.pentaho.di.core.logging.ChannelLogTable) JobEntryLogTable(org.pentaho.di.core.logging.JobEntryLogTable)

Example 15 with JobLogTable

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

the class JobHasJobLogConfiguredImportRuleIT method testRule.

public void testRule() throws Exception {
    JobMeta jobMeta = new JobMeta();
    DatabaseMeta logDbMeta = new DatabaseMeta("LOGDB", "MYSQL", "JDBC", "localhost", "test", "3306", "foo", "bar");
    jobMeta.addDatabase(logDbMeta);
    JobLogTable logTable = jobMeta.getJobLogTable();
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.findPluginWithId(ImportRulePluginType.class, "JobHasJobLogConfigured");
    assertNotNull("The 'job has job log table configured' rule could not be found in the plugin registry!", plugin);
    JobHasJobLogConfiguredImportRule rule = (JobHasJobLogConfiguredImportRule) registry.loadClass(plugin);
    assertNotNull("The 'job has job log table configured' class could not be loaded by the plugin registry!", plugin);
    rule.setEnabled(true);
    List<ImportValidationFeedback> feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't get any feedback from the 'job has job log table configured'", !feedback.isEmpty());
    assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    logTable.setTableName("SCHEMA");
    logTable.setTableName("LOGTABLE");
    logTable.setConnectionName(logDbMeta.getName());
    feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't get any feedback from the 'job has description rule'", !feedback.isEmpty());
    assertTrue("An approval ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.APPROVAL);
    // Make the rules stricter!
    // 
    rule.setTableName("SCHEMA");
    rule.setTableName("LOGTABLE");
    rule.setConnectionName(logDbMeta.getName());
    feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't get any feedback from the 'job has description rule'", !feedback.isEmpty());
    assertTrue("An approval ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.APPROVAL);
    // Break the rule
    // 
    rule.setSchemaName("INCORRECT_SCHEMA");
    rule.setTableName("LOGTABLE");
    rule.setConnectionName(logDbMeta.getName());
    feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't get any feedback from the 'job has description rule'", !feedback.isEmpty());
    assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    rule.setSchemaName("SCHEMA");
    rule.setTableName("INCORRECT_LOGTABLE");
    rule.setConnectionName(logDbMeta.getName());
    feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't get any feedback from the 'job has description rule'", !feedback.isEmpty());
    assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    rule.setSchemaName("SCHEMA");
    rule.setTableName("LOGTABLE");
    rule.setConnectionName("INCORRECT_DATABASE");
    feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't get any feedback from the 'job has description rule'", !feedback.isEmpty());
    assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    // No feedback expected!
    // 
    rule.setEnabled(false);
    feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't expect any feedback from the 'job has job log table configured' since the rule is not enabled", feedback.isEmpty());
}
Also used : JobHasJobLogConfiguredImportRule(org.pentaho.di.imp.rules.JobHasJobLogConfiguredImportRule) JobMeta(org.pentaho.di.job.JobMeta) JobLogTable(org.pentaho.di.core.logging.JobLogTable) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Aggregations

JobLogTable (org.pentaho.di.core.logging.JobLogTable)15 ChannelLogTable (org.pentaho.di.core.logging.ChannelLogTable)8 JobEntryLogTable (org.pentaho.di.core.logging.JobEntryLogTable)8 JobMeta (org.pentaho.di.job.JobMeta)7 Test (org.junit.Test)5 LogTableInterface (org.pentaho.di.core.logging.LogTableInterface)4 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)4 ArrayList (java.util.ArrayList)3 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)3 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)3 DataNode (org.pentaho.platform.api.repository2.unified.data.node.DataNode)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)2 KettleException (org.pentaho.di.core.exception.KettleException)2 KettleJobException (org.pentaho.di.core.exception.KettleJobException)2 KettleValueException (org.pentaho.di.core.exception.KettleValueException)2 Point (org.pentaho.di.core.gui.Point)2 DuplicateParamException (org.pentaho.di.core.parameters.DuplicateParamException)2