Skip to content

Commit

Permalink
Don't ignore workflow-module-id for loading resources
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanpelikan committed Jan 12, 2024
1 parent 0d889f7 commit 0da5cfe
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package io.vanillabp.springboot.adapter;

import io.vanillabp.springboot.modules.WorkflowModuleProperties;
import io.vanillabp.springboot.utils.WorkflowAndModule;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -61,7 +63,7 @@ private void deployWorkflowModule(
private String resourcesPath(
final String workflowModuleId) {

return properties
final var adaptersPath = properties
.getAdapters()
.entrySet()
.stream()
Expand All @@ -71,6 +73,20 @@ private String resourcesPath(
.or(() -> Optional.ofNullable(properties.getResourcesPath()))
.orElse(DEFAULT_RESOURCES_PATH);

if (workflowModuleId == null) {
return adaptersPath;
}

final var workflowModulePath = properties
.getWorkflows()
.stream()
.filter(workflowAndModuleAdapters -> workflowAndModuleAdapters.matches(workflowModuleId))
.findFirst()
.map(WorkflowAndModule::getResourcesPath)
.orElseGet(() -> workflowModuleId);

return adaptersPath + File.separator + workflowModulePath;

}

protected abstract void doDeployment(
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/io/vanillabp/springboot/utils/WorkflowAndModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class WorkflowAndModule {
private String workflowModuleId;

private String bpmnProcessId;

private String resourcesPath;

public String getBpmnProcessId() {
return bpmnProcessId;
Expand All @@ -24,6 +26,14 @@ public void setWorkflowModuleId(String workflowModuleId) {
this.workflowModuleId = workflowModuleId;
}

public String getResourcesPath() {
return resourcesPath;
}

public void setResourcesPath(String resourcesPath) {
this.resourcesPath = resourcesPath;
}

public boolean matches(
final String workflowModuleId) {

Expand Down

0 comments on commit 0da5cfe

Please sign in to comment.