Git Product home page Git Product logo

Comments (2)

mchevvuri avatar mchevvuri commented on June 12, 2024

I'm facing the exact same issue, it doesn't matter whether I'm setting this in rulebookbuiler or rulebuilder. GolenRule class has a logic where it checks if action type is "STOP_ONFAILURE" and then constructs it. I guess it shouldn't have that "IF" conditon and it should just proceed with creating construction using action type.

from rulebook.

kzander91 avatar kzander91 commented on June 12, 2024

Just encountered the same issue. Looks like ERROR_ON_FAILURE currently only works when defining Rules with annotated POJOs using @Rule(ruleChainAction = RuleChainActionType.ERROR_ON_FAILURE).
Quite a deal-breaker for me. I'm currently working around this by post-processing all my rules and setting the private _actionType field using reflection.

I'm using Spring and all my rules are beans, so I can do it like this:

@Bean
static BeanPostProcessor errorOnFailureGoldenRulePostProcessor() {
    Field actionTypeField = FieldUtils.getField(GoldenRule.class, "_actionType");
    ReflectionUtils.makeAccessible(actionTypeField);
    return new BeanPostProcessor() {

        @Override
        public Object postProcessAfterInitialization(Object bean, String beanName) {
            if (bean instanceof GoldenRule<?, ?> goldenRule) {
                ReflectionUtils.setField(actionTypeField, goldenRule, RuleChainActionType.ERROR_ON_FAILURE);
            }
            return bean;
        }
    };
}

This will of course only work if you need all rules to use this action type.

from rulebook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.