Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #527

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->

<link rel="stylesheet" href="/automatiko/css/bootstrap.min.css">
<link rel="stylesheet" href="/automatiko/css/all.css">
<script src="/automatiko/js/jquery.min.js"></script>
<script src="/automatiko/js/popper.min.js"></script>
<script src="/automatiko/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/all.css">
<script src="js/jquery.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>

<!-- optional script that can allow to use more advanced authorization setup such as keycloak etc -->
<script src="/js/automatiko-authorization.js"></script>
<script src="js/automatiko-authorization.js"></script>

<style>
.active-card {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ public MessagingBuildConfig messaging() {
public JobsBuildConfig jobs() {
return new JobsBuildConfig();
}

public RestBuildConfig rest() {
return new RestBuildConfig();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.automatiko.engine.api.config;

import java.util.Optional;

public class RestBuildConfig {

/**
* Enables REST for automatiko
*/
public boolean enabled() {
return false;
}

public Optional<String> updateDataMethod() {
return Optional.of("POST");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,6 @@ public CompilationUnit generateCompilationUnit() {
template.findAll(FieldDeclaration.class, CodegenUtils::isProcessField).stream()
.filter(fd -> fd.getVariable(0).getNameAsString().startsWith("subprocess_"))
.forEach(fd -> annotator.withNamedInjection(fd, processId + version));
//
// template.findAll(FieldDeclaration.class, CodegenUtils::isApplicationField)
// .forEach(fd -> annotator.withInjection(fd));
// template.findAll(FieldDeclaration.class, CodegenUtils::isIdentitySupplierField)
// .forEach(fd -> annotator.withInjection(fd));

boolean tracingAvailable = context.getBuildContext().isTracingSupported();

Expand Down Expand Up @@ -533,6 +528,16 @@ public int compare(Parameter o1, Parameter o2) {

}

Optional<String> updateModelMethodValue = context.getApplicationProperty("quarkus.automatiko.rest.update-data-method");
// if update method config param is given apply it on update model methods

if (updateModelMethodValue.isPresent()) {
template.findAll(MethodDeclaration.class).stream()
.filter(md -> md.getNameAsString().equals("updateModel_" + processName)).forEach(updateModelMethod -> {
updateModelMethod.getAnnotationByName("POST").get().remove();
updateModelMethod.addAnnotation("jakarta.ws.rs." + updateModelMethodValue.get().toUpperCase());
});
}
try {
template.getMembers().sort(new BodyDeclarationComparator());
} catch (IllegalArgumentException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,23 +520,27 @@ public List<GeneratedFile> generate() {
execModelGen.className(),
applicationCanonicalName).withDependencyInjection(annotator));
} else if (isServiceProject()) {
if (isPublic(workFlowProcess)) {

// Creating and adding the ResourceGenerator
resourceGeneratorFactory
.create(context(), workFlowProcess, modelClassGenerator.className(), execModelGen.className(),
applicationCanonicalName)
.map(r -> r.withDependencyInjection(annotator).withParentProcess(null).withPersistence(persistence)
.withUserTasks(processIdToUserTaskModel.get(execModelGen.getProcessId()))
.withPathPrefix("{id}").withSignals(metaData.getSignals(),
metaData.getSignalNodes())
.withTriggers(metaData.isStartable(), metaData.isDynamic())
.withSubProcesses(populateSubprocesses(workFlowProcess,
processIdToMetadata.get(execModelGen.getProcessId()), processIdToMetadata,
processIdToModelGenerator, processExecutableModelGenerators,
processIdToUserTaskModel)))
.ifPresent(rgs::add);

if (isPublic(workFlowProcess)) {
Optional<String> isRestEnabled = context.getApplicationProperty("quarkus.automatiko.rest.enabled");

if (Boolean.parseBoolean(isRestEnabled.orElse("true"))) {
// Creating and adding the ResourceGenerator
resourceGeneratorFactory
.create(context(), workFlowProcess, modelClassGenerator.className(), execModelGen.className(),
applicationCanonicalName)
.map(r -> r.withDependencyInjection(annotator).withParentProcess(null)
.withPersistence(persistence)
.withUserTasks(processIdToUserTaskModel.get(execModelGen.getProcessId()))
.withPathPrefix("{id}").withSignals(metaData.getSignals(),
metaData.getSignalNodes())
.withTriggers(metaData.isStartable(), metaData.isDynamic())
.withSubProcesses(populateSubprocesses(workFlowProcess,
processIdToMetadata.get(execModelGen.getProcessId()), processIdToMetadata,
processIdToModelGenerator, processExecutableModelGenerators,
processIdToUserTaskModel)))
.ifPresent(rgs::add);
}
if (context.getBuildContext().isGraphQLSupported()) {
GraphQLResourceGenerator graphqlGenerator = new GraphQLResourceGenerator(context(), workFlowProcess,
modelClassGenerator.className(), execModelGen.className(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ quarkus.automatiko.jobs.filesystem.path=target/jobs
quarkus.swagger-ui.always-include=true
%dev.quarkus.automatiko.on-instance-end=keep

quarkus.automatiko.resource-path-prefix=/api/workflows
quarkus.automatiko.resource-path-prefix=/api/workflows

quarkus.automatiko.rest.update-data-method=PUT
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ public void testProcessExecution() {
.statusCode(200)
.body("$.size()", is(1));

// update the variables using dedicated endpoint
given()
.contentType(ContentType.JSON)
.accept(ContentType.JSON)
.body(addPayload)
.when()
.put("/api/workflows/v1_0/orders/" + id)
.then()
.statusCode(200);

// and one task coming from it
List<Map<String, String>> taskInfo = given()
.accept(ContentType.JSON)
Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,20 @@
<version.net.java.dev.glazedlists>1.8.0</version.net.java.dev.glazedlists>

<version.io.cloudevents>4.0.1</version.io.cloudevents>
<version.io.quarkus>3.14.4</version.io.quarkus>
<version.io.quarkus>3.15.1</version.io.quarkus>
<version.io.restassured>5.5.0</version.io.restassured>
<version.io.smallrye.reactive>4.24.0</version.io.smallrye.reactive>
<version.org.eclipse.microprofile.metrics>4.0.1</version.org.eclipse.microprofile.metrics>
<version.org.eclipse.microprofile.rest.client>3.0.1</version.org.eclipse.microprofile.rest.client>
<version.org.eclipse.microprofile.config>3.1</version.org.eclipse.microprofile.config>
<version.org.eclipse.microprofile.openapi>3.1.1</version.org.eclipse.microprofile.openapi>

<version.io.javaoperatorsdk>6.8.0</version.io.javaoperatorsdk>
<version.io.quarkiverse.googlecloudservices>2.11.0</version.io.quarkiverse.googlecloudservices>
<version.io.javaoperatorsdk>6.8.3</version.io.javaoperatorsdk>
<version.io.quarkiverse.googlecloudservices>2.12.1</version.io.quarkiverse.googlecloudservices>
<version.com.datastax.oss.quarkus>1.2.0</version.com.datastax.oss.quarkus>
<version.com.datastax.oss>4.17.0</version.com.datastax.oss>
<version.org.apache.camel.quarkus>3.14.0</version.org.apache.camel.quarkus>
<version.io.quarkiverse.reactivemessaging.http>2.2.0</version.io.quarkiverse.reactivemessaging.http>
<version.org.apache.camel.quarkus>3.15.0</version.org.apache.camel.quarkus>
<version.io.quarkiverse.reactivemessaging.http>2.4.1</version.io.quarkiverse.reactivemessaging.http>
<version.io.quarkiverse.amazonservices>2.18.1</version.io.quarkiverse.amazonservices>
<version.io.quarkiverse.azure-services>1.0.7</version.io.quarkiverse.azure-services>
<version.io.quarkiverse.jdbc-sqlite>3.0.10</version.io.quarkiverse.jdbc-sqlite>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.automatiko.engine.api.config.MessagingBuildConfig;
import io.automatiko.engine.api.config.MetricsBuildConfig;
import io.automatiko.engine.api.config.PersistenceBuildConfig;
import io.automatiko.engine.api.config.RestBuildConfig;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
Expand Down Expand Up @@ -85,6 +86,12 @@ public class AutomatikoBuildTimeConfig extends AutomatikoBuildConfig {
@ConfigItem
public JobsBuildTimeConfig jobs;

/**
* Configures rest
*/
@ConfigItem
public RestBuildTimeConfig rest;

public Optional<String> packageName() {
return packageName;
}
Expand Down Expand Up @@ -129,4 +136,9 @@ public JobsBuildConfig jobs() {
return jobs;
}

@Override
public RestBuildConfig rest() {
return rest;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.automatiko.engine.quarkus;

import java.util.Optional;

import io.automatiko.engine.api.config.RestBuildConfig;
import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;

@ConfigGroup
public class RestBuildTimeConfig extends RestBuildConfig {

/**
* Enables REST for automatiko
*/
@ConfigItem(defaultValue = "true")
public boolean enabled;

/**
* Specifies which HTTP method should be used for update variables endpoint - POST or PUT defaults to POST
*/
@ConfigItem(defaultValue = "POST")
public Optional<String> updateDataMethod;

@Override
public boolean enabled() {
return enabled;
}

@Override
public Optional<String> updateDataMethod() {
return updateDataMethod;
}
}