Skip to content

Commit

Permalink
Add seatunnel dynamicform module
Browse files Browse the repository at this point in the history
  • Loading branch information
EricJoy2048 committed May 6, 2023
1 parent 61bfaca commit c2b9c91
Show file tree
Hide file tree
Showing 24 changed files with 1,690 additions and 4 deletions.
77 changes: 75 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
<skipUT>false</skipUT>

<!-- dependency -->
<seatunnel-common.version>2.1.3</seatunnel-common.version>
<commons.logging.version>1.2</commons.logging.version>
<slf4j.version>1.7.25</slf4j.version>
<jackson.version>2.12.7.1</jackson.version>
Expand All @@ -113,14 +112,88 @@
<checker.qual.version>3.10.0</checker.qual.version>
<log4j-core.version>2.17.1</log4j-core.version>
<awaitility.version>4.2.0</awaitility.version>
<seatunnel-framework.version>2.3.1-SNAPSHOT</seatunnel-framework.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>seatunnel-common</artifactId>
<version>${seatunnel-common.version}</version>
<version>${seatunnel-framework.version}</version>
</dependency>

<!-- seatunnel main repository dependency -->
<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>seatunnel-common</artifactId>
<version>${seatunnel-framework.version}</version>
</dependency>

<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>seatunnel-jackson</artifactId>
<version>${seatunnel-framework.version}</version>
<classifier>optional</classifier>
</dependency>

<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>seatunnel-api</artifactId>
<version>${seatunnel-framework.version}</version>
</dependency>

<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>seatunnel-engine-client</artifactId>
<version>${seatunnel-framework.version}</version>
</dependency>

<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>${auto-service.version}</version>
</dependency>

<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>seatunnel-plugin-discovery</artifactId>
<version>${seatunnel-framework.version}</version>
</dependency>

<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>seatunnel-transforms-v2</artifactId>
<version>${seatunnel-framework.version}</version>
</dependency>

<!-- seatunnel connector test -->
<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>connector-common</artifactId>
<version>${seatunnel-framework.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>connector-console</artifactId>
<version>${seatunnel-framework.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>connector-fake</artifactId>
<version>${seatunnel-framework.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>connector-jdbc</artifactId>
<version>${seatunnel-framework.version}</version>
<scope>test</scope>
</dependency>

<dependency>
Expand Down
1 change: 1 addition & 0 deletions seatunnel-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<packaging>pom</packaging>
<modules>
<module>seatunnel-app</module>
<module>seatunnel-dynamicform</module>
<module>seatunnel-spi</module>
<module>seatunnel-scheduler</module>
<module>seatunnel-server-common</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spring:
date-format: yyyy-MM-dd HH:mm:ss
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/seatunnel?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
url: jdbc:mysql://localhost:3306/seatunnel?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&allowPublicKeyRetrieval=true
username: root
password: 123456
mvc:
Expand All @@ -40,7 +40,7 @@ ds:
default: default
api:
token: 12345678
prefix: http://127.0.0.1:12345/dolphinscheduler
prefix: http://localhost:12345/dolphinscheduler

jwt:
expireTime: 86400
Expand Down
57 changes: 57 additions & 0 deletions seatunnel-server/seatunnel-dynamicform/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
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.
-->
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>seatunnel-server</artifactId>
<groupId>org.apache.seatunnel</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>seatunnel-dynamicform</artifactId>

<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</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.apache.seatunnel</groupId>
<artifactId>seatunnel-common</artifactId>
</dependency>
<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>seatunnel-jackson</artifactId>
<classifier>optional</classifier>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* 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
*
* 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 org.apache.seatunnel.app.dynamicforms;

import org.apache.seatunnel.app.dynamicforms.validate.AbstractValidate;

import org.apache.seatunnel.shade.com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.seatunnel.shade.com.fasterxml.jackson.annotation.JsonProperty;

import lombok.Data;
import lombok.Getter;
import lombok.NonNull;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
public abstract class AbstractFormOption<T extends AbstractFormOption, V extends AbstractValidate> {

// support i18n
private final String label;
private final String field;
private Object defaultValue;

// support i18n
private String description = "";
private boolean clearable;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Map<String, Object> show;

// support i18n
private String placeholder = "";

@JsonInclude(JsonInclude.Include.NON_NULL)
private V validate;

public AbstractFormOption(@NonNull String label, @NonNull String field) {
this.label = label;
this.field = field;
}

public enum FormType {
@JsonProperty("input")
INPUT("input"),

@JsonProperty("select")
SELECT("select");

@Getter
private String formType;

FormType(String formType) {
this.formType = formType;
}
}

public T withShow(@NonNull String field, @NonNull List<Object> values) {
if (this.show == null) {
this.show = new HashMap<>();
}

this.show.put(Constants.SHOW_FIELD, field);
this.show.put(Constants.SHOW_VALUE, values);
return (T) this;
}

public T withValidate(@NonNull V validate) {
this.validate = validate;
return (T) this;
}

public T withDefaultValue(Object defaultValue) {
this.defaultValue = defaultValue;
return (T) this;
}

public T withDescription(@NonNull String description) {
this.description = description;
return (T) this;
}

public T withI18nDescription(@NonNull String description) {
this.description = FormLocale.I18N_PREFIX + description;
return (T) this;
}

public T withClearable() {
this.clearable = true;
return (T) this;
}

public T withPlaceholder(@NonNull String placeholder) {
this.placeholder = placeholder;
return (T) this;
}

public T withI18nPlaceholder(@NonNull String placeholder) {
this.placeholder = FormLocale.I18N_PREFIX + placeholder;
return (T) this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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
*
* 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 org.apache.seatunnel.app.dynamicforms;

import org.apache.seatunnel.shade.com.fasterxml.jackson.annotation.JsonProperty;

import lombok.Getter;
import lombok.NonNull;

public abstract class AbstractFormSelectOption extends AbstractFormOption {

@JsonProperty("type")
@Getter
private final FormType formType = FormType.SELECT;

public AbstractFormSelectOption(@NonNull String label, @NonNull String field) {
super(label, field);
}

public static class SelectOption {
@JsonProperty
@Getter
private String label;

@JsonProperty
@Getter
private Object value;

public SelectOption(@NonNull String label, @NonNull Object value) {
this.label = label;
this.value = value;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.apache.seatunnel.app.dynamicforms;

public final class Constants {

public static final String SHOW_FIELD = "field";

public static final String SHOW_VALUE = "value";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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
*
* 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 org.apache.seatunnel.app.dynamicforms;

import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;

public class DynamicSelectOption extends AbstractFormSelectOption {
@Getter
@Setter
private String api;

public DynamicSelectOption(@NonNull String api, @NonNull String label, @NonNull String field) {
super(label, field);
this.api = api;
}
}
Loading

0 comments on commit c2b9c91

Please sign in to comment.