+ * 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.submarine.server.jobserver.rest.api;
+
+import org.apache.submarine.server.jobserver.rest.dao.MLJobSpec;
+import org.apache.submarine.server.jobserver.rest.dao.RestConstants;
+import org.apache.submarine.server.response.JsonResponse;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * ML job rest API v1. It can accept MLJobSpec to create a job.
+ * To create a job:
+ * POST /api/v1/jobs
+ *
+ * To list the jobs
+ * GET /api/v1/jobs
+ *
+ * To get a specific job
+ * GET /api/v1/jobs/{id}
+ *
+ * To delete a job by id
+ * DELETE /api/v1/jobs/{id}
+ * */
+@Path(RestConstants.V1 + "/" + RestConstants.JOBS)
+@Produces({MediaType.APPLICATION_JSON + "; " + RestConstants.CHARSET_UTF8})
+public class JobApi {
+
+ // A ping test to verify the job server is up.
+ @Path(RestConstants.PING)
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response ping() {
+ return new JsonResponse.Builder(Response.Status.OK)
+ .success(true).result("Pong").build();
+ }
+
+ @POST
+ @Consumes({RestConstants.MEDIA_TYPE_YAML, MediaType.APPLICATION_JSON})
+ public Response submitJob(MLJobSpec jobSpec) {
+ // Submit the job spec through submitter
+ return new JsonResponse.Builder(Response.Status.ACCEPTED)
+ .success(true).result(jobSpec).build();
+ }
+
+ @GET
+ @Path("{" + RestConstants.JOB_ID + "}")
+ public Response listJob(@PathParam(RestConstants.JOB_ID) String id) {
+ // Query the job status though submitter
+ return new JsonResponse.Builder(Response.Status.OK)
+ .success(true).result(id).build();
+ }
+
+ @GET
+ public Response listAllJob() {
+ // Query all the job status though submitter
+ return new JsonResponse.Builder(Response.Status.OK)
+ .success(true).build();
+ }
+
+ @DELETE
+ @Path("{" + RestConstants.JOB_ID + "}")
+ public Response deleteJob(@PathParam(RestConstants.JOB_ID) String id) {
+ // Delete the job though submitter
+ return new JsonResponse.Builder(Response.Status.OK)
+ .success(true).result(id).build();
+ }
+
+}
diff --git a/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/dao/Component.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/dao/Component.java
new file mode 100644
index 0000000000..e5b39efc0f
--- /dev/null
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/dao/Component.java
@@ -0,0 +1,69 @@
+/*
+ * 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.submarine.server.jobserver.rest.dao;
+
+
+/**
+ * One component contains role, count and resources.
+ * The role name could be tensorflow ps, Pytorch master or tensorflow worker
+ * The count is the count of the role instance
+ * The resource is the memory/vcore/gpu resource strings in the format:
+ * "memory=2048M,vcore=4,nvidia.com/gpu=1"
+ */
+
+public class Component {
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ public String getCount() {
+ return count;
+ }
+
+ public void setCount(String count) {
+ this.count = count;
+ }
+
+ public String getResources() {
+ return resources;
+ }
+
+ public void setResources(String resources) {
+ this.resources = resources;
+ }
+
+ String role;
+ String count;
+ String resources;
+
+ public Component() {}
+
+ public Component(String r, String ct, String res) {
+ this.count = ct;
+ this.role = r;
+ this.resources = res;
+ }
+
+}
diff --git a/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/dao/EnvVaraible.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/dao/EnvVaraible.java
new file mode 100644
index 0000000000..b8388ff616
--- /dev/null
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/dao/EnvVaraible.java
@@ -0,0 +1,53 @@
+/*
+ * 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.submarine.server.jobserver.rest.dao;
+
+// A process level environment variable.
+public class EnvVaraible {
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ String key;
+ String value;
+
+ public EnvVaraible() {}
+
+ public EnvVaraible(String k, String v) {
+ this.key = k;
+ this.value = v;
+ }
+
+
+
+}
diff --git a/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/dao/MLJobSpec.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/dao/MLJobSpec.java
new file mode 100644
index 0000000000..0e64b710a6
--- /dev/null
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/dao/MLJobSpec.java
@@ -0,0 +1,177 @@
+/*
+ * 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.submarine.server.jobserver.rest.dao;
+
+/**
+ * The machine learning job spec the submarine job server can accept.
+ * */
+public class MLJobSpec {
+
+ String apiVersion;
+ // The engine type the job will use, can be tensorflow or pytorch
+ String type;
+ // The engine version, not image version/tag. For instance, tensorflow v1.13
+ String version;
+ /**
+ * Advanced property. The RM this job will submit to, k8s or yarn.
+ * Could be the path of yarn’s config file or k8s kubeconfig file
+ * This should be settled when deploy submarine job server.
+ */
+ String rmConfig;
+
+ /**
+ * Advanced property. The image should be inferred from type and version.
+ * The normal user should not set this.
+ * */
+ String dockerImage;
+
+ // The process aware environment variable
+ EnvVaraible[] envVars;
+
+ // The components this cluster will consists.
+ Component[] components;
+
+ // The user id who submit job
+ String uid;
+
+ /**
+ * The queue this job will submitted to.
+ * In YARN, we call it queue. In k8s, no such concept.
+ * It could be namespace’s name.
+ */
+ String queue;
+
+ /**
+ * The user-specified job name for easy search
+ * */
+ String name;
+
+ /**
+ * This could be file/directory which contains multiple python scripts.
+ * We should solve dependencies distribution in k8s or yarn.
+ * Or we could build images for each projects before submitting the job
+ * */
+ String projects;
+
+ /**
+ * The command uses to start the job. This is very job-specific.
+ * We assume the cmd is the same for all containers in a cluster
+ * */
+ String cmd;
+
+ public MLJobSpec() {}
+
+ public String getUid() {
+ return uid;
+ }
+
+ public void setUid(String uid) {
+ this.uid = uid;
+ }
+
+ public String getQueue() {
+ return queue;
+ }
+
+ public void setQueue(String queue) {
+ this.queue = queue;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getProjects() {
+ return projects;
+ }
+
+ public void setProjects(String projects) {
+ this.projects = projects;
+ }
+ public String getCmd() {
+ return cmd;
+ }
+
+ public void setCmd(String cmd) {
+ this.cmd = cmd;
+ }
+
+ public Component[] getComponents() {
+ return components;
+ }
+
+ public void setComponents(
+ Component[] components) {
+ this.components = components;
+ }
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getRmConfig() {
+ return rmConfig;
+ }
+
+ public void setRmConfig(String rmConfig) {
+ this.rmConfig = rmConfig;
+ }
+
+ public String getDockerImage() {
+ return dockerImage;
+ }
+
+ public void setDockerImage(String dockerImage) {
+ this.dockerImage = dockerImage;
+ }
+
+ public EnvVaraible[] getEnvVars() {
+ return envVars;
+ }
+
+ public void setEnvVars(EnvVaraible[] envVars) {
+ this.envVars = envVars;
+ }
+
+ public String getApiVersion() {
+ return apiVersion;
+ }
+
+ public void setApiVersion(String apiVersion) {
+ this.apiVersion = apiVersion;
+ }
+
+
+}
diff --git a/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/dao/RestConstants.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/dao/RestConstants.java
new file mode 100644
index 0000000000..360d86cf99
--- /dev/null
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/dao/RestConstants.java
@@ -0,0 +1,29 @@
+/*
+ * 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.submarine.server.jobserver.rest.dao;
+
+public class RestConstants {
+ public static final String V1 = "v1";
+ public static final String JOBS = "jobs";
+ public static final String JOB_ID = "id";
+ public static final String PING = "ping";
+ public static final String MEDIA_TYPE_YAML = "application/yaml";
+ public static final String CHARSET_UTF8 = "charset=utf-8";
+}
diff --git a/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/provider/YamlEntityProvider.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/provider/YamlEntityProvider.java
new file mode 100644
index 0000000000..8250ce0e84
--- /dev/null
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/jobserver/rest/provider/YamlEntityProvider.java
@@ -0,0 +1,91 @@
+/*
+ * 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.submarine.server.jobserver.rest.provider;
+
+import org.yaml.snakeyaml.Yaml;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Scanner;
+
+@Provider
+@Consumes({"application/yaml", MediaType.TEXT_PLAIN})
+@Produces({"application/yaml", MediaType.TEXT_PLAIN})
+public class YamlEntityProvider implements MessageBodyWriter, MessageBodyReader {
+
+ @Override
+ public boolean isReadable(Class> type, Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType) {
+ return true;
+ }
+
+ @Override
+ public T readFrom(Class type, Type genericType, Annotation[] annotations,
+ MediaType mediaType,
+ MultivaluedMap httpHeaders, InputStream entityStream)
+ throws WebApplicationException {
+ Yaml yaml = new Yaml();
+ T t = yaml.loadAs(toString(entityStream), type);
+ return t;
+ }
+
+ public static String toString(InputStream inputStream) {
+ return new Scanner(inputStream, "UTF-8")
+ .useDelimiter("\\A").next();
+ }
+
+ @Override
+ public boolean isWriteable(Class> type, Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType) {
+ return true;
+ }
+
+ @Override
+ public long getSize(T t, Class> type, Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ public void writeTo(T t, Class> type, Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType, MultivaluedMap httpHeaders,
+ OutputStream entityStream) throws IOException, WebApplicationException {
+ Yaml yaml = new Yaml();
+ OutputStreamWriter writer = new OutputStreamWriter(entityStream);
+ yaml.dump(t, writer);
+ writer.close();
+ }
+}
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/DictAnnotation.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/response/DictAnnotation.java
similarity index 94%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/DictAnnotation.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/response/DictAnnotation.java
index 503bf1b1b6..fae35753f0 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/DictAnnotation.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/response/DictAnnotation.java
@@ -16,15 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.utils;
+package org.apache.submarine.server.response;
import net.sf.cglib.beans.BeanGenerator;
import net.sf.cglib.beans.BeanMap;
import org.apache.commons.lang.StringUtils;
-import org.apache.submarine.annotation.Dict;
-import org.apache.submarine.database.entity.SysDictItem;
-import org.apache.submarine.database.service.SysDictItemService;
-import org.apache.submarine.server.JsonResponse.ListResult;
+import org.apache.submarine.server.workbench.annotation.Dict;
+import org.apache.submarine.server.workbench.database.entity.SysDictItem;
+import org.apache.submarine.server.workbench.database.service.SysDictItemService;
+import org.apache.submarine.server.response.JsonResponse.ListResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/JsonExclusionStrategy.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/response/JsonExclusionStrategy.java
similarity index 96%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/JsonExclusionStrategy.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/response/JsonExclusionStrategy.java
index 9d92ca5f5c..ba62662b34 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/JsonExclusionStrategy.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/response/JsonExclusionStrategy.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.server;
+package org.apache.submarine.server.response;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/JsonResponse.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/response/JsonResponse.java
similarity index 98%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/JsonResponse.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/response/JsonResponse.java
index a45da02c1c..1c5a0e9f2a 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/server/JsonResponse.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/response/JsonResponse.java
@@ -16,13 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.server;
+package org.apache.submarine.server.response;
import com.google.common.annotations.VisibleForTesting;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.TypeAdapter;
-import org.apache.submarine.database.utils.DictAnnotation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -78,6 +77,10 @@ public Map getAttributes() {
return attributes;
}
+ public int getCode() {
+ return code;
+ }
+
public static class Builder {
private javax.ws.rs.core.Response.Status status;
private int code;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/HttpRequestUtil.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/utils/GitHttpRequest.java
similarity index 96%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/HttpRequestUtil.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/utils/GitHttpRequest.java
index fb392c49b4..50d301f937 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/HttpRequestUtil.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/utils/GitHttpRequest.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.utils;
+package org.apache.submarine.server.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,8 +32,8 @@
import java.util.Date;
import java.util.Map;
-public class HttpRequestUtil {
- private static final Logger LOG = LoggerFactory.getLogger(HttpRequestUtil.class);
+public class GitHttpRequest {
+ private static final Logger LOG = LoggerFactory.getLogger(GitHttpRequest.class);
/**
* Sends an HTTP request to the specified URL
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/GitUtils.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/utils/GitUtils.java
similarity index 99%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/GitUtils.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/utils/GitUtils.java
index 0c0c58a592..7c0dca0a0e 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/GitUtils.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/utils/GitUtils.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.utils;
+package org.apache.submarine.server.utils;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.ListBranchCommand;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/annotation/Dict.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/annotation/Dict.java
similarity index 94%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/annotation/Dict.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/annotation/Dict.java
index b354c80590..29f7aa7e68 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/annotation/Dict.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/annotation/Dict.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.annotation;
+package org.apache.submarine.server.workbench.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/annotation/SubmarineApi.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/annotation/SubmarineApi.java
similarity index 95%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/annotation/SubmarineApi.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/annotation/SubmarineApi.java
index b73e8e314b..0a23396b6c 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/annotation/SubmarineApi.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/annotation/SubmarineApi.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.annotation;
+package org.apache.submarine.server.workbench.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/MyBatisUtil.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/MyBatisUtil.java
similarity index 92%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/MyBatisUtil.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/MyBatisUtil.java
index 40ac9a8059..733159c96a 100755
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/MyBatisUtil.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/MyBatisUtil.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database;
+package org.apache.submarine.server.workbench.database;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
@@ -47,7 +47,7 @@ public class MyBatisUtil {
checkCalledByTestMethod();
- SubmarineConfiguration conf = SubmarineConfiguration.create();
+ SubmarineConfiguration conf = SubmarineConfiguration.getInstance();
String jdbcClassName = conf.getJdbcDriverClassName();
String jdbcUrl = conf.getJdbcUrl();
String jdbcUserName = conf.getJdbcUserName();
@@ -95,8 +95,8 @@ private static void checkCalledByTestMethod() {
private static void usingTestDatabase() {
LOG.info("Run the test unit using the test database");
// Run the test unit using the test database
- SubmarineConfiguration conf = SubmarineConfiguration.create();
- conf.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/submarineDB_test?" +
+ SubmarineConfiguration conf = SubmarineConfiguration.getInstance();
+ conf.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/submarine_test?" +
"useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&" +
"failOverReadOnly=false&zeroDateTimeBehavior=convertToNull&useSSL=false");
conf.setJdbcUserName("submarine_test");
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/BaseEntity.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/BaseEntity.java
similarity index 95%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/BaseEntity.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/BaseEntity.java
index ba301fad88..1ed11a08b9 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/BaseEntity.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/BaseEntity.java
@@ -16,11 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.server.workbench.database.entity;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.common.annotations.VisibleForTesting;
-import org.apache.submarine.database.utils.CustomJsonDateDeserializer;
+import org.apache.submarine.server.workbench.database.utils.CustomJsonDateDeserializer;
import java.lang.reflect.Field;
import java.util.Date;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/Project.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/Project.java
similarity index 96%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/Project.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/Project.java
index 848ab22879..966db2120a 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/Project.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/Project.java
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.server.workbench.database.entity;
-import org.apache.submarine.annotation.Dict;
+import org.apache.submarine.server.workbench.annotation.Dict;
import java.util.ArrayList;
import java.util.List;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/ProjectFiles.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/ProjectFiles.java
similarity index 95%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/ProjectFiles.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/ProjectFiles.java
index 08c367c917..6e64c312aa 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/ProjectFiles.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/ProjectFiles.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.server.workbench.database.entity;
public class ProjectFiles extends BaseEntity {
private String projectId;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDept.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDept.java
similarity index 97%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDept.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDept.java
index 2896690ab8..e0a159c545 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDept.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDept.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.server.workbench.database.entity;
public class SysDept extends BaseEntity {
private String deptCode;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDeptSelect.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDeptSelect.java
similarity index 97%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDeptSelect.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDeptSelect.java
index fe41842b8a..3f2c57e2da 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDeptSelect.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDeptSelect.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.server.workbench.database.entity;
import java.util.ArrayList;
import java.util.List;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDeptTree.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDeptTree.java
similarity index 96%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDeptTree.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDeptTree.java
index 66c832e490..c8d6231928 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDeptTree.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDeptTree.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.server.workbench.database.entity;
import java.util.ArrayList;
import java.util.List;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDict.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDict.java
similarity index 96%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDict.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDict.java
index 403fd22c72..572100e4e9 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDict.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDict.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.server.workbench.database.entity;
public class SysDict extends BaseEntity {
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDictItem.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDictItem.java
similarity index 96%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDictItem.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDictItem.java
index 1a578c3eec..3067c54874 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysDictItem.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysDictItem.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.server.workbench.database.entity;
public class SysDictItem extends BaseEntity {
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysMessage.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysMessage.java
similarity index 96%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysMessage.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysMessage.java
index 8b8f857690..d65a548642 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysMessage.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysMessage.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.server.workbench.database.entity;
public class SysMessage extends BaseEntity {
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysUser.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysUser.java
similarity index 93%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysUser.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysUser.java
index feb8a9f293..32019c5946 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/SysUser.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/SysUser.java
@@ -16,11 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.server.workbench.database.entity;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import org.apache.submarine.annotation.Dict;
-import org.apache.submarine.database.utils.CustomJsonDateDeserializer;
+import org.apache.submarine.server.workbench.annotation.Dict;
+import org.apache.submarine.server.workbench.database.utils.CustomJsonDateDeserializer;
import java.util.Date;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/Team.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/Team.java
similarity index 96%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/Team.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/Team.java
index c878a0e093..5c9010c47d 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/Team.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/Team.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.server.workbench.database.entity;
import java.util.ArrayList;
import java.util.List;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/TeamMember.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/TeamMember.java
similarity index 95%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/TeamMember.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/TeamMember.java
index 5b13cc6246..41c326b0b1 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/entity/TeamMember.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/entity/TeamMember.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.entity;
+package org.apache.submarine.server.workbench.database.entity;
public class TeamMember extends BaseEntity {
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/ProjectFilesMapper.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/ProjectFilesMapper.java
similarity index 90%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/ProjectFilesMapper.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/ProjectFilesMapper.java
index b15b779cad..06b2067cdc 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/ProjectFilesMapper.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/ProjectFilesMapper.java
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.mappers;
+package org.apache.submarine.server.workbench.database.mappers;
-import org.apache.submarine.database.entity.ProjectFiles;
+import org.apache.submarine.server.workbench.database.entity.ProjectFiles;
import java.util.List;
import java.util.Map;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/ProjectMapper.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/ProjectMapper.java
similarity index 90%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/ProjectMapper.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/ProjectMapper.java
index e5ca4dc60e..4604a28b70 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/ProjectMapper.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/ProjectMapper.java
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.mappers;
+package org.apache.submarine.server.workbench.database.mappers;
import org.apache.ibatis.session.RowBounds;
-import org.apache.submarine.database.entity.Project;
+import org.apache.submarine.server.workbench.database.entity.Project;
import java.util.List;
import java.util.Map;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysDeptMapper.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysDeptMapper.java
similarity index 89%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysDeptMapper.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysDeptMapper.java
index a39634cc01..cfd59e1a15 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysDeptMapper.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysDeptMapper.java
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.mappers;
+package org.apache.submarine.server.workbench.database.mappers;
-import org.apache.submarine.database.entity.SysDept;
+import org.apache.submarine.server.workbench.database.entity.SysDept;
import java.util.List;
import java.util.Map;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysDictItemMapper.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysDictItemMapper.java
similarity index 89%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysDictItemMapper.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysDictItemMapper.java
index c1bbc02f7d..855fddbeaa 100755
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysDictItemMapper.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysDictItemMapper.java
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.mappers;
+package org.apache.submarine.server.workbench.database.mappers;
import org.apache.ibatis.session.RowBounds;
-import org.apache.submarine.database.entity.SysDictItem;
+import org.apache.submarine.server.workbench.database.entity.SysDictItem;
import java.util.List;
import java.util.Map;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysDictMapper.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysDictMapper.java
similarity index 89%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysDictMapper.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysDictMapper.java
index 847d471b51..8f3fd59f4d 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysDictMapper.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysDictMapper.java
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.mappers;
+package org.apache.submarine.server.workbench.database.mappers;
import org.apache.ibatis.session.RowBounds;
-import org.apache.submarine.database.entity.SysDict;
+import org.apache.submarine.server.workbench.database.entity.SysDict;
import java.util.List;
import java.util.Map;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysMessageMapper.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysMessageMapper.java
similarity index 89%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysMessageMapper.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysMessageMapper.java
index f3cd28f583..6ff4c05b06 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysMessageMapper.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysMessageMapper.java
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.mappers;
+package org.apache.submarine.server.workbench.database.mappers;
-import org.apache.submarine.database.entity.SysMessage;
+import org.apache.submarine.server.workbench.database.entity.SysMessage;
public interface SysMessageMapper {
int deleteByPrimaryKey(String id);
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysUserMapper.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysUserMapper.java
similarity index 90%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysUserMapper.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysUserMapper.java
index 10b2c495e1..1d9697ad2c 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SysUserMapper.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SysUserMapper.java
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.mappers;
+package org.apache.submarine.server.workbench.database.mappers;
import org.apache.ibatis.session.RowBounds;
-import org.apache.submarine.database.entity.SysUser;
+import org.apache.submarine.server.workbench.database.entity.SysUser;
import java.util.List;
import java.util.Map;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SystemMapper.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SystemMapper.java
similarity index 93%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SystemMapper.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SystemMapper.java
index b624220afd..0b5ffe6041 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/SystemMapper.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/SystemMapper.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.mappers;
+package org.apache.submarine.server.workbench.database.mappers;
import java.util.Map;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/TeamMapper.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/TeamMapper.java
similarity index 90%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/TeamMapper.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/TeamMapper.java
index 5d877a4e7d..e904913924 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/TeamMapper.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/TeamMapper.java
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.mappers;
+package org.apache.submarine.server.workbench.database.mappers;
import org.apache.ibatis.session.RowBounds;
-import org.apache.submarine.database.entity.Team;
+import org.apache.submarine.server.workbench.database.entity.Team;
import java.util.List;
import java.util.Map;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/TeamMemberMapper.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/TeamMemberMapper.java
similarity index 90%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/TeamMemberMapper.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/TeamMemberMapper.java
index 9bcea17091..9f905b6787 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/mappers/TeamMemberMapper.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/mappers/TeamMemberMapper.java
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.mappers;
+package org.apache.submarine.server.workbench.database.mappers;
-import org.apache.submarine.database.entity.TeamMember;
+import org.apache.submarine.server.workbench.database.entity.TeamMember;
import java.util.List;
import java.util.Map;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/ProjectFilesService.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/ProjectFilesService.java
similarity index 85%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/ProjectFilesService.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/ProjectFilesService.java
index 9ba8776a37..3eb9e36c0d 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/ProjectFilesService.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/ProjectFilesService.java
@@ -16,12 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.service;
+package org.apache.submarine.server.workbench.database.service;
import org.apache.ibatis.session.SqlSession;
-import org.apache.submarine.database.MyBatisUtil;
-import org.apache.submarine.database.entity.ProjectFiles;
-import org.apache.submarine.database.mappers.ProjectFilesMapper;
+import org.apache.submarine.server.workbench.database.MyBatisUtil;
+import org.apache.submarine.server.workbench.database.entity.ProjectFiles;
+import org.apache.submarine.server.workbench.database.mappers.ProjectFilesMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/ProjectService.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/ProjectService.java
similarity index 93%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/ProjectService.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/ProjectService.java
index 6c434db6f8..6396370226 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/ProjectService.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/ProjectService.java
@@ -16,15 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.service;
+package org.apache.submarine.server.workbench.database.service;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
-import org.apache.submarine.database.MyBatisUtil;
-import org.apache.submarine.database.entity.Project;
-import org.apache.submarine.database.entity.ProjectFiles;
-import org.apache.submarine.database.mappers.ProjectFilesMapper;
-import org.apache.submarine.database.mappers.ProjectMapper;
+import org.apache.submarine.server.workbench.database.MyBatisUtil;
+import org.apache.submarine.server.workbench.database.entity.Project;
+import org.apache.submarine.server.workbench.database.entity.ProjectFiles;
+import org.apache.submarine.server.workbench.database.mappers.ProjectFilesMapper;
+import org.apache.submarine.server.workbench.database.mappers.ProjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/SysDictItemService.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/SysDictItemService.java
similarity index 81%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/SysDictItemService.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/SysDictItemService.java
index 3e8b6fcd67..dea66c22f0 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/SysDictItemService.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/SysDictItemService.java
@@ -16,13 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.service;
+package org.apache.submarine.server.workbench.database.service;
import org.apache.ibatis.session.SqlSession;
-import org.apache.submarine.database.MyBatisUtil;
-import org.apache.submarine.database.entity.SysDictItem;
-import org.apache.submarine.database.mappers.SysDictItemMapper;
-import org.apache.submarine.rest.SysDictRestApi;
+import org.apache.submarine.server.workbench.database.MyBatisUtil;
+import org.apache.submarine.server.workbench.database.entity.SysDictItem;
+import org.apache.submarine.server.workbench.database.mappers.SysDictItemMapper;
+import org.apache.submarine.server.workbench.rest.SysDictRestApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/SysMessageService.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/SysMessageService.java
similarity index 83%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/SysMessageService.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/SysMessageService.java
index 54cbb9d345..de6dd728d5 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/SysMessageService.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/SysMessageService.java
@@ -16,12 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.service;
+package org.apache.submarine.server.workbench.database.service;
import org.apache.ibatis.session.SqlSession;
-import org.apache.submarine.database.MyBatisUtil;
-import org.apache.submarine.database.entity.SysMessage;
-import org.apache.submarine.database.mappers.SysMessageMapper;
+import org.apache.submarine.server.workbench.database.MyBatisUtil;
+import org.apache.submarine.server.workbench.database.entity.SysMessage;
+import org.apache.submarine.server.workbench.database.mappers.SysMessageMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/SysUserService.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/SysUserService.java
similarity index 94%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/SysUserService.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/SysUserService.java
index 26f0fd912c..0c714ae84d 100755
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/SysUserService.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/SysUserService.java
@@ -16,13 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.service;
+package org.apache.submarine.server.workbench.database.service;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
-import org.apache.submarine.database.MyBatisUtil;
-import org.apache.submarine.database.entity.SysUser;
-import org.apache.submarine.database.mappers.SysUserMapper;
+import org.apache.submarine.server.workbench.database.MyBatisUtil;
+import org.apache.submarine.server.workbench.database.entity.SysUser;
+import org.apache.submarine.server.workbench.database.mappers.SysUserMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/TeamMemberService.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/TeamMemberService.java
similarity index 90%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/TeamMemberService.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/TeamMemberService.java
index e70f81480f..aea9fb2e48 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/TeamMemberService.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/TeamMemberService.java
@@ -16,12 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.service;
+package org.apache.submarine.server.workbench.database.service;
import org.apache.ibatis.session.SqlSession;
-import org.apache.submarine.database.MyBatisUtil;
-import org.apache.submarine.database.entity.TeamMember;
-import org.apache.submarine.database.mappers.TeamMemberMapper;
+import org.apache.submarine.server.workbench.database.MyBatisUtil;
+import org.apache.submarine.server.workbench.database.entity.TeamMember;
+import org.apache.submarine.server.workbench.database.mappers.TeamMemberMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/TeamService.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/TeamService.java
similarity index 93%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/TeamService.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/TeamService.java
index 29fa3be535..a365eef6b1 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/service/TeamService.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/service/TeamService.java
@@ -16,15 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.service;
+package org.apache.submarine.server.workbench.database.service;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
-import org.apache.submarine.database.MyBatisUtil;
-import org.apache.submarine.database.entity.Team;
-import org.apache.submarine.database.entity.TeamMember;
-import org.apache.submarine.database.mappers.TeamMapper;
-import org.apache.submarine.database.mappers.TeamMemberMapper;
+import org.apache.submarine.server.workbench.database.MyBatisUtil;
+import org.apache.submarine.server.workbench.database.entity.Team;
+import org.apache.submarine.server.workbench.database.entity.TeamMember;
+import org.apache.submarine.server.workbench.database.mappers.TeamMapper;
+import org.apache.submarine.server.workbench.database.mappers.TeamMemberMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/CustomJsonDateDeserializer.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/utils/CustomJsonDateDeserializer.java
similarity index 96%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/CustomJsonDateDeserializer.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/utils/CustomJsonDateDeserializer.java
index 3ed7e1aedc..30cb6f0f68 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/CustomJsonDateDeserializer.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/utils/CustomJsonDateDeserializer.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.utils;
+package org.apache.submarine.server.workbench.database.utils;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/DepartmentUtil.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/utils/DepartmentUtil.java
similarity index 93%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/DepartmentUtil.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/utils/DepartmentUtil.java
index fd6f65bdc4..479ac00386 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/DepartmentUtil.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/utils/DepartmentUtil.java
@@ -16,11 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.utils;
+package org.apache.submarine.server.workbench.database.utils;
-import org.apache.submarine.database.entity.SysDeptSelect;
-import org.apache.submarine.database.entity.SysDeptTree;
-import org.apache.submarine.database.entity.SysDept;
+import org.apache.submarine.server.workbench.database.entity.SysDeptSelect;
+import org.apache.submarine.server.workbench.database.entity.SysDeptTree;
+import org.apache.submarine.server.workbench.database.entity.SysDept;
import java.util.ArrayList;
import java.util.List;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/MybatisGeneratorMain.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/utils/MybatisGenerator.java
similarity index 90%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/MybatisGeneratorMain.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/utils/MybatisGenerator.java
index 2d86707df6..f0f28e011e 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/database/utils/MybatisGeneratorMain.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/database/utils/MybatisGenerator.java
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.database.utils;
+package org.apache.submarine.server.workbench.database.utils;
-import org.apache.submarine.database.service.TeamService;
+import org.apache.submarine.server.workbench.database.service.TeamService;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
@@ -34,7 +34,7 @@
import java.util.ArrayList;
import java.util.List;
-public class MybatisGeneratorMain {
+public class MybatisGenerator {
private static final Logger LOG = LoggerFactory.getLogger(TeamService.class);
public static void main(String[] args) {
@@ -42,7 +42,7 @@ public static void main(String[] args) {
boolean overwrite = true;
// If a null pointer here, write directly absolute path.
String genCfg = "/mbgConfiguration.xml";
- File configFile = new File(MybatisGeneratorMain.class.getResource(genCfg).getFile());
+ File configFile = new File(MybatisGenerator.class.getResource(genCfg).getFile());
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = null;
try {
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/Action.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/Action.java
similarity index 96%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/Action.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/Action.java
index bd21959f7f..0ff63702ca 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/Action.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/Action.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.entity;
+package org.apache.submarine.server.workbench.entity;
public class Action {
private String action;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/Permission.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/Permission.java
similarity index 98%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/Permission.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/Permission.java
index 6dd5471dff..ba62cd327b 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/Permission.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/Permission.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.entity;
+package org.apache.submarine.server.workbench.entity;
import java.util.List;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/Role.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/Role.java
similarity index 98%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/Role.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/Role.java
index 19b7966030..1944f7378f 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/Role.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/Role.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.entity;
+package org.apache.submarine.server.workbench.entity;
import java.util.List;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/User.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/User.java
similarity index 98%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/User.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/User.java
index 6c5eadc527..8e89188838 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/User.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/User.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.entity;
+package org.apache.submarine.server.workbench.entity;
public class User {
private final String id;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/UserInfo.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/UserInfo.java
similarity index 98%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/UserInfo.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/UserInfo.java
index 6ece630e72..c2d18dc8e2 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/entity/UserInfo.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/entity/UserInfo.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.entity;
+package org.apache.submarine.server.workbench.entity;
public class UserInfo {
private final String id;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/LoginRestApi.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/LoginRestApi.java
similarity index 79%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/LoginRestApi.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/LoginRestApi.java
index df21f29e76..039411540a 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/LoginRestApi.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/LoginRestApi.java
@@ -16,16 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.rest;
+package org.apache.submarine.server.workbench.rest;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.apache.ibatis.session.SqlSession;
-import org.apache.submarine.annotation.SubmarineApi;
-import org.apache.submarine.database.MyBatisUtil;
-import org.apache.submarine.database.entity.SysUser;
-import org.apache.submarine.database.mappers.SysUserMapper;
-import org.apache.submarine.server.JsonResponse;
+import org.apache.submarine.server.workbench.annotation.SubmarineApi;
+import org.apache.submarine.server.workbench.database.MyBatisUtil;
+import org.apache.submarine.server.workbench.database.entity.SysUser;
+import org.apache.submarine.server.workbench.database.mappers.SysUserMapper;
+import org.apache.submarine.server.response.JsonResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -59,11 +59,12 @@ public Response login(String loginParams) {
try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) {
SysUserMapper sysUserMapper = sqlSession.getMapper(SysUserMapper.class);
sysUser = sysUserMapper.login(mapParams);
+
+ sysUser.setToken("mock_token");
} catch (Exception e) {
LOG.error(e.getMessage(), e);
return new JsonResponse.Builder<>(Response.Status.OK).success(false).build();
}
- sysUser.setToken("mock_token");
return new JsonResponse.Builder(Response.Status.OK).success(true).result(sysUser).build();
}
@@ -76,4 +77,11 @@ public Response step() {
return new JsonResponse.Builder(Response.Status.OK).success(true).result(data).build();
}
+
+ @POST
+ @Path("/logout")
+ @SubmarineApi
+ public Response logout() {
+ return new JsonResponse.Builder(Response.Status.OK).success(true).result(true).build();
+ }
}
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/ProjectRestApi.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/ProjectRestApi.java
similarity index 91%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/ProjectRestApi.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/ProjectRestApi.java
index 8d98b08c5a..8741c0c8c2 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/ProjectRestApi.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/ProjectRestApi.java
@@ -16,14 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.rest;
+package org.apache.submarine.server.workbench.rest;
import com.github.pagehelper.PageInfo;
-import org.apache.submarine.annotation.SubmarineApi;
-import org.apache.submarine.database.entity.Project;
-import org.apache.submarine.database.service.ProjectService;
-import org.apache.submarine.server.JsonResponse;
-import org.apache.submarine.server.JsonResponse.ListResult;
+import org.apache.submarine.server.workbench.annotation.SubmarineApi;
+import org.apache.submarine.server.workbench.database.entity.Project;
+import org.apache.submarine.server.workbench.database.service.ProjectService;
+import org.apache.submarine.server.response.JsonResponse;
+import org.apache.submarine.server.response.JsonResponse.ListResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SysDeptRestApi.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SysDeptRestApi.java
similarity index 93%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SysDeptRestApi.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SysDeptRestApi.java
index f24954b187..0db262a772 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SysDeptRestApi.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SysDeptRestApi.java
@@ -16,20 +16,20 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.rest;
+package org.apache.submarine.server.workbench.rest;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.session.SqlSession;
-import org.apache.submarine.annotation.SubmarineApi;
-import org.apache.submarine.database.MyBatisUtil;
-import org.apache.submarine.database.entity.SysDeptSelect;
-import org.apache.submarine.database.entity.SysDeptTree;
-import org.apache.submarine.database.entity.SysDept;
-import org.apache.submarine.database.mappers.SysDeptMapper;
-import org.apache.submarine.database.utils.DepartmentUtil;
-import org.apache.submarine.server.JsonResponse;
-import org.apache.submarine.server.JsonResponse.ListResult;
+import org.apache.submarine.server.workbench.annotation.SubmarineApi;
+import org.apache.submarine.server.workbench.database.MyBatisUtil;
+import org.apache.submarine.server.workbench.database.entity.SysDeptSelect;
+import org.apache.submarine.server.workbench.database.entity.SysDeptTree;
+import org.apache.submarine.server.workbench.database.entity.SysDept;
+import org.apache.submarine.server.workbench.database.mappers.SysDeptMapper;
+import org.apache.submarine.server.workbench.database.utils.DepartmentUtil;
+import org.apache.submarine.server.response.JsonResponse;
+import org.apache.submarine.server.response.JsonResponse.ListResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SysDictItemRestApi.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SysDictItemRestApi.java
similarity index 93%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SysDictItemRestApi.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SysDictItemRestApi.java
index a79bc2669b..29f5dbc39b 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SysDictItemRestApi.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SysDictItemRestApi.java
@@ -16,19 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.rest;
+package org.apache.submarine.server.workbench.rest;
import com.github.pagehelper.PageInfo;
import com.google.gson.Gson;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
-import org.apache.submarine.annotation.SubmarineApi;
-import org.apache.submarine.database.MyBatisUtil;
-import org.apache.submarine.database.entity.SysDictItem;
-import org.apache.submarine.database.mappers.SysDictItemMapper;
-import org.apache.submarine.database.service.SysDictItemService;
-import org.apache.submarine.server.JsonResponse;
-import org.apache.submarine.server.JsonResponse.ListResult;
+import org.apache.submarine.server.workbench.annotation.SubmarineApi;
+import org.apache.submarine.server.workbench.database.MyBatisUtil;
+import org.apache.submarine.server.workbench.database.entity.SysDictItem;
+import org.apache.submarine.server.workbench.database.mappers.SysDictItemMapper;
+import org.apache.submarine.server.workbench.database.service.SysDictItemService;
+import org.apache.submarine.server.response.JsonResponse;
+import org.apache.submarine.server.response.JsonResponse.ListResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SysDictRestApi.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SysDictRestApi.java
similarity index 93%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SysDictRestApi.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SysDictRestApi.java
index 1217ae73b3..b5d4fff01a 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SysDictRestApi.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SysDictRestApi.java
@@ -16,18 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.rest;
+package org.apache.submarine.server.workbench.rest;
import com.github.pagehelper.PageInfo;
import com.google.gson.Gson;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
-import org.apache.submarine.annotation.SubmarineApi;
-import org.apache.submarine.database.MyBatisUtil;
-import org.apache.submarine.database.entity.SysDict;
-import org.apache.submarine.database.mappers.SysDictMapper;
-import org.apache.submarine.server.JsonResponse;
-import org.apache.submarine.server.JsonResponse.ListResult;
+import org.apache.submarine.server.workbench.annotation.SubmarineApi;
+import org.apache.submarine.server.workbench.database.MyBatisUtil;
+import org.apache.submarine.server.workbench.database.entity.SysDict;
+import org.apache.submarine.server.workbench.database.mappers.SysDictMapper;
+import org.apache.submarine.server.response.JsonResponse;
+import org.apache.submarine.server.response.JsonResponse.ListResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SysUserRestApi.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SysUserRestApi.java
similarity index 92%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SysUserRestApi.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SysUserRestApi.java
index c1d6668add..87288973c8 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SysUserRestApi.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SysUserRestApi.java
@@ -16,20 +16,20 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.rest;
+package org.apache.submarine.server.workbench.rest;
import com.github.pagehelper.PageInfo;
import com.google.gson.Gson;
-import org.apache.submarine.annotation.SubmarineApi;
-import org.apache.submarine.database.entity.SysDept;
-import org.apache.submarine.database.entity.SysUser;
-import org.apache.submarine.database.service.SysUserService;
-import org.apache.submarine.entity.Action;
-import org.apache.submarine.entity.Permission;
-import org.apache.submarine.entity.Role;
-import org.apache.submarine.entity.UserInfo;
-import org.apache.submarine.server.JsonResponse;
-import org.apache.submarine.server.JsonResponse.ListResult;
+import org.apache.submarine.server.workbench.annotation.SubmarineApi;
+import org.apache.submarine.server.workbench.database.entity.SysDept;
+import org.apache.submarine.server.workbench.database.entity.SysUser;
+import org.apache.submarine.server.workbench.database.service.SysUserService;
+import org.apache.submarine.server.workbench.entity.Action;
+import org.apache.submarine.server.workbench.entity.Permission;
+import org.apache.submarine.server.workbench.entity.Role;
+import org.apache.submarine.server.workbench.entity.UserInfo;
+import org.apache.submarine.server.response.JsonResponse;
+import org.apache.submarine.server.response.JsonResponse.ListResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SystemRestApi.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SystemRestApi.java
similarity index 88%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SystemRestApi.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SystemRestApi.java
index 3f07ae4a7c..83ab0b3492 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/SystemRestApi.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/SystemRestApi.java
@@ -16,18 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.rest;
+package org.apache.submarine.server.workbench.rest;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.session.SqlSession;
-import org.apache.submarine.annotation.SubmarineApi;
-import org.apache.submarine.database.MyBatisUtil;
-import org.apache.submarine.database.entity.SysUser;
-import org.apache.submarine.database.mappers.SystemMapper;
-import org.apache.submarine.database.service.SysUserService;
-import org.apache.submarine.server.JsonResponse;
-import org.apache.submarine.server.JsonResponse.ListResult;
+import org.apache.submarine.server.workbench.annotation.SubmarineApi;
+import org.apache.submarine.server.workbench.database.MyBatisUtil;
+import org.apache.submarine.server.workbench.database.entity.SysUser;
+import org.apache.submarine.server.workbench.database.mappers.SystemMapper;
+import org.apache.submarine.server.workbench.database.service.SysUserService;
+import org.apache.submarine.server.response.JsonResponse;
+import org.apache.submarine.server.response.JsonResponse.ListResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/TeamRestApi.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/TeamRestApi.java
similarity index 92%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/TeamRestApi.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/TeamRestApi.java
index 028be6b9e0..6149e9c3a0 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/rest/TeamRestApi.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/rest/TeamRestApi.java
@@ -16,14 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.submarine.rest;
+package org.apache.submarine.server.workbench.rest;
import com.github.pagehelper.PageInfo;
-import org.apache.submarine.annotation.SubmarineApi;
-import org.apache.submarine.database.entity.Team;
-import org.apache.submarine.database.service.TeamService;
-import org.apache.submarine.server.JsonResponse;
-import org.apache.submarine.server.JsonResponse.ListResult;
+import org.apache.submarine.server.workbench.annotation.SubmarineApi;
+import org.apache.submarine.server.workbench.database.entity.Team;
+import org.apache.submarine.server.workbench.database.service.TeamService;
+import org.apache.submarine.server.response.JsonResponse;
+import org.apache.submarine.server.response.JsonResponse.ListResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/ConnectionManager.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/ConnectionManager.java
similarity index 98%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/ConnectionManager.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/ConnectionManager.java
index 3ed92e7cd4..fbb173d455 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/ConnectionManager.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/ConnectionManager.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.submarine.websocket;
+package org.apache.submarine.server.workbench.websocket;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/DateJsonDeserializer.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/DateJsonDeserializer.java
similarity index 97%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/DateJsonDeserializer.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/DateJsonDeserializer.java
index 07885b1023..95ddc34deb 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/DateJsonDeserializer.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/DateJsonDeserializer.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.submarine.websocket;
+package org.apache.submarine.server.workbench.websocket;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/Message.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/Message.java
similarity index 97%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/Message.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/Message.java
index 93ade25db3..b50c8b3c0c 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/Message.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/Message.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.submarine.websocket;
+package org.apache.submarine.server.workbench.websocket;
import com.google.gson.Gson;
import org.slf4j.Logger;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/NotebookServer.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/NotebookServer.java
similarity index 98%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/NotebookServer.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/NotebookServer.java
index 6a42a01e33..192896aa1d 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/NotebookServer.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/NotebookServer.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.submarine.websocket;
+package org.apache.submarine.server.workbench.websocket;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/NotebookSocket.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/NotebookSocket.java
similarity index 97%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/NotebookSocket.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/NotebookSocket.java
index dfaf858032..8525915738 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/NotebookSocket.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/NotebookSocket.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.submarine.websocket;
+package org.apache.submarine.server.workbench.websocket;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.websocket.api.Session;
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/NotebookSocketListener.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/NotebookSocketListener.java
similarity index 94%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/NotebookSocketListener.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/NotebookSocketListener.java
index 0b9f318f1c..c56484c4ed 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/NotebookSocketListener.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/NotebookSocketListener.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.submarine.websocket;
+package org.apache.submarine.server.workbench.websocket;
/**
* NoteboookSocket listener.
diff --git a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/NotebookWebSocketCreator.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/NotebookWebSocketCreator.java
similarity index 96%
rename from submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/NotebookWebSocketCreator.java
rename to submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/NotebookWebSocketCreator.java
index c834938d1c..1350b87dd4 100644
--- a/submarine-workbench/workbench-server/src/main/java/org/apache/submarine/websocket/NotebookWebSocketCreator.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/workbench/websocket/NotebookWebSocketCreator.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.submarine.websocket;
+package org.apache.submarine.server.workbench.websocket;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
diff --git a/submarine-workbench/workbench-server/src/main/resources/log4j.properties b/submarine-server/server-core/src/main/resources/log4j.properties
similarity index 100%
rename from submarine-workbench/workbench-server/src/main/resources/log4j.properties
rename to submarine-server/server-core/src/main/resources/log4j.properties
diff --git a/submarine-workbench/workbench-server/src/main/resources/mbgConfiguration.xml b/submarine-server/server-core/src/main/resources/mbgConfiguration.xml
similarity index 99%
rename from submarine-workbench/workbench-server/src/main/resources/mbgConfiguration.xml
rename to submarine-server/server-core/src/main/resources/mbgConfiguration.xml
index d7610a8183..888d6fe94b 100644
--- a/submarine-workbench/workbench-server/src/main/resources/mbgConfiguration.xml
+++ b/submarine-server/server-core/src/main/resources/mbgConfiguration.xml
@@ -28,7 +28,7 @@
diff --git a/submarine-workbench/workbench-server/src/main/resources/mybatis-config.xml b/submarine-server/server-core/src/main/resources/mybatis-config.xml
similarity index 100%
rename from submarine-workbench/workbench-server/src/main/resources/mybatis-config.xml
rename to submarine-server/server-core/src/main/resources/mybatis-config.xml
diff --git a/submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/ProjectFilesMapper.xml b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/ProjectFilesMapper.xml
similarity index 88%
rename from submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/ProjectFilesMapper.xml
rename to submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/ProjectFilesMapper.xml
index 33de3c3719..2edffc52aa 100644
--- a/submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/ProjectFilesMapper.xml
+++ b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/ProjectFilesMapper.xml
@@ -18,8 +18,8 @@
under the License.
-->
-
-
+
+
@@ -27,7 +27,7 @@
-
+
@@ -48,7 +48,7 @@
-
+
select REPLACE(UUID(),"-","")
@@ -72,7 +72,7 @@
DELETE FROM sys_department WHERE id = #{id}
-
+
UPDATE sys_department SET
`dept_code` = #{deptCode},`dept_name` = #{deptName},
diff --git a/submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SysDictItemMapper.xml b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SysDictItemMapper.xml
similarity index 89%
rename from submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SysDictItemMapper.xml
rename to submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SysDictItemMapper.xml
index d2cf8fa51c..1c10dc1b7a 100644
--- a/submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SysDictItemMapper.xml
+++ b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SysDictItemMapper.xml
@@ -18,9 +18,9 @@
under the License.
-->
-
+
-
+
@@ -35,7 +35,7 @@
AND `item_name` like '%${itemName}%'
ORDER BY sort_order
-
+
@@ -44,7 +44,7 @@
-
+
INSERT INTO sys_dict_item (`id`, `dict_code`, `item_code`, `item_name`, `description`,
`sort_order`, `deleted`,
@@ -63,7 +63,7 @@
DELETE FROM sys_dict_item WHERE id = #{id}
-
+
UPDATE sys_dict_item SET
`dict_code` = #{dictCode},`item_code` = #{itemCode},
diff --git a/submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SysDictMapper.xml b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SysDictMapper.xml
similarity index 89%
rename from submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SysDictMapper.xml
rename to submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SysDictMapper.xml
index 6dd628711c..a4e45ef9f0 100644
--- a/submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SysDictMapper.xml
+++ b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SysDictMapper.xml
@@ -18,9 +18,9 @@
under the License.
-->
-
+
-
+
@@ -35,7 +35,7 @@
AND `dict_name` like '%${dictName}%'
ORDER BY id
-
+
@@ -43,7 +43,7 @@
-
+
INSERT INTO sys_dict(`id`, `dict_code`, `dict_name`, `description`,
`deleted`,`type`,
@@ -71,7 +71,7 @@
DELETE FROM sys_dict WHERE id = #{id}
-
+
UPDATE sys_dict SET
`dict_code`=#{dictCode},`dict_name`=#{dictName},
diff --git a/submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SysMessageMapper.xml b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SysMessageMapper.xml
similarity index 89%
rename from submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SysMessageMapper.xml
rename to submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SysMessageMapper.xml
index 83932e9266..28f3298116 100644
--- a/submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SysMessageMapper.xml
+++ b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SysMessageMapper.xml
@@ -18,8 +18,8 @@
under the License.
-->
-
-
+
+
@@ -27,7 +27,7 @@
-
+
@@ -35,7 +35,7 @@
-
+
@@ -60,18 +60,18 @@
where id = #{id,jdbcType=VARCHAR}
-
- insert into sys_message (id, sender, receiver,
- type, status, create_by,
+
+ insert into sys_message (id, sender, receiver,
+ type, status, create_by,
create_time, update_time,
context)
values (REPLACE(UUID(),"-",""), #{sender,jdbcType=VARCHAR}, #{receiver,jdbcType=VARCHAR},
- #{type,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{createBy,jdbcType=VARCHAR},
+ #{type,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{createBy,jdbcType=VARCHAR},
now(), now()
#{context,jdbcType=LONGVARCHAR})
-
+
insert into sys_message
@@ -139,7 +139,7 @@
-
+
update sys_message
@@ -173,7 +173,7 @@
where id = #{id,jdbcType=VARCHAR}
-
+
update sys_message
set sender = #{sender,jdbcType=VARCHAR},
receiver = #{receiver,jdbcType=VARCHAR},
@@ -187,7 +187,7 @@
where id = #{id,jdbcType=VARCHAR}
-
+
update sys_message
set sender = #{sender,jdbcType=VARCHAR},
receiver = #{receiver,jdbcType=VARCHAR},
@@ -199,4 +199,4 @@
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=VARCHAR}
-
\ No newline at end of file
+
diff --git a/submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SysUserMapper.xml b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SysUserMapper.xml
similarity index 91%
rename from submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SysUserMapper.xml
rename to submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SysUserMapper.xml
index 875b83e13a..e15bc7a27e 100644
--- a/submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SysUserMapper.xml
+++ b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SysUserMapper.xml
@@ -18,8 +18,8 @@
under the License.
-->
-
-
+
+
@@ -27,7 +27,7 @@
-
+
@@ -53,7 +53,7 @@
SELECT * FROM sys_user WHERE user_name = #{username} AND password = #{password}
-
+
select REPLACE(UUID(),"-","")
@@ -90,7 +90,7 @@
#{createBy}, now(), now())
-
+
UPDATE sys_user SET
`user_name` = #{userName},`real_name` = #{realName},
@@ -138,7 +138,7 @@
DELETE FROM sys_user WHERE id = #{id}
-
+
UPDATE sys_user SET password = #{password}, `update_time`=now()
WHERE id = #{id}
diff --git a/submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SystemMapper.xml b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SystemMapper.xml
similarity index 93%
rename from submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SystemMapper.xml
rename to submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SystemMapper.xml
index 250cb5992f..41a218d2fe 100644
--- a/submarine-workbench/workbench-server/src/main/resources/org/apache/submarine/database/mappers/SystemMapper.xml
+++ b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/SystemMapper.xml
@@ -18,7 +18,7 @@
under the License.
-->
-
+
diff --git a/submarine-server/server-submitter/submitter-k8s/pom.xml b/submarine-server/server-submitter/submitter-k8s/pom.xml
new file mode 100644
index 0000000000..4a2e3eda4d
--- /dev/null
+++ b/submarine-server/server-submitter/submitter-k8s/pom.xml
@@ -0,0 +1,77 @@
+
+
+
+
+
+ server-submitter
+ org.apache.submarine
+ 0.3.0-SNAPSHOT
+
+ 4.0.0
+
+ submitter-k8s
+ 0.3.0-SNAPSHOT
+ Submarine: Kubernetes Submitter
+
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
+
+ org.slf4j
+ slf4j-log4j12
+ ${slf4j.version}
+
+
+
+ io.kubernetes
+ client-java
+ ${k8s.client-java.version}
+
+
+
+
+ junit
+ junit
+
+
+
+
+ submarine-${artifactId}-${project.version}
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+ false
+
+
+
+
+ maven-enforcer-plugin
+
+
+
+
diff --git a/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sJobRequest.java b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sJobRequest.java
new file mode 100644
index 0000000000..327a08246b
--- /dev/null
+++ b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sJobRequest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.submarine.server.submitter.k8s;
+
+/**
+ * Job request for Kubernetes Submitter.
+ */
+// TODO(jiwq): It should implement the JobRequest interface
+public class K8sJobRequest {
+ private Path path;
+ private Object body;
+ private String jobName;
+
+ public K8sJobRequest(Path path, Object body) {
+ this(path, body, null);
+ }
+
+ public K8sJobRequest(Path path, Object body, String jobName) {
+ this.path = path;
+ this.body = body;
+ this.jobName = jobName;
+ }
+
+ public void setPath(Path path) {
+ this.path = path;
+ }
+
+ public Path getPath() {
+ return path;
+ }
+
+ public void setBody(Object body) {
+ this.body = body;
+ }
+
+ public Object getBody() {
+ return body;
+ }
+
+ public String getJobName() {
+ return jobName;
+ }
+
+ static class Path {
+ private String group;
+ private String apiVersion;
+ private String namespace;
+ private String plural;
+
+ Path(String group, String apiVersion, String namespace, String plural) {
+ this.group = group;
+ this.apiVersion = apiVersion;
+ this.namespace = namespace;
+ this.plural = plural;
+ }
+
+ public String getGroup() {
+ return group;
+ }
+
+ public String getApiVersion() {
+ return apiVersion;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public String getPlural() {
+ return plural;
+ }
+ }
+}
diff --git a/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sJobSubmitter.java b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sJobSubmitter.java
new file mode 100644
index 0000000000..0e6f0ad4b2
--- /dev/null
+++ b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/K8sJobSubmitter.java
@@ -0,0 +1,120 @@
+/*
+ * 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.submarine.server.submitter.k8s;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.gson.Gson;
+import io.kubernetes.client.ApiClient;
+import io.kubernetes.client.ApiException;
+import io.kubernetes.client.Configuration;
+import io.kubernetes.client.apis.CustomObjectsApi;
+import io.kubernetes.client.models.V1DeleteOptions;
+import io.kubernetes.client.models.V1DeleteOptionsBuilder;
+import io.kubernetes.client.util.ClientBuilder;
+import io.kubernetes.client.util.KubeConfig;
+import org.apache.submarine.server.submitter.k8s.model.CustomResourceJob;
+import org.apache.submarine.server.submitter.k8s.model.CustomResourceJobList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.FileReader;
+import java.io.IOException;
+
+/**
+ * JobSubmitter for Kubernetes Cluster.
+ */
+// TODO(jiwq): It should implement the JobSubmitter interface
+public class K8sJobSubmitter {
+ private final Logger LOG = LoggerFactory.getLogger(K8sJobSubmitter.class);
+
+ public K8sJobSubmitter(String confPath) throws IOException {
+ ApiClient client =
+ ClientBuilder.kubeconfig(KubeConfig.loadKubeConfig(new FileReader(confPath))).build();
+ Configuration.setDefaultApiClient(client);
+ }
+
+ public String submitJob(K8sJobRequest request) {
+ return "job_id";
+ }
+
+ @VisibleForTesting
+ CustomResourceJob createCustomJob(K8sJobRequest request) {
+ try {
+ CustomObjectsApi api = new CustomObjectsApi();
+ K8sJobRequest.Path path = request.getPath();
+ Object o = api.createNamespacedCustomObject(path.getGroup(),
+ path.getApiVersion(), path.getNamespace(), path.getPlural(),
+ request.getBody(), "true");
+ Gson gson = new Gson();
+ return gson.fromJson(gson.toJson(o), CustomResourceJob.class);
+ } catch (ApiException ae) {
+ LOG.error("Create CRD job: " + ae.getMessage(), ae);
+ }
+ return null;
+ }
+
+ @VisibleForTesting
+ CustomResourceJob getCustomResourceJob(K8sJobRequest request) {
+ try {
+ CustomObjectsApi api = new CustomObjectsApi();
+ K8sJobRequest.Path path = request.getPath();
+ Object o = api.getNamespacedCustomObject(path.getGroup(), path.getApiVersion(),
+ path.getNamespace(), path.getPlural(), request.getJobName());
+ Gson gson = new Gson();
+ return gson.fromJson(gson.toJson(o), CustomResourceJob.class);
+ } catch (ApiException ae) {
+ LOG.error("Get CRD job: " + ae.getMessage(), ae);
+ }
+ return null;
+ }
+
+ @VisibleForTesting
+ CustomResourceJob deleteCustomResourceJob(K8sJobRequest request) {
+ try {
+ CustomObjectsApi api = new CustomObjectsApi();
+ K8sJobRequest.Path path = request.getPath();
+ V1DeleteOptions body =
+ new V1DeleteOptionsBuilder().withApiVersion(path.getApiVersion()).build();
+ Object o = api.deleteNamespacedCustomObject(path.getGroup(),
+ path.getApiVersion(), path.getNamespace(), path.getPlural(),
+ request.getJobName(), body, null, null, null);
+ Gson gson = new Gson();
+ return gson.fromJson(gson.toJson(o), CustomResourceJob.class);
+ } catch (ApiException ae) {
+ LOG.error("Delete CRD job: " + ae.getMessage(), ae);
+ }
+ return null;
+ }
+
+ @VisibleForTesting
+ CustomResourceJobList listCustomResourceJobs(K8sJobRequest request) {
+ try {
+ CustomObjectsApi api = new CustomObjectsApi();
+ K8sJobRequest.Path path = request.getPath();
+ Object o = api.listNamespacedCustomObject(path.getGroup(), path.getApiVersion(),
+ path.getNamespace(), path.getPlural(), "true", null, null, null, null, null);
+ Gson gson = new Gson();
+ return gson.fromJson(gson.toJson(o), CustomResourceJobList.class);
+ } catch (ApiException ae) {
+ LOG.error("List CRD jobs: " + ae.getMessage(), ae);
+ }
+ return null;
+ }
+}
diff --git a/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/model/CustomResourceJob.java b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/model/CustomResourceJob.java
new file mode 100644
index 0000000000..610fc79984
--- /dev/null
+++ b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/model/CustomResourceJob.java
@@ -0,0 +1,66 @@
+/*
+ * 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.submarine.server.submitter.k8s.model;
+
+import com.google.gson.GsonBuilder;
+import com.google.gson.annotations.SerializedName;
+
+import java.util.Map;
+
+/**
+ * The response job for CRD API.
+ * POST: /apis/{group}/{version}/namespaces/{namespace}/{plural}
+ * GET: /apis/{group}/{version}/namespaces/{namespace}/{plural}/{name}
+ * DELETE: /apis/{group}/{version}/namespaces/{namespace}/{plural}/{name}
+ */
+public class CustomResourceJob {
+ @SerializedName("apiVersion")
+ private String apiVersion;
+
+ @SerializedName("kind")
+ protected String kind;
+
+ @SerializedName("metadata")
+ private ObjectMeta metadata;
+
+ @SerializedName("spec")
+ private Map spec;
+
+ public String getApiVersion() {
+ return apiVersion;
+ }
+
+ public String getKind() {
+ return kind;
+ }
+
+ public ObjectMeta getMetadata() {
+ return metadata;
+ }
+
+ public Map getSpec() {
+ return spec;
+ }
+
+ @Override
+ public String toString() {
+ return new GsonBuilder().setPrettyPrinting().create().toJson(this);
+ }
+}
diff --git a/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/model/CustomResourceJobList.java b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/model/CustomResourceJobList.java
new file mode 100644
index 0000000000..3ad0114baa
--- /dev/null
+++ b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/model/CustomResourceJobList.java
@@ -0,0 +1,86 @@
+/*
+ * 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.submarine.server.submitter.k8s.model;
+
+import com.google.gson.GsonBuilder;
+import com.google.gson.annotations.SerializedName;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * The response for CRD API.
+ * GET: /apis/{group}/{version}/namespaces/{namespace}/{plural}
+ */
+public class CustomResourceJobList {
+ @SerializedName("apiVersion")
+ private String apiVersion;
+
+ @SerializedName("items")
+ private List
diff --git a/submarine-workbench/interpreter/spark-interpreter/src/main/java/org/apache/submarine/interpreter/SparkInterpreter.java b/submarine-workbench/interpreter/spark-interpreter/src/main/java/org/apache/submarine/interpreter/SparkInterpreter.java
index 40ee1604c3..132ef60e2a 100644
--- a/submarine-workbench/interpreter/spark-interpreter/src/main/java/org/apache/submarine/interpreter/SparkInterpreter.java
+++ b/submarine-workbench/interpreter/spark-interpreter/src/main/java/org/apache/submarine/interpreter/SparkInterpreter.java
@@ -18,158 +18,76 @@
*/
package org.apache.submarine.interpreter;
-import org.apache.commons.lang.StringUtils;
-import org.apache.zeppelin.interpreter.InterpreterContext;
-import org.apache.zeppelin.interpreter.InterpreterException;
-import org.apache.zeppelin.interpreter.InterpreterGroup;
-import org.apache.zeppelin.interpreter.InterpreterResultMessage;
+import org.apache.spark.SparkContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Properties;
-public class SparkInterpreter extends InterpreterProcess {
+public class SparkInterpreter extends AbstractInterpreter {
private static final Logger LOG = LoggerFactory.getLogger(SparkInterpreter.class);
- private org.apache.zeppelin.spark.SparkInterpreter zpleSparkInterpreter;
- private InterpreterContext intpContext;
-
- private String extractScalaVersion() throws InterpreterException {
- String scalaVersionString = scala.util.Properties.versionString();
- LOG.info("Using Scala: " + scalaVersionString);
- if (scalaVersionString.contains("version 2.10")) {
- return "2.10";
- } else if (scalaVersionString.contains("version 2.11")) {
- return "2.11";
- } else if (scalaVersionString.contains("version 2.12")) {
- return "2.12";
- } else {
- throw new InterpreterException("Unsupported scala version: " + scalaVersionString);
- }
- }
-
public SparkInterpreter(Properties properties) {
- properties = mergeZeplSparkIntpProp(properties);
- zpleSparkInterpreter = new org.apache.zeppelin.spark.SparkInterpreter(properties);
- zpleSparkInterpreter.setInterpreterGroup(new InterpreterGroup());
- intpContext = this.getIntpContext();
+ properties = mergeZeppelinInterpreterProperties(properties);
+ this.zeppelinInterpreter = new org.apache.zeppelin.spark.SparkInterpreter(properties);
+ this.setInterpreterGroup(new InterpreterGroup());
}
+
public SparkInterpreter() {
this(new Properties());
}
@Override
- public void open() {
+ public boolean test() {
try {
- ClassLoader scalaInterpreterClassLoader = null;
- String submarineHome = System.getenv("SUBMARINE_HOME");
- String interpreterDir = "";
- if (StringUtils.isBlank(submarineHome)) {
- LOG.warn("SUBMARINE_HOME is not set, default interpreter directory is ../ ");
- interpreterDir = "..";
- } else {
- interpreterDir = submarineHome + "/workbench/interpreter";
+ open();
+ String code = "val df = spark.createDataFrame(Seq((1,\"a\"),(2, null)))\n" +
+ "df.show()";
+ InterpreterResult result = interpret(code);
+ LOG.info("Execution Spark Interpreter, Calculation Spark Code {}, Result = {}",
+ code, result.message().get(0).getData()
+ );
+
+ if (result.code() != InterpreterResult.Code.SUCCESS) {
+ close();
+ return false;
}
- String scalaVersion = extractScalaVersion();
- File scalaJarFolder = new File(interpreterDir + "/spark/scala-" + scalaVersion);
- List urls = new ArrayList<>();
- for (File file : scalaJarFolder.listFiles()) {
- LOG.info("Add file " + file.getAbsolutePath() + " to classpath of spark scala interpreter: "
- + scalaJarFolder);
- urls.add(file.toURI().toURL());
- }
- scalaInterpreterClassLoader = new URLClassLoader(urls.toArray(new URL[0]),
- Thread.currentThread().getContextClassLoader());
- if (scalaInterpreterClassLoader != null) {
- Thread.currentThread().setContextClassLoader(scalaInterpreterClassLoader);
- }
- zpleSparkInterpreter.open();
+ boolean success = (result.message().get(0).getData().contains(
+ "+---+----+\n" +
+ "| _1| _2|\n" +
+ "+---+----+\n" +
+ "| 1| a|\n" +
+ "| 2|null|\n" +
+ "+---+----+")
+ );
+ close();
+ return success;
} catch (InterpreterException e) {
LOG.error(e.getMessage(), e);
- } catch (MalformedURLException e) {
- LOG.error(e.getMessage(), e);
- }
- }
-
- @Override
- public InterpreterResult interpret(String code) {
- InterpreterResult interpreterResult = null;
- try {
- org.apache.zeppelin.interpreter.InterpreterResult zeplInterpreterResult
- = zpleSparkInterpreter.interpret(code, intpContext);
- interpreterResult = new InterpreterResult(zeplInterpreterResult);
-
- List interpreterResultMessages =
- intpContext.out.toInterpreterResultMessage();
-
- for (org.apache.zeppelin.interpreter.InterpreterResultMessage message : interpreterResultMessages) {
- interpreterResult.add(message);
- }
- } catch (InterpreterException | IOException e) {
- LOG.error(e.getMessage(), e);
+ return false;
}
-
- return interpreterResult;
}
- @Override
- public void close() {
- try {
- zpleSparkInterpreter.close();
- } catch (InterpreterException e) {
- LOG.error(e.getMessage(), e);
- }
+ public SparkContext getSparkContext() {
+ return ((org.apache.zeppelin.spark.SparkInterpreter) this.zeppelinInterpreter).getSparkContext();
}
- @Override
- public void cancel() {
- try {
- zpleSparkInterpreter.cancel(intpContext);
- } catch (InterpreterException e) {
- LOG.error(e.getMessage(), e);
- }
+ public void setSchedulerPool(String pool){
+ this.getIntpContext().getLocalProperties().put("pool", pool);
}
@Override
- public int getProgress() {
- int process = 0;
- try {
- process = zpleSparkInterpreter.getProgress(intpContext);
- } catch (InterpreterException e) {
- LOG.error(e.getMessage(), e);
- }
-
- return process;
- }
+ protected Properties mergeZeppelinInterpreterProperties(Properties properties) {
+ properties = super.mergeZeppelinInterpreterProperties(properties);
+ Properties defaultProperties = new Properties();
- @Override
- public boolean test() {
- open();
- String code = "val df = spark.createDataFrame(Seq((1,\"a\"),(2, null)))\n" +
- "df.show()";
- InterpreterResult result = interpret(code);
- LOG.info("Execution Spark Interpreter, Calculation Spark Code {}, Result = {}",
- code, result.message().get(0).getData());
+ defaultProperties.setProperty("zeppelin.spark.maxResult", "1000");
+ defaultProperties.setProperty("zeppelin.spark.scala.color", "false");
- if (result.code() != InterpreterResult.Code.SUCCESS) {
- close();
- return false;
+ if (null != properties) {
+ defaultProperties.putAll(properties);
}
- boolean success = (result.message().get(0).getData().contains(
- "+---+----+\n" +
- "| _1| _2|\n" +
- "+---+----+\n" +
- "| 1| a|\n" +
- "| 2|null|\n" +
- "+---+----+"));
- close();
- return success;
+ return defaultProperties;
}
+
}
diff --git a/submarine-workbench/interpreter/spark-interpreter/src/main/java/org/apache/submarine/interpreter/SparkSqlInterpreter.java b/submarine-workbench/interpreter/spark-interpreter/src/main/java/org/apache/submarine/interpreter/SparkSqlInterpreter.java
new file mode 100644
index 0000000000..a9732cbdb3
--- /dev/null
+++ b/submarine-workbench/interpreter/spark-interpreter/src/main/java/org/apache/submarine/interpreter/SparkSqlInterpreter.java
@@ -0,0 +1,89 @@
+/*
+ * 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.submarine.interpreter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.LinkedList;
+import java.util.Properties;
+
+public class SparkSqlInterpreter extends AbstractInterpreter {
+ private static final Logger LOG = LoggerFactory.getLogger(SparkInterpreter.class);
+
+ public SparkSqlInterpreter(Properties properties) {
+ properties = mergeZeppelinInterpreterProperties(properties);
+ this.zeppelinInterpreter = new org.apache.zeppelin.spark.SparkSqlInterpreter(properties);
+ }
+
+ public SparkSqlInterpreter() {
+ this(new Properties());
+ }
+
+
+ @Override
+ public boolean test() {
+ try {
+ InterpreterGroup intpGroup = new InterpreterGroup();
+ SparkInterpreter sparkInterpreter = new SparkInterpreter();
+ sparkInterpreter.setInterpreterGroup(intpGroup);
+
+ this.setInterpreterGroup(intpGroup);
+
+ String session = "session_1";
+ intpGroup.put(session, new LinkedList<>());
+ sparkInterpreter.addToSession(session);
+ this.addToSession(session);
+
+ sparkInterpreter.open();
+ open();
+
+ sparkInterpreter.interpret("case class Person(name:String, age:Int)");
+ sparkInterpreter.interpret("case class People(group:String, person:Person)");
+ sparkInterpreter.interpret(
+ "val gr = sc.parallelize(Seq(" +
+ "People(\"g1\", " +
+ "Person(\"moon\",33)), " +
+ "People(\"g2\", " +
+ "Person(\"sun\",11" +
+ "))))");
+ sparkInterpreter.interpret("gr.toDF.registerTempTable(\"gr\")");
+
+ InterpreterResult result = interpret("select * from gr");
+ LOG.info("Execution SparkSQL Interpreter, Calculation Spark Code {}, Result =\n {}",
+ result.code(), result.message().get(0).getData()
+ );
+ if (result.code() != InterpreterResult.Code.SUCCESS) {
+ return false;
+ }
+ if (!result.message().get(0).getData().contains("[moon,33]") ||
+ !result.message().get(0).getData().contains("[sun,11]")) {
+ return false;
+ }
+ return true;
+ } catch (InterpreterException e) {
+ LOG.error(e.getMessage(), e);
+ return false;
+ }
+ }
+
+ public void setResultLimits(long number){
+ getIntpContext().getLocalProperties().put("limit", String.valueOf(number));
+ }
+}
diff --git a/submarine-workbench/interpreter/spark-interpreter/src/test/java/org/apache/submarine/interpreter/SparkInterpreterTest.java b/submarine-workbench/interpreter/spark-interpreter/src/test/java/org/apache/submarine/interpreter/SparkInterpreterTest.java
index 9672e21a21..3a2f8b6b45 100644
--- a/submarine-workbench/interpreter/spark-interpreter/src/test/java/org/apache/submarine/interpreter/SparkInterpreterTest.java
+++ b/submarine-workbench/interpreter/spark-interpreter/src/test/java/org/apache/submarine/interpreter/SparkInterpreterTest.java
@@ -17,65 +17,42 @@
package org.apache.submarine.interpreter;
-import org.apache.zeppelin.display.AngularObjectRegistry;
-import org.apache.zeppelin.interpreter.InterpreterContext;
-
-import org.apache.zeppelin.interpreter.InterpreterOutput;
-import org.apache.zeppelin.interpreter.InterpreterOutputListener;
-import org.apache.zeppelin.interpreter.InterpreterResultMessageOutput;
-import org.apache.zeppelin.interpreter.remote.RemoteInterpreterEventClient;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.io.IOException;
import java.util.Properties;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
+import static org.junit.Assert.fail;
public class SparkInterpreterTest {
private SparkInterpreter interpreter;
// catch the streaming output in onAppend
private volatile String output = "";
- // catch the interpreter output in onUpdate
- private InterpreterResultMessageOutput messageOutput;
-
- private RemoteInterpreterEventClient mockRemoteEventClient;
@Before
public void setUp() {
- mockRemoteEventClient = mock(RemoteInterpreterEventClient.class);
+ // SparkInterpreter will change the current thread's classLoader
+ Thread.currentThread().setContextClassLoader(SparkInterpreterTest.class.getClassLoader());
}
@Test
- public void testSparkInterpreter() throws InterruptedException {
+ public void testSparkInterpreter() throws InterruptedException, InterpreterException {
Properties properties = new Properties();
properties.setProperty("spark.master", "local");
properties.setProperty("spark.app.name", "test");
- properties.setProperty("zeppelin.spark.maxResult", "100");
- properties.setProperty("zeppelin.spark.test", "true");
- properties.setProperty("zeppelin.spark.uiWebUrl", "fake_spark_weburl");
+ properties.setProperty("submarine.spark.scala.color", "false");
+ properties.setProperty("submarine.spark.test", "true");
+ properties.setProperty("submarine.spark.uiWebUrl", "fake_spark_weburl");
// disable color output for easy testing
- properties.setProperty("zeppelin.spark.scala.color", "false");
- properties.setProperty("zeppelin.spark.deprecatedMsg.show", "false");
-
- InterpreterContext context = InterpreterContext.builder()
- .setInterpreterOut(new InterpreterOutput(null))
- .setIntpEventClient(mockRemoteEventClient)
- .setAngularObjectRegistry(new AngularObjectRegistry("spark", null))
- .build();
- InterpreterContext.set(context);
-
- interpreter = new SparkInterpreter();
- try {
- interpreter.open();
- } catch (Throwable ex) {
- ex.printStackTrace();
- }
+ properties.setProperty("submarine.spark.deprecatedMsg.show", "false");
+ interpreter = new SparkInterpreter(properties);
+
+ interpreter.open();
InterpreterResult result = interpreter.interpret("val a=\"hello world\"");
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
@@ -126,24 +103,23 @@ public void testSparkInterpreter() throws InterruptedException {
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
// Companion object with case class
- result = interpreter.interpret("import scala.math._\n" +
- "object Circle {\n" +
- " private def calculateArea(radius: Double): Double = Pi * pow(radius, 2.0)\n" +
- "}\n" +
- "case class Circle(radius: Double) {\n" +
- " import Circle._\n" +
- " def area: Double = calculateArea(radius)\n" +
- "}\n" +
- "\n" +
- "val circle1 = new Circle(5.0)");
+ result = interpreter.interpret(
+ "import scala.math._\n" +
+ "object Circle {\n" +
+ "private def calculateArea(radius: Double): Double = Pi * pow(radius, 2.0)\n" +
+ "}\n" +
+ "case class Circle(radius: Double) {\n" +
+ " import Circle._\n" +
+ " def area: Double = calculateArea(radius)\n" +
+ "}\n" +
+ "\n" +
+ "val circle1 = new Circle(5.0)");
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
// class extend
result = interpreter.interpret("import java.util.ArrayList");
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
- context = getInterpreterContext();
- context.setParagraphId("pid_1");
result = interpreter.interpret("sc\n.range(1, 10)\n.sum");
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
assertTrue(result.message().get(0).getData().contains("45"));
@@ -154,15 +130,15 @@ public void testSparkInterpreter() throws InterruptedException {
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
result = interpreter.interpret(
- "case class Bank(age:Integer, job:String, marital : String, edu : String, balance : Integer)\n" +
- "val bank = bankText.map(s=>s.split(\";\")).filter(s => s(0)!=\"\\\"age\\\"\").map(\n" +
- " s => Bank(s(0).toInt, \n" +
- " s(1).replaceAll(\"\\\"\", \"\"),\n" +
- " s(2).replaceAll(\"\\\"\", \"\"),\n" +
- " s(3).replaceAll(\"\\\"\", \"\"),\n" +
- " s(5).replaceAll(\"\\\"\", \"\").toInt\n" +
- " )\n" +
- ").toDF()");
+ "case class Bank(age:Integer, job:String, marital : String, edu : String, balance : Integer)\n" +
+ "val bank = bankText.map(s=>s.split(\";\")).filter(s => s(0)!=\"\\\"age\\\"\").map(\n" +
+ " s => Bank(s(0).toInt, \n" +
+ " s(1).replaceAll(\"\\\"\", \"\"),\n" +
+ " s(2).replaceAll(\"\\\"\", \"\"),\n" +
+ " s(3).replaceAll(\"\\\"\", \"\"),\n" +
+ " s(5).replaceAll(\"\\\"\", \"\").toInt\n" +
+ " )\n" +
+ ").toDF()");
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
// spark version
@@ -176,11 +152,11 @@ public void testSparkInterpreter() throws InterruptedException {
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
result = interpreter.interpret(
- "val df = sqlContext.createDataFrame(Seq((1,\"a\"),(2, null)))\n" +
- "df.show()");
+ "val df = sqlContext.createDataFrame(Seq((1,\"a\"),(2, null)))\n" +
+ "df.show()");
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
assertTrue(result.message().get(0).getData().contains(
- "+---+----+\n" +
+ "+---+----+\n" +
"| _1| _2|\n" +
"+---+----+\n" +
"| 1| a|\n" +
@@ -191,11 +167,11 @@ public void testSparkInterpreter() throws InterruptedException {
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
result = interpreter.interpret(
- "val df = spark.createDataFrame(Seq((1,\"a\"),(2, null)))\n" +
- "df.show()");
+ "val df = spark.createDataFrame(Seq((1,\"a\"),(2, null)))\n" +
+ "df.show()");
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
assertTrue(result.message().get(0).getData().contains(
- "+---+----+\n" +
+ "+---+----+\n" +
"| _1| _2|\n" +
"+---+----+\n" +
"| 1| a|\n" +
@@ -203,7 +179,7 @@ public void testSparkInterpreter() throws InterruptedException {
"+---+----+"));
}
- // ZeppelinContext
+ // submarineContext
result = interpreter.interpret("z.show(df)");
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
assertEquals(InterpreterResult.Type.TABLE, result.message().get(0).getType());
@@ -213,15 +189,16 @@ public void testSparkInterpreter() throws InterruptedException {
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
// getProgress;
- Thread interpretThread = new Thread() {
- @Override
- public void run() {
- InterpreterResult result = null;
- result = interpreter.interpret(
- "val df = sc.parallelize(1 to 10, 5).foreach(e=>Thread.sleep(1000))");
- assertEquals(InterpreterResult.Code.SUCCESS, result.code());
+ Thread interpretThread = new Thread(() -> {
+ try {
+ InterpreterResult result1 = interpreter.interpret(
+ "val df = sc.parallelize(1 to 10, 5).foreach(e=>Thread.sleep(1000))");
+ assertEquals(InterpreterResult.Code.SUCCESS, result1.code());
+ } catch (InterpreterException e) {
+ e.printStackTrace();
+ fail();
}
- };
+ });
interpretThread.start();
boolean nonZeroProgress = false;
int progress = 0;
@@ -235,16 +212,17 @@ public void run() {
}
assertTrue(nonZeroProgress);
- interpretThread = new Thread() {
- @Override
- public void run() {
- InterpreterResult result = null;
- result = interpreter.interpret(
- "val df = sc.parallelize(1 to 10, 2).foreach(e=>Thread.sleep(1000))");
- assertEquals(InterpreterResult.Code.ERROR, result.code());
- assertTrue(result.message().get(0).getData().contains("cancelled"));
+ interpretThread = new Thread(() -> {
+ try {
+ InterpreterResult result12 = interpreter.interpret(
+ "val df = sc.parallelize(1 to 10, 2).foreach(e=>Thread.sleep(1000))");
+ assertEquals(InterpreterResult.Code.ERROR, result12.code());
+ assertTrue(result12.message().get(0).getData().contains("cancelled"));
+ } catch (org.apache.submarine.interpreter.InterpreterException e) {
+ e.printStackTrace();
+ fail();
}
- };
+ });
interpretThread.start();
// sleep 1 second to wait for the spark job start
@@ -254,19 +232,18 @@ public void run() {
}
@Test
- public void testDisableReplOutput() {
+ public void testDisableReplOutput() throws InterpreterException {
Properties properties = new Properties();
properties.setProperty("spark.master", "local");
properties.setProperty("spark.app.name", "test");
- properties.setProperty("zeppelin.spark.maxResult", "100");
- properties.setProperty("zeppelin.spark.test", "true");
- properties.setProperty("zeppelin.spark.printREPLOutput", "false");
+ properties.setProperty("submarine.spark.maxResult", "100");
+ properties.setProperty("submarine.spark.test", "true");
+ properties.setProperty("submarine.spark.printREPLOutput", "false");
// disable color output for easy testing
- properties.setProperty("zeppelin.spark.scala.color", "false");
- properties.setProperty("zeppelin.spark.deprecatedMsg.show", "false");
+ properties.setProperty("submarine.spark.scala.color", "false");
+ properties.setProperty("submarine.spark.deprecatedMsg.show", "false");
- InterpreterContext.set(getInterpreterContext());
- interpreter = new SparkInterpreter();
+ interpreter = new SparkInterpreter(properties);
interpreter.open();
InterpreterResult result = interpreter.interpret("val a=\"hello world\"");
@@ -281,42 +258,41 @@ public void testDisableReplOutput() {
}
@Test
- public void testSchedulePool() {
+ public void testSchedulePool() throws InterpreterException {
Properties properties = new Properties();
properties.setProperty("spark.master", "local");
properties.setProperty("spark.app.name", "test");
- properties.setProperty("zeppelin.spark.maxResult", "100");
- properties.setProperty("zeppelin.spark.test", "true");
+ properties.setProperty("submarine.spark.maxResult", "100");
+ properties.setProperty("submarine.spark.test", "true");
properties.setProperty("spark.scheduler.mode", "FAIR");
// disable color output for easy testing
- properties.setProperty("zeppelin.spark.scala.color", "false");
- properties.setProperty("zeppelin.spark.deprecatedMsg.show", "false");
+ properties.setProperty("submarine.spark.scala.color", "false");
+ properties.setProperty("submarine.spark.deprecatedMsg.show", "false");
+ properties.setProperty("spark.scheduler.pool", "pool1");
- interpreter = new SparkInterpreter();
- InterpreterContext.set(getInterpreterContext());
+ interpreter = new SparkInterpreter(properties);
+ interpreter.setSchedulerPool("pool1");
interpreter.open();
InterpreterResult result = interpreter.interpret("sc.range(1, 10).sum");
- // pool is reset to null if user don't specify it via paragraph properties
- result = interpreter.interpret("sc.range(1, 10).sum");
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
+ assertEquals("pool1", interpreter.getSparkContext().getLocalProperty("spark.scheduler.pool"));
}
// spark.ui.enabled: false
@Test
- public void testDisableSparkUI_1() {
+ public void testDisableSparkUI_1() throws InterpreterException {
Properties properties = new Properties();
properties.setProperty("spark.master", "local");
properties.setProperty("spark.app.name", "test");
- properties.setProperty("zeppelin.spark.maxResult", "100");
- properties.setProperty("zeppelin.spark.test", "true");
+ properties.setProperty("submarine.spark.maxResult", "100");
+ properties.setProperty("submarine.spark.test", "true");
properties.setProperty("spark.ui.enabled", "false");
// disable color output for easy testing
- properties.setProperty("zeppelin.spark.scala.color", "false");
- properties.setProperty("zeppelin.spark.deprecatedMsg.show", "false");
+ properties.setProperty("submarine.spark.scala.color", "false");
+ properties.setProperty("submarine.spark.deprecatedMsg.show", "false");
- interpreter = new SparkInterpreter();
- InterpreterContext.set(getInterpreterContext());
+ interpreter = new SparkInterpreter(properties);
interpreter.open();
InterpreterResult result = interpreter.interpret("sc.range(1, 10).sum");
@@ -324,21 +300,20 @@ public void testDisableSparkUI_1() {
}
- // zeppelin.spark.ui.hidden: true
+ // submarine.spark.ui.hidden: true
@Test
- public void testDisableSparkUI_2() {
+ public void testDisableSparkUI_2() throws InterpreterException {
Properties properties = new Properties();
properties.setProperty("spark.master", "local");
properties.setProperty("spark.app.name", "test");
- properties.setProperty("zeppelin.spark.maxResult", "100");
- properties.setProperty("zeppelin.spark.test", "true");
- properties.setProperty("zeppelin.spark.ui.hidden", "true");
+ properties.setProperty("submarine.spark.maxResult", "100");
+ properties.setProperty("submarine.spark.test", "true");
+ properties.setProperty("submarine.spark.ui.hidden", "true");
// disable color output for easy testing
- properties.setProperty("zeppelin.spark.scala.color", "false");
- properties.setProperty("zeppelin.spark.deprecatedMsg.show", "false");
+ properties.setProperty("submarine.spark.scala.color", "false");
+ properties.setProperty("submarine.spark.deprecatedMsg.show", "false");
- interpreter = new SparkInterpreter();
- InterpreterContext.set(getInterpreterContext());
+ interpreter = new SparkInterpreter(properties);
interpreter.open();
InterpreterResult result = interpreter.interpret("sc.range(1, 10).sum");
@@ -347,41 +322,9 @@ public void testDisableSparkUI_2() {
@After
- public void tearDown() {
+ public void tearDown() throws InterpreterException {
if (this.interpreter != null) {
this.interpreter.close();
}
}
-
- private InterpreterContext getInterpreterContext() {
- output = "";
- InterpreterContext context = InterpreterContext.builder()
- .setInterpreterOut(new InterpreterOutput(null))
- .setIntpEventClient(mockRemoteEventClient)
- .setAngularObjectRegistry(new AngularObjectRegistry("spark", null))
- .build();
- context.out = new InterpreterOutput(
- new InterpreterOutputListener() {
- @Override
- public void onUpdateAll(InterpreterOutput out) {
-
- }
-
- @Override
- public void onAppend(int index, InterpreterResultMessageOutput out, byte[] line) {
- try {
- output = out.toInterpreterResultMessage().getData();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void onUpdate(int index, InterpreterResultMessageOutput out) {
- messageOutput = out;
- }
- }
- );
- return context;
- }
}
diff --git a/submarine-workbench/interpreter/spark-interpreter/src/test/java/org/apache/submarine/interpreter/SparkSqlInterpreterTest.java b/submarine-workbench/interpreter/spark-interpreter/src/test/java/org/apache/submarine/interpreter/SparkSqlInterpreterTest.java
new file mode 100644
index 0000000000..ea3d9a1670
--- /dev/null
+++ b/submarine-workbench/interpreter/spark-interpreter/src/test/java/org/apache/submarine/interpreter/SparkSqlInterpreterTest.java
@@ -0,0 +1,204 @@
+/*
+ * 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.submarine.interpreter;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.LinkedList;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class SparkSqlInterpreterTest {
+
+ private static SparkSqlInterpreter sqlInterpreter;
+ private static SparkInterpreter sparkInterpreter;
+
+ @BeforeClass
+ public static void setUp() throws InterpreterException {
+ Properties p = new Properties();
+ p.setProperty("spark.master", "local[4]");
+ p.setProperty("spark.app.name", "test");
+ p.setProperty("submarine.spark.maxResult", "10");
+ p.setProperty("submarine.spark.concurrentSQL", "true");
+ p.setProperty("submarine.spark.sql.stacktrace", "true");
+ p.setProperty("submarine.spark.useHiveContext", "true");
+ p.setProperty("submarine.spark.deprecatedMsg.show", "false");
+
+ sqlInterpreter = new SparkSqlInterpreter(p);
+
+ InterpreterGroup intpGroup = new InterpreterGroup();
+ sparkInterpreter = new SparkInterpreter(p);
+ sparkInterpreter.setInterpreterGroup(intpGroup);
+
+ sqlInterpreter = new SparkSqlInterpreter(p);
+ sqlInterpreter.setInterpreterGroup(intpGroup);
+
+ String session = "session_1";
+ intpGroup.put(session, new LinkedList<>());
+ sparkInterpreter.addToSession(session);
+ sqlInterpreter.addToSession(session);
+
+ //SparkInterpreter will change the current thread's classLoader
+ Thread.currentThread().setContextClassLoader(SparkInterpreterTest.class.getClassLoader());
+
+ sparkInterpreter.open();
+ sqlInterpreter.open();
+ }
+
+ @AfterClass
+ public static void tearDown() throws InterpreterException {
+ sqlInterpreter.close();
+ }
+
+ @Test
+ public void test() throws InterpreterException {
+ sparkInterpreter.interpret("case class Test(name:String, age:Int)");
+ sparkInterpreter.interpret(
+ "val test = sc.parallelize(Seq(" +
+ " Test(\"moon\", 33)," +
+ " Test(\"jobs\", 51)," +
+ " Test(\"gates\", 51)," +
+ " Test(\"park\", 34)" +
+ "))");
+ sparkInterpreter.interpret("test.toDF.registerTempTable(\"test\")");
+
+ InterpreterResult ret = sqlInterpreter.interpret("select name, age from test where age < 40");
+ assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
+ assertEquals(org.apache.submarine.interpreter.InterpreterResult.Type.TABLE,
+ ret.message().get(0).getType()
+ );
+ assertEquals("name\tage\nmoon\t33\npark\t34\n", ret.message().get(0).getData());
+
+ ret = sqlInterpreter.interpret("select wrong syntax");
+ assertEquals(InterpreterResult.Code.ERROR, ret.code());
+ assertTrue(ret.message().get(0).getData().length() > 0);
+
+ assertEquals(InterpreterResult.Code.SUCCESS,
+ sqlInterpreter.interpret("select case when name='aa' then name else name end from test")
+ .code()
+ );
+ }
+
+ @Test
+ public void testStruct() throws InterpreterException {
+ sparkInterpreter.interpret("case class Person(name:String, age:Int)");
+ sparkInterpreter.interpret("case class People(group:String, person:Person)");
+ sparkInterpreter.interpret(
+ "val gr = sc.parallelize(Seq(" +
+ "People(\"g1\", " +
+ "Person(\"moon\",33)), " +
+ "People(\"g2\", " +
+ "Person(\"sun\",11" +
+ "))))");
+ sparkInterpreter.interpret("gr.toDF.registerTempTable(\"gr\")");
+
+ InterpreterResult ret = sqlInterpreter.interpret("select * from gr");
+ assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
+ assertTrue(ret.message().get(0).getData().contains("[moon,33]"));
+ assertTrue(ret.message().get(0).getData().contains("[sun,11]"));
+ }
+
+
+ @Test
+ public void testMaxResults() throws InterpreterException {
+ sparkInterpreter.interpret("case class P(age:Int)");
+ sparkInterpreter.interpret(
+ "val gr = sc.parallelize(Seq(P(1),P(2),P(3),P(4),P(5),P(6),P(7),P(8),P(9),P(10),P(11)))");
+ sparkInterpreter.interpret("gr.toDF.registerTempTable(\"gr\")");
+
+ InterpreterResult ret = sqlInterpreter.interpret("select * from gr");
+ assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
+ // the number of rows is 10+1, 1 is the head of table
+ assertEquals(11, ret.message().get(0).getData().split("\n").length);
+ assertTrue(ret.message().get(1).getData().contains("alert-warning"));
+
+ // test limit local property
+ sqlInterpreter.setResultLimits(5);
+ ret = sqlInterpreter.interpret("select * from gr");
+ assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
+ // the number of rows is 5+1, 1 is the head of table
+ assertEquals(6, ret.message().get(0).getData().split("\n").length);
+ }
+
+ @Test
+ public void testConcurrentSQL() throws InterruptedException, InterpreterException {
+
+ sparkInterpreter.interpret("spark.udf.register(\"sleep\", (e:Int) => {Thread.sleep(e*1000); e})");
+
+
+ Thread thread1 = new Thread(() -> {
+ try {
+ InterpreterResult result = sqlInterpreter.interpret("select sleep(10)");
+ assertEquals(InterpreterResult.Code.SUCCESS, result.code());
+ } catch (InterpreterException e) {
+ e.printStackTrace();
+ }
+ });
+
+ Thread thread2 = new Thread(() -> {
+ try {
+ InterpreterResult result = sqlInterpreter.interpret("select sleep(10)");
+ assertEquals(InterpreterResult.Code.SUCCESS, result.code());
+ } catch (InterpreterException e) {
+ e.printStackTrace();
+ }
+ });
+
+ // start running 2 spark sql, each would sleep 10 seconds, the totally running time should
+ // be less than 20 seconds, which means they run concurrently.
+ long start = System.currentTimeMillis();
+ thread1.start();
+ thread2.start();
+ thread1.join();
+ thread2.join();
+ long end = System.currentTimeMillis();
+ assertTrue("running time must be less than 20 seconds", ((end - start) / 1000) < 20);
+
+ }
+
+ @Test
+ public void testDDL() throws InterpreterException {
+ InterpreterResult ret = sqlInterpreter.interpret("create table t1(id int, name string)");
+ assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
+ // spark 1.x will still return DataFrame with non-empty columns.
+ // org.apache.spark.sql.DataFrame = [result: string]
+
+ assertTrue(ret.message().isEmpty());
+
+ // create the same table again
+ ret = sqlInterpreter.interpret("create table t1(id int, name string)");
+ assertEquals(InterpreterResult.Code.ERROR, ret.code());
+ assertEquals(1, ret.message().size());
+ assertEquals(InterpreterResult.Type.TEXT,
+ ret.message().get(0).getType()
+ );
+ assertTrue(ret.message().get(0).getData().contains("already exists"));
+
+ // invalid DDL
+ ret = sqlInterpreter.interpret("create temporary function udf1 as 'org.apache.submarine.UDF'");
+ assertEquals(InterpreterResult.Code.ERROR, ret.code());
+ assertEquals(1, ret.message().size());
+ assertEquals(InterpreterResult.Type.TEXT,
+ ret.message().get(0).getType()
+ );
+
+ }
+}
diff --git a/submarine-workbench/interpreter/spark-interpreter/src/test/resources/hive-site.xml b/submarine-workbench/interpreter/spark-interpreter/src/test/resources/hive-site.xml
new file mode 100644
index 0000000000..e38c7be581
--- /dev/null
+++ b/submarine-workbench/interpreter/spark-interpreter/src/test/resources/hive-site.xml
@@ -0,0 +1,7 @@
+
+
+ hive.metastore.warehouse.dir
+ ${user.home}/hive/warehouse
+ location of default database for the warehouse
+
+
\ No newline at end of file
diff --git a/submarine-workbench/interpreter/spark-interpreter/src/test/resources/log4j.properties b/submarine-workbench/interpreter/spark-interpreter/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..d7a86238a4
--- /dev/null
+++ b/submarine-workbench/interpreter/spark-interpreter/src/test/resources/log4j.properties
@@ -0,0 +1,35 @@
+# 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.
+
+# Define some default values that can be overridden by system properties
+submarine.log.threshold=ALL
+submarine.root.logger=INFO, console
+
+log4j.rootLogger=${submarine.root.logger}
+
+# Logging Threshold
+log4j.threshold=${submarine.log.threshold}
+
+#
+# console
+# Add "console" to rootlogger above if you want to use this
+#
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.target=System.err
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} [%t]: %p %c{2}: %m%n
+log4j.appender.console.encoding=UTF-8
diff --git a/submarine-workbench/pom.xml b/submarine-workbench/pom.xml
index 0fc9ae9af2..0ef2294192 100644
--- a/submarine-workbench/pom.xml
+++ b/submarine-workbench/pom.xml
@@ -40,7 +40,6 @@
interpreterworkbench-webworkbench-web-ng
- workbench-server
diff --git a/submarine-workbench/workbench-web-ng/angular.json b/submarine-workbench/workbench-web-ng/angular.json
index c47d29ddb1..b8ea29d7ec 100644
--- a/submarine-workbench/workbench-web-ng/angular.json
+++ b/submarine-workbench/workbench-web-ng/angular.json
@@ -101,7 +101,8 @@
"styles": [
"src/styles.scss"
],
- "scripts": []
+ "scripts": [],
+ "codeCoverage": true
}
},
"lint": {
@@ -133,4 +134,4 @@
}
},
"defaultProject": "workbench-web-ng"
-}
\ No newline at end of file
+}
diff --git a/submarine-workbench/workbench-web-ng/e2e/protractor-ci.conf.js b/submarine-workbench/workbench-web-ng/e2e/protractor-ci.conf.js
new file mode 100644
index 0000000000..11abcc4b92
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/e2e/protractor-ci.conf.js
@@ -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.
+ */
+
+// @ts-check
+// Protractor configuration file, see link for more information
+// https://github.com/angular/protractor/blob/master/lib/config.ts
+
+const config = require('./protractor.conf').config;
+
+config.capabilities = {
+ browserName: 'chrome',
+ chromeOptions: {
+ args: ['--headless', '--no-sandbox']
+ }
+};
+
+exports.config = config;
diff --git a/submarine-workbench/workbench-web-ng/e2e/src/app.e2e-spec.ts b/submarine-workbench/workbench-web-ng/e2e/src/app.e2e-spec.ts
index 5b0d8f69ef..d91a449404 100644
--- a/submarine-workbench/workbench-web-ng/e2e/src/app.e2e-spec.ts
+++ b/submarine-workbench/workbench-web-ng/e2e/src/app.e2e-spec.ts
@@ -27,9 +27,9 @@ describe('workspace-project App', () => {
page = new AppPage();
});
- it('should display welcome message', () => {
+ it('should display submarine', () => {
page.navigateTo();
- expect(page.getTitleText()).toEqual('workbench-web-ng app is running!');
+ expect(page.getTitleText()).toEqual('Submarine');
});
afterEach(async () => {
diff --git a/submarine-workbench/workbench-web-ng/e2e/src/app.po.ts b/submarine-workbench/workbench-web-ng/e2e/src/app.po.ts
index 493318b21d..62e9fb6452 100644
--- a/submarine-workbench/workbench-web-ng/e2e/src/app.po.ts
+++ b/submarine-workbench/workbench-web-ng/e2e/src/app.po.ts
@@ -25,6 +25,6 @@ export class AppPage {
}
getTitleText() {
- return element(by.css('app-root .content span')).getText() as Promise;
+ return element(by.css('submarine-root submarine-user .title')).getText() as Promise;
}
}
diff --git a/submarine-workbench/workbench-web-ng/karma.conf.js b/submarine-workbench/workbench-web-ng/karma.conf.js
index 00f2741fd5..bfa1d61080 100644
--- a/submarine-workbench/workbench-web-ng/karma.conf.js
+++ b/submarine-workbench/workbench-web-ng/karma.conf.js
@@ -45,6 +45,12 @@ module.exports = function (config) {
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
+ customLaunchers: {
+ ChromeHeadlessCI: {
+ base: 'ChromeHeadless',
+ flags: ['--no-sandbox']
+ }
+ },
singleRun: false,
restartOnFileChange: true
});
diff --git a/submarine-workbench/workbench-web-ng/package.json b/submarine-workbench/workbench-web-ng/package.json
index c2deab23d1..8fc2e31ced 100644
--- a/submarine-workbench/workbench-web-ng/package.json
+++ b/submarine-workbench/workbench-web-ng/package.json
@@ -19,6 +19,8 @@
"@angular/platform-browser": "~8.2.9",
"@angular/platform-browser-dynamic": "~8.2.9",
"@angular/router": "~8.2.9",
+ "date-fns": "^2.6.0",
+ "lodash": "^4.17.15",
"md5": "^2.2.1",
"ng-zorro-antd": "8.1.2",
"rxjs": "~6.4.0",
diff --git a/submarine-workbench/workbench-web-ng/pom.xml b/submarine-workbench/workbench-web-ng/pom.xml
index 081d2d712b..f74883de90 100644
--- a/submarine-workbench/workbench-web-ng/pom.xml
+++ b/submarine-workbench/workbench-web-ng/pom.xml
@@ -48,6 +48,7 @@
+ compileorg.apache.rat
diff --git a/submarine-workbench/workbench-web-ng/src/app/app-routing.module.ts b/submarine-workbench/workbench-web-ng/src/app/app-routing.module.ts
index 6cb4725943..6ca7ea429c 100644
--- a/submarine-workbench/workbench-web-ng/src/app/app-routing.module.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/app-routing.module.ts
@@ -25,12 +25,12 @@ const routes: Routes = [
{
path: '',
pathMatch: 'full',
- redirectTo: '/manager/user'
+ redirectTo: 'workbench'
},
{
- path: 'manager',
+ path: 'workbench',
canActivate: [AuthGuard],
- loadChildren: () => import('./pages/manager/manager.module').then(m => m.ManagerModule)
+ loadChildren: () => import('./pages/workbench/workbench.module').then(m => m.WorkbenchModule)
},
{
path: 'user',
diff --git a/submarine-workbench/workbench-web-ng/src/app/app.component.html b/submarine-workbench/workbench-web-ng/src/app/app.component.html
index 6c447c048d..970329bad2 100644
--- a/submarine-workbench/workbench-web-ng/src/app/app.component.html
+++ b/submarine-workbench/workbench-web-ng/src/app/app.component.html
@@ -19,56 +19,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/submarine-workbench/workbench-web-ng/src/app/app.component.scss b/submarine-workbench/workbench-web-ng/src/app/app.component.scss
index 67bafe67fa..a3b64854a4 100644
--- a/submarine-workbench/workbench-web-ng/src/app/app.component.scss
+++ b/submarine-workbench/workbench-web-ng/src/app/app.component.scss
@@ -17,83 +17,6 @@
* under the License.
*/
-:host {
- display: flex;
- text-rendering: optimizeLegibility;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
-}
-
.app-layout {
height: 100vh;
}
-
-.menu-sidebar {
- position: relative;
- z-index: 10;
- min-height: 100vh;
- box-shadow: 2px 0 6px rgba(0,21,41,.35);
-}
-
-.header-trigger {
- height: 64px;
- padding: 20px 24px;
- font-size: 20px;
- cursor: pointer;
- transition: all .3s,padding 0s;
-}
-
-.trigger:hover {
- color: #1890ff;
-}
-
-.sidebar-logo {
- position: relative;
- height: 64px;
- padding-left: 24px;
- overflow: hidden;
- line-height: 64px;
- background: #001529;
- transition: all .3s;
-}
-
-.sidebar-logo img {
- display: inline-block;
- height: 32px;
- width: 32px;
- vertical-align: middle;
-}
-
-.sidebar-logo h1 {
- display: inline-block;
- margin: 0 0 0 20px;
- color: #fff;
- font-weight: 600;
- font-size: 14px;
- font-family: Avenir,Helvetica Neue,Arial,Helvetica,sans-serif;
- vertical-align: middle;
-}
-
-nz-header {
- padding: 0;
- width: 100%;
- z-index: 2;
-}
-
-.app-header {
- position: relative;
- height: 64px;
- padding: 0;
- background: #fff;
- box-shadow: 0 1px 4px rgba(0,21,41,.08);
-}
-
-nz-content {
- margin: 24px;
-}
-
-.inner-content {
- padding: 24px;
- background: #fff;
- height: 100%;
-}
diff --git a/submarine-workbench/workbench-web-ng/src/app/app.component.spec.ts b/submarine-workbench/workbench-web-ng/src/app/app.component.spec.ts
index e59a500ba2..c26eb91e19 100644
--- a/submarine-workbench/workbench-web-ng/src/app/app.component.spec.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/app.component.spec.ts
@@ -19,12 +19,13 @@
import { async, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
+import { NgZorroAntdModule } from 'ng-zorro-antd';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
- imports: [RouterTestingModule],
+ imports: [RouterTestingModule, NgZorroAntdModule],
declarations: [AppComponent]
}).compileComponents();
}));
@@ -34,17 +35,4 @@ describe('AppComponent', () => {
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
-
- it(`should have as title 'workbench-web-ng'`, () => {
- const fixture = TestBed.createComponent(AppComponent);
- const app = fixture.debugElement.componentInstance;
- expect(app.title).toEqual('workbench-web-ng');
- });
-
- it('should render title', () => {
- const fixture = TestBed.createComponent(AppComponent);
- fixture.detectChanges();
- const compiled = fixture.debugElement.nativeElement;
- expect(compiled.querySelector('.content span').textContent).toContain('workbench-web-ng app is running!');
- });
});
diff --git a/submarine-workbench/workbench-web-ng/src/app/app.module.ts b/submarine-workbench/workbench-web-ng/src/app/app.module.ts
index 59c9cfdebc..64acdb46e2 100644
--- a/submarine-workbench/workbench-web-ng/src/app/app.module.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/app.module.ts
@@ -25,7 +25,7 @@ import { HttpClientModule } from '@angular/common/http';
import zh from '@angular/common/locales/zh';
import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
-import { LocalStorageService } from '@submarine/services/local-storage.service';
+import { LocalStorageService } from '@submarine/services';
import { zh_CN, NgZorroAntdModule, NZ_I18N } from 'ng-zorro-antd';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/manager/manager.module.ts b/submarine-workbench/workbench-web-ng/src/app/components/components.module.ts
similarity index 74%
rename from submarine-workbench/workbench-web-ng/src/app/pages/manager/manager.module.ts
rename to submarine-workbench/workbench-web-ng/src/app/components/components.module.ts
index cfabafeada..bfbd54c19e 100644
--- a/submarine-workbench/workbench-web-ng/src/app/pages/manager/manager.module.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/components/components.module.ts
@@ -19,13 +19,14 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
+import { RouterModule } from '@angular/router';
import { NgZorroAntdModule } from 'ng-zorro-antd';
-import { ManagerRoutingModule } from './manager-routing.module';
-import { ManagerComponent } from './manager.component';
-import { UserComponent } from './user/user.component';
+import { PageLayoutComponent } from './page-layout/page-layout.component';
@NgModule({
- declarations: [UserComponent, ManagerComponent],
- imports: [CommonModule, ManagerRoutingModule, NgZorroAntdModule]
+ declarations: [PageLayoutComponent],
+ imports: [CommonModule, RouterModule, NgZorroAntdModule],
+ exports: [PageLayoutComponent]
})
-export class ManagerModule {}
+export class ComponentsModule {
+}
diff --git a/submarine-workbench/workbench-web-ng/src/app/components/page-layout/page-layout.component.html b/submarine-workbench/workbench-web-ng/src/app/components/page-layout/page-layout.component.html
new file mode 100644
index 0000000000..bf9287dd65
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/components/page-layout/page-layout.component.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+ {{item|titlecase}}
+
+
+
+
{{description}}
+
+
+
+
+
+
+
+
diff --git a/submarine-workbench/workbench-web-ng/src/app/components/page-layout/page-layout.component.scss b/submarine-workbench/workbench-web-ng/src/app/components/page-layout/page-layout.component.scss
new file mode 100644
index 0000000000..ecea51cf63
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/components/page-layout/page-layout.component.scss
@@ -0,0 +1,23 @@
+/*!
+ * 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.
+ */
+
+nz-page-header {
+ margin: -24px -24px 16px;
+}
+
diff --git a/submarine-workbench/workbench-web-ng/src/app/components/page-layout/page-layout.component.ts b/submarine-workbench/workbench-web-ng/src/app/components/page-layout/page-layout.component.ts
new file mode 100644
index 0000000000..77a8a2814d
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/components/page-layout/page-layout.component.ts
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+import { Component, Input, OnInit } from '@angular/core';
+
+@Component({
+ selector: 'submarine-page-layout',
+ templateUrl: './page-layout.component.html',
+ styleUrls: ['./page-layout.component.scss']
+})
+export class PageLayoutComponent implements OnInit {
+ @Input() title: string;
+ @Input() description: string;
+ @Input() breadCrumb: string[];
+
+ constructor() {
+ }
+
+ ngOnInit() {
+ }
+}
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/manager/user/user.component.ts b/submarine-workbench/workbench-web-ng/src/app/interfaces/action.ts
similarity index 75%
rename from submarine-workbench/workbench-web-ng/src/app/pages/manager/user/user.component.ts
rename to submarine-workbench/workbench-web-ng/src/app/interfaces/action.ts
index 8c3d582c9d..525ed78c5a 100644
--- a/submarine-workbench/workbench-web-ng/src/app/pages/manager/user/user.component.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/interfaces/action.ts
@@ -17,15 +17,8 @@
* under the License.
*/
-import { Component, OnInit } from '@angular/core';
-
-@Component({
- selector: 'submarine-manager-user',
- templateUrl: './user.component.html',
- styleUrls: ['./user.component.scss']
-})
-export class UserComponent implements OnInit {
- constructor() {}
-
- ngOnInit() {}
+export interface Action {
+ action: string;
+ defaultCheck: boolean;
+ describe: string;
}
diff --git a/submarine-workbench/workbench-web-ng/src/app/interfaces/base-entity.ts b/submarine-workbench/workbench-web-ng/src/app/interfaces/base-entity.ts
new file mode 100644
index 0000000000..00dbaa319f
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/interfaces/base-entity.ts
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+export class BaseEntity {
+ id: string;
+ createBy: string;
+ createTime: number;
+ updateBy: string;
+ updateTime: number;
+
+ constructor(data: BaseEntity) {
+ this.id = data.id;
+ this.createBy = data.createBy;
+ this.createTime = data.createTime;
+ this.updateBy = data.updateBy;
+ this.updateTime = data.updateTime;
+ }
+}
diff --git a/submarine-workbench/workbench-web-ng/src/app/interfaces/permission.ts b/submarine-workbench/workbench-web-ng/src/app/interfaces/permission.ts
index fffef9eb40..349649a547 100644
--- a/submarine-workbench/workbench-web-ng/src/app/interfaces/permission.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/interfaces/permission.ts
@@ -17,19 +17,30 @@
* under the License.
*/
-export interface PermissionActionEntitySet {
+import { Action } from './action';
+
+export interface ActionEntitySet {
action: string;
- defaultChecked: boolean;
+ defaultCheck: boolean;
describe: string;
}
-export type PermissionAction = PermissionActionEntitySet;
-
export class Permission {
- permissionId = '';
- permissionName = '';
- roleId = '';
- actionList = null;
- actionEntitySet: PermissionActionEntitySet[] = [];
- actions: PermissionAction[] = [];
+ roleId: string;
+ permissionId: string;
+ permissionName: string;
+ dataAccess?: any;
+ actionList?: any;
+ actions: Action[];
+ actionEntitySet: ActionEntitySet[];
+
+ constructor(permission: Permission) {
+ this.roleId = permission.roleId;
+ this.permissionId = permission.permissionId;
+ this.permissionName = permission.permissionName;
+ this.dataAccess = permission.dataAccess;
+ this.actionList = permission.actionList;
+ this.actions = permission.actions;
+ this.actionEntitySet = permission.actionEntitySet;
+ }
}
diff --git a/submarine-workbench/workbench-web-ng/src/app/interfaces/public-api.ts b/submarine-workbench/workbench-web-ng/src/app/interfaces/public-api.ts
index 89585222ee..4123a936fc 100644
--- a/submarine-workbench/workbench-web-ng/src/app/interfaces/public-api.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/interfaces/public-api.ts
@@ -19,5 +19,7 @@
export * from './permission';
export * from './role';
-export * from './user';
+export * from './user-info';
export * from './rest';
+export * from './action';
+export * from './sys-user';
diff --git a/submarine-workbench/workbench-web-ng/src/app/interfaces/rest.ts b/submarine-workbench/workbench-web-ng/src/app/interfaces/rest.ts
index dcf39fc54c..61f5d46dfe 100644
--- a/submarine-workbench/workbench-web-ng/src/app/interfaces/rest.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/interfaces/rest.ts
@@ -17,10 +17,41 @@
* under the License.
*/
+/**
+ * REST api abstract interface
+ *
+ * @example
+ * ```typescript
+ * const res = Rest<{userName: string, password: string}>;
+ *
+ * // res.result.userName is string
+ * // res.result.password is string
+ * ```
+ */
export interface Rest {
+ /**
+ * request result
+ */
result: T;
+ /**
+ * request http status code
+ */
code: number;
message: string;
status: string;
success: boolean;
}
+
+/**
+ * Array result
+ */
+export interface ListResult {
+ /**
+ * result list
+ */
+ records: T[];
+ /**
+ * result list length
+ */
+ total: number;
+}
diff --git a/submarine-workbench/workbench-web-ng/src/app/interfaces/role.ts b/submarine-workbench/workbench-web-ng/src/app/interfaces/role.ts
index f3f8669e23..1464300dd8 100644
--- a/submarine-workbench/workbench-web-ng/src/app/interfaces/role.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/interfaces/role.ts
@@ -19,13 +19,24 @@
import { Permission } from './permission';
-export type RoleId = string;
-
export class Role {
- createTime: number = -1;
- creatorId = '';
- describe = '';
- id = '';
- name = '';
+ id: string;
+ name: string;
+ describe: string;
+ status: number;
+ creatorId: string;
+ createTime: number;
+ deleted: number;
permissions: Permission[];
+
+ constructor(role: Role) {
+ this.id = role.id;
+ this.name = role.name;
+ this.describe = role.describe;
+ this.status = role.status;
+ this.creatorId = role.creatorId;
+ this.createTime = role.createTime;
+ this.deleted = role.deleted;
+ this.permissions = role.permissions.map(permission => new Permission(permission));
+ }
}
diff --git a/submarine-workbench/workbench-web-ng/src/app/interfaces/sys-dept-select.ts b/submarine-workbench/workbench-web-ng/src/app/interfaces/sys-dept-select.ts
new file mode 100644
index 0000000000..5929e7bd3e
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/interfaces/sys-dept-select.ts
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+export class SysDeptSelect {
+ key: string;
+ value: string;
+ title: string;
+ disabled: boolean;
+ children: SysDeptSelect[];
+
+ constructor(data: SysDeptSelect) {
+ this.key = data.key;
+ this.value = data.value;
+ this.title = data.title;
+ this.disabled = data.disabled;
+ this.children = data.children.map(item => new SysDeptSelect(item));
+ }
+}
diff --git a/submarine-workbench/workbench-web-ng/src/app/interfaces/sys-dict-item.ts b/submarine-workbench/workbench-web-ng/src/app/interfaces/sys-dict-item.ts
new file mode 100644
index 0000000000..dbe56d1598
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/interfaces/sys-dict-item.ts
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+import { BaseEntity } from '@submarine/interfaces/base-entity';
+
+export class SysDictItem extends BaseEntity {
+ dictCode: string;
+ itemCode: string;
+ itemName: string;
+ description: string;
+ sortOrder: number;
+ deleted: number;
+
+ constructor(data: SysDictItem) {
+ super(data);
+
+ this.dictCode = data.dictCode;
+ this.itemCode = data.itemCode;
+ this.itemName = data.itemName;
+ this.description = data.description;
+ this.sortOrder = data.sortOrder;
+ this.deleted = data.deleted;
+ }
+}
diff --git a/submarine-workbench/workbench-web-ng/src/app/interfaces/sys-user.ts b/submarine-workbench/workbench-web-ng/src/app/interfaces/sys-user.ts
new file mode 100644
index 0000000000..18571e771a
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/interfaces/sys-user.ts
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+import { BaseEntity } from './base-entity';
+
+export interface SysUser extends BaseEntity {
+ userName: string;
+ realName: string;
+ password: string;
+ avatar: string;
+ sex: string;
+ status: string;
+ phone: string;
+ email: string;
+ deptCode: string;
+ deptName: string;
+ roleCode: string;
+ birthday: number;
+ deleted: number;
+ token: string;
+}
diff --git a/submarine-workbench/workbench-web-ng/src/app/interfaces/user-info.ts b/submarine-workbench/workbench-web-ng/src/app/interfaces/user-info.ts
new file mode 100644
index 0000000000..c159497426
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/interfaces/user-info.ts
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+
+import { Role } from './role';
+
+export class UserInfo {
+ id: string;
+ name: string;
+ username: string;
+ password: string;
+ avatar: string;
+ status: number;
+ telephone: string;
+ lastLoginIp: string;
+ lastLoginTime: number;
+ creatorId: string;
+ createTime: number;
+ merchantCode: string;
+ deleted: number;
+ roleId: string;
+ role: Role;
+
+ constructor(res: UserInfo) {
+ this.id = res.id;
+ this.name = res.name;
+ this.username = res.username;
+ this.password = res.password;
+ this.avatar = res.avatar;
+ this.status = res.status;
+ this.telephone = res.telephone;
+ this.lastLoginIp = res.lastLoginIp;
+ this.lastLoginTime = res.lastLoginTime;
+ this.creatorId = res.creatorId;
+ this.createTime = res.createTime;
+ this.merchantCode = res.merchantCode;
+ this.deleted = res.deleted;
+ this.roleId = res.roleId;
+ this.role = new Role(res.role);
+ }
+}
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/user/login/login.component.ts b/submarine-workbench/workbench-web-ng/src/app/pages/user/login/login.component.ts
index 9190cea1aa..2158604322 100644
--- a/submarine-workbench/workbench-web-ng/src/app/pages/user/login/login.component.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/user/login/login.component.ts
@@ -20,8 +20,8 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
+import { AuthService } from '@submarine/services';
import { NzNotificationService } from 'ng-zorro-antd';
-import { AuthService } from '../../../services';
@Component({
selector: 'submarine-login',
@@ -38,7 +38,7 @@ export class LoginComponent implements OnInit {
private router: Router
) {
if (this.authService.isLoggedIn) {
- this.router.navigate(['/manager/user']);
+ this.router.navigate(['/workbench']);
}
}
@@ -55,7 +55,6 @@ export class LoginComponent implements OnInit {
this.loginSuccess();
},
error => {
- console.log(error);
this.requestFailed(error);
}
);
@@ -71,11 +70,7 @@ export class LoginComponent implements OnInit {
}
loginSuccess() {
- this.router.navigate(['/manager/user']);
-
- setTimeout(() => {
- this.nzNotificationService.success('Welcome', 'Welcome back');
- }, 1000);
+ this.router.navigate(['/workbench']);
}
requestFailed(error: Error) {
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/user/user.component.ts b/submarine-workbench/workbench-web-ng/src/app/pages/user/user.component.ts
index b38a643d78..c4f6328d43 100644
--- a/submarine-workbench/workbench-web-ng/src/app/pages/user/user.component.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/user/user.component.ts
@@ -18,6 +18,7 @@
*/
import { Component, OnInit } from '@angular/core';
+import { UserService } from '@submarine/services';
@Component({
selector: 'submarine-user',
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/manager/user/user.component.html b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/data-dict/data-dict.component.html
similarity index 97%
rename from submarine-workbench/workbench-web-ng/src/app/pages/manager/user/user.component.html
rename to submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/data-dict/data-dict.component.html
index c5412cf557..5f8f81fdd9 100644
--- a/submarine-workbench/workbench-web-ng/src/app/pages/manager/user/user.component.html
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/data-dict/data-dict.component.html
@@ -17,4 +17,4 @@
~ under the License.
-->
-
user works!
+
data-dict works!
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/manager/manager.component.scss b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/data-dict/data-dict.component.scss
similarity index 100%
rename from submarine-workbench/workbench-web-ng/src/app/pages/manager/manager.component.scss
rename to submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/data-dict/data-dict.component.scss
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/manager/manager.component.ts b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/data-dict/data-dict.component.ts
similarity index 80%
rename from submarine-workbench/workbench-web-ng/src/app/pages/manager/manager.component.ts
rename to submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/data-dict/data-dict.component.ts
index efa6503968..3dde811fe9 100644
--- a/submarine-workbench/workbench-web-ng/src/app/pages/manager/manager.component.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/data-dict/data-dict.component.ts
@@ -20,12 +20,14 @@
import { Component, OnInit } from '@angular/core';
@Component({
- selector: 'submarine-manager',
- templateUrl: './manager.component.html',
- styleUrls: ['./manager.component.scss']
+ selector: 'submarine-data-dict',
+ templateUrl: './data-dict.component.html',
+ styleUrls: ['./data-dict.component.scss']
})
-export class ManagerComponent implements OnInit {
- constructor() {}
+export class DataDictComponent implements OnInit {
+ constructor() {
+ }
- ngOnInit() {}
+ ngOnInit() {
+ }
}
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/manager/manager-routing.module.ts b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/manager-routing.module.ts
similarity index 86%
rename from submarine-workbench/workbench-web-ng/src/app/pages/manager/manager-routing.module.ts
rename to submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/manager-routing.module.ts
index 97c775f132..52757dc541 100644
--- a/submarine-workbench/workbench-web-ng/src/app/pages/manager/manager-routing.module.ts
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/manager-routing.module.ts
@@ -19,6 +19,7 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
+import { DataDictComponent } from '@submarine/pages/workbench/manager/data-dict/data-dict.component';
import { ManagerComponent } from './manager.component';
import { UserComponent } from './user/user.component';
@@ -30,11 +31,15 @@ const routes: Routes = [
{
path: '',
pathMatch: 'full',
- redirectTo: '/manager/user'
+ redirectTo: 'user'
},
{
path: 'user',
component: UserComponent
+ },
+ {
+ path: 'data-dict',
+ component: DataDictComponent
}
]
}
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/manager/manager.component.html b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/manager.component.html
similarity index 79%
rename from submarine-workbench/workbench-web-ng/src/app/pages/manager/manager.component.html
rename to submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/manager.component.html
index 4f806ffbe7..598d7dba22 100644
--- a/submarine-workbench/workbench-web-ng/src/app/pages/manager/manager.component.html
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/manager.component.html
@@ -17,5 +17,10 @@
~ under the License.
-->
-
manager works!
-
+
+
+
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/manager/user/user.component.scss b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/manager.component.scss
similarity index 100%
rename from submarine-workbench/workbench-web-ng/src/app/pages/manager/user/user.component.scss
rename to submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/manager.component.scss
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/manager.component.ts b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/manager.component.ts
new file mode 100644
index 0000000000..15f42c56f3
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/manager.component.ts
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+import { Location, LocationStrategy, PathLocationStrategy } from '@angular/common';
+import { Component, OnInit } from '@angular/core';
+import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
+import _ from 'lodash';
+
+interface HeaderInfo {
+ title: string;
+ description: string;
+ breadCrumb: string[];
+}
+
+@Component({
+ selector: 'submarine-manager',
+ templateUrl: './manager.component.html',
+ styleUrls: ['./manager.component.scss'],
+ providers: [Location, { provide: LocationStrategy, useClass: PathLocationStrategy }]
+})
+export class ManagerComponent implements OnInit {
+ private headerInfo: { [key: string]: HeaderInfo } = {
+ user: {
+ title: 'user',
+ description: 'You can check the user, delete the user, lock and unlock the user, etc.',
+ breadCrumb: ['manager', 'user']
+ }
+ };
+ currentHeaderInfo: HeaderInfo;
+
+ constructor(private route: ActivatedRoute, private location: Location, private router: Router) {
+ this.router.events.subscribe(event => {
+ if (event instanceof NavigationEnd) {
+ const lastMatch = _.last(event.urlAfterRedirects.split('/'));
+ this.currentHeaderInfo = this.headerInfo[lastMatch];
+ }
+ });
+ }
+
+ ngOnInit() {}
+}
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/manager.module.ts b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/manager.module.ts
new file mode 100644
index 0000000000..94048f526e
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/manager.module.ts
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+import { CommonModule } from '@angular/common';
+import { NgModule } from '@angular/core';
+import { FormsModule, ReactiveFormsModule } from '@angular/forms';
+import { ComponentsModule } from '@submarine/components/components.module';
+import { NgZorroAntdModule } from 'ng-zorro-antd';
+
+import { DataDictComponent } from './data-dict/data-dict.component';
+import { ManagerRoutingModule } from './manager-routing.module';
+import { ManagerComponent } from './manager.component';
+import { UserDrawerComponent } from './user-drawer/user-drawer.component';
+import { UserPasswordModalComponent } from './user-password-modal/user-password-modal.component';
+import { UserComponent } from './user/user.component';
+
+@NgModule({
+ declarations: [UserComponent, ManagerComponent, DataDictComponent, UserPasswordModalComponent, UserDrawerComponent],
+ imports: [CommonModule, ManagerRoutingModule, NgZorroAntdModule, ComponentsModule, FormsModule, ReactiveFormsModule]
+})
+export class ManagerModule {}
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-drawer/user-drawer.component.html b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-drawer/user-drawer.component.html
new file mode 100644
index 0000000000..9ae9b64ff6
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-drawer/user-drawer.component.html
@@ -0,0 +1,206 @@
+
+
+
+
+
+
+
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-drawer/user-drawer.component.scss b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-drawer/user-drawer.component.scss
new file mode 100644
index 0000000000..7750c7a524
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-drawer/user-drawer.component.scss
@@ -0,0 +1,29 @@
+/*!
+ * 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.
+ */
+
+.footer {
+ position: absolute;
+ bottom: 0;
+ width: 100%;
+ border-top: 1px solid rgb(232, 232, 232);
+ padding: 10px 16px;
+ text-align: right;
+ left: 0;
+ background: #fff;
+}
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-drawer/user-drawer.component.ts b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-drawer/user-drawer.component.ts
new file mode 100644
index 0000000000..a480af43e7
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-drawer/user-drawer.component.ts
@@ -0,0 +1,243 @@
+/*
+ * 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.
+ */
+
+import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
+import { FormBuilder, FormControl, FormGroup, ValidationErrors, Validators } from '@angular/forms';
+import { SysUser } from '@submarine/interfaces';
+import { SysDeptSelect } from '@submarine/interfaces/sys-dept-select';
+import { SysDictItem } from '@submarine/interfaces/sys-dict-item';
+import { SystemUtilsService, SysDictCode } from '@submarine/services';
+import { format } from 'date-fns';
+import { zip, Observable, Observer } from 'rxjs';
+import { filter, map, startWith, take } from 'rxjs/operators';
+
+@Component({
+ selector: 'submarine-user-drawer',
+ templateUrl: './user-drawer.component.html',
+ styleUrls: ['./user-drawer.component.scss']
+})
+export class UserDrawerComponent implements OnInit, OnChanges {
+ @Input() visible: boolean;
+ @Input() readonly: boolean;
+ @Input() sysUser: SysUser;
+ @Input() sysDeptTreeList: SysDeptSelect[];
+ @Output() readonly close: EventEmitter = new EventEmitter();
+ @Output() readonly submit: EventEmitter> = new EventEmitter>();
+
+ form: FormGroup;
+ labelSpan = 5;
+ controlSpan = 14;
+ sexDictSelect: SysDictItem[] = [];
+ statusDictSelect: SysDictItem[] = [];
+ title = 'Add';
+
+ constructor(private fb: FormBuilder, private systemUtilsService: SystemUtilsService) {
+ }
+
+ ngOnInit() {
+ this.form = this.fb.group(
+ {
+ userName: new FormControl('',
+ {
+ updateOn: 'blur',
+ validators: [Validators.required],
+ asyncValidators: [this.userNameValidator]
+ }
+ ),
+ password: ['', [Validators.required, Validators.pattern(/^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/)]],
+ confirm: ['', this.confirmValidator],
+ realName: ['', Validators.required],
+ deptCode: [],
+ sex: [],
+ status: [],
+ birthday: [],
+ email: new FormControl('', {
+ updateOn: 'blur',
+ validators: [Validators.email],
+ asyncValidators: [this.emailValidator]
+ }),
+ phone: new FormControl('', {
+ updateOn: 'blur',
+ asyncValidators: [this.phoneValidator]
+ })
+ }
+ );
+
+ zip(
+ this.systemUtilsService.fetchSysDictByCode(SysDictCode.USER_SEX),
+ this.systemUtilsService.fetchSysDictByCode(SysDictCode.USER_STATUS)
+ )
+ .pipe(map(([item1, item2]) => [item1.records, item2.records]))
+ .subscribe(([sexDictSelect, statusDictSelect]) => {
+ this.sexDictSelect = sexDictSelect;
+ this.statusDictSelect = statusDictSelect;
+ });
+ }
+
+ ngOnChanges(changes: SimpleChanges): void {
+ if (!changes.visible) {
+ return;
+ }
+
+ if (changes.visible.currentValue) {
+ const sysUser = this.sysUser;
+ const readOnly = this.readonly;
+
+ this.form.reset({
+ userName: sysUser ? sysUser.userName : '',
+ password: sysUser ? sysUser.password : '',
+ confirm: sysUser ? sysUser.password : '',
+ realName: sysUser ? sysUser.realName : '',
+ deptCode: {
+ value: sysUser ? sysUser.deptCode : '',
+ disabled: readOnly
+ },
+ sex: {
+ value: sysUser ? sysUser.sex : '',
+ disabled: readOnly
+ },
+ status: {
+ value: sysUser ? sysUser.status : '',
+ disabled: readOnly
+ },
+ birthday: {
+ value: (sysUser && sysUser.birthday) ? new Date(sysUser.birthday) : '',
+ disabled: readOnly
+ },
+ email: sysUser ? sysUser.email : '',
+ phone: sysUser ? sysUser.phone : ''
+ });
+ this.title = this.generateTitle();
+ }
+ }
+
+ onClose() {
+ this.close.emit();
+ }
+
+ onSubmit() {
+ for (const key in this.form.controls) {
+ this.form.controls[key].markAsDirty();
+ this.form.controls[key].updateValueAndValidity();
+ }
+
+ this.form.statusChanges.pipe(
+ startWith(this.form.status),
+ filter(status => status !== 'PENDING'),
+ take(1),
+ map(status => status === 'VALID')
+ ).subscribe(valid => {
+ if (valid) {
+ const sysUser = this.sysUser ? this.sysUser : {};
+ const formData = { ...sysUser, ...this.form.value };
+
+ delete formData.confirm;
+ delete formData['sex@dict'];
+ delete formData['status@dict'];
+
+ if (formData.birthday) {
+ formData.birthday = format(formData.birthday, 'yyyy-MM-dd HH:mm:ss');
+ }
+
+ this.submit.emit(formData);
+ }
+ });
+ }
+
+ generateTitle(): string {
+ if (this.readonly) {
+ return 'Details';
+ } else if (this.sysUser && this.sysUser.id) {
+ return 'Edit';
+ } else {
+ return 'Add';
+ }
+ }
+
+ confirmValidator = (control: FormControl): { [s: string]: boolean } => {
+ if (!control.value) {
+ return { error: true, required: true };
+ } else if (control.value !== this.form.controls.password.value) {
+ return { error: true, confirm: true };
+ }
+
+ return {};
+ };
+
+ validateConfirmPassword = () => {
+ setTimeout(() => {
+ this.form.controls.confirm.updateValueAndValidity();
+ });
+ };
+
+ userNameValidator = (control: FormControl) =>
+ new Observable((observer: Observer) => {
+ this.systemUtilsService
+ .duplicateCheckUsername(control.value, this.sysUser && this.sysUser.id)
+ .subscribe(status => {
+ if (status) {
+ observer.next(null);
+ } else {
+ observer.next({ error: true, duplicated: true });
+ }
+
+ observer.complete();
+ });
+ });
+
+ emailValidator = (control: FormControl) =>
+ new Observable((observer: Observer) => {
+ if (!control.value) {
+ observer.next(null);
+ return observer.complete();
+ }
+
+ this.systemUtilsService
+ .duplicateCheckUserEmail(control.value, this.sysUser && this.sysUser.id)
+ .subscribe(status => {
+ if (status) {
+ observer.next(null);
+ } else {
+ observer.next({ error: true, duplicated: true });
+ }
+
+ observer.complete();
+ });
+ });
+
+ phoneValidator = (control: FormControl) =>
+ new Observable((observer: Observer) => {
+ if (!control.value) {
+ observer.next(null);
+ return observer.complete();
+ }
+
+ this.systemUtilsService
+ .duplicateCheckUserPhone(control.value, this.sysUser && this.sysUser.id)
+ .subscribe(status => {
+ if (status) {
+ observer.next(null);
+ } else {
+ observer.next({ error: true, duplicated: true });
+ }
+
+ observer.complete();
+ });
+ });
+}
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-password-modal/user-password-modal.component.html b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-password-modal/user-password-modal.component.html
new file mode 100644
index 0000000000..9ae1ea9125
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-password-modal/user-password-modal.component.html
@@ -0,0 +1,62 @@
+
+
+
+
+
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-password-modal/user-password-modal.component.scss b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-password-modal/user-password-modal.component.scss
new file mode 100644
index 0000000000..510f082c6f
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-password-modal/user-password-modal.component.scss
@@ -0,0 +1,19 @@
+/*!
+ * 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.
+ */
+
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-password-modal/user-password-modal.component.ts b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-password-modal/user-password-modal.component.ts
new file mode 100644
index 0000000000..2478ff64be
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user-password-modal/user-password-modal.component.ts
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
+import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
+
+@Component({
+ selector: 'submarine-user-password-modal',
+ templateUrl: './user-password-modal.component.html',
+ styleUrls: ['./user-password-modal.component.scss']
+})
+export class UserPasswordModalComponent implements OnChanges {
+ @Input() accountName: string;
+ @Input() visible: boolean;
+ @Output() readonly close: EventEmitter = new EventEmitter();
+ @Output() readonly ok: EventEmitter = new EventEmitter();
+ form: FormGroup;
+
+ constructor(private fb: FormBuilder) {
+ this.form = this.fb.group({
+ accountName: [''],
+ password: ['', Validators.required],
+ confirm: ['', this.confirmValidator]
+ });
+ }
+
+ ngOnChanges(changes: SimpleChanges) {
+ this.form.reset({
+ accountName: this.accountName,
+ password: '',
+ confirm: ''
+ });
+ }
+
+ confirmValidator = (control: FormControl): { [s: string]: boolean } => {
+ if (!control.value) {
+ return { error: true, required: true };
+ } else if (control.value !== this.form.controls.password.value) {
+ return { error: true, confirm: true };
+ }
+
+ return {};
+ };
+
+ validateConfirmPassword = () => {
+ setTimeout(() => {
+ this.form.controls.confirm.updateValueAndValidity();
+ });
+ };
+
+ hideModal() {
+ this.close.emit();
+ }
+
+ submitForm() {
+ for (const key in this.form.controls) {
+ this.form.controls[key].markAsDirty();
+ this.form.controls[key].updateValueAndValidity();
+ }
+
+ if (!this.form.valid) {
+ return;
+ }
+
+ this.ok.emit(this.form.value.password);
+ }
+}
diff --git a/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user/user.component.html b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user/user.component.html
new file mode 100644
index 0000000000..d13467abe8
--- /dev/null
+++ b/submarine-workbench/workbench-web-ng/src/app/pages/workbench/manager/user/user.component.html
@@ -0,0 +1,131 @@
+
+
+
+