Skip to content

Commit

Permalink
Moved the bpmn files. Updated the UI. Added a new GH based workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWittmann committed Jan 11, 2024
1 parent 7f9d05c commit d430088
Show file tree
Hide file tree
Showing 50 changed files with 5,754 additions and 154 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/build-hub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ jobs:
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Build Workflows Client (required, not yet in Maven Central)
run: |
cd workflows
mvn install -Dmaven.javadoc.skip=true --no-transfer-progress -DtrimStackTrace=false
- name: Build Apicurio API Lifecycle Hub
run: |
cd hub
Expand Down
20 changes: 7 additions & 13 deletions hub/app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
<name>apicurio-api-lifecycle-hub-app</name>

<dependencies>
<!-- Project Components -->
<dependency>
<groupId>io.apicurio</groupId>
<artifactId>apicurio-api-lifecycle-hub-clients</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Common App Components -->
<dependency>
<groupId>io.apicurio</groupId>
Expand All @@ -36,13 +43,6 @@
<version>${apicurio-common-app-components.version}</version>
</dependency>

<!-- Workflows Components -->
<dependency>
<groupId>io.apicurio</groupId>
<artifactId>apicurio-api-lifecycle-workflows-client</artifactId>
<version>${apicurio-api-lifecycle-workflows.version}</version>
</dependency>

<!-- Quarkus Dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
Expand Down Expand Up @@ -96,12 +96,6 @@
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.apicurio</groupId>
<artifactId>apicurio-api-lifecycle-hub-client</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.microsoft.kiota.authentication.AnonymousAuthenticationProvider;
import com.microsoft.kiota.http.OkHttpRequestAdapter;

import io.apicurio.lifecycle.workflows.rest.client.LifecycleWorkflowsClient;
import io.apicurio.lifecycle.rest.clients.workflows.LifecycleWorkflowsClient;
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import org.slf4j.Logger;

import io.apicurio.common.apps.content.IoUtil;
import io.apicurio.lifecycle.rest.clients.workflows.LifecycleWorkflowsClient;
import io.apicurio.lifecycle.rest.clients.workflows.models.Event;
import io.apicurio.lifecycle.rest.clients.workflows.models.EventContext;
import io.apicurio.lifecycle.rest.v0.ApisResource;
import io.apicurio.lifecycle.rest.v0.beans.Api;
import io.apicurio.lifecycle.rest.v0.beans.ApiSearchResults;
Expand All @@ -45,15 +48,12 @@
import io.apicurio.lifecycle.storage.dtos.UpdateVersionContentDto;
import io.apicurio.lifecycle.storage.dtos.VersionContentDto;
import io.apicurio.lifecycle.storage.dtos.VersionSearchResultsDto;
import io.apicurio.lifecycle.workflows.rest.client.LifecycleWorkflowsClient;
import io.apicurio.lifecycle.workflows.rest.client.models.Event;
import io.apicurio.lifecycle.workflows.rest.client.models.EventContext;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Context;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.ws.rs.core.Response;

/**
* @author [email protected]
Expand Down Expand Up @@ -145,11 +145,15 @@ public void createVersion(String apiId, @NotNull NewVersion data) {
storage.createVersion(apiId, ToDto.newVersion(data));

// Fire event (trigger workflow)
String workflow = "default";
if (data.getWorkflow() != null && data.getWorkflow().trim().length() > 0) {
workflow = data.getWorkflow();
}
Event event = new Event();
event.setType("version:create");
event.setId(UUID.randomUUID().toString());
event.setContext(new EventContext());
event.getContext().setAdditionalData(Map.of("apiId", apiId, "version", data.getVersion()));
event.getContext().setAdditionalData(Map.of("apiId", apiId, "version", data.getVersion(), "workflow", workflow));
workflowsClient.events().post(event);
}

Expand Down
4 changes: 4 additions & 0 deletions hub/app/src/main/resources/META-INF/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,10 @@
"content": {
"$ref": "#/components/schemas/NewContent",
"description": ""
},
"workflow": {
"description": "",
"type": "string"
}
},
"example": {
Expand Down
3 changes: 3 additions & 0 deletions hub/app/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ app.description=${alh.description}
app.version=${alh.version}
app.date=${alh.date}

quarkus.http.test-port=7071


Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.microsoft.kiota.authentication.AnonymousAuthenticationProvider;
import com.microsoft.kiota.http.OkHttpRequestAdapter;

import io.apicurio.lifecycle.rest.client.LifecycleHubClient;
import io.apicurio.lifecycle.rest.clients.self.LifecycleHubClient;

/**
* @author [email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
import org.junit.jupiter.api.Test;

import io.apicurio.common.apps.content.IoUtil;
import io.apicurio.lifecycle.rest.client.models.Api;
import io.apicurio.lifecycle.rest.client.models.ApiType;
import io.apicurio.lifecycle.rest.client.models.Labels;
import io.apicurio.lifecycle.rest.client.models.NewApi;
import io.apicurio.lifecycle.rest.client.models.NewContent;
import io.apicurio.lifecycle.rest.client.models.NewVersion;
import io.apicurio.lifecycle.rest.client.models.UpdateApi;
import io.apicurio.lifecycle.rest.client.models.UpdateVersion;
import io.apicurio.lifecycle.rest.client.models.Version;
import io.apicurio.lifecycle.rest.client.models.VersionSearchResults;
import io.apicurio.lifecycle.rest.clients.self.models.Api;
import io.apicurio.lifecycle.rest.clients.self.models.ApiType;
import io.apicurio.lifecycle.rest.clients.self.models.Labels;
import io.apicurio.lifecycle.rest.clients.self.models.NewApi;
import io.apicurio.lifecycle.rest.clients.self.models.NewContent;
import io.apicurio.lifecycle.rest.clients.self.models.NewVersion;
import io.apicurio.lifecycle.rest.clients.self.models.UpdateApi;
import io.apicurio.lifecycle.rest.clients.self.models.UpdateVersion;
import io.apicurio.lifecycle.rest.clients.self.models.Version;
import io.apicurio.lifecycle.rest.clients.self.models.VersionSearchResults;
import io.quarkus.test.junit.QuarkusTest;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import io.apicurio.lifecycle.rest.client.models.SystemInfo;
import io.apicurio.lifecycle.rest.clients.self.models.SystemInfo;
import io.quarkus.test.junit.QuarkusTest;

/**
Expand Down
26 changes: 19 additions & 7 deletions hub/client/pom.xml → hub/clients/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<version>0.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>apicurio-api-lifecycle-hub-client</artifactId>
<artifactId>apicurio-api-lifecycle-hub-clients</artifactId>
<packaging>jar</packaging>
<name>apicurio-api-lifecycle-hub-client</name>
<name>apicurio-api-lifecycle-hub-clients</name>
<properties>
<kiota.libs.version>0.7.8</kiota.libs.version>
</properties>
Expand Down Expand Up @@ -64,16 +64,28 @@
<version>0.0.7</version>
<executions>
<execution>
<id>self</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<file>../app/src/main/resources/META-INF/openapi.json</file>
<namespace>io.apicurio.lifecycle.rest.clients.self</namespace>
<clientClass>LifecycleHubClient</clientClass>
</configuration>
</execution>
<execution>
<id>workflows</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<file>../../workflows/app/src/main/resources/META-INF/openapi.json</file>
<namespace>io.apicurio.lifecycle.rest.clients.workflows</namespace>
<clientClass>LifecycleWorkflowsClient</clientClass>
</configuration>
</execution>
</executions>
<configuration>
<file>../app/src/main/resources/META-INF/openapi.json</file>
<namespace>io.apicurio.lifecycle.rest.client</namespace>
<clientClass>LifecycleHubClient</clientClass>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down
2 changes: 1 addition & 1 deletion hub/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

<modules>
<module>app</module>
<module>client</module>
<module>clients</module>
<module>dist/docker</module>
</modules>

Expand Down
32 changes: 26 additions & 6 deletions ui/public/workflow_default.bpmn
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:activiti="http://activiti.org/bpmn" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="workflow_default_defs" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Web Modeler" exporterVersion="50c6516" camunda:diagramRelationId="ea9b8b7a-253b-4ab9-9a98-375be265d47a">
<bpmn2:message id="ApiChangeMessage" name="ApiChangeMessage" />
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:activiti="http://activiti.org/bpmn" id="workflow_default_defs" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Web Modeler" exporterVersion="66740e0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.3.0">
<bpmn2:message id="ApiChangeMessage" name="ApiChangeMessage">
<bpmn2:extensionElements>
<zeebe:subscription correlationKey="=ApiVersionChange" />
</bpmn2:extensionElements>
</bpmn2:message>
<bpmn2:process id="workflow_default" name="Default Workflow" isExecutable="true">
<bpmn2:startEvent id="StartEvent" name="Start">
<bpmn2:extensionElements>
Expand All @@ -10,19 +14,30 @@
<bpmn2:outgoing>toAddWorkflowLabels</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:serviceTask id="AddWorkflowLabels" name="Add Workflow Labels" activiti:class="io.apicurio.lifecycle.workflows.activiti.tasks.AddWorkflowLabelTask">
<bpmn2:extensionElements>
<zeebe:taskDefinition type="main" />
</bpmn2:extensionElements>
<bpmn2:incoming>toAddWorkflowLabels</bpmn2:incoming>
<bpmn2:outgoing>fromAddWorkflowLabelToValidate</bpmn2:outgoing>
</bpmn2:serviceTask>
<bpmn2:serviceTask id="ValidateTask" name="Validate API Design" activiti:class="io.apicurio.lifecycle.workflows.activiti.tasks.ValidateTask">
<bpmn2:extensionElements>
<zeebe:taskDefinition type="main" />
</bpmn2:extensionElements>
<bpmn2:incoming>toValidate</bpmn2:incoming>
<bpmn2:outgoing>toMicrocks</bpmn2:outgoing>
</bpmn2:serviceTask>
<bpmn2:serviceTask id="MicrocksTask" name="Push to Microcks" activiti:class="io.apicurio.lifecycle.workflows.activiti.tasks.MicrocksTask">
<bpmn2:extensionElements />
<bpmn2:extensionElements>
<zeebe:taskDefinition type="main" />
</bpmn2:extensionElements>
<bpmn2:incoming>toMicrocks</bpmn2:incoming>
<bpmn2:outgoing>fromMicrocksToCatchEvent</bpmn2:outgoing>
</bpmn2:serviceTask>
<bpmn2:serviceTask id="RegistryTask" name="Push to Registry" activiti:class="io.apicurio.lifecycle.workflows.activiti.tasks.RegistryTask">
<bpmn2:extensionElements>
<zeebe:taskDefinition type="main" />
</bpmn2:extensionElements>
<bpmn2:incoming>fromApprovalGatewayToRegistry</bpmn2:incoming>
<bpmn2:outgoing>toEnd</bpmn2:outgoing>
</bpmn2:serviceTask>
Expand All @@ -36,7 +51,10 @@
API ${apiId} (version ${version}) is ready to register. Do you approve?
</bpmn2:documentation>
<bpmn2:extensionElements>
<activiti:formProperty id="approval" name="Approval" type="boolean" />
<activiti:formProperty id="registryGroup" name="Group" type="string" value="default" />
<activiti:formProperty id="registryArtifactId" name="Artifact ID" type="string" value="${apiId}" />
<activiti:formProperty id="registryVersion" name="Version" type="string" value="${version}" />
<activiti:formProperty id="approved" name="Approved" type="boolean" />
</bpmn2:extensionElements>
<bpmn2:incoming>toApproval</bpmn2:incoming>
<bpmn2:outgoing>toApprovalGateway</bpmn2:outgoing>
Expand Down Expand Up @@ -68,10 +86,10 @@
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="toApprovalGateway" sourceRef="ApprovalTask" targetRef="ApprovalGateway" />
<bpmn2:sequenceFlow id="fromApprovalGatewayToSetReadOnlyFalse" name="Not Approved" sourceRef="ApprovalGateway" targetRef="SetReadOnlyFalse">
<bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${approval == false}</bpmn2:conditionExpression>
<bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${approved == false}</bpmn2:conditionExpression>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="fromApprovalGatewayToRegistry" name="Approved" sourceRef="ApprovalGateway" targetRef="RegistryTask">
<bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${approval == true}</bpmn2:conditionExpression>
<bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${approved == true}</bpmn2:conditionExpression>
</bpmn2:sequenceFlow>
<bpmn2:exclusiveGateway id="ApiChangedOrCreatedJoin">
<bpmn2:incoming>fromAddWorkflowLabelToValidate</bpmn2:incoming>
Expand All @@ -89,6 +107,7 @@
<bpmn2:serviceTask id="SetReadOnlyTrue" name="Set Read Only (true)" activiti:class="io.apicurio.lifecycle.workflows.activiti.tasks.SetReadOnlyTask">
<bpmn2:extensionElements>
<activiti:field name="isReadOnly" stringValue="true" />
<zeebe:taskDefinition type="main" />
</bpmn2:extensionElements>
<bpmn2:incoming>fromCatchEventGatewayToSetReadOnlyTrue</bpmn2:incoming>
<bpmn2:outgoing>toApproval</bpmn2:outgoing>
Expand All @@ -97,6 +116,7 @@
<bpmn2:serviceTask id="SetReadOnlyFalse" name="Set Read Only (false)" activiti:class="io.apicurio.lifecycle.workflows.activiti.tasks.SetReadOnlyTask">
<bpmn2:extensionElements>
<activiti:field name="isReadOnly" stringValue="false" />
<zeebe:taskDefinition type="main" />
</bpmn2:extensionElements>
<bpmn2:incoming>fromApprovalGatewayToSetReadOnlyFalse</bpmn2:incoming>
<bpmn2:outgoing>fromSetReadOnlyFalseToCatchEvent</bpmn2:outgoing>
Expand Down
Loading

0 comments on commit d430088

Please sign in to comment.