diff --git a/examples/pom.xml b/examples/pom.xml index ec165c8ec..ef69089ac 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -17,7 +17,21 @@ pom + + + + io.miranum.platform + miranum-deployment-server-embedded-starter + ${project.version} + + + io.miranum.platform + miranum-unit-test + ${project.version} + test + + diff --git a/examples/single-deployment-unit-example/pom.xml b/examples/single-deployment-unit-example/pom.xml index 9f7a801d2..4cbee0f0a 100644 --- a/examples/single-deployment-unit-example/pom.xml +++ b/examples/single-deployment-unit-example/pom.xml @@ -16,6 +16,18 @@ org.springframework.boot spring-boot-starter-web + + + io.miranum.platform + miranum-deployment-server-embedded-starter + + + + + io.miranum.platform + miranum-unit-test + test + diff --git a/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/DeploymentReceiverAdapter.java b/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/DeploymentReceiverAdapter.java new file mode 100644 index 000000000..7d05cebe4 --- /dev/null +++ b/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/DeploymentReceiverAdapter.java @@ -0,0 +1,30 @@ +package io.miranum.platform.example.adapter.out.deployment; + +import io.miranum.platform.deploymentreceiver.application.DeploymentFailedException; +import io.miranum.platform.deploymentreceiver.application.ports.out.MiranumDeploymentReceiver; +import io.miranum.platform.deploymentreceiver.domain.Deployment; +import io.miranum.platform.example.adapter.out.deployment.handler.DeploymentHandler; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +@RequiredArgsConstructor +@Slf4j +public class DeploymentReceiverAdapter implements MiranumDeploymentReceiver { + + private final List deploymentHandlers; + + @Override + public void deploy(final Deployment deployment) { + this.deploymentHandlers.stream() + .filter(handler -> handler.isResponsibleFor(deployment.getType())) + .findFirst() + .ifPresentOrElse(handler -> handler.deployArtifact(deployment), () -> { + throw new DeploymentFailedException("No handler found for deployment type " + deployment.getType()); + }); + } + +} diff --git a/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/BpmnDeploymentHandler.java b/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/BpmnDeploymentHandler.java new file mode 100644 index 000000000..7c9acec86 --- /dev/null +++ b/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/BpmnDeploymentHandler.java @@ -0,0 +1,25 @@ +package io.miranum.platform.example.adapter.out.deployment.handler; + +import io.miranum.platform.deploymentreceiver.application.DeploymentFailedException; +import io.miranum.platform.deploymentreceiver.domain.Deployment; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +@Slf4j +public class BpmnDeploymentHandler implements DeploymentHandler { + @Override + public boolean isResponsibleFor(final String artifactType) { + return artifactType.equalsIgnoreCase("bpmn"); + } + + @Override + public void deployArtifact(final Deployment artifact) throws DeploymentFailedException { + // TODO implement me + log.info("Deploy file {} of type {} to namespace {} with tags {}", + artifact.getFilename(), artifact.getType(), artifact.getNamespace(), artifact.getTags()); + } + +} diff --git a/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/ConfigurationDeploymentHandler.java b/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/ConfigurationDeploymentHandler.java new file mode 100644 index 000000000..a29966883 --- /dev/null +++ b/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/ConfigurationDeploymentHandler.java @@ -0,0 +1,30 @@ +package io.miranum.platform.example.adapter.out.deployment.handler; + + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.miranum.platform.deploymentreceiver.application.DeploymentFailedException; +import io.miranum.platform.deploymentreceiver.domain.Deployment; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +@Slf4j +public class ConfigurationDeploymentHandler implements DeploymentHandler { + + private final ObjectMapper objectMapper = new ObjectMapper(); + + @Override + public boolean isResponsibleFor(final String artifactType) { + return artifactType.equalsIgnoreCase("config"); + } + + @Override + public void deployArtifact(final Deployment artifact) throws DeploymentFailedException { + // TODO implement me + log.info("Deploy file {} of type {} to namespace {} with tags {}", + artifact.getFilename(), artifact.getType(), artifact.getNamespace(), artifact.getTags()); + } + +} diff --git a/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/DeploymentHandler.java b/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/DeploymentHandler.java new file mode 100644 index 000000000..85681655d --- /dev/null +++ b/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/DeploymentHandler.java @@ -0,0 +1,16 @@ +package io.miranum.platform.example.adapter.out.deployment.handler; + +import io.miranum.platform.deploymentreceiver.application.DeploymentFailedException; +import io.miranum.platform.deploymentreceiver.domain.Deployment; + +/** + * Handle deployment for specific types + */ +public interface DeploymentHandler { + + boolean isResponsibleFor(String artifactType); + + void deployArtifact(final Deployment artifact) throws DeploymentFailedException; + + +} diff --git a/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/DmnDeploymentHandler.java b/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/DmnDeploymentHandler.java new file mode 100644 index 000000000..2e0f54416 --- /dev/null +++ b/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/DmnDeploymentHandler.java @@ -0,0 +1,27 @@ +package io.miranum.platform.example.adapter.out.deployment.handler; + + +import io.miranum.platform.deploymentreceiver.application.DeploymentFailedException; +import io.miranum.platform.deploymentreceiver.domain.Deployment; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +@Slf4j +public class DmnDeploymentHandler implements DeploymentHandler { + + @Override + public boolean isResponsibleFor(final String artifactType) { + return artifactType.equalsIgnoreCase("dmn"); + } + + @Override + public void deployArtifact(Deployment artifact) throws DeploymentFailedException { + // TODO implement me + log.info("Deploy file {} of type {} to namespace {} with tags {}", + artifact.getFilename(), artifact.getType(), artifact.getNamespace(), artifact.getTags()); + } + +} diff --git a/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/FormDeploymentHandler.java b/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/FormDeploymentHandler.java new file mode 100644 index 000000000..10d570a3d --- /dev/null +++ b/examples/single-deployment-unit-example/src/main/java/io/miranum/platform/example/adapter/out/deployment/handler/FormDeploymentHandler.java @@ -0,0 +1,26 @@ +package io.miranum.platform.example.adapter.out.deployment.handler; + + +import io.miranum.platform.deploymentreceiver.domain.Deployment; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +@Slf4j +public class FormDeploymentHandler implements DeploymentHandler { + + @Override + public boolean isResponsibleFor(final String artifactType) { + return artifactType.equalsIgnoreCase("form"); + } + + @Override + public void deployArtifact(final Deployment artifact) { + // TODO implement me + log.info("Deploy file {} of type {} to namespace {} with tags {}", + artifact.getFilename(), artifact.getType(), artifact.getNamespace(), artifact.getTags()); + } + +} diff --git a/resources/example-process/miranum.json b/resources/example-process/miranum.json index f0ce9aa15..75c3f91ee 100644 --- a/resources/example-process/miranum.json +++ b/resources/example-process/miranum.json @@ -19,6 +19,10 @@ { "name": "rest", "url": "http://localhost:9001" + }, + { + "name": "singleDeploymentUnit", + "url": "http://localhost:8083" } ] } diff --git a/resources/example-process/package.json b/resources/example-process/package.json index fe792473f..5ce80816b 100644 --- a/resources/example-process/package.json +++ b/resources/example-process/package.json @@ -5,7 +5,8 @@ "scripts": { "deploy:all": "npm run deploy:embedded && npm run deploy:rest", "deploy:embedded": "npx @miragon/miranum-cli deploy -d . -t embedded", - "deploy:rest": "npx @miragon/miranum-cli deploy -d . -t rest" + "deploy:rest": "npx @miragon/miranum-cli deploy -d . -t rest", + "deploy:singleDeploymentUnit": "npx @miragon/miranum-cli deploy -d . -t singleDeploymentUnit" }, "author": "lmoesle", "license": "MIT",