use of org.apache.hop.core.Condition in project hop by apache.
the class JoinRowsMeta method readData.
private void readData(Node transformNode) throws HopXmlException {
try {
directory = XmlHandler.getTagValue(transformNode, "directory");
prefix = XmlHandler.getTagValue(transformNode, "prefix");
cacheSize = Const.toInt(XmlHandler.getTagValue(transformNode, "cache_size"), -1);
mainTransformName = XmlHandler.getTagValue(transformNode, "main");
Node compare = XmlHandler.getSubNode(transformNode, "compare");
Node condnode = XmlHandler.getSubNode(compare, "condition");
// The new situation...
if (condnode != null) {
condition = new Condition(condnode);
} else {
condition = new Condition();
}
} catch (Exception e) {
throw new HopXmlException(BaseMessages.getString(PKG, "JoinRowsMeta.Exception.UnableToReadTransformMetaFromXML"), e);
}
}
use of org.apache.hop.core.Condition in project hop by apache.
the class StringSearcher method stringSearchInObject.
private static void stringSearchInObject(Object obj, int level, List<StringSearchResult> stringList, Object parentObject, Object grandParentObject, Field field) {
String fieldName = field.getName();
if (obj instanceof String) {
// OK, let's add the String
stringList.add(new StringSearchResult((String) obj, parentObject, grandParentObject, fieldName));
} else if (obj instanceof String[]) {
String[] array = (String[]) obj;
for (int x = 0; x < array.length; x++) {
if (array[x] != null) {
stringList.add(new StringSearchResult(array[x], parentObject, grandParentObject, fieldName + " #" + (x + 1)));
}
}
} else if (obj instanceof Boolean) {
// OK, let's add the String
stringList.add(new StringSearchResult(((Boolean) obj).toString(), parentObject, grandParentObject, fieldName + " (Boolean)"));
} else if (obj instanceof Condition) {
stringList.add(new StringSearchResult(((Condition) obj).toString(), parentObject, grandParentObject, fieldName + " (Condition)"));
} else if (obj instanceof IDatabase) {
// Make sure we read the attributes. This is not picked up by default. (getDeclaredFields
// doesn't pick up
// inherited fields)
//
IDatabase iDatabase = (IDatabase) obj;
findMapMetaData(iDatabase.getAttributes(), level + 1, stringList, parentObject, grandParentObject, field);
findMetaData(obj, level + 1, stringList, parentObject, grandParentObject);
} else if (obj instanceof Map) {
findMapMetaData((Map<?, ?>) obj, level, stringList, parentObject, grandParentObject, field);
} else if (obj instanceof Object[]) {
for (int j = 0; j < ((Object[]) obj).length; j++) {
findMetaData(((Object[]) obj)[j], level + 1, stringList, parentObject, grandParentObject);
}
} else {
findMetaData(obj, level + 1, stringList, parentObject, grandParentObject);
}
}
use of org.apache.hop.core.Condition in project hop by apache.
the class FilterRowsMetaTest method testClone.
@Test
public void testClone() {
FilterRowsMeta filterRowsMeta = new FilterRowsMeta();
filterRowsMeta.setCondition(new Condition());
filterRowsMeta.setTrueTransformName("true");
filterRowsMeta.setFalseTransformName("false");
FilterRowsMeta clone = (FilterRowsMeta) filterRowsMeta.clone();
assertNotNull(clone.getCondition());
assertEquals("true", clone.getTrueTransformName());
assertEquals("false", clone.getFalseTransformName());
}
use of org.apache.hop.core.Condition in project hop by apache.
the class TableView method setFilter.
// Filtering...
public void setFilter() {
if (condition == null) {
condition = new Condition();
}
IRowMeta f = getRowWithoutValues();
EnterConditionDialog ecd = new EnterConditionDialog(parent.getShell(), SWT.NONE, f, condition);
Condition cond = ecd.open();
if (cond != null) {
ArrayList<Integer> tokeep = new ArrayList<>();
// 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.apache.hop.core.Condition in project hop by apache.
the class PipelineDebugDialog method showTransformDebugInformation.
private void showTransformDebugInformation() {
//
for (Control control : wComposite.getChildren()) {
control.dispose();
}
wComposite.layout(true, true);
int[] selectionIndices = wTransforms.table.getSelectionIndices();
if (selectionIndices == null || selectionIndices.length != 1) {
return;
}
previousIndex = selectionIndices[0];
// What transform did we click on?
//
final TransformMeta transformMeta = pipelineDebugMeta.getPipelineMeta().getTransform(selectionIndices[0]);
// What is the transform debugging metadata?
// --> This can be null (most likely scenario)
//
final TransformDebugMeta transformDebugMeta = transformDebugMetaMap.get(transformMeta);
// At the top we'll put a few common items like first[x], etc.
//
// The row count (e.g. number of rows to keep)
//
wRowCount = new LabelText(wComposite, BaseMessages.getString(PKG, "PipelineDebugDialog.RowCount.Label"), BaseMessages.getString(PKG, "PipelineDebugDialog.RowCount.ToolTip"));
FormData fdRowCount = new FormData();
fdRowCount.left = new FormAttachment(0, 0);
fdRowCount.right = new FormAttachment(100, 0);
fdRowCount.top = new FormAttachment(0, 0);
wRowCount.setLayoutData(fdRowCount);
wRowCount.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
ok(false);
}
});
// Do we retrieve the first rows passing?
//
wFirstRows = new Button(wComposite, SWT.CHECK);
props.setLook(wFirstRows);
wFirstRows.setText(BaseMessages.getString(PKG, "PipelineDebugDialog.FirstRows.Label"));
wFirstRows.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.FirstRows.ToolTip"));
FormData fdFirstRows = new FormData();
fdFirstRows.left = new FormAttachment(middle, 0);
fdFirstRows.right = new FormAttachment(100, 0);
fdFirstRows.top = new FormAttachment(wRowCount, margin);
wFirstRows.setLayoutData(fdFirstRows);
// Do we pause on break point, when the condition is met?
//
wPauseBreakPoint = new Button(wComposite, SWT.CHECK);
props.setLook(wPauseBreakPoint);
wPauseBreakPoint.setText(BaseMessages.getString(PKG, "PipelineDebugDialog.PauseBreakPoint.Label"));
wPauseBreakPoint.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.PauseBreakPoint.ToolTip"));
FormData fdPauseBreakPoint = new FormData();
fdPauseBreakPoint.left = new FormAttachment(middle, 0);
fdPauseBreakPoint.right = new FormAttachment(100, 0);
fdPauseBreakPoint.top = new FormAttachment(wFirstRows, margin);
wPauseBreakPoint.setLayoutData(fdPauseBreakPoint);
// The condition to pause for...
//
condition = null;
if (transformDebugMeta != null) {
condition = transformDebugMeta.getCondition();
}
if (condition == null) {
condition = new Condition();
}
// The input fields...
IRowMeta transformInputFields;
try {
transformInputFields = pipelineDebugMeta.getPipelineMeta().getTransformFields(variables, transformMeta);
} catch (HopTransformException e) {
transformInputFields = new RowMeta();
}
Label wlCondition = new Label(wComposite, SWT.RIGHT);
props.setLook(wlCondition);
wlCondition.setText(BaseMessages.getString(PKG, "PipelineDebugDialog.Condition.Label"));
wlCondition.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.Condition.ToolTip"));
FormData fdlCondition = new FormData();
fdlCondition.left = new FormAttachment(0, 0);
fdlCondition.right = new FormAttachment(middle, -margin);
fdlCondition.top = new FormAttachment(wPauseBreakPoint, margin);
wlCondition.setLayoutData(fdlCondition);
ConditionEditor wCondition = new ConditionEditor(wComposite, SWT.BORDER, condition, transformInputFields);
FormData fdCondition = new FormData();
fdCondition.left = new FormAttachment(middle, 0);
fdCondition.right = new FormAttachment(100, 0);
fdCondition.top = new FormAttachment(wPauseBreakPoint, margin);
fdCondition.bottom = new FormAttachment(100, 0);
wCondition.setLayoutData(fdCondition);
getTransformDebugData(transformDebugMeta);
// Add a "clear" button at the bottom on the left...
//
Button wClear = new Button(wComposite, SWT.PUSH);
props.setLook(wClear);
wClear.setText(BaseMessages.getString(PKG, "PipelineDebugDialog.Clear.Label"));
wClear.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.Clear.ToolTip"));
FormData fdClear = new FormData();
fdClear.left = new FormAttachment(0, 0);
fdClear.bottom = new FormAttachment(100, 0);
wClear.setLayoutData(fdClear);
wClear.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
// Clear the preview transform information for this transform...
//
transformDebugMetaMap.remove(transformMeta);
wTransforms.table.setSelection(new int[] {});
previousIndex = -1;
// refresh the transforms list...
//
refreshTransformList();
showTransformDebugInformation();
}
});
wComposite.layout(true, true);
}
Aggregations