Skip to content

Commit 9c6afa4

Browse files
authored
Merge pull request #24 from openMF/foundation-onboarding-workflows-setup
Foundation onboarding workflows setup
2 parents 3f631eb + b3e23e0 commit 9c6afa4

24 files changed

+1434
-92
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# mifos-workflow
22

3+
### Default Configuration
4+
5+
The application uses these default credentials (you should override them with environment variables):
6+
7+
**Database (Flowable):**
8+
- Username: `mifos`
9+
- Password: Set via `DB_PASSWORD` environment variable
10+
11+
**Fineract API:**
12+
- Username: `mifos`
13+
- Password: Set via `FINERACT_PASSWORD` environment variable
14+
15+
### Example Setup
16+
17+
```bash
18+
export DB_PASSWORD=your_secure_db_password
19+
export FINERACT_PASSWORD=your_secure_fineract_password
20+
```
21+
322
## Documentation
423

524
Documentation is available in the `docs/` directory. To generate HTML documentation:

src/main/java/org/mifos/workflow/config/FineractApiConfig.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
import javax.net.ssl.*;
2828
import java.lang.reflect.Type;
29+
import java.security.KeyManagementException;
30+
import java.security.NoSuchAlgorithmException;
2931
import java.security.cert.CertificateException;
3032
import java.security.cert.X509Certificate;
3133
import java.time.LocalDate;
@@ -65,8 +67,10 @@ public X509Certificate[] getAcceptedIssuers() {
6567
try {
6668
trustAllSslContext = SSLContext.getInstance("SSL");
6769
trustAllSslContext.init(null, trustAllCerts, new java.security.SecureRandom());
68-
} catch (Exception e) {
69-
throw new RuntimeException("Failed to initialize trust-all SSL context", e);
70+
} catch (NoSuchAlgorithmException e) {
71+
throw new RuntimeException("SSL algorithm not available", e);
72+
} catch (KeyManagementException e) {
73+
throw new RuntimeException("Failed to initialize SSL key management", e);
7074
}
7175
}
7276

src/main/java/org/mifos/workflow/config/WorkflowConfig.java

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class WorkflowConfig {
1515

1616
private Engine engine = new Engine();
1717
private Fineract fineract = new Fineract();
18+
private Authentication authentication = new Authentication();
19+
private Process process = new Process();
1820

1921
@Data
2022
public static class Engine {
@@ -26,14 +28,40 @@ public static class Engine {
2628
public static class Flowable {
2729
private boolean asyncExecutorEnabled = true;
2830
private boolean databaseSchemaUpdate = true;
31+
private boolean historyEnabled = true;
32+
private String databaseType = "mysql";
33+
private String databaseUrl;
34+
private String databaseUsername;
35+
private String databasePassword;
2936
}
3037

3138
@Data
3239
public static class Fineract {
33-
private String baseUrl = "http://localhost:8443/fineract-provider/api/v1/";
34-
private String username = "mifos";
35-
private String password = "password";
36-
private String tenantId = "default";
40+
private String baseUrl;
41+
private String username;
42+
private String password;
43+
private String tenantId;
44+
private boolean testEnabled;
45+
private int connectionTimeout = 30000;
46+
private int readTimeout = 30000;
3747
}
3848

49+
@Data
50+
public static class Authentication {
51+
private boolean enabled = true;
52+
private String authKeyHeader = "Authorization";
53+
private String authKeyPrefix = "Basic ";
54+
private int tokenRefreshInterval = 3600;
55+
private boolean autoRefresh = true;
56+
}
57+
58+
@Data
59+
public static class Process {
60+
private String defaultAssignee = "system";
61+
private boolean autoDeploy = true;
62+
private String processLocation = "classpath:processes/";
63+
private boolean enableProcessHistory = true;
64+
private int maxProcessInstances = 1000;
65+
private int processTimeout = 86400;
66+
}
3967
}

src/main/java/org/mifos/workflow/core/engine/WorkflowEngineFactory.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.springframework.beans.factory.annotation.Autowired;
1010
import org.springframework.stereotype.Component;
1111

12-
1312
/**
1413
* Factory class for creating instances of WorkflowEngine based on configuration.
1514
* This implements the factory pattern to support dynamic selection of workflow engines.
@@ -20,30 +19,32 @@ public class WorkflowEngineFactory {
2019
private static final Logger logger = LoggerFactory.getLogger(WorkflowEngineFactory.class);
2120

2221
private final WorkflowConfig properties;
22+
private final FlowableWorkflowEngine flowableWorkflowEngine;
2323

2424
@Getter
2525
private WorkflowEngine workflowEngine;
2626

2727
@Autowired
28-
public WorkflowEngineFactory(WorkflowConfig properties) {
28+
public WorkflowEngineFactory(WorkflowConfig properties, FlowableWorkflowEngine flowableWorkflowEngine) {
2929
this.properties = properties;
30+
this.flowableWorkflowEngine = flowableWorkflowEngine;
3031
}
3132

3233
@PostConstruct
3334
private void init() {
34-
String engineType = properties.getEngine().getType().toLowerCase();
35+
String engineType = properties.getEngine().getType().trim().toLowerCase();
3536
logger.info("Initializing workflow engine of type: {}", engineType);
3637
switch (engineType) {
3738
case "flowable":
38-
this.workflowEngine = new FlowableWorkflowEngine(properties);
39+
this.workflowEngine = flowableWorkflowEngine;
3940
break;
4041
case "temporal":
4142
logger.warn("Temporal engine not yet implemented, falling back to Flowable");
43+
this.workflowEngine = flowableWorkflowEngine;
4244
break;
4345
default:
4446
logger.error("Unsupported workflow engine type: {}", engineType);
4547
throw new IllegalArgumentException("Unsupported workflow engine type: " + engineType);
4648
}
4749
}
48-
4950
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.mifos.workflow.core.engine.delegates;
2+
3+
import org.flowable.engine.delegate.DelegateExecution;
4+
import org.flowable.engine.delegate.JavaDelegate;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
8+
/**
9+
* Delegate for verifying client accounts in the Fineract system.
10+
* This is a placeholder implementation.
11+
* Full implementation will be provided later.
12+
*/
13+
public class AccountVerificationDelegate implements JavaDelegate {
14+
15+
private static final Logger logger = LoggerFactory.getLogger(AccountVerificationDelegate.class);
16+
17+
@Override
18+
public void execute(DelegateExecution execution) {
19+
// TODO: Implement account verification logic
20+
logger.info("AccountVerificationDelegate.execute() called - placeholder implementation");
21+
logger.info("Process instance ID: {}", execution.getProcessInstanceId());
22+
logger.info("Variables: {}", execution.getVariables());
23+
24+
Long clientId = (Long) execution.getVariable("clientId");
25+
if (clientId == null) {
26+
throw new IllegalArgumentException("clientId is missing from process variables");
27+
}
28+
// String clientIdStr = clientId.toString();
29+
logger.info("Would verify accounts for client {}", clientId);
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.mifos.workflow.core.engine.delegates;
2+
3+
import org.flowable.engine.delegate.DelegateExecution;
4+
import org.flowable.engine.delegate.JavaDelegate;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
8+
/**
9+
* Delegate for activating a client in the Fineract system.
10+
* This is a placeholder implementation.
11+
* Full implementation will be provided later.
12+
*/
13+
public class ClientActivationDelegate implements JavaDelegate {
14+
15+
private static final Logger logger = LoggerFactory.getLogger(ClientActivationDelegate.class);
16+
17+
@Override
18+
public void execute(DelegateExecution execution) {
19+
// TODO: Implement client activation logic
20+
logger.info("ClientActivationDelegate.execute() called - placeholder implementation");
21+
logger.info("Process instance ID: {}", execution.getProcessInstanceId());
22+
logger.info("Variables: {}", execution.getVariables());
23+
24+
Long clientId = (Long) execution.getVariable("clientId");
25+
if (clientId == null) {
26+
throw new IllegalArgumentException("clientId is missing from process variables");
27+
}
28+
// String clientIdStr = clientId.toString();
29+
logger.info("Would activate client with ID: {}", clientId);
30+
}
31+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.mifos.workflow.core.engine.delegates;
2+
3+
import org.flowable.engine.delegate.DelegateExecution;
4+
import org.flowable.engine.delegate.JavaDelegate;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
8+
/**
9+
* Delegate for closing a client in the Fineract system.
10+
* This is a placeholder implementation.
11+
* Full implementation will be provided later.
12+
*/
13+
public class ClientClosureDelegate implements JavaDelegate {
14+
15+
private static final Logger logger = LoggerFactory.getLogger(ClientClosureDelegate.class);
16+
17+
@Override
18+
public void execute(DelegateExecution execution) {
19+
// TODO: Implement client closure logic
20+
logger.info("ClientClosureDelegate.execute() called - placeholder implementation");
21+
logger.info("Process instance ID: {}", execution.getProcessInstanceId());
22+
logger.info("Variables: {}", execution.getVariables());
23+
24+
Long clientId = (Long) execution.getVariable("clientId");
25+
if (clientId == null) {
26+
throw new IllegalArgumentException("clientId is missing from process variables");
27+
}
28+
Long closureReasonId = (Long) execution.getVariable("closureReasonId");
29+
if (closureReasonId == null) {
30+
throw new IllegalArgumentException("closureReasonId is missing from process variables");
31+
}
32+
logger.info("Would close client {} with reason ID: {}", clientId, closureReasonId);
33+
}
34+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.mifos.workflow.core.engine.delegates;
2+
3+
import org.flowable.engine.delegate.DelegateExecution;
4+
import org.flowable.engine.delegate.JavaDelegate;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
8+
/**
9+
* Delegate for creating a new client in the Fineract system.
10+
* This is a placeholder implementation.
11+
* Full implementation will be provided later.
12+
*/
13+
public class ClientCreationDelegate implements JavaDelegate {
14+
15+
private static final Logger logger = LoggerFactory.getLogger(ClientCreationDelegate.class);
16+
17+
@Override
18+
public void execute(DelegateExecution execution) {
19+
// TODO: Implement client creation logic
20+
logger.info("ClientCreationDelegate.execute() called - placeholder implementation");
21+
logger.info("Process instance ID: {}", execution.getProcessInstanceId());
22+
logger.info("Variables: {}", execution.getVariables());
23+
24+
execution.setVariable("clientId", System.currentTimeMillis());
25+
}
26+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.mifos.workflow.core.engine.delegates;
2+
3+
import org.flowable.engine.delegate.DelegateExecution;
4+
import org.flowable.engine.delegate.JavaDelegate;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
8+
/**
9+
* Delegate for rejecting a client in the Fineract system.
10+
* This is a placeholder implementation.
11+
* Full implementation will be provided later.
12+
*/
13+
public class ClientRejectionDelegate implements JavaDelegate {
14+
15+
private static final Logger logger = LoggerFactory.getLogger(ClientRejectionDelegate.class);
16+
17+
@Override
18+
public void execute(DelegateExecution execution) {
19+
// TODO: Implement client rejection logic
20+
logger.info("ClientRejectionDelegate.execute() called - placeholder implementation");
21+
logger.info("Process instance ID: {}", execution.getProcessInstanceId());
22+
logger.info("Variables: {}", execution.getVariables());
23+
24+
Long clientId = (Long) execution.getVariable("clientId");
25+
if (clientId == null) {
26+
throw new IllegalArgumentException("clientId is missing from process variables");
27+
}
28+
String rejectionReason = (String) execution.getVariable("rejectionReason");
29+
logger.info("Would reject client with ID: {} for reason: {}", clientId, rejectionReason);
30+
}
31+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.mifos.workflow.core.engine.delegates;
2+
3+
import org.flowable.engine.delegate.DelegateExecution;
4+
import org.flowable.engine.delegate.JavaDelegate;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
8+
/**
9+
* Delegate for transferring a client in the Fineract system.
10+
* This is a placeholder implementation.
11+
* Full implementation will be provided later.
12+
*/
13+
public class ClientTransferDelegate implements JavaDelegate {
14+
15+
private static final Logger logger = LoggerFactory.getLogger(ClientTransferDelegate.class);
16+
17+
@Override
18+
public void execute(DelegateExecution execution) {
19+
// TODO: Implement client transfer logic
20+
logger.info("ClientTransferDelegate.execute() called - placeholder implementation");
21+
logger.info("Process instance ID: {}", execution.getProcessInstanceId());
22+
logger.info("Variables: {}", execution.getVariables());
23+
24+
Long clientId = (Long) execution.getVariable("clientId");
25+
if (clientId == null) {
26+
throw new IllegalArgumentException("clientId is missing from process variables");
27+
}
28+
Long destinationOfficeId = (Long) execution.getVariable("destinationOfficeId");
29+
if (destinationOfficeId == null) {
30+
throw new IllegalArgumentException("destinationOfficeId is missing from process variables");
31+
}
32+
logger.info("Would transfer client {} to office {}", clientId, destinationOfficeId);
33+
}
34+
}

0 commit comments

Comments
 (0)