Skip to content

Commit d758194

Browse files
authored
Add the spotfire configuration.
Run initial checks. (#119)
1 parent 18863ff commit d758194

File tree

531 files changed

+16354
-16326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

531 files changed

+16354
-16326
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
root = true
2+
3+
[*.java]
4+
indent_style = space
5+
indent_size = 2
6+
ij_java_continuation_indent_size = 4

.github/workflows/component-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Configure Java version
1515
uses: actions/setup-java@v4
1616
with:
17-
java-version: '21'
17+
java-version: '24'
1818
distribution: 'temurin'
1919
architecture: x64
2020
- name: Prepare gradle installation

.github/workflows/main-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Configure Java version
2222
uses: actions/setup-java@v4
2323
with:
24-
java-version: '21'
24+
java-version: '24'
2525
distribution: 'temurin'
2626
architecture: x64
2727
- name: Download build artifact

.github/workflows/pull-request-gate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Configure Java version
2121
uses: actions/setup-java@v4
2222
with:
23-
java-version: '21'
23+
java-version: '24'
2424
distribution: 'temurin'
2525
architecture: x64
2626
- name: Download build artifact

.github/workflows/release-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Configure Java version
2121
uses: actions/setup-java@v4
2222
with:
23-
java-version: '21'
23+
java-version: '24'
2424
distribution: 'temurin'
2525
architecture: x64
2626
- name: Download build artifact

bpmn-process/src/main/java/com/jongsoft/finance/ProcessMapper.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,35 @@
88

99
@Slf4j
1010
@Singleton
11-
public class ProcessMapper {
12-
13-
private final ObjectMapper objectMapper;
14-
15-
public ProcessMapper(ObjectMapper objectMapper) {
16-
this.objectMapper = objectMapper;
17-
}
18-
19-
20-
public <T> String writeSafe(T entity) {
21-
return Control.Try(() -> objectMapper.writeValueAsString(entity))
22-
.recover(x -> {
23-
log.warn("Could not serialize entity {}", entity, x);
24-
return null;
25-
})
26-
.get();
27-
}
28-
29-
public <T> T readSafe(String json, Class<T> clazz) {
30-
return Control.Try(() -> objectMapper.readValue(json, clazz))
31-
.recover(x -> {
32-
log.warn("Could not deserialize json {}", json, x);
33-
return null;
34-
})
35-
.get();
36-
}
37-
38-
public <T> Try<T> read(String json, Class<T> clazz) {
39-
return Control.Try(() -> objectMapper.readValue(json, clazz));
40-
}
41-
11+
public class ProcessMapper {
12+
13+
private final ObjectMapper objectMapper;
14+
15+
public ProcessMapper(ObjectMapper objectMapper) {
16+
this.objectMapper = objectMapper;
17+
}
18+
19+
public <T> String writeSafe(T entity) {
20+
return Control.Try(() -> objectMapper.writeValueAsString(entity))
21+
.recover(
22+
x -> {
23+
log.warn("Could not serialize entity {}", entity, x);
24+
return null;
25+
})
26+
.get();
27+
}
28+
29+
public <T> T readSafe(String json, Class<T> clazz) {
30+
return Control.Try(() -> objectMapper.readValue(json, clazz))
31+
.recover(
32+
x -> {
33+
log.warn("Could not deserialize json {}", json, x);
34+
return null;
35+
})
36+
.get();
37+
}
38+
39+
public <T> Try<T> read(String json, Class<T> clazz) {
40+
return Control.Try(() -> objectMapper.readValue(json, clazz));
41+
}
4242
}

bpmn-process/src/main/java/com/jongsoft/finance/ProcessVariable.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,5 @@
22

33
import com.fasterxml.jackson.annotation.JsonTypeInfo;
44

5-
import java.io.Serializable;
6-
75
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "_type")
8-
public interface ProcessVariable {
9-
}
6+
public interface ProcessVariable {}

bpmn-process/src/main/java/com/jongsoft/finance/bpmn/KnownProcesses.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22

33
public class KnownProcesses {
44

5-
private KnownProcesses() {
6-
// private constructor
7-
}
5+
private KnownProcesses() {
6+
// private constructor
7+
}
88

9-
/**
10-
* The process identifier for the process that monitors for contract ending and sends the user a notification
11-
* before hand.
12-
*/
13-
public static final String CONTRACT_WARN_EXPIRY = "ContractEndWarning";
14-
15-
/**
16-
* The process identifier for the process that handles any type of scheduling.
17-
*/
18-
public static final String PROCESS_SCHEDULE = "ProcessScheduler";
9+
/**
10+
* The process identifier for the process that monitors for contract ending and sends the user a
11+
* notification before hand.
12+
*/
13+
public static final String CONTRACT_WARN_EXPIRY = "ContractEndWarning";
1914

15+
/** The process identifier for the process that handles any type of scheduling. */
16+
public static final String PROCESS_SCHEDULE = "ProcessScheduler";
2017
}
Lines changed: 85 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package com.jongsoft.finance.bpmn;
22

3+
import static org.springframework.core.io.support.ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX;
4+
35
import com.jongsoft.finance.ProcessVariable;
46
import com.jongsoft.finance.bpmn.camunda.*;
57
import com.jongsoft.finance.importer.api.TransactionDTO;
68
import io.micronaut.context.ApplicationContext;
79
import io.micronaut.context.annotation.Bean;
810
import io.micronaut.context.annotation.Factory;
9-
import io.micronaut.context.annotation.Requirements;
1011
import io.micronaut.context.annotation.Requires;
1112
import io.micronaut.serde.ObjectMapper;
13+
import java.io.IOException;
14+
import java.util.List;
1215
import lombok.extern.slf4j.Slf4j;
1316
import org.camunda.bpm.engine.HistoryService;
1417
import org.camunda.bpm.engine.ProcessEngine;
@@ -18,88 +21,90 @@
1821
import org.springframework.core.io.Resource;
1922
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
2023

21-
import java.io.IOException;
22-
import java.util.List;
23-
2424
@Slf4j
2525
@Factory
26-
@Requirements({
27-
@Requires(notEnv = "no-camunda")})
26+
@Requires(notEnv = "no-camunda")
2827
public class ProcessEngineConfiguration {
2928

30-
private final ApplicationContext applicationContext;
31-
private final CamundaDatasourceConfiguration camundaDatasourceConfiguration;
32-
33-
public ProcessEngineConfiguration(
34-
ApplicationContext applicationContext,
35-
CamundaDatasourceConfiguration camundaDatasourceConfiguration) {
36-
this.applicationContext = applicationContext;
37-
this.camundaDatasourceConfiguration = camundaDatasourceConfiguration;
29+
private final ApplicationContext applicationContext;
30+
private final CamundaDatasourceConfiguration camundaDatasourceConfiguration;
31+
32+
public ProcessEngineConfiguration(
33+
ApplicationContext applicationContext,
34+
CamundaDatasourceConfiguration camundaDatasourceConfiguration) {
35+
this.applicationContext = applicationContext;
36+
this.camundaDatasourceConfiguration = camundaDatasourceConfiguration;
37+
}
38+
39+
@Bean
40+
public ProcessEngine processEngine() throws IOException {
41+
var configuration = new StandaloneProcessEngineConfiguration();
42+
43+
configuration
44+
.setHistory(camundaDatasourceConfiguration.getHistoryLevel())
45+
.setJobExecutorActivate(true)
46+
.setMetricsEnabled(true)
47+
.setJdbcDriver(camundaDatasourceConfiguration.getDriverClassName())
48+
.setJdbcUrl(camundaDatasourceConfiguration.getUrl())
49+
.setJdbcUsername(camundaDatasourceConfiguration.getUsername())
50+
.setJdbcPassword(camundaDatasourceConfiguration.getPassword())
51+
.setDatabaseSchemaUpdate(camundaDatasourceConfiguration.getAutoUpdate())
52+
.setProcessEngineName("fintrack")
53+
.setHistoryCleanupEnabled(true)
54+
.setSkipIsolationLevelCheck(true)
55+
.setExpressionManager(
56+
new MicronautExpressionManager(new MicronautElResolver(applicationContext)));
57+
58+
configuration.setHistoryCleanupBatchSize(250);
59+
configuration.setHistoryCleanupBatchWindowStartTime("01:00");
60+
configuration.setHistoryCleanupBatchWindowEndTime("03:00");
61+
configuration.setHistoryTimeToLive("P1D");
62+
configuration.setResolverFactories(List.of(new MicronautBeanResolver(applicationContext)));
63+
configuration.setCustomPreVariableSerializers(
64+
List.of(
65+
new JsonRecordSerializer<>(
66+
applicationContext.getBean(ObjectMapper.class), ProcessVariable.class),
67+
new JsonRecordSerializer<>(
68+
applicationContext.getBean(ObjectMapper.class), TransactionDTO.class)));
69+
70+
var processEngine = configuration.buildProcessEngine();
71+
log.info("Created camunda process engine");
72+
73+
deployResources(processEngine);
74+
return processEngine;
75+
}
76+
77+
@Bean
78+
public HistoryService historyService(ProcessEngine processEngine) {
79+
return processEngine.getHistoryService();
80+
}
81+
82+
@Bean
83+
public TaskService taskService(ProcessEngine processEngine) {
84+
return processEngine.getTaskService();
85+
}
86+
87+
@Bean
88+
public RuntimeService runtimeService(ProcessEngine processEngine) {
89+
return processEngine.getRuntimeService();
90+
}
91+
92+
private void deployResources(ProcessEngine processEngine) throws IOException {
93+
log.info("Searching for deployable camunda processes");
94+
95+
PathMatchingResourcePatternResolver resourceLoader = new PathMatchingResourcePatternResolver();
96+
for (String extension : List.of("dmn", "cmmn", "bpmn")) {
97+
for (Resource resource :
98+
resourceLoader.getResources(CLASSPATH_ALL_URL_PREFIX + extension + "/*/*." + extension)) {
99+
log.info("Deploying model: {}", resource.getFilename());
100+
processEngine
101+
.getRepositoryService()
102+
.createDeployment()
103+
.name("MicronautAutoDeployment")
104+
.addInputStream(resource.getFilename(), resource.getInputStream())
105+
.enableDuplicateFiltering(true)
106+
.deploy();
107+
}
38108
}
39-
40-
@Bean
41-
public ProcessEngine processEngine() throws IOException {
42-
var configuration = new StandaloneProcessEngineConfiguration();
43-
44-
configuration.setHistory(camundaDatasourceConfiguration.getHistoryLevel())
45-
.setJobExecutorActivate(true)
46-
.setMetricsEnabled(true)
47-
.setJdbcDriver(camundaDatasourceConfiguration.getDriverClassName())
48-
.setJdbcUrl(camundaDatasourceConfiguration.getUrl())
49-
.setJdbcUsername(camundaDatasourceConfiguration.getUsername())
50-
.setJdbcPassword(camundaDatasourceConfiguration.getPassword())
51-
.setDatabaseSchemaUpdate(camundaDatasourceConfiguration.getAutoUpdate())
52-
.setProcessEngineName("fintrack")
53-
.setHistoryCleanupEnabled(true)
54-
.setSkipIsolationLevelCheck(true)
55-
.setExpressionManager(new MicronautExpressionManager(new MicronautElResolver(applicationContext)));
56-
57-
configuration.setHistoryCleanupBatchSize(250);
58-
configuration.setHistoryCleanupBatchWindowStartTime("01:00");
59-
configuration.setHistoryCleanupBatchWindowEndTime("03:00");
60-
configuration.setHistoryTimeToLive("P1D");
61-
configuration.setResolverFactories(List.of(new MicronautBeanResolver(applicationContext)));
62-
configuration.setCustomPreVariableSerializers(List.of(
63-
new JsonRecordSerializer<>(applicationContext.getBean(ObjectMapper.class), ProcessVariable.class),
64-
new JsonRecordSerializer<>(applicationContext.getBean(ObjectMapper.class), TransactionDTO.class)));
65-
66-
var processEngine = configuration.buildProcessEngine();
67-
log.info("Created camunda process engine");
68-
69-
deployResources(processEngine);
70-
return processEngine;
71-
}
72-
73-
@Bean
74-
public HistoryService historyService(ProcessEngine processEngine) {
75-
return processEngine.getHistoryService();
76-
}
77-
78-
@Bean
79-
public TaskService taskService(ProcessEngine processEngine) {
80-
return processEngine.getTaskService();
81-
}
82-
83-
@Bean
84-
public RuntimeService runtimeService(ProcessEngine processEngine) {
85-
return processEngine.getRuntimeService();
86-
}
87-
88-
private void deployResources(ProcessEngine processEngine) throws IOException {
89-
log.info("Searching for deployable camunda processes");
90-
91-
PathMatchingResourcePatternResolver resourceLoader = new PathMatchingResourcePatternResolver();
92-
for (String extension : List.of("dmn", "cmmn", "bpmn")) {
93-
for (Resource resource :
94-
resourceLoader.getResources(PathMatchingResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + extension + "/*/*." + extension)) {
95-
log.info("Deploying model: {}", resource.getFilename());
96-
processEngine.getRepositoryService().createDeployment()
97-
.name("MicronautAutoDeployment")
98-
.addInputStream(resource.getFilename(), resource.getInputStream())
99-
.enableDuplicateFiltering(true)
100-
.deploy();
101-
}
102-
}
103-
}
104-
109+
}
105110
}

bpmn-process/src/main/java/com/jongsoft/finance/bpmn/camunda/CamundaDatasourceConfiguration.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,26 @@
88
@ConfigurationProperties("datasources.default")
99
public interface CamundaDatasourceConfiguration {
1010

11-
@Bindable(defaultValue = "jdbc:h2:mem:fintrack;DB_CLOSE_DELAY=1000")
12-
@NotBlank
13-
String getUrl();
11+
@Bindable(defaultValue = "jdbc:h2:mem:fintrack;DB_CLOSE_DELAY=1000")
12+
@NotBlank
13+
String getUrl();
1414

15-
@Bindable(defaultValue = "sa")
16-
@NotBlank
17-
String getUsername();
15+
@Bindable(defaultValue = "sa")
16+
@NotBlank
17+
String getUsername();
1818

19-
@Bindable(defaultValue = "")
20-
@NotNull
21-
String getPassword();
19+
@Bindable(defaultValue = "")
20+
@NotNull
21+
String getPassword();
2222

23-
@Bindable(defaultValue = "org.h2.Driver")
24-
@NotBlank
25-
String getDriverClassName();
23+
@Bindable(defaultValue = "org.h2.Driver")
24+
@NotBlank
25+
String getDriverClassName();
2626

27-
@Bindable(defaultValue = "false")
28-
@NotBlank
29-
String getAutoUpdate();
30-
31-
@Bindable(defaultValue = "auto")
32-
String getHistoryLevel();
27+
@Bindable(defaultValue = "false")
28+
@NotBlank
29+
String getAutoUpdate();
3330

31+
@Bindable(defaultValue = "auto")
32+
String getHistoryLevel();
3433
}

0 commit comments

Comments
 (0)