use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class TableView method setFilter.
// Filtering...
public void setFilter() {
if (condition == null) {
condition = new Condition();
}
RowMetaInterface f = getRowWithoutValues();
EnterConditionDialog ecd = new EnterConditionDialog(parent.getShell(), SWT.NONE, f, condition);
Condition cond = ecd.open();
if (cond != null) {
ArrayList<Integer> tokeep = new ArrayList<Integer>();
// Apply the condition to the TableView...
int nr = table.getItemCount();
for (int i = nr - 1; i >= 0; i--) {
RowMetaAndData r = getRow(i);
boolean keep = cond.evaluate(r.getRowMeta(), r.getData());
if (keep) {
tokeep.add(Integer.valueOf(i));
}
}
int[] sels = new int[tokeep.size()];
for (int i = 0; i < sels.length; i++) {
sels[i] = (tokeep.get(i)).intValue();
}
table.setSelection(sels);
}
}
use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class TableView method getRow.
public RowMetaAndData getRow(int nr) {
TableItem ti = table.getItem(nr);
RowMetaInterface rowMeta = getRowWithoutValues();
Object[] rowData = new Object[rowMeta.size()];
rowData[0] = new Long(nr);
for (int i = 1; i < rowMeta.size(); i++) {
rowData[i] = ti.getText(i);
}
return new RowMetaAndData(rowMeta, rowData);
}
use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class StepLogTable method getLogRecord.
/**
* This method calculates all the values that are required
*
* @param id
* the id to use or -1 if no id is needed
* @param status
* the log status to use
*/
public RowMetaAndData getLogRecord(LogStatus status, Object subject, Object parent) {
if (subject == null || subject instanceof StepMetaDataCombi) {
StepMetaDataCombi combi = (StepMetaDataCombi) subject;
RowMetaAndData row = new RowMetaAndData();
for (LogTableField field : fields) {
if (field.isEnabled()) {
Object value = null;
if (subject != null) {
switch(ID.valueOf(field.getId())) {
case ID_BATCH:
value = new Long(combi.step.getTrans().getBatchId());
break;
case CHANNEL_ID:
value = combi.step.getLogChannel().getLogChannelId();
break;
case LOG_DATE:
value = new Date();
break;
case TRANSNAME:
value = combi.step.getTrans().getName();
break;
case STEPNAME:
value = combi.stepname;
break;
case STEP_COPY:
value = new Long(combi.copy);
break;
case LINES_READ:
value = new Long(combi.step.getLinesRead());
break;
case LINES_WRITTEN:
value = new Long(combi.step.getLinesWritten());
break;
case LINES_UPDATED:
value = new Long(combi.step.getLinesUpdated());
break;
case LINES_INPUT:
value = new Long(combi.step.getLinesInput());
break;
case LINES_OUTPUT:
value = new Long(combi.step.getLinesOutput());
break;
case LINES_REJECTED:
value = new Long(combi.step.getLinesRejected());
break;
case ERRORS:
value = new Long(combi.step.getErrors());
break;
case LOG_FIELD:
value = getLogBuffer(combi.step, combi.step.getLogChannel().getLogChannelId(), status, null);
break;
default:
break;
}
}
row.addValue(field.getFieldName(), field.getDataType(), value);
row.getRowMeta().getValueMeta(row.size() - 1).setLength(field.getLength());
}
}
return row;
} else {
return null;
}
}
use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class TransLogTable method getLogRecord.
/**
* This method calculates all the values that are required
*
* @param id
* the id to use or -1 if no id is needed
* @param status
* the log status to use
* @param subject
* the subject to query, in this case a Trans object
*/
public RowMetaAndData getLogRecord(LogStatus status, Object subject, Object parent) {
if (subject == null || subject instanceof Trans) {
Trans trans = (Trans) subject;
Result result = null;
if (trans != null) {
result = trans.getResult();
}
RowMetaAndData row = new RowMetaAndData();
for (LogTableField field : fields) {
if (field.isEnabled()) {
Object value = null;
if (trans != null) {
switch(ID.valueOf(field.getId())) {
case ID_BATCH:
value = new Long(trans.getBatchId());
break;
case CHANNEL_ID:
value = trans.getLogChannelId();
break;
case TRANSNAME:
value = trans.getName();
break;
case STATUS:
value = status.getStatus();
break;
case LINES_READ:
value = new Long(result.getNrLinesRead());
break;
case LINES_WRITTEN:
value = new Long(result.getNrLinesWritten());
break;
case LINES_INPUT:
value = new Long(result.getNrLinesInput());
break;
case LINES_OUTPUT:
value = new Long(result.getNrLinesOutput());
break;
case LINES_UPDATED:
value = new Long(result.getNrLinesUpdated());
break;
case LINES_REJECTED:
value = new Long(result.getNrLinesRejected());
break;
case ERRORS:
value = new Long(result.getNrErrors());
break;
case STARTDATE:
value = trans.getStartDate();
break;
case LOGDATE:
value = trans.getLogDate();
break;
case ENDDATE:
value = trans.getEndDate();
break;
case DEPDATE:
value = trans.getDepDate();
break;
case REPLAYDATE:
value = trans.getCurrentDate();
break;
case LOG_FIELD:
value = getLogBuffer(trans, trans.getLogChannelId(), status, logSizeLimit);
break;
case EXECUTING_SERVER:
value = trans.getExecutingServer();
break;
case EXECUTING_USER:
value = trans.getExecutingUser();
break;
case CLIENT:
value = KettleClientEnvironment.getInstance().getClient() != null ? KettleClientEnvironment.getInstance().getClient().toString() : "unknown";
break;
default:
break;
}
}
row.addValue(field.getFieldName(), field.getDataType(), value);
row.getRowMeta().getValueMeta(row.size() - 1).setLength(field.getLength());
}
}
return row;
} else {
return null;
}
}
use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.
the class DatabaseConnectionPoolParameterTest method testGetRowList.
@Test
public void testGetRowList() {
List<RowMetaAndData> result = DatabaseConnectionPoolParameter.getRowList(BaseDatabaseMeta.poolingParameters, "myTitleParameter", "myTitleDefaultValue", "myTitleDescription");
assertNotNull(result);
for (RowMetaAndData rmd : result) {
assertEquals(3, rmd.getRowMeta().size());
assertEquals("myTitleParameter", rmd.getRowMeta().getValueMeta(0).getName());
assertEquals(ValueMetaInterface.TYPE_STRING, rmd.getRowMeta().getValueMeta(0).getType());
assertEquals("myTitleDefaultValue", rmd.getRowMeta().getValueMeta(1).getName());
assertEquals(ValueMetaInterface.TYPE_STRING, rmd.getRowMeta().getValueMeta(1).getType());
assertEquals("myTitleDescription", rmd.getRowMeta().getValueMeta(2).getName());
assertEquals(ValueMetaInterface.TYPE_STRING, rmd.getRowMeta().getValueMeta(2).getType());
}
}
Aggregations