Skip to content

Commit 0f1be22

Browse files
committed
CB-7595: Document the possibility of creating a custom batch validation rule.
1 parent 05c1e03 commit 0f1be22

File tree

11 files changed

+308
-2
lines changed

11 files changed

+308
-2
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
This project contains code samples documented in the following section in [Backbase Community](https://community.backbase.com/documentation/ServiceSDK/latest/index):
1+
This project contains code samples documented in the following section in [Backbase Community](https://community.backbase.com/documentation/DBS/latest/index):
22

3-
* [Add a custom batch type](https://community.backbase.com/documentation/DBS/latest/payments_add_custom_batch_type)
3+
* [Add a custom batch type](https://community.backbase.com/documentation/DBS/latest/batches_add_custom_batch_type)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This project contains code samples documented in the following section in [Backbase Community](https://community.backbase.com/documentation/DBS/latest/index):
2+
3+
* [Add a custom validation rule](https://community.backbase.com/documentation/DBS/latest/batches_add_custom_validation_rule)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
**/*.iml
2+
**/*.ipr
3+
**/*.iws
4+
**/*.log
5+
**/.classpath
6+
**/.idea/
7+
**/.project
8+
**/.settings
9+
**/target/
10+
**/*.class
11+
12+
# General
13+
.DS_Store
14+
.AppleDouble
15+
.LSOverride
16+
17+
18+
.vscode/*
19+
!.vscode/settings.json
20+
!.vscode/tasks.json
21+
!.vscode/launch.json
22+
!.vscode/extensions.json
23+
*.code-workspace
24+
25+
# Local History for Visual Studio Code
26+
.history/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## payment-batch extension.
2+
3+
[Fill out this file with some information about your service extension.]
4+
5+
## How to use
6+
7+
To use your service extension, you include the JAR build from this artifact to the CLASSPATH used when the service is
8+
started.
9+
10+
11+
When you run a service as an [executable JAR](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#executable-jar-property-launcher-features),
12+
use the `loader.path` command line argument to add JARs or directories of JARs to the classpath. For example:
13+
14+
```
15+
./rtn-blocklist-batch-validation-rule-service-extension.jar -Dloader.path=/path/to/my.jar,/path/to/my/other.jar,/path/to/lib-dir
16+
```
17+
18+
If you are not running the Service as a bootable jar, use the mechanism available in your application server.
19+
20+
### Docker
21+
22+
To extend the Backbase Docker images
23+
with the Behaviour Extension jar built from this project.
24+
25+
mvn package -Pdocker-image
26+
27+
The build creates a Docker image with the extension added and ready to use.
28+
29+
To build the image to a local Docker daemon without pushing to the repository.
30+
31+
mvn package -Pdocker-image,local-client
32+
33+
## Community Documentation
34+
35+
* [Extend the behavior of a service](https://community.backbase.com/documentation/ServiceSDK/latest/extend_service_behavior)
36+
37+
Add links to documentation including setup, config, etc.
38+
39+
## Jira Project
40+
41+
Add link to Jira project.
42+
43+
## Confluence Links
44+
Links to relevant confluence pages (design etc).
45+
46+
## Support
47+
48+
Slack, Email, Jira etc.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>com.backbase.buildingblocks</groupId>
7+
<artifactId>backbase-service-extension-starter-parent</artifactId>
8+
<version>13.3.1</version>
9+
</parent>
10+
11+
<groupId>com.backbase.batch</groupId>
12+
<artifactId>rtn-blocklist-batch-validation-rule-service-extension</artifactId>
13+
<version>1.0.0-SNAPSHOT</version>
14+
15+
<properties>
16+
17+
<!-- docker configuration -->
18+
<docker.image.name>harbor.backbase.eu/development/${project.artifactId}</docker.image.name>
19+
<docker.image.tag>${project.version}</docker.image.tag>
20+
21+
<!-- base image -->
22+
<docker.base.tag>DBS-2.21.4</docker.base.tag>
23+
<docker.base.name>repo.backbase.com/backbase-docker-releases/payment-batch</docker.base.name>
24+
</properties>
25+
26+
<dependencyManagement>
27+
<dependencies>
28+
<dependency>
29+
<groupId>com.backbase.dbs</groupId>
30+
<artifactId>banking-services-bom</artifactId>
31+
<version>2.21.4</version>
32+
<type>pom</type>
33+
<scope>import</scope>
34+
</dependency>
35+
</dependencies>
36+
</dependencyManagement>
37+
38+
<dependencies>
39+
<dependency>
40+
<groupId>com.backbase.batch</groupId>
41+
<artifactId>payment-batch</artifactId>
42+
<classifier>classes</classifier>
43+
<scope>provided</scope>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.springframework.boot</groupId>
47+
<artifactId>spring-boot-starter-test</artifactId>
48+
<scope>test</scope>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.projectlombok</groupId>
52+
<artifactId>lombok</artifactId>
53+
<version>1.18.22</version>
54+
<scope>provided</scope>
55+
</dependency>
56+
</dependencies>
57+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.backbase.dbs.payment.batch.rule.validation;
2+
3+
import static com.backbase.dbs.payment.batch.rule.BatchFacts.FACT_BATCH_PAYMENT;
4+
5+
import com.backbase.dbs.payment.batch.config.BatchRuleInformation;
6+
import com.backbase.dbs.payment.batch.model.BatchPayment;
7+
import com.backbase.dbs.payment.batch.rule.AbstractBatchValidationRule;
8+
import com.backbase.dbs.payment.batch.service.RtnBlocklistValidator;
9+
import java.util.ArrayList;
10+
import java.util.Map;
11+
import org.jeasy.rules.api.Facts;
12+
import org.springframework.expression.EvaluationContext;
13+
import org.springframework.expression.Expression;
14+
15+
public class RtnBlocklistBatchValidationRule extends AbstractBatchValidationRule {
16+
17+
private final RtnBlocklistValidator rtnBlocklistValidator;
18+
19+
public static class RtnBlocklist extends ArrayList<String> {
20+
21+
}
22+
23+
public RtnBlocklistBatchValidationRule(
24+
BatchRuleInformation batchRuleInformation,
25+
Map<String, Expression> errorContextExpressions,
26+
EvaluationContext evaluationContext,
27+
Expression conditionExpression, RtnBlocklistValidator rtnBlocklistValidator) {
28+
super(batchRuleInformation, errorContextExpressions, evaluationContext, conditionExpression);
29+
this.rtnBlocklistValidator = rtnBlocklistValidator;
30+
}
31+
32+
@Override
33+
public boolean isValid(Facts facts) {
34+
BatchPayment batchPayment = facts.get(FACT_BATCH_PAYMENT);
35+
36+
Map<String, String> ruleConfiguration = getBatchRuleInformation().getConfiguration();
37+
38+
String rtnBlocklistUrl = ruleConfiguration.get("rtn-blocklist-url");
39+
40+
return rtnBlocklistValidator.isValid(rtnBlocklistUrl, batchPayment.getCounterpartyBankBranchCode());
41+
}
42+
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.backbase.dbs.payment.batch.rule.validation;
2+
3+
import static com.backbase.dbs.payment.batch.rule.BatchFacts.FACT_BATCH_PAYMENT;
4+
5+
import com.backbase.dbs.payment.batch.config.ManualBatchRuleInformation;
6+
import com.backbase.dbs.payment.batch.model.engine.manual.BatchPaymentFact;
7+
import com.backbase.dbs.payment.batch.rule.AbstractManualBatchValidationRule;
8+
import com.backbase.dbs.payment.batch.service.RtnBlocklistValidator;
9+
import java.util.Map;
10+
import org.jeasy.rules.api.Facts;
11+
import org.springframework.expression.EvaluationContext;
12+
import org.springframework.expression.Expression;
13+
14+
public class RtnBlocklistManualBatchValidationRule extends AbstractManualBatchValidationRule {
15+
16+
private final RtnBlocklistValidator rtnBlocklistValidator;
17+
18+
public RtnBlocklistManualBatchValidationRule(ManualBatchRuleInformation information,
19+
EvaluationContext evaluationContext,
20+
Expression conditionExpression,
21+
Map<String, Expression> errorContextExpressions, RtnBlocklistValidator rtnBlocklistValidator) {
22+
super(information, evaluationContext, conditionExpression, errorContextExpressions);
23+
this.rtnBlocklistValidator = rtnBlocklistValidator;
24+
}
25+
26+
@Override
27+
public boolean isValid(Facts facts) {
28+
BatchPaymentFact batchPayment = facts.get(FACT_BATCH_PAYMENT);
29+
30+
Map<String, String> ruleConfiguration = getManualBatchRuleInformation().getConfiguration();
31+
32+
String rtnBlocklistUrl = ruleConfiguration.get("rtn-blocklist-url");
33+
34+
return rtnBlocklistValidator.isValid(rtnBlocklistUrl, batchPayment.getCounterpartyBankBranchCode());
35+
}
36+
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.backbase.dbs.payment.batch.rule.validation.factory;
2+
3+
import com.backbase.dbs.payment.batch.config.BatchRuleInformation;
4+
import com.backbase.dbs.payment.batch.rule.factory.AbstractSpelBatchValidationRuleFactory;
5+
import com.backbase.dbs.payment.batch.rule.validation.BatchValidationRule;
6+
import com.backbase.dbs.payment.batch.rule.validation.RtnBlocklistBatchValidationRule;
7+
import com.backbase.dbs.payment.batch.service.RtnBlocklistValidator;
8+
import lombok.RequiredArgsConstructor;
9+
import org.springframework.stereotype.Component;
10+
11+
@Component
12+
@RequiredArgsConstructor
13+
public class RtnBlocklistBatchValidationRuleFactory extends AbstractSpelBatchValidationRuleFactory
14+
implements BatchValidationRuleFactory {
15+
16+
private final RtnBlocklistValidator rtnBlocklistValidator;
17+
18+
@Override
19+
public String getType() {
20+
return "rtn-blocklist-validation";
21+
}
22+
23+
@Override
24+
public BatchValidationRule buildRule(BatchRuleInformation information) {
25+
return new RtnBlocklistBatchValidationRule(information,
26+
createErrorContextExpressions(information.getConfiguration(), information.getName()),
27+
createEvaluationContext(),
28+
createConditionExpression(information), rtnBlocklistValidator);
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.backbase.dbs.payment.batch.rule.validation.factory;
2+
3+
import com.backbase.dbs.payment.batch.config.ManualBatchRuleInformation;
4+
import com.backbase.dbs.payment.batch.rule.factory.AbstractSpelBatchValidationRuleFactory;
5+
import com.backbase.dbs.payment.batch.rule.validation.ManualBatchValidationRule;
6+
import com.backbase.dbs.payment.batch.rule.validation.RtnBlocklistManualBatchValidationRule;
7+
import com.backbase.dbs.payment.batch.service.RtnBlocklistValidator;
8+
import lombok.RequiredArgsConstructor;
9+
import org.springframework.stereotype.Component;
10+
11+
@Component
12+
@RequiredArgsConstructor
13+
public class RtnBlocklistManualBatchValidationRuleFactory extends AbstractSpelBatchValidationRuleFactory
14+
implements ManualBatchValidationRuleFactory {
15+
16+
private final RtnBlocklistValidator rtnBlocklistValidator;
17+
18+
@Override
19+
public String getType() {
20+
return "rtn-blocklist-validation";
21+
}
22+
23+
@Override
24+
public ManualBatchValidationRule buildRule(ManualBatchRuleInformation information) {
25+
return new RtnBlocklistManualBatchValidationRule(information,
26+
createEvaluationContext(),
27+
createConditionExpression(information),
28+
createErrorContextExpressions(information.getConfiguration(), information.getName()),
29+
rtnBlocklistValidator);
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.backbase.dbs.payment.batch.service;
2+
3+
import java.util.ArrayList;
4+
5+
public class RtnBlocklist extends ArrayList<String> {
6+
7+
}

0 commit comments

Comments
 (0)