protected List generateMatchingFacts()

in drools-benchmarks-parent/drools-benchmarks/src/main/java/org/drools/benchmarks/turtle/runtime/generator/AdvancedOperatorsFactsGenerator.java [37:168]


    protected List<Object> generateMatchingFacts(final int totalNumber) {
        // generate needed number of facts
        final List<Object> facts = new ArrayList<>();
        final int nrOfFactsInInnerLoop = 12;
        final int innerLoops = (config.getNumberOfRulesInDRL() / config.getNumberOfRuleTypesInDRL());
        final int outerLoops = (totalNumber / (innerLoops * nrOfFactsInInnerLoop));
        for (int j = 0; j < outerLoops; j++) {
            for (int i = 0; i < innerLoops; i++) {
                currentLoop = i;
                // rule "customerHasSpecificAccount"
                Customer cust = new Customer("That" + getRandomInt(0, 100000), "Eidam");
                cust.setUuid("customerHasSpecifiedAccount");
                cust.setEmail("mail" + getRandomInt(1, 100000));

                Account acc = new Account();
                acc.setNumber(getRandomInt(getPlaceHolderValue("number1"), getPlaceHolderValue("number2")));
                acc.setUuid("customerHasSpecifiedAccount");
                acc.setOwner(cust);

                List<Account> accounts = new ArrayList<>();
                accounts.add(acc);
                for (int k = 0; k < 5; k++) {
                    final Account otherAcc = new Account();
                    otherAcc.setNumber(getRandomInt(0, 100000));
                    otherAcc.setUuid("SomeOtherUuid" + getRandomInt(0, 100000));
                    acc.setOwner(cust);
                    accounts.add(otherAcc);
                }
                cust.setAccounts(accounts);
                facts.add(acc);
                facts.add(cust);

                //////////////////////////////////////////////////
                // rule "customerDoesNotHaveSpecifiedAccount"
                cust = new Customer("Delicious" + getRandomInt(0, 100000), "Gorgonzola");
                cust.setUuid("customerDoesNotHaveSpecifiedAccount");
                cust.setEmail("mail" + getRandomInt(1, 100000));

                acc = new Account();
                acc.setNumber(getRandomInt(getPlaceHolderValue("number3"), getPlaceHolderValue("number4")));
                acc.setUuid("customerDoesNotHaveSpecifiedAccount");
                acc.setOwner(cust);

                Account acc1 = new Account();
                acc1.setNumber(getRandomInt(0, 100000));
                acc1.setOwner(cust);

                accounts = new ArrayList<>();
                accounts.add(acc1);
                for (int k = 0; k < 5; k++) {
                    final Account otherAcc = new Account();
                    otherAcc.setNumber(getRandomInt(0, 100000));
                    otherAcc.setUuid("SomeOtherUuid" + getRandomInt(0, 100000));
                    acc.setOwner(cust);
                    accounts.add(otherAcc);
                }
                cust.setAccounts(accounts);
                facts.add(acc);
                facts.add(cust);
                facts.add(acc1);

                /////////////////////////////////////////////
                // rule "memberOfCustomersAccounts"
                cust = new Customer("That" + i + getRandomInt(0, 100000));
                cust.setUuid("memberOfCustomersAccounts");

                acc = new Account();
                acc.setUuid("memberOfCustomersAccounts");
                acc.setBalance(getRandomInt(getPlaceHolderValue("balance1"), getPlaceHolderValue("balance2")));
                acc.setNumber(getRandomInt(0, 100000));
                acc.setOwner(cust);

                accounts = new ArrayList<>();
                for (int k = 0; k < 5; k++) {
                    final Account otherAcc = new Account();
                    otherAcc.setNumber(getRandomInt(0, 100000));
                    otherAcc.setUuid("SomeOtherUuid" + getRandomInt(0, 100000));
                    otherAcc.setOwner(cust);
                    accounts.add(otherAcc);
                }
                accounts.add(acc);
                cust.setAccounts(accounts);
                facts.add(acc);
                facts.add(cust);

                /////////////////////////////////////////////
                // rule "notMemberOfCustomersAccounts"
                cust = new Customer("Strange" + i + getRandomInt(0, 100000));
                cust.setUuid("notMemberOfCustomersAccounts");

                acc = new Account();
                acc.setUuid("notMemberOfCustomersAccounts");
                acc.setBalance(getRandomInt(getPlaceHolderValue("balance3"), getPlaceHolderValue("balance4")));
                acc.setNumber(getRandomInt(0, 100000));
                acc.setOwner(cust);

                acc1 = new Account();
                acc1.setNumber(getRandomInt(0, 1000000));

                accounts = new ArrayList<>();
                for (int k = 0; k < 5; k++) {
                    final Account otherAcc = new Account();
                    otherAcc.setNumber(getRandomInt(0, 100000));
                    otherAcc.setUuid("SomeOtherUuid" + getRandomInt(0, 100000));
                    otherAcc.setOwner(cust);
                    accounts.add(otherAcc);
                }
                accounts.add(acc1);
                cust.setAccounts(accounts);
                facts.add(acc);
                facts.add(acc1);
                facts.add(cust);

                /////////////////////////////////////////////
                // rule "matchesCityWithPrefixBr"
                final Address addr = new Address();
                addr.setUuid("matchesCityWithPrefixBr" + getPlaceHolderValue("number1"));
                addr.setPostalCode(String.valueOf(getRandomInt(0, 1000000)));
                addr.setCity("Br" + getPlaceHolderValue("number1") + getRandomInt(0, 1000000));
                facts.add(addr);

                /////////////////////////////////////////////
                // rule "notMatchesTransactionDescription"
                final Transaction tr = new Transaction();
                tr.setDescription("BadDescriptionNotMatch" + getPlaceHolderValue("number2") + "someOtherStaff");
                tr.setUuid("notMatchesTransactionDescription" + getPlaceHolderValue("number2"));
                facts.add(tr);
                // total of 32 facts inserted in each inner loop
            }
        }
        return facts;
    }