public boolean isPatternValid( Pattern52 p ) { return !( p.getBoundName() == null || p.getBoundName().equals( "" ) ); }
public boolean isPatternBindingUnique( Pattern52 pattern ) { String binding = pattern.getBoundName(); if ( binding == null || binding.equals( "" ) ) { return true; } for ( CompositeColumn<? extends BaseColumn> cc : patternsConditions ) { if ( cc instanceof Pattern52 ) { Pattern52 p = (Pattern52) cc; if ( p != pattern ) { if ( p.getBoundName() != null && p.getBoundName().equals( binding ) ) { return false; } } } } for ( Pattern52 p : patternsActions ) { if ( p != pattern ) { if ( p.getBoundName() != null && p.getBoundName().equals( binding ) ) { return false; } } } return true; }
private String getFactType( String boundName ) { for ( Pattern52 p : model.getPatterns() ) { if ( p.getBoundName().equals( boundName ) ) { return p.getFactType(); } } return ""; }
private Label makePatternLabel( Pattern52 p ) { StringBuilder patternLabel = new StringBuilder(); String factType = p.getFactType(); String boundName = p.getBoundName(); if ( factType != null && factType.length() > 0 ) { if ( p.isNegated() ) { patternLabel.append( Constants.INSTANCE.negatedPattern() ).append( " " ).append( factType ); } else { patternLabel.append( factType ).append( " [" ).append( boundName ).append( "]" ); } } return new Label( patternLabel.toString() ); }
if ( cc instanceof Pattern52 ) { Pattern52 p = (Pattern52) cc; String binding = p.getBoundName(); if ( binding != null && !binding.equals( "" ) ) { List<Pattern52> ps = bindings.get( binding ); String binding = p.getBoundName(); if ( binding != null && !binding.equals( "" ) ) { List<Pattern52> ps = bindings.get( binding );
@Override public void render( final Context context, final Pattern52 pattern, final SafeHtmlBuilder sb ) { final String binding = pattern.getBoundName(); final StringBuilder b = new StringBuilder(); if ( binding == null || "".equals( binding ) ) { b.append( pattern.getFactType() ); } else { b.append( pattern.getBoundName() ); b.append( " : " ); b.append( pattern.getFactType() ); } sb.append( TEMPLATE.text( getCssStyleName( pattern ), b.toString() ) ); }
@Override public void makeResult( final GuidedDecisionTable52 model ) { //Copy actions to decision table model. Assertion of bindings occurs in FactPatternsPage for ( Map.Entry<Pattern52, List<ActionSetFieldCol52>> ps : patternToActionsMap.entrySet() ) { final Pattern52 p = ps.getKey(); //Patterns with no conditions don't get created if ( p.getChildColumns().size() > 0 ) { final String binding = p.getBoundName(); for ( ActionSetFieldCol52 a : ps.getValue() ) { a.setBoundName( binding ); model.getActionCols().add( a ); } } } }
private ListBox loadPatterns() { Set<String> vars = new HashSet<String>(); ListBox patterns = new ListBox(); for ( Pattern52 p : model.getPatterns() ) { if ( !vars.contains( p.getBoundName() ) ) { patterns.addItem( ( p.isNegated() ? Constants.INSTANCE.negatedPattern() + " " : "" ) + p.getFactType() + " [" + p.getBoundName() + "]", p.getFactType() + " " + p.getBoundName() + " " + p.isNegated() ); vars.add( p.getBoundName() ); } } return patterns; }
private void doPatternLabel() { if ( editingPattern.getFactType() != null ) { StringBuilder patternLabel = new StringBuilder(); String factType = editingPattern.getFactType(); String boundName = editingPattern.getBoundName(); if ( factType != null && factType.length() > 0 ) { if ( editingPattern.isNegated() ) { patternLabel.append( Constants.INSTANCE.negatedPattern() ).append( " " ).append( factType ); } else { patternLabel.append( factType ).append( " [" ).append( boundName ).append( "]" ); } } this.patternLabel.setText( patternLabel.toString() ); } doFieldLabel(); doOperatorLabel(); }
private boolean canConditionBeDeleted( ConditionCol52 col ) { Pattern52 pattern = model.getPattern( col ); if ( pattern.getChildColumns().size() > 1 ) { return true; } if ( isBindingUsed( pattern.getBoundName() ) ) { return false; } return true; }
private boolean isBindingUnique( String binding ) { for ( Pattern52 p : model.getPatterns() ) { if ( p.getBoundName().equals( binding ) ) { return false; } for ( ConditionCol52 c : p.getChildColumns() ) { if ( c.isBound() ) { if ( c.getBinding().equals( binding ) ) { return false; } } } } return true; }
private ListBox loadBoundFacts() { Set<String> facts = new HashSet<String>(); for ( Pattern52 p : model.getPatterns() ) { if ( !p.isNegated() ) { facts.add( p.getBoundName() ); } } ListBox box = new ListBox(); for ( Iterator<String> iterator = facts.iterator(); iterator.hasNext(); ) { String b = (String) iterator.next(); box.addItem( b ); } String[] globs = this.oracle.getGlobalVariables(); for ( int i = 0; i < globs.length; i++ ) { box.addItem( globs[ i ] ); } return box; }
private boolean isEquivalentConditionColumn( ConditionCol52 c1, ConditionCol52 c2 ) { Pattern52 c1Pattern = model.getPattern( c1 ); Pattern52 c2Pattern = model.getPattern( c2 ); if ( isEqualOrNull( c1Pattern.getFactType(), c2Pattern.getFactType() ) && isEqualOrNull( c1Pattern.getBoundName(), c2Pattern.getBoundName() ) ) { return true; } return false; }
public Set<String> getBindings( String className ) { //For some reason, Fact Pattern data-types use the leaf name of the fully qualified Class Name //whereas Fields use the fully qualified Class Name. We don't use the generic fieldType (see //SuggestionCompletionEngine.TYPE) as we can't distinguish between different numeric types String simpleClassName = className; if ( simpleClassName != null && simpleClassName.lastIndexOf( "." ) > 0 ) { simpleClassName = simpleClassName.substring( simpleClassName.lastIndexOf( "." ) + 1 ); } Set<String> bindings = new HashSet<String>(); for ( Pattern52 p : this.model.getPatterns() ) { if ( className == null || p.getFactType().equals( simpleClassName ) ) { String binding = p.getBoundName(); if ( !( binding == null || "".equals( binding ) ) ) { bindings.add( binding ); } } for ( ConditionCol52 c : p.getChildColumns() ) { if ( c.isBound() ) { String fieldDataType = oracle.getFieldClassName( p.getFactType(), c.getFactField() ); if ( fieldDataType.equals( className ) ) { bindings.add( c.getBinding() ); } } } } return bindings; }
private ActionSetFieldCol52 makeNewActionColumn( final AvailableField f ) { final GuidedDecisionTable52.TableFormat format = presenter.getTableFormat(); if ( format == GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY ) { final ActionSetFieldCol52 a = new ActionSetFieldCol52(); a.setBoundName( availablePatternsSelection.getBoundName() ); a.setFactField( f.getName() ); a.setType( f.getType() ); return a; } else { final LimitedEntryActionSetFieldCol52 a = new LimitedEntryActionSetFieldCol52(); a.setBoundName( availablePatternsSelection.getBoundName() ); a.setFactField( f.getName() ); a.setType( f.getType() ); return a; } }
private void chosenTypesSelected( final Set<Pattern52> ps ) { btnRemove.setEnabled( true ); if ( ps.size() == 1 ) { chosenPatternSelection = ps.iterator().next(); patternDefinition.setVisible( true ); validateBinding(); txtBinding.setEnabled( true ); txtBinding.setText( chosenPatternSelection.getBoundName() ); txtEntryPoint.setEnabled( true ); txtEntryPoint.setText( chosenPatternSelection.getEntryPointName() ); enableMoveUpButton(); enableMoveDownButton(); if ( presenter.isPatternEvent( chosenPatternSelection ) ) { ddCEPWindow.setCEPWindow( chosenPatternSelection ); cepWindowContainer.setVisible( true ); } else { cepWindowContainer.setVisible( false ); } } else { chosenPatternSelection = null; patternDefinition.setVisible( false ); txtBinding.setEnabled( false ); txtBinding.setText( "" ); txtEntryPoint.setEnabled( false ); txtEntryPoint.setText( "" ); btnMoveUp.setEnabled( false ); btnMoveDown.setEnabled( false ); cepWindowContainer.setVisible( false ); } }
if ( !isEqualOrNull( origPattern.getBoundName(), editPattern.getBoundName() ) ) {
tsdt.getConditionPattern( "z1" ).getBoundName() ); assertEquals( "Driver", tsdt.getConditionPattern( "z1" ).getFactType() ); tsdt.getConditionPattern( "f1" ).getBoundName() ); assertEquals( "Person", tsdt.getConditionPattern( "f1" ).getFactType() ); tsdt.getConditionPattern( "f2" ).getBoundName() ); assertEquals( "Person2", tsdt.getConditionPattern( "f2" ).getFactType() );
tsdt.getConditionPattern( "f1" ).getBoundName() ); assertEquals( "Driver", tsdt.getConditionPattern( "f1" ).getFactType() ); tsdt.getConditionPattern( "f2" ).getBoundName() ); assertEquals( "Person", tsdt.getConditionPattern( "f2" ).getFactType() );
tsdt.getConditionPattern( "f1" ).getBoundName() ); assertEquals( "Driver", tsdt.getConditionPattern( "f1" ).getFactType() ); tsdt.getConditionPattern( "f2" ).getBoundName() ); assertEquals( "Driver", tsdt.getConditionPattern( "f2" ).getFactType() );