Examples of RulesEngine


Examples of com.izforge.izpack.rules.RulesEngine

    {
        /**
         * Look if there are new variables defined
         */
        Vector<XMLElement> variables = spec.getChildrenNamed(VARIABLE_NODE);
        RulesEngine rules = parent.getRules();

        VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
        for (int i = 0; i < variables.size(); i++)
        {
            XMLElement variable = variables.elementAt(i);
            String vname = variable.getAttribute(ATTRIBUTE_VARIABLE_NAME);
            String vvalue = variable.getAttribute(ATTRIBUTE_VARIABLE_VALUE);

            if (vvalue == null)
            {
                // try to read value element
                if (variable.hasChildren())
                {
                    XMLElement value = variable.getFirstChildNamed("value");
                    vvalue = value.getContent();
                }
            }

            String conditionid = variable.getAttribute(ATTRIBUTE_CONDITIONID_NAME);
            if (conditionid != null)
            {
                // check if condition for this variable is fulfilled
                if (!rules.isConditionTrue(conditionid, idata.getVariables()))
                {
                    continue;
                }
            }
            // are there any OS-Constraints?
View Full Code Here

Examples of com.izforge.izpack.rules.RulesEngine

            InputStream in = InstallerFrame.class.getResourceAsStream("/rules");
            ObjectInputStream objIn = new ObjectInputStream(in);
            Map rules = (Map) objIn.readObject();
            if ((rules != null) && (rules.size() != 0))
            {
                this.rules = new RulesEngine(rules, installdata);
            }
            objIn.close();
        }
        catch (Exception e)
        {
            Debug.trace("Can not find optional rules");
        }
        if (rules != null)
        {
            // rules already read
            return;
        }
        try
        {
            InputStream input = null;
            input = this.getResource(CONDITIONS_SPECRESOURCENAME);
            if (input == null)
            {
                this.rules = new RulesEngine((XMLElement) null, installdata);
                return;
            }

            StdXMLParser parser = new StdXMLParser();
            parser.setBuilder(XMLBuilderFactory.createXMLBuilder());
            parser.setValidator(new NonValidator());
            parser.setReader(new StdXMLReader(input));

            // get the data
            XMLElement conditionsxml = (XMLElement) parser.parse();
            this.rules = new RulesEngine(conditionsxml, installdata);
        }
        catch (Exception e)
        {
            Debug.trace("Can not find optional resource " + CONDITIONS_SPECRESOURCENAME);
            // there seem to be no conditions
            this.rules = new RulesEngine((XMLElement) null, installdata);
        }
    }
View Full Code Here

Examples of org.roolie.RulesEngine

    // Get the config file as an InputStream
    InputStream is = Main.class.getClassLoader().getResourceAsStream(
      "rooliebanking/roolie-config.xml");

    // Create RulesEngine instance
    RulesEngine rules = new RulesEngine(is);

    // Create some rule arguments (aka "Facts") to test for some users
    List<BankingRuleArgs> bankingRuleArgsList = createRuleArgsToTest();

    // See if rules pass for each BankingRuleArgs created.
    for (BankingRuleArgs ruleArgs : bankingRuleArgsList)
    {
      msg("\n* Evaluating 'userCanWithdrawFunds' rule for " + ruleArgs.getUser());
      boolean canWithdrawFunds =
        rules.passesRule("userCanWithdrawFunds", ruleArgs);

      msg("User can withdraw funds? " + canWithdrawFunds);
      if (canWithdrawFunds)
      {
        withdrawFunds(ruleArgs);
      }
      else
      {
        msg(ruleArgs.getUser() + " cannot withdraw $"
          + ruleArgs.getRequestedWithdrawlAmount());
      }

      msg("\n* Evaluating 'userCanDepositFunds' rule for " + ruleArgs.getUser());
      boolean canDepositFunds =
        rules.passesRule("userCanDepositFunds", ruleArgs);

      msg("User can deposit funds? " + canDepositFunds);
      if (canDepositFunds)
      {
        depositFunds(ruleArgs);
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.