diff --git a/src/main/java/edu/zju/gis/dldsj/config/CommonSetting.java b/src/main/java/edu/zju/gis/dldsj/config/CommonSetting.java index 57ec9c3922f98464d61a9e709e896c750adbc1f3..dca65537968d47348b07d0facc5af659f53e43b6 100755 --- a/src/main/java/edu/zju/gis/dldsj/config/CommonSetting.java +++ b/src/main/java/edu/zju/gis/dldsj/config/CommonSetting.java @@ -41,4 +41,6 @@ public class CommonSetting { private int keepAliveSeconds; private String airflowHome; private String dagsFolder; + private String frontEndRegion; + private String sessionMaxAge; } diff --git a/src/main/java/edu/zju/gis/dldsj/config/CorsConfig.java b/src/main/java/edu/zju/gis/dldsj/config/CorsConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..03a24e256840421aa887ab582da3f20f80c754f5 --- /dev/null +++ b/src/main/java/edu/zju/gis/dldsj/config/CorsConfig.java @@ -0,0 +1,18 @@ +package edu.zju.gis.dldsj.config; + +import com.google.common.net.HttpHeaders; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +public class CorsConfig extends WebMvcConfigurerAdapter { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**").allowedOrigins("*") + .allowedMethods("*").allowedHeaders("*") + .allowCredentials(true) + .exposedHeaders(HttpHeaders.SET_COOKIE) + .exposedHeaders(HttpHeaders.ORIGIN).maxAge(3600L); + } +} diff --git a/src/main/java/edu/zju/gis/dldsj/controller/DashBoardController.java b/src/main/java/edu/zju/gis/dldsj/controller/DashBoardController.java new file mode 100644 index 0000000000000000000000000000000000000000..734cde8ca518f66a360acb6cc468579d110a3197 --- /dev/null +++ b/src/main/java/edu/zju/gis/dldsj/controller/DashBoardController.java @@ -0,0 +1,86 @@ +package edu.zju.gis.dldsj.controller; + +import edu.zju.gis.dldsj.common.Result; +import edu.zju.gis.dldsj.constant.CodeConstants; +import edu.zju.gis.dldsj.entity.DbStructjson; +import edu.zju.gis.dldsj.service.DashBoardService; +import edu.zju.gis.dldsj.utils.DateUtil; +import lombok.extern.slf4j.Slf4j; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@Slf4j +@CrossOrigin +@Controller +@RequestMapping("/dashboard") +public class DashBoardController { + @Autowired + private DashBoardService dashboardService; + + //仪表盘 保存、读取、更新 + @RequestMapping(value = "/getDashBoardList", method = RequestMethod.GET) + @ResponseBody + public String getDashBoardStructList(@SessionAttribute("userId") String userId) { + Result> result = new Result<>(); + try { + List records = dashboardService.getWfStructjsonList(userId); + result.setCode(CodeConstants.SUCCESS).setBody(records).setMessage("获取工作流列表成功"); + } catch (RuntimeException e) { + result.setCode(CodeConstants.VALIDATE_ERROR).setMessage("获取工作流列表失败:" + e.getMessage()); + } + return result.toString(); + } + + @RequestMapping(value = "/getDashBoardAsJson/{dashboardName}", method = RequestMethod.GET) + @ResponseBody + public String getDashBoardAsJson(@SessionAttribute("userId") String userId, @PathVariable String dagName) { + Result result = new Result<>(); + try { + DbStructjson record = dashboardService.getWfStructjson(dagName + "_" + userId); + String body = record.getStructJson(); + result.setCode(CodeConstants.SUCCESS).setBody(body).setMessage("获取工作流结构json成功"); + } catch (RuntimeException e) { + result.setCode(CodeConstants.VALIDATE_ERROR).setMessage("获取工作流结构json失败:" + e.getMessage()); + } + return result.toString(); + } + + @RequestMapping(value = "/saveDashBoardAsJson", method = RequestMethod.POST) + @ResponseBody + public String saveDashBoardAsJson(@SessionAttribute("userId") String userId, @RequestBody String requestBody) { + Result result = new Result<>(); + try { + JSONObject params = new JSONObject(requestBody); + DbStructjson structjson = new DbStructjson(); + structjson.setDashId(params.getString("dashboardName") + "_" + userId); + structjson.setDashName(params.getString("dashboardName")); + structjson.setStructJson(params.getString("structJson")); + structjson.setSaveTime(DateUtil.now()); + structjson.setComment(params.getString("comment")); + structjson.setUserId(userId); + dashboardService.saveWfStructjson(structjson); + result.setCode(CodeConstants.SUCCESS).setMessage("保存工作流结构json成功"); + } catch (RuntimeException e) { + result.setCode(CodeConstants.SERVICE_ERROR).setMessage("保存工作流结构json失败:" + e.getMessage()); + } + return result.toString(); + } + + @RequestMapping(value = "/{dagId}", method = RequestMethod.DELETE) + @ResponseBody + public Result delete(@SessionAttribute("userId") String userId, @PathVariable String dagId){ + Result result = new Result<>(); + if(!dagId.split("_")[1].equals(userId)) + result.setCode(CodeConstants.VALIDATE_ERROR) + .setBody(false).setMessage("Unauthorized user, the target dag is not his"); + else { + result.setCode(CodeConstants.SUCCESS).setBody(dashboardService.delete(dagId)); + } + return result; + } + +} diff --git a/src/main/java/edu/zju/gis/dldsj/controller/DataController.java b/src/main/java/edu/zju/gis/dldsj/controller/DataController.java index 79ef2267b2c0ecf0292d31caf14760ef1fcd521f..d8cd645ac02473bd459a0a8394c73179653203f3 100755 --- a/src/main/java/edu/zju/gis/dldsj/controller/DataController.java +++ b/src/main/java/edu/zju/gis/dldsj/controller/DataController.java @@ -45,6 +45,15 @@ public class DataController { private StorageFieldService fieldService; private ElasticSearchHelper esHelper; + /** + * 公共数据 + * 获取所有数据与分页用totalSize + * + * @param offset + * @param size + * @param type + * @return + */ @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseBody public String getDataList(Integer offset, int size, String type) { @@ -65,6 +74,13 @@ public class DataController { return result.toString(); } + /** + * 公共数据 + * 根据数据ID检索字段信息 + * + * @param dataId + * @return + */ @RequestMapping(value = "/field/{dataId}", method = RequestMethod.GET) @ResponseBody public String getFieldInfo(@PathVariable String dataId) { @@ -76,6 +92,7 @@ public class DataController { /** * 以json的格式读取指定数据的部分记录 + * 用于表格形式数据预览 * * @param dataId 数据ID * @param offset 读取偏移量 @@ -102,6 +119,7 @@ public class DataController { /** * 以geojson的格式读取指定数据的部分记录 + * 用于地图要素形式数据上图 * * @param dataId 数据ID * @param offset 读取偏移量 @@ -170,4 +188,5 @@ public class DataController { return first; } + } diff --git a/src/main/java/edu/zju/gis/dldsj/controller/ParallelModelController.java b/src/main/java/edu/zju/gis/dldsj/controller/ParallelModelController.java index 4cb376f291cb9695190f754554ae81cf17d044ef..e08276db8a758180e943a9a93dcc3e0f36dadd3d 100755 --- a/src/main/java/edu/zju/gis/dldsj/controller/ParallelModelController.java +++ b/src/main/java/edu/zju/gis/dldsj/controller/ParallelModelController.java @@ -179,16 +179,18 @@ public class ParallelModelController { return result.toString(); } - @RequestMapping(value = "/unregister/{artifactId}", method = RequestMethod.DELETE) + // @CrossOrigin(origins = "http://localhost:13000/dldsj/parallel/unregister/ODPairSTFilter", maxAge = 3600) + @RequestMapping(value = "/unregister/{artifactId}", method = RequestMethod.GET) @ResponseBody public String unregister(@SessionAttribute("userId") String userId, @PathVariable String artifactId) { Result result = new Result<>(); try { ParallelModel model = parallelModelService.select(artifactId); - parallelModelService.delete(artifactId); - roleModelService.updateStatus(artifactId, FunctionStatus.DELETED.name()); userModelService.delete(userId, artifactId); - userModelService.updateStatus(artifactId, FunctionStatus.DELETED.name()); + parallelModelService.delete(artifactId); + //delete之后为什么还要更新STATUS +// roleModelService.updateStatus(artifactId, FunctionStatus.DELETED.name()); +// userModelService.updateStatus(artifactId, FunctionStatus.DELETED.name()); //数据库中记录删除成功后,删除相关文件 FileUtil.deletePath(model.getJarPath().split(",")); FileUtil.deletePath(model.getXmlPath()); @@ -202,13 +204,29 @@ public class ParallelModelController { return result.toString(); } - @RequestMapping(value = "/get", method = RequestMethod.GET) + @RequestMapping(value = "/getPublic", method = RequestMethod.GET) + @ResponseBody + public String getPublicModels() { + Result> result = new Result<>(); + try { + //公共资源的 roleId=100 + Set artifactIds = roleModelService.selectByRoleId("100").stream().map(RoleModel::getModelId).collect(Collectors.toSet()); +// artifactIds.addAll(userModelService.get(userId).stream().map(UserModel::getModelId).collect(Collectors.toSet())); + List models = parallelModelService.getByIdList(artifactIds); + result.setCode(CodeConstants.SUCCESS).setBody(models); + } catch (Exception e) { + log.error("模型列表读取失败", e); + result.setCode(CodeConstants.DAO_ERROR).setMessage("模型列表读取失败:" + e.getMessage()); + } + return result.toString(); + } + + @RequestMapping(value = "/getMine", method = RequestMethod.GET) @ResponseBody - public String getAllModels(@SessionAttribute("roleId") String roleId, @SessionAttribute("userId") String userId) { + public String getUserModels(@SessionAttribute("userId") String userId) { Result> result = new Result<>(); try { - Set artifactIds = roleModelService.selectByRoleId(roleId).stream().map(RoleModel::getModelId).collect(Collectors.toSet()); - artifactIds.addAll(userModelService.get(userId).stream().map(UserModel::getModelId).collect(Collectors.toSet())); + Set artifactIds = userModelService.get(userId).stream().map(UserModel::getModelId).collect(Collectors.toSet()); List models = parallelModelService.getByIdList(artifactIds); result.setCode(CodeConstants.SUCCESS).setBody(models); } catch (Exception e) { diff --git a/src/main/java/edu/zju/gis/dldsj/controller/UserController.java b/src/main/java/edu/zju/gis/dldsj/controller/UserController.java index 4918fc876ecec31a6acc00728950f98ec810aecf..f27c8b7019a30aa41075319676e628467bf75c9f 100755 --- a/src/main/java/edu/zju/gis/dldsj/controller/UserController.java +++ b/src/main/java/edu/zju/gis/dldsj/controller/UserController.java @@ -13,10 +13,13 @@ import lombok.extern.slf4j.Slf4j; import org.json.JSONArray; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import java.io.File; import java.io.IOException; import java.time.Instant; import java.util.*; @@ -26,7 +29,7 @@ import java.util.*; * @version 1.0 2018/08/09 */ @Slf4j -@CrossOrigin +//@CrossOrigin @Controller @RequestMapping("/user") public class UserController { @@ -44,21 +47,25 @@ public class UserController { private UserFavoriteService favoriteService; @Autowired private TaskRecordService taskRecordService; + @Value("${spring.mvc.static-path-pattern}") + private String staticPathPattern; @RequestMapping(value = "/register", method = RequestMethod.POST) @ResponseBody - public String register(@SessionAttribute("roleId") String roleId, @RequestBody String requestBody) { + public String register(/*@SessionAttribute("roleId") String roleId,*/ @RequestBody String requestBody) { Result result = new Result<>(); - Role currentRole = roleService.select(roleId); - if (currentRole == null || !currentRole.getIsAdministrator().equals("true") - || !currentRole.getStatus().equals(FunctionStatus.NORMAL.name())) { - result.setCode(CodeConstants.SSO_PERMISSION_ERROR); - result.setMessage("失败,当前用户无该项权限"); - return result.toString(); - } +// Role currentRole = roleService.select(roleId); +// if (currentRole == null || !currentRole.getIsAdministrator().equals("true") +// || !currentRole.getStatus().equals(FunctionStatus.NORMAL.name())) { +// result.setCode(CodeConstants.SSO_PERMISSION_ERROR); +// result.setMessage("失败,当前用户无该项权限"); +// return result.toString(); +// } try { JSONObject json = new JSONObject(requestBody); User user = new User(); + String id = UUID.randomUUID().toString(); + user.setId(id); user.setRoleId(json.getString("roleId")); user.setName(json.getString("name")); user.setFullName(json.optString("fullName")); @@ -70,23 +77,33 @@ public class UserController { user.setEmail(json.optString("email")); user.setOrganization(json.optString("organization")); user.setDepartment(json.optString("department")); - user.setId(UUID.randomUUID().toString()); user.setRegistrationTime(Date.from(Instant.now())); user.setStatus(FunctionStatus.NORMAL.name()); - userService.insert(user); - String[] modelIds = json.optString("modelId").split(","); - List models = new ArrayList<>(); - for (String modelId : modelIds) { - UserModel userModel = new UserModel(); - userModel.setId(UUID.randomUUID().toString()); - userModel.setUserId(user.getId()); - userModel.setModelId(modelId); - userModel.setRegistrationTime(user.getRegistrationTime()); - userModel.setStatus(ModelStatus.NORMAL.name()); - models.add(userModel); + user.setPrivateDir("/" + json.getString("name") + id); + user.setDirSize(10240);//TODO 根据roleID给定初始值 + String sourceUrl = json.optString("avatarPath"); + String picUrl = ""; + if (!sourceUrl.isEmpty()) { + //TODO 上传自定义头像 + picUrl = staticPathPattern.replace("*", "") + "defaultavatar.jpg"; + } else { + picUrl = staticPathPattern.replace("*", "") + "defaultavatar.jpg"; } - modelService.insert(models); + user.setAvatarPath(picUrl); + userService.insert(user); +// String[] modelIds = json.optString("modelId").split(","); +// List models = new ArrayList<>(); +// for (String modelId : modelIds) { +// UserModel userModel = new UserModel(); +// userModel.setId(UUID.randomUUID().toString()); +// userModel.setUserId(user.getId()); +// userModel.setModelId(modelId); +// userModel.setRegistrationTime(user.getRegistrationTime()); +// userModel.setStatus(ModelStatus.NORMAL.name()); +// models.add(userModel); +// } +// modelService.insert(models); result.setCode(CodeConstants.SUCCESS).setBody("success"); } catch (RuntimeException e) { log.error("用户添加失败", e); @@ -97,16 +114,20 @@ public class UserController { @RequestMapping(value = "/login", method = RequestMethod.POST) @ResponseBody - public String login(String name, String pass, HttpSession session) { + public String login(@RequestBody String input, HttpSession session) { +// = request.getSession(); Result result = new Result<>(); - User user = userService.select(name); + JSONObject jsInput = new JSONObject(input); + String name = jsInput.getString("name"); + String pass = jsInput.getString("pass"); + User user = userService.getByName(name); if (user == null) { result.setCode(CodeConstants.USER_NOT_EXIST); result.setMessage("该用户名不存在,请注册"); } else { if (user.getPassword().equals(pass)) { result.setCode(CodeConstants.SUCCESS); - result.setBody("success"); + result.setBody(user.getId()); session.setAttribute("userId", user.getId()); session.setAttribute("userName", user.getName()); session.setAttribute("fullName", user.getFullName()); @@ -119,13 +140,25 @@ public class UserController { return result.toString(); } - @RequestMapping(value = "/logout", method = RequestMethod.GET) + @RequestMapping(value = "/logout", method = RequestMethod.POST) + @ResponseBody public String logout(HttpSession session) { - session.removeAttribute("userId"); - session.removeAttribute("userName"); - session.removeAttribute("fullName"); - session.removeAttribute("roleId"); - return "redirect:/user/login"; + Result result = new Result<>(); + try { + session.removeAttribute("userId"); + session.removeAttribute("userName"); + session.removeAttribute("fullName"); + session.removeAttribute("roleId"); + result.setCode(CodeConstants.SUCCESS); + result.setMessage("用户注销成功。"); + result.setBody("用户注销成功。"); + return result.toString(); + } catch (RuntimeException e) { + result.setCode(CodeConstants.SERVICE_ERROR); + result.setMessage("用户注销失败。"); + result.setBody("用户注销失败。"); + return result.toString(); + } } @RequestMapping(value = "/data", method = RequestMethod.GET) @@ -280,4 +313,16 @@ public class UserController { return jsons; } + @RequestMapping(value = "/getinfo/{userName}", method = RequestMethod.GET) + @ResponseBody + public String getUserInfo(@SessionAttribute("userName") String userName) { + Result result = new Result(); + try { + User body = userService.getByName(userName); + result.setCode(CodeConstants.SUCCESS).setMessage("获取用户信息成功。").setBody(body); + } catch (RuntimeException e) { + result.setCode(CodeConstants.SERVICE_ERROR).setMessage("获取用户信息失败:" + e.getMessage()); + } + return result.toString(); + } } diff --git a/src/main/java/edu/zju/gis/dldsj/controller/WorkflowController.java b/src/main/java/edu/zju/gis/dldsj/controller/WorkflowController.java index 58e05f85cf5ce6e368ce997ae193dbd661cb5822..1846efa25369f0bf24b4b51dcbbacd6859f2e8f3 100755 --- a/src/main/java/edu/zju/gis/dldsj/controller/WorkflowController.java +++ b/src/main/java/edu/zju/gis/dldsj/controller/WorkflowController.java @@ -58,6 +58,7 @@ public class WorkflowController { @ResponseBody public String postDag(@SessionAttribute("userId") String userId, @RequestBody String requestBody) { try { + JSONObject params = new JSONObject(requestBody); String dagId = params.getString("dagId"); WfDag wfDag = new WfDag(); @@ -68,22 +69,7 @@ public class WorkflowController { int retries = params.optInt("retries"); //获取最终子任务的ID - String endPointId = ""; - List> chains = Arrays.stream(wfDag.getTasks().split("#")).map(s -> Arrays.asList(s.split(","))).collect(Collectors.toList()); - for (int i = 0; i < chains.size(); i++) { - boolean isEnd = true; - List chain = chains.get(i); - for (int j = 0; j < chains.size() && j != i; j++) { - int index = chains.get(j).indexOf(chain.get(chain.size() - 1)); - if (index >= 0 && index < (chains.get(j).size() - 1)) { - isEnd = false; - break; - } - } - if (isEnd) - endPointId = chain.get(chain.size() - 1); - } - String endpoint = endPointId; + String endpoint = getEndPoint(wfDag); //子任务节点参数构造 Map> nodeConfigs = new HashMap<>(); @@ -109,6 +95,7 @@ public class WorkflowController { config.setArtifactId(node.getString("artifactId")); JSONArray appParams = node.getJSONArray("params"); int outputOrder = 0; + for (int i = 0; i < appParams.length(); i++) { if (appParams.getString(i).equals("$OUTPUT")) {//设置中间结果的输出位置 appParams.put(i, Paths.get(workspace, config.getTaskId() + "_" + outputOrder++).toString()); @@ -119,9 +106,10 @@ public class WorkflowController { node.put("model", model); if (endpoint.equals(config.getTaskId())) {//记录最终结果的输出路径 JSONArray paramsDesc = new JSONArray(model.getParameters()); - for (int i = 0; i < paramsDesc.length(); i++) + for (int i = 0; i < paramsDesc.length(); i++) { if (paramsDesc.getJSONObject(i).has("out")) resultAddress.add(appParams.getString(i)); + } } nodeConfigs.put(config.getTaskId(), new Tuple2<>(config, node)); }); @@ -170,11 +158,10 @@ public class WorkflowController { String startCmd = String.format("export AIRFLOW_HOME=%s;airflow unpause %s;airflow trigger_dag %s", setting.getAirflowHome(), dagId, dagId); SSHHelper.runSSH(setting.getNameNode(), setting.getUsername(), setting.getPassword(), startCmd, setting.getParallelFilePath()); WorkflowMonitor monitor = new WorkflowMonitor(setting, wfService - , wfDag, nodeConfigs.values().stream().map(Tuple2::_1).collect(Collectors.toList()), workspace, String.join(",", resultAddress)); + , wfDag, nodeConfigs.values().stream().map(Tuple2::_1).collect(Collectors.toList()), workspace, String.join(",", resultAddress), parallelModelService); monitorTasks.execute(monitor); return Result.success().setBody("").toString(); } catch (Exception e) { - log.error("工作流提交失败", e); return Result.error("工作流提交失败:" + e.getMessage()).toString(); } } @@ -282,13 +269,17 @@ public class WorkflowController { return localFile.listFiles() != null; } - private void buildDag(WfDag wfDag, boolean dependsOnPast, int retries, Iterable nodeConfigs) throws IOException { + private void buildDag(WfDag wfDag, boolean dependsOnPast, int retries, Iterable nodeConfigs) { List content = new ArrayList<>(); content.add(buildHead(wfDag.getUserId(), dependsOnPast, retries, wfDag.getDagId())); nodeConfigs.forEach(node -> content.add(node.buildTask(parallelModelService))); Arrays.stream(wfDag.getTasks().split("#")).map(s -> s.split(",")) .forEach(conn -> content.add(String.join(" >> ", conn).replace("-", "_"))); - FileUtil.write(Paths.get(wfDag.getFileLocation()), content); + try { + FileUtil.write(Paths.get(wfDag.getFileLocation()), content); + } catch (IOException e) { + log.error("文件`" + wfDag.getFileLocation() + "写入异常", e); + } } private static String buildHead(String user, boolean dependsOnPast, int retries, String dagId) { @@ -310,4 +301,146 @@ public class WorkflowController { " default_args=default_args\n" + ")\n\n", user, dependsOnPast ? "True" : "False", retries, dagId); } + + //获取当前用户提交过的AirFlow任务 + @RequestMapping(value = "/getUserDags", method = RequestMethod.GET) + @ResponseBody + public String getUserDags(@SessionAttribute("userId") String userId) { + Result> result = new Result<>(); + try { + List wfdags = wfService.getWfDag(userId, 0, 100); + List body = new ArrayList<>(); + wfdags.forEach(e -> body.addAll(wfService.getWfRun(e.getDagId()))); + result.setCode(CodeConstants.SUCCESS).setBody(body); + } catch (Exception e) { + log.error("获取工作流列表失败", e); + result.setCode(CodeConstants.SERVICE_ERROR).setMessage("获取工作流列表失败:" + e.getMessage()); + } + return result.toString(); + } + + //结果预览-表格 + @RequestMapping(value = "/result/{dagId}/table", method = RequestMethod.GET) + @ResponseBody + public String getResultAsTable(@PathVariable String dagId, int offset, int size) { + Result result = new Result<>(); + try { + result.setCode(CodeConstants.SUCCESS).setBody(getResultAsJSONArray(dagId, offset, size)).setMessage("获取工作流列表成功。"); + } catch (Exception e) { + log.error("获取工作流列表失败", e); + result.setCode(CodeConstants.SERVICE_ERROR).setMessage("获取工作流列表失败:" + e.getMessage()); + } + return result.toString(); + } + + //结果预览-地图要素 + @RequestMapping(value = "/result/{dagId}/geojson", method = RequestMethod.GET) + @ResponseBody + public String getResultAsGeoJson(@PathVariable String dagId, int offset, int size) { + Result result = new Result<>(); + try { + result.setCode(CodeConstants.SUCCESS).setBody(GeometryUtil.toGeoJSON(getResultAsJSONArray(dagId, offset, size), dagId)).setMessage("获取工作流列表成功。"); + } catch (Exception e) { + log.error("获取工作流列表失败", e); + result.setCode(CodeConstants.SERVICE_ERROR).setMessage("获取工作流列表失败:" + e.getMessage()); + } + return result.toString(); + } + + private JSONArray getResultAsJSONArray(String dagId, int offset, int size) throws IOException { + JSONArray result = new JSONArray(); + List wfRuns = wfService.getWfRun(dagId); + if (wfRuns.size() == 0) { + return null; + } else { + WfRun wfRun = wfRuns.get(0); + String outputs = wfRun.getResult();//TODO 可能包含多个结果文件 + String dataPath = outputs.split(",")[0]; + String[] fieldNames = wfRun.getOutputType().split(";")[0].split(","); + List lines = FileUtil.readByLine(dataPath, size, false); + boolean isCsv = lines.stream().limit(20).noneMatch(s -> s.contains("\t")); + for (String line : lines) { + String[] cells = line.split(isCsv ? "," : "\t", -1); + JSONObject obj = new JSONObject(); + for (int i = 0; i < fieldNames.length; i++) { + obj.put(fieldNames[i], cells[i]); + } + result.put(obj); + } + } + return result; + } + + //工作流保存、读取、更新 + @RequestMapping(value = "/getWfList", method = RequestMethod.GET) + @ResponseBody + public String getWfStructList(@SessionAttribute("userId") String userId) { + Result> result = new Result<>(); + try { + List records = wfService.getWfStructjsonList(userId); + if (records.size() > 0) + result.setCode(CodeConstants.SUCCESS).setBody(records).setMessage("获取工作流列表成功。"); + else + result.setCode(CodeConstants.SUCCESS).setBody(records).setMessage("工作流列表为空。"); + } catch (RuntimeException e) { + result.setCode(CodeConstants.SERVICE_ERROR).setMessage("获取工作流列表失败:" + e.getMessage()); + } + return result.toString(); + } + + @RequestMapping(value = "/getWfAsJson/{dagName}", method = RequestMethod.GET) + @ResponseBody + public String getWfAsJson(@SessionAttribute("userId") String userId, @PathVariable String dagName) { + Result result = new Result<>(); + try { + WfStructjson record = wfService.getWfStructjson(dagName + "_" + userId); + String body = record.getStructJson(); + result.setCode(CodeConstants.SUCCESS).setBody(body).setMessage("获取工作流结构json成功"); + } catch (RuntimeException e) { + result.setCode(CodeConstants.VALIDATE_ERROR).setMessage("获取工作流结构json失败:" + e.getMessage()); + } + return result.toString(); + } + + @RequestMapping(value = "/saveWfAsJson", method = RequestMethod.POST) + @ResponseBody + public String saveWfAsJson(@SessionAttribute("userId") String userId, @RequestBody String requestBody) { + Result result = new Result<>(); + try { + JSONObject params = new JSONObject(requestBody); + WfStructjson structjson = new WfStructjson(); + structjson.setDagId(params.getString("dagName") + "_" + userId); + structjson.setDagName(params.getString("dagName")); + structjson.setStructJson(params.getString("structJson")); + structjson.setSaveTime(DateUtil.now()); + structjson.setComment(params.getString("comment")); + structjson.setUserId(userId); + wfService.saveWfStructjson(structjson); + result.setCode(CodeConstants.SUCCESS).setMessage("保存工作流结构json成功"); + } catch (RuntimeException e) { + result.setCode(CodeConstants.SERVICE_ERROR).setMessage("保存工作流结构json失败:" + e.getMessage()); + } + return result.toString(); + } + + private String getEndPoint(WfDag wfDag) { + //获取最终子任务的ID + String endPointId = ""; + List> chains = Arrays.stream(wfDag.getTasks().split("#")).map(s -> Arrays.asList(s.split(","))).collect(Collectors.toList()); + for (int i = 0; i < chains.size(); i++) { + boolean isEnd = true; + List chain = chains.get(i); + for (int j = 0; j < chains.size() && j != i; j++) { + int index = chains.get(j).indexOf(chain.get(chain.size() - 1)); + if (index >= 0 && index < (chains.get(j).size() - 1)) { + isEnd = false; + break; + } + } + if (isEnd) + endPointId = chain.get(chain.size() - 1); + } + return endPointId; + } + } diff --git a/src/main/java/edu/zju/gis/dldsj/dao/DbStructjsonMapper.java b/src/main/java/edu/zju/gis/dldsj/dao/DbStructjsonMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..3d8a6a7faf09d6378a70c4b8003628401c1df632 --- /dev/null +++ b/src/main/java/edu/zju/gis/dldsj/dao/DbStructjsonMapper.java @@ -0,0 +1,23 @@ +package edu.zju.gis.dldsj.dao; + +import edu.zju.gis.dldsj.entity.DbStructjson; + +import java.util.List; + +public interface DbStructjsonMapper { + int deleteByPrimaryKey(String dashId); + + int insert(DbStructjson record); + + int insertSelective(DbStructjson record); + + DbStructjson selectByPrimaryKey(String dashId); + + int updateByPrimaryKeySelective(DbStructjson record); + + int updateByPrimaryKeyWithBLOBs(DbStructjson record); + + int updateByPrimaryKey(DbStructjson record); + + List selectByUserId(String userId); +} \ No newline at end of file diff --git a/src/main/java/edu/zju/gis/dldsj/dao/UserTaskMapper.java b/src/main/java/edu/zju/gis/dldsj/dao/UserTaskMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..ec85ca6c03a33351154e56378fb1067af5e2e77a --- /dev/null +++ b/src/main/java/edu/zju/gis/dldsj/dao/UserTaskMapper.java @@ -0,0 +1,29 @@ +package edu.zju.gis.dldsj.dao; + +import edu.zju.gis.dldsj.base.BaseMapper; +import edu.zju.gis.dldsj.entity.UserTask; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface UserTaskMapper extends BaseMapper { + int deleteByPrimaryKey(String id); + + int insert(UserTask record); + + int insertSelective(UserTask record); + + UserTask selectByPrimaryKey(String id); + + int updateByPrimaryKeySelective(UserTask record); + + int updateByPrimaryKey(UserTask record); + + int deleteByUserTask(@Param("userId") String userId, @Param("taskId") String taskId); + + List getByUserId(String userId); + + UserTask selectByUserTask(@Param("userId") String userId, @Param("taskId") String taskId); + + int updateStatus(String taskId, String status); +} \ No newline at end of file diff --git a/src/main/java/edu/zju/gis/dldsj/dao/WfStructjsonMapper.java b/src/main/java/edu/zju/gis/dldsj/dao/WfStructjsonMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8af8ef1c6126130e8c428fad6a34404d0d1167 --- /dev/null +++ b/src/main/java/edu/zju/gis/dldsj/dao/WfStructjsonMapper.java @@ -0,0 +1,17 @@ +package edu.zju.gis.dldsj.dao; + +import edu.zju.gis.dldsj.entity.WfStructjson; + +import java.util.List; + +public interface WfStructjsonMapper { + int deleteByPrimaryKey(String dagId); + int insert(WfStructjson record); + int insertSelective(WfStructjson record); + List selectByUserId(String userId); + + WfStructjson selectByPrimaryKey(String dagId); + int updateByPrimaryKeySelective(WfStructjson record); + int updateByPrimaryKeyWithBLOBs(WfStructjson record); + int updateByPrimaryKey(WfStructjson record); +} \ No newline at end of file diff --git a/src/main/java/edu/zju/gis/dldsj/entity/DbStructjson.java b/src/main/java/edu/zju/gis/dldsj/entity/DbStructjson.java new file mode 100644 index 0000000000000000000000000000000000000000..7436b31fc08f6946563f13ec45b50e4fc5833321 --- /dev/null +++ b/src/main/java/edu/zju/gis/dldsj/entity/DbStructjson.java @@ -0,0 +1,23 @@ +package edu.zju.gis.dldsj.entity; + +import edu.zju.gis.dldsj.model.Jsonable; +import lombok.Getter; +import lombok.Setter; + +import java.util.Date; + +@Getter +@Setter +public class DbStructjson implements Jsonable { + private String dashId; + private String dashName; + private String userId; + private Date saveTime; + private String comment; + private String structJson; + + @Override + public String id() { + return dashId; + } +} \ No newline at end of file diff --git a/src/main/java/edu/zju/gis/dldsj/entity/User.java b/src/main/java/edu/zju/gis/dldsj/entity/User.java index 96b70ce356b6d53366bcb5c750cd07c52af3f2f4..50718bc2d4cea90cc0e98b0d9b307426cc1f0b9c 100755 --- a/src/main/java/edu/zju/gis/dldsj/entity/User.java +++ b/src/main/java/edu/zju/gis/dldsj/entity/User.java @@ -23,6 +23,10 @@ public class User implements Jsonable { private String organization; private String department; private String status; + private String privateDir; + private int dirSize; + private String avatarPath; + private int dirUsedSize; @Override public String id() { diff --git a/src/main/java/edu/zju/gis/dldsj/entity/UserTask.java b/src/main/java/edu/zju/gis/dldsj/entity/UserTask.java new file mode 100644 index 0000000000000000000000000000000000000000..575a9c7d2acedd5207d47d8ad8c043d535db9096 --- /dev/null +++ b/src/main/java/edu/zju/gis/dldsj/entity/UserTask.java @@ -0,0 +1,22 @@ +package edu.zju.gis.dldsj.entity; + +import java.util.Date; + +import edu.zju.gis.dldsj.model.Jsonable; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class UserTask implements Jsonable { + private String id; + private String userId; + private String taskId; + private Date createTime; + private String status; + + @Override + public String id() { + return id; + } +} \ No newline at end of file diff --git a/src/main/java/edu/zju/gis/dldsj/entity/WfRun.java b/src/main/java/edu/zju/gis/dldsj/entity/WfRun.java index 491675cc3ff9c8df2fbca8892ab515b7b654539b..41947890b61c4118a52d469c6d7e15800e2fcf49 100755 --- a/src/main/java/edu/zju/gis/dldsj/entity/WfRun.java +++ b/src/main/java/edu/zju/gis/dldsj/entity/WfRun.java @@ -29,4 +29,5 @@ public class WfRun { * 最终结果的存储位置 */ private String result; + private String outputType; } \ No newline at end of file diff --git a/src/main/java/edu/zju/gis/dldsj/entity/WfStructjson.java b/src/main/java/edu/zju/gis/dldsj/entity/WfStructjson.java new file mode 100644 index 0000000000000000000000000000000000000000..33a0af92891bb6dc16cd710bdc2ca99524223ca8 --- /dev/null +++ b/src/main/java/edu/zju/gis/dldsj/entity/WfStructjson.java @@ -0,0 +1,15 @@ +package edu.zju.gis.dldsj.entity; + +import lombok.Setter; +import lombok.Getter; +import java.util.Date; +@Getter +@Setter +public class WfStructjson { + private String dagId; + private String dagName; + private Date saveTime; + private String userId; + private String comment; + private String structJson; +} \ No newline at end of file diff --git a/src/main/java/edu/zju/gis/dldsj/interceptor/WebConfig.java b/src/main/java/edu/zju/gis/dldsj/interceptor/WebConfig.java index dad9783ac5b7f971d109ee150923ea04a9eb701c..a10ac719219b9bf1a85e5573cfd86078956b8abb 100755 --- a/src/main/java/edu/zju/gis/dldsj/interceptor/WebConfig.java +++ b/src/main/java/edu/zju/gis/dldsj/interceptor/WebConfig.java @@ -1,10 +1,10 @@ package edu.zju.gis.dldsj.interceptor; +import edu.zju.gis.dldsj.common.Result; +import edu.zju.gis.dldsj.constant.CodeConstants; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.InterceptorRegistration; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.config.annotation.*; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import javax.servlet.http.HttpServletRequest; @@ -33,7 +33,7 @@ public class WebConfig implements WebMvcConfigurer { addInterceptor.excludePathPatterns("/error"); addInterceptor.excludePathPatterns("/user/login**"); - + addInterceptor.excludePathPatterns("/user/register"); addInterceptor.addPathPatterns("/**"); } @@ -42,16 +42,23 @@ public class WebConfig implements WebMvcConfigurer { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { HttpSession session = request.getSession(); //todo to be removed - session.setAttribute(SESSION_KEY, "ubt"); - session.setAttribute("userId", "1"); - session.setAttribute("roleId", "1"); - session.setAttribute("fullName", "ubt@ubt1"); - if (session.getAttribute(SESSION_KEY) != null) { +// session.setAttribute(SESSION_KEY, "ubt"); +// session.setAttribute("userId", "1"); +// session.setAttribute("roleId", "1"); +// session.setAttribute("fullName", "ubt@ubt1"); + if (session.getAttribute("userId") != null) { return true; } else { - response.sendRedirect("/login");//todo 待更改为消息,而非页面 +// response.sendRedirect("/login"); + Result result = + new Result(CodeConstants.VALIDATE_ERROR, "unauthorized user, not log in yet"); + result.setBody(""); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().write(result.toString()); return false; } } } } + + diff --git a/src/main/java/edu/zju/gis/dldsj/interceptor/myCORSFilter.java b/src/main/java/edu/zju/gis/dldsj/interceptor/myCORSFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..55f8dc7128352345ed0cab18a15c47c598bceff5 --- /dev/null +++ b/src/main/java/edu/zju/gis/dldsj/interceptor/myCORSFilter.java @@ -0,0 +1,41 @@ +package edu.zju.gis.dldsj.interceptor; + +import edu.zju.gis.dldsj.config.CommonSetting; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.*; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Component +@WebFilter(urlPatterns = "/*", filterName = "mycorsfilter") +public class myCORSFilter implements Filter { + @Autowired + private CommonSetting setting; + // public class myCORSFilter { + @Override + public void init(FilterConfig filterConfig) throws ServletException { + + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { + HttpServletResponse response = (HttpServletResponse) servletResponse; + String origin = (String) servletRequest.getRemoteHost() + ":" + servletRequest.getRemotePort(); + + response.setHeader("Access-Control-Allow-Origin", setting.getFrontEndRegion()); + response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); + response.setHeader("Access-Control-Max-Age", "36000"); + response.setHeader("Access-Control-Allow-Headers", " Origin, X-Requested-With, Content-Type, Accept"); + response.setHeader("Access-Control-Allow-Credentials", "true"); + + filterChain.doFilter(servletRequest, servletResponse); + } + + @Override + public void destroy() { + + } +} \ No newline at end of file diff --git a/src/main/java/edu/zju/gis/dldsj/service/DashBoardService.java b/src/main/java/edu/zju/gis/dldsj/service/DashBoardService.java new file mode 100644 index 0000000000000000000000000000000000000000..ac1c381e93186d898f8d1cd26dd30f4da8aabec5 --- /dev/null +++ b/src/main/java/edu/zju/gis/dldsj/service/DashBoardService.java @@ -0,0 +1,16 @@ +package edu.zju.gis.dldsj.service; + +import edu.zju.gis.dldsj.entity.DbStructjson; + +import java.util.List; + +public interface DashBoardService { + //仪表盘 保存、读取、更新 + List getWfStructjsonList(String userId); + + DbStructjson getWfStructjson(String dagid); + + void saveWfStructjson(DbStructjson structjson); + + boolean delete(String pk); +} diff --git a/src/main/java/edu/zju/gis/dldsj/service/UserTaskService.java b/src/main/java/edu/zju/gis/dldsj/service/UserTaskService.java new file mode 100644 index 0000000000000000000000000000000000000000..7a6308606989c1a0c0d007adc7a41e1d7ed05e77 --- /dev/null +++ b/src/main/java/edu/zju/gis/dldsj/service/UserTaskService.java @@ -0,0 +1,20 @@ +package edu.zju.gis.dldsj.service; + +import edu.zju.gis.dldsj.base.BaseService; +import edu.zju.gis.dldsj.entity.UserTask; + +import java.util.List; + +public interface UserTaskService extends BaseService { + List get(String userId); + + UserTask get(String userId, String taskId); + + void insert(List userTasks); + + void upsert(UserTask userTask); + + void updateStatus(String taskId, String status); + + void delete(String userId, String mtaskId); +} diff --git a/src/main/java/edu/zju/gis/dldsj/service/WfService.java b/src/main/java/edu/zju/gis/dldsj/service/WfService.java index be0c59dd389cfbb653a469eb2bd1452a83fc74e2..e5171fceea850d7ef2e2215a5dd1e9fcfca76bb6 100755 --- a/src/main/java/edu/zju/gis/dldsj/service/WfService.java +++ b/src/main/java/edu/zju/gis/dldsj/service/WfService.java @@ -74,4 +74,11 @@ public interface WfService { WfInstance getWfInstance(String dagId, Date executionDate, String taskId); + //工作流 保存、读取、更新 + List getWfStructjsonList(String userId); + + WfStructjson getWfStructjson(String dagid); + + void saveWfStructjson(WfStructjson structjson); + } diff --git a/src/main/java/edu/zju/gis/dldsj/service/impl/DashBoardServiceImpl.java b/src/main/java/edu/zju/gis/dldsj/service/impl/DashBoardServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..2fcbf6e3dd75506d11ca3043a8b6942507805462 --- /dev/null +++ b/src/main/java/edu/zju/gis/dldsj/service/impl/DashBoardServiceImpl.java @@ -0,0 +1,41 @@ +package edu.zju.gis.dldsj.service.impl; + +import edu.zju.gis.dldsj.dao.DbStructjsonMapper; +import edu.zju.gis.dldsj.entity.DbStructjson; +import edu.zju.gis.dldsj.service.DashBoardService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class DashBoardServiceImpl implements DashBoardService { + @Autowired + private DbStructjsonMapper dbstructjsonMapper; + + //仪表盘 保存、读取、更新 + @Override + public List getWfStructjsonList(String userId) { + return dbstructjsonMapper.selectByUserId(userId); + } + + @Override + public DbStructjson getWfStructjson(String dagId) { + return dbstructjsonMapper.selectByPrimaryKey(dagId); + } + + @Override + public void saveWfStructjson(DbStructjson structjson) { + DbStructjson old = dbstructjsonMapper.selectByPrimaryKey(structjson.getDashId()); + if (old != null) { + dbstructjsonMapper.deleteByPrimaryKey(old.getDashId()); + } + dbstructjsonMapper.insertSelective(structjson); + } + + @Override + public boolean delete(String pk) { + int code = dbstructjsonMapper.deleteByPrimaryKey(pk); + return code > 0; + } +} diff --git a/src/main/java/edu/zju/gis/dldsj/service/impl/UserTaskServiceImpl.java b/src/main/java/edu/zju/gis/dldsj/service/impl/UserTaskServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..df5c635727aaa245947560726b58e1c4eaff6dee --- /dev/null +++ b/src/main/java/edu/zju/gis/dldsj/service/impl/UserTaskServiceImpl.java @@ -0,0 +1,77 @@ +package edu.zju.gis.dldsj.service.impl; + +import edu.zju.gis.dldsj.dao.UserTaskMapper; +import edu.zju.gis.dldsj.entity.UserTask; +import edu.zju.gis.dldsj.service.UserTaskService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +public class UserTaskServiceImpl implements UserTaskService { + @Autowired + private UserTaskMapper userTaskMapper; + + @Override + public UserTask select(String pk) { + return userTaskMapper.selectByPrimaryKey(pk); + } + + @Override + public int insert(UserTask UserTask) { + return userTaskMapper.insertSelective(UserTask); + } + + @Override + public void update(UserTask UserTask) { + userTaskMapper.updateByPrimaryKeySelective(UserTask); + } + + @Override + public void delete(String s) { + userTaskMapper.deleteByPrimaryKey(s); + } + + @Override + public boolean isExist(String s) { + return userTaskMapper.selectByPrimaryKey(s) != null; + } + + @Override + public List getByPage(int offset, int size) { + return userTaskMapper.selectByPage(offset, size); + } + + @Override + public List get(String userId) { + return userTaskMapper.getByUserId(userId); + } + + @Override + public UserTask get(String userId, String taskId) { + return userTaskMapper.selectByUserTask(userId, taskId); + } + + @Override + public void insert(List userTasks) { + userTasks.forEach(userTaskMapper::insertSelective); + } + + @Override + public void upsert(UserTask UserTask) { + UserTask old = userTaskMapper.selectByUserTask(UserTask.getUserId(), UserTask.getTaskId()); + if (old != null) { + userTaskMapper.deleteByPrimaryKey(old.getId()); + } + userTaskMapper.insertSelective(UserTask); + } + + @Override + public void updateStatus(String artifactId, String status) { + userTaskMapper.updateStatus(artifactId, status); + } + + @Override + public void delete(String userId, String modelId) { + userTaskMapper.deleteByUserTask(userId, modelId); + } +} diff --git a/src/main/java/edu/zju/gis/dldsj/service/impl/WfServiceImpl.java b/src/main/java/edu/zju/gis/dldsj/service/impl/WfServiceImpl.java index 82612e765491654313d690426e860037f8c4198d..2dcb0a01699fe2b8dbf1d0c054b0126f4ccedba8 100755 --- a/src/main/java/edu/zju/gis/dldsj/service/impl/WfServiceImpl.java +++ b/src/main/java/edu/zju/gis/dldsj/service/impl/WfServiceImpl.java @@ -33,6 +33,8 @@ public class WfServiceImpl implements WfService { private WfRunMapper runMapper; @Autowired private WfInstanceMapper instanceMapper; + @Autowired + private WfStructjsonMapper structjsonMapper; @Override public int insert(AirflowDag airflowDag) { @@ -196,4 +198,24 @@ public class WfServiceImpl implements WfService { public WfInstance getWfInstance(String dagId, Date executionDate, String taskId) { return instanceMapper.selectByPrimaryKey(dagId, executionDate, taskId); } + + //工作流 保存、读取、更新 + @Override + public List getWfStructjsonList(String userId) { + return structjsonMapper.selectByUserId(userId); + } + + @Override + public WfStructjson getWfStructjson(String dagId) { + return structjsonMapper.selectByPrimaryKey(dagId); + } + + @Override + public void saveWfStructjson(WfStructjson structjson) { + WfStructjson old = structjsonMapper.selectByPrimaryKey(structjson.getDagId()); + if (old != null) { + structjsonMapper.deleteByPrimaryKey(old.getDagId()); + } + structjsonMapper.insertSelective(structjson); + } } diff --git a/src/main/java/edu/zju/gis/dldsj/tasks/WorkflowMonitor.java b/src/main/java/edu/zju/gis/dldsj/tasks/WorkflowMonitor.java index a6253fbd3de5fa148d0487874044ac9ec50a3b3d..6a94d744279d79e51655c64a2674f5abe6bdf574 100755 --- a/src/main/java/edu/zju/gis/dldsj/tasks/WorkflowMonitor.java +++ b/src/main/java/edu/zju/gis/dldsj/tasks/WorkflowMonitor.java @@ -2,10 +2,16 @@ package edu.zju.gis.dldsj.tasks; import edu.zju.gis.dldsj.config.CommonSetting; import edu.zju.gis.dldsj.entity.*; +import edu.zju.gis.dldsj.service.ParallelModelService; import edu.zju.gis.dldsj.service.WfService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.json.JSONArray; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; @@ -28,6 +34,7 @@ public class WorkflowMonitor implements Runnable { * 最终结果的存储位置 */ private String resultAddress; + private ParallelModelService parallelModelService; @Override public void run() { @@ -69,6 +76,29 @@ public class WorkflowMonitor implements Runnable { wfService.insert(instance); return instance; }).collect(Collectors.toList()); + log.info("tasks count is {}, start watch", tasks.size()); + + String endpoint = getEndPoint(wfService.getWfDag(wfRun.getDagId()));//获取最终模型taskId; + JSONArray fieldsJsonStr = new JSONArray(parallelModelService.select( + wfService.getWfInstance(wfRun.getDagId(), wfRun.getExecutionDate(), endpoint).getArtifactId()).getOut()); + String fieldNamesList = ""; + for (int i = 0; i < fieldsJsonStr.length(); i++) { + String fieldNames = ""; + JSONObject output = fieldsJsonStr.getJSONObject(i); + JSONArray fields = output.optJSONArray("fields"); + for (int j = 0; j < fields.length(); j++) { + JSONObject field = fields.getJSONObject(j); + String name = field.optString("name"); + if (!name.isEmpty()) { + fieldNames = fieldNames + name + ","; + } + } + fieldNamesList = fieldNamesList + fieldNames.substring(0, fieldNames.length() - 1) + ";"; + } + wfRun.setOutputType(fieldNamesList.substring(0, fieldNamesList.length() - 1)); + wfService.update(wfRun); + log.info("outputType信息已更新。"); + //4. 更新dag实例运行状态到业务数据库 while (true) { for (WfInstance task : tasks) { @@ -95,4 +125,24 @@ public class WorkflowMonitor implements Runnable { log.error("工作流`" + wfDag.getDagId() + "`监控失败", e); } } + + private String getEndPoint(WfDag wfDag) { + //获取最终子任务的ID + String endPointId = ""; + List> chains = Arrays.stream(wfDag.getTasks().split("#")).map(s -> Arrays.asList(s.split(","))).collect(Collectors.toList()); + for (int i = 0; i < chains.size(); i++) { + boolean isEnd = true; + List chain = chains.get(i); + for (int j = 0; j < chains.size() && j != i; j++) { + int index = chains.get(j).indexOf(chain.get(chain.size() - 1)); + if (index >= 0 && index < (chains.get(j).size() - 1)) { + isEnd = false; + break; + } + } + if (isEnd) + endPointId = chain.get(chain.size() - 1); + } + return endPointId; + } } diff --git a/src/main/java/edu/zju/gis/dldsj/utils/GeometryUtil.java b/src/main/java/edu/zju/gis/dldsj/utils/GeometryUtil.java index 6f894e9a8d15684011e56a8a564981c717c81423..8675035840dde2a018ba6e1e56862b97fda78b53 100755 --- a/src/main/java/edu/zju/gis/dldsj/utils/GeometryUtil.java +++ b/src/main/java/edu/zju/gis/dldsj/utils/GeometryUtil.java @@ -217,7 +217,9 @@ public final class GeometryUtil { } //根据数据类型构造geometry字段 assert geomField != null; - typeBuilder.add("geometry", reader.read(geomField.get(record).toString()).getClass()); + typeBuilder.add("geometry", LineString.class); + //TODO From "geom", geomtryType is Unknown, mark it in geom_fileds? + //typeBuilder.add("geometry", reader.read(geomField.get(record).toString()).getClass()); DefaultFeatureCollection sfc = new DefaultFeatureCollection(null, typeBuilder.buildFeatureType()); for (Object model : models) { SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(sfc.getSchema()); @@ -231,7 +233,9 @@ public final class GeometryUtil { featureBuilder.add(field.get(model));//按顺序添加属性值 } } - Geometry geometry = reader.read(geomField.get(model).toString()); + Object geomValue = geomField.get(model); + String value2Str = "LineString(" + geomValue.toString() + ")"; + Geometry geometry = reader.read(value2Str); featureBuilder.add(geometry); sfc.add(featureBuilder.buildFeature(null)); } diff --git a/src/main/resources/application-dls.yml b/src/main/resources/application-dls.yml index 9c2938e7a5d68605da5adf3b00c1c668d5881c61..395607b3d5589feda5c42b4569643a673a0fb645 100755 --- a/src/main/resources/application-dls.yml +++ b/src/main/resources/application-dls.yml @@ -64,3 +64,5 @@ settings: keepAliveSeconds: 60 airflowHome: /home/platform/airflow dagsFolder: /home/platform/airflow/dags + frontEndRegion: http://nn01:8081 + sessionMaxAge: 36000 diff --git a/src/main/resources/application-gislab.yml b/src/main/resources/application-gislab.yml index 454e2f7c09bd9a8486688bf3c948732af9155ba4..e135c3b33bec13ee60c7f2fe72d3812a5e32c95f 100755 --- a/src/main/resources/application-gislab.yml +++ b/src/main/resources/application-gislab.yml @@ -64,3 +64,5 @@ settings: keepAliveSeconds: 60 airflowHome: /home/ubt/airflow dagsFolder: /home/ubt/airflow/dags + frontEndRegion: http://localhost:8082 + sessionMaxAge: 36000 diff --git a/src/main/resources/application-localhost.yml b/src/main/resources/application-localhost.yml new file mode 100644 index 0000000000000000000000000000000000000000..f9239bc12dc0034fd6f0b3d0f78a0c978b6d05ee --- /dev/null +++ b/src/main/resources/application-localhost.yml @@ -0,0 +1,69 @@ +server: + port: 13001 + tomcat: + uri-encoding: UTF-8 + servlet: + context-path: /dldsj/ + + +spring: + application: + name: ${application-info.name} + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://192.168.1.5:3306/dldsj?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2B8 + username: ubt + password: Ubt123 + hikari: + auto-commit: true + maximum-pool-size: 20 + minimum-idle: 5 + idle-timeout: 3000 + connection-test-query: select 1 + connection-timeout: 3000 + type: com.zaxxer.hikari.HikariDataSource + servlet: + multipart: + max-file-size: 200MB + max-request-size: 200MB + mvc: + static-path-pattern: static/** + resources: + static-locations: + - file://${settings.picPath} + - classpath:/static + +#logging: +# level: +# edu.zju.gis.dldsj.dao: DEBUG + + +settings: + parallelFilePath: /Users/moral/opt/upload + jarPath: ${settings.parallelFilePath}/jar + xmlPath: ${settings.parallelFilePath}/xml + templatePath: ${settings.parallelFilePath}/template + picPath: ${settings.parallelFilePath}/pic + metaPath: /opt/dldsj/metadata + nameNode: 192.168.1.5 + username: ubt + password: ubt123 + javaHome: /opt/tool/jdk8 + hadoopHome: /opt/tool/hadoop + sparkHome: /opt/tool/spark + esHost: ubt1 + esPort: 9300 + esName: elasticsearch + esIndex: dls + jobMonitor: http://${settings.nameNode}:8088/ws/v1/cluster/apps + monitorInterval: 2000 + jobFailInterval: 300000 + jobResultPath: /output/task + initTaskPoolSize: 3 + maxTaskPoolSize: 20 + keepAliveSeconds: 60 + airflowHome: /home/ubt/airflow + dagsFolder: /home/ubt/airflow/dags + frontEndRegion: http://localhost:8082 + sessionMaxAge: 36000 + diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml index d34fe00d47be936a0fd7e467df4b02ceec6439b6..9010d65f0fd0b37cd127f4a66ed0a04c64223035 100755 --- a/src/main/resources/generatorConfig.xml +++ b/src/main/resources/generatorConfig.xml @@ -11,18 +11,31 @@ - -
- -
-
+ + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/mapper/DbStructjsonMapper.xml b/src/main/resources/mapper/DbStructjsonMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..39c668874dc44d87e9b6d7ca8d772fb158ed37ad --- /dev/null +++ b/src/main/resources/mapper/DbStructjsonMapper.xml @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + DASH_ID, DASH_NAME, USER_ID, SAVE_TIME, COMMENT + + + + STRUCT_JSON + + + + + + + + delete from tb_dash_structjson + where DASH_ID = #{dashId,jdbcType=VARCHAR} + + + + insert into tb_dash_structjson (DASH_ID, DASH_NAME, USER_ID, + SAVE_TIME, COMMENT, STRUCT_JSON + ) + values (#{dashId,jdbcType=VARCHAR}, #{dashName,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, + #{saveTime,jdbcType=TIMESTAMP}, #{comment,jdbcType=VARCHAR}, #{structJson,jdbcType=LONGVARCHAR} + ) + + + + insert into tb_dash_structjson + + + DASH_ID, + + + DASH_NAME, + + + USER_ID, + + + SAVE_TIME, + + + COMMENT, + + + STRUCT_JSON, + + + + + #{dashId,jdbcType=VARCHAR}, + + + #{dashName,jdbcType=VARCHAR}, + + + #{userId,jdbcType=VARCHAR}, + + + #{saveTime,jdbcType=TIMESTAMP}, + + + #{comment,jdbcType=VARCHAR}, + + + #{structJson,jdbcType=LONGVARCHAR}, + + + + + + update tb_dash_structjson + + + DASH_NAME = #{dashName,jdbcType=VARCHAR}, + + + USER_ID = #{userId,jdbcType=VARCHAR}, + + + SAVE_TIME = #{saveTime,jdbcType=TIMESTAMP}, + + + COMMENT = #{comment,jdbcType=VARCHAR}, + + + STRUCT_JSON = #{structJson,jdbcType=LONGVARCHAR}, + + + where DASH_ID = #{dashId,jdbcType=VARCHAR} + + + + update tb_dash_structjson + set DASH_NAME = #{dashName,jdbcType=VARCHAR}, + USER_ID = #{userId,jdbcType=VARCHAR}, + SAVE_TIME = #{saveTime,jdbcType=TIMESTAMP}, + COMMENT = #{comment,jdbcType=VARCHAR}, + STRUCT_JSON = #{structJson,jdbcType=LONGVARCHAR} + where DASH_ID = #{dashId,jdbcType=VARCHAR} + + + + update tb_dash_structjson + set DASH_NAME = #{dashName,jdbcType=VARCHAR}, + USER_ID = #{userId,jdbcType=VARCHAR}, + SAVE_TIME = #{saveTime,jdbcType=TIMESTAMP}, + COMMENT = #{comment,jdbcType=VARCHAR} + where DASH_ID = #{dashId,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml index b7e26d4978f46dbe2b10c1602cdf20d0affaeae4..4caf9c967cce013fdaad63695971538c7a4afe81 100755 --- a/src/main/resources/mapper/UserMapper.xml +++ b/src/main/resources/mapper/UserMapper.xml @@ -16,10 +16,14 @@ + + + + ID, ROLE_ID, NAME, FULL_NAME, PASSWORD, PSD_PROMPT, SEX, DESCRIPTION, REGISTRATION_TIME, - PHONE, EMAIL, ORGANIZATION, DEPARTMENT, STATUS + PHONE, EMAIL, ORGANIZATION, DEPARTMENT, STATUS, PRIVATE_DIR, DIR_SIZE, AVATAR_PATH, DIR_USED_SIZE + + select + + from sys_user_task + where ID = #{id,jdbcType=VARCHAR} + + + + + + + + + delete from sys_user_task + where ID = #{id,jdbcType=VARCHAR} + + + delete + from sys_user_task + where USER_ID = #{userId,jdbcType=VARCHAR} + and TASK_ID = #{taskId,jdbcType=VARCHAR} + + + + insert into sys_user_task (ID, USER_ID, TASK_ID, + CREATE_TIME, STATUS) + values (#{id,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{taskId,jdbcType=VARCHAR}, + #{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=VARCHAR}) + + + + insert into sys_user_task + + + ID, + + + USER_ID, + + + TASK_ID, + + + CREATE_TIME, + + + STATUS, + + + + + #{id,jdbcType=VARCHAR}, + + + #{userId,jdbcType=VARCHAR}, + + + #{taskId,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{status,jdbcType=VARCHAR}, + + + + + + update sys_user_task + + + USER_ID = #{userId,jdbcType=VARCHAR}, + + + TASK_ID = #{taskId,jdbcType=VARCHAR}, + + + CREATE_TIME = #{createTime,jdbcType=TIMESTAMP}, + + + STATUS = #{status,jdbcType=VARCHAR}, + + + where ID = #{id,jdbcType=VARCHAR} + + + + update sys_user_task + set USER_ID = #{userId,jdbcType=VARCHAR}, + TASK_ID = #{taskId,jdbcType=VARCHAR}, + CREATE_TIME = #{createTime,jdbcType=TIMESTAMP}, + STATUS = #{status,jdbcType=VARCHAR} + where ID = #{id,jdbcType=VARCHAR} + + + update sys_user_task + set STATUS = #{status,jdbcType=VARCHAR} + where TASK_ID = #{taskId,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/src/main/resources/mapper/WfInstanceMapper.xml b/src/main/resources/mapper/WfInstanceMapper.xml old mode 100755 new mode 100644 diff --git a/src/main/resources/mapper/WfRunMapper.xml b/src/main/resources/mapper/WfRunMapper.xml index 90dcd3b46051fa046cc60692c58e4b2200f8d3e3..8c9460d931001d6291ce9eda357f70e771978d6a 100755 --- a/src/main/resources/mapper/WfRunMapper.xml +++ b/src/main/resources/mapper/WfRunMapper.xml @@ -9,9 +9,10 @@ + - ID, DAG_ID, EXECUTION_DATE, RUN_ID, STATE, WORKSPACE, RESULT + ID, DAG_ID, EXECUTION_DATE, RUN_ID, STATE, WORKSPACE, RESULT, OUTPUT_TYPE + + select + + , + + from tb_wf_structjson + where DAG_ID = #{dagId,jdbcType=VARCHAR} + + + + + + + delete from tb_wf_structjson + where DAG_ID = #{dagId,jdbcType=VARCHAR} + + + + insert into tb_wf_structjson (DAG_ID, DAG_NAME, SAVE_TIME, + USER_ID, COMMENT, STRUCT_JSON + ) + values (#{dagId,jdbcType=VARCHAR}, #{dagName,jdbcType=VARCHAR}, #{saveTime,jdbcType=TIMESTAMP}, + #{userId,jdbcType=VARCHAR}, #{comment,jdbcType=VARCHAR}, #{structJson,jdbcType=LONGVARCHAR} + ) + + + + insert into tb_wf_structjson + + + DAG_ID, + + + DAG_NAME, + + + SAVE_TIME, + + + USER_ID, + + + COMMENT, + + + STRUCT_JSON, + + + + + #{dagId,jdbcType=VARCHAR}, + + + #{dagName,jdbcType=VARCHAR}, + + + #{saveTime,jdbcType=TIMESTAMP}, + + + #{userId,jdbcType=VARCHAR}, + + + #{comment,jdbcType=VARCHAR}, + + + #{structJson,jdbcType=LONGVARCHAR}, + + + + + + update tb_wf_structjson + + + DAG_NAME = #{dagName,jdbcType=VARCHAR}, + + + SAVE_TIME = #{saveTime,jdbcType=TIMESTAMP}, + + + USER_ID = #{userId,jdbcType=VARCHAR}, + + + COMMENT = #{comment,jdbcType=VARCHAR}, + + + STRUCT_JSON = #{structJson,jdbcType=LONGVARCHAR}, + + + where DAG_ID = #{dagId,jdbcType=VARCHAR} + + + + update tb_wf_structjson + set DAG_NAME = #{dagName,jdbcType=VARCHAR}, + SAVE_TIME = #{saveTime,jdbcType=TIMESTAMP}, + USER_ID = #{userId,jdbcType=VARCHAR}, + COMMENT = #{comment,jdbcType=VARCHAR}, + STRUCT_JSON = #{structJson,jdbcType=LONGVARCHAR} + where DAG_ID = #{dagId,jdbcType=VARCHAR} + + + + update tb_wf_structjson + set DAG_NAME = #{dagName,jdbcType=VARCHAR}, + SAVE_TIME = #{saveTime,jdbcType=TIMESTAMP}, + USER_ID = #{userId,jdbcType=VARCHAR}, + COMMENT = #{comment,jdbcType=VARCHAR} + where DAG_ID = #{dagId,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/src/test/java/edu/zju/gis/dldsj/controller/DashBoardControllerTest.java b/src/test/java/edu/zju/gis/dldsj/controller/DashBoardControllerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6b42534cf2c94beb1697c0454f370ae9e59cdd51 --- /dev/null +++ b/src/test/java/edu/zju/gis/dldsj/controller/DashBoardControllerTest.java @@ -0,0 +1,46 @@ +package edu.zju.gis.dldsj.controller; + +import com.google.gson.JsonObject; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class DashBoardControllerTest { + @Autowired + public DashBoardController dashboardController; + + @Test + public void testList() { + String s = dashboardController.getDashBoardStructList("1"); + System.out.println(s); + } + + @Test + public void testgetStructJson() { + String s = dashboardController.getDashBoardAsJson("1", "newStoreWay"); + System.out.println(s); + } + + @Test + public void testsaveStructJson() { + JsonObject res = new JsonObject(); + res.addProperty("dashboardName", "newStoreWay2"); + res.addProperty("structJson", "[{\"method\":\"BKmeans\",\"id\":\"item1543477377826\"," + + "\"positionTop\":122,\"positionLeft\":222,\"sourceData\":[{\"name\":\"经济贸易情况\"," + + "\"id\":\"item1543477371418\",\"positionTop\":105,\"positionLeft\":52,\"type\":\"data\"}," + + "{\"name\":\"能源工业情况\",\"id\":\"item1543477373759\",\"positionTop\":206,\"positionLeft\":48," + + "\"type\":\"data\"}]},{\"method\":\"spatial_filter\",\"id\":\"item1543497565878\"," + + "\"positionTop\":115,\"positionLeft\":402,\"sourceData\":[{\"name\":\"人口统计情况\"," + + "\"id\":\"item1543497553064\",\"positionTop\":22,\"positionLeft\":136,\"type\":\"data\"}," + + "{\"name\":\"BKmeans\",\"id\":\"item1543477377826\",\"positionTop\":122,\"positionLeft\":222," + + "\"type\":\"method\"}]}]"); + res.addProperty("userId", "1"); + res.addProperty("comment", "wawawawawawa"); + String s = dashboardController.saveDashBoardAsJson("1", res.toString()); + System.out.println(s); + } +} diff --git a/src/test/java/edu/zju/gis/dldsj/controller/DataControllerTest.java b/src/test/java/edu/zju/gis/dldsj/controller/DataControllerTest.java index c5f2ee4eb318c71e05d0a416c16372db2d021dca..b2d853f4746f0ba2d03211b77c62be5973e243f3 100755 --- a/src/test/java/edu/zju/gis/dldsj/controller/DataControllerTest.java +++ b/src/test/java/edu/zju/gis/dldsj/controller/DataControllerTest.java @@ -42,7 +42,7 @@ public class DataControllerTest { @Test public void testGetAsGeoJSON() { - String result = dataController.getAsGeoJSON("13", 0, 200); + String result = dataController.getAsGeoJSON("20", 0, 200); System.out.println(result); } diff --git a/src/test/java/edu/zju/gis/dldsj/controller/ParallelModelControllerTest.java b/src/test/java/edu/zju/gis/dldsj/controller/ParallelModelControllerTest.java index 8f2a28099096401e72aa80c8a529c3e97e3ab96b..ee79a5766142a435671c9ee6965ea7142c2463e5 100755 --- a/src/test/java/edu/zju/gis/dldsj/controller/ParallelModelControllerTest.java +++ b/src/test/java/edu/zju/gis/dldsj/controller/ParallelModelControllerTest.java @@ -18,7 +18,7 @@ public class ParallelModelControllerTest { @Test public void testGetAllModels() { - System.out.println(controller.getAllModels("1", "1")); + System.out.println(controller.getPublicModels()); } @Test diff --git a/src/test/java/edu/zju/gis/dldsj/controller/RoleControllerTest.java b/src/test/java/edu/zju/gis/dldsj/controller/RoleControllerTest.java index 3f27b5d3ec51154a652226083a2dfd19a796737f..1bfc0e55f3fffcc0d038168df32667a292537dd2 100755 --- a/src/test/java/edu/zju/gis/dldsj/controller/RoleControllerTest.java +++ b/src/test/java/edu/zju/gis/dldsj/controller/RoleControllerTest.java @@ -22,7 +22,6 @@ public class RoleControllerTest { public void testAdd() throws JsonProcessingException { Role role = new Role(); role.setName("lyl"); - ; role.setDescription("no description"); role.setIsAdministrator("true"); roleController.addRole("1", role.toJsonString()); diff --git a/src/test/java/edu/zju/gis/dldsj/controller/UserControllerTest.java b/src/test/java/edu/zju/gis/dldsj/controller/UserControllerTest.java index 4bfb2cf0f5d1d8c32f5098a2ccf004ceb93f4b8c..1dac45a2ecd2de9e5c541a4b5653c60ef31c38dc 100755 --- a/src/test/java/edu/zju/gis/dldsj/controller/UserControllerTest.java +++ b/src/test/java/edu/zju/gis/dldsj/controller/UserControllerTest.java @@ -22,14 +22,21 @@ public class UserControllerTest { private RoleService roleService; @Test - public void testAdd() throws JsonProcessingException { + public void test_register() throws JsonProcessingException { User user = new User(); - user.setRoleId(roleService.getByName("test").getId()); - user.setName("test"); - user.setFullName("just for test"); + user.setRoleId("1"); + user.setName("fzy"); + user.setFullName("FuZhiyi"); user.setPassword("123"); user.setSex("male"); - String res = userController.register("1", user.toJsonString()); + user.setAvatarPath("xxxxxx.jpg"); + String res = userController.register(user.toJsonString()); + System.out.println(res); + } + + @Test + public void test_getuserinfo() { + String res = userController.getUserInfo("czd"); System.out.println(res); } } diff --git a/src/test/java/edu/zju/gis/dldsj/controller/WorkflowControllerTest.java b/src/test/java/edu/zju/gis/dldsj/controller/WorkflowControllerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8d04e4ba56bd27bc1d64d6604e726437e638a194 --- /dev/null +++ b/src/test/java/edu/zju/gis/dldsj/controller/WorkflowControllerTest.java @@ -0,0 +1,64 @@ +package edu.zju.gis.dldsj.controller; + +import com.google.gson.JsonObject; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class WorkflowControllerTest { + @Autowired + public WorkflowController workflowController; + + @Test + public void testList() { + String s = workflowController.getUserDags("1"); + System.out.println(s); + } + + @Test + public void testgetStructJsonlist() { + String s = workflowController.getWfStructList("1"); + System.out.println(s); + } + + @Test + public void testgetStructJson() { + String s = workflowController.getWfAsJson("1", "demo"); + System.out.println(s); + } + + @Test + public void testsaveStructJson() { + JsonObject res = new JsonObject(); + res.addProperty("dagName", "newStoreWay"); + res.addProperty("structJson", "[{\"method\":\"BKmeans\",\"id\":\"item1543477377826\"," + + "\"positionTop\":122,\"positionLeft\":222,\"sourceData\":[{\"name\":\"经济贸易情况\"," + + "\"id\":\"item1543477371418\",\"positionTop\":105,\"positionLeft\":52,\"type\":\"data\"}," + + "{\"name\":\"能源工业情况\",\"id\":\"item1543477373759\",\"positionTop\":206,\"positionLeft\":48," + + "\"type\":\"data\"}]},{\"method\":\"spatial_filter\",\"id\":\"item1543497565878\"," + + "\"positionTop\":115,\"positionLeft\":402,\"sourceData\":[{\"name\":\"人口统计情况\"," + + "\"id\":\"item1543497553064\",\"positionTop\":22,\"positionLeft\":136,\"type\":\"data\"}," + + "{\"name\":\"BKmeans\",\"id\":\"item1543477377826\",\"positionTop\":122,\"positionLeft\":222," + + "\"type\":\"method\"}]}]"); + res.addProperty("userId", "1"); + res.addProperty("comment", "wawawawawawa"); + String s = workflowController.saveWfAsJson("1", res.toString()); + System.out.println(s); + } + + @Test + public void testgetTablePreview() { + String s = workflowController.getResultAsTable("BKmeans1544019793967", 0, 50); + System.out.println(s); + } + + @Test + public void testgetResultAsGeoJson() { + String s = workflowController.getResultAsGeoJson("ODPairDetectionVehicle1544179375282", 0, 50); + System.out.println(s); + } +} diff --git a/src/test/java/edu/zju/gis/dldsj/service/DagServiceTest.java b/src/test/java/edu/zju/gis/dldsj/service/DagServiceTest.java index 79385d840c9e769fd273c289ac3a3eeba3502961..a529e638ce356f3f39b059101b2b75880ef3ce86 100755 --- a/src/test/java/edu/zju/gis/dldsj/service/DagServiceTest.java +++ b/src/test/java/edu/zju/gis/dldsj/service/DagServiceTest.java @@ -65,8 +65,8 @@ public class DagServiceTest { @Test public void testMonitor() { - WfDag wfDag = wfService.getWfDag("mr-spark"); - WorkflowMonitor monitor = new WorkflowMonitor(setting, wfService, wfDag, null, "/airflow/mr-spark/output", "/airflow/mr-spark/output/spark"); - monitorTasks.execute(monitor); +// WfDag wfDag = wfService.getWfDag("mr-spark"); +// WorkflowMonitor monitor = new WorkflowMonitor(setting, wfService, wfDag, null, "/airflow/mr-spark/output", "/airflow/mr-spark/output/spark"); +// monitorTasks.execute(monitor); } }