use of org.pentaho.di.core.logging.LoggingObject in project pentaho-kettle by pentaho.
the class XulDatabaseExplorerController method dataProfile.
public void dataProfile() {
if (model.getTable() == null) {
return;
}
Shell dbShell = (Shell) dbExplorerDialog.getRootObject();
try {
TransProfileFactory profileFactory = new TransProfileFactory(this.model.getDatabaseMeta(), getSchemaAndTable(this.model));
TransMeta transMeta = profileFactory.generateTransformation(new LoggingObject(model.getTable()));
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(dbShell, transMeta, new String[] { TransProfileFactory.RESULT_STEP_NAME }, new int[] { 25000 });
progressDialog.open();
if (!progressDialog.isCancelled()) {
Trans trans = progressDialog.getTrans();
String loggingText = progressDialog.getLoggingText();
if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
EnterTextDialog etd = new EnterTextDialog(dbShell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
etd.setReadOnly();
etd.open();
}
PreviewRowsDialog prd = new PreviewRowsDialog(dbShell, transMeta, SWT.NONE, TransProfileFactory.RESULT_STEP_NAME, progressDialog.getPreviewRowsMeta(TransProfileFactory.RESULT_STEP_NAME), progressDialog.getPreviewRows(TransProfileFactory.RESULT_STEP_NAME), loggingText);
prd.open();
}
} catch (Exception e) {
new ErrorDialog(this.dbExplorerDialog.getShell(), BaseMessages.getString(PKG, "DatabaseExplorerDialog.UnexpectedProfilingError.Title"), BaseMessages.getString(PKG, "DatabaseExplorerDialog.UnexpectedProfilingError.Message"), e);
}
}
use of org.pentaho.di.core.logging.LoggingObject in project pentaho-kettle by pentaho.
the class SubtransExecutorTest method stopsAll.
@Test
public void stopsAll() throws KettleException {
TransMeta parentMeta = new TransMeta(this.getClass().getResource("subtrans-executor-parent.ktr").getPath(), new Variables());
TransMeta subMeta = new TransMeta(this.getClass().getResource("subtrans-executor-sub.ktr").getPath(), new Variables());
LoggingObjectInterface loggingObject = new LoggingObject("anything");
Trans parentTrans = new Trans(parentMeta, loggingObject);
SubtransExecutor subtransExecutor = new SubtransExecutor("subtransname", parentTrans, subMeta, true, new TransExecutorParameters(), "");
subtransExecutor.running = Mockito.spy(subtransExecutor.running);
RowMetaInterface rowMeta = parentMeta.getStepFields("Data Grid");
List<RowMetaAndData> rows = Arrays.asList(new RowMetaAndData(rowMeta, "Pentaho", 1L), new RowMetaAndData(rowMeta, "Pentaho", 2L), new RowMetaAndData(rowMeta, "Pentaho", 3L), new RowMetaAndData(rowMeta, "Pentaho", 4L));
subtransExecutor.execute(rows);
verify(subtransExecutor.running).add(any());
subtransExecutor.stop();
assertTrue(subtransExecutor.running.isEmpty());
}
use of org.pentaho.di.core.logging.LoggingObject in project pentaho-platform by pentaho.
the class Custom1 method execSQL.
@SuppressWarnings("unused")
private void execSQL(TransMeta transMeta, String targetDatabaseName) throws KettleStepException, KettleDatabaseException {
// OK, What's the SQL we need to execute to generate the target table?
String sql = transMeta.getSQLStatementsString();
// Execute the SQL on the target table:
Database targetDatabase = new Database(new LoggingObject("Custom1"), transMeta.findDatabase(targetDatabaseName));
targetDatabase.connect();
targetDatabase.execStatements(sql);
}
use of org.pentaho.di.core.logging.LoggingObject in project pentaho-kettle by pentaho.
the class ValueMetaBaseTest method testValueMetaBaseOnlyHasOneLogger.
@Test
public void testValueMetaBaseOnlyHasOneLogger() throws NoSuchFieldException, IllegalAccessException {
Field log = ValueMetaBase.class.getDeclaredField("log");
assertTrue(Modifier.isStatic(log.getModifiers()));
assertTrue(Modifier.isFinal(log.getModifiers()));
log.setAccessible(true);
try {
assertEquals(LoggingRegistry.getInstance().findExistingLoggingSource(new LoggingObject("ValueMetaBase")).getLogChannelId(), ((LogChannelInterface) log.get(null)).getLogChannelId());
} finally {
log.setAccessible(false);
}
}
use of org.pentaho.di.core.logging.LoggingObject in project pentaho-kettle by pentaho.
the class SubtransExecutorTest method testRunsATrans.
@Test
public void testRunsATrans() throws Exception {
TransMeta parentMeta = new TransMeta(this.getClass().getResource("subtrans-executor-parent.ktr").getPath(), new Variables());
TransMeta subMeta = new TransMeta(this.getClass().getResource("subtrans-executor-sub.ktr").getPath(), new Variables());
LoggingObjectInterface loggingObject = new LoggingObject("anything");
Trans parentTrans = spy(new Trans(parentMeta, loggingObject));
SubtransExecutor subtransExecutor = new SubtransExecutor("subtransname", parentTrans, subMeta, true, new TransExecutorParameters(), "Group By");
RowMetaInterface rowMeta = parentMeta.getStepFields("Data Grid");
List<RowMetaAndData> rows = Arrays.asList(new RowMetaAndData(rowMeta, "Pentaho", 1L), new RowMetaAndData(rowMeta, "Pentaho", 2L), new RowMetaAndData(rowMeta, "Pentaho", 3L), new RowMetaAndData(rowMeta, "Pentaho", 4L));
Optional<Result> optionalResult = subtransExecutor.execute(rows);
assertEquals(1, optionalResult.orElseThrow(AssertionError::new).getRows().size());
verify(this.logChannel).logBasic(Const.CR + "------------> Linenr 1------------------------------" + Const.CR + "name = Pentaho" + Const.CR + "sum = 10" + Const.CR + Const.CR + "====================");
Map<String, StepStatus> statuses = subtransExecutor.getStatuses();
assertEquals(3, statuses.size());
List<StepStatus> statusList = new ArrayList<>(statuses.values());
assertEquals("Get rows from result", statusList.get(0).getStepname());
assertEquals("Group by", statusList.get(1).getStepname());
assertEquals("Write to log", statusList.get(2).getStepname());
for (Map.Entry<String, StepStatus> entry : statuses.entrySet()) {
StepStatus statusSpy = spy(entry.getValue());
statuses.put(entry.getKey(), statusSpy);
}
subtransExecutor.execute(rows);
for (Map.Entry<String, StepStatus> entry : statuses.entrySet()) {
verify(entry.getValue()).updateAll(any());
}
verify(parentTrans, atLeastOnce()).addActiveSubTransformation(eq("subtransname"), any(Trans.class));
}
Aggregations