-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61bfaca
commit c2b9c91
Showing
24 changed files
with
1,690 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
118 changes: 118 additions & 0 deletions
118
...l-dynamicform/src/main/java/org/apache/seatunnel/app/dynamicforms/AbstractFormOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...micform/src/main/java/org/apache/seatunnel/app/dynamicforms/AbstractFormSelectOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
.../seatunnel-dynamicform/src/main/java/org/apache/seatunnel/app/dynamicforms/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
33 changes: 33 additions & 0 deletions
33
...-dynamicform/src/main/java/org/apache/seatunnel/app/dynamicforms/DynamicSelectOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.