public String getFactType() { if ( this.factPattern == null ) { return null; } return this.factPattern.getFactType(); }
public ExpressionUnboundFact( FactPattern fact ) { super( fact.getFactType(), fact.getFactType(), fact.getFactType() ); this.fact = fact; }
public ExpressionVariable( FactPattern fact ) { super( fact.getBoundName(), fact.getFactType(), fact.getFactType() ); if ( !fact.isBound() ) { throw new RuntimeException( "the fact is not bounded: " + fact ); } this.fact = fact; }
private String getFactType( String boundName ) { return rm.getLHSBoundFact( boundName ).getFactType(); }
private String getFactType( FactPattern fp, SingleFieldConstraint sfc ) { String factType; if ( sfc == null ) { factType = fp.getFactType(); } else { factType = sfc.getFieldType(); //If field name is "this" use parent FactPattern type otherwise we can use the Constraint's field type String fieldName = sfc.getFieldName(); if ( DataType.TYPE_THIS.equals( fieldName ) ) { factType = fp.getFactType(); } } return factType; }
@Override protected void calculateReadOnly() { if ( this.pattern.getFactPattern() != null ) { this.readOnly = !( this.getExtraLeftSidePatternFactTypes().containsValue( this.pattern.getFactPattern().getFactType() ) || this.getModeller().getSuggestionCompletions().isFactTypeRecognized( this.pattern.getFactPattern().getFactType() ) ); } }
private boolean isLHSFactTypeEquivalent( String boundVariable ) { String boundFactType = model.getLHSBoundFact( boundVariable ).getFactType(); String boundFieldType = model.getLHSBindingType( boundVariable ); //If the types are SuggestionCompletionEngine.TYPE_COMPARABLE check the enums are equivalent if ( boundFactType.equals( DataType.TYPE_COMPARABLE ) ) { if ( !this.fieldType.equals( DataType.TYPE_COMPARABLE ) ) { return false; } String[] dd = this.sce.getEnumValues( boundFactType, this.fieldName ); return isEnumEquivalent( dd ); } return isBoundVariableApplicable( boundFactType, boundFieldType ); }
private void generateFactPattern( final FactPattern pattern ) { if ( pattern.isNegated() ) { buf.append( "not " ); } else if ( pattern.isBound() ) { bindingsPatterns.put( pattern.getBoundName(), pattern ); buf.append( pattern.getBoundName() ); buf.append( " : " ); } if ( pattern.getFactType() != null ) { buf.append( pattern.getFactType() ); } buf.append( "( " ); // top level constraints if ( pattern.getConstraintList() != null ) { generateConstraints( pattern ); } buf.append( ")" ); //Add CEP window definition CEPWindow window = pattern.getWindow(); if ( window.isDefined() ) { buf.append( " " ); buf.append( window.getOperator() ); buf.append( buildOperatorParameterDRL( window.getParameters() ) ); } }
private boolean isLHSFactTypeEquivalent( String boundVariable ) { String boundFactType = modeller.getModel().getLHSBoundFact( boundVariable ).getFactType(); //If the types are SuggestionCompletionEngine.TYPE_COMPARABLE check the enums are equivalent if ( boundFactType.equals( DataType.TYPE_COMPARABLE ) ) { if ( !this.variableType.equals( DataType.TYPE_COMPARABLE ) ) { return false; } String[] dd = this.modeller.getSuggestionCompletions().getEnumValues( boundFactType, this.value.getField() ); return isEnumEquivalent( dd ); } //If the types are identical (and not SuggestionCompletionEngine.TYPE_COMPARABLE) then return true if ( boundFactType.equals( this.variableType ) ) { return true; } return false; }
protected void calculateReadOnly() { if ( this.pattern.getFactPattern() != null ) { this.isFactTypeKnown = this.getModeller().getSuggestionCompletions().isFactTypeRecognized( this.pattern.getFactPattern().getFactType() ); this.readOnly = !this.isFactTypeKnown; } }
private boolean isLHSFieldTypeEquivalent( String boundVariable ) { String boundFieldType = this.model.getLHSBindingType( boundVariable ); //If the fieldTypes are SuggestionCompletionEngine.TYPE_COMPARABLE check the enums are equivalent if ( boundFieldType.equals( DataType.TYPE_COMPARABLE ) ) { if ( !this.fieldType.equals( DataType.TYPE_COMPARABLE ) ) { return false; } FieldConstraint fc = this.model.getLHSBoundField( boundVariable ); if ( fc instanceof SingleFieldConstraint ) { String fieldName = ( (SingleFieldConstraint) fc ).getFieldName(); String parentFactTypeForBinding = this.model.getLHSParentFactPatternForBinding( boundVariable ).getFactType(); String[] dd = this.sce.getEnumValues( parentFactTypeForBinding, fieldName ); return isEnumEquivalent( dd ); } return false; } return isBoundVariableApplicable( boundFieldType ); }
/** * Get the data-type associated with the binding * @param var * @return The data-type, or null if the binding could not be found */ public String getLHSBindingType( final String var ) { if ( this.lhs == null ) { return null; } for ( int i = 0; i < this.lhs.length; i++ ) { IPattern pat = this.lhs[ i ]; if ( pat instanceof FromCompositeFactPattern ) { pat = ( (FromCompositeFactPattern) pat ).getFactPattern(); } if ( pat instanceof FactPattern ) { final FactPattern p = (FactPattern) pat; if ( p.isBound() && var.equals( p.getBoundName() ) ) { return p.getFactType(); } for ( FieldConstraint fc : p.getFieldConstraints() ) { String type = getFieldBinding( fc, var ); if ( type != null ) { return type; } } } } return null; }
/** * This returns the pattern label. */ private Widget getPatternLabel( final FactPattern fp ) { ClickHandler click = new ClickHandler() { public void onClick( ClickEvent event ) { popupCreator.showPatternPopup( (Widget) event.getSource(), fp, null, false ); } }; String patternName = ( pattern.isBound() ) ? pattern.getFactType() + " <b>[" + pattern.getBoundName() + "]</b>" : pattern.getFactType(); String desc; if ( isAll0WithLabel ) { desc = Constants.INSTANCE.All0with( patternName ); } else { if ( pattern.getNumberOfConstraints() > 0 ) { desc = Constants.INSTANCE.ThereIsAAn0With( patternName ); } else { desc = Constants.INSTANCE.ThereIsAAn0( patternName ); } desc = anA( desc, patternName ); } return new ClickableLabel( desc, click, !this.readOnly ); }
private boolean isLHSFieldTypeEquivalent( String boundVariable ) { String boundFieldType = modeller.getModel().getLHSBindingType( boundVariable ); //If the fieldTypes are SuggestionCompletionEngine.TYPE_COMPARABLE check the enums are equivalent if ( boundFieldType.equals( DataType.TYPE_COMPARABLE ) ) { if ( !this.variableType.equals( DataType.TYPE_COMPARABLE ) ) { return false; } FieldConstraint fc = this.modeller.getModel().getLHSBoundField( boundVariable ); if ( fc instanceof SingleFieldConstraint ) { String fieldName = ( (SingleFieldConstraint) fc ).getFieldName(); String parentFactTypeForBinding = this.modeller.getModel().getLHSParentFactPatternForBinding( boundVariable ).getFactType(); String[] dd = this.modeller.getSuggestionCompletions().getEnumValues( parentFactTypeForBinding, fieldName ); return isEnumEquivalent( dd ); } return false; } //If the fieldTypes are identical (and not SuggestionCompletionEngine.TYPE_COMPARABLE) then return true if ( boundFieldType.equals( this.variableType ) ) { return true; } return false; }
public void onClick( ClickEvent event ) { String[] fields = new String[ 0 ]; //If field name is "this" use parent FactPattern type otherwise we can use the Constraint's field type String fieldName = con.getFieldName(); if ( DataType.TYPE_THIS.equals( fieldName ) ) { fields = connectives.getCompletions().getFieldCompletions( pattern.getFactType() ); } else { fields = connectives.getCompletions().getFieldCompletions( con.getFieldType() ); } popupCreator.showBindFieldPopup( (Widget) event.getSource(), pattern, con, fields, popupCreator ); } };
public void onChange( ChangeEvent event ) { String factType = pattern.getFactType(); String fieldName = box.getItemText( box.getSelectedIndex() ); String fieldType = getCompletions().getFieldType( factType, fieldName ); hasConstraints.addConstraint( new SingleFieldConstraint( factType, fieldName, fieldType, null ) ); modeller.refreshWidget(); popup.hide(); } } );
private Widget createCEPWindowWidget( final RuleModeller modeller, final HasCEPWindow c ) { if ( modeller.getSuggestionCompletions().isFactTypeAnEvent( pattern.getFactType() ) ) { HorizontalPanel hp = new HorizontalPanel(); Label lbl = new Label( HumanReadableConstants.INSTANCE.OverCEPWindow() ); lbl.setStyleName( "paddedLabel" ); hp.add( lbl ); CEPWindowOperatorsDropdown cwo = new CEPWindowOperatorsDropdown( c, readOnly ); if ( !this.isReadOnly() ) { cwo.addValueChangeHandler( new ValueChangeHandler<OperatorSelection>() { public void onValueChange( ValueChangeEvent<OperatorSelection> event ) { setModified( true ); OperatorSelection selection = event.getValue(); String selected = selection.getValue(); c.getWindow().setOperator( selected ); getModeller().makeDirty(); } } ); } hp.add( cwo ); return hp; } return new HTML(); }
private FactPattern visitFactPattern( FactPattern pattern ) { FactPattern clone = new FactPattern(); clone.setBoundName( pattern.getBoundName() ); clone.setFactType( pattern.getFactType() ); clone.setNegated( pattern.isNegated() ); CEPWindow cloneCEPWindow = new CEPWindow(); cloneCEPWindow.setOperator( pattern.getWindow().getOperator() ); cloneCEPWindow.setParameters( cloneCEPWindowParameters( pattern.getWindow() ) ); clone.setWindow( cloneCEPWindow ); for ( FieldConstraint fc : pattern.getFieldConstraints() ) { clone.addConstraint( (FieldConstraint) visit( fc ) ); } return clone; }
fp1.getBoundName() ); assertEquals( "Applicant", fp1.getFactType() ); fp2.getBoundName() ); assertEquals( "Bananna", fp2.getFactType() );
p.getBoundName() ); assertEquals( "Applicant", p.getFactType() );