-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing new structure of Spring Boot properties
- Loading branch information
1 parent
ea7565b
commit b7fe56b
Showing
7 changed files
with
138 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
spring-boot/src/main/java/io/vanillabp/camunda8/Camunda8VanillaBpProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package io.vanillabp.camunda8; | ||
|
||
import io.vanillabp.springboot.adapter.VanillaBpProperties; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.util.StringUtils; | ||
|
||
import java.util.Map; | ||
|
||
@ConfigurationProperties(prefix = VanillaBpProperties.PREFIX, ignoreUnknownFields = true) | ||
public class Camunda8VanillaBpProperties { | ||
|
||
private Map<String, WorkflowModuleAdapterProperties> workflowModules = Map.of(); | ||
|
||
public Map<String, WorkflowModuleAdapterProperties> getWorkflowModules() { | ||
return workflowModules; | ||
} | ||
|
||
public void setWorkflowModules(Map<String, WorkflowModuleAdapterProperties> workflowModules) { | ||
|
||
this.workflowModules = workflowModules; | ||
workflowModules.forEach((workflowModuleId, properties) -> { | ||
properties.workflowModuleId = workflowModuleId; | ||
}); | ||
|
||
} | ||
|
||
private static final WorkflowModuleAdapterProperties defaultProperties = new WorkflowModuleAdapterProperties(); | ||
private static final AdapterConfiguration defaultAdapterProperties = new AdapterConfiguration(); | ||
|
||
public String getTenantId( | ||
final String workflowModuleId) { | ||
|
||
final var configuration = workflowModules | ||
.getOrDefault(workflowModuleId, defaultProperties) | ||
.getAdapters() | ||
.getOrDefault(Camunda8AdapterConfiguration.ADAPTER_ID, defaultAdapterProperties); | ||
if (!configuration.isUseTenants()) { | ||
return null; | ||
} | ||
if (StringUtils.hasText(configuration.getTenant())) { | ||
return configuration.getTenant(); | ||
} | ||
return workflowModuleId; | ||
|
||
} | ||
|
||
public static class AdapterConfiguration { | ||
|
||
private boolean useTenants = true; | ||
|
||
private String tenant; | ||
|
||
public boolean isUseTenants() { | ||
return useTenants; | ||
} | ||
|
||
public void setUseTenants(boolean useTenants) { | ||
this.useTenants = useTenants; | ||
} | ||
|
||
public String getTenant() { | ||
return tenant; | ||
} | ||
|
||
public void setTenant(String tenant) { | ||
this.tenant = tenant; | ||
} | ||
|
||
} | ||
|
||
public static class WorkflowModuleAdapterProperties { | ||
|
||
String workflowModuleId; | ||
|
||
private Map<String, AdapterConfiguration> adapters = Map.of(); | ||
|
||
public Map<String, AdapterConfiguration> getAdapters() { | ||
return adapters; | ||
} | ||
|
||
public void setAdapters(Map<String, AdapterConfiguration> adapters) { | ||
this.adapters = adapters; | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters