private void makeLimitedValueWidget() { if ( !( chosenConditionsSelection instanceof LimitedEntryConditionCol52 ) ) { return; } final LimitedEntryConditionCol52 lec = (LimitedEntryConditionCol52) chosenConditionsSelection; boolean doesOperatorNeedValue = validator.doesOperatorNeedValue( chosenConditionsSelection ); if ( !doesOperatorNeedValue ) { limitedEntryValueContainer.setVisible( false ); lec.setValue( null ); return; } limitedEntryValueContainer.setVisible( true ); if ( lec.getValue() == null ) { lec.setValue( factory.makeNewValue( chosenConditionsSelection ) ); } limitedEntryValueWidgetContainer.setWidget( factory.getWidget( availablePatternsSelection, chosenConditionsSelection, lec.getValue() ) ); }
private void makeLimitedValueWidget() { if ( !( editingCol instanceof LimitedEntryConditionCol52 ) ) { return; } LimitedEntryConditionCol52 lec = (LimitedEntryConditionCol52) editingCol; boolean doesOperatorNeedValue = validator.doesOperatorNeedValue( editingCol ); if ( !doesOperatorNeedValue ) { setAttributeVisibility( limitedEntryValueAttributeIndex, false ); lec.setValue( null ); return; } setAttributeVisibility( limitedEntryValueAttributeIndex, true ); if ( lec.getValue() == null ) { lec.setValue( factory.makeNewValue( editingPattern, editingCol ) ); } limitedEntryValueWidgetContainer.setWidget( factory.getWidget( editingPattern, editingCol, lec.getValue() ) ); }
@Test public void testLimitedEntryConditionsNoConstraints() { GuidedDecisionTable52 dt = new GuidedDecisionTable52(); dt.setTableFormat( GuidedDecisionTable52.TableFormat.LIMITED_ENTRY ); dt.setTableName( "limited-entry" ); Pattern52 p1 = new Pattern52(); p1.setBoundName( "p1" ); p1.setFactType( "Smurf" ); dt.getConditions().add( p1 ); // This is a hack consistent with how the Expanded Form decision table // works. I wouldn't be too surprised if this changes at some time, but // GuidedDTDRLPersistence.marshal does not support empty patterns at // present. LimitedEntryConditionCol52 cc1 = new LimitedEntryConditionCol52(); cc1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); cc1.setValue( new DTCellValue52( "y" ) ); p1.getChildColumns().add( cc1 ); dt.setData( DataUtilities.makeDataLists( new Object[][]{ new Object[]{ 1l, "desc", true }, new Object[]{ 2l, "desc", false } } ) ); GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance(); String drl = p.marshal( dt ); int index = -1; index = drl.indexOf( "Smurf( )" ); assertTrue( index > -1 ); index = drl.indexOf( "Smurf( )", index + 1 ); assertFalse( index > -1 ); }
cc1.setFactField( "name" ); cc1.setOperator( "==" ); cc1.setValue( new DTCellValue52( "Pupa" ) ); p1.getChildColumns().add( cc1 ); cc2.setFactField( "name" ); cc2.setOperator( "==" ); cc2.setValue( new DTCellValue52( "Smurfette" ) ); p1.getChildColumns().add( cc2 ); cc3.setFactField( "colour" ); cc3.setOperator( "==" ); cc3.setValue( new DTCellValue52( "Blue" ) ); p1.getChildColumns().add( cc3 );
@Test public void testLimitedEntryConditionsConstraints1() { GuidedDecisionTable52 dt = new GuidedDecisionTable52(); dt.setTableFormat( GuidedDecisionTable52.TableFormat.LIMITED_ENTRY ); dt.setTableName( "limited-entry" ); Pattern52 p1 = new Pattern52(); p1.setBoundName( "p1" ); p1.setFactType( "Smurf" ); dt.getConditions().add( p1 ); LimitedEntryConditionCol52 cc1 = new LimitedEntryConditionCol52(); cc1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL ); cc1.setFieldType( DataType.TYPE_STRING ); cc1.setFactField( "name" ); cc1.setOperator( "==" ); cc1.setValue( new DTCellValue52( "Pupa" ) ); p1.getChildColumns().add( cc1 ); dt.setData( DataUtilities.makeDataLists( new Object[][]{ new Object[]{ 1l, "desc", true }, new Object[]{ 2l, "desc", false } } ) ); GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance(); String drl = p.marshal( dt ); int index = -1; index = drl.indexOf( "Smurf( name == \"Pupa\" )" ); assertTrue( index > -1 ); index = drl.indexOf( "Smurf( name == \"Pupa\" )", index + 1 ); assertFalse( index > -1 ); }
cc1.setFactField( "isSmurf" ); cc1.setOperator( "==" ); cc1.setValue( new DTCellValue52( "true" ) ); p1.getChildColumns().add( cc1 );