Examples of RuleModel


Examples of org.drools.workbench.models.datamodel.rule.RuleModel

                    }
                }

            } else if ( col instanceof BRLConditionColumn ) {
                //Delegate to super class's implementation
                final RuleModel rm = new RuleModel();
                final BRLConditionColumn brl = (BRLConditionColumn) col;
                rm.lhs = brl.getDefinition().toArray( new IPattern[ brl.getDefinition().size() ] );
                variables.addAll( rm.getBoundVariablesInScope( con ) );
            }
        }
        variables.addAll( super.getBoundVariablesInScope( con ) );
        return new ArrayList<String>( variables );
    }
View Full Code Here

Examples of org.drools.workbench.models.datamodel.rule.RuleModel

    }

    private boolean hasVariables( BRLActionColumn column ) {
        Map<InterpolationVariable, Integer> ivs = new HashMap<InterpolationVariable, Integer>();
        RuleModel rm = new RuleModel();
        for ( IAction action : column.getDefinition() ) {
            rm.addRhsItem( action );
        }
        RuleModelVisitor rmv = new RuleModelVisitor( ivs );
        rmv.visit( rm );
        return ivs.size() > 0;
    }
View Full Code Here

Examples of org.drools.workbench.models.datamodel.rule.RuleModel

    }

    private boolean hasVariables( BRLConditionColumn column ) {
        Map<InterpolationVariable, Integer> ivs = new HashMap<InterpolationVariable, Integer>();
        RuleModel rm = new RuleModel();
        for ( IPattern pattern : column.getDefinition() ) {
            rm.addLhsItem( pattern );
        }
        RuleModelVisitor rmv = new RuleModelVisitor( ivs );
        rmv.visit( rm );
        return ivs.size() > 0;
    }
View Full Code Here

Examples of org.drools.workbench.models.datamodel.rule.RuleModel

     */
    public RuleModel unmarshal( final String str,
                                final List<String> globals,
                                final PackageDataModelOracle dmo ) {
        if ( str == null || str.isEmpty() ) {
            return new RuleModel();
        }
        return getRuleModel( preprocessDRL( str,
                                            false ).registerGlobals( dmo,
                                                                     globals ),
                             dmo );
View Full Code Here

Examples of org.drools.workbench.models.datamodel.rule.RuleModel

    public RuleModel unmarshalUsingDSL( final String str,
                                        final List<String> globals,
                                        final PackageDataModelOracle dmo,
                                        final String... dsls ) {
        if ( str == null || str.isEmpty() ) {
            return new RuleModel();
        }
        return getRuleModel( parseDSLs( preprocessDRL( str,
                                                       true ),
                                        dsls ).registerGlobals( dmo,
                                                                globals ),
View Full Code Here

Examples of org.drools.workbench.models.datamodel.rule.RuleModel

    private RuleModel getRuleModel( ExpandedDRLInfo expandedDRLInfo,
                                    PackageDataModelOracle dmo ) {
        //De-serialize model
        RuleDescr ruleDescr = parseDrl( expandedDRLInfo );
        RuleModel model = new RuleModel();
        model.name = ruleDescr.getName();
        model.parentName = ruleDescr.getParentName();

        Map<String, AnnotationDescr> annotations = ruleDescr.getAnnotations();
        if ( annotations != null ) {
            for ( AnnotationDescr annotation : annotations.values() ) {
                model.addMetadata( new RuleMetadata( annotation.getName(), annotation.getValuesAsString() ) );
            }
        }

        //De-serialize Package name
        final String packageName = PackageNameParser.parsePackageName( expandedDRLInfo.plainDrl );
        model.setPackageName( packageName );

        //De-serialize imports
        final Imports imports = ImportsParser.parseImports( expandedDRLInfo.plainDrl );
        for ( Import item : imports.getImports() ) {
            model.getImports().addImport( item );
        }

        boolean isJavaDialect = parseAttributes( model,
                                                 ruleDescr.getAttributes() );
        Map<String, String> boundParams = parseLhs( model, ruleDescr.getLhs(), expandedDRLInfo, dmo );
View Full Code Here

Examples of org.openhab.model.rule.rules.RuleModel

   *
   * @param rule the rule to get the context for
   * @return the evaluation context
   */
  public static synchronized IEvaluationContext getContext(Rule rule) {
      RuleModel ruleModel = (RuleModel) rule.eContainer();

      // check if a context already exists on the resource
      for(Adapter adapter : ruleModel.eAdapters()) {
      if(adapter instanceof RuleContextAdapter) {
        return ((RuleContextAdapter) adapter).getContext();
      }
    }
   
    // no evaluation context found, so create a new one
      IEvaluationContext evaluationContext = contextProvider.get();
      for(XExpression expr : ruleModel.getVariables()) {
        if (expr instanceof XVariableDeclaration) {
        XVariableDeclaration var = (XVariableDeclaration) expr;
        try {
            Object initialValue = var.getRight()==null ? null : scriptEngine.newScriptFromXExpression(var.getRight()).execute();
          evaluationContext.newValue(QualifiedName.create(var.getName()), initialValue);
        } catch (ScriptExecutionException e) {
          logger.warn("Variable '{}' on rule file '{}' cannot be initialized with value '{}': {}",
              new String[] { var.getName(), ruleModel.eResource().getURI().path(), var.getRight().toString(), e.getMessage() });
        }
      }
      }
      ruleModel.eAdapters().add(new RuleContextAdapter(evaluationContext));
    return evaluationContext;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.