public void getUsedFields( Hashtable<String, String> fields ) { if ( isAtomic() ) { if ( getLeftValuename() != null ) { fields.put( getLeftValuename(), "-" ); } if ( getRightValuename() != null ) { fields.put( getRightValuename(), "-" ); } } else { for ( int i = 0; i < nrConditions(); i++ ) { Condition subc = getCondition( i ); subc.getUsedFields( fields ); } } }
public void addCondition( Condition cb ) { if ( isAtomic() && getLeftValuename() != null ) { /* * Copy current atomic setup... */ Condition current = new Condition( getLeftValuename(), getFunction(), getRightValuename(), getRightExact() ); current.setNegated( isNegated() ); setNegated( false ); list.add( current ); } else { // Set default operator if not on first position... if ( isComposite() && list.size() > 0 && cb.getOperator() == OPERATOR_NONE ) { cb.setOperator( OPERATOR_AND ); } } list.add( cb ); }
public void addCondition( int idx, Condition cb ) { if ( isAtomic() && getLeftValuename() != null ) { /* * Copy current atomic setup... */ Condition current = new Condition( getLeftValuename(), getFunction(), getRightValuename(), getRightExact() ); current.setNegated( isNegated() ); setNegated( false ); list.add( current ); } else { // Set default operator if not on first position... if ( isComposite() && idx > 0 && cb.getOperator() == OPERATOR_NONE ) { cb.setOperator( OPERATOR_AND ); } } list.add( idx, cb ); }
private boolean simplify( Condition condition, Condition parent ) { // If condition is atomic // AND // if parent only contain a single child: simplify // if ( condition.isAtomic() && parent.nrConditions() == 1 ) { parent.setLeftValuename( condition.getLeftValuename() ); parent.setFunction( condition.getFunction() ); parent.setRightValuename( condition.getRightValuename() ); parent.setRightExact( condition.getRightExact() ); parent.setNegated( condition.isNegated() ^ parent.isNegated() ); parent.list.clear(); return true; } return false; }
public void removeCondition( int nr ) { if ( isComposite() ) { Condition c = list.get( nr ); list.remove( nr ); // Nothing left or only one condition left: move it to the parent: make it atomic. boolean moveUp = isAtomic() || nrConditions() == 1; if ( nrConditions() == 1 ) { c = getCondition( 0 ); } if ( moveUp ) { setLeftValuename( c.getLeftValuename() ); setFunction( c.getFunction() ); setRightValuename( c.getRightValuename() ); setRightExact( c.getRightExact() ); setNegated( isNegated() ^ c.isNegated() ); } } }
Point ext_fn = gc.textExtent( fn_max ); String rightval = Const.rightPad( condition.getRightValuename(), max_field_length ); Point ext_rval = gc.textExtent( rightval ); if ( condition.getLeftValuename() == null ) { if ( condition.getRightValuename() != null ) { gc.drawText( rightval, size_rightval.x + 1 + offsetx, size_rightval.y + 1 + offsety, SWT.DRAW_TRANSPARENT ); } else { gc.setForeground( gray ); gc.drawText( nothing, size_rightval.x + 1 + offsetx, size_rightval.y + 1 + offsety, SWT.DRAW_TRANSPARENT ); if ( condition.getRightValuename() == null ) { gc.setForeground( black ); gc.drawText( re, size_rightex.x + 1 + offsetx, size_rightex.y + 1 + offsety, SWT.DRAW_TRANSPARENT ); } else { String nothing = condition.getRightValuename() == null ? "<value>" : ""; gc.setForeground( gray ); gc.drawText( nothing, size_rightex.x + 1 + offsetx, size_rightex.y + 1 + offsety, SWT.DRAW_TRANSPARENT );
public String getXML( int level ) throws KettleValueException { String retval = ""; String indent1 = Const.rightPad( " ", level ); String indent2 = Const.rightPad( " ", level + 1 ); String indent3 = Const.rightPad( " ", level + 2 ); retval += indent1 + XMLHandler.openTag( XML_TAG ) + Const.CR; retval += indent2 + XMLHandler.addTagValue( "negated", isNegated() ); if ( getOperator() != OPERATOR_NONE ) { retval += indent2 + XMLHandler.addTagValue( "operator", Const.rtrim( getOperatorDesc() ) ); } if ( isAtomic() ) { retval += indent2 + XMLHandler.addTagValue( "leftvalue", getLeftValuename() ); retval += indent2 + XMLHandler.addTagValue( "function", getFunctionDesc() ); retval += indent2 + XMLHandler.addTagValue( "rightvalue", getRightValuename() ); if ( getRightExact() != null ) { retval += indent2 + getRightExact().getXML(); } } else { retval += indent2 + "<conditions>" + Const.CR; for ( int i = 0; i < nrConditions(); i++ ) { Condition c = getCondition( i ); retval += c.getXML( level + 2 ); } retval += indent3 + "</conditions>" + Const.CR; } retval += indent2 + XMLHandler.closeTag( XML_TAG ) + Const.CR; return retval; }
table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_CONDITION_RIGHT_NAME ), condition .getRightValuename() );