[JAVA-14177] Renamed rule-engines to rule-enfines-modules (#12723)
Co-authored-by: panagiotiskakos <panagiotis.kakos@libra-is.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung.openltablets</groupId>
|
||||
<artifactId>openl-tablets</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>openl-tablets</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>rule-engines-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.openl</groupId>
|
||||
<artifactId>org.openl.core</artifactId>
|
||||
<version>${openl.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openl.rules</groupId>
|
||||
<artifactId>org.openl.rules</artifactId>
|
||||
<version>${openl.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<openl.version>5.19.4</openl.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.baeldung.openltablets.model;
|
||||
|
||||
public class Case {
|
||||
|
||||
private User user;
|
||||
private int hourOfDay;
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(final User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public int getHourOfDay() {
|
||||
return hourOfDay;
|
||||
}
|
||||
|
||||
public void setHourOfDay(final int hourOfDay) {
|
||||
this.hourOfDay = hourOfDay;
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.baeldung.openltablets.model;
|
||||
|
||||
public enum Greeting {
|
||||
|
||||
GOOD_MORNING("Good Morning"),
|
||||
GOOD_AFTERNOON("Good Afternoon"),
|
||||
GOOD_EVENING("Good Evening"),
|
||||
GOOD_NIGHT("Good Night");
|
||||
|
||||
private final String literal;
|
||||
|
||||
private Greeting(final String literal) {
|
||||
this.literal = literal;
|
||||
}
|
||||
|
||||
public String getLiteral() {
|
||||
return literal;
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.openltablets.model;
|
||||
|
||||
public class User {
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.baeldung.openltablets.rules;
|
||||
|
||||
import com.baeldung.openltablets.model.Case;
|
||||
|
||||
public interface IRule {
|
||||
void helloUser(final Case aCase, final Response response);
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.baeldung.openltablets.rules;
|
||||
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.openl.rules.runtime.RulesEngineFactory;
|
||||
import org.openl.runtime.EngineFactory;
|
||||
|
||||
import com.baeldung.openltablets.model.Case;
|
||||
import com.baeldung.openltablets.model.User;
|
||||
|
||||
public class Main {
|
||||
private IRule instance;
|
||||
|
||||
public static void main(String[] args) {
|
||||
Main rules = new Main();
|
||||
User user = new User();
|
||||
user.setName("Donald Duck");
|
||||
Case aCase = new Case();
|
||||
aCase.setUser(user);
|
||||
aCase.setHourOfDay(23);
|
||||
rules.process(aCase);
|
||||
}
|
||||
|
||||
public void process(Case aCase) {
|
||||
final EngineFactory<IRule> engineFactory = new RulesEngineFactory<IRule>(getClass().getClassLoader()
|
||||
.getResource("openltablets/HelloUser.xls"), IRule.class);
|
||||
instance = engineFactory.newEngineInstance();
|
||||
instance.helloUser(aCase, new Response());
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.baeldung.openltablets.rules;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Response {
|
||||
private String result;
|
||||
private Map<String, String> map = new HashMap<>();
|
||||
|
||||
public Response() { }
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(final String s) {
|
||||
result = s;
|
||||
}
|
||||
|
||||
public Map<String, String> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
Binary file not shown.
Reference in New Issue
Block a user