Skip to content

[Fix #473] Refactor project structure #476

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

Merged
merged 1 commit into from
Nov 25, 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
71 changes: 0 additions & 71 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,77 +121,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<checkstyleRules>
<module name="Checker">
<module name="RegexpHeader">
<property name="header" value="${checkstyle.header.template}" />
<property name="fileExtensions" value="${checkstyle.header.extensions}" />
</module>
<module name="TreeWalker">
<module name="RegexpSinglelineJava">
<property name="format" value="@author" />
<property name="message" value="No @author tag allowed" />
</module>
</module>
</module>
</checkstyleRules>
<outputFile>${project.build.directory}/checkstyle.log</outputFile>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<includeResources>true</includeResources>
<includeTestResources>true</includeTestResources>
<consoleOutput>false</consoleOutput>
<failsOnError>false</failsOnError>
<logViolationsToConsole>${checkstyle.logViolationsToConsole}</logViolationsToConsole>
<failOnViolation>${checkstyle.failOnViolation}</failOnViolation>
<sourceDirectories>
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
<sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
</sourceDirectories>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify.fmt</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<configuration>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<verbose>false</verbose>
<filesNamePattern>.*\.java</filesNamePattern>
<skip>false</skip>
<skipSortingImports>false</skipSortingImports>
<style>google</style>
</configuration>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
20 changes: 20 additions & 0 deletions impl/bom/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-impl</artifactId>
<version>7.0.0-SNAPSHOT</version>
</parent>
<artifactId>serverlessworkflow-impl-bom</artifactId>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-impl-core</artifactId>
</dependency>
<dependency>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-impl-http</artifactId>
</dependency>
</dependencies>
</project>
14 changes: 14 additions & 0 deletions impl/core/.checkstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<fileset-config file-format-version="1.2.0" simple-config="false" sync-formatter="false">
<local-check-config name="maven-checkstyle-plugin default" location="file:/home/ftirados/kogito_new/.metadata/.plugins/com.basistech.m2e.code.quality.checkstyle/serverlessworkflow-impl-core_inline_checkstyle.xml" type="remote" description="maven-checkstyle-plugin configuration default">
<property name="checkstyle.header.file" value="/home/ftirados/kogito_new/.metadata/.plugins/org.eclipse.core.resources/.projects/serverlessworkflow-impl-core/com.basistech.m2e.code.quality.checkstyleConfigurator/checkstyle-header-default.txt"/>
<property name="checkstyle.cache.file" value="${project_loc}/target/checkstyle-cachefile"/>
</local-check-config>
<fileset name="java-sources-default" enabled="true" check-config-name="maven-checkstyle-plugin default" local="true">
<file-match-pattern match-pattern="^src/test/java/.*\/.*\.java" include-pattern="true"/>
<file-match-pattern match-pattern="^src/main/java/.*\/.*\.java" include-pattern="true"/>
<file-match-pattern match-pattern="^src/main/resources/.*\.properties" include-pattern="true"/>
<file-match-pattern match-pattern="^src/test/resources/.*\.properties" include-pattern="true"/>
</fileset>
</fileset-config>
48 changes: 48 additions & 0 deletions impl/core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-impl</artifactId>
<version>7.0.0-SNAPSHOT</version>
</parent>
<artifactId>serverlessworkflow-impl-core</artifactId>
<properties>
<version.net.thisptr>1.1.0</version.net.thisptr>
</properties>
<dependencies>
<dependency>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-api</artifactId>
<version>7.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator</artifactId>
</dependency>
<dependency>
<groupId>net.thisptr</groupId>
<artifactId>jackson-jq</artifactId>
<version>${version.net.thisptr}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2020-Present The Serverless Workflow Specification Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.serverlessworkflow.impl;

public enum WorkflowState {
STARTED,
WAITING,
COMPLETED
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2020-Present The Serverless Workflow Specification Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.serverlessworkflow.impl.executors;

import io.serverlessworkflow.api.types.TaskBase;
import io.serverlessworkflow.impl.TaskContext;
import io.serverlessworkflow.impl.WorkflowContext;
import io.serverlessworkflow.impl.WorkflowDefinition;

public class CallTaskExecutor<T extends TaskBase> extends AbstractTaskExecutor<T> {

private final CallableTask<T> callable;

protected CallTaskExecutor(T task, WorkflowDefinition definition, CallableTask<T> callable) {
super(task, definition);
this.callable = callable;
callable.init(task, definition);
}

@Override
protected void internalExecute(WorkflowContext workflow, TaskContext<T> taskContext) {
taskContext.rawOutput(callable.apply(workflow, taskContext, taskContext.input()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2020-Present The Serverless Workflow Specification Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.serverlessworkflow.impl.executors;

import com.fasterxml.jackson.databind.JsonNode;
import io.serverlessworkflow.api.types.TaskBase;
import io.serverlessworkflow.impl.TaskContext;
import io.serverlessworkflow.impl.WorkflowContext;
import io.serverlessworkflow.impl.WorkflowDefinition;

public interface CallableTask<T extends TaskBase> {
void init(T task, WorkflowDefinition definition);

JsonNode apply(WorkflowContext workflowContext, TaskContext<T> taskContext, JsonNode input);

boolean accept(Class<? extends TaskBase> clazz);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
*/
package io.serverlessworkflow.impl.executors;

import io.serverlessworkflow.api.types.CallHTTP;
import io.serverlessworkflow.api.types.CallTask;
import io.serverlessworkflow.api.types.Task;
import io.serverlessworkflow.api.types.TaskBase;
import io.serverlessworkflow.impl.WorkflowDefinition;
import java.util.ServiceLoader;
import java.util.ServiceLoader.Provider;

public class DefaultTaskExecutorFactory implements TaskExecutorFactory {

Expand All @@ -30,12 +33,15 @@ public static TaskExecutorFactory get() {

protected DefaultTaskExecutorFactory() {}

private ServiceLoader<CallableTask> callTasks = ServiceLoader.load(CallableTask.class);

public TaskExecutor<? extends TaskBase> getTaskExecutor(
Task task, WorkflowDefinition definition) {
if (task.getCallTask() != null) {
CallTask callTask = task.getCallTask();
if (callTask.getCallHTTP() != null) {
return new HttpExecutor(callTask.getCallHTTP(), definition);
return new CallTaskExecutor<>(
callTask.getCallHTTP(), definition, findCallTask(CallHTTP.class));
}
} else if (task.getSwitchTask() != null) {
return new SwitchExecutor(task.getSwitchTask(), definition);
Expand All @@ -46,4 +52,15 @@ public TaskExecutor<? extends TaskBase> getTaskExecutor(
}
throw new UnsupportedOperationException(task.get().getClass().getName() + " not supported yet");
}

@SuppressWarnings("unchecked")
private <T extends TaskBase> CallableTask<T> findCallTask(Class<T> clazz) {
return (CallableTask<T>)
callTasks.stream()
.map(Provider::get)
.filter(s -> s.accept(clazz))
.findAny()
.orElseThrow(
() -> new UnsupportedOperationException(clazz.getName() + " not supported yet"));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2020-Present The Serverless Workflow Specification Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.serverlessworkflow.impl.executors;

import io.serverlessworkflow.api.types.FlowDirective;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2020-Present The Serverless Workflow Specification Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.serverlessworkflow.impl.expressions;

public class ExpressionValidationException extends RuntimeException {

private static final long serialVersionUID = 1L;

public ExpressionValidationException(String message) {
super(message);
}

public ExpressionValidationException(String message, Throwable ex) {
super(message, ex);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* Copyright 2020-Present The Serverless Workflow Specification Authors
*
* http://www.apache.org/licenses/LICENSE-2.0
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.serverlessworkflow.impl.jsonschema;

Expand Down
Loading
Loading