public FilterRowsMeta() { super(); // allocate BaseStepMeta condition = new Condition(); }
public void allocate() { condition = new Condition(); }
public JoinRowsMeta() { super(); // allocate BaseStepMeta condition = new Condition(); }
@Injection( name = "CONDITION" ) public void setCondition( String conditionXML ) throws Exception { condition = new Condition( conditionXML ); }
@Injection( name = "CONDITION" ) public void setConditionXML( String conditionXML ) { try { this.condition = new Condition( conditionXML ); } catch ( KettleXMLException e ) { log.logError( e.getMessage() ); } } }
@Override public Condition loadConditionFromStepAttribute( ObjectId id_step, String code ) throws KettleException { // TODO Auto-generated method stub String tmp = this.getStepAttributeString( id_step, code ); return new Condition( tmp ); }
private void addCondition() { Condition c = new Condition(); c.setOperator( Condition.OPERATOR_AND ); addCondition( c ); setModified(); widget.redraw(); }
@Override public void widgetSelected( SelectionEvent e ) { Condition c = new Condition(); c.setOperator( Condition.OPERATOR_AND ); sub.addCondition( c ); setModified(); widget.redraw(); } } );
@Override public Condition getTestObject() { Condition rtn = new Condition(); rtn.setFunction( rand.nextInt( Condition.functions.length ) ); rtn.setLeftValuename( UUID.randomUUID().toString() ); rtn.setNegated( rand.nextBoolean() ); rtn.setOperator( rand.nextInt( Condition.operators.length ) ); rtn.setRightValuename( UUID.randomUUID().toString() ); return rtn; }
private void readData( Node stepnode ) throws KettleXMLException { try { directory = XMLHandler.getTagValue( stepnode, "directory" ); prefix = XMLHandler.getTagValue( stepnode, "prefix" ); cacheSize = Const.toInt( XMLHandler.getTagValue( stepnode, "cache_size" ), -1 ); mainStepname = XMLHandler.getTagValue( stepnode, "main" ); Node compare = XMLHandler.getSubNode( stepnode, "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 KettleXMLException( BaseMessages.getString( PKG, "JoinRowsMeta.Exception.UnableToReadStepInfoFromXML" ), e ); } }
public Condition loadConditionFromStepAttribute( ObjectId idStep, String code ) throws KettleException { DataNode conditionNode = node.getNode( code ); if ( conditionNode.hasProperty( PROPERTY_XML ) ) { String xml = conditionNode.getProperty( PROPERTY_XML ).getString(); Condition condition = new Condition( XMLHandler.getSubNode( XMLHandler.loadXMLString( xml ), Condition.XML_TAG ) ); return condition; } else { return null; } }
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 ); }
@Override public void widgetSelected( SelectionEvent e ) { // Move the condition lower: this means create a subcondition and put the condition there in the list. // Condition down = active_condition.getCondition( cond_nr ); Condition c = new Condition(); c.setOperator( down.getOperator() ); down.setOperator( Condition.OPERATOR_NONE ); active_condition.setCondition( cond_nr, c ); c.addCondition( down ); widget.redraw(); } } );
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 ); }
@Override public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException { try { directory = rep.getStepAttributeString( id_step, "directory" ); prefix = rep.getStepAttributeString( id_step, "prefix" ); cacheSize = (int) rep.getStepAttributeInteger( id_step, "cache_size" ); mainStepname = rep.getStepAttributeString( id_step, "main" ); condition = rep.loadConditionFromStepAttribute( id_step, "id_condition" ); if ( condition == null ) { condition = new Condition(); } } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "JoinRowsMeta.Exception.UnexpectedErrorInReadStepInfoFromRepository" ), e ); } }
@Test public void test() throws Exception { check( "SEND_FALSE_STEP", new StringGetter() { public String get() { return meta.getFalseStepname(); } } ); check( "SEND_TRUE_STEP", new StringGetter() { public String get() { return meta.getTrueStepname(); } } ); check( "CONDITION", new StringGetter() { public String get() { return meta.getConditionXML(); } }, new Condition().getXML() ); } }
@Override public void widgetSelected( SelectionEvent e ) { String xml = GUIResource.getInstance().fromClipboard(); try { Document d = XMLHandler.loadXMLString( xml ); Node condNode = XMLHandler.getSubNode( d, "condition" ); if ( condNode != null ) { Condition c = new Condition( condNode ); active_condition.addCondition( cond_nr, c ); widget.redraw(); } else { new ErrorDialog( shell, BaseMessages.getString( PKG, "ConditionEditor.Error" ), BaseMessages .getString( PKG, "ConditionEditor.NoConditionFoundXML" ), new KettleXMLException( BaseMessages .getString( PKG, "ConditionEditor.NoConditionFoundXML.Exception", Const.CR + Const.CR + xml ) ) ); } } catch ( KettleXMLException ex ) { new ErrorDialog( shell, BaseMessages.getString( PKG, "ConditionEditor.Error" ), BaseMessages .getString( PKG, "ConditionEditor.ErrorParsingCondition" ), ex ); } } } );
@Override public void widgetSelected( SelectionEvent e ) { String xml = GUIResource.getInstance().fromClipboard(); try { Document d = XMLHandler.loadXMLString( xml ); Node condNode = XMLHandler.getSubNode( d, "condition" ); if ( condNode != null ) { Condition c = new Condition( condNode ); active_condition.addCondition( cond_nr + 1, c ); widget.redraw(); } else { new ErrorDialog( shell, BaseMessages.getString( PKG, "ConditionEditor.Error" ), BaseMessages .getString( PKG, "ConditionEditor.NoConditionFoundXML" ), new KettleXMLException( BaseMessages .getString( PKG, "ConditionEditor.NoConditionFoundXML.Exception", Const.CR + Const.CR + xml ) ) ); } } catch ( KettleXMLException ex ) { new ErrorDialog( shell, BaseMessages.getString( PKG, "ConditionEditor.Error" ), BaseMessages .getString( PKG, "ConditionEditor.ErrorParsingCondition" ), ex ); } } } );
@Test public void testClone() { FilterRowsMeta filterRowsMeta = new FilterRowsMeta(); filterRowsMeta.setCondition( new Condition() ); filterRowsMeta.setTrueStepname( "true" ); filterRowsMeta.setFalseStepname( "false" ); FilterRowsMeta clone = (FilterRowsMeta) filterRowsMeta.clone(); assertNotNull( clone.getCondition() ); assertEquals( "true", clone.getTrueStepname() ); assertEquals( "false", clone.getFalseStepname() ); }
@Test public void modifiedTarget() throws Exception { FilterRowsMeta filterRowsMeta = new FilterRowsMeta(); StepMeta trueOutput = new StepMeta( "true", new DummyTransMeta() ); StepMeta falseOutput = new StepMeta( "false", new DummyTransMeta() ); filterRowsMeta.setCondition( new Condition() ); filterRowsMeta.setTrueStepname( trueOutput.getName() ); filterRowsMeta.setFalseStepname( falseOutput.getName() ); filterRowsMeta.searchInfoAndTargetSteps( ImmutableList.of( trueOutput, falseOutput ) ); trueOutput.setName( "true renamed" ); falseOutput.setName( "false renamed" ); assertEquals( "true renamed", filterRowsMeta.getTrueStepname() ); assertEquals( "false renamed", filterRowsMeta.getFalseStepname() ); } }