Support
Quality
Security
License
Reuse
kandi has reviewed drools and discovered the below as its top functions. This is intended to give you an instant insight into drools implemented functionality, and help decide if they suit your requirements.
Drools is a rule engine, DMN engine and complex event processing (CEP) engine for Java.
How to deal with publishing promotion issues Hybris 2105?
import de.hybris.platform.commerceservices.search.pagedata.PageableData
import de.hybris.platform.servicelayer.search.FlexibleSearchQuery
import com.google.common.collect.ImmutableMap;
import de.hybris.platform.servicelayer.interceptor.impl.InterceptorExecutionPolicy;
import de.hybris.platform.servicelayer.session.SessionExecutionBody;
import de.hybris.platform.servicelayer.session.SessionService;
import com.google.common.collect.ImmutableSet;
int start = 0
int pageSize = 1000
int total = pageSize
final FlexibleSearchQuery searchQuery = new FlexibleSearchQuery("select {PK} from {DroolsRule} ORDER BY {PK}")
searchQuery.setCount(pageSize)
searchQuery.setNeedTotal(true)
while (start < total) {
searchQuery.setStart(start)
def searchResult = flexibleSearchService.search(searchQuery)
searchResult.getResult().each {
final Map<String, Object> params = ImmutableMap.of(InterceptorExecutionPolicy.DISABLED_INTERCEPTOR_TYPES,
ImmutableSet.of(InterceptorExecutionPolicy.InterceptorType.PREPARE,InterceptorExecutionPolicy.InterceptorType.VALIDATE));
sessionService.executeInLocalViewWithParams(params, new SessionExecutionBody() {
@Override
public void executeWithoutResult() {
it.setRuleContent("");
modelService.save(it);
}
});
}
total = searchResult.getTotalCount()
start += pageSize
}
println "Script has been completed."
What does a drools fact check (when) return when one uses the "in" operator
class Vgdoc {
public String getCode() { ... }
public String getColour() { ... }
}
rule "One"
when
vg1: Vgdoc( code in ("IA1003", "IA1004"),
colour == "red" )
then
Systen.out.println("Rule 1 fired");
end
Vgdoc{ code: "IA1003", colour: "red" } // A
Vgdoc{ code: "IA1004", colour: "red" } // B
Vgdoc{ code: "IA1005", colour: "red" } // C
Vgdoc{ code: "IA1003", colour: "blue" } // D
rule "IA1003 and IA1004 with red"
when
vgList: List() from collect( Vgdoc( code in ("IA1003", "IA1004"), colour == "red" ))
then
System.out.println("Rule fired, match count: " + vgList.size());
// vgList will contain all items that match the conditions for code and colour
end
-----------------------
class Vgdoc {
public String getCode() { ... }
public String getColour() { ... }
}
rule "One"
when
vg1: Vgdoc( code in ("IA1003", "IA1004"),
colour == "red" )
then
Systen.out.println("Rule 1 fired");
end
Vgdoc{ code: "IA1003", colour: "red" } // A
Vgdoc{ code: "IA1004", colour: "red" } // B
Vgdoc{ code: "IA1005", colour: "red" } // C
Vgdoc{ code: "IA1003", colour: "blue" } // D
rule "IA1003 and IA1004 with red"
when
vgList: List() from collect( Vgdoc( code in ("IA1003", "IA1004"), colour == "red" ))
then
System.out.println("Rule fired, match count: " + vgList.size());
// vgList will contain all items that match the conditions for code and colour
end
-----------------------
class Vgdoc {
public String getCode() { ... }
public String getColour() { ... }
}
rule "One"
when
vg1: Vgdoc( code in ("IA1003", "IA1004"),
colour == "red" )
then
Systen.out.println("Rule 1 fired");
end
Vgdoc{ code: "IA1003", colour: "red" } // A
Vgdoc{ code: "IA1004", colour: "red" } // B
Vgdoc{ code: "IA1005", colour: "red" } // C
Vgdoc{ code: "IA1003", colour: "blue" } // D
rule "IA1003 and IA1004 with red"
when
vgList: List() from collect( Vgdoc( code in ("IA1003", "IA1004"), colour == "red" ))
then
System.out.println("Rule fired, match count: " + vgList.size());
// vgList will contain all items that match the conditions for code and colour
end
-----------------------
class Vgdoc {
public String getCode() { ... }
public String getColour() { ... }
}
rule "One"
when
vg1: Vgdoc( code in ("IA1003", "IA1004"),
colour == "red" )
then
Systen.out.println("Rule 1 fired");
end
Vgdoc{ code: "IA1003", colour: "red" } // A
Vgdoc{ code: "IA1004", colour: "red" } // B
Vgdoc{ code: "IA1005", colour: "red" } // C
Vgdoc{ code: "IA1003", colour: "blue" } // D
rule "IA1003 and IA1004 with red"
when
vgList: List() from collect( Vgdoc( code in ("IA1003", "IA1004"), colour == "red" ))
then
System.out.println("Rule fired, match count: " + vgList.size());
// vgList will contain all items that match the conditions for code and colour
end
Drools Stream mode negative patterns
declare MetaMessage
@role(event)
end
rule 'rule1'
when
$inMess : MetaMessage()
not(MetaMessage(this != $inMess, this after [0s,10s] $inMess) )
then
//do things
end
kieSession.insert(metaMessage);
kieSession.fireAllRules();
-----------------------
declare MetaMessage
@role(event)
end
rule 'rule1'
when
$inMess : MetaMessage()
not(MetaMessage(this != $inMess, this after [0s,10s] $inMess) )
then
//do things
end
kieSession.insert(metaMessage);
kieSession.fireAllRules();
Generic classes within Drools-WorkBench
@DroolsSession(resources = "draft/inputObjectExample.xlsx",
builderProperties = "drools.dump.dir = target/dump",
showStateTransitionPopup = true)
public class PlaygroundTest extends DroolsAssert {
@RegisterExtension
public DroolsAssert droolsAssert = this;
@Test
@TestRules(expectedCount = { "1", "Check_DyrAlder" })
public void testInputObjectExample() {
KieCommands commandFactory = KieServices.get().getCommands();
List<Command<?>> commands = new ArrayList<>();
for (int i = 0; i < 10; i++) {
InputObject inputObject = new InputObject();
inputObject.setTransactionId(i);
inputObject.setRuleSet("set" + i);
inputObject.setInput(ImmutableMap.of("DyrAlder", i));
inputObject.setValidationResults(new ArrayList<>());
commands.add(commandFactory.newInsert(inputObject, "ValRes"));
commands.add(commandFactory.newFireAllRules());
}
commands.forEach(c -> getSession().execute(c));
}
}
package draft;
//generated from Decision Table
import draft.InputObject;
import draft.ValidationResult;
// rule values at A9, header at A4
rule "Check_DyrAlder"
when
animal:InputObject(ruleSet == "set3", input["DyrAlder"] < 5)
then
animal.addValidationResult(new ValidationResult("HDY-08277", "message"));
end
public class InputObject {
private Integer primaryKey;
private Integer sessionId;
private Integer transactionId;
private String ruleSet;
private Map<String, Object> input;
private List<ValidationResult> validationResults;
// getters/setters
@DroolsSession(resources = "draft/droolsObjectExample.xlsx",
builderProperties = "drools.dump.dir = target/dump",
showStateTransitionPopup = true)
public class PlaygroundTest extends DroolsAssert {
@RegisterExtension
public DroolsAssert droolsAssert = this;
@Test
@TestRules(expectedCount = { "1", "Check_DyrAlder" })
public void testDroolsObjectExample() {
KieCommands commandFactory = KieServices.get().getCommands();
List<Command<?>> commands = new ArrayList<>();
for (int i = 0; i < 10; i++) {
DroolsObject inputObject = new DroolsObject();
inputObject.put("ruleSet", "set" + i);
inputObject.put("DyrAlder", i);
commands.add(commandFactory.newInsert(inputObject, "ValRes"));
commands.add(commandFactory.newFireAllRules());
}
commands.forEach(c -> getSession().execute(c));
}
}
package draft;
//generated from Decision Table
import draft.DroolsObject;
import draft.ValidationResult;
// rule values at A9, header at A4
rule "Check_DyrAlder"
when
animal:DroolsObject(ruleSet == "set3", DyrAlder < 5)
then
animal.addValidationResult(new ValidationResult("HDY-08277", "message"));
end
public class DroolsObject extends LinkedHashMap<String, Object> {
public void addValidationResult(ValidationResult validationResult) {
if (!this.containsKey("validationResult"))
this.put("validationResult", new LinkedList<ValidationResult>());
((List<ValidationResult>) this.get("validationResult")).add(validationResult);
}
}
-----------------------
@DroolsSession(resources = "draft/inputObjectExample.xlsx",
builderProperties = "drools.dump.dir = target/dump",
showStateTransitionPopup = true)
public class PlaygroundTest extends DroolsAssert {
@RegisterExtension
public DroolsAssert droolsAssert = this;
@Test
@TestRules(expectedCount = { "1", "Check_DyrAlder" })
public void testInputObjectExample() {
KieCommands commandFactory = KieServices.get().getCommands();
List<Command<?>> commands = new ArrayList<>();
for (int i = 0; i < 10; i++) {
InputObject inputObject = new InputObject();
inputObject.setTransactionId(i);
inputObject.setRuleSet("set" + i);
inputObject.setInput(ImmutableMap.of("DyrAlder", i));
inputObject.setValidationResults(new ArrayList<>());
commands.add(commandFactory.newInsert(inputObject, "ValRes"));
commands.add(commandFactory.newFireAllRules());
}
commands.forEach(c -> getSession().execute(c));
}
}
package draft;
//generated from Decision Table
import draft.InputObject;
import draft.ValidationResult;
// rule values at A9, header at A4
rule "Check_DyrAlder"
when
animal:InputObject(ruleSet == "set3", input["DyrAlder"] < 5)
then
animal.addValidationResult(new ValidationResult("HDY-08277", "message"));
end
public class InputObject {
private Integer primaryKey;
private Integer sessionId;
private Integer transactionId;
private String ruleSet;
private Map<String, Object> input;
private List<ValidationResult> validationResults;
// getters/setters
@DroolsSession(resources = "draft/droolsObjectExample.xlsx",
builderProperties = "drools.dump.dir = target/dump",
showStateTransitionPopup = true)
public class PlaygroundTest extends DroolsAssert {
@RegisterExtension
public DroolsAssert droolsAssert = this;
@Test
@TestRules(expectedCount = { "1", "Check_DyrAlder" })
public void testDroolsObjectExample() {
KieCommands commandFactory = KieServices.get().getCommands();
List<Command<?>> commands = new ArrayList<>();
for (int i = 0; i < 10; i++) {
DroolsObject inputObject = new DroolsObject();
inputObject.put("ruleSet", "set" + i);
inputObject.put("DyrAlder", i);
commands.add(commandFactory.newInsert(inputObject, "ValRes"));
commands.add(commandFactory.newFireAllRules());
}
commands.forEach(c -> getSession().execute(c));
}
}
package draft;
//generated from Decision Table
import draft.DroolsObject;
import draft.ValidationResult;
// rule values at A9, header at A4
rule "Check_DyrAlder"
when
animal:DroolsObject(ruleSet == "set3", DyrAlder < 5)
then
animal.addValidationResult(new ValidationResult("HDY-08277", "message"));
end
public class DroolsObject extends LinkedHashMap<String, Object> {
public void addValidationResult(ValidationResult validationResult) {
if (!this.containsKey("validationResult"))
this.put("validationResult", new LinkedList<ValidationResult>());
((List<ValidationResult>) this.get("validationResult")).add(validationResult);
}
}
-----------------------
@DroolsSession(resources = "draft/inputObjectExample.xlsx",
builderProperties = "drools.dump.dir = target/dump",
showStateTransitionPopup = true)
public class PlaygroundTest extends DroolsAssert {
@RegisterExtension
public DroolsAssert droolsAssert = this;
@Test
@TestRules(expectedCount = { "1", "Check_DyrAlder" })
public void testInputObjectExample() {
KieCommands commandFactory = KieServices.get().getCommands();
List<Command<?>> commands = new ArrayList<>();
for (int i = 0; i < 10; i++) {
InputObject inputObject = new InputObject();
inputObject.setTransactionId(i);
inputObject.setRuleSet("set" + i);
inputObject.setInput(ImmutableMap.of("DyrAlder", i));
inputObject.setValidationResults(new ArrayList<>());
commands.add(commandFactory.newInsert(inputObject, "ValRes"));
commands.add(commandFactory.newFireAllRules());
}
commands.forEach(c -> getSession().execute(c));
}
}
package draft;
//generated from Decision Table
import draft.InputObject;
import draft.ValidationResult;
// rule values at A9, header at A4
rule "Check_DyrAlder"
when
animal:InputObject(ruleSet == "set3", input["DyrAlder"] < 5)
then
animal.addValidationResult(new ValidationResult("HDY-08277", "message"));
end
public class InputObject {
private Integer primaryKey;
private Integer sessionId;
private Integer transactionId;
private String ruleSet;
private Map<String, Object> input;
private List<ValidationResult> validationResults;
// getters/setters
@DroolsSession(resources = "draft/droolsObjectExample.xlsx",
builderProperties = "drools.dump.dir = target/dump",
showStateTransitionPopup = true)
public class PlaygroundTest extends DroolsAssert {
@RegisterExtension
public DroolsAssert droolsAssert = this;
@Test
@TestRules(expectedCount = { "1", "Check_DyrAlder" })
public void testDroolsObjectExample() {
KieCommands commandFactory = KieServices.get().getCommands();
List<Command<?>> commands = new ArrayList<>();
for (int i = 0; i < 10; i++) {
DroolsObject inputObject = new DroolsObject();
inputObject.put("ruleSet", "set" + i);
inputObject.put("DyrAlder", i);
commands.add(commandFactory.newInsert(inputObject, "ValRes"));
commands.add(commandFactory.newFireAllRules());
}
commands.forEach(c -> getSession().execute(c));
}
}
package draft;
//generated from Decision Table
import draft.DroolsObject;
import draft.ValidationResult;
// rule values at A9, header at A4
rule "Check_DyrAlder"
when
animal:DroolsObject(ruleSet == "set3", DyrAlder < 5)
then
animal.addValidationResult(new ValidationResult("HDY-08277", "message"));
end
public class DroolsObject extends LinkedHashMap<String, Object> {
public void addValidationResult(ValidationResult validationResult) {
if (!this.containsKey("validationResult"))
this.put("validationResult", new LinkedList<ValidationResult>());
((List<ValidationResult>) this.get("validationResult")).add(validationResult);
}
}
-----------------------
@DroolsSession(resources = "draft/inputObjectExample.xlsx",
builderProperties = "drools.dump.dir = target/dump",
showStateTransitionPopup = true)
public class PlaygroundTest extends DroolsAssert {
@RegisterExtension
public DroolsAssert droolsAssert = this;
@Test
@TestRules(expectedCount = { "1", "Check_DyrAlder" })
public void testInputObjectExample() {
KieCommands commandFactory = KieServices.get().getCommands();
List<Command<?>> commands = new ArrayList<>();
for (int i = 0; i < 10; i++) {
InputObject inputObject = new InputObject();
inputObject.setTransactionId(i);
inputObject.setRuleSet("set" + i);
inputObject.setInput(ImmutableMap.of("DyrAlder", i));
inputObject.setValidationResults(new ArrayList<>());
commands.add(commandFactory.newInsert(inputObject, "ValRes"));
commands.add(commandFactory.newFireAllRules());
}
commands.forEach(c -> getSession().execute(c));
}
}
package draft;
//generated from Decision Table
import draft.InputObject;
import draft.ValidationResult;
// rule values at A9, header at A4
rule "Check_DyrAlder"
when
animal:InputObject(ruleSet == "set3", input["DyrAlder"] < 5)
then
animal.addValidationResult(new ValidationResult("HDY-08277", "message"));
end
public class InputObject {
private Integer primaryKey;
private Integer sessionId;
private Integer transactionId;
private String ruleSet;
private Map<String, Object> input;
private List<ValidationResult> validationResults;
// getters/setters
@DroolsSession(resources = "draft/droolsObjectExample.xlsx",
builderProperties = "drools.dump.dir = target/dump",
showStateTransitionPopup = true)
public class PlaygroundTest extends DroolsAssert {
@RegisterExtension
public DroolsAssert droolsAssert = this;
@Test
@TestRules(expectedCount = { "1", "Check_DyrAlder" })
public void testDroolsObjectExample() {
KieCommands commandFactory = KieServices.get().getCommands();
List<Command<?>> commands = new ArrayList<>();
for (int i = 0; i < 10; i++) {
DroolsObject inputObject = new DroolsObject();
inputObject.put("ruleSet", "set" + i);
inputObject.put("DyrAlder", i);
commands.add(commandFactory.newInsert(inputObject, "ValRes"));
commands.add(commandFactory.newFireAllRules());
}
commands.forEach(c -> getSession().execute(c));
}
}
package draft;
//generated from Decision Table
import draft.DroolsObject;
import draft.ValidationResult;
// rule values at A9, header at A4
rule "Check_DyrAlder"
when
animal:DroolsObject(ruleSet == "set3", DyrAlder < 5)
then
animal.addValidationResult(new ValidationResult("HDY-08277", "message"));
end
public class DroolsObject extends LinkedHashMap<String, Object> {
public void addValidationResult(ValidationResult validationResult) {
if (!this.containsKey("validationResult"))
this.put("validationResult", new LinkedList<ValidationResult>());
((List<ValidationResult>) this.get("validationResult")).add(validationResult);
}
}
-----------------------
@DroolsSession(resources = "draft/inputObjectExample.xlsx",
builderProperties = "drools.dump.dir = target/dump",
showStateTransitionPopup = true)
public class PlaygroundTest extends DroolsAssert {
@RegisterExtension
public DroolsAssert droolsAssert = this;
@Test
@TestRules(expectedCount = { "1", "Check_DyrAlder" })
public void testInputObjectExample() {
KieCommands commandFactory = KieServices.get().getCommands();
List<Command<?>> commands = new ArrayList<>();
for (int i = 0; i < 10; i++) {
InputObject inputObject = new InputObject();
inputObject.setTransactionId(i);
inputObject.setRuleSet("set" + i);
inputObject.setInput(ImmutableMap.of("DyrAlder", i));
inputObject.setValidationResults(new ArrayList<>());
commands.add(commandFactory.newInsert(inputObject, "ValRes"));
commands.add(commandFactory.newFireAllRules());
}
commands.forEach(c -> getSession().execute(c));
}
}
package draft;
//generated from Decision Table
import draft.InputObject;
import draft.ValidationResult;
// rule values at A9, header at A4
rule "Check_DyrAlder"
when
animal:InputObject(ruleSet == "set3", input["DyrAlder"] < 5)
then
animal.addValidationResult(new ValidationResult("HDY-08277", "message"));
end
public class InputObject {
private Integer primaryKey;
private Integer sessionId;
private Integer transactionId;
private String ruleSet;
private Map<String, Object> input;
private List<ValidationResult> validationResults;
// getters/setters
@DroolsSession(resources = "draft/droolsObjectExample.xlsx",
builderProperties = "drools.dump.dir = target/dump",
showStateTransitionPopup = true)
public class PlaygroundTest extends DroolsAssert {
@RegisterExtension
public DroolsAssert droolsAssert = this;
@Test
@TestRules(expectedCount = { "1", "Check_DyrAlder" })
public void testDroolsObjectExample() {
KieCommands commandFactory = KieServices.get().getCommands();
List<Command<?>> commands = new ArrayList<>();
for (int i = 0; i < 10; i++) {
DroolsObject inputObject = new DroolsObject();
inputObject.put("ruleSet", "set" + i);
inputObject.put("DyrAlder", i);
commands.add(commandFactory.newInsert(inputObject, "ValRes"));
commands.add(commandFactory.newFireAllRules());
}
commands.forEach(c -> getSession().execute(c));
}
}
package draft;
//generated from Decision Table
import draft.DroolsObject;
import draft.ValidationResult;
// rule values at A9, header at A4
rule "Check_DyrAlder"
when
animal:DroolsObject(ruleSet == "set3", DyrAlder < 5)
then
animal.addValidationResult(new ValidationResult("HDY-08277", "message"));
end
public class DroolsObject extends LinkedHashMap<String, Object> {
public void addValidationResult(ValidationResult validationResult) {
if (!this.containsKey("validationResult"))
this.put("validationResult", new LinkedList<ValidationResult>());
((List<ValidationResult>) this.get("validationResult")).add(validationResult);
}
}
-----------------------
@DroolsSession(resources = "draft/inputObjectExample.xlsx",
builderProperties = "drools.dump.dir = target/dump",
showStateTransitionPopup = true)
public class PlaygroundTest extends DroolsAssert {
@RegisterExtension
public DroolsAssert droolsAssert = this;
@Test
@TestRules(expectedCount = { "1", "Check_DyrAlder" })
public void testInputObjectExample() {
KieCommands commandFactory = KieServices.get().getCommands();
List<Command<?>> commands = new ArrayList<>();
for (int i = 0; i < 10; i++) {
InputObject inputObject = new InputObject();
inputObject.setTransactionId(i);
inputObject.setRuleSet("set" + i);
inputObject.setInput(ImmutableMap.of("DyrAlder", i));
inputObject.setValidationResults(new ArrayList<>());
commands.add(commandFactory.newInsert(inputObject, "ValRes"));
commands.add(commandFactory.newFireAllRules());
}
commands.forEach(c -> getSession().execute(c));
}
}
package draft;
//generated from Decision Table
import draft.InputObject;
import draft.ValidationResult;
// rule values at A9, header at A4
rule "Check_DyrAlder"
when
animal:InputObject(ruleSet == "set3", input["DyrAlder"] < 5)
then
animal.addValidationResult(new ValidationResult("HDY-08277", "message"));
end
public class InputObject {
private Integer primaryKey;
private Integer sessionId;
private Integer transactionId;
private String ruleSet;
private Map<String, Object> input;
private List<ValidationResult> validationResults;
// getters/setters
@DroolsSession(resources = "draft/droolsObjectExample.xlsx",
builderProperties = "drools.dump.dir = target/dump",
showStateTransitionPopup = true)
public class PlaygroundTest extends DroolsAssert {
@RegisterExtension
public DroolsAssert droolsAssert = this;
@Test
@TestRules(expectedCount = { "1", "Check_DyrAlder" })
public void testDroolsObjectExample() {
KieCommands commandFactory = KieServices.get().getCommands();
List<Command<?>> commands = new ArrayList<>();
for (int i = 0; i < 10; i++) {
DroolsObject inputObject = new DroolsObject();
inputObject.put("ruleSet", "set" + i);
inputObject.put("DyrAlder", i);
commands.add(commandFactory.newInsert(inputObject, "ValRes"));
commands.add(commandFactory.newFireAllRules());
}
commands.forEach(c -> getSession().execute(c));
}
}
package draft;
//generated from Decision Table
import draft.DroolsObject;
import draft.ValidationResult;
// rule values at A9, header at A4
rule "Check_DyrAlder"
when
animal:DroolsObject(ruleSet == "set3", DyrAlder < 5)
then
animal.addValidationResult(new ValidationResult("HDY-08277", "message"));
end
public class DroolsObject extends LinkedHashMap<String, Object> {
public void addValidationResult(ValidationResult validationResult) {
if (!this.containsKey("validationResult"))
this.put("validationResult", new LinkedList<ValidationResult>());
((List<ValidationResult>) this.get("validationResult")).add(validationResult);
}
}
drools getting error : handle not found for object is it in working memory
then
$ins.setCategory("A");
update( $pcr );
end
then
$ins.setCategory("A");
modify( $pcr ){
setInsuranceTypes($insuranceTypes)
}
end
$ins: InsuranceType( name == "TPD" , category == "D" ) from $insuranceTypes
-----------------------
then
$ins.setCategory("A");
update( $pcr );
end
then
$ins.setCategory("A");
modify( $pcr ){
setInsuranceTypes($insuranceTypes)
}
end
$ins: InsuranceType( name == "TPD" , category == "D" ) from $insuranceTypes
-----------------------
then
$ins.setCategory("A");
update( $pcr );
end
then
$ins.setCategory("A");
modify( $pcr ){
setInsuranceTypes($insuranceTypes)
}
end
$ins: InsuranceType( name == "TPD" , category == "D" ) from $insuranceTypes
Drools - how do I compare a string value present in a Java Object which is present inside a List
rule "Example"
when
Premium( $insuranceTypes: insuranceTypes )
exists( InsuranceType( name == "TPD" ) from $insuranceTypes )
then
System.out.println("Error");
end
How to loop through a list to check if an item is a memberOf another list
rule "Problems related to social environment"
when
$eligibilityDomainObject:EligibilityDomainObject($listOfString : listOfString)
value: String(value memberOf "F77 EOO F99" ) from $listOfString
then
$eligibilityDomainObject.setIsComplexPhysicalHealth(true);
end
-----------------------
rule "Problems related to social environment"
when
$eligibilityDomainObject:EligibilityDomainObject($listOfString : listOfString)
value: String(value in ("F77", "EOO", "F99") ) from $listOfString
then
$eligibilityDomainObject.setIsComplexPhysicalHealth(true);
end
import static org.apache.commons.collections4.CollectionUtils.containsAny;
rule "Problems related to social environment"
when
$eligibilityDomainObject:EligibilityDomainObject(containsAny(listOfString, "F77", "EOO", "F99"))
then
$eligibilityDomainObject.setIsComplexPhysicalHealth(true);
end
import static org.apache.commons.collections4.CollectionUtils.intersection;
import static com.google.common.collect.Sets.newHashSet;
rule "Problems related to social environment"
when
$eligibilityDomainObject:EligibilityDomainObject(
$values : intersection(listOfString, newHashSet("F77", "EOO", "F99")),
!$values.isEmpty())
then
$eligibilityDomainObject.setIsComplexPhysicalHealth(true);
System.out.println($values);
end
-----------------------
rule "Problems related to social environment"
when
$eligibilityDomainObject:EligibilityDomainObject($listOfString : listOfString)
value: String(value in ("F77", "EOO", "F99") ) from $listOfString
then
$eligibilityDomainObject.setIsComplexPhysicalHealth(true);
end
import static org.apache.commons.collections4.CollectionUtils.containsAny;
rule "Problems related to social environment"
when
$eligibilityDomainObject:EligibilityDomainObject(containsAny(listOfString, "F77", "EOO", "F99"))
then
$eligibilityDomainObject.setIsComplexPhysicalHealth(true);
end
import static org.apache.commons.collections4.CollectionUtils.intersection;
import static com.google.common.collect.Sets.newHashSet;
rule "Problems related to social environment"
when
$eligibilityDomainObject:EligibilityDomainObject(
$values : intersection(listOfString, newHashSet("F77", "EOO", "F99")),
!$values.isEmpty())
then
$eligibilityDomainObject.setIsComplexPhysicalHealth(true);
System.out.println($values);
end
-----------------------
rule "Problems related to social environment"
when
$eligibilityDomainObject:EligibilityDomainObject($listOfString : listOfString)
value: String(value in ("F77", "EOO", "F99") ) from $listOfString
then
$eligibilityDomainObject.setIsComplexPhysicalHealth(true);
end
import static org.apache.commons.collections4.CollectionUtils.containsAny;
rule "Problems related to social environment"
when
$eligibilityDomainObject:EligibilityDomainObject(containsAny(listOfString, "F77", "EOO", "F99"))
then
$eligibilityDomainObject.setIsComplexPhysicalHealth(true);
end
import static org.apache.commons.collections4.CollectionUtils.intersection;
import static com.google.common.collect.Sets.newHashSet;
rule "Problems related to social environment"
when
$eligibilityDomainObject:EligibilityDomainObject(
$values : intersection(listOfString, newHashSet("F77", "EOO", "F99")),
!$values.isEmpty())
then
$eligibilityDomainObject.setIsComplexPhysicalHealth(true);
System.out.println($values);
end
Problem with pattern matching in Drools 7.57.0.Final
@DroolsSession(
resources = "classpath*:**/section06/step5/*",
showStateTransitionPopup = true)
public class Section6Step5Test {
@RegisterExtension
public DroolsAssert drools = new DroolsAssert();
@Test
public void test() {
ApplicationRepository.getPassports().forEach(drools::insert);
ApplicationRepository.getVisaApplications().forEach(drools::insert);
drools.getSession().getAgenda().getAgendaGroup("issue-visa").setFocus();
drools.getSession().getAgenda().getAgendaGroup("validate-application").setFocus();
drools.getSession().getAgenda().getAgendaGroup("validate-passport").setFocus();
drools.fireAllRules();
assertEquals(1, drools.getObjects(Visa.class).size());
}
}
How to test list length in Drools 7.59?
rule "Person has 3 or more existing checked out books"
when
BookEvent( type == BookEventType.BORROW )
$person: Person( $books: checkedOutBooks, $books.size >= 3 )
$book1: Book() from $person.checkedOutBooks.get(0)
$book3: Book(name == 'book3') from $person.checkedOutBooks
$bookNames: List(size >= 3) from accumulate (Book($name: name) from $books, collectList($name))
then
System.out.println("First book " + $book1);
System.out.println("Third book " + $book3);
System.out.println("Book names " + $bookNames);
System.out.println("Books " + $books);
end
Potential OptaPlanner/Drools Bug: Strange MultiAccumulate ClassCastException
$cc : MyConstraintConfiguration()
accumulate(PlanningEntity($key : key,
$value : $cc.getCachedValue($key)
...
QUESTION
How to deal with publishing promotion issues Hybris 2105?
Asked 2022-Feb-16 at 07:14We have migrated our SAP Hybris from 2011 to 2105.
There are some issues coming while publishing new promotions, which seem to work fine in the lower version.When we publish a promotion(even OOB promotion like in Conditions CMS Site and in Action 10% discount on cart) and when I publish the promotion, I get an error like:
ruleOrderEntryFixedDiscountAction.executeAction(new
DefaultDroolsRuleActionContext(variables, kcontext),
["value_uuid":"6e732228-89fe-4f4e-8dea-5235dee2ccd7",
"bundleSize":new Integer(4), "bundleSize_uuid":"49803399-
53a8-44b6-85cd-35c1b83235d7", "bundleLimit_uuid":"778299c6-
75bd-414e-97bb-3e5fe1aa0bf9", "bundleLimit":new Integer(2),
"value":new BigDecimal("50")]);
$groupExecution.trackRuleGroupExecution($config);:
[Error: unable to resolve method using strict-mode:
org.drools.core.spi.KnowledgeHelper.$groupExecution()]
ANSWER
Answered 2022-Feb-02 at 20:56This is due to some changes in the drools rule engine. This causes an exception during the parsing of older Drools Rule.
To solve this, you can
Make the content of all drools rules blank, and republish all rules to have correct and active drools rules for all your promotions. Example of a script: You need to disable the interceptors as they might prevent you from changing the rule content
import de.hybris.platform.commerceservices.search.pagedata.PageableData
import de.hybris.platform.servicelayer.search.FlexibleSearchQuery
import com.google.common.collect.ImmutableMap;
import de.hybris.platform.servicelayer.interceptor.impl.InterceptorExecutionPolicy;
import de.hybris.platform.servicelayer.session.SessionExecutionBody;
import de.hybris.platform.servicelayer.session.SessionService;
import com.google.common.collect.ImmutableSet;
int start = 0
int pageSize = 1000
int total = pageSize
final FlexibleSearchQuery searchQuery = new FlexibleSearchQuery("select {PK} from {DroolsRule} ORDER BY {PK}")
searchQuery.setCount(pageSize)
searchQuery.setNeedTotal(true)
while (start < total) {
searchQuery.setStart(start)
def searchResult = flexibleSearchService.search(searchQuery)
searchResult.getResult().each {
final Map<String, Object> params = ImmutableMap.of(InterceptorExecutionPolicy.DISABLED_INTERCEPTOR_TYPES,
ImmutableSet.of(InterceptorExecutionPolicy.InterceptorType.PREPARE,InterceptorExecutionPolicy.InterceptorType.VALIDATE));
sessionService.executeInLocalViewWithParams(params, new SessionExecutionBody() {
@Override
public void executeWithoutResult() {
it.setRuleContent("");
modelService.save(it);
}
});
}
total = searchResult.getTotalCount()
start += pageSize
}
println "Script has been completed."
OR
DroolsRule
objects if you no longer need them. Do note that removing these old rules might have impact on existing orders tied to that Drools rule. The promotion results will still be attached, but it will be hard to tell what promotion triggered that result.I would advise going for the first option as to not lose any data
Don't forget to republish your rules after performing either of the steps
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit