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 ); }
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 ); }
@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() ); }