@Override public void onClick( final ClickEvent w ) { chosenConditionsSelection.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE ); chosenConditionsWidget.redraw(); presenter.assertDefaultValue( availablePatternsSelection, chosenConditionsSelection ); makeDefaultValueWidget(); } } );
@Override public void onClick( final ClickEvent w ) { chosenConditionsSelection.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); chosenConditionsWidget.redraw(); presenter.assertDefaultValue( availablePatternsSelection, chosenConditionsSelection ); makeDefaultValueWidget(); } } );
@Override public void onClick( final ClickEvent w ) { chosenConditionsSelection.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE ); chosenConditionsWidget.redraw(); presenter.assertDefaultValue( availablePatternsSelection, chosenConditionsSelection ); makeDefaultValueWidget(); } } );
private void applyConsTypeChange( int newType ) { editingCol.setConstraintValueType( newType ); binding.setEnabled( newType == BaseSingleFieldConstraint.TYPE_LITERAL && !isReadOnly ); doFieldLabel(); doValueList(); doOperatorLabel(); doImageButtons(); makeDefaultValueWidget(); }
private void doCalculationType() { if ( model.getTableFormat() == TableFormat.LIMITED_ENTRY ) { return; } //Disable Formula and Predicate if the Fact\Field has enums final String factType = editingPattern.getFactType(); final String factField = editingCol.getFactField(); final boolean hasEnums = oracle.hasEnums( factType, factField ); this.literal.setEnabled( hasEnums || !isReadOnly ); this.formula.setEnabled( !( hasEnums || isReadOnly ) ); this.predicate.setEnabled( !( hasEnums || isReadOnly ) ); //If Fact\Field has enums the Value Type has to be a literal if ( hasEnums ) { this.editingCol.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); } }
private ConditionCol52 makeNewConditionColumn( final AvailableField f ) { final GuidedDecisionTable52.TableFormat format = presenter.getTableFormat(); if ( format == GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY ) { final ConditionCol52 c = new ConditionCol52(); c.setFactField( f.getName() ); c.setFieldType( f.getType() ); c.setConstraintValueType( f.getCalculationType() ); return c; } else { final LimitedEntryConditionCol52 c = new LimitedEntryConditionCol52(); c.setFactField( f.getName() ); c.setFieldType( f.getType() ); c.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); return c; } }
col1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); col1.setOperator( "" ); p1.getChildColumns().add( col1 );
@Test public void testNoConstraints() { GuidedDecisionTable52 dt = new GuidedDecisionTable52(); Pattern52 p1 = new Pattern52(); p1.setBoundName( "x" ); p1.setFactType( "Context" ); ConditionCol52 c = new ConditionCol52(); c.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); p1.getChildColumns().add( c ); dt.getConditions().add( p1 ); ActionSetFieldCol52 asf = new ActionSetFieldCol52(); asf.setBoundName( "x" ); asf.setFactField( "age" ); asf.setType( DataType.TYPE_STRING ); dt.getActionCols().add( asf ); String[][] data = new String[][]{ new String[]{ "1", "desc", "y", "old" } }; dt.setData( DataUtilities.makeDataLists( data ) ); String drl = GuidedDTDRLPersistence.getInstance().marshal( dt ); assertTrue( drl.indexOf( "Context( )" ) > -1 ); assertTrue( drl.indexOf( "x.setAge" ) > drl.indexOf( "Context( )" ) ); assertFalse( drl.indexOf( "update( x );" ) > -1 ); dt.setData( DataUtilities.makeDataLists( new String[][]{ new String[]{ "1", "desc", "", "old" } } ) ); drl = GuidedDTDRLPersistence.getInstance().marshal( dt ); assertEquals( -1, drl.indexOf( "Context( )" ) ); }
cc1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); cc1.setFieldType( DataType.TYPE_STRING ); cc1.setFactField( "name" ); cc2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); cc2.setFieldType( DataType.TYPE_NUMERIC_INTEGER ); cc2.setFactField( "age" ); cc3.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); cc3.setFieldType( DataType.TYPE_DATE ); cc3.setFactField( "dateOfBirth" );
cc1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); cc1.setFieldType( DataType.TYPE_STRING ); cc1.setFactField( "name" ); cc2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); cc2.setFieldType( DataType.TYPE_NUMERIC_INTEGER ); cc2.setFactField( "age" );
c.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); p1.getChildColumns().add( c ); dt.getConditions().add( p1 );
cc1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); cc1.setFieldType( DataType.TYPE_STRING ); cc1.setFactField( "name" ); cc2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); cc2.setFieldType( DataType.TYPE_NUMERIC_INTEGER ); cc2.setFactField( "age" );
p1.setBoundName( "c1" ); p1.setFactType( "Driver" ); c1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); p1.getChildColumns().add( c1 ); dt.getConditions().add( p1 ); p2.setBoundName( "c2" ); p2.setFactType( "Driver" ); c2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); c2.setValueList( "a,b,c" ); p2.getChildColumns().add( c2 );
@Test public void testOnlyDecisionTableColumns() { GuidedDecisionTable52 dt = new GuidedDecisionTable52(); Pattern52 p1 = new Pattern52(); p1.setFactType( "Driver" ); p1.setBoundName( "$p1" ); ConditionCol52 c1 = new ConditionCol52(); c1.setFactField( "name" ); c1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); c1.setBinding( "$c1" ); p1.getChildColumns().add( c1 ); dt.getConditions().add( p1 ); ActionInsertFactCol52 ins = new ActionInsertFactCol52(); ins.setBoundName( "$ins" ); ins.setFactField( "rating" ); ins.setFactType( "Person" ); ins.setType( DataType.TYPE_STRING ); dt.getActionCols().add( ins ); BRLRuleModel model = new BRLRuleModel( dt ); assertNotNull( model.getAllVariables() ); assertEquals( 3, model.getAllVariables().size() ); assertTrue( model.getAllVariables().contains( "$p1" ) ); assertTrue( model.getAllVariables().contains( "$c1" ) ); assertTrue( model.getAllVariables().contains( "$ins" ) ); }
@Test public void testPackageNameAndImports() throws Exception { GuidedDecisionTable52 dt = new GuidedDecisionTable52(); dt.setPackageName( "org.drools.guvnor.models.guided.dtable.backend" ); dt.getImports().addImport( new Import( "java.lang.String" ) ); dt.setTableName( "michael" ); Pattern52 p1 = new Pattern52(); p1.setBoundName( "f1" ); p1.setFactType( "Driver" ); ConditionCol52 con = new ConditionCol52(); con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); con.setFactField( "age" ); con.setHeader( "Driver f1 age" ); con.setOperator( "==" ); p1.getChildColumns().add( con ); dt.getConditions().add( p1 ); dt.setData( DataUtilities.makeDataLists( new String[][]{ new String[]{ "1", "desc", "42" } } ) ); GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance(); String drl = p.marshal( dt ); assertTrue( drl.indexOf( "package org.drools.guvnor.models.guided.dtable.backend;" ) == 0 ); assertTrue( drl.indexOf( "import java.lang.String;" ) > 0 ); }
private void populateModelColumn( final ConditionCol52 col, final ConditionCol52 editingCol ) { col.setConstraintValueType( editingCol.getConstraintValueType() ); col.setFactField( editingCol.getFactField() ); col.setFieldType( editingCol.getFieldType() ); col.setHeader( editingCol.getHeader() ); col.setOperator( editingCol.getOperator() ); col.setValueList( editingCol.getValueList() ); col.setDefaultValue( editingCol.getDefaultValue() ); col.setHideColumn( editingCol.isHideColumn() ); col.setParameters( editingCol.getParameters() ); col.setBinding( editingCol.getBinding() ); if ( col instanceof LimitedEntryCol && editingCol instanceof LimitedEntryCol ) { ( (LimitedEntryCol) col ).setValue( ( (LimitedEntryCol) editingCol ).getValue() ); } }
c.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); c.setFactField( "favouriteCheese" ); c.setDefaultValue( new DTCellValue52( "cheddar" ) );
private ConditionCol52 cloneConditionColumn( ConditionCol52 col ) { ConditionCol52 clone = null; if ( col instanceof LimitedEntryConditionCol52 ) { clone = new LimitedEntryConditionCol52(); DTCellValue52 dcv = cloneLimitedEntryValue( ( (LimitedEntryCol) col ).getValue() ); ( (LimitedEntryCol) clone ).setValue( dcv ); } else { clone = new ConditionCol52(); } clone.setConstraintValueType( col.getConstraintValueType() ); clone.setFactField( col.getFactField() ); clone.setFieldType( col.getFieldType() ); clone.setHeader( col.getHeader() ); clone.setOperator( col.getOperator() ); clone.setValueList( col.getValueList() ); clone.setDefaultValue( new DTCellValue52( col.getDefaultValue() ) ); clone.setHideColumn( col.isHideColumn() ); clone.setParameters( col.getParameters() ); clone.setWidth( col.getWidth() ); clone.setBinding( col.getBinding() ); return clone; }
p1.setBoundName( "c1" ); p1.setFactType( "Driver" ); c1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE ); c1.setFieldType( DataType.TYPE_STRING ); c1.setValueList( "age>10,age>20,age>30" );
p1.setBoundName( "c1" ); p1.setFactType( "Driver" ); c1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE ); c1.setFieldType( DataType.TYPE_STRING ); c1.setValueList( "getAge()>10,getAge()>20,getAge()>30" );