Package org.drools.ide.common.client.modeldriven.brl

Examples of org.drools.ide.common.client.modeldriven.brl.RuleAttribute


    @Test
    public void testRuleAttributes() {

        RuleModel model = new RuleModel();
        model.attributes = new RuleAttribute[2];
        model.attributes[0] = new RuleAttribute( "attr0",
                                                 "attr0Value" );
        model.attributes[1] = new RuleAttribute( "attr1",
                                                 "attr1Value" );

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );
View Full Code Here


            HorizontalPanel hp = new HorizontalPanel();
            hp.add( new SmallLabel( constants.Attributes1() ) );
            layout.addRow( hp );
        }
        for ( int i = 0; i < attrs.length; i++ ) {
            RuleAttribute at = attrs[i];
            layout.addAttribute( at.attributeName,
                                 getEditorWidget( at,
                                                  i ) );
        }
View Full Code Here

                String attr = list.getItemText( list.getSelectedIndex() );
                if ( attr.equals( RuleAttributeWidget.LOCK_LHS ) || attr.equals( RuleAttributeWidget.LOCK_RHS ) ) {
                    model.addMetadata( new RuleMetadata( attr,
                                                         "true" ) );
                } else {
                    model.addAttribute( new RuleAttribute( attr,
                                                           "" ) );
                }
                refresh.execute();
                hide();
            }
View Full Code Here

     */
    private void marshalAttributes(StringBuilder buf,
                                   RuleModel model) {
        boolean hasDialect = false;
        for ( int i = 0; i < model.attributes.length; i++ ) {
            RuleAttribute attr = model.attributes[i];

            buf.append( "\t" );
            buf.append( attr );

            buf.append( "\n" );
            if ( attr.attributeName.equals( "dialect" ) ) {
                hasDialect = true;
            }
        }
        // Un comment below for mvel
        if ( !hasDialect ) {
            RuleAttribute attr = new RuleAttribute( "dialect",
                                                    "mvel" );
            buf.append( "\t" );
            buf.append( attr );
            buf.append( "\n" );
        }
View Full Code Here

                //If instance of "otherwise" column then flag RuleModel as being negated
                if ( at.getAttribute().equals( GuidedDecisionTable52.NEGATE_RULE_ATTR ) ) {
                    rm.setNegated( Boolean.valueOf( cell ) );
                } else {
                    attribs.add( new RuleAttribute( at.getAttribute(),
                                                    cell ) );
                }
            } else if ( at.getDefaultValue() != null ) {
                attribs.add( new RuleAttribute( at.getAttribute(),
                                                at.getDefaultValue() ) );
            }
        }
        if ( attribs.size() > 0 ) {
            rm.attributes = attribs.toArray( new RuleAttribute[attribs.size()] );
View Full Code Here

        }
        throw new IllegalArgumentException( "Class " + o.getClass().getName() + " is not recognised" );
    }

    private RuleAttribute visitRuleAttribute(RuleAttribute attr) {
        RuleAttribute clone = new RuleAttribute();
        clone.attributeName = attr.attributeName;
        clone.value = attr.value;
        return clone;
    }
View Full Code Here

        clone.setNegated( model.isNegated() );

        if ( model.attributes != null ) {
            clone.attributes = new RuleAttribute[model.attributes.length];
            for ( int i = 0; i < model.attributes.length; i++ ) {
                RuleAttribute attr = model.attributes[i];
                clone.attributes[i] = (RuleAttribute) visit( attr );
            }
        }
        if ( model.metadataList != null ) {
            clone.metadataList = new RuleMetadata[model.metadataList.length];
View Full Code Here

                           new Listener() {
                               public void handleEvent(Event event) {
                                   if ( combo.getSelectionIndex() == 0 ) {
                                       return;
                                   }
                                   modeller.getModel().addAttribute( new RuleAttribute( combo.getText(),
                                                                                        "" ) );
                                   modeller.setDirty( true );
                                   modeller.reloadOptions();
                                   close();
                               }
View Full Code Here

        String expected = "rule \"my rule\"\n\tno-loop true\n\tdialect \"mvel\"\n\twhen\n\t\tPerson( )\n"
                          + "\t\tAccident( )\n\tthen\n\t\tinsert( new Report() );\nend\n";
        final RuleModel m = new RuleModel();
        m.addLhsItem( new FactPattern( "Person" ) );
        m.addLhsItem( new FactPattern( "Accident" ) );
        m.addAttribute( new RuleAttribute( "no-loop",
                                           "true" ) );

        m.addRhsItem( new ActionInsertFact( "Report" ) );
        m.name = "my rule";
View Full Code Here

        String expected = "rule \"my rule\"\n\tno-loop true\n\tdialect \"mvel\"\n\twhen\n\t\tPerson( )\n"
                          + "\t\tAccident( )\n\tthen\n\t\tinsertLogical( new Report() );\nend\n";
        final RuleModel m = new RuleModel();
        m.addLhsItem( new FactPattern( "Person" ) );
        m.addLhsItem( new FactPattern( "Accident" ) );
        m.addAttribute( new RuleAttribute( "no-loop",
                                           "true" ) );

        m.addRhsItem( new ActionInsertLogicalFact( "Report" ) );

        m.name = "my rule";
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.modeldriven.brl.RuleAttribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.