private ActionSetFieldCol52 makeNewColumn(ActionSetFieldCol c) { ActionSetFieldCol52 nc = new ActionSetFieldCol52(); nc.setBoundName( c.boundName ); nc.setDefaultValue( new DTCellValue52( c.defaultValue ) ); nc.setFactField( c.factField ); nc.setHeader( c.header ); nc.setHideColumn( c.hideColumn ); nc.setType( c.type ); nc.setUpdate( c.update ); nc.setValueList( c.valueList ); nc.setWidth( c.width ); return nc; }
private void doAction(List<LabelledAction> actions, ActionSetFieldCol52 sf, String cell) { LabelledAction a = findByLabelledAction( actions, sf.getBoundName() ); if ( a == null ) { a = new LabelledAction(); a.boundName = sf.getBoundName(); if ( !sf.isUpdate() ) { a.action = new ActionSetField( sf.getBoundName() ); } else { a.action = new ActionUpdateField( sf.getBoundName() ); } actions.add( a ); } else if ( sf.isUpdate() && !(a.action instanceof ActionUpdateField) ) { // lets swap it out for an update as the user has asked for it. ActionSetField old = (ActionSetField) a.action; ActionUpdateField update = new ActionUpdateField( sf.getBoundName() ); update.fieldValues = old.fieldValues; a.action = update; } ActionSetField asf = (ActionSetField) a.action; ActionFieldValue val = new ActionFieldValue( sf.getFactField(), cell, sf.getType() ); asf.addFieldValue( val ); }
public ActionSetFieldColumnDetails(final ActionSetFieldCol52 column) { super( column ); this.boundName = column.getBoundName(); this.factField = column.getFactField(); }
dt.getConditions().add( p1 ); ActionSetFieldCol52 asf = new ActionSetFieldCol52(); asf.setBoundName( "x" ); asf.setFactField( "age" ); asf.setType( SuggestionCompletionEngine.TYPE_NUMERIC_INTEGER ); asf.setUpdate( true );
dt.getConditions().add( p2 ); ActionSetFieldCol52 asf = new ActionSetFieldCol52(); asf.setBoundName( "c1" ); asf.setFactField( "name" ); dt.getActionCols().add( asf ); ActionSetFieldCol52 asf_ = new ActionSetFieldCol52(); asf_.setBoundName( "c1" ); asf_.setFactField( "goo" ); dt.getActionCols().add( asf_ ); ActionSetFieldCol52 asf__ = new ActionSetFieldCol52(); asf__.setBoundName( "c1" ); asf__.setFactField( "goo" ); asf__.setValueList( "one,two,three" ); dt.getActionCols().add( asf__ ); asf.getFactField() ) ); assertFalse( dt.hasValueList( asf ) ); r = sce.getEnums( p1.getFactType(), asf.getFactField(), currentValueMap ).fixedList; assertEquals( 2, asf__.getFactField() ) ); assertTrue( dt.hasValueList( asf__ ) ); r = dt.getValueList( asf__ );
dt.getConditions().add( p2 ); ActionSetFieldCol52 a = new ActionSetFieldCol52(); a.setBoundName( "c1" ); a.setFactField( "name" ); dt.getActionCols().add( a ); ActionSetFieldCol52 a2 = new ActionSetFieldCol52(); a2.setBoundName( "c1" ); a2.setFactField( "age" ); dt.getActionCols().add( a2 );
a3.getBoundName() ); assertEquals( "goo1", a3.getFactField() ); assertEquals( SuggestionCompletionEngine.TYPE_STRING, a3.getType() ); a4.getBoundName() ); assertEquals( "goo2", a4.getFactField() ); assertEquals( "whee", a4.getDefaultValue().getStringValue() ); assertEquals( SuggestionCompletionEngine.TYPE_STRING, a4.getType() );
@Test public void testBackwardsCompatability() throws Exception { String xml = BRLPersistenceTest.loadResource( "ExistingDecisionTable.xml" ); GuidedDecisionTable52 dt_ = GuidedDTXMLPersistence.getInstance().unmarshal( xml ); assertNotNull( dt_ ); assertEquals( "blah", dt_.getTableName() ); assertEquals( 1, dt_.getMetadataCols().size() ); assertEquals( 1, dt_.getAttributeCols().size() ); assertEquals( 2, dt_.getActionCols().size() ); assertEquals( 1, dt_.getConditions().size() ); assertEquals( 1, dt_.getConditions().get( 0 ).getChildColumns().size() ); assertTrue( dt_.getActionCols().get( 1 ) instanceof ActionSetFieldCol52 ); ActionSetFieldCol52 asf = (ActionSetFieldCol52) dt_.getActionCols().get( 1 ); assertEquals( "foo", asf.getFactField() ); assertEquals( false, asf.isUpdate() ); }
ActionSetFieldCol52 set = new ActionSetFieldCol52(); set.setFactField( "foo" ); dt.getActionCols().add( set );
private String getType(Pattern52 pattern, ActionSetFieldCol52 col, SuggestionCompletionEngine sce) { // Columns with "Value Lists" etc are always Text (for now) if ( hasValueList( col ) ) { return SuggestionCompletionEngine.TYPE_STRING; } //Otherwise lookup from SuggestionCompletionEngine final String factType = pattern.getFactType(); final String fieldName = col.getFactField(); return getTypeFromSCE( factType, fieldName, sce ); }
@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( SuggestionCompletionEngine.TYPE_STRING ); dt.getActionCols().add( asf ); String[][] data = new String[][]{ new String[]{"1", "desc", "y", "old"} }; dt.setData( upgrader.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( upgrader.makeDataLists( new String[][]{ new String[]{"1", "desc", "", "old"} } ) ); drl = GuidedDTDRLPersistence.getInstance().marshal( dt ); assertEquals( -1, drl.indexOf( "Context( )" ) ); }
ActionSetFieldCol52 a = new ActionSetFieldCol52(); a.setBoundName( "c1" ); a.setFactField( "name" ); dt.getActionCols().add( a ); ActionSetFieldCol52 a2 = new ActionSetFieldCol52(); a2.setBoundName( "c1" ); a2.setFactField( "age" ); dt.getActionCols().add( a2 );
a3.getBoundName() ); assertEquals( "goo1", a3.getFactField() ); assertEquals( SuggestionCompletionEngine.TYPE_STRING, a3.getType() ); a4.getBoundName() ); assertEquals( "goo2", a4.getFactField() ); assertEquals( "whee", a4.getDefaultValue().getStringValue() ); assertEquals( SuggestionCompletionEngine.TYPE_STRING, a4.getType() );
public ActionSetFieldColumnDetails(final ActionSetFieldCol52 column) { super( column ); this.boundName = column.getBoundName(); this.factField = column.getFactField(); }
private String getType(Pattern52 pattern, ActionSetFieldCol52 col, SuggestionCompletionEngine sce) { // Columns with "Value Lists" etc are always Text (for now) if ( hasValueList( col ) ) { return SuggestionCompletionEngine.TYPE_STRING; } //Otherwise lookup from SuggestionCompletionEngine final String factType = pattern.getFactType(); final String fieldName = col.getFactField(); return getTypeFromSCE( factType, fieldName, sce ); }
private ActionSetFieldCol52 makeNewColumn(ActionSetFieldCol c) { ActionSetFieldCol52 nc = new ActionSetFieldCol52(); nc.setBoundName( c.boundName ); nc.setDefaultValue( new DTCellValue52( c.defaultValue ) ); nc.setFactField( c.factField ); nc.setHeader( c.header ); nc.setHideColumn( c.hideColumn ); nc.setType( c.type ); nc.setUpdate( c.update ); nc.setValueList( c.valueList ); nc.setWidth( c.width ); return nc; }
List<ActionCol52> cols = new ArrayList<ActionCol52>(); ActionSetFieldCol52 asf1 = new ActionSetFieldCol52(); asf1.setBoundName( "a" ); asf1.setFactField( "field1" ); asf1.setType( SuggestionCompletionEngine.TYPE_STRING ); cols.add( asf1 ); ActionSetFieldCol52 asf2 = new ActionSetFieldCol52(); asf2.setBoundName( "a" ); asf2.setFactField( "field2" ); asf2.setUpdate( true ); asf2.setType( SuggestionCompletionEngine.TYPE_NUMERIC_INTEGER ); cols.add( asf2 );
private void doAction(List<LabelledAction> actions, ActionSetFieldCol52 sf, String cell) { LabelledAction a = findByLabelledAction( actions, sf.getBoundName() ); if ( a == null ) { a = new LabelledAction(); a.boundName = sf.getBoundName(); if ( !sf.isUpdate() ) { a.action = new ActionSetField( sf.getBoundName() ); } else { a.action = new ActionUpdateField( sf.getBoundName() ); } actions.add( a ); } else if ( sf.isUpdate() && !(a.action instanceof ActionUpdateField) ) { // lets swap it out for an update as the user has asked for it. ActionSetField old = (ActionSetField) a.action; ActionUpdateField update = new ActionUpdateField( sf.getBoundName() ); update.fieldValues = old.fieldValues; a.action = update; } ActionSetField asf = (ActionSetField) a.action; ActionFieldValue val = new ActionFieldValue( sf.getFactField(), cell, sf.getType() ); asf.addFieldValue( val ); }
ac.setAttribute( "salience" ); ActionSetFieldCol52 asfc = new ActionSetFieldCol52(); asfc.setBoundName( "d1" ); asfc.setFactField( "age" );
private String getType(ActionSetFieldCol52 col, SuggestionCompletionEngine sce) { // Columns with "Value Lists" etc are always Text (for now) if ( hasValueList( col ) ) { return SuggestionCompletionEngine.TYPE_STRING; } //Otherwise lookup from SuggestionCompletionEngine final String factType = getBoundFactType( col.getBoundName() ); final String fieldName = col.getFactField(); return getTypeFromSCE( factType, fieldName, sce ); }