/** * This will return the list of field constraints that are in the root * CompositeFieldConstraint object. If there is no root, then an empty array * will be returned. * @return an empty array, or the list of constraints (which may be * composites). */ public FieldConstraint[] getFieldConstraints() { if ( this.constraintList == null ) { return new FieldConstraint[ 0 ]; } return this.constraintList.getConstraints(); }
private void visitCompositeFieldConstraint( CompositeFieldConstraint cfc ) { if ( cfc.getConstraints() != null ) { for ( FieldConstraint fc : cfc.getConstraints() ) { visit( fc ); } } }
private CompositeFieldConstraint visitCompositeFieldConstraint( CompositeFieldConstraint cfc ) { CompositeFieldConstraint clone = new CompositeFieldConstraint(); clone.setCompositeJunctionType( cfc.getCompositeJunctionType() ); if ( cfc.getConstraints() != null ) { clone.setConstraints( new FieldConstraint[ cfc.getConstraints().length ] ); for ( int i = 0; i < cfc.getConstraints().length; i++ ) { FieldConstraint fc = cfc.getConstraints()[ i ]; clone.getConstraints()[ i ] = (FieldConstraint) visit( fc ); } } return clone; }
public void setFieldConstraints( final List<FieldConstraint> sortedConstraints ) { if ( sortedConstraints != null ) { if ( this.constraintList != null ) { this.constraintList.setConstraints( new FieldConstraint[ sortedConstraints.size() ] ); for ( int i = 0; i < sortedConstraints.size(); i++ ) { this.constraintList.getConstraints()[ i ] = (FieldConstraint) sortedConstraints.get( i ); } } else if ( sortedConstraints.size() > 0 ) { throw new IllegalStateException( "Cannot have constraints if constraint list is null." ); } } else { this.constraintList.setConstraints( null ); } }
private void generateConstraints( final FactPattern pattern ) { int printedCount = 0; for ( int i = 0; i < pattern.getFieldConstraints().length; i++ ) { StringBuilder buffer = new StringBuilder(); generateConstraint( pattern.getConstraintList().getConstraints()[ i ], false, buffer ); if ( buffer.length() > 0 ) { if ( printedCount > 0 ) { buf.append( ", " ); } buf.append( buffer ); printedCount++; } } }
private DropDownData getDropDownData() { //Set applicable flags and reference data depending upon type if ( DataType.TYPE_BOOLEAN.equals( this.fieldType ) ) { this.isDropDownDataEnum = false; this.dropDownData = DropDownData.create( new String[]{ "true", "false" } ); } else { this.isDropDownDataEnum = true; final Map<String, String> currentValueMap = new HashMap<String, String>(); if ( constraintList != null && constraintList.getConstraints() != null ) { for ( FieldConstraint con : constraintList.getConstraints() ) { if ( con instanceof SingleFieldConstraint ) { SingleFieldConstraint sfc = (SingleFieldConstraint) con; String fieldName = sfc.getFieldName(); currentValueMap.put( fieldName, sfc.getValue() ); } } } this.dropDownData = sce.getEnums( this.factType, fieldName, currentValueMap ); } return dropDownData; }
buf.append( "( " ); FieldConstraint[] nestedConstraints = cfc.getConstraints(); if ( nestedConstraints != null ) { for ( int i = 0; i < nestedConstraints.length; i++ ) {
protected String getFieldBinding( FieldConstraint fc, String var ) { String fieldType = null; if ( fc instanceof SingleFieldConstraint ) { SingleFieldConstraint s = (SingleFieldConstraint) fc; if ( s.isBound() && var.equals( s.getFieldBinding() ) ) { fieldType = s.getFieldType(); } } if ( fc instanceof SingleFieldConstraintEBLeftSide ) { SingleFieldConstraintEBLeftSide s = (SingleFieldConstraintEBLeftSide) fc; if ( s.isBound() && var.equals( s.getFieldBinding() ) ) { fieldType = s.getExpressionLeftSide().getGenericType(); } } if ( fc instanceof CompositeFieldConstraint ) { CompositeFieldConstraint s = (CompositeFieldConstraint) fc; if ( s.getConstraints() != null ) { for ( FieldConstraint ss : s.getConstraints() ) { fieldType = getFieldBinding( ss, var ); } } } return fieldType; }
protected List<String> getFieldBinding( FieldConstraint f ) { List<String> result = new ArrayList<String>(); if ( f instanceof SingleFieldConstraint ) { SingleFieldConstraint con = (SingleFieldConstraint) f; if ( con.isBound() ) { result.add( con.getFieldBinding() ); } if ( con.getExpressionValue() != null && con.getExpressionValue().isBound() ) { result.add( con.getExpressionValue().getBinding() ); } if ( con instanceof SingleFieldConstraintEBLeftSide ) { SingleFieldConstraintEBLeftSide exp = (SingleFieldConstraintEBLeftSide) con; if ( exp.getExpressionLeftSide() != null && exp.getExpressionLeftSide().isBound() ) { result.add( exp.getExpressionLeftSide().getBinding() ); } } } else if ( f instanceof CompositeFieldConstraint ) { CompositeFieldConstraint cfc = (CompositeFieldConstraint) f; if ( cfc.getConstraints() != null ) { for ( FieldConstraint ss : cfc.getConstraints() ) { List<String> t = getFieldBinding( ss ); result.addAll( t ); } } } return result; }
final FieldConstraint[] cons = fact.getConstraintList().getConstraints(); if ( cons != null ) { for ( int k = 0; k < cons.length; k++ ) {
2 ); FieldConstraint[] nested = constraint.getConstraints(); DirtyableFlexTable inner = new DirtyableFlexTable(); if ( nested != null ) {
person.getConstraintList().getConstraints().length ); SingleFieldConstraint cons = (SingleFieldConstraint) person.getConstraint( 0 ); assertEquals( BaseSingleFieldConstraint.TYPE_LITERAL, cheese.getConstraintList().getConstraints().length ); cons = (SingleFieldConstraint) cheese.getConstraint( 0 ); assertEquals( "type",
person.getConstraintList().getConstraints().length ); SingleFieldConstraint cons = (SingleFieldConstraint) person.getConstraint( 0 ); assertEquals( BaseSingleFieldConstraint.TYPE_LITERAL, cheese.getConstraintList().getConstraints().length ); cons = (SingleFieldConstraint) cheese.getConstraint( 0 ); assertEquals( "type",
person.getConstraintList().getConstraints().length );
result0Fp1.getConstraintList().getConstraints().length ); result0Fp2.getConstraintList().getConstraints().length ); result1Fp1.getConstraintList().getConstraints().length ); result2Fp1.getConstraintList().getConstraints().length );