From abf3352c81507e1239b64726690ebf62b07d65ee Mon Sep 17 00:00:00 2001 From: yangzhiyue <904666286@qq.com> Date: Wed, 18 Aug 2021 22:26:26 +0800 Subject: [PATCH 1/2] add dss-framework module close #363 close #364 close #365 close #366 close #367 close #368 close #369 --- dss-framework/dss-appconn-framework/pom.xml | 127 ++++ .../appconn/SpringAppConnManager.java | 36 ++ .../framework/appconn/dao/AppConnMapper.java | 52 ++ .../appconn/dao/AppInstanceMapper.java | 40 ++ .../appconn/dao/impl/appConnMapper.xml | 81 +++ .../appconn/dao/impl/appInstanceMapper.xml | 49 ++ .../framework/appconn/entity/AppConnBean.java | 155 +++++ .../appconn/entity/AppConnResource.java | 51 ++ .../appconn/entity/AppInstanceBean.java | 110 ++++ .../AppConnNotExistsErrorException.java | 32 + .../restful/AppConnManagerRestfulApi.java | 106 +++ .../service/AppConnResourceUploadService.java | 26 + .../service/impl/AppConnInfoServiceImpl.java | 69 ++ .../impl/AppConnResourceServiceImpl.java | 173 +++++ .../appconn/utils/AppConnServiceUtils.java | 33 + dss-framework/dss-framework-common/pom.xml | 115 ++++ .../exception/DSSFrameworkErrorException.java | 39 ++ .../DSSFrameworkRuntimeException.java | 27 + .../exception/DSSFrameworkWarnException.java | 33 + .../common/exception/ThrowingConsumer.java | 23 + .../common/exception/ThrowingFunction.java | 23 + .../utils/DSSFrameworkExceptionUtils.java | 57 ++ .../framework/common/utils/RestfulUtils.java | 48 ++ ...start-dss-framework-orchestrator-server.sh | 36 ++ .../stop-dss-framework-orchestrator-server.sh | 47 ++ .../dss-framework-orchestrator-server/pom.xml | 187 ++++++ .../src/main/assembly/distribution.xml | 44 ++ .../server/conf/OrchestratorConf.java | 24 + .../server/conf/OrchestratorSpringConf.java | 33 + .../constant/DSSOrchestratorConstant.java | 22 + .../OrchestratorSpringConfiguration.java | 34 + .../server/entity/UploadFileResponse.java | 32 + .../query/QueryOrchestratorVersion.java | 35 + .../server/restful/OrchestratorIERestful.java | 181 ++++++ .../server/restful/OrchestratorRestful.java | 150 +++++ .../service/OrchestratorPluginService.java | 29 + .../server/service/OrchestratorService.java | 99 +++ .../impl/OrchestratorPluginServiceImpl.java | 160 +++++ .../service/impl/OrchestratorServiceImpl.java | 376 +++++++++++ .../DSSOrchestratorServerApplication.scala | 39 ++ .../receiver/DSSOrchestratorChooser.scala | 58 ++ .../receiver/DSSOrchestratorReceiver.scala | 114 ++++ .../bin/start-dss-framework-project-server.sh | 36 ++ .../bin/stop-dss-framework-project-server.sh | 47 ++ .../dss-framework-project-server/pom.xml | 252 ++++++++ .../src/main/assembly/distribution.xml | 44 ++ .../framework/project/conf/ProjectConf.java | 26 + .../project/conf/ProjectSpringConf.java | 43 ++ .../conf/ValidationExceptionMapper.java | 52 ++ .../project/contant/OrchestratorTypeEnum.java | 88 +++ .../contant/ProjectServerResponse.java | 49 ++ .../contant/ProjectSpringConfiguration.java | 34 + .../project/contant/ProjectUserPrivEnum.java | 50 ++ .../project/dao/DSSOrchestratorMapper.java | 31 + .../project/dao/DSSProjectMapper.java | 75 +++ .../project/dao/DSSProjectUserMapper.java | 45 ++ .../project/dao/impl/DSSProjectMapper.xml | 77 +++ .../project/entity/DSSOrchestrator.java | 236 +++++++ .../project/entity/DSSProjectDO.java | 344 ++++++++++ .../project/entity/DSSProjectUser.java | 106 +++ .../project/entity/po/DSSProjectPo.java | 276 ++++++++ .../project/entity/po/ProjectRelationPo.java | 58 ++ .../entity/request/ForbiddenFlowRequest.java | 79 +++ .../request/OrchestratorCreateRequest.java | 161 +++++ .../request/OrchestratorDeleteRequest.java | 74 +++ .../request/OrchestratorModifyRequest.java | 152 +++++ .../entity/request/OrchestratorRequest.java | 83 +++ .../entity/request/ProjectCreateRequest.java | 160 +++++ .../entity/request/ProjectDeleteRequest.java | 67 ++ .../entity/request/ProjectModifyRequest.java | 184 ++++++ .../entity/request/ProjectQueryRequest.java | 59 ++ .../entity/request/RemoveFlowRequest.java | 67 ++ .../entity/response/ProjectResponse.java | 222 +++++++ .../entity/vo/AbstractOrchestratorVo.java | 48 ++ .../entity/vo/CommonOrchestratorVo.java | 26 + .../entity/vo/DSSFlowOrchestratorFlowVo.java | 86 +++ .../project/entity/vo/DSSProjectDetailVo.java | 109 ++++ .../project/entity/vo/DSSProjectVo.java | 54 ++ .../project/entity/vo/LabelRouteVo.java | 30 + .../entity/vo/OrchestratorBaseInfo.java | 229 +++++++ .../entity/vo/OrdinaryOrchestratorVo.java | 26 + .../project/entity/vo/ProcessNode.java | 28 + .../project/entity/vo/ProjectInfoVo.java | 61 ++ .../project/entity/vo/QueryProjectVo.java | 165 +++++ .../exception/DSSProjectErrorException.java | 30 + .../exception/DSSProjectWarnException.java | 29 + .../exception/LambdaWarnException.java | 28 + .../DSSFrameworkOrchestratorRestful.java | 149 +++++ .../DSSFrameworkProjectRestfulApi.java | 188 ++++++ .../DSSFrameworkOrchestratorService.java | 40 ++ .../service/DSSFrameworkProjectService.java | 39 ++ .../service/DSSOrchestratorService.java | 55 ++ .../project/service/DSSProjectService.java | 67 ++ .../service/DSSProjectUserService.java | 46 ++ .../DSSFrameworkOrchestratorServiceImpl.java | 295 +++++++++ .../impl/DSSFrameworkProjectServiceImpl.java | 226 +++++++ .../impl/DSSOrchestratorServiceImpl.java | 306 +++++++++ .../service/impl/DSSProjectServiceImpl.java | 259 ++++++++ .../impl/DSSProjectUserServiceImpl.java | 188 ++++++ .../project/utils/ApplicationArea.java | 52 ++ .../framework/project/utils/LambdaHelper.java | 41 ++ .../project/utils/ProjectStringUtils.java | 67 ++ .../project/utils/ProjectUserUtils.java | 52 ++ .../framework/project/utils/RestfulUtils.java | 46 ++ .../server/DSSProjectServerApplication.scala | 38 ++ .../project/server/rpc/ProjectReceiver.scala | 80 +++ .../server/rpc/ProjectReceiverChooser.scala | 47 ++ .../project/server/service/BMLService.scala | 183 ++++++ .../start-dss-framework-workspace-server.sh | 36 ++ .../stop-dss-framework-workspace-server.sh | 47 ++ .../dss-framework-workspace-server/pom.xml | 133 ++++ .../src/main/assembly/distribution.xml | 320 ++++++++++ .../workspace/annotation/DSSWorkspaceUM.java | 29 + .../annotation/WorkspaceIdChecker.java | 29 + .../workspace/aop/DSSPrivCheckerAspect.java | 28 + .../aop/DSSUWorkspaceIdCheckerAspect.java | 29 + .../workspace/aop/DSSWorkspaceUMAspect.java | 26 + .../framework/workspace/bean/BaseEntity.java | 63 ++ .../workspace/bean/DSSApplication.java | 169 +++++ .../workspace/bean/DSSApplicationBean.java | 57 ++ .../workspace/bean/DSSComponentRole.java | 102 +++ .../workspace/bean/DSSDictionary.java | 304 +++++++++ .../framework/workspace/bean/DSSFavorite.java | 70 ++ .../framework/workspace/bean/DSSHomepage.java | 48 ++ .../dss/framework/workspace/bean/DSSMenu.java | 169 +++++ .../framework/workspace/bean/DSSMenuRole.java | 115 ++++ .../dss/framework/workspace/bean/DSSRole.java | 89 +++ .../dss/framework/workspace/bean/DSSUser.java | 93 +++ .../workspace/bean/DSSWorkspace.java | 124 ++++ .../workspace/bean/DSSWorkspaceComponent.java | 48 ++ .../bean/DSSWorkspaceComponentInfo.java | 106 +++ .../bean/DSSWorkspaceComponentPriv.java | 100 +++ .../bean/DSSWorkspaceComponentRolePriv.java | 106 +++ .../workspace/bean/DSSWorkspaceHomepage.java | 88 +++ .../bean/DSSWorkspaceHomepageSetting.java | 68 ++ .../bean/DSSWorkspaceMenuComponentUrl.java | 86 +++ .../workspace/bean/DSSWorkspaceMenuRole.java | 95 +++ .../bean/DSSWorkspaceMenuRolePriv.java | 86 +++ .../workspace/bean/DSSWorkspaceUser.java | 63 ++ .../framework/workspace/bean/LinkisUser.java | 84 +++ .../dss/framework/workspace/bean/Sidebar.java | 185 ++++++ .../workspace/bean/SidebarContent.java | 223 +++++++ .../framework/workspace/bean/StaffInfo.java | 147 +++++ .../workspace/bean/WorkSpaceUserAndRole.java | 80 +++ .../dto/response/HomepageDemoInstanceVo.java | 93 +++ .../bean/dto/response/HomepageDemoMenuVo.java | 86 +++ .../bean/dto/response/HomepageVideoVo.java | 75 +++ .../response/OnestopMenuAppInstanceVo.java | 158 +++++ .../bean/dto/response/OnestopMenuVo.java | 59 ++ .../dto/response/WorkspaceDepartmentVo.java | 41 ++ .../dto/response/WorkspaceFavoriteVo.java | 98 +++ .../workspace/bean/vo/AbstractDSSVO.java | 21 + .../workspace/bean/vo/DSSDatasourceVO.java | 123 ++++ .../bean/vo/DSSDictionaryRequestVO.java | 53 ++ .../bean/vo/DSSPersonalWorkflowVO.java | 83 +++ .../workspace/bean/vo/DSSProjectUserVo.java | 82 +++ .../workspace/bean/vo/DSSPublicTableVO.java | 123 ++++ .../bean/vo/DSSScheduledWorkFlow.java | 21 + .../bean/vo/DSSScheduledWorkFlowVO.java | 131 ++++ .../bean/vo/DSSWorkflowVersionVO.java | 93 +++ .../bean/vo/DSSWorkspaceComponentPrivVO.java | 72 +++ .../bean/vo/DSSWorkspaceHomePageVO.java | 63 ++ .../vo/DSSWorkspaceHomepageSettingVO.java | 86 +++ .../bean/vo/DSSWorkspaceMenuPrivVO.java | 70 ++ .../bean/vo/DSSWorkspaceMenuPrivsVO.java | 48 ++ .../workspace/bean/vo/DSSWorkspaceMenuVO.java | 75 +++ .../bean/vo/DSSWorkspaceOverviewVO.java | 119 ++++ .../workspace/bean/vo/DSSWorkspacePrivVO.java | 88 +++ .../workspace/bean/vo/DSSWorkspaceRoleVO.java | 62 ++ .../vo/DSSWorkspaceScriptisStatiticVO.java | 65 ++ .../bean/vo/DSSWorkspaceStatisticVO.java | 22 + .../workspace/bean/vo/DSSWorkspaceUserVO.java | 97 +++ .../workspace/bean/vo/DSSWorkspaceVO.java | 89 +++ .../workspace/bean/vo/DepartmentVO.java | 58 ++ .../bean/vo/SecondaryWorkspaceMenuVO.java | 57 ++ .../workspace/bean/vo/SidebarContentVO.java | 74 +++ .../workspace/bean/vo/SidebarVO.java | 64 ++ .../workspace/bean/vo/StaffInfoVO.java | 57 ++ .../framework/workspace/bean/vo/VOUtils.java | 28 + .../AbstractWorkspaceComponentInfoVO.java | 131 ++++ .../vo/info/DSSWorkspaceScriptisInfoVO.java | 39 ++ .../vo/info/DSSWorkspaceVisualisInfoVO.java | 40 ++ .../vo/info/DSSWorkspaceWorkflowInfoVO.java | 45 ++ .../workspace/constant/ApplicationConf.java | 42 ++ .../workspace/dao/DSSApplicationMapper.java | 28 + .../workspace/dao/DSSComponentRoleMapper.java | 33 + .../workspace/dao/DSSDictionaryMapper.java | 27 + .../workspace/dao/DSSMenuRoleMapper.java | 31 + .../workspace/dao/DSSUserMapper.java | 26 + .../dao/DSSWorkspaceHomepageMapper.java | 31 + .../workspace/dao/DSSWorkspaceInfoMapper.java | 41 ++ .../workspace/dao/DSSWorkspaceMapper.java | 50 ++ .../workspace/dao/DSSWorkspaceMenuMapper.java | 75 +++ .../workspace/dao/DSSWorkspacePrivMapper.java | 48 ++ .../dao/DSSWorkspaceProjectMapper.java | 157 +++++ .../workspace/dao/DSSWorkspaceRoleMapper.java | 138 ++++ .../workspace/dao/DSSWorkspaceUserMapper.java | 99 +++ .../workspace/dao/LinkisUserMapper.java | 26 + .../workspace/dao/SidebarContentMapper.java | 26 + .../workspace/dao/SidebarMapper.java | 29 + .../workspace/dao/WorkspaceMapper.java | 68 ++ .../dao/impl/DSSComponentRoleMapper.xml | 31 + .../workspace/dao/impl/DSSMenuRoleMapper.xml | 31 + .../dao/impl/DSSWorkspaceHomepageMapper.xml | 29 + .../workspace/dao/impl/DSSWorkspaceMapper.xml | 81 +++ .../dao/impl/DSSWorkspaceUserMapper.xml | 29 + .../workspace/dao/impl/WorkspaceMapper.xml | 193 ++++++ .../DSSWorkspaceDuplicateNameException.java | 28 + .../DSSWorkspaceLoginFailException.java | 30 + .../restful/DSSDictionaryRestful.java | 134 ++++ .../workspace/restful/DSSSideInfoRestful.java | 59 ++ .../restful/DSSWorkspacePrivRestful.java | 122 ++++ .../restful/DSSWorkspaceRestful.java | 134 ++++ .../restful/DSSWorkspaceRoleRestful.java | 212 ++++++ .../restful/DSSWorkspaceUserRestful.java | 169 +++++ .../restful/WorkspaceRestfulApi.java | 177 +++++ .../service/DSSDictionaryService.java | 45 ++ .../workspace/service/DSSSideInfoService.java | 28 + .../workspace/service/DSSUserService.java | 32 + .../service/DSSWorkspaceMenuService.java | 30 + .../service/DSSWorkspacePrivService.java | 30 + .../service/DSSWorkspaceRoleService.java | 30 + .../service/DSSWorkspaceService.java | 86 +++ .../service/DSSWorkspaceUserService.java | 39 ++ .../workspace/service/StaffInfoGetter.java | 30 + .../impl/DSSDictionaryServiceImpl.java | 120 ++++ .../service/impl/DSSSideInfoServiceImpl.java | 129 ++++ .../service/impl/DSSUserServiceImpl.java | 98 +++ .../impl/DSSWorkspaceMenuServiceImpl.java | 63 ++ .../impl/DSSWorkspacePrivServiceImpl.java | 65 ++ .../impl/DSSWorkspaceRoleServiceImpl.java | 108 ++++ .../service/impl/DSSWorkspaceServiceImpl.java | 604 ++++++++++++++++++ .../impl/DSSWorkspaceUserServiceImpl.java | 99 +++ .../service/impl/DefaultStaffInfoGetter.java | 40 ++ .../workspace/util/ApplicationUtils.java | 50 ++ .../workspace/util/CommonRoleEnum.java | 64 ++ .../workspace/util/DSSDictionaryConstant.java | 22 + .../workspace/util/DSSWorkspaceConstant.java | 32 + .../workspace/util/RestfulUtils.java | 49 ++ .../workspace/util/RestulHelper.java | 45 ++ .../workspace/util/WorkspaceDBHelper.java | 337 ++++++++++ .../util/WorkspaceServerConstant.java | 24 + .../workspace/util/WorkspaceSpringConfig.java | 36 ++ .../pom.xml | 114 ++++ .../ConversionDSSOrchestratorPlugin.java | 35 + .../publish/ExportDSSOrchestratorPlugin.java | 47 ++ .../publish/ImportDSSOrchestratorPlugin.java | 54 ++ .../publish/conf/DSSOrchestratorConf.java | 24 + .../ConversionDSSOrchestratorPluginImpl.java | 50 ++ .../impl/ExportDSSOrchestratorPluginImpl.java | 221 +++++++ .../impl/ImportDSSOrchestratorPluginImpl.java | 194 ++++++ .../publish/io/export/MetaExportService.java | 37 ++ .../publish/io/export/MetaWriter.java | 172 +++++ .../io/export/impl/MetaExportServiceImpl.java | 61 ++ .../publish/io/input/MetaInputService.java | 34 + .../publish/io/input/MetaReader.java | 166 +++++ .../io/input/impl/MetaInputServiceImpl.java | 61 ++ .../publish/job/ConversionJobEntity.java | 119 ++++ .../job/OrchestratorConversionJob.java | 107 ++++ dss-framework/pom.xml | 40 ++ 260 files changed, 22734 insertions(+) create mode 100644 dss-framework/dss-appconn-framework/pom.xml create mode 100644 dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/SpringAppConnManager.java create mode 100644 dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/AppConnMapper.java create mode 100644 dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/AppInstanceMapper.java create mode 100644 dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/impl/appConnMapper.xml create mode 100644 dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/impl/appInstanceMapper.xml create mode 100644 dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/entity/AppConnBean.java create mode 100644 dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/entity/AppConnResource.java create mode 100644 dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/entity/AppInstanceBean.java create mode 100644 dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/exception/AppConnNotExistsErrorException.java create mode 100644 dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/restful/AppConnManagerRestfulApi.java create mode 100644 dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/service/AppConnResourceUploadService.java create mode 100644 dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/service/impl/AppConnInfoServiceImpl.java create mode 100644 dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/service/impl/AppConnResourceServiceImpl.java create mode 100644 dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/utils/AppConnServiceUtils.java create mode 100644 dss-framework/dss-framework-common/pom.xml create mode 100644 dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/DSSFrameworkErrorException.java create mode 100644 dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/DSSFrameworkRuntimeException.java create mode 100644 dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/DSSFrameworkWarnException.java create mode 100644 dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/ThrowingConsumer.java create mode 100644 dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/ThrowingFunction.java create mode 100644 dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/utils/DSSFrameworkExceptionUtils.java create mode 100644 dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/utils/RestfulUtils.java create mode 100644 dss-framework/dss-framework-orchestrator-server/bin/start-dss-framework-orchestrator-server.sh create mode 100644 dss-framework/dss-framework-orchestrator-server/bin/stop-dss-framework-orchestrator-server.sh create mode 100644 dss-framework/dss-framework-orchestrator-server/pom.xml create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/assembly/distribution.xml create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/conf/OrchestratorConf.java create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/conf/OrchestratorSpringConf.java create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/constant/DSSOrchestratorConstant.java create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/constant/OrchestratorSpringConfiguration.java create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/entity/UploadFileResponse.java create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/entity/query/QueryOrchestratorVersion.java create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/restful/OrchestratorIERestful.java create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/restful/OrchestratorRestful.java create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/OrchestratorPluginService.java create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/OrchestratorService.java create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/impl/OrchestratorPluginServiceImpl.java create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/impl/OrchestratorServiceImpl.java create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/scala/com/webank/wedatasphere/dss/orchestrator/server/DSSOrchestratorServerApplication.scala create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/scala/com/webank/wedatasphere/dss/orchestrator/server/receiver/DSSOrchestratorChooser.scala create mode 100644 dss-framework/dss-framework-orchestrator-server/src/main/scala/com/webank/wedatasphere/dss/orchestrator/server/receiver/DSSOrchestratorReceiver.scala create mode 100644 dss-framework/dss-framework-project-server/bin/start-dss-framework-project-server.sh create mode 100644 dss-framework/dss-framework-project-server/bin/stop-dss-framework-project-server.sh create mode 100644 dss-framework/dss-framework-project-server/pom.xml create mode 100644 dss-framework/dss-framework-project-server/src/main/assembly/distribution.xml create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/conf/ProjectConf.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/conf/ProjectSpringConf.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/conf/ValidationExceptionMapper.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/OrchestratorTypeEnum.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/ProjectServerResponse.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/ProjectSpringConfiguration.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/ProjectUserPrivEnum.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/DSSOrchestratorMapper.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/DSSProjectMapper.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/DSSProjectUserMapper.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/impl/DSSProjectMapper.xml create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/DSSOrchestrator.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/DSSProjectDO.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/DSSProjectUser.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/po/DSSProjectPo.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/po/ProjectRelationPo.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ForbiddenFlowRequest.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorCreateRequest.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorDeleteRequest.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorModifyRequest.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorRequest.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectCreateRequest.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectDeleteRequest.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectModifyRequest.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectQueryRequest.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/RemoveFlowRequest.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/response/ProjectResponse.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/AbstractOrchestratorVo.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/CommonOrchestratorVo.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/DSSFlowOrchestratorFlowVo.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/DSSProjectDetailVo.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/DSSProjectVo.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/LabelRouteVo.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/OrchestratorBaseInfo.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/OrdinaryOrchestratorVo.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/ProcessNode.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/ProjectInfoVo.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/QueryProjectVo.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/exception/DSSProjectErrorException.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/exception/DSSProjectWarnException.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/exception/LambdaWarnException.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/restful/DSSFrameworkOrchestratorRestful.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/restful/DSSFrameworkProjectRestfulApi.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSFrameworkOrchestratorService.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSFrameworkProjectService.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSOrchestratorService.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSProjectService.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSProjectUserService.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSFrameworkOrchestratorServiceImpl.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSFrameworkProjectServiceImpl.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSOrchestratorServiceImpl.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSProjectServiceImpl.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSProjectUserServiceImpl.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/ApplicationArea.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/LambdaHelper.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/ProjectStringUtils.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/ProjectUserUtils.java create mode 100644 dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/RestfulUtils.java create mode 100644 dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/DSSProjectServerApplication.scala create mode 100644 dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/rpc/ProjectReceiver.scala create mode 100644 dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/rpc/ProjectReceiverChooser.scala create mode 100644 dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/service/BMLService.scala create mode 100644 dss-framework/dss-framework-workspace-server/bin/start-dss-framework-workspace-server.sh create mode 100644 dss-framework/dss-framework-workspace-server/bin/stop-dss-framework-workspace-server.sh create mode 100644 dss-framework/dss-framework-workspace-server/pom.xml create mode 100644 dss-framework/dss-framework-workspace-server/src/main/assembly/distribution.xml create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/annotation/DSSWorkspaceUM.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/annotation/WorkspaceIdChecker.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/aop/DSSPrivCheckerAspect.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/aop/DSSUWorkspaceIdCheckerAspect.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/aop/DSSWorkspaceUMAspect.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/BaseEntity.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSApplication.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSApplicationBean.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSComponentRole.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSDictionary.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSFavorite.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSHomepage.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSMenu.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSMenuRole.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSRole.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSUser.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspace.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponent.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponentInfo.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponentPriv.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponentRolePriv.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceHomepage.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceHomepageSetting.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceMenuComponentUrl.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceMenuRole.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceMenuRolePriv.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceUser.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/LinkisUser.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/Sidebar.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/SidebarContent.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/StaffInfo.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/WorkSpaceUserAndRole.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/HomepageDemoInstanceVo.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/HomepageDemoMenuVo.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/HomepageVideoVo.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/OnestopMenuAppInstanceVo.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/OnestopMenuVo.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/WorkspaceDepartmentVo.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/WorkspaceFavoriteVo.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/AbstractDSSVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSDatasourceVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSDictionaryRequestVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSPersonalWorkflowVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSProjectUserVo.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSPublicTableVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSScheduledWorkFlow.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSScheduledWorkFlowVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkflowVersionVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceComponentPrivVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceHomePageVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceHomepageSettingVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceMenuPrivVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceMenuPrivsVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceMenuVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceOverviewVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspacePrivVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceRoleVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceScriptisStatiticVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceStatisticVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceUserVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DepartmentVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/SecondaryWorkspaceMenuVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/SidebarContentVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/SidebarVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/StaffInfoVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/VOUtils.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/AbstractWorkspaceComponentInfoVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/DSSWorkspaceScriptisInfoVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/DSSWorkspaceVisualisInfoVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/DSSWorkspaceWorkflowInfoVO.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/constant/ApplicationConf.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSApplicationMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSComponentRoleMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSDictionaryMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSMenuRoleMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSUserMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceHomepageMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceInfoMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceMenuMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspacePrivMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceProjectMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceRoleMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceUserMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/LinkisUserMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/SidebarContentMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/SidebarMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/WorkspaceMapper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSComponentRoleMapper.xml create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSMenuRoleMapper.xml create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSWorkspaceHomepageMapper.xml create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSWorkspaceMapper.xml create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSWorkspaceUserMapper.xml create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/WorkspaceMapper.xml create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/exception/DSSWorkspaceDuplicateNameException.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/exception/DSSWorkspaceLoginFailException.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSDictionaryRestful.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSSideInfoRestful.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspacePrivRestful.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceRestful.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceRoleRestful.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceUserRestful.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/WorkspaceRestfulApi.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSDictionaryService.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSSideInfoService.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSUserService.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceMenuService.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspacePrivService.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceRoleService.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceService.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceUserService.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/StaffInfoGetter.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSDictionaryServiceImpl.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSSideInfoServiceImpl.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSUserServiceImpl.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceMenuServiceImpl.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspacePrivServiceImpl.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceRoleServiceImpl.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceServiceImpl.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceUserServiceImpl.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DefaultStaffInfoGetter.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/ApplicationUtils.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/CommonRoleEnum.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/DSSDictionaryConstant.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/DSSWorkspaceConstant.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/RestfulUtils.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/RestulHelper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/WorkspaceDBHelper.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/WorkspaceServerConstant.java create mode 100644 dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/WorkspaceSpringConfig.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/pom.xml create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/ConversionDSSOrchestratorPlugin.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/ExportDSSOrchestratorPlugin.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/ImportDSSOrchestratorPlugin.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/conf/DSSOrchestratorConf.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/impl/ConversionDSSOrchestratorPluginImpl.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/impl/ExportDSSOrchestratorPluginImpl.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/impl/ImportDSSOrchestratorPluginImpl.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/export/MetaExportService.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/export/MetaWriter.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/export/impl/MetaExportServiceImpl.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/input/MetaInputService.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/input/MetaReader.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/input/impl/MetaInputServiceImpl.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/job/ConversionJobEntity.java create mode 100644 dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/job/OrchestratorConversionJob.java create mode 100644 dss-framework/pom.xml diff --git a/dss-framework/dss-appconn-framework/pom.xml b/dss-framework/dss-appconn-framework/pom.xml new file mode 100644 index 0000000000..2ab3817824 --- /dev/null +++ b/dss-framework/dss-appconn-framework/pom.xml @@ -0,0 +1,127 @@ + + + + + + dss + com.webank.wedatasphere.dss + 1.0.0 + + + 4.0.0 + + dss-appconn-framework + + + + junit + junit + 4.12 + test + + + + + com.webank.wedatasphere.linkis + linkis-mybatis + ${linkis.version} + provided + + + + com.webank.wedatasphere.dss + dss-appconn-manager-core + ${dss.version} + + + com.webank.wedatasphere.dss + dss-common + ${dss.version} + provided + + + com.webank.wedatasphere.linkis + linkis-rpc + ${linkis.version} + provided + + + linkis-common + com.webank.wedatasphere.linkis + + + + + com.webank.wedatasphere.linkis + linkis-bml-client + ${linkis.version} + + + commons-beanutils + commons-beanutils + + + linkis-common + com.webank.wedatasphere.linkis + + + json4s-jackson_2.11 + org.json4s + + + + + jakarta.annotation + jakarta.annotation-api + 1.3.5 + provided + + + + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + + + net.alchim31.maven + scala-maven-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + + + src/main/java + + **/*.xml + + + + + + + \ No newline at end of file diff --git a/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/SpringAppConnManager.java b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/SpringAppConnManager.java new file mode 100644 index 0000000000..0a68dbc5d6 --- /dev/null +++ b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/SpringAppConnManager.java @@ -0,0 +1,36 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.appconn; + +import com.webank.wedatasphere.dss.appconn.manager.impl.AbstractAppConnManager; +import com.webank.wedatasphere.dss.appconn.manager.service.AppConnInfoService; +import com.webank.wedatasphere.dss.appconn.manager.service.AppConnResourceService; +import com.webank.wedatasphere.linkis.DataWorkCloudApplication; + + +public class SpringAppConnManager extends AbstractAppConnManager { + + @Override + protected AppConnInfoService createAppConnInfoService() { + return DataWorkCloudApplication.getApplicationContext().getBean(AppConnInfoService.class); + } + + @Override + protected AppConnResourceService createAppConnResourceService() { + return DataWorkCloudApplication.getApplicationContext().getBean(AppConnResourceService.class); + } +} diff --git a/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/AppConnMapper.java b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/AppConnMapper.java new file mode 100644 index 0000000000..7eaa59040e --- /dev/null +++ b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/AppConnMapper.java @@ -0,0 +1,52 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.appconn.dao; + + +import com.webank.wedatasphere.dss.framework.appconn.entity.AppConnBean; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +@Mapper +public interface AppConnMapper { + + /** + * get all appconnbeans + * */ + List getAllAppConnBeans(); + + /** + * get all appconns' name + * */ + List getAllAppConnsName(); + + /** + * get appconnbeans by name + * */ + AppConnBean getAppConnBeanByName(@Param("appConnName") String appConnName); + + /** + * get appconn by id + * */ + AppConnBean getAppConnBeanById(@Param("appConnId") Long appConnId); + + void updateResourceByName(AppConnBean appConnBean); + +} \ No newline at end of file diff --git a/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/AppInstanceMapper.java b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/AppInstanceMapper.java new file mode 100644 index 0000000000..7015067016 --- /dev/null +++ b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/AppInstanceMapper.java @@ -0,0 +1,40 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.appconn.dao; + + +import com.webank.wedatasphere.dss.framework.appconn.entity.AppInstanceBean; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +@Mapper +public interface AppInstanceMapper { + + /** + * get instance by appconnid + * */ + List getAppInstancesByAppConnId(@Param("appConnId") Long appConnId); + + /** + * get instance by appconnid and label + * */ + List getAppInstance(@Param("appConnId") Long appConnId, + @Param("label") String label); +} diff --git a/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/impl/appConnMapper.xml b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/impl/appConnMapper.xml new file mode 100644 index 0000000000..1e0a308978 --- /dev/null +++ b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/impl/appConnMapper.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + `appconn_name`, `is_user_need_init`, `level`, `if_iframe`, `is_external`, + `reference`, `class_name`, `appconn_class_path`,`resource` + + + + `id`, `appconn_name`, `is_user_need_init`, `level`, `if_iframe`, `is_external`, + `reference`, `class_name`, `appconn_class_path`, `resource` + + + + + + + + + + + + update `dss_appconn` + + resource=#{resource}, + appconn_class_path=#{appConnClassPath}, + + where appconn_name=#{appConnName} + + \ No newline at end of file diff --git a/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/impl/appInstanceMapper.xml b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/impl/appInstanceMapper.xml new file mode 100644 index 0000000000..f1cd23c2ff --- /dev/null +++ b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/dao/impl/appInstanceMapper.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + `id`, `appconn_id`, `label`, `url`, `enhance_json`, `homepage_url`, `redirect_url` + + + + + + \ No newline at end of file diff --git a/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/entity/AppConnBean.java b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/entity/AppConnBean.java new file mode 100644 index 0000000000..9e63c8a2b2 --- /dev/null +++ b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/entity/AppConnBean.java @@ -0,0 +1,155 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.appconn.entity; + +import com.webank.wedatasphere.dss.appconn.manager.entity.AppConnInfo; +import com.webank.wedatasphere.dss.common.entity.Resource; +import java.io.Serializable; +import java.util.List; + + + +public class AppConnBean implements AppConnInfo, Serializable { + + private static final long serialVersionUID=1L; + private Long id; + private String appConnName; + private String isUserNeedInit; + private String level; + private Boolean ifIframe; + private Boolean isExternal; + + // todo:目前通过这两个字段在classpath下加载类。 + // todo:未来这两个字段的作用是在bml和默认应用的。 + private String reference; + private String resource; + private Resource resourceObj; + private String className; + private String appConnClassPath; + + private List appInstanceBeans; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @Override + public String getAppConnName() { + return appConnName; + } + + public void setAppConnName(String appConnName) { + this.appConnName = appConnName; + } + + public String getIsUserNeedInit() { + return isUserNeedInit; + } + + public void setIsUserNeedInit(String isUserNeedInit) { + this.isUserNeedInit = isUserNeedInit; + } + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + public Boolean getIfIframe() { + return ifIframe; + } + + public void setIfIframe(Boolean ifIframe) { + this.ifIframe = ifIframe; + } + + public Boolean getExternal() { + return isExternal; + } + + public void setExternal(Boolean external) { + isExternal = external; + } + + public String getReference() { + return reference; + } + + public void setReference(String reference) { + this.reference = reference; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public List getAppInstanceBeans() { + return appInstanceBeans; + } + + public void setAppInstanceBeans(List appInstanceBeans) { + this.appInstanceBeans = appInstanceBeans; + } + + @Override + public String getClassName() { + return className; + } + + @Override + public Resource getAppConnResource() { + return resourceObj; + } + + public void setAppConnResource(Resource resource) { + resourceObj = resource; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getAppConnClassPath() { + return appConnClassPath; + } + + public void setAppConnClassPath(String appConnClassPath) { + this.appConnClassPath = appConnClassPath; + } + + @Override + public String toString() { + return "AppConnBean{" + + "id=" + id + + ", appConnName='" + appConnName + '\'' + + ", className='" + className + '\'' + + ", appConnClassPath='" + appConnClassPath + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/entity/AppConnResource.java b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/entity/AppConnResource.java new file mode 100644 index 0000000000..a698e6bc8b --- /dev/null +++ b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/entity/AppConnResource.java @@ -0,0 +1,51 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.appconn.entity; + +import com.webank.wedatasphere.dss.common.entity.Resource; + + +public class AppConnResource { + + private Resource resource; + private long lastModifiedTime; + private long size; + + public Resource getResource() { + return resource; + } + + public void setResource(Resource resource) { + this.resource = resource; + } + + public long getLastModifiedTime() { + return lastModifiedTime; + } + + public void setLastModifiedTime(long lastModifiedTime) { + this.lastModifiedTime = lastModifiedTime; + } + + public long getSize() { + return size; + } + + public void setSize(long size) { + this.size = size; + } +} diff --git a/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/entity/AppInstanceBean.java b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/entity/AppInstanceBean.java new file mode 100644 index 0000000000..1914a0a29b --- /dev/null +++ b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/entity/AppInstanceBean.java @@ -0,0 +1,110 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.appconn.entity; + +import com.webank.wedatasphere.dss.appconn.manager.entity.AppInstanceInfo; +import java.io.Serializable; + + +public class AppInstanceBean implements AppInstanceInfo, Serializable { + + private static final long serialVersionUID=1L; + + private Long id; + private Long appConnId; + private String label; + private String url; + private String enhanceJson; + private String homepageUrl; + private String redirectUrl; + + @Override + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getAppconnId() { + return appConnId; + } + + public void setAppConnId(Long appConnId) { + this.appConnId = appConnId; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + @Override + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + @Override + public String getEnhanceJson() { + return enhanceJson; + } + + public void setEnhanceJson(String enhanceJson) { + this.enhanceJson = enhanceJson; + } + + @Override + public String getHomepageUrl() { + return homepageUrl; + } + + public void setHomepageUrl(String homepageUrl) { + this.homepageUrl = homepageUrl; + } + + @Override + public String getRedirectUrl() { + return redirectUrl; + } + + @Override + public String getLabels() { + return label; + } + + public void setRedirectUrl(String redirectUrl) { + this.redirectUrl = redirectUrl; + } + + @Override + public String toString() { + return "AppInstanceBean{" + + "id=" + id + + ", appConnId=" + appConnId + + ", label='" + label + '\'' + + ", url='" + url + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/exception/AppConnNotExistsErrorException.java b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/exception/AppConnNotExistsErrorException.java new file mode 100644 index 0000000000..d73dfcb3ca --- /dev/null +++ b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/exception/AppConnNotExistsErrorException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.appconn.exception; + +import com.webank.wedatasphere.dss.common.exception.DSSErrorException; + + +public class AppConnNotExistsErrorException extends DSSErrorException { + + public AppConnNotExistsErrorException(int errCode, String desc) { + super(errCode, desc); + } + + public AppConnNotExistsErrorException(int errCode, String desc, Throwable cause) { + super(errCode, desc); + initCause(cause); + } +} diff --git a/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/restful/AppConnManagerRestfulApi.java b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/restful/AppConnManagerRestfulApi.java new file mode 100644 index 0000000000..e9aabdb319 --- /dev/null +++ b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/restful/AppConnManagerRestfulApi.java @@ -0,0 +1,106 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.appconn.restful; + +import com.webank.wedatasphere.dss.appconn.manager.entity.AppConnInfo; +import com.webank.wedatasphere.dss.appconn.manager.entity.AppInstanceInfo; +import com.webank.wedatasphere.dss.appconn.manager.service.AppConnInfoService; +import com.webank.wedatasphere.dss.common.utils.DSSExceptionUtils; +import com.webank.wedatasphere.dss.framework.appconn.service.AppConnResourceUploadService; +import com.webank.wedatasphere.linkis.server.Message; +import java.util.List; +import javax.annotation.PostConstruct; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +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; +import org.apache.commons.lang.exception.ExceptionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +@Component +@Path("/dss/framework/project/appconn") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class AppConnManagerRestfulApi { + + private static final Logger LOGGER = LoggerFactory.getLogger(AppConnManagerRestfulApi.class); + + @Autowired + private AppConnInfoService appConnInfoService; + @Autowired + private AppConnResourceUploadService appConnResourceUploadService; + + @PostConstruct + public void init() { + LOGGER.info("Try to scan AppConn plugins..."); + appConnInfoService.getAppConnInfos().forEach(DSSExceptionUtils.handling(appConnInfo -> { + LOGGER.info("Try to load or update AppConn {}.", appConnInfo.getAppConnName()); + appConnResourceUploadService.upload(appConnInfo.getAppConnName()); + })); + LOGGER.info("All AppConn plugins has scanned."); + } + + @GET + @Path("listAppConnInfos") + public Response listAppConnInfos() { + List appConnInfos = appConnInfoService.getAppConnInfos(); + Message message = Message.ok("Get AppConnInfo list succeed."); + message.data("appConnInfos", appConnInfos); + return Message.messageToResponse(message); + } + + @GET + @Path("{appConnName}/get") + public Response get(@PathParam("appConnName") String appConnName) { + AppConnInfo appConnInfo = appConnInfoService.getAppConnInfo(appConnName); + Message message = Message.ok("Get AppConnInfo succeed."); + message.data("appConnInfo", appConnInfo); + return Message.messageToResponse(message); + } + + @GET + @Path("/{appConnName}/getAppInstances") + public Response getAppInstancesByAppConnInfo(@PathParam("appConnName") String appConnName) { + List appInstanceInfos = appConnInfoService.getAppInstancesByAppConnName(appConnName); + Message message = Message.ok("Get AppInstance list succeed."); + message.data("appInstanceInfos", appInstanceInfos); + return Message.messageToResponse(message); + } + + @GET + @Path("/{appConnName}/load") + public Response load(@PathParam("appConnName") String appConnName) { + LOGGER.info("Try to load a new AppConn {}.", appConnName); + try { + appConnResourceUploadService.upload(appConnName); + } catch (Exception e) { + LOGGER.error("Load AppConn " + appConnName + " failed.", e); + Message message = Message.error("Load AppConn " + appConnName + " failed. Reason: " + ExceptionUtils.getRootCauseMessage(e)); + return Message.messageToResponse(message); + } + Message message = Message.ok("Load AppConn " + appConnName + " succeed."); + return Message.messageToResponse(message); + } + +} diff --git a/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/service/AppConnResourceUploadService.java b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/service/AppConnResourceUploadService.java new file mode 100644 index 0000000000..f97951b77d --- /dev/null +++ b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/service/AppConnResourceUploadService.java @@ -0,0 +1,26 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.appconn.service; + +import com.webank.wedatasphere.dss.common.exception.DSSErrorException; + + +public interface AppConnResourceUploadService { + + void upload(String appConnName) throws DSSErrorException; + +} diff --git a/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/service/impl/AppConnInfoServiceImpl.java b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/service/impl/AppConnInfoServiceImpl.java new file mode 100644 index 0000000000..c150791782 --- /dev/null +++ b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/service/impl/AppConnInfoServiceImpl.java @@ -0,0 +1,69 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.appconn.service.impl; + +import com.webank.wedatasphere.dss.appconn.manager.entity.AppConnInfo; +import com.webank.wedatasphere.dss.appconn.manager.entity.AppInstanceInfo; +import com.webank.wedatasphere.dss.appconn.manager.service.AppConnInfoService; +import com.webank.wedatasphere.dss.framework.appconn.dao.AppConnMapper; +import com.webank.wedatasphere.dss.framework.appconn.dao.AppInstanceMapper; +import com.webank.wedatasphere.dss.framework.appconn.entity.AppConnBean; +import com.webank.wedatasphere.dss.framework.appconn.utils.AppConnServiceUtils; +import java.util.List; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +@Component +public class AppConnInfoServiceImpl implements AppConnInfoService { + + @Autowired + private AppConnMapper appConnMapper; + + @Autowired + private AppInstanceMapper appInstanceMapper; + + @Override + public List getAppConnInfos() { + List appConnBeans = appConnMapper.getAllAppConnBeans(); + appConnBeans.forEach(appConnBean -> { + String resource = appConnBean.getResource(); + if(StringUtils.isNotBlank(resource)) { + appConnBean.setAppConnResource(AppConnServiceUtils.stringToResource(resource).getResource()); + } + }); + return appConnBeans; + } + + @Override + public AppConnInfo getAppConnInfo(String appConnName) { + return appConnMapper.getAppConnBeanByName(appConnName); + } + + @Override + public List getAppInstancesByAppConnInfo(AppConnInfo appConnInfo) { + Long id = ((AppConnBean) appConnInfo).getId(); + return appInstanceMapper.getAppInstancesByAppConnId(id); + } + + @Override + public List getAppInstancesByAppConnName(String appConnName) { + AppConnBean appConnBean = appConnMapper.getAppConnBeanByName(appConnName); + return getAppInstancesByAppConnInfo(appConnBean); + } +} diff --git a/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/service/impl/AppConnResourceServiceImpl.java b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/service/impl/AppConnResourceServiceImpl.java new file mode 100644 index 0000000000..2d8ff0d5b2 --- /dev/null +++ b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/service/impl/AppConnResourceServiceImpl.java @@ -0,0 +1,173 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.appconn.service.impl; + +import com.webank.wedatasphere.dss.appconn.loader.utils.AppConnUtils; +import com.webank.wedatasphere.dss.appconn.manager.AppConnManager; +import com.webank.wedatasphere.dss.appconn.manager.entity.AppConnInfo; +import com.webank.wedatasphere.dss.appconn.manager.impl.AbstractAppConnManager; +import com.webank.wedatasphere.dss.appconn.manager.service.AppConnResourceService; +import com.webank.wedatasphere.dss.appconn.manager.utils.AppConnIndexFileUtils; +import com.webank.wedatasphere.dss.common.entity.Resource; +import com.webank.wedatasphere.dss.common.exception.DSSErrorException; +import com.webank.wedatasphere.dss.common.utils.ZipHelper; +import com.webank.wedatasphere.dss.framework.appconn.dao.AppConnMapper; +import com.webank.wedatasphere.dss.framework.appconn.entity.AppConnBean; +import com.webank.wedatasphere.dss.framework.appconn.entity.AppConnResource; +import com.webank.wedatasphere.dss.framework.appconn.exception.AppConnNotExistsErrorException; +import com.webank.wedatasphere.dss.framework.appconn.service.AppConnResourceUploadService; +import com.webank.wedatasphere.dss.framework.appconn.utils.AppConnServiceUtils; +import com.webank.wedatasphere.linkis.bml.client.BmlClient; +import com.webank.wedatasphere.linkis.bml.client.BmlClientFactory; +import com.webank.wedatasphere.linkis.bml.protocol.BmlUpdateResponse; +import com.webank.wedatasphere.linkis.bml.protocol.BmlUploadResponse; +import com.webank.wedatasphere.linkis.common.utils.Utils; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +@Component +public class AppConnResourceServiceImpl implements AppConnResourceService, AppConnResourceUploadService { + + private Logger LOGGER = LoggerFactory.getLogger(AppConnResourceServiceImpl.class); + private static final String LIB_NAME = "/lib"; + + @Autowired + private AppConnMapper appConnMapper; + private BmlClient bmlClient; + + @PostConstruct + public void init() { + bmlClient = BmlClientFactory.createBmlClient(); + } + + @Override + public String getAppConnHome(AppConnInfo appConnInfo) { + AppConnBean appConnBean = (AppConnBean) appConnInfo; + String appConnHome=appConnBean.getAppConnClassPath(); + if(appConnHome.endsWith(LIB_NAME)){ + appConnHome =appConnHome.substring(0,appConnHome.lastIndexOf(LIB_NAME)); + } + return appConnHome; + } + + @Override + public void upload(String appConnName) throws DSSErrorException { + File appConnPath = new File(AppConnUtils.getAppConnHomePath(), appConnName); + if (!appConnPath.exists()) { + throw new AppConnNotExistsErrorException(20350, "AppConn home path " + appConnPath.getPath() + " not exists."); + } else if (!appConnPath.isDirectory()) { + throw new AppConnNotExistsErrorException(20350, "AppConn home path " + appConnPath.getPath() + " is not a directory."); + } + File zipFile = new File(appConnPath.getPath() + ".zip"); + if (zipFile.exists() && !zipFile.delete()) { + throw new AppConnNotExistsErrorException(20001, "No permission to delete old zip file " + zipFile); + } + ZipHelper.zip(appConnPath.getPath(), false); +// TODO ZipUtils.fileToZip(appConnPath.getPath(), AppConnUtils.getAppConnHomePath(), appConnName + ".zip"); + AppConnBean appConnBean = appConnMapper.getAppConnBeanByName(appConnName); + AppConnResource appConnResource; + File indexFile = null; + if (appConnBean == null) { + throw new AppConnNotExistsErrorException(20350, "AppConn not exists in DB, please update db at first."); + } else if (StringUtils.isNotBlank(appConnBean.getResource())) { + // If resource is exists, then indexFile is also exists. + appConnResource = AppConnServiceUtils.stringToResource(appConnBean.getResource()); + indexFile = AppConnIndexFileUtils.getIndexFile(appConnPath); + if (appConnPath.lastModified() == appConnResource.getLastModifiedTime() + && zipFile.length() == appConnResource.getSize() && AppConnIndexFileUtils.isLatestIndex(appConnPath, appConnResource.getResource())) { + LOGGER.info("No necessary to update the AppConn {}, since it's packages has no changes in path {}.", appConnName, appConnPath.getPath()); + return; + } + } else { + // If resource is not exists, this is the first time to upload this AppConn. + appConnResource = new AppConnResource(); + } + // At first, upload appConn file to BML + Resource resource = new Resource(); + InputStream inputStream = null; + if (appConnResource.getResource() != null) { + try { + inputStream = new FileInputStream(zipFile.getPath()); + + BmlUpdateResponse response = bmlClient.updateResource(Utils.getJvmUser(), appConnResource.getResource().getResourceId(), zipFile.getPath(),inputStream); + resource.setResourceId(appConnResource.getResource().getResourceId()); + resource.setVersion(response.version()); + } catch (FileNotFoundException e) { + throw new AppConnNotExistsErrorException(20351, "AppConn update to bml failed"+e.getMessage()); + } finally { + IOUtils.closeQuietly(inputStream); + } + } else { + + try { + inputStream = new FileInputStream(zipFile.getPath()); + BmlUploadResponse response = bmlClient.uploadResource(Utils.getJvmUser(), zipFile.getPath(), inputStream); + resource.setResourceId(response.resourceId()); + resource.setVersion(response.version()); + } catch (FileNotFoundException e) { + throw new AppConnNotExistsErrorException(20352, "AppConn update to bml failed"+e.getMessage()); + } finally { + IOUtils.closeQuietly(inputStream); + } + + } + resource.setFileName(zipFile.getName()); + // Then, insert into db. + appConnResource.setLastModifiedTime(appConnPath.lastModified()); + appConnResource.setSize(zipFile.length()); + appConnResource.setResource(resource); + String resourceStr = AppConnServiceUtils.resourceToString(appConnResource); + + AppConnBean appConnBeanReLoad = new AppConnBean(); + appConnBeanReLoad.setId(appConnBean.getId()); + appConnBeanReLoad.setResource(resourceStr); + appConnBeanReLoad.setAppConnName(appConnName); + appConnBeanReLoad.setAppConnClassPath(appConnPath.getPath()); + appConnBeanReLoad.setClassName(appConnBean.getClassName()); + appConnMapper.updateResourceByName(appConnBeanReLoad); + // update index file. + if (indexFile != null && !indexFile.delete()) { + throw new AppConnNotExistsErrorException(20350, "Delete index file " + indexFile.getName() + " failed, please ensure the permission is all right."); + } + indexFile = new File(appConnPath, AppConnIndexFileUtils.getIndexFileName(resource)); + try { + indexFile.createNewFile(); + } catch (IOException e) { + throw new AppConnNotExistsErrorException(20350, "create index file " + indexFile.getName() + " failed, please ensure the permission is all right.", e); + } + // Finally, reload this AppConn. + ((AbstractAppConnManager) AppConnManager.getAppConnManager()).reloadAppConn(appConnBeanReLoad); + LOGGER.info("AppConn {} has updated resource to {}.", appConnName, resourceStr); + } + + @PreDestroy + public void destory() { + IOUtils.closeQuietly(bmlClient); + } +} diff --git a/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/utils/AppConnServiceUtils.java b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/utils/AppConnServiceUtils.java new file mode 100644 index 0000000000..11d851cd8c --- /dev/null +++ b/dss-framework/dss-appconn-framework/src/main/java/com/webank/wedatasphere/dss/framework/appconn/utils/AppConnServiceUtils.java @@ -0,0 +1,33 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.appconn.utils; + +import com.webank.wedatasphere.dss.common.utils.DSSCommonUtils; +import com.webank.wedatasphere.dss.framework.appconn.entity.AppConnResource; + + +public class AppConnServiceUtils { + + public static String resourceToString(AppConnResource resource) { + return DSSCommonUtils.COMMON_GSON.toJson(resource); + } + + public static AppConnResource stringToResource(String resource) { + return DSSCommonUtils.COMMON_GSON.fromJson(resource, AppConnResource.class); + } + +} diff --git a/dss-framework/dss-framework-common/pom.xml b/dss-framework/dss-framework-common/pom.xml new file mode 100644 index 0000000000..05aac9fe15 --- /dev/null +++ b/dss-framework/dss-framework-common/pom.xml @@ -0,0 +1,115 @@ + + + + + + dss + com.webank.wedatasphere.dss + 1.0.0 + + + 4.0.0 + dss-framework-common + + + + com.webank.wedatasphere.linkis + linkis-module + ${linkis.version} + provided + + + org.springframework.cloud + spring-cloud-netflix + + + spring-cloud-starter-netflix-eureka-client + org.springframework.cloud + + + + + org.apache.commons + commons-math3 + provided + + + xstream + com.thoughtworks.xstream + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + ${spring.cloud.version} + provided + + + logback-classic + ch.qos.logback + + + log4j-to-slf4j + org.apache.logging.log4j + + + gson + com.google.code.gson + + + jsr311-api + javax.ws.rs + + + xstream + com.thoughtworks.xstream + + + commons-math + org.apache.commons + + + jackson-core + com.fasterxml.jackson.core + + + spring-boot-autoconfigure + org.springframework.boot + + + spring-boot-starter-aop + org.springframework.boot + + + spring-boot-starter + org.springframework.boot + + + spring-boot-starter-cache + org.springframework.boot + + + + + com.webank.wedatasphere.linkis + linkis-mybatis + ${linkis.version} + provided + + + \ No newline at end of file diff --git a/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/DSSFrameworkErrorException.java b/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/DSSFrameworkErrorException.java new file mode 100644 index 0000000000..2a0e291333 --- /dev/null +++ b/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/DSSFrameworkErrorException.java @@ -0,0 +1,39 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.common.exception; + +import com.webank.wedatasphere.linkis.common.exception.ErrorException; + + +public class DSSFrameworkErrorException extends ErrorException { + + public DSSFrameworkErrorException(int errorCode, String errorDesc){ + super(errorCode, errorDesc); + } + + public static void dealErrorException(int errorCode, String errorDesc, Throwable t) throws DSSFrameworkErrorException{ + DSSFrameworkErrorException dssFrameworkErrorException = new DSSFrameworkErrorException(errorCode, errorDesc); + dssFrameworkErrorException.initCause(t); + throw dssFrameworkErrorException; + } + + public static void dealErrorException(int errorCode, String errorDesc) throws DSSFrameworkErrorException{ + throw new DSSFrameworkErrorException(errorCode, errorDesc); + } + + +} diff --git a/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/DSSFrameworkRuntimeException.java b/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/DSSFrameworkRuntimeException.java new file mode 100644 index 0000000000..1e1df42ebd --- /dev/null +++ b/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/DSSFrameworkRuntimeException.java @@ -0,0 +1,27 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.common.exception; + +import com.webank.wedatasphere.linkis.common.exception.WarnException; + + +public class DSSFrameworkRuntimeException extends WarnException { + + public DSSFrameworkRuntimeException(String msg){ + super(100000, msg); + } +} diff --git a/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/DSSFrameworkWarnException.java b/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/DSSFrameworkWarnException.java new file mode 100644 index 0000000000..b41db5bc9e --- /dev/null +++ b/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/DSSFrameworkWarnException.java @@ -0,0 +1,33 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.common.exception; + +import com.webank.wedatasphere.linkis.common.exception.WarnException; + + +public class DSSFrameworkWarnException extends WarnException { + public DSSFrameworkWarnException(int errorCode, String errorDesc){ + super(errorCode, errorDesc); + } + + public static void dealWarnException(int errorCode, String errorDesc, Throwable t) throws DSSFrameworkWarnException { + DSSFrameworkWarnException dssFrameworkWarnException = new DSSFrameworkWarnException(errorCode, errorDesc); + dssFrameworkWarnException.initCause(t); + throw dssFrameworkWarnException; + } + +} diff --git a/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/ThrowingConsumer.java b/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/ThrowingConsumer.java new file mode 100644 index 0000000000..56cf17087b --- /dev/null +++ b/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/ThrowingConsumer.java @@ -0,0 +1,23 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.common.exception; + + +@FunctionalInterface +public interface ThrowingConsumer { + void accept(T t) throws E; +} diff --git a/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/ThrowingFunction.java b/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/ThrowingFunction.java new file mode 100644 index 0000000000..54e1f3b379 --- /dev/null +++ b/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/exception/ThrowingFunction.java @@ -0,0 +1,23 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.common.exception; + + +@FunctionalInterface +public interface ThrowingFunction { + R accept(T t) throws E; +} diff --git a/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/utils/DSSFrameworkExceptionUtils.java b/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/utils/DSSFrameworkExceptionUtils.java new file mode 100644 index 0000000000..24b8468930 --- /dev/null +++ b/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/utils/DSSFrameworkExceptionUtils.java @@ -0,0 +1,57 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.common.utils; + + +import com.webank.wedatasphere.dss.framework.common.exception.DSSFrameworkRuntimeException; +import com.webank.wedatasphere.dss.framework.common.exception.ThrowingConsumer; +import com.webank.wedatasphere.dss.framework.common.exception.ThrowingFunction; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.function.Consumer; +import java.util.function.Function; + + +public class DSSFrameworkExceptionUtils { + + private static final Logger LOGGER = LoggerFactory.getLogger(DSSFrameworkExceptionUtils.class); + + public static Consumer handling( + ThrowingConsumer throwingConsumer) { + return i -> { + try { + throwingConsumer.accept(i); + } catch (Exception e) { + LOGGER.error("execute failed,reason:",e); + throw new DSSFrameworkRuntimeException(e.getMessage()); + } + }; + } + + public static Function map( + ThrowingFunction throwingFunction) { + return i -> { + try { + return throwingFunction.accept(i); + } catch (Exception e) { + LOGGER.error("execute failed,reason:",e); + throw new DSSFrameworkRuntimeException(e.getMessage()); + } + }; + } +} diff --git a/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/utils/RestfulUtils.java b/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/utils/RestfulUtils.java new file mode 100644 index 0000000000..5e9b7d185f --- /dev/null +++ b/dss-framework/dss-framework-common/src/main/java/com/webank/wedatasphere/dss/framework/common/utils/RestfulUtils.java @@ -0,0 +1,48 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.common.utils; + +import com.webank.wedatasphere.linkis.server.Message; +import org.apache.commons.math3.util.Pair; + +import javax.ws.rs.core.Response; +import java.util.Arrays; + + +public class RestfulUtils { + + + public static Response dealError(String reason){ + Message message = Message.error(reason); + return Message.messageToResponse(message); + } + + public static Response dealOk(String msg){ + Message message = Message.ok(msg); + return Message.messageToResponse(message); + } + + + + @SafeVarargs + public static Response dealOk(String msg, Pair... data){ + Message message = Message.ok(msg); + Arrays.stream(data).forEach(p -> message.data(p.getKey(), p.getValue())); + return Message.messageToResponse(message); + } + +} diff --git a/dss-framework/dss-framework-orchestrator-server/bin/start-dss-framework-orchestrator-server.sh b/dss-framework/dss-framework-orchestrator-server/bin/start-dss-framework-orchestrator-server.sh new file mode 100644 index 0000000000..7e592a27a6 --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/bin/start-dss-framework-orchestrator-server.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +cd `dirname $0` +cd .. +HOME=`pwd` +export DWS_ENGINE_MANAGER_HOME=$HOME + +export DWS_ENGINE_MANAGER_PID=$HOME/bin/linkis.pid + +if [[ -f "${DWS_ENGINE_MANAGER_PID}" ]]; then + pid=$(cat ${DWS_ENGINE_MANAGER_PID}) + if kill -0 ${pid} >/dev/null 2>&1; then + echo "DSS SERVER is already running." + return 0; + fi +fi + +export DWS_ENGINE_MANAGER_LOG_PATH=$HOME/logs +export DWS_ENGINE_MANAGER_HEAP_SIZE="1G" + +export DWS_ENGINE_MANAGER_JAVA_OPTS="-Xms$DWS_ENGINE_MANAGER_HEAP_SIZE -Xmx$DWS_ENGINE_MANAGER_HEAP_SIZE -XX:+UseG1GC -XX:MaxPermSize=500m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=20012" + +#export DWS_ENGINE_MANAGER_JAVA_OPTS="-Xms$DWS_ENGINE_MANAGER_HEAP_SIZE -Xmx$DWS_ENGINE_MANAGER_HEAP_SIZE -XX:+UseG1GC -XX:MaxPermSize=500m" + +nohup java $DWS_ENGINE_MANAGER_JAVA_OPTS -cp $HOME/conf:$HOME/lib/* com.webank.wedatasphere.linkis.DataWorkCloudApplication 2>&1 > $DWS_ENGINE_MANAGER_LOG_PATH/linkis.out & +pid=$! +if [[ -z "${pid}" ]]; then + echo "DSS SERVER start failed!" + sleep 1 + exit 1 +else + echo "DSS SERVER start succeeded!" + echo $pid > $DWS_ENGINE_MANAGER_PID + sleep 1 +fi +exit 1 \ No newline at end of file diff --git a/dss-framework/dss-framework-orchestrator-server/bin/stop-dss-framework-orchestrator-server.sh b/dss-framework/dss-framework-orchestrator-server/bin/stop-dss-framework-orchestrator-server.sh new file mode 100644 index 0000000000..2ca464de62 --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/bin/stop-dss-framework-orchestrator-server.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +cd `dirname $0` +cd .. +HOME=`pwd` + +export FLOW_ENTRANCE_HOME_PID=$HOME/bin/linkis.pid + +function wait_for_FLOW_ENTRANCE_HOME_to_die() { + local pid + local count + pid=$1 + timeout=$2 + count=0 + timeoutTime=$(date "+%s") + let "timeoutTime+=$timeout" + currentTime=$(date "+%s") + forceKill=1 + + while [[ $currentTime -lt $timeoutTime ]]; do + $(kill ${pid} > /dev/null 2> /dev/null) + if kill -0 ${pid} > /dev/null 2>&1; then + sleep 3 + else + forceKill=0 + break + fi + currentTime=$(date "+%s") + done + + if [[ forceKill -ne 0 ]]; then + $(kill -9 ${pid} > /dev/null 2> /dev/null) + fi +} + +if [[ ! -f "${FLOW_ENTRANCE_HOME_PID}" ]]; then + echo "DSS SERVER is not running" +else + pid=$(cat ${FLOW_ENTRANCE_HOME_PID}) + if [[ -z "${pid}" ]]; then + echo "DSS SERVER is not running" + else + wait_for_FLOW_ENTRANCE_HOME_to_die $pid 40 + $(rm -f ${FLOW_ENTRANCE_HOME_PID}) + echo "DSS SERVER is stopped." + fi +fi \ No newline at end of file diff --git a/dss-framework/dss-framework-orchestrator-server/pom.xml b/dss-framework/dss-framework-orchestrator-server/pom.xml new file mode 100644 index 0000000000..d847d188d9 --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/pom.xml @@ -0,0 +1,187 @@ + + + + + + dss + com.webank.wedatasphere.dss + 1.0.0 + + + 4.0.0 + + dss-framework-orchestrator-server + + + + com.webank.wedatasphere.dss + dss-framework-common + ${dss.version} + + + com.webank.wedatasphere.dss + dss-orchestrator-core + ${dss.version} + + + commons-beanutils + commons-beanutils + + + commons-collections + commons-collections + + + + + com.webank.wedatasphere.dss + dss-orchestrator-db + ${dss.version} + + + + com.webank.wedatasphere.dss + dss-orchestrator-loader + ${dss.version} + + + com.webank.wedatasphere.dss + dss-framework-orchestrator-publish + ${dss.version} + + + + com.webank.wedatasphere.linkis + linkis-rpc + ${linkis.version} + provided + + + spring-cloud-starter-netflix-eureka-client + org.springframework.cloud + + + + + + com.webank.wedatasphere.dss + dss-contextservice + ${dss.version} + + + linkis-common + com.webank.wedatasphere.linkis + + + commons-text + org.apache.commons + + + json4s-jackson_2.11 + org.json4s + + + + + + com.webank.wedatasphere.linkis + linkis-mybatis + ${linkis.version} + provided + + + com.webank.wedatasphere.dss + dss-common + ${dss.version} + provided + + + com.webank.wedatasphere.dss + dss-appconn-manager-client + ${dss.version} + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + + + net.alchim31.maven + scala-maven-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.3 + false + + + make-assembly + package + + single + + + + src/main/assembly/distribution.xml + + + + + + false + out + false + false + + src/main/assembly/distribution.xml + + + + + + + src/main/java + + **/*.xml + **/*.properties + **/*.yml + + + + + + + \ No newline at end of file diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/assembly/distribution.xml b/dss-framework/dss-framework-orchestrator-server/src/main/assembly/distribution.xml new file mode 100644 index 0000000000..313ea1281e --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/assembly/distribution.xml @@ -0,0 +1,44 @@ + + + + dss-framework-orchestrator-server + + dir + + true + dss-framework-orchestrator-server + + + + + + lib + true + true + false + true + true + + + + + + + diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/conf/OrchestratorConf.java b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/conf/OrchestratorConf.java new file mode 100644 index 0000000000..4bef87f060 --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/conf/OrchestratorConf.java @@ -0,0 +1,24 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server.conf; + +import com.webank.wedatasphere.linkis.common.conf.CommonVars; + + +public class OrchestratorConf { + public static final CommonVars DSS_UPLOAD_PATH = CommonVars.apply("wds.dss.file.upload.dir", "/appcom/tmp/uploads"); +} diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/conf/OrchestratorSpringConf.java b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/conf/OrchestratorSpringConf.java new file mode 100644 index 0000000000..e2df01daa3 --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/conf/OrchestratorSpringConf.java @@ -0,0 +1,33 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server.conf; + +import com.webank.wedatasphere.dss.contextservice.service.ContextService; +import com.webank.wedatasphere.dss.contextservice.service.impl.ContextServiceImpl; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + + +@Configuration +public class OrchestratorSpringConf { + + @Bean(name = "contextService") + public ContextService createContextService(){ + return ContextServiceImpl.getInstance(); + } + +} diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/constant/DSSOrchestratorConstant.java b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/constant/DSSOrchestratorConstant.java new file mode 100644 index 0000000000..81a5bb06bc --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/constant/DSSOrchestratorConstant.java @@ -0,0 +1,22 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server.constant; + + +public class DSSOrchestratorConstant { + public static final String PUBLISH_FLOW_REPORT_FORMATE = "工作流名:%s,版本号:%s,工作流内容为空,请自行修改或者删除"; +} diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/constant/OrchestratorSpringConfiguration.java b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/constant/OrchestratorSpringConfiguration.java new file mode 100644 index 0000000000..f9176d6c69 --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/constant/OrchestratorSpringConfiguration.java @@ -0,0 +1,34 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server.constant; + +import com.webank.wedatasphere.dss.orchestrator.server.service.OrchestratorPluginService; +import com.webank.wedatasphere.dss.orchestrator.server.service.impl.OrchestratorPluginServiceImpl; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class OrchestratorSpringConfiguration { + + @Bean + @ConditionalOnMissingBean + public OrchestratorPluginService createOrchestratorPluginService() { + return new OrchestratorPluginServiceImpl(); + } + +} \ No newline at end of file diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/entity/UploadFileResponse.java b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/entity/UploadFileResponse.java new file mode 100644 index 0000000000..d1d72a6c1a --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/entity/UploadFileResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server.entity; + +public class UploadFileResponse { + private String fileName; + private String fileDownloadUri; + private String fileType; + private long size; + + public UploadFileResponse(String fileName, String fileDownloadUri, String fileType, long size) { + this.fileName = fileName; + this.fileDownloadUri = fileDownloadUri; + this.fileType = fileType; + this.size = size; + } + // getter and setter ... +} diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/entity/query/QueryOrchestratorVersion.java b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/entity/query/QueryOrchestratorVersion.java new file mode 100644 index 0000000000..110d021e8b --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/entity/query/QueryOrchestratorVersion.java @@ -0,0 +1,35 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server.entity.query; + +import javax.validation.constraints.NotNull; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class QueryOrchestratorVersion { + + @NotNull(message = "orchestratorId不能为空") + private Long orchestratorId; + + public Long getOrchestratorId() { + return orchestratorId; + } + + public void setOrchestratorId(Long orchestratorId) { + this.orchestratorId = orchestratorId; + } +} \ No newline at end of file diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/restful/OrchestratorIERestful.java b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/restful/OrchestratorIERestful.java new file mode 100644 index 0000000000..465c752259 --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/restful/OrchestratorIERestful.java @@ -0,0 +1,181 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server.restful; + +import com.webank.wedatasphere.dss.common.exception.DSSErrorException; +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.common.label.EnvDSSLabel; +import com.webank.wedatasphere.dss.common.label.LabelKeyConvertor; +import com.webank.wedatasphere.dss.common.utils.DSSCommonUtils; +import com.webank.wedatasphere.dss.orchestrator.common.entity.OrchestratorVo; +import com.webank.wedatasphere.dss.orchestrator.core.DSSOrchestratorContext; +import com.webank.wedatasphere.dss.orchestrator.core.service.BMLService; +import com.webank.wedatasphere.dss.orchestrator.publish.ExportDSSOrchestratorPlugin; +import com.webank.wedatasphere.dss.orchestrator.publish.ImportDSSOrchestratorPlugin; +import com.webank.wedatasphere.dss.orchestrator.server.service.OrchestratorService; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.dss.standard.sso.utils.SSOHelper; +import com.webank.wedatasphere.linkis.server.Message; +import com.webank.wedatasphere.linkis.server.security.SecurityFilter; +import org.apache.commons.io.IOUtils; +import org.glassfish.jersey.media.multipart.FormDataBodyPart; +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import org.glassfish.jersey.media.multipart.FormDataMultiPart; +import org.glassfish.jersey.media.multipart.FormDataParam; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +@Produces(MediaType.APPLICATION_JSON) +@Consumes({MediaType.APPLICATION_JSON, MediaType.MULTIPART_FORM_DATA}) +@Component +@Path("/dss/framework/orchestrator") +public class OrchestratorIERestful { + private static final Logger logger = LoggerFactory.getLogger(OrchestratorIERestful.class); + @Autowired + private BMLService bmlService; + @Autowired + OrchestratorService orchestratorService; + @Autowired + private DSSOrchestratorContext orchestratorContext; + + @POST + @Path("/importOrchestratorFile") + public Response importOrcFile(@Context HttpServletRequest req, + @FormDataParam("projectName") String projectName, + @FormDataParam("projectID") Long projectID, + @FormDataParam("labels") String labels, + FormDataMultiPart form) throws DSSErrorException, UnsupportedEncodingException { + List files = form.getFields("file"); + if (null == files || files.size() == 0) { + throw new DSSErrorException(100788, "Import orchestrator failed for files is empty"); + } + Long importOrcId = 0L; + for (FormDataBodyPart p : files) { + InputStream inputStream = p.getValueAs(InputStream.class); + FormDataContentDisposition fileDetail = p.getFormDataContentDisposition(); + String fileName = new String(fileDetail.getFileName().getBytes("ISO8859-1"), "UTF-8"); + String userName = SecurityFilter.getLoginUsername(req); + //调用工具类生产label + List dssLabelList = getDSSLabelList(labels); +// String fileDownloadUri = ServletUriComponentsBuilder.fromCurrentContextPath() +// .path("/downloadFile/") +// .path(fileName) +// .toUriString(); +// java.nio.file.Path targetLocation = DSSFileService.fileStorageLocation.resolve(fileName); + Workspace workspace = SSOHelper.getWorkspace(req); + //3、打包新的zip包上传BML +// InputStream inputStream = bmlService.readLocalResourceFile(userName, targetLocation.toAbsolutePath().toString()); + Map resultMap = bmlService.upload(userName, inputStream, + fileName, projectName); + try { + importOrcId = orchestratorContext.getDSSOrchestratorPlugin(ImportDSSOrchestratorPlugin.class).importOrchestrator(userName, + workspace.getWorkspaceName(), + projectName, + projectID, + resultMap.get("resourceId").toString(), + resultMap.get("version").toString(), + dssLabelList, + workspace); + } catch (Exception e) { + logger.error("Import orchestrator failed for ", e); + throw new DSSErrorException(100789, "Import orchestrator failed for " + e.getMessage()); + } + } + return Message.messageToResponse(Message.ok().data("importOrcId", importOrcId)); + } + + @GET + @Path("/exportOrchestrator") + public void exportOrcFile(@Context HttpServletRequest req, + @Context HttpServletResponse resp, + @DefaultValue("exportOrc") @QueryParam("outputFileName") String outputFileName, + @DefaultValue("utf-8") @QueryParam("charset") String charset, + @DefaultValue("zip") @QueryParam("outputFileType") String outputFileType, + @QueryParam("projectName") String projectName, + @QueryParam("orchestratorId") Long orchestratorId, + @QueryParam("orcVersionId") Long orcVersionId, + @DefaultValue("false") @QueryParam("addOrcVersion") Boolean addOrcVersion, + @QueryParam("labels") String labels) throws DSSErrorException, IOException { + resp.addHeader("Content-Disposition", "attachment;filename=" + + new String(outputFileName.getBytes("UTF-8"), "ISO8859-1") + "." + outputFileType); + resp.setCharacterEncoding(charset); + Workspace workspace = SSOHelper.getWorkspace(req); + String userName = SecurityFilter.getLoginUsername(req); + List dssLabelList = getDSSLabelList(labels); + Map res = null; + OrchestratorVo orchestratorVo = orchestratorService.getOrchestratorVoById(orchestratorId); + orcVersionId = orchestratorVo.getDssOrchestratorVersion().getId(); + logger.info("export orchestrator orchestratorId " + orchestratorId + ",orcVersionId:" + orcVersionId); + try { + res = orchestratorContext.getDSSOrchestratorPlugin(ExportDSSOrchestratorPlugin.class).exportOrchestrator(userName, + workspace.getWorkspaceName(), + orchestratorId, + orcVersionId, + projectName, + dssLabelList, + addOrcVersion, + workspace); + } catch (Exception e) { + logger.error("export orchestrator failed for ", e); + throw new DSSErrorException(100789, "export orchestrator failed for " + e.getMessage()); + } + if (null != res) { + Map downRes = bmlService.download(userName, + res.get("resourceId").toString(), + res.get("version").toString()); + + InputStream inputStream = (InputStream) downRes.get("is"); + try { + IOUtils.copy(inputStream, resp.getOutputStream()); + resp.getOutputStream().flush(); + } finally { + IOUtils.closeQuietly(inputStream); + } + } + } + + //生成label list + public List getDSSLabelList(String labels) { + //原来的逻辑 +// List dssLabelList = Arrays.asList(dssLabels.split(",")).stream().map(label -> { +// DSSLabel dssLabel = new EnvDSSLabel(label); +// return dssLabel; +// }).collect(Collectors.toList()); + String labelStr = DSSCommonUtils.ENV_LABEL_VALUE_DEV; + Map labelMap = DSSCommonUtils.COMMON_GSON.fromJson(labels, Map.class); + if (labelMap.containsKey(LabelKeyConvertor.ROUTE_LABEL_KEY)) { + labelStr = (String) labelMap.get(LabelKeyConvertor.ROUTE_LABEL_KEY); + } + List dssLabelList = Arrays.asList(new EnvDSSLabel(labelStr)); + return dssLabelList; + } +} \ No newline at end of file diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/restful/OrchestratorRestful.java b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/restful/OrchestratorRestful.java new file mode 100644 index 0000000000..8e3cbed25d --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/restful/OrchestratorRestful.java @@ -0,0 +1,150 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server.restful; + +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.common.label.DSSLabelUtil; +import com.webank.wedatasphere.dss.common.label.EnvDSSLabel; +import com.webank.wedatasphere.dss.common.label.LabelKeyConvertor; +import com.webank.wedatasphere.dss.common.utils.DSSCommonUtils; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo; +import com.webank.wedatasphere.dss.orchestrator.common.entity.OrchestratorVo; +import com.webank.wedatasphere.dss.orchestrator.server.entity.query.QueryOrchestratorVersion; +import com.webank.wedatasphere.dss.orchestrator.server.service.OrchestratorService; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.dss.standard.sso.utils.SSOHelper; +import com.webank.wedatasphere.linkis.server.Message; +import com.webank.wedatasphere.linkis.server.security.SecurityFilter; +import org.codehaus.jackson.JsonNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + + +@Component +@Path("/dss/framework/orchestrator") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class OrchestratorRestful { + private final static Logger LOGGER = LoggerFactory.getLogger(OrchestratorRestful.class); + @Autowired + OrchestratorService orchestratorService; + + @POST + @Path("/addOrchestrator") + public Response addOrchestrator(@Context HttpServletRequest req, JsonNode json) throws Exception { + String userName = SecurityFilter.getLoginUsername(req); + String name = json.get("name").getTextValue(); + String workspaceName = json.get("workspaceName").getTextValue(); + String projectName = json.get("projectName").getTextValue(); + String typeStr = json.get("type").getTextValue(); + String desc = json.get("desc").getTextValue(); + Long projectID = json.get("projectID").getLongValue(); +// List dssLabelList = Arrays.asList(dssLabels.split(",")).stream().map(label -> { +// DSSLabel dssLabel = new EnvDSSLabel(label); +// return dssLabel; +// }).collect(Collectors.toList()); + List dssLabelList = getDSSLabelList(json); + DSSOrchestratorInfo dssOrchestratorInfo = new DSSOrchestratorInfo(); + dssOrchestratorInfo.setName(name); + dssOrchestratorInfo.setCreator(userName); + dssOrchestratorInfo.setDesc(desc); + dssOrchestratorInfo.setType(typeStr); + OrchestratorVo orchestratorVo = orchestratorService.createOrchestrator(userName, + workspaceName, + projectName, + projectID, + desc, + dssOrchestratorInfo, + dssLabelList); + return Message.messageToResponse(Message.ok().data("OrchestratorVo", orchestratorVo)); + } + + + @POST + @Path("/rollbackOrchestrator") + public Response rollbackOrchestrator(@Context HttpServletRequest request, JsonNode jsonNode) { + String username = SecurityFilter.getLoginUsername(request); + Long orchestratorId = jsonNode.get("orchestratorId").getLongValue(); + String version = jsonNode.get("version").getTextValue(); + Long projectId = jsonNode.get("projectId").getLongValue(); + String projectName = jsonNode.get("projectName").getTextValue(); + Workspace workspace = SSOHelper.getWorkspace(request); + DSSLabel envDSSLabel = getDSSLabelList(jsonNode).get(0); + try { + String newVersion = orchestratorService.rollbackOrchestrator(username, projectId, projectName, orchestratorId, version, envDSSLabel, workspace); + Message message = Message.ok("回滚版本成功").data("newVersion", newVersion); + return Message.messageToResponse(message); + } catch (final Throwable t) { + LOGGER.error("Failed to rollback orchestrator for user {} orchestratorId {}, projectId {} version {}", + username, orchestratorId, projectId, version, t); + return Message.messageToResponse(Message.error("回滚工作流版本失败")); + } + } + + @POST + @Path("/openOrchestrator") + public Response openOrchestrator(@Context HttpServletRequest req, JsonNode json) throws Exception { + String openUrl = ""; + String userName = SecurityFilter.getLoginUsername(req); + List dssLabelList = getDSSLabelList(json); + String workspaceName = json.get("workspaceName").getTextValue(); + Long orchestratorId = json.get("orchestratorId").getLongValue(); + openUrl = orchestratorService.openOrchestrator(userName, workspaceName, orchestratorId, dssLabelList); + OrchestratorVo orchestratorVo = orchestratorService.getOrchestratorVoById(orchestratorId); + LOGGER.info("open url is {}, orcId is {}, dssLabels is {}", openUrl, orchestratorId, dssLabelList); + return Message.messageToResponse(Message.ok(). + data("OrchestratorOpenUrl", openUrl). + data("OrchestratorVo", orchestratorVo)); + } + + /** + * 获取编排模式下的所有版本号 + * + * @param queryOrchestratorVersion + * @return + * @throws Exception + */ + @POST + @Path("/getVersionByOrchestratorId") + public Response getVersionByOrchestratorId(@Valid QueryOrchestratorVersion queryOrchestratorVersion) throws Exception { + List list = orchestratorService.getVersionByOrchestratorId(queryOrchestratorVersion.getOrchestratorId()); + return Message.messageToResponse(Message.ok().data("list", list)); + } + + //生成label list + public List getDSSLabelList(JsonNode json) { + JsonNode labelJsonNode = json.get(DSSCommonUtils.DSS_LABELS_KEY); + String dssLabel = labelJsonNode.get(LabelKeyConvertor.ROUTE_LABEL_KEY).getTextValue(); + List dssLabelList = Arrays.asList(new EnvDSSLabel(dssLabel)); + return dssLabelList; + } +} diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/OrchestratorPluginService.java b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/OrchestratorPluginService.java new file mode 100644 index 0000000000..f329849593 --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/OrchestratorPluginService.java @@ -0,0 +1,29 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server.service; + +import com.webank.wedatasphere.dss.orchestrator.common.protocol.RequestFrameworkConvertOrchestration; +import com.webank.wedatasphere.dss.orchestrator.common.protocol.ResponseConvertOrchestrator; + + +public interface OrchestratorPluginService { + + ResponseConvertOrchestrator convertOrchestration(RequestFrameworkConvertOrchestration requestConversionOrchestration); + + ResponseConvertOrchestrator getConvertOrchestrationStatus(String id); + +} diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/OrchestratorService.java b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/OrchestratorService.java new file mode 100644 index 0000000000..beefda5eb5 --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/OrchestratorService.java @@ -0,0 +1,99 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server.service; + + +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorVersion; +import com.webank.wedatasphere.dss.orchestrator.common.entity.OrchestratorVo; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import java.util.List; + + +public interface OrchestratorService { + /** + * 新建编排,实例化一个用户的Orchestrator,并创建数据库记录 + * + * @param dssOrchestratorInfo + * @return + */ + OrchestratorVo createOrchestrator(String userName, + String workspaceName, + String projectName, + Long projectId, + String description, + DSSOrchestratorInfo dssOrchestratorInfo, + List dssLabels) throws Exception; + + + /** + * 更新编排,更新编排的基本信息 + * + * @param dssOrchestratorInfo + */ + void updateOrchestrator(String userName, + String workspaceName, + DSSOrchestratorInfo dssOrchestratorInfo, + List dssLabels) throws Exception; + + /** + * 删除编排,根据编排ID删除一个编排 + * + * @param orchestratorInfoId + */ + void deleteOrchestrator(String userName, + String workspaceName, + String projectName, + Long orchestratorInfoId, + List dssLabels) throws Exception; + + + /** + * 返回一个编排,包含编排的基本信息和最新版本信息 + * + * @param orchestratorId + * @return + */ + OrchestratorVo getOrchestratorVoById(Long orchestratorId); + + /** + * 根据一个集合查找 + * + * @param orchestratorIds + * @return + */ + + List getOrchestratorVoList(List orchestratorIds); + + String openOrchestrator(String userName, String workspaceName, Long orchestratorId, List dssLabels) throws Exception; + /** + * 获取编排模式下的版本号 + * + * @param orchestratorId + * @return + */ + List getVersionByOrchestratorId(Long orchestratorId); + +// OrchestratorInfo getOrchestratorInfo(String username, Long workflowId); + + List getOrchestratorVersions(String username, Long projectId, Long orchestratorId); + + String rollbackOrchestrator(String username, Long projectId, String projectName, + Long orchestratorId, String version, DSSLabel dssLabel, Workspace workspace) throws Exception; + +} diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/impl/OrchestratorPluginServiceImpl.java b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/impl/OrchestratorPluginServiceImpl.java new file mode 100644 index 0000000000..b00762ef34 --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/impl/OrchestratorPluginServiceImpl.java @@ -0,0 +1,160 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server.service.impl; + +import com.webank.wedatasphere.dss.common.entity.project.DSSProject; +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.common.utils.DSSExceptionUtils; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorVersion; +import com.webank.wedatasphere.dss.orchestrator.common.entity.OrchestratorInfo; +import com.webank.wedatasphere.dss.orchestrator.common.protocol.RequestFrameworkConvertOrchestration; +import com.webank.wedatasphere.dss.orchestrator.common.protocol.ResponseConvertOrchestrator; +import com.webank.wedatasphere.dss.orchestrator.common.protocol.ResponseOperateOrchestrator; +import com.webank.wedatasphere.dss.orchestrator.core.DSSOrchestratorContext; +import com.webank.wedatasphere.dss.orchestrator.db.dao.OrchestratorMapper; +import com.webank.wedatasphere.dss.orchestrator.publish.ExportDSSOrchestratorPlugin; +import com.webank.wedatasphere.dss.orchestrator.publish.job.ConversionJobEntity; +import com.webank.wedatasphere.dss.orchestrator.publish.job.OrchestratorConversionJob; +import com.webank.wedatasphere.dss.orchestrator.server.service.OrchestratorPluginService; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.linkis.common.utils.Utils; +import com.webank.wedatasphere.linkis.manager.label.builder.factory.LabelBuilderFactoryContext; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.atomic.AtomicInteger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + + +public class OrchestratorPluginServiceImpl implements OrchestratorPluginService { + + private final Logger LOGGER = LoggerFactory.getLogger(getClass()); + + @Autowired + private OrchestratorMapper orchestratorMapper; + + @Autowired + private DSSOrchestratorContext dssOrchestratorContext; + + private ExecutorService releaseThreadPool = Utils.newCachedThreadPool(50, "Convert-Orchestration-Thread-", true); + private Map orchestratorConversionJobMap = new ConcurrentHashMap<>(); + private AtomicInteger idGenerator = new AtomicInteger(); + + @Override + public ResponseConvertOrchestrator convertOrchestration(RequestFrameworkConvertOrchestration requestConversionOrchestration) { + Long toPublishOrcId; + if(requestConversionOrchestration.getOrcAppId() != null) { + OrchestratorInfo orchestratorInfo = orchestratorMapper.getOrcInfoByAppId(requestConversionOrchestration.getOrcAppId()); + toPublishOrcId = orchestratorInfo.getOrchestratorId(); + } else if(requestConversionOrchestration.getOrcIds() != null && !requestConversionOrchestration.getOrcIds().isEmpty()) { + toPublishOrcId = requestConversionOrchestration.getOrcIds().get(0); + } else { + return new ResponseConvertOrchestrator("-1", ResponseOperateOrchestrator.failed("Both orcAppId and orcIds are not exists.")); + } + DSSOrchestratorInfo dssOrchestratorInfo = orchestratorMapper.getOrchestrator(toPublishOrcId); + long projectId = dssOrchestratorInfo.getProjectId(); + //把orcId装车第三方的AppId + List refAppIdList = new ArrayList<>(); + List publishedOrcIds; + List labels = LabelBuilderFactoryContext.getLabelBuilderFactory().getLabels(requestConversionOrchestration.getLabels()); + if(requestConversionOrchestration.isConvertAllOrcs()) { + //这个地方应该是要获取所有的已经发布过的orchestrator + publishedOrcIds = orchestratorMapper.getAllOrcIdsByProjectId(projectId); + if (!publishedOrcIds.contains(toPublishOrcId)){ + publishedOrcIds.add(toPublishOrcId); + } + for (Long orcId : publishedOrcIds) { + DSSOrchestratorVersion dssOrchestratorVersion = orchestratorMapper.getLatestOrchestratorVersionById(orcId); + refAppIdList.add(dssOrchestratorVersion.getAppId()); + } + } else { + publishedOrcIds = new ArrayList<>(); + if(requestConversionOrchestration.getOrcAppId() != null) { + publishedOrcIds.add(toPublishOrcId); + DSSOrchestratorVersion dssOrchestratorVersion = orchestratorMapper.getLatestOrchestratorVersionById(toPublishOrcId); + refAppIdList.add(dssOrchestratorVersion.getAppId()); + } + if(requestConversionOrchestration.getOrcIds() != null && !requestConversionOrchestration.getOrcIds().isEmpty()) { + for (Long orcId : requestConversionOrchestration.getOrcIds()) { + DSSOrchestratorVersion dssOrchestratorVersion = orchestratorMapper.getLatestOrchestratorVersionById(orcId); + publishedOrcIds.add(orcId); + refAppIdList.add(dssOrchestratorVersion.getAppId()); + } + } + } + OrchestratorConversionJob job = new OrchestratorConversionJob(); + job.setId(generateId()); + ConversionJobEntity entity = new ConversionJobEntity(); + entity.setResponse(ResponseOperateOrchestrator.inited()); + entity.setCreateTime(new Date()); + entity.setUserName(requestConversionOrchestration.getUserName()); + entity.setOrcIdList(publishedOrcIds); + entity.setRefAppIdList(refAppIdList); + entity.setLabels(labels); + entity.setWorkspace((Workspace) requestConversionOrchestration.getWorkspace()); + DSSProject dssProject = new DSSProject(); + dssProject.setId(projectId); + entity.setProject(dssProject); + job.setConversionJobEntity(entity); + job.setConversionDSSOrchestratorPlugins(dssOrchestratorContext.getOrchestratorPlugins()); + job.afterConversion(response -> this.updateDBAfterConversion(response, job, requestConversionOrchestration)); + //submit it + releaseThreadPool.submit(job); + orchestratorConversionJobMap.put(job.getId(), job); + return new ResponseConvertOrchestrator(job.getId(), entity.getResponse()); + } + + @Override + public ResponseConvertOrchestrator getConvertOrchestrationStatus(String id) { + OrchestratorConversionJob job = orchestratorConversionJobMap.get(id); + if(job.getConversionJobEntity().getResponse().isCompleted()) { + orchestratorConversionJobMap.remove(id); + } + return new ResponseConvertOrchestrator(job.getId(), job.getConversionJobEntity().getResponse()); + } + + private String generateId() { + return String.valueOf(idGenerator.getAndIncrement()); + } + + @Transactional(rollbackFor = Exception.class) + private void updateDBAfterConversion(ResponseOperateOrchestrator response, + OrchestratorConversionJob job, + RequestFrameworkConvertOrchestration requestConversionOrchestration) { + LOGGER.info("{} completed with status {}.", job.getId(), response.getJobStatus()); + if(response.isSucceed()) { + //1. 进行导出,用于升级版本,目的是为了复用原来的代码 + List orcIdList = job.getConversionJobEntity().getOrcIdList(); + orcIdList.forEach(DSSExceptionUtils.handling(orcId -> { + DSSOrchestratorInfo dssOrchestratorInfo = orchestratorMapper.getOrchestrator(orcId); + dssOrchestratorContext.getDSSOrchestratorPlugin(ExportDSSOrchestratorPlugin.class) + .orchestratorVersionIncrease(orcId, job.getConversionJobEntity().getUserName(), requestConversionOrchestration.getComment(), + requestConversionOrchestration.getWorkspace().getWorkspaceName(), dssOrchestratorInfo, + job.getConversionJobEntity().getProject().getName(), job.getConversionJobEntity().getLabels()); + })); + //2. 做一个标记表示已经发布过了 + orcIdList.forEach(orchestratorMapper::setPublished); + } + } +} diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/impl/OrchestratorServiceImpl.java b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/impl/OrchestratorServiceImpl.java new file mode 100644 index 0000000000..d9e37e1dee --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/java/com/webank/wedatasphere/dss/orchestrator/server/service/impl/OrchestratorServiceImpl.java @@ -0,0 +1,376 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server.service.impl; + +import com.webank.wedatasphere.dss.appconn.core.AppConn; +import com.webank.wedatasphere.dss.appconn.manager.AppConnManager; +import com.webank.wedatasphere.dss.common.exception.DSSErrorException; +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.common.utils.DSSExceptionUtils; +import com.webank.wedatasphere.dss.contextservice.service.ContextService; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorVersion; +import com.webank.wedatasphere.dss.orchestrator.common.entity.OrchestratorVo; +import com.webank.wedatasphere.dss.orchestrator.core.DSSOrchestrator; +import com.webank.wedatasphere.dss.orchestrator.core.exception.DSSOrchestratorErrorException; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorCopyRequestRef; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorCopyResponseRef; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorCreateRequestRef; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorDeleteRequestRef; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorOpenRequestRef; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorUpdateRef; +import com.webank.wedatasphere.dss.orchestrator.core.utils.OrchestratorUtils; +import com.webank.wedatasphere.dss.orchestrator.db.dao.OrchestratorMapper; +import com.webank.wedatasphere.dss.orchestrator.loader.OrchestratorManager; +import com.webank.wedatasphere.dss.orchestrator.loader.utils.OrchestratorLoaderUtils; +import com.webank.wedatasphere.dss.orchestrator.server.service.OrchestratorService; +import com.webank.wedatasphere.dss.standard.app.development.ref.CommonResponseRef; +import com.webank.wedatasphere.dss.standard.app.development.ref.UrlResponseRef; +import com.webank.wedatasphere.dss.standard.app.development.service.RefCRUDService; +import com.webank.wedatasphere.dss.standard.app.development.service.RefQueryService; +import com.webank.wedatasphere.dss.standard.app.development.standard.DevelopmentIntegrationStandard; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.dss.standard.common.desc.AppInstance; +import com.webank.wedatasphere.dss.standard.common.entity.ref.AppConnRefFactoryUtils; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; +import javafx.util.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + + +@Service +public class OrchestratorServiceImpl implements OrchestratorService { + private static final Logger LOGGER = LoggerFactory.getLogger(OrchestratorServiceImpl.class); + @Autowired + private OrchestratorManager orchestratorManager; + @Autowired + private OrchestratorMapper orchestratorMapper; + @Autowired + private ContextService contextService; + + @Override + @Transactional(rollbackFor = Exception.class) + public OrchestratorVo createOrchestrator(String userName, + String workspaceName, + String projectName, + Long projectId, + String description, + DSSOrchestratorInfo dssOrchestratorInfo, + List dssLabels) throws Exception { + OrchestratorVo orchestratorVo = new OrchestratorVo(); + //todo 增加校验 + String uuid = UUID.randomUUID().toString(); + + //作为Orchestrator的唯一标识,包括跨环境导入导出也不发生变化。 + dssOrchestratorInfo.setUUID(uuid); + orchestratorMapper.addOrchestrator(dssOrchestratorInfo); + Pair standMap = OrchestratorLoaderUtils.getOrcDevelopStandard(userName, workspaceName, dssOrchestratorInfo, dssLabels); + DSSOrchestrator dssOrchestrator = orchestratorManager.getOrCreateOrchestrator(userName, + workspaceName, dssOrchestratorInfo.getType(), dssOrchestratorInfo.getAppConnName(), dssLabels); + AppConn orchestratorAppConn = dssOrchestrator.getAppConn(); + if (null != standMap && null != orchestratorAppConn) { + //访问工作流微模块创建工作流 + OrchestratorCreateRequestRef ref = AppConnRefFactoryUtils.newAppConnRef(OrchestratorCreateRequestRef.class, + orchestratorAppConn.getClass().getClassLoader(), dssOrchestratorInfo.getType()); + if (null != ref) { + ref.setUserName(userName); + ref.setWorkspaceName(workspaceName); + ref.setProjectName(projectName); + ref.setProjectId(projectId); + ref.setDssOrchestratorInfo(dssOrchestratorInfo); + String version = OrchestratorUtils.generateNewVersion(); + String contextId = contextService.createContextID(workspaceName, projectName, dssOrchestratorInfo.getName(), version, userName); + ref.setContextID(contextId); + LOGGER.info("Create a new ContextId: {} ", contextId); + RefCRUDService crudService =standMap.getValue().getRefCRUDService(standMap.getKey()); + if (crudService != null) { + CommonResponseRef appRef = (CommonResponseRef) crudService + .getRefCreationOperation().createRef(ref); + if (null != appRef) { + DSSOrchestratorVersion dssOrchestratorVersion = new DSSOrchestratorVersion(); + dssOrchestratorVersion.setOrchestratorId(dssOrchestratorInfo.getId()); + dssOrchestratorVersion.setAppId(appRef.getOrcId()); + dssOrchestratorVersion.setContent(appRef.getContent()); + dssOrchestratorVersion.setComment(description); + dssOrchestratorVersion.setProjectId(projectId); + dssOrchestratorVersion.setSource("Orchestrator create"); + dssOrchestratorVersion.setUpdater(userName); + dssOrchestratorVersion.setVersion(version); + dssOrchestratorVersion.setUpdateTime(new Date()); + dssOrchestratorVersion.setFormatContextId(contextId); + orchestratorMapper.addOrchestratorVersion(dssOrchestratorVersion); + orchestratorVo.setDssOrchestratorInfo(dssOrchestratorInfo); + orchestratorVo.setDssOrchestratorVersion(dssOrchestratorVersion); + } else { + LOGGER.error("create ref return appRef is null"); + throw new DSSErrorException(100068, "Use appInstance create workflow failed!"); + } + } else { + LOGGER.error("crudService is null can not continue"); + throw new DSSErrorException(60092, "create crudService is null"); + } + } else { + LOGGER.error("ref is null can not continue"); + throw new DSSErrorException(60093, "ref is null can not continue"); + } + } else { + throw new DSSErrorException(100069, "Can not find correct devCRUDService"); + } + return orchestratorVo; + } + + @Override + public void updateOrchestrator(String userName, + String workspaceName, + DSSOrchestratorInfo dssOrchestratorInfo, + List dssLabels) throws Exception { + orchestratorMapper.updateOrchestrator(dssOrchestratorInfo); + DSSOrchestratorVersion dssOrchestratorVersion = orchestratorMapper.getLatestOrchestratorVersionById(dssOrchestratorInfo.getId()); + + //todo 目前写死为工作流,这里应该是要和dssOrchestratorInfo.type作为参数传入 + AppConn appConn = AppConnManager.getAppConnManager().getAppConn("workflow"); + if(appConn==null){ + LOGGER.error("appConn is null,not update workflow"); + return; + } + OrchestratorUpdateRef orchestratorUpdateRef = AppConnRefFactoryUtils.newAppConnRef(OrchestratorUpdateRef.class, + appConn.getClass().getClassLoader(), dssOrchestratorInfo.getType()); + if (orchestratorUpdateRef != null) { + orchestratorUpdateRef.setOrcId(dssOrchestratorVersion.getAppId()); + orchestratorUpdateRef.setUserName(userName); + orchestratorUpdateRef.setDescription(dssOrchestratorInfo.getComment()); + orchestratorUpdateRef.setOrcName(dssOrchestratorInfo.getName()); + orchestratorUpdateRef.setUses(dssOrchestratorInfo.getUses()); + //update ref orchestrator info + Pair standMap = OrchestratorLoaderUtils.getOrcDevelopStandard(userName, workspaceName, dssOrchestratorInfo, dssLabels); + if (null != standMap ) { + RefCRUDService crudService = standMap.getValue().getRefCRUDService(standMap.getKey()); + if (null != crudService) { + crudService.getRefUpdateOperation().updateRef(orchestratorUpdateRef); + } + } else { + LOGGER.error("processService is null,can not do crud service"); + DSSExceptionUtils.dealErrorException(60056, "process service is null, can not do crud", DSSErrorException.class); + } + + } else { + LOGGER.error("update ref is null, can not continue doing"); + DSSExceptionUtils.dealErrorException(61123, "update ref is null, can not continue doing", DSSErrorException.class); + } + + } + + @Override + public void deleteOrchestrator(String userName, + String workspaceName, + String projectName, + Long orchestratorInfoId, + List dssLabels) throws Exception { + + DSSOrchestratorInfo dssOrchestratorInfo = orchestratorMapper.getOrchestrator(orchestratorInfoId); + if(null== dssOrchestratorInfo){ + LOGGER.error("dssOrchestratorInfo is null,no need to delete"); + return; + } + DSSOrchestratorVersion dssOrchestratorVersion = orchestratorMapper.getLatestOrchestratorVersionById(orchestratorInfoId); + + //todo 是否需要删除版本信息 + + //todo 删除版本信息对应的工作流信息 + + OrchestratorDeleteRequestRef orchestratorDeleteRequestRef = null; + try { + //todo 目前写死为工作流,这里应该是要和dssOrchestratorInfo.type作为参数传入 + AppConn appConn = AppConnManager.getAppConnManager().getAppConn(dssOrchestratorInfo.getType()); + if(appConn == null){ + LOGGER.error("appConn is null, not delete {}." + dssOrchestratorInfo.getType()); + return; + } + orchestratorDeleteRequestRef = AppConnRefFactoryUtils.newAppConnRefByPackageName(OrchestratorDeleteRequestRef.class, + appConn.getClass().getClassLoader(), appConn.getClass().getPackage().getName()); + } catch (Exception e) { + LOGGER.error("Failed to create a new ref for {}.", OrchestratorDeleteRequestRef.class, e); + } + assert orchestratorDeleteRequestRef != null; + Pair standMap = OrchestratorLoaderUtils.getOrcDevelopStandard(userName, workspaceName, dssOrchestratorInfo, dssLabels); + + RefCRUDService refCRUDService = standMap.getValue().getRefCRUDService (standMap.getKey()); + + //删除只需要 + orchestratorDeleteRequestRef.setAppId(dssOrchestratorVersion.getAppId()); + orchestratorDeleteRequestRef.setOrcId(orchestratorInfoId); + orchestratorDeleteRequestRef.setUserName(userName); + orchestratorDeleteRequestRef.setDSSLabels(dssLabels); + if (null != refCRUDService) { + refCRUDService.getRefDeletionOperation().deleteRef(orchestratorDeleteRequestRef); + } + + orchestratorMapper.deleteOrchestrator(orchestratorInfoId); + } + + @Override + public List getOrchestratorVoList(List orchestratorIds) { + List orchestratorVoList = new ArrayList<>(); + orchestratorIds.stream().forEach(orchestratorId -> { + OrchestratorVo orchestratorVo = getOrchestratorVoById(orchestratorId); + orchestratorVoList.add(orchestratorVo); + }); + return orchestratorVoList; + } + + @Override + public String openOrchestrator(String userName, String workspaceName, Long orchestratorId, List dssLabels) throws Exception { + DSSOrchestratorInfo dssOrchestratorInfo = orchestratorMapper.getOrchestrator(orchestratorId); + DSSOrchestratorVersion dssOrchestratorVersion = orchestratorMapper.getLatestOrchestratorVersionById(orchestratorId); + if (null == dssOrchestratorInfo || null == dssOrchestratorVersion) { + throw new DSSOrchestratorErrorException(1000856, "can not find orc from db for orcId: " + orchestratorId); + } + OrchestratorOpenRequestRef orchestratorOpenRequestRef = null; + Pair standMap = OrchestratorLoaderUtils.getOrcDevelopStandard(userName, workspaceName, dssOrchestratorInfo, dssLabels); + + DSSOrchestrator dssOrchestrator = orchestratorManager.getOrCreateOrchestrator(userName, + workspaceName, dssOrchestratorInfo.getType(), dssOrchestratorInfo.getAppConnName(), dssLabels); + AppConn orchestratorAppConn = dssOrchestrator.getAppConn(); + + try { + orchestratorOpenRequestRef = AppConnRefFactoryUtils.newAppConnRefByPackageName(OrchestratorOpenRequestRef.class, + orchestratorAppConn.getClass().getClassLoader(), orchestratorAppConn.getClass().getPackage().getName()); + } catch (final Exception e) { + LOGGER.error("Failed to open a new ref for {}", OrchestratorOpenRequestRef.class, e); + } + assert orchestratorOpenRequestRef != null; + RefQueryService refQueryService =standMap.getValue().getRefQueryService (standMap.getKey()); + + orchestratorOpenRequestRef.setRefAppId(dssOrchestratorVersion.getAppId()); + orchestratorOpenRequestRef.setOrchestratorId(orchestratorId); + orchestratorOpenRequestRef.setUserName(userName); + orchestratorOpenRequestRef.setSecondaryType(dssOrchestratorInfo.getSecondaryType()); + orchestratorOpenRequestRef.setDSSLabels(dssLabels); + if (null != refQueryService) { + UrlResponseRef urlResponseRef=(UrlResponseRef) refQueryService.getRefQueryOperation().query(orchestratorOpenRequestRef); + return urlResponseRef.getUrl(); + } + return null; + } + + @Override + public OrchestratorVo getOrchestratorVoById(Long orchestratorId) { + + DSSOrchestratorInfo dssOrchestratorInfo = orchestratorMapper.getOrchestrator(orchestratorId); + DSSOrchestratorVersion dssOrchestratorVersion = orchestratorMapper.getLatestOrchestratorVersionById(orchestratorId); + + OrchestratorVo orchestratorVo = new OrchestratorVo(); + orchestratorVo.setDssOrchestratorInfo(dssOrchestratorInfo); + orchestratorVo.setDssOrchestratorVersion(dssOrchestratorVersion); + return orchestratorVo; + } + + @Override + public List getVersionByOrchestratorId(Long orchestratorId) { + return orchestratorMapper.getVersionByOrchestratorId(orchestratorId); + } + +// @Override +// public OrchestratorInfo getOrchestratorInfo(String username, Long workflowId) { +// LOGGER.info("{} ask the orcInfo for workflowId {}", username, workflowId); +// OrchestratorInfo orchestratorInfo = orchestratorMapper.getOrcInfoByAppId(workflowId); +// LOGGER.info("workflowId is {} , orcId is {}, orcVersionId is {}", workflowId, orchestratorInfo.getOrchestratorId(), orchestratorInfo.getOrchestratorVersionId()); +// return orchestratorInfo; +// } + + @Override + public List getOrchestratorVersions(String username, Long projectId, Long orchestratorId) { + LOGGER.info("user {} wants to get orc versions in projectId {} for orcId {}", username, projectId, orchestratorId); + List orchestratorVersions = orchestratorMapper.getOrchestratorVersions(projectId, orchestratorId); + LOGGER.info("projectId is {} , orcId is {}, orcVersions are {}", projectId, orchestratorId, orchestratorVersions); + return orchestratorVersions; + } + + + @Override + @Transactional(rollbackFor = Exception.class) + public String rollbackOrchestrator(String userName, Long projectId, String projectName, + Long orchestratorId, String version, DSSLabel dssLabel, Workspace workspace) throws Exception { + //1.新建一个版本 + //2.然后将version的版本内容进行去workflow进行cp + //3.然后把生产的内容进行update到数据库 + String latestVersion = orchestratorMapper.getLatestVersion(orchestratorId); + List labels = new ArrayList<>(); + labels.add(dssLabel); + DSSOrchestratorInfo dssOrchestratorInfo = orchestratorMapper.getOrchestrator(orchestratorId); + String newVersion = OrchestratorUtils.increaseVersion(latestVersion); + DSSOrchestratorVersion dssOrchestratorVersion = new DSSOrchestratorVersion(); + dssOrchestratorVersion.setId(orchestratorId); + dssOrchestratorVersion.setVersion(newVersion); + dssOrchestratorVersion.setUpdateTime(new Date()); + dssOrchestratorVersion.setProjectId(projectId); + dssOrchestratorVersion.setUpdater(userName); + dssOrchestratorVersion.setComment("回滚工作流到版本:" + version); + dssOrchestratorVersion.setSource("rollback from version :" + version); + Long appId = orchestratorMapper.getAppIdByVersion(orchestratorId, version); + + Pair standMap = OrchestratorLoaderUtils.getOrcDevelopStandard(userName, workspace.getWorkspaceName(), dssOrchestratorInfo, labels); + + if(standMap == null){ + LOGGER.error("dev stand Service is null"); + throw new DSSErrorException(61105, "dev stand Service is null"); + } + RefCRUDService refcrudservice = standMap.getValue().getRefCRUDService(standMap.getKey()); + if (null != refcrudservice) { + try { + OrchestratorCopyRequestRef orchestratorCopyRequestRef = + AppConnRefFactoryUtils.newAppConnRef(OrchestratorCopyRequestRef.class, + refcrudservice.getClass().getClassLoader(), dssOrchestratorInfo.getType()); + orchestratorCopyRequestRef.setCopyOrcAppId(appId); + orchestratorCopyRequestRef.setCopyOrcVersionId(dssOrchestratorVersion.getOrchestratorId()); + orchestratorCopyRequestRef.setUserName(userName); + Field field = orchestratorCopyRequestRef.getClass().getDeclaredField("projectName"); + field.setAccessible(true); + field.set(orchestratorCopyRequestRef, projectName); + + //5、生成上下文ContextId + String contextId = contextService.createContextID(workspace.getWorkspaceName(), projectName, dssOrchestratorInfo.getName(), dssOrchestratorVersion.getVersion(), userName); + dssOrchestratorVersion.setContextId(contextId); + LOGGER.info("Create a new ContextId for import: {} ", contextId); + + orchestratorCopyRequestRef.setContextID(contextId); + OrchestratorCopyResponseRef orchestratorCopyResponseRef = + (OrchestratorCopyResponseRef) refcrudservice.getRefCopyOperation().copyRef(orchestratorCopyRequestRef); + dssOrchestratorVersion.setAppId(orchestratorCopyResponseRef.getCopyTargetAppId()); + dssOrchestratorVersion.setContent(orchestratorCopyResponseRef.getCopyTargetContent()); + dssOrchestratorVersion.setFormatContextId(contextId); + //update appConn node contextId + orchestratorMapper.addOrchestratorVersion(dssOrchestratorVersion); + } catch (final Throwable t) { + LOGGER.error("Faild to copy app in orchestrator server", t); + DSSExceptionUtils.dealErrorException(60099, "Faild to copy app in orchestrator server", t, DSSOrchestratorErrorException.class); + } + return dssOrchestratorVersion.getVersion(); + } else { + throw new DSSOrchestratorErrorException(10023, "获取第三方应用的Ref为空,不能完成拷贝操作!"); + } + } + +} diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/scala/com/webank/wedatasphere/dss/orchestrator/server/DSSOrchestratorServerApplication.scala b/dss-framework/dss-framework-orchestrator-server/src/main/scala/com/webank/wedatasphere/dss/orchestrator/server/DSSOrchestratorServerApplication.scala new file mode 100644 index 0000000000..848f1ea22e --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/scala/com/webank/wedatasphere/dss/orchestrator/server/DSSOrchestratorServerApplication.scala @@ -0,0 +1,39 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server + +import com.webank.wedatasphere.dss.common.utils.DSSMainHelper +import com.webank.wedatasphere.linkis.DataWorkCloudApplication +import com.webank.wedatasphere.linkis.common.utils.{Logging, Utils} + + +object DSSOrchestratorServerApplication extends Logging { + + val userName: String = System.getProperty("user.name") + val hostName: String = Utils.getComputerName + + def main(args: Array[String]): Unit = { + val serviceName = System.getProperty("serviceName")//ProjectConf.SERVICE_NAME.getValue + DSSMainHelper.formatPropertyFiles(serviceName) + val allArgs = args ++ DSSMainHelper.getExtraSpringOptions + System.setProperty("hostName", hostName) + System.setProperty("userName", userName) + info(s"Ready to start $serviceName with args: ${allArgs.toList}.") + println(s"Test Ready to start $serviceName with args: ${allArgs.toList}.") + DataWorkCloudApplication.main(allArgs) + } +} \ No newline at end of file diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/scala/com/webank/wedatasphere/dss/orchestrator/server/receiver/DSSOrchestratorChooser.scala b/dss-framework/dss-framework-orchestrator-server/src/main/scala/com/webank/wedatasphere/dss/orchestrator/server/receiver/DSSOrchestratorChooser.scala new file mode 100644 index 0000000000..c5ccda43c6 --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/scala/com/webank/wedatasphere/dss/orchestrator/server/receiver/DSSOrchestratorChooser.scala @@ -0,0 +1,58 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server.receiver + +import com.webank.wedatasphere.dss.orchestrator.common.protocol._ +import com.webank.wedatasphere.dss.orchestrator.core.DSSOrchestratorContext +import com.webank.wedatasphere.dss.orchestrator.server.service.{OrchestratorPluginService, OrchestratorService} +import com.webank.wedatasphere.linkis.rpc.{RPCMessageEvent, Receiver, ReceiverChooser} +import javax.annotation.PostConstruct +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.stereotype.Component + + + +@Component +class DSSOrchestratorChooser extends ReceiverChooser { + + @Autowired + var orchestratorService: OrchestratorService = _ + + @Autowired + var orchestratorPluginService: OrchestratorPluginService = _ + + @Autowired + var orchestratorContext: DSSOrchestratorContext = _ + + var receiver: Option[DSSOrchestratorReceiver] = _ + + @PostConstruct + def init(): Unit = receiver = Some(new DSSOrchestratorReceiver(orchestratorService,orchestratorPluginService,orchestratorContext)) + + override def chooseReceiver(event: RPCMessageEvent): Option[Receiver] = event.message match { + case _: RequestCreateOrchestrator => receiver + case _: RequestUpdateOrchestrator => receiver + case _: RequestDeleteOrchestrator => receiver + case _: RequestExportOrchestrator => receiver + case _: RequestImportOrchestrator => receiver + case _: RequestQueryOrchestrator => receiver + case _: RequestFrameworkConvertOrchestration => receiver + case _: RequestFrameworkConvertOrchestrationStatus => receiver + case _: RequestOrchestratorVersion => receiver + case _ => None + } +} \ No newline at end of file diff --git a/dss-framework/dss-framework-orchestrator-server/src/main/scala/com/webank/wedatasphere/dss/orchestrator/server/receiver/DSSOrchestratorReceiver.scala b/dss-framework/dss-framework-orchestrator-server/src/main/scala/com/webank/wedatasphere/dss/orchestrator/server/receiver/DSSOrchestratorReceiver.scala new file mode 100644 index 0000000000..946b0481b8 --- /dev/null +++ b/dss-framework/dss-framework-orchestrator-server/src/main/scala/com/webank/wedatasphere/dss/orchestrator/server/receiver/DSSOrchestratorReceiver.scala @@ -0,0 +1,114 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.server.receiver + +import java.util + +import com.webank.wedatasphere.dss.common.exception.DSSErrorException +import com.webank.wedatasphere.dss.common.protocol._ +import com.webank.wedatasphere.dss.common.utils.DSSCommonUtils +import com.webank.wedatasphere.dss.orchestrator.common.entity.OrchestratorVo +import com.webank.wedatasphere.dss.orchestrator.common.protocol._ +import com.webank.wedatasphere.dss.orchestrator.core.DSSOrchestratorContext +import com.webank.wedatasphere.dss.orchestrator.publish.{ExportDSSOrchestratorPlugin, ImportDSSOrchestratorPlugin} +import com.webank.wedatasphere.dss.orchestrator.server.service.{OrchestratorPluginService, OrchestratorService} +import com.webank.wedatasphere.dss.standard.app.sso.Workspace +import com.webank.wedatasphere.linkis.rpc.{Receiver, Sender} + +import scala.concurrent.duration.Duration + + + +class DSSOrchestratorReceiver(orchestratorService: OrchestratorService,orchestratorPluginService: OrchestratorPluginService,orchestratorContext: DSSOrchestratorContext) extends Receiver { + + override def receive(message: Any, sender: Sender): Unit = {} + + override def receiveAndReply(message: Any, sender: Sender): Any = message match { + case reqCreateOrchestrator: RequestCreateOrchestrator => + val orchestratorVo: OrchestratorVo = orchestratorService.createOrchestrator(reqCreateOrchestrator.getUserName, + reqCreateOrchestrator.getWorkspaceName, + reqCreateOrchestrator.getProjectName, + reqCreateOrchestrator.getProjectId, + reqCreateOrchestrator.getDescription, + reqCreateOrchestrator.getDssOrchestratorInfo, + reqCreateOrchestrator.getDssLabels) + ResponseCreateOrchestrator(orchestratorVo.getDssOrchestratorInfo.getId, orchestratorVo.getDssOrchestratorVersion.getId) + + case reqUpdateOrchestrator: RequestUpdateOrchestrator => + orchestratorService.updateOrchestrator(reqUpdateOrchestrator.getUserName, + reqUpdateOrchestrator.getWorkspaceName, + reqUpdateOrchestrator.getDssOrchestratorInfo, + reqUpdateOrchestrator.getDssLabels) + ResponseOperateOrchestrator.success() + + case reqDeleteOrchestrator: RequestDeleteOrchestrator => + orchestratorService.deleteOrchestrator(reqDeleteOrchestrator.getUserName, + reqDeleteOrchestrator.getWorkspaceName, + reqDeleteOrchestrator.getProjectName, + reqDeleteOrchestrator.getOrchestratorId, + reqDeleteOrchestrator.getDssLabels + ) + ResponseOperateOrchestrator.success() + + case reqExportOrchestrator: RequestExportOrchestrator => + val dssExportOrcResource: util.Map[String, AnyRef] = orchestratorContext.getDSSOrchestratorPlugin(classOf[ExportDSSOrchestratorPlugin]).exportOrchestrator( + reqExportOrchestrator.getUserName, + reqExportOrchestrator.getWorkspaceName, + reqExportOrchestrator.getOrchestratorId, + reqExportOrchestrator.getOrcVersionId, + reqExportOrchestrator.getProjectName, + reqExportOrchestrator.getDssLabels, + reqExportOrchestrator.getAddOrcVersion, + DSSCommonUtils.COMMON_GSON.fromJson(reqExportOrchestrator.getWorkspaceStr, classOf[Workspace])) + ResponseExportOrchestrator(dssExportOrcResource.get("resourceId").toString, + dssExportOrcResource.get("version").toString, dssExportOrcResource.get("orcVersionId").asInstanceOf[Long] + ) + + case requestImportOrchestrator: RequestImportOrchestrator => + val importOrcId = orchestratorContext.getDSSOrchestratorPlugin(classOf[ImportDSSOrchestratorPlugin]).importOrchestrator( + requestImportOrchestrator.getUserName, + requestImportOrchestrator.getWorkspaceName, + requestImportOrchestrator.getProjectName, + requestImportOrchestrator.getProjectId, + requestImportOrchestrator.getResourceId, + requestImportOrchestrator.getBmlVersion, + requestImportOrchestrator.getDssLabels, + DSSCommonUtils.COMMON_GSON.fromJson(requestImportOrchestrator.getWorkspaceStr, classOf[Workspace])) + ResponseImportOrchestrator(importOrcId) + + case requestQueryOrchestrator: RequestQueryOrchestrator => + val requestIdList = requestQueryOrchestrator.getOrchestratorIds + val queryOrchestratorList: util.List[OrchestratorVo] = orchestratorService.getOrchestratorVoList(requestIdList) + new ResponseQueryOrchestrator(queryOrchestratorList) + + case requestConversionOrchestration: RequestFrameworkConvertOrchestration => + //发布调度 + orchestratorPluginService.convertOrchestration(requestConversionOrchestration) + case requestConversionOrchestrationStatus: RequestFrameworkConvertOrchestrationStatus => + orchestratorPluginService.getConvertOrchestrationStatus(requestConversionOrchestrationStatus.getId) + + case requestOrchestratorVersion: RequestOrchestratorVersion => + val projectId = requestOrchestratorVersion.getProjectId + val username = requestOrchestratorVersion.getUsername + val orchestratorId = requestOrchestratorVersion.getOrchestratorId + val orchestratorVersions = orchestratorService.getOrchestratorVersions(username, projectId, orchestratorId) + new ResponseOrchetratorVersion(projectId, orchestratorId, orchestratorVersions) + case _ => throw new DSSErrorException(90000, "") + } + + override def receiveAndReply(message: Any, duration: Duration, sender: Sender): Any = {} +} diff --git a/dss-framework/dss-framework-project-server/bin/start-dss-framework-project-server.sh b/dss-framework/dss-framework-project-server/bin/start-dss-framework-project-server.sh new file mode 100644 index 0000000000..93242ae192 --- /dev/null +++ b/dss-framework/dss-framework-project-server/bin/start-dss-framework-project-server.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +cd `dirname $0` +cd .. +HOME=`pwd` +export DWS_ENGINE_MANAGER_HOME=$HOME + +export DWS_ENGINE_MANAGER_PID=$HOME/bin/linkis.pid + +if [[ -f "${DWS_ENGINE_MANAGER_PID}" ]]; then + pid=$(cat ${DWS_ENGINE_MANAGER_PID}) + if kill -0 ${pid} >/dev/null 2>&1; then + echo "DSS SERVER is already running." + return 0; + fi +fi + +export DWS_ENGINE_MANAGER_LOG_PATH=$HOME/logs +export DWS_ENGINE_MANAGER_HEAP_SIZE="1G" + +export DWS_ENGINE_MANAGER_JAVA_OPTS="-Xms$DWS_ENGINE_MANAGER_HEAP_SIZE -Xmx$DWS_ENGINE_MANAGER_HEAP_SIZE -XX:+UseG1GC -XX:MaxPermSize=500m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=20013" + +#export DWS_ENGINE_MANAGER_JAVA_OPTS="-Xms$DWS_ENGINE_MANAGER_HEAP_SIZE -Xmx$DWS_ENGINE_MANAGER_HEAP_SIZE -XX:+UseG1GC -XX:MaxPermSize=500m" + +nohup java $DWS_ENGINE_MANAGER_JAVA_OPTS -cp $HOME/conf:$HOME/lib/* com.webank.wedatasphere.linkis.DataWorkCloudApplication 2>&1 > $DWS_ENGINE_MANAGER_LOG_PATH/linkis.out & +pid=$! +if [[ -z "${pid}" ]]; then + echo "DSS SERVER start failed!" + sleep 1 + exit 1 +else + echo "DSS SERVER start succeeded!" + echo $pid > $DWS_ENGINE_MANAGER_PID + sleep 1 +fi +exit 1 \ No newline at end of file diff --git a/dss-framework/dss-framework-project-server/bin/stop-dss-framework-project-server.sh b/dss-framework/dss-framework-project-server/bin/stop-dss-framework-project-server.sh new file mode 100644 index 0000000000..2ca464de62 --- /dev/null +++ b/dss-framework/dss-framework-project-server/bin/stop-dss-framework-project-server.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +cd `dirname $0` +cd .. +HOME=`pwd` + +export FLOW_ENTRANCE_HOME_PID=$HOME/bin/linkis.pid + +function wait_for_FLOW_ENTRANCE_HOME_to_die() { + local pid + local count + pid=$1 + timeout=$2 + count=0 + timeoutTime=$(date "+%s") + let "timeoutTime+=$timeout" + currentTime=$(date "+%s") + forceKill=1 + + while [[ $currentTime -lt $timeoutTime ]]; do + $(kill ${pid} > /dev/null 2> /dev/null) + if kill -0 ${pid} > /dev/null 2>&1; then + sleep 3 + else + forceKill=0 + break + fi + currentTime=$(date "+%s") + done + + if [[ forceKill -ne 0 ]]; then + $(kill -9 ${pid} > /dev/null 2> /dev/null) + fi +} + +if [[ ! -f "${FLOW_ENTRANCE_HOME_PID}" ]]; then + echo "DSS SERVER is not running" +else + pid=$(cat ${FLOW_ENTRANCE_HOME_PID}) + if [[ -z "${pid}" ]]; then + echo "DSS SERVER is not running" + else + wait_for_FLOW_ENTRANCE_HOME_to_die $pid 40 + $(rm -f ${FLOW_ENTRANCE_HOME_PID}) + echo "DSS SERVER is stopped." + fi +fi \ No newline at end of file diff --git a/dss-framework/dss-framework-project-server/pom.xml b/dss-framework/dss-framework-project-server/pom.xml new file mode 100644 index 0000000000..d5b79a300d --- /dev/null +++ b/dss-framework/dss-framework-project-server/pom.xml @@ -0,0 +1,252 @@ + + + + + + dss + com.webank.wedatasphere.dss + 1.0.0 + + + 4.0.0 + + dss-framework-project-server + + + + com.webank.wedatasphere.dss + dss-framework-common + ${dss.version} + + + commons-math3 + org.apache.commons + + + + + + org.apache.commons + commons-math3 + provided + + + + com.webank.wedatasphere.dss + dss-appconn-framework + ${dss.version} + + + + com.webank.wedatasphere.dss + dss-structure-integration-standard + ${dss.version} + + + commons-collections + commons-collections + + + dss-common + com.webank.wedatasphere.dss + + + linkis-common + com.webank.wedatasphere.linkis + + + + + + com.webank.wedatasphere.dss + dss-development-process-standard + ${dss.version} + + + + com.webank.wedatasphere.dss + dss-orchestrator-core + ${dss.version} + + + commons-collections + commons-collections + + + linkis-common + com.webank.wedatasphere.linkis + + + commons-lang3 + org.apache.commons + + + commons-logging + commons-logging + + + + + + com.webank.wedatasphere.dss + dss-orchestrator-db + ${dss.version} + + + + + + org.apache.commons + commons-lang3 + ${commons.lang3.version} + provided + + + + org.glassfish.jersey.ext + jersey-bean-validation + 2.21 + provided + + + com.webank.wedatasphere.linkis + linkis-rpc + ${linkis.version} + provided + + + linkis-common + com.webank.wedatasphere.linkis + + + + + com.webank.wedatasphere.dss + dss-framework-workspace-server + ${dss.version} + + + linkis-common + com.webank.wedatasphere.linkis + + + commons-logging + commons-logging + + + commons-codec + commons-codec + + + commons-lang3 + org.apache.commons + + + json4s-jackson_2.11 + org.json4s + + + + + + com.webank.wedatasphere.linkis + linkis-mybatis + ${linkis.version} + provided + + + com.webank.wedatasphere.dss + dss-common + ${dss.version} + provided + + + com.webank.wedatasphere.dss + dss-sender-service + ${dss.version} + provided + + + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + + + net.alchim31.maven + scala-maven-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + org.apache.maven.plugins + maven-assembly-plugin + 2.3 + false + + + make-assembly + package + + single + + + + src/main/assembly/distribution.xml + + + + + + false + out + false + false + + src/main/assembly/distribution.xml + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + + + src/main/java + + **/*.xml + + + + + + \ No newline at end of file diff --git a/dss-framework/dss-framework-project-server/src/main/assembly/distribution.xml b/dss-framework/dss-framework-project-server/src/main/assembly/distribution.xml new file mode 100644 index 0000000000..a506dcb069 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/assembly/distribution.xml @@ -0,0 +1,44 @@ + + + + dss-framework-project-server + + dir + + true + dss-framework-project-server + + + + + + lib + true + true + false + true + true + + + + + + + diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/conf/ProjectConf.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/conf/ProjectConf.java new file mode 100644 index 0000000000..67bd65d9d7 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/conf/ProjectConf.java @@ -0,0 +1,26 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.conf; + +import com.webank.wedatasphere.linkis.common.conf.CommonVars; + + +public interface ProjectConf { + + CommonVars SUPPORT_ABILITY = CommonVars.apply("wds.dss.framework.project.support.ability", "import,export,publish"); + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/conf/ProjectSpringConf.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/conf/ProjectSpringConf.java new file mode 100644 index 0000000000..f29748335a --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/conf/ProjectSpringConf.java @@ -0,0 +1,43 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.conf; + +import com.webank.wedatasphere.dss.framework.project.service.DSSFrameworkOrchestratorService; +import com.webank.wedatasphere.dss.framework.project.service.DSSProjectUserService; +import com.webank.wedatasphere.dss.framework.project.service.impl.DSSFrameworkOrchestratorServiceImpl; +import com.webank.wedatasphere.dss.framework.project.service.impl.DSSProjectUserServiceImpl; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + + +@Configuration +public class ProjectSpringConf { + + @Bean + @ConditionalOnMissingBean + public DSSProjectUserService createDSSProjectUserService() { + return new DSSProjectUserServiceImpl(); + } + + @Bean + @ConditionalOnMissingBean + public DSSFrameworkOrchestratorService createDSSFrameworkOrchestratorService() { + return new DSSFrameworkOrchestratorServiceImpl(); + } + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/conf/ValidationExceptionMapper.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/conf/ValidationExceptionMapper.java new file mode 100644 index 0000000000..4b16c64032 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/conf/ValidationExceptionMapper.java @@ -0,0 +1,52 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.conf; + + + +import com.webank.wedatasphere.linkis.server.Message; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; +import javax.validation.ValidationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + + + +@Provider +public class ValidationExceptionMapper implements ExceptionMapper { + + private final Logger LOGGER = LoggerFactory.getLogger(getClass()); + + @Override + public Response toResponse(ValidationException e) { + if (LOGGER.isDebugEnabled()){ + LOGGER.debug("failed to validate request bean", e); + } + StringBuilder strBuilder = new StringBuilder(); + for (ConstraintViolation cv : ((ConstraintViolationException) e).getConstraintViolations()) { + strBuilder.append(cv.getMessage()).append(";"); + } + Message message = Message.error(strBuilder.toString()); + return Message.messageToResponse(message); + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/OrchestratorTypeEnum.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/OrchestratorTypeEnum.java new file mode 100644 index 0000000000..5db47b925c --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/OrchestratorTypeEnum.java @@ -0,0 +1,88 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.contant; + +import com.webank.wedatasphere.dss.orchestrator.core.type.OrchestratorKindEnum; +import org.apache.commons.lang.StringUtils; + +import java.util.Arrays; + +public enum OrchestratorTypeEnum { + + WORKFLOW("'pom_work_flow'", 1, "工作流"), + SINGLE_TASK("'pom_single_task'",2, "单任务"), + COMBINED("'pom_consist_orchestrator'",3, "组合编排"); + + private String key; + private Integer type; + private String name; + + OrchestratorTypeEnum(String key, Integer type, String name) { + this.key = key; + this.type = type; + this.name = name; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public static Integer getTypeByKey(String key){ + return Arrays.stream(OrchestratorTypeEnum.values()) + .filter(a -> a.getKey().equals(key)) + .map(OrchestratorTypeEnum::getType) + .findFirst() + .orElse(0); + } + + public static String getKeyByOrcType(String type) { + int index = Arrays.stream(OrchestratorKindEnum.values()) + .filter(a -> a.getName().equals(type)) + .map(OrchestratorKindEnum::getIndex) + .findFirst() + .orElse(0); + String key = Arrays.stream(OrchestratorTypeEnum.values()) + .filter(a -> a.getType().equals(index)) + .map(OrchestratorTypeEnum::getKey) + .findFirst() + .orElse(null); + return StringUtils.isNotBlank(key) ? key.replace("'", "") : null; + } + + + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/ProjectServerResponse.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/ProjectServerResponse.java new file mode 100644 index 0000000000..93fbef2e47 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/ProjectServerResponse.java @@ -0,0 +1,49 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.contant; + +public enum ProjectServerResponse { + PROJECT_NOT_EDIT_AUTH(6001,"没有修改权限"), + PROJECT_NOT_EDIT_NAME(6002,"不能修改工程名称"), + PROJECT_NOT_EXIST(6003,"工程不存在"), + PROJECT_IS_NOT_ADMIN(6004,"只有创建人或管理员才能编辑工程") + ; + + ProjectServerResponse(int code, String msg) { + this.code = code; + this.msg = msg; + } + + private int code; + private String msg; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/ProjectSpringConfiguration.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/ProjectSpringConfiguration.java new file mode 100644 index 0000000000..12f52b7c9a --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/ProjectSpringConfiguration.java @@ -0,0 +1,34 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.contant; + +import com.webank.wedatasphere.dss.framework.project.service.DSSProjectService; +import com.webank.wedatasphere.dss.framework.project.service.impl.DSSProjectServiceImpl; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ProjectSpringConfiguration { + + @Bean + @ConditionalOnMissingBean + public DSSProjectService createProjectService() { + return new DSSProjectServiceImpl(); + } + +} \ No newline at end of file diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/ProjectUserPrivEnum.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/ProjectUserPrivEnum.java new file mode 100644 index 0000000000..3de13c31cf --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/contant/ProjectUserPrivEnum.java @@ -0,0 +1,50 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.contant; + + +public enum ProjectUserPrivEnum { + + PRIV_ACCESS(1,"查看权限"), + PRIV_EDIT(2,"编辑权限"), + PRIV_RELEASE(3,"发布权限"); + + ProjectUserPrivEnum(int rank, String name) { + this.rank = rank; + this.name = name; + } + + private int rank; + + private String name; + + public int getRank() { + return rank; + } + + public void setRank(int rank) { + this.rank = rank; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/DSSOrchestratorMapper.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/DSSOrchestratorMapper.java new file mode 100644 index 0000000000..b310318b21 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/DSSOrchestratorMapper.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.webank.wedatasphere.dss.framework.project.entity.DSSOrchestrator; +import org.apache.ibatis.annotations.*; + + +@Mapper +public interface DSSOrchestratorMapper extends BaseMapper { + + @Select("Select `uuid` from `dss_orchestrator_info` where `id` = #{orchestratorId} ") + String getUUID(@Param("orchestratorId") Long orchestratorId); +} + + diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/DSSProjectMapper.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/DSSProjectMapper.java new file mode 100644 index 0000000000..5cc71f1697 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/DSSProjectMapper.java @@ -0,0 +1,75 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.webank.wedatasphere.dss.framework.project.entity.DSSProjectDO; +import com.webank.wedatasphere.dss.framework.project.entity.po.DSSProjectPo; +import com.webank.wedatasphere.dss.framework.project.entity.po.ProjectRelationPo; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectQueryRequest; +import com.webank.wedatasphere.dss.framework.project.entity.vo.ProjectInfoVo; +import com.webank.wedatasphere.dss.framework.project.entity.vo.QueryProjectVo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import java.util.List; + + +@Mapper +public interface DSSProjectMapper extends BaseMapper { + + void addProject(DSSProjectPo dssProjectPo); + + @Select("select id from dss_project where `name` = #{projectName}") + Long getProjectIdByName(@Param("projectName") String projectName); + + @Select("select `name` from dss_project where `id` = #{projectId}") + String getProjectNameById(@Param("projectId") Long projectId); + + + @Select("select `id` from dss_project where `workspace_id` = #{workspaceId} and visible = #{visible}") + List getProjectIdsByWorkspaceId(@Param("workspaceId") Long workspaceId,@Param("visible")int visible); + + + List getListByParam(ProjectQueryRequest projectRequest); + + /** + * 获取工程详情:工程名称、空间名称 + */ + ProjectInfoVo getProjectInfoById(@Param("id") Long id); + + void saveProjectRelation(List projectRelationPoList); + + @Select("select `appconn_instance_project_id` from dss_appconn_project_relation " + + "where `project_id` = #{dssProjectId} and `appconn_instance_id` = #{appInstanceId}") + Long getAppConnProjectId(@Param("appInstanceId")Long appInstanceId, @Param("dssProjectId")Long dssProjectId); + + + @Update("update dss_project set `visible` = 0 where `id` = #{projectId}") + void deleteProject(@Param("projectId")Long projectId); + + @Select("SELECT a.url FROM dss_appconn_instance a LEFT JOIN dss_appconn b ON a.appconn_id = b.id WHERE b.appconn_name=#{schedulisName} LIMIT 1") + String getSchedualisUrl(@Param("schedulisName")String schedulisName); + + @Select("SELECT a.appconn_instance_project_id FROM dss_appconn_project_relation a WHERE a.appconn_instance_id = 1 AND a.project_id = #{projectId} LIMIT 1") + Long getSchedulisProjectId(@Param("projectId")Long projectId); + + @Update("update dss_appconn_project_relation set appconn_instance_project_id = #{schedulisProjectId} WHERE appconn_instance_id = 1 AND project_id = #{projectId} ") + int updateSchedulisProjectId(@Param("schedulisProjectId")Long schedulisProjectId,@Param("projectId")Long projectId); +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/DSSProjectUserMapper.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/DSSProjectUserMapper.java new file mode 100644 index 0000000000..999ec38ac1 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/DSSProjectUserMapper.java @@ -0,0 +1,45 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.webank.wedatasphere.dss.framework.project.entity.DSSProjectUser; +import org.apache.ibatis.annotations.*; + +import java.util.List; + + +@Mapper +public interface DSSProjectUserMapper extends BaseMapper { + @Insert({ + "" + }) + void insertBatchProjectUser(@Param("list") List projectUserList); + + @Delete("delete from dss_project_user where project_id = #{projectID}") + void deleteAllPriv(@Param("projectID") long projectID); + + @Select("SELECT COUNT(0) FROM dss_workspace_user_role WHERE workspace_id = #{workspaceId} AND username = #{username} AND role_id = #{roleId} ") + Long isAdminByUsername(@Param("workspaceId")Long workspaceId,@Param("username")String username,@Param("roleId")int roleId); +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/impl/DSSProjectMapper.xml b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/impl/DSSProjectMapper.xml new file mode 100644 index 0000000000..4713083937 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/dao/impl/DSSProjectMapper.xml @@ -0,0 +1,77 @@ + + + + + + + id,`name`,`source`, `workspace_id`,`description`,`org_id`,`visibility`,`is_transfer`,`initial_org_id`, + `username`,`create_time`,`create_by`,`product`,`application_area`,`business` + , `user_id`, `create_by_str`, `update_by_str` + + + + INSERT INTO dss_project () + VALUES + (#{id},#{name},#{source}, #{workspaceId}, #{description},#{orgID},#{visibility},#{isTransfer},#{initialOrgID}, + #{username},#{createTime},#{createBy},#{product},#{applicationArea},#{business}, + #{userID},#{createByStr},#{updateByStr}) + + + + + + + + insert into dss_appconn_project_relation + ( + `project_id`, + `appconn_instance_id`, + `appconn_instance_project_id` + ) + values + + ( + #{item.dssProjectId}, + #{item.appInstanceId}, + #{item.appInstanceProjectId} + ) + + + + + \ No newline at end of file diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/DSSOrchestrator.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/DSSOrchestrator.java new file mode 100644 index 0000000000..6269691e3f --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/DSSOrchestrator.java @@ -0,0 +1,236 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.*; + + +@TableName(value = "dss_project_orchestrator") +public class DSSOrchestrator implements Serializable { + + private static final long serialVersionUID=1L; + + /** + * 主键ID + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 空间id + */ + private Long workspaceId; + + /** + * 工程id + */ + private Long projectId; + + /** + * 编排模式id(工作流,调用orchestrator服务返回的orchestratorId) + */ + private Long orchestratorId; + + /** + * 编排模式版本id(工作流,调用orchestrator服务返回的orchestratorVersionId) + */ + private Long orchestratorVersionId; + + /** + * 编排名称 + */ + private String orchestratorName; + + /** + * 编排模式,取得的值是dss_dictionary中的dic_key(parent_key=p_orchestratorment_mode) + */ + private String orchestratorMode; + + /** + * 编排方式 + */ + private String orchestratorWay; + + /** + * 用途 + */ + private String uses; + + /** + * 描述 + */ + private String description; + + /** + * 创建人 + */ + private String createUser; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新人 + */ + private String updateUser; + + /** + * 更新时间 + */ + private Date updateTime; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Long workspaceId) { + this.workspaceId = workspaceId; + } + + public Long getProjectId() { + return projectId; + } + + public void setProjectId(Long projectId) { + this.projectId = projectId; + } + + public Long getOrchestratorId() { + return orchestratorId; + } + + public void setOrchestratorId(Long orchestratorId) { + this.orchestratorId = orchestratorId; + } + + public Long getOrchestratorVersionId() { + return orchestratorVersionId; + } + + public void setOrchestratorVersionId(Long orchestratorVersionId) { + this.orchestratorVersionId = orchestratorVersionId; + } + + public String getOrchestratorName() { + return orchestratorName; + } + + public void setOrchestratorName(String orchestratorName) { + this.orchestratorName = orchestratorName; + } + + public String getOrchestratorMode() { + return orchestratorMode; + } + + public void setOrchestratorMode(String orchestratorMode) { + this.orchestratorMode = orchestratorMode; + } + + public String getOrchestratorWay() { + return orchestratorWay; + } + + public void setOrchestratorWay(String orchestratorWay) { + this.orchestratorWay = orchestratorWay; + } + + public String getUses() { + return uses; + } + + public void setUses(String uses) { + this.uses = uses; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateUser() { + return createUser; + } + + public void setCreateUser(String createUser) { + this.createUser = createUser; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getUpdateUser() { + return updateUser; + } + + public void setUpdateUser(String updateUser) { + this.updateUser = updateUser; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + @Override + public String toString() { + return "DSSOrchestrator{" + + "id=" + id + + ", workspaceId=" + workspaceId + + ", projectId=" + projectId + + ", orchestratorId=" + orchestratorId + + ", orchestratorVersionId=" + orchestratorVersionId + + ", orchestratorName='" + orchestratorName + '\'' + + ", orchestratorMode='" + orchestratorMode + '\'' + + ", orchestratorWay='" + orchestratorWay + '\'' + + ", uses='" + uses + '\'' + + ", description='" + description + '\'' + + ", createUser='" + createUser + '\'' + + ", createTime=" + createTime + + ", updateUser='" + updateUser + '\'' + + ", updateTime=" + updateTime + + '}'; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/DSSProjectDO.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/DSSProjectDO.java new file mode 100644 index 0000000000..a26f72a5e9 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/DSSProjectDO.java @@ -0,0 +1,344 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.Date; + + + +@TableName(value = "dss_project") +public class DSSProjectDO implements Serializable { + + private static final long serialVersionUID=1L; + + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + private String name; + + /** + * Source of the dss_project + */ + private String source; + + private String description; + + private Long userId; + + private String username; + + private Long workspaceId; + + private Date createTime; + + private String createBy; + + private Date updateTime; + + private String updateBy; + + /** + * Organization ID + */ + private Long orgId; + + private Boolean visibility; + + /** + * Reserved word + */ + private Boolean isTransfer; + + private Long initialOrgId; + + /** + * If it is archived + */ + @TableField("isArchive") + private Boolean isArchive; + + private String pic; + + private Integer starNum; + + private String product; + + private Integer applicationArea; + + private String business; + + private Integer isPersonal; + + private String createByStr; + + private String updateByStr; + /** + * 开发流程,多个以英文逗号分隔,取得的值是dss_dictionary中的dic_key(parent_key=p_develop_process),首尾以英文逗号结束 + */ + private String devProcess; + + /** + * 编码模式,多个以英文逗号分隔,取得的值是dss_dictionary中的dic_key(parent_key=p_arrangement_mode或下面一级),首尾以英文逗号结束 + */ + private String orchestratorMode; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public Long getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Long workspaceId) { + this.workspaceId = workspaceId; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateBy() { + return updateBy; + } + + public void setUpdateBy(String updateBy) { + this.updateBy = updateBy; + } + + public Long getOrgId() { + return orgId; + } + + public void setOrgId(Long orgId) { + this.orgId = orgId; + } + + public Boolean getVisibility() { + return visibility; + } + + public void setVisibility(Boolean visibility) { + this.visibility = visibility; + } + + public Boolean getTransfer() { + return isTransfer; + } + + public void setTransfer(Boolean transfer) { + isTransfer = transfer; + } + + public Long getInitialOrgId() { + return initialOrgId; + } + + public void setInitialOrgId(Long initialOrgId) { + this.initialOrgId = initialOrgId; + } + + public Boolean getArchive() { + return isArchive; + } + + public void setArchive(Boolean archive) { + isArchive = archive; + } + + public String getPic() { + return pic; + } + + public void setPic(String pic) { + this.pic = pic; + } + + public Integer getStarNum() { + return starNum; + } + + public void setStarNum(Integer starNum) { + this.starNum = starNum; + } + + public String getProduct() { + return product; + } + + public void setProduct(String product) { + this.product = product; + } + + public Integer getApplicationArea() { + return applicationArea; + } + + public void setApplicationArea(Integer applicationArea) { + this.applicationArea = applicationArea; + } + + public String getBusiness() { + return business; + } + + public void setBusiness(String business) { + this.business = business; + } + + public Integer getIsPersonal() { + return isPersonal; + } + + public void setIsPersonal(Integer isPersonal) { + this.isPersonal = isPersonal; + } + + public String getCreateByStr() { + return createByStr; + } + + public void setCreateByStr(String createByStr) { + this.createByStr = createByStr; + } + + public String getUpdateByStr() { + return updateByStr; + } + + public void setUpdateByStr(String updateByStr) { + this.updateByStr = updateByStr; + } + + public String getDevProcess() { + return devProcess; + } + + public void setDevProcess(String devProcess) { + this.devProcess = devProcess; + } + + public String getOrchestratorMode() { + return orchestratorMode; + } + + public void setOrchestratorMode(String orchestratorMode) { + this.orchestratorMode = orchestratorMode; + } + + @Override + public String toString() { + return "DSSProject{" + + "id=" + id + + ", name='" + name + '\'' + + ", source='" + source + '\'' + + ", description='" + description + '\'' + + ", userId=" + userId + + ", username='" + username + '\'' + + ", workspaceId=" + workspaceId + + ", createTime=" + createTime + + ", createBy='" + createBy + '\'' + + ", updateTime=" + updateTime + + ", updateBy='" + updateBy + '\'' + + ", orgId=" + orgId + + ", visibility=" + visibility + + ", isTransfer=" + isTransfer + + ", initialOrgId=" + initialOrgId + + ", isArchive=" + isArchive + + ", pic='" + pic + '\'' + + ", starNum=" + starNum + + ", product='" + product + '\'' + + ", applicationArea=" + applicationArea + + ", business='" + business + '\'' + + ", isPersonal=" + isPersonal + + ", createByStr='" + createByStr + '\'' + + ", updateByStr='" + updateByStr + '\'' + + ", devProcess='" + devProcess + '\'' + + ", orchestratorMode='" + orchestratorMode + '\'' + + '}'; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/DSSProjectUser.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/DSSProjectUser.java new file mode 100644 index 0000000000..9494d501e2 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/DSSProjectUser.java @@ -0,0 +1,106 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.Date; + + +@TableName(value = "dss_project_user") +public class DSSProjectUser implements Serializable { + + private static final long serialVersionUID=1L; + + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + private Long projectId; + + private String username; + + private Long workspaceId; + + /** + * 权限等级:1-查看,2-编辑,3-发布 + */ + private Integer priv; + + private Date lastUpdateTime; + + public DSSProjectUser() { + } + + + public DSSProjectUser(Long workspaceId, Long projectId, String username, int priv) { + this.workspaceId = workspaceId; + this.projectId = projectId; + this.username = username; + this.priv = priv; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getProjectId() { + return projectId; + } + + public void setProjectId(Long projectId) { + this.projectId = projectId; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public Long getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Long workspaceId) { + this.workspaceId = workspaceId; + } + + public Integer getPriv() { + return priv; + } + + public void setPriv(Integer priv) { + this.priv = priv; + } + + public Date getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(Date lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/po/DSSProjectPo.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/po/DSSProjectPo.java new file mode 100644 index 0000000000..f6d6513ece --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/po/DSSProjectPo.java @@ -0,0 +1,276 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.po; + +import java.util.Date; +import java.util.List; + + +public class DSSProjectPo { + + + private Long id; + private String name; + private String description; + private String source; + private Date createTime; + private String createBy; //兼容Visualis 后修改类型 + private Date updateTime; + private Long orgID; + private Boolean visibility; + private Boolean isTransfer; + private Boolean isArchive; + private Long initialOrgID; + private String pic; + private Long starNum; + private String product; + private Integer applicationArea; + private String business; + private Integer workspaceId; + private String projectGroup; + private String workspaceName; + private String username; + private Integer isPersonal; + + private Long userID; + private String createByStr; + private String updateByStr; + + private List accessUsers; + private List editUsers; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Long getOrgID() { + return orgID; + } + + public void setOrgID(Long orgID) { + this.orgID = orgID; + } + + public Boolean getVisibility() { + return visibility; + } + + public void setVisibility(Boolean visibility) { + this.visibility = visibility; + } + + public Boolean getTransfer() { + return isTransfer; + } + + public void setTransfer(Boolean transfer) { + isTransfer = transfer; + } + + public Boolean getArchive() { + return isArchive; + } + + public void setArchive(Boolean archive) { + isArchive = archive; + } + + public Long getInitialOrgID() { + return initialOrgID; + } + + public void setInitialOrgID(Long initialOrgID) { + this.initialOrgID = initialOrgID; + } + + public String getPic() { + return pic; + } + + public void setPic(String pic) { + this.pic = pic; + } + + public Long getStarNum() { + return starNum; + } + + public void setStarNum(Long starNum) { + this.starNum = starNum; + } + + public String getProduct() { + return product; + } + + public void setProduct(String product) { + this.product = product; + } + + public Integer getApplicationArea() { + return applicationArea; + } + + public void setApplicationArea(Integer applicationArea) { + this.applicationArea = applicationArea; + } + + public String getBusiness() { + return business; + } + + public void setBusiness(String business) { + this.business = business; + } + + public Integer getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Integer workspaceId) { + this.workspaceId = workspaceId; + } + + public String getProjectGroup() { + return projectGroup; + } + + public void setProjectGroup(String projectGroup) { + this.projectGroup = projectGroup; + } + + public List getAccessUsers() { + return accessUsers; + } + + public void setAccessUsers(List accessUsers) { + this.accessUsers = accessUsers; + } + + public List getEditUsers() { + return editUsers; + } + + public void setEditUsers(List editUsers) { + this.editUsers = editUsers; + } + + + public String getWorkspaceName() { + return workspaceName; + } + + public void setWorkspaceName(String workspaceName) { + this.workspaceName = workspaceName; + } + + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public Integer getIsPersonal() { + return isPersonal; + } + + public void setIsPersonal(Integer isPersonal) { + this.isPersonal = isPersonal; + } + + public Long getUserID() { + return userID; + } + + public void setUserID(Long userID) { + this.userID = userID; + } + + public String getCreateByStr() { + return createByStr; + } + + public void setCreateByStr(String createByStr) { + this.createByStr = createByStr; + } + + public String getUpdateByStr() { + return updateByStr; + } + + public void setUpdateByStr(String updateByStr) { + this.updateByStr = updateByStr; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/po/ProjectRelationPo.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/po/ProjectRelationPo.java new file mode 100644 index 0000000000..d7648d0f4c --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/po/ProjectRelationPo.java @@ -0,0 +1,58 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.po; + + +public class ProjectRelationPo { + + private Long dssProjectId; + + private Long appInstanceId; + + private Long appInstanceProjectId; + + + public ProjectRelationPo(Long dssProjectId, Long appInstanceId, Long appInstanceProjectId) { + this.dssProjectId = dssProjectId; + this.appInstanceId = appInstanceId; + this.appInstanceProjectId = appInstanceProjectId; + } + + public Long getDssProjectId() { + return dssProjectId; + } + + public void setDssProjectId(Long dssProjectId) { + this.dssProjectId = dssProjectId; + } + + public Long getAppInstanceId() { + return appInstanceId; + } + + public void setAppInstanceId(Long appInstanceId) { + this.appInstanceId = appInstanceId; + } + + public Long getAppInstanceProjectId() { + return appInstanceProjectId; + } + + public void setAppInstanceProjectId(Long appInstanceProjectId) { + this.appInstanceProjectId = appInstanceProjectId; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ForbiddenFlowRequest.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ForbiddenFlowRequest.java new file mode 100644 index 0000000000..91e7eff88d --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ForbiddenFlowRequest.java @@ -0,0 +1,79 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.request; + +import javax.validation.constraints.NotNull; +import javax.xml.bind.annotation.XmlRootElement; + + +@XmlRootElement +public class ForbiddenFlowRequest { + + @NotNull(message = "编排模式Id不能为空") + private Long orchestratorId; + + @NotNull(message = "工程id不能为空") + private Long projectId; + + @NotNull(message = "禁用标示不能为空") + private String activeFlag; + + @NotNull(message = "工作流名称不能为空") + private String orchestratorName; + + public Long getProjectId() { + return projectId; + } + + public void setProjectId(Long projectId) { + this.projectId = projectId; + } + + public String getOrchestratorName() { + return orchestratorName; + } + + public void setOrchestratorName(String orchestratorName) { + this.orchestratorName = orchestratorName; + } + + public String getActiveFlag() { + return activeFlag; + } + + public void setActiveFlag(String activeFlag) { + this.activeFlag = activeFlag; + } + + public Long getOrchestratorId() { + return orchestratorId; + } + + public void setOrchestratorId(Long orchestratorId) { + this.orchestratorId = orchestratorId; + } + + @Override + public String toString() { + return "ForbiddenFlowRequest{" + + "orchestratorId=" + orchestratorId + + ", projectId=" + projectId + + ", activeFlag='" + activeFlag + '\'' + + ", orchestratorName='" + orchestratorName + '\'' + + '}'; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorCreateRequest.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorCreateRequest.java new file mode 100644 index 0000000000..9fbd697d4a --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorCreateRequest.java @@ -0,0 +1,161 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.request; + +import com.webank.wedatasphere.dss.framework.project.entity.vo.LabelRouteVo; + +import javax.validation.constraints.NotNull; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + + +@XmlRootElement +public class OrchestratorCreateRequest { + + @NotNull(message = "workspaceId不能为空") + private Long workspaceId; + + @NotNull(message = "工程id不能为空") + private Long projectId; + + @NotNull(message = "编排名称不能为空") + private String orchestratorName; + + /** + * 编排模式,如工作流,组合编排等 + */ + @NotNull(message = "编排模式类型不能为空") + private String orchestratorMode; + + /** + * 编排方式 + */ + @NotNull(message = "编排方式不能为空") + private List orchestratorWays; + + /** + * 编排用途 + */ + private String uses; + + @NotNull(message = "描述不能为空") + private String description; + + + private String projectName; + + private String workspaceName; + + /** + * labels是通过前端进行传入的,主要是用来进行当前的环境信息 + */ + private LabelRouteVo labels; + + public Long getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Long workspaceId) { + this.workspaceId = workspaceId; + } + + public Long getProjectId() { + return projectId; + } + + public void setProjectId(Long projectId) { + this.projectId = projectId; + } + + public String getOrchestratorName() { + return orchestratorName; + } + + public void setOrchestratorName(String orchestratorName) { + this.orchestratorName = orchestratorName; + } + + public String getOrchestratorMode() { + return orchestratorMode; + } + + public void setOrchestratorMode(String orchestratorMode) { + this.orchestratorMode = orchestratorMode; + } + + public List getOrchestratorWays() { + return orchestratorWays; + } + + public void setOrchestratorWays(List orchestratorWays) { + this.orchestratorWays = orchestratorWays; + } + + public String getUses() { + return uses; + } + + public void setUses(String uses) { + this.uses = uses; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public LabelRouteVo getLabels() { + return labels; + } + + public void setLabels(LabelRouteVo labels) { + this.labels = labels; + } + + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public String getWorkspaceName() { + return workspaceName; + } + + public void setWorkspaceName(String workspaceName) { + this.workspaceName = workspaceName; + } + + @Override + public String toString() { + return "OrchestratorCreateRequest{" + + "workspaceId=" + workspaceId + + ", projectId=" + projectId + + ", arrangeName='" + orchestratorName + '\'' + + ", arrangeMode='" + orchestratorMode + '\'' + + ", arrangeWays=" + orchestratorWays + + ", uses='" + uses + '\'' + + ", description='" + description + '\'' + + ", labels=" + labels + + '}'; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorDeleteRequest.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorDeleteRequest.java new file mode 100644 index 0000000000..15f79847c9 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorDeleteRequest.java @@ -0,0 +1,74 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.request; + +import com.webank.wedatasphere.dss.framework.project.entity.vo.LabelRouteVo; + +import javax.validation.constraints.NotNull; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + + +@XmlRootElement +public class OrchestratorDeleteRequest { + + @NotNull(message = "id不能为空") + private Long id; + + @NotNull(message = "workspaceId不能为空") + private Long workspaceId; + + @NotNull(message = "工程id不能为空") + private Long projectId; + + /** + * dssLabels是通过前端进行传入的,主要是用来进行当前的环境信息 + */ + private LabelRouteVo labels; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Long workspaceId) { + this.workspaceId = workspaceId; + } + + public Long getProjectId() { + return projectId; + } + + public void setProjectId(Long projectId) { + this.projectId = projectId; + } + + public LabelRouteVo getLabels() { + return labels; + } + + public void setLabels(LabelRouteVo labels) { + this.labels = labels; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorModifyRequest.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorModifyRequest.java new file mode 100644 index 0000000000..2a8a9c9e3c --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorModifyRequest.java @@ -0,0 +1,152 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.request; + +import com.webank.wedatasphere.dss.framework.project.entity.vo.LabelRouteVo; + +import javax.validation.constraints.NotNull; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + + +@XmlRootElement +public class OrchestratorModifyRequest { + + @NotNull(message = "id不能为空") + private Long id; + + @NotNull(message = "workspaceId不能为空") + private Long workspaceId; + + @NotNull(message = "工程id不能为空") + private Long projectId; + + @NotNull(message = "编排名称不能为空") + private String orchestratorName; + + /** + * 编排模式,如工作流,组合编排等 + */ + @NotNull(message = "编排模式不能为空") + private String orchestratorMode; + + /** + * 编排方式 + */ + @NotNull(message = "编排方式不能为空") + private List orchestratorWays; + + /** + * 编排用途 + */ + private String uses; + + @NotNull(message = "描述不能为空") + private String description; + + /** + * labels是通过前端进行传入的,主要是用来进行当前的环境信息 + */ + private LabelRouteVo labels; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Long workspaceId) { + this.workspaceId = workspaceId; + } + + public Long getProjectId() { + return projectId; + } + + public void setProjectId(Long projectId) { + this.projectId = projectId; + } + + public String getOrchestratorName() { + return orchestratorName; + } + + public void setOrchestratorName(String orchestratorName) { + this.orchestratorName = orchestratorName; + } + + public String getOrchestratorMode() { + return orchestratorMode; + } + + public void setOrchestratorMode(String orchestratorMode) { + this.orchestratorMode = orchestratorMode; + } + + public List getOrchestratorWays() { + return orchestratorWays; + } + + public void setOrchestratorWays(List orchestratorWays) { + this.orchestratorWays = orchestratorWays; + } + + public String getUses() { + return uses; + } + + public void setUses(String uses) { + this.uses = uses; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public LabelRouteVo getLabels() { + return labels; + } + + public void setLabels(LabelRouteVo labels) { + this.labels = labels; + } + + @Override + public String toString() { + return "OrchestratorModifyRequest{" + + "id=" + id + + ", workspaceId=" + workspaceId + + ", projectId=" + projectId + + ", orchestratorName='" + orchestratorName + '\'' + + ", orchestratorMode='" + orchestratorMode + '\'' + + ", orchestratorWays=" + orchestratorWays + + ", uses='" + uses + '\'' + + ", description='" + description + '\'' + + ", labels=" + labels + + '}'; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorRequest.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorRequest.java new file mode 100644 index 0000000000..235e5485d7 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/OrchestratorRequest.java @@ -0,0 +1,83 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.request; + +import javax.validation.constraints.NotNull; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + + +@XmlRootElement +public class OrchestratorRequest { + + private Long id; + + @NotNull(message = "workspaceId不能为空") + private Long workspaceId; + + @NotNull(message = "工程id不能为空") + private Long projectId; + + /** + * 编排类型,如工作流,组合编排等 + */ + // @NotNull(message = "编排类型不能为空") + private String orchestratorMode; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Long workspaceId) { + this.workspaceId = workspaceId; + } + + public Long getProjectId() { + return projectId; + } + + public void setProjectId(Long projectId) { + this.projectId = projectId; + } + + public String getOrchestratorMode() { + return orchestratorMode; + } + + public void setOrchestratorMode(String orchestratorMode) { + this.orchestratorMode = orchestratorMode; + } + + @Override + public String toString() { + return "OrchestratorRequest{" + + "id=" + id + + ", workspaceId=" + workspaceId + + ", projectId=" + projectId + + ", orchestratorMode='" + orchestratorMode + '\'' + + '}'; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectCreateRequest.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectCreateRequest.java new file mode 100644 index 0000000000..4d9710881d --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectCreateRequest.java @@ -0,0 +1,160 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.request; + +import javax.validation.constraints.NotNull; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + + +@XmlRootElement +public class ProjectCreateRequest { + + @NotNull(message = "工程名称不能为空") + private String name; + + @NotNull(message = "应用领域不能为空") + private Integer applicationArea; + + private String business; + + //产品 + private String product; + + private List releaseUsers; + + private List editUsers; + + private List accessUsers; + + @NotNull(message = "工程描述不能为空") + private String description; + + /** + * 工作空间名,因为是全局唯一的 + */ + @NotNull(message = "workspaceId不能为空") + private Long workspaceId; + + private String workspaceName; + /** + * 开发流程 list + */ + private List devProcessList; + + /** + * 编码模式 list + */ + private List orchestratorModeList; + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getApplicationArea() { + return applicationArea; + } + + public void setApplicationArea(Integer applicationArea) { + this.applicationArea = applicationArea; + } + + public String getBusiness() { + return business; + } + + public void setBusiness(String business) { + this.business = business; + } + + public String getProduct() { + return product; + } + + public void setProduct(String product) { + this.product = product; + } + + public List getReleaseUsers() { + return releaseUsers; + } + + public void setReleaseUsers(List releaseUsers) { + this.releaseUsers = releaseUsers; + } + + public List getEditUsers() { + return editUsers; + } + + public void setEditUsers(List editUsers) { + this.editUsers = editUsers; + } + + public List getAccessUsers() { + return accessUsers; + } + + public void setAccessUsers(List accessUsers) { + this.accessUsers = accessUsers; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Long getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Long workspaceId) { + this.workspaceId = workspaceId; + } + + public String getWorkspaceName() { + return workspaceName; + } + + public void setWorkspaceName(String workspaceName) { + this.workspaceName = workspaceName; + } + + public List getDevProcessList() { + return devProcessList; + } + + public void setDevProcessList(List devProcessList) { + this.devProcessList = devProcessList; + } + + public List getOrchestratorModeList() { + return orchestratorModeList; + } + + public void setOrchestratorModeList(List orchestratorModeList) { + this.orchestratorModeList = orchestratorModeList; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectDeleteRequest.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectDeleteRequest.java new file mode 100644 index 0000000000..031521267d --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectDeleteRequest.java @@ -0,0 +1,67 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.request; + +import javax.validation.constraints.NotNull; +import javax.xml.bind.annotation.XmlRootElement; + + +@XmlRootElement +public class ProjectDeleteRequest { + + @NotNull(message = "工程id不能为空") + private Long id; + + @NotNull(message = "确认不能为空") + private boolean sure; + + @NotNull(message = "同步删除其它系统工程不能为空") + private boolean ifDelOtherSys; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public boolean isSure() { + return sure; + } + + public void setSure(boolean sure) { + this.sure = sure; + } + + public boolean isIfDelOtherSys() { + return ifDelOtherSys; + } + + public void setIfDelOtherSys(boolean ifDelOtherSys) { + this.ifDelOtherSys = ifDelOtherSys; + } + + @Override + public String toString() { + return "ProjectDeleteRequest{" + + "id=" + id + + ", sure=" + sure + + ", ifDelOtherSys=" + ifDelOtherSys + + '}'; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectModifyRequest.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectModifyRequest.java new file mode 100644 index 0000000000..655e63c381 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectModifyRequest.java @@ -0,0 +1,184 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.request; + +import javax.validation.constraints.NotNull; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + + +@XmlRootElement +public class ProjectModifyRequest { + + + @NotNull(message = "工程名称不能为空") + private String name; + + @NotNull(message = "工程id不能为空") + private Long id; + + @NotNull(message = "应用领域不能为空") + private String applicationArea; + + //业务 + private String business; + + //编辑权限用户 + private List editUsers; + + //查看权限用户 + private List accessUsers; + + //发布权限用户 + private List releaseUsers; + + @NotNull(message = "工程描述不能为空") + private String description; + + //产品 + private String product; + + /** + * 工作空间名,因为是全局唯一的 + */ + @NotNull(message = "workspaceId不能为空") + private Long workspaceId; + + /* + 开发流程 code list + */ + private List devProcessList; + + /** + * 编排模式 code list + */ + private List orchestratorModeList; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getApplicationArea() { + return applicationArea; + } + + public void setApplicationArea(String applicationArea) { + this.applicationArea = applicationArea; + } + + public String getBusiness() { + return business; + } + + public void setBusiness(String business) { + this.business = business; + } + + public List getEditUsers() { + return editUsers; + } + + public void setEditUsers(List editUsers) { + this.editUsers = editUsers; + } + + public List getAccessUsers() { + return accessUsers; + } + + public void setAccessUsers(List accessUsers) { + this.accessUsers = accessUsers; + } + + public List getReleaseUsers() { + return releaseUsers; + } + + public void setReleaseUsers(List releaseUsers) { + this.releaseUsers = releaseUsers; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getProduct() { + return product; + } + + public void setProduct(String product) { + this.product = product; + } + + public Long getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Long workspaceId) { + this.workspaceId = workspaceId; + } + + public List getDevProcessList() { + return devProcessList; + } + + public void setDevProcessList(List devProcessList) { + this.devProcessList = devProcessList; + } + + public List getOrchestratorModeList() { + return orchestratorModeList; + } + + public void setOrchestratorModeList(List orchestratorModeList) { + this.orchestratorModeList = orchestratorModeList; + } + + @Override + public String toString() { + return "ProjectModifyRequest{" + + "name='" + name + '\'' + + ", id=" + id + + ", applicationArea='" + applicationArea + '\'' + + ", business='" + business + '\'' + + ", editUsers=" + editUsers + + ", accessUsers=" + accessUsers + + ", releaseUsers=" + releaseUsers + + ", description='" + description + '\'' + + ", product='" + product + '\'' + + ", workspaceId=" + workspaceId + + ", devProcessList=" + devProcessList + + ", orchestratorModeList=" + orchestratorModeList + + '}'; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectQueryRequest.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectQueryRequest.java new file mode 100644 index 0000000000..b0147415ae --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/ProjectQueryRequest.java @@ -0,0 +1,59 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.request; + +import javax.validation.constraints.NotNull; +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; + + +@XmlRootElement +public class ProjectQueryRequest implements Serializable { + + private static final long serialVersionUID=1L; + + private Long id; + + @NotNull(message = "workspaceId不能为空") + private Long workspaceId; + + private String username; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Long workspaceId) { + this.workspaceId = workspaceId; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/RemoveFlowRequest.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/RemoveFlowRequest.java new file mode 100644 index 0000000000..d1f7cfd83b --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/request/RemoveFlowRequest.java @@ -0,0 +1,67 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.request; + +import javax.validation.constraints.NotNull; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + + +@XmlRootElement +public class RemoveFlowRequest { + + private Long orchestratorId; + + @NotNull(message = "工程id不能为空") + private Long projectId; + + @NotNull(message = "工作流名称不能为空") + private String orchestratorName; + + public Long getProjectId() { + return projectId; + } + + public void setProjectId(Long projectId) { + this.projectId = projectId; + } + + public String getOrchestratorName() { + return orchestratorName; + } + + public void setOrchestratorName(String orchestratorName) { + this.orchestratorName = orchestratorName; + } + + public Long getOrchestratorId() { + return orchestratorId; + } + + public void setOrchestratorId(Long orchestratorId) { + this.orchestratorId = orchestratorId; + } + + @Override + public String toString() { + return "RemoveFlowRequest{" + + "orchestratorId=" + orchestratorId + + ", projectId=" + projectId + + ", orchestratorName='" + orchestratorName + '\'' + + '}'; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/response/ProjectResponse.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/response/ProjectResponse.java new file mode 100644 index 0000000000..9344ee01c3 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/response/ProjectResponse.java @@ -0,0 +1,222 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.response; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + + +public class ProjectResponse implements Serializable { + private static final long serialVersionUID=1L; + //工程id + private Long id; + //应用领域 + private Integer applicationArea; + //业务 + private String business; + //创建人 + private String createBy; + //工程描述 + private String description; + //工程名称 + private String name; + // + private String source; + //产品 + private String product; + private Boolean isArchive; + //工程创建时间 + private Date createTime; + //工程修改时间 + private Date updateTime; + + /** + * 发布用户 list + */ + private List releaseUsers; + + /** + * 编辑用户 list + */ + private List editUsers; + + /** + * 查看用户 list + */ + private List accessUsers; + + /** + * 开发流程 list + */ + private List devProcessList; + + /** + * 编码模式 list + */ + private List orchestratorModeList; + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Integer getApplicationArea() { + return applicationArea; + } + + public void setApplicationArea(Integer applicationArea) { + this.applicationArea = applicationArea; + } + + public String getBusiness() { + return business; + } + + public void setBusiness(String business) { + this.business = business; + } + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getProduct() { + return product; + } + + public void setProduct(String product) { + this.product = product; + } + + public Boolean getArchive() { + return isArchive; + } + + public void setArchive(Boolean archive) { + isArchive = archive; + } + + public List getReleaseUsers() { + return releaseUsers; + } + + public void setReleaseUsers(List releaseUsers) { + this.releaseUsers = releaseUsers; + } + + public List getEditUsers() { + return editUsers; + } + + public void setEditUsers(List editUsers) { + this.editUsers = editUsers; + } + + public List getAccessUsers() { + return accessUsers; + } + + public void setAccessUsers(List accessUsers) { + this.accessUsers = accessUsers; + } + + public List getDevProcessList() { + return devProcessList; + } + + public void setDevProcessList(List devProcessList) { + this.devProcessList = devProcessList; + } + + public List getOrchestratorModeList() { + return orchestratorModeList; + } + + public void setOrchestratorModeList(List orchestratorModeList) { + this.orchestratorModeList = orchestratorModeList; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + @Override + public String toString() { + return "ResponseProjectVo{" + + "id=" + id + + ", applicationArea=" + applicationArea + + ", business='" + business + '\'' + + ", createBy='" + createBy + '\'' + + ", description='" + description + '\'' + + ", name='" + name + '\'' + + ", source='" + source + '\'' + + ", product='" + product + '\'' + + ", isArchive=" + isArchive + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + ", releaseUsers=" + releaseUsers + + ", editUsers=" + editUsers + + ", accessUsers=" + accessUsers + + ", devProcessList=" + devProcessList + + ", orchestratorModeList=" + orchestratorModeList + + '}'; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/AbstractOrchestratorVo.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/AbstractOrchestratorVo.java new file mode 100644 index 0000000000..5a32ef18f8 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/AbstractOrchestratorVo.java @@ -0,0 +1,48 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.vo; + + +public abstract class AbstractOrchestratorVo { + + final static String WORK_FLOW = "workflow"; + + final static String ORDINARY = "ordinary"; + + private Long orchestratorId; + + private String orchestratorVersion; + + public Long getOrchestratorId() { + return orchestratorId; + } + + public void setOrchestratorId(Long orchestratorId) { + this.orchestratorId = orchestratorId; + } + + public String getOrchestratorVersion() { + return orchestratorVersion; + } + + public void setOrchestratorVersion(String orchestratorVersion) { + this.orchestratorVersion = orchestratorVersion; + } + + abstract String getType(); + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/CommonOrchestratorVo.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/CommonOrchestratorVo.java new file mode 100644 index 0000000000..93700f75a1 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/CommonOrchestratorVo.java @@ -0,0 +1,26 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.vo; + + +public class CommonOrchestratorVo extends AbstractOrchestratorVo{ + + @Override + String getType() { + return WORK_FLOW; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/DSSFlowOrchestratorFlowVo.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/DSSFlowOrchestratorFlowVo.java new file mode 100644 index 0000000000..fa231af966 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/DSSFlowOrchestratorFlowVo.java @@ -0,0 +1,86 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.vo; + +import java.util.List; + + +public class DSSFlowOrchestratorFlowVo { + + private Integer orchestratorId; + + private String orchestratorVersion; + + /** + * flowId 传递到前端让前端使用进行工作流的渲染 + */ + private String flowId; + + private String description; + + private String name; + + private List tags; + + public Integer getOrchestratorId() { + return orchestratorId; + } + + public void setOrchestratorId(Integer orchestratorId) { + this.orchestratorId = orchestratorId; + } + + public String getOrchestratorVersion() { + return orchestratorVersion; + } + + public void setOrchestratorVersion(String orchestratorVersion) { + this.orchestratorVersion = orchestratorVersion; + } + + public String getFlowId() { + return flowId; + } + + public void setFlowId(String flowId) { + this.flowId = flowId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/DSSProjectDetailVo.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/DSSProjectDetailVo.java new file mode 100644 index 0000000000..cf5a850334 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/DSSProjectDetailVo.java @@ -0,0 +1,109 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.vo; + +import java.util.List; + + + +public class DSSProjectDetailVo extends DSSProjectVo { + + /** + * 发布用户 list + */ + private List releaseUsers; + + /** + * 编辑用户 list + */ + private List editUsers; + + /** + * 查看用户 list + */ + private List accessUsers; + + /** + * 开发的模式,主要是工作流和应用工具 + */ + private String projectMode; + + /** + * 应用领域,不为空 + */ + private String applicationArea; + + + /** + * 使用业务 + */ + private String business; + + + private String description; + + + public List getEditUsers() { + return editUsers; + } + + public void setEditUsers(List editUsers) { + this.editUsers = editUsers; + } + + public List getAccessUsers() { + return accessUsers; + } + + public void setAccessUsers(List accessUsers) { + this.accessUsers = accessUsers; + } + + public String getProjectMode() { + return projectMode; + } + + public void setProjectMode(String projectMode) { + this.projectMode = projectMode; + } + + public String getApplicationArea() { + return applicationArea; + } + + public void setApplicationArea(String applicationArea) { + this.applicationArea = applicationArea; + } + + public String getBusiness() { + return business; + } + + public void setBusiness(String business) { + this.business = business; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public void setDescription(String description) { + this.description = description; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/DSSProjectVo.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/DSSProjectVo.java new file mode 100644 index 0000000000..a7206d4526 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/DSSProjectVo.java @@ -0,0 +1,54 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.vo; + +import java.util.List; + + +public class DSSProjectVo { + + private Long id; + + private String name; + + private String description; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/LabelRouteVo.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/LabelRouteVo.java new file mode 100644 index 0000000000..621a99b2ba --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/LabelRouteVo.java @@ -0,0 +1,30 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.vo; + +public class LabelRouteVo { + + private String route; + + public String getRoute() { + return route; + } + + public void setRoute(String route) { + this.route = route; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/OrchestratorBaseInfo.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/OrchestratorBaseInfo.java new file mode 100644 index 0000000000..63a3e45f2c --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/OrchestratorBaseInfo.java @@ -0,0 +1,229 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.vo; + +import java.util.Date; +import java.util.List; + +public class OrchestratorBaseInfo { + /** + * 主键ID + */ + private Long id; + + /** + * 空间id + */ + private Long workspaceId; + + /** + * 工程id + */ + private Long projectId; + + /** + * 编排模式id(工作流,调用orchestrator服务返回的orchestratorId) + */ + private Long orchestratorId; + + /** + * 编排模式版本id(工作流,调用orchestrator服务返回的orchestratorVersionId) + */ + private Long orchestratorVersionId; + + /** + * 编排名称 + */ + private String orchestratorName; + + /** + * 编排模式,取得的值是dss_dictionary中的dic_key(parent_key=p_orchestratorment_mode) + */ + private String orchestratorMode; + + /** + * 编排方式 + */ + //private String orchestratorWay; + + /** + * 用途 + */ + private String uses; + + /** + * 描述 + */ + private String description; + + /** + * 创建人 + */ + private String createUser; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新人 + */ + private String updateUser; + + /** + * 更新时间 + */ + private Date updateTime; + + private List orchestratorWays; + + private boolean flowEditLockExist=false; + + /** + * 工程权限等级:0-查看,1-编辑,2-发布 + */ + private Integer priv; + + public Integer getPriv() { + return priv; + } + + public void setPriv(Integer priv) { + this.priv = priv; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Long workspaceId) { + this.workspaceId = workspaceId; + } + + public Long getProjectId() { + return projectId; + } + + public void setProjectId(Long projectId) { + this.projectId = projectId; + } + + public Long getOrchestratorId() { + return orchestratorId; + } + + public void setOrchestratorId(Long orchestratorId) { + this.orchestratorId = orchestratorId; + } + + public Long getOrchestratorVersionId() { + return orchestratorVersionId; + } + + public void setOrchestratorVersionId(Long orchestratorVersionId) { + this.orchestratorVersionId = orchestratorVersionId; + } + + public String getOrchestratorName() { + return orchestratorName; + } + + public void setOrchestratorName(String orchestratorName) { + this.orchestratorName = orchestratorName; + } + + public String getOrchestratorMode() { + return orchestratorMode; + } + + public void setOrchestratorMode(String orchestratorMode) { + this.orchestratorMode = orchestratorMode; + } + + public String getUses() { + return uses; + } + + public void setUses(String uses) { + this.uses = uses; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateUser() { + return createUser; + } + + public void setCreateUser(String createUser) { + this.createUser = createUser; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getUpdateUser() { + return updateUser; + } + + public void setUpdateUser(String updateUser) { + this.updateUser = updateUser; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public List getOrchestratorWays() { + return orchestratorWays; + } + + public void setOrchestratorWays(List orchestratorWays) { + this.orchestratorWays = orchestratorWays; + } + + public boolean isFlowEditLockExist() { + return flowEditLockExist; + } + + public void setFlowEditLockExist(boolean flowEditLockExist) { + this.flowEditLockExist = flowEditLockExist; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/OrdinaryOrchestratorVo.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/OrdinaryOrchestratorVo.java new file mode 100644 index 0000000000..4c643f8bbe --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/OrdinaryOrchestratorVo.java @@ -0,0 +1,26 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.vo; + + +public class OrdinaryOrchestratorVo extends AbstractOrchestratorVo{ + + @Override + String getType() { + return ORDINARY; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/ProcessNode.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/ProcessNode.java new file mode 100644 index 0000000000..094c32a852 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/ProcessNode.java @@ -0,0 +1,28 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.vo; + + +public interface ProcessNode { + + Integer getIndex(); + + String getName(); + + String getChName(); + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/ProjectInfoVo.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/ProjectInfoVo.java new file mode 100644 index 0000000000..abe420c482 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/ProjectInfoVo.java @@ -0,0 +1,61 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.vo; + +import java.io.Serializable; + + +public class ProjectInfoVo implements Serializable { + + private static final long serialVersionUID=1L; + private Long id; + private Long workspaceId; + private String projectName; + private String workspaceName; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Long workspaceId) { + this.workspaceId = workspaceId; + } + + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public String getWorkspaceName() { + return workspaceName; + } + + public void setWorkspaceName(String workspaceName) { + this.workspaceName = workspaceName; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/QueryProjectVo.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/QueryProjectVo.java new file mode 100644 index 0000000000..687b6d3617 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/entity/vo/QueryProjectVo.java @@ -0,0 +1,165 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.entity.vo; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + + +public class QueryProjectVo implements Serializable { + + private static final long serialVersionUID=1L; + private Long id; + private Integer applicationArea; + private String business; + private String createBy; + private String description; + private String name; + private String source; + private String product; + private Boolean isArchive; + private Date createTime; + private Date updateTime; + + private String devProcess; + private String orchestratorMode; + private String pusername; + + private Integer visible; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Integer getApplicationArea() { + return applicationArea; + } + + public void setApplicationArea(Integer applicationArea) { + this.applicationArea = applicationArea; + } + + public String getBusiness() { + return business; + } + + public void setBusiness(String business) { + this.business = business; + } + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getProduct() { + return product; + } + + public void setProduct(String product) { + this.product = product; + } + + public Boolean getArchive() { + return isArchive; + } + + public void setArchive(Boolean archive) { + isArchive = archive; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getDevProcess() { + return devProcess; + } + + public void setDevProcess(String devProcess) { + this.devProcess = devProcess; + } + + public String getOrchestratorMode() { + return orchestratorMode; + } + + public void setOrchestratorMode(String orchestratorMode) { + this.orchestratorMode = orchestratorMode; + } + + public String getPusername() { + return pusername; + } + + public void setPusername(String pusername) { + this.pusername = pusername; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Integer getVisible() { + return visible; + } + + public void setVisible(Integer visible) { + this.visible = visible; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/exception/DSSProjectErrorException.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/exception/DSSProjectErrorException.java new file mode 100644 index 0000000000..9e291f489c --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/exception/DSSProjectErrorException.java @@ -0,0 +1,30 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.exception; + +import com.webank.wedatasphere.linkis.common.exception.ErrorException; + + +public class DSSProjectErrorException extends ErrorException { + + public DSSProjectErrorException(int errorCode, String errorDesc){ + super(errorCode, errorDesc); + } + + + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/exception/DSSProjectWarnException.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/exception/DSSProjectWarnException.java new file mode 100644 index 0000000000..175271ab66 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/exception/DSSProjectWarnException.java @@ -0,0 +1,29 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.exception; + +import com.webank.wedatasphere.linkis.common.exception.WarnException; + + +public class DSSProjectWarnException extends WarnException { + public DSSProjectWarnException(int errorCode, String errorDesc){ + super(errorCode, errorDesc); + } + + + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/exception/LambdaWarnException.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/exception/LambdaWarnException.java new file mode 100644 index 0000000000..f14debcd0f --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/exception/LambdaWarnException.java @@ -0,0 +1,28 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.exception; + + +public class LambdaWarnException extends DSSProjectWarnException { + + + public LambdaWarnException(int errorCode, String errorDesc) { + super(errorCode, errorDesc); + } + + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/restful/DSSFrameworkOrchestratorRestful.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/restful/DSSFrameworkOrchestratorRestful.java new file mode 100644 index 0000000000..6591dad5e2 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/restful/DSSFrameworkOrchestratorRestful.java @@ -0,0 +1,149 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.restful; + +import com.webank.wedatasphere.dss.framework.common.utils.RestfulUtils; +import com.webank.wedatasphere.dss.framework.project.dao.DSSProjectMapper; +import com.webank.wedatasphere.dss.framework.project.entity.request.*; +import com.webank.wedatasphere.dss.framework.project.entity.vo.CommonOrchestratorVo; +import com.webank.wedatasphere.dss.framework.project.service.DSSFrameworkOrchestratorService; +import com.webank.wedatasphere.dss.framework.project.service.DSSOrchestratorService; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.dss.standard.sso.utils.SSOHelper; +import com.webank.wedatasphere.linkis.server.security.SecurityFilter; +import org.apache.commons.math3.util.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + + +@Component +@Path("/dss/framework/project") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class DSSFrameworkOrchestratorRestful { + + + private static final Logger LOGGER = LoggerFactory.getLogger(DSSFrameworkOrchestratorRestful.class); + + @Autowired + private DSSFrameworkOrchestratorService dssFrameworkOrchestratorService; + @Autowired + private DSSOrchestratorService orchestratorService; + + @Autowired + private DSSProjectMapper projectMapper; + + /** + * 创建编排模式 + * + * @param httpServletRequest + * @param createRequest + * @return + */ + @POST + @Path("createOrchestrator") + public Response createOrchestrator(@Context HttpServletRequest httpServletRequest, @Valid OrchestratorCreateRequest createRequest) { + String username = SecurityFilter.getLoginUsername(httpServletRequest); + Workspace workspace = SSOHelper.getWorkspace(httpServletRequest); + LOGGER.info("workspace is {}", workspace.getWorkspaceName()); + try { + //保存编排模式 + //todo 先注释掉 + // orchestratorService.saveOrchestrator(createRequest,null,username); + // return RestfulUtils.dealOk("创建工作流编排模式成功", new Pair<>("orchestratorId", 1L)); + CommonOrchestratorVo orchestratorVo = dssFrameworkOrchestratorService.createOrchestrator(username, createRequest, workspace); + return RestfulUtils.dealOk("创建工作流编排模式成功", new Pair<>("orchestratorId", orchestratorVo.getOrchestratorId())); + } catch (Exception e) { + LOGGER.error("Failed to create orchestrator {} for user {}", createRequest, username, e); + return RestfulUtils.dealError("创建工作流编排模式失败:" + e.getMessage()); + } + } + + /** + * 查询所有的编排模式 + * + * @param httpServletRequest + * @param orchestratorRequest + * @return + */ + @POST + @Path("getAllOrchestrator") + public Response getAllOrchestrator(@Context HttpServletRequest httpServletRequest, @Valid OrchestratorRequest orchestratorRequest) { + try { + String username = SecurityFilter.getLoginUsername(httpServletRequest); + return RestfulUtils.dealOk("获取编排模式成功", new Pair<>("page", orchestratorService.getListByPage(orchestratorRequest, username))); + } catch (Exception e) { + LOGGER.error("getAllOrchestratorError ", e); + return RestfulUtils.dealError("获取编排模式失败:" + e.getMessage()); + } + } + + /** + * 修改编排模式 + * + * @param httpServletRequest + * @param modifyRequest + * @return + */ + @POST + @Path("modifyOrchestrator") + public Response modifyOrchestrator(@Context HttpServletRequest httpServletRequest, @Valid OrchestratorModifyRequest modifyRequest) { + String username = SecurityFilter.getLoginUsername(httpServletRequest); + Workspace workspace = SSOHelper.getWorkspace(httpServletRequest); + LOGGER.info("workspace is {}", workspace.getWorkspaceName()); + try { + CommonOrchestratorVo orchestratorVo = dssFrameworkOrchestratorService.modifyOrchestrator(username, modifyRequest,workspace); + //保存编排模式 +// orchestratorService.updateOrchestrator(modifyRequest, username); + return RestfulUtils.dealOk("创建工作流编排模式成功", new Pair<>("orchestratorId", orchestratorVo.getOrchestratorId())); + } catch (Exception e) { + LOGGER.error("Failed to create orchestrator {} for user {}", modifyRequest, username, e); + return RestfulUtils.dealError("创建工作流编排模式失败:" + e.getMessage()); + } + } + + /** + * 删除编排模式 + * + * @param httpServletRequest + * @param deleteRequest + * @return + */ + @POST + @Path("deleteOrchestrator") + public Response deleteOrchestrator(@Context HttpServletRequest httpServletRequest, @Valid OrchestratorDeleteRequest deleteRequest) { + String username = SecurityFilter.getLoginUsername(httpServletRequest); + Workspace workspace = SSOHelper.getWorkspace(httpServletRequest); + LOGGER.info("workspace is {}", workspace.getWorkspaceName()); + try { + dssFrameworkOrchestratorService.deleteOrchestrator(username, deleteRequest,workspace); + return RestfulUtils.dealOk("删除工作流编排模式成功"); + } catch (Exception e) { + LOGGER.error("Failed to delete orchestrator {} for user {}", deleteRequest, username, e); + return RestfulUtils.dealError("删除工作流编排模式失败:" + e.getMessage()); + } + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/restful/DSSFrameworkProjectRestfulApi.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/restful/DSSFrameworkProjectRestfulApi.java new file mode 100644 index 0000000000..258e044554 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/restful/DSSFrameworkProjectRestfulApi.java @@ -0,0 +1,188 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.restful; + +import com.webank.wedatasphere.dss.common.utils.DSSCommonUtils; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectCreateRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectDeleteRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectModifyRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectQueryRequest; +import com.webank.wedatasphere.dss.framework.project.entity.response.ProjectResponse; +import com.webank.wedatasphere.dss.framework.project.entity.vo.DSSProjectVo; +import com.webank.wedatasphere.dss.framework.project.service.DSSFrameworkProjectService; +import com.webank.wedatasphere.dss.framework.project.service.DSSProjectService; +import com.webank.wedatasphere.dss.framework.project.utils.ApplicationArea; +import com.webank.wedatasphere.dss.framework.project.utils.RestfulUtils; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.dss.standard.sso.utils.SSOHelper; +import com.webank.wedatasphere.linkis.server.Message; +import com.webank.wedatasphere.linkis.server.security.SecurityFilter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.apache.commons.math3.util.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +@Component +@Path("/dss/framework/project") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class DSSFrameworkProjectRestfulApi { + private static final Logger LOGGER = LoggerFactory.getLogger(DSSFrameworkProjectRestfulApi.class); + @Autowired + DSSFrameworkProjectService dssFrameworkProjectService; + @Autowired + private DSSProjectService projectService; + + /** + * 获取所有工程或者单个工程 + * + * @param request + * @return + */ + @GET + @Path("getWorkSpaceStr") + public Response getWorkSpaceStr(@Context HttpServletRequest request) { + Workspace workspace = SSOHelper.getWorkspace(request); + Message message = Message.ok("").data("workspaceStr", DSSCommonUtils.COMMON_GSON.toJson(workspace)); + return Message.messageToResponse(message); + } + + /** + * 获取所有工程或者单个工程 + * + * @param request + * @param projectRequest + * @return + */ + @POST + @Path("getAllProjects") + public Response getAllProjects(@Context HttpServletRequest request, @Valid ProjectQueryRequest projectRequest) { + String username = SecurityFilter.getLoginUsername(request); + projectRequest.setUsername(username); + List dssProjectVos = projectService.getListByParam(projectRequest); + Message message = Message.ok("获取工作空间的工程成功").data("projects", dssProjectVos); + return Message.messageToResponse(message); + } + + /** + * 新建工程,通过和各个AppConn进行交互,将需要满足工程规范的所有的appconn进行创建工程 + */ + @POST + @Path("createProject") + public Response createProject(@Context HttpServletRequest request, @Valid ProjectCreateRequest projectCreateRequest) { + String username = SecurityFilter.getLoginUsername(request); + Workspace workspace = SSOHelper.getWorkspace(request); + try { + DSSProjectVo dssProjectVo = dssFrameworkProjectService.createProject(projectCreateRequest, username, workspace); + if (dssProjectVo != null) { + return Message.messageToResponse(Message.ok("创建工程成功").data("project", dssProjectVo)); + } else { + return Message.messageToResponse(Message.error("创建工程失败")); + } + } catch (final Throwable t) { + LOGGER.error("failed to create project {} for user {}", projectCreateRequest.getName(), username, t); + return RestfulUtils.dealError("创建工程失败:" + t.getMessage()); + } + } + + /** + * 编辑工程 + * + * @param request + * @param projectModifyRequest + * @return + */ + @POST + @Path("modifyProject") + public Response modifyProject(@Context HttpServletRequest request, @Valid ProjectModifyRequest projectModifyRequest) { + String username = SecurityFilter.getLoginUsername(request); + try { + dssFrameworkProjectService.modifyProject(projectModifyRequest, username); + return Message.messageToResponse(Message.ok("修改工程成功")); + } catch (Exception e) { + LOGGER.error("Failed to modify project {} for user {}", projectModifyRequest.getName(), username, e); + return RestfulUtils.dealError("修改工程失败:" + e.getMessage()); + } + } + + /** + * 删除工程 + * + * @param request + * @param projectDeleteRequest + * @return + */ + @POST + @Path("deleteProject") + public Response deleteProject(@Context HttpServletRequest request, @Valid ProjectDeleteRequest projectDeleteRequest) { + String username = SecurityFilter.getLoginUsername(request); + Workspace workspace = SSOHelper.getWorkspace(request); + try{ + projectService.deleteProject(username, projectDeleteRequest, workspace); + return RestfulUtils.dealOk("删除工程成功"); + }catch(final Throwable t){ + LOGGER.error("Failed to delete {} for user {}", projectDeleteRequest, username); + return RestfulUtils.dealError("删除工程失败"); + } + } + + @GET + @Path("/listApplicationAreas") + public Response listApplicationAreas(@Context HttpServletRequest req) { + String header = req.getHeader("Content-language").trim(); + ApplicationArea[] applicationAreas = ApplicationArea.values(); + List areas = new ArrayList<>(); + Arrays.stream(applicationAreas).forEach(item -> { + if ("zh-CN".equals(header)) { + areas.add(item.getName()); + } else { + areas.add(item.getEnName()); + } + }); + return Message.messageToResponse(Message.ok().data("applicationAreas", areas)); + } + + + @GET + @Path("/getProjectAbilities") + public Response getProjectAbilities(@Context HttpServletRequest request){ + //为了获取到此环境的能力,导入 导出 发布等 + String username = SecurityFilter.getLoginUsername(request); + try{ + List projectAbilities = projectService.getProjectAbilities(username); + return RestfulUtils.dealOk("获取工程能力成功", new Pair<>("projectAbilities", projectAbilities)); + }catch(final Throwable t){ + LOGGER.error("failed to get project ability for user {}", username, t); + return RestfulUtils.dealError("获取工程能力失败"); + } + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSFrameworkOrchestratorService.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSFrameworkOrchestratorService.java new file mode 100644 index 0000000000..a9618f4550 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSFrameworkOrchestratorService.java @@ -0,0 +1,40 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.service; + +import com.webank.wedatasphere.dss.framework.project.entity.request.OrchestratorCreateRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.OrchestratorDeleteRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.OrchestratorModifyRequest; +import com.webank.wedatasphere.dss.framework.project.entity.vo.CommonOrchestratorVo; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; + + +public interface DSSFrameworkOrchestratorService { + + + + CommonOrchestratorVo createOrchestrator(String username, OrchestratorCreateRequest orchestratorCreateRequest, Workspace workspace) throws Exception; + + + + CommonOrchestratorVo modifyOrchestrator(String username, OrchestratorModifyRequest orchestratorModifyRequest, Workspace workspace) throws Exception; + + + + CommonOrchestratorVo deleteOrchestrator(String username, OrchestratorDeleteRequest orchestratorDeleteRequest, Workspace workspace) throws Exception; + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSFrameworkProjectService.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSFrameworkProjectService.java new file mode 100644 index 0000000000..920e4ff410 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSFrameworkProjectService.java @@ -0,0 +1,39 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.service; + +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectCreateRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectModifyRequest; +import com.webank.wedatasphere.dss.framework.project.entity.vo.DSSProjectDetailVo; +import com.webank.wedatasphere.dss.framework.project.entity.vo.DSSProjectVo; +import com.webank.wedatasphere.dss.framework.project.entity.vo.ProcessNode; +import com.webank.wedatasphere.dss.framework.project.exception.DSSProjectErrorException; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; + +import java.util.List; + + +public interface DSSFrameworkProjectService { + + DSSProjectDetailVo getProjectSettings(Long projectId); + + + DSSProjectVo createProject(ProjectCreateRequest projectCreateRequest, String username, Workspace workspace) throws Exception; + + void modifyProject(ProjectModifyRequest projectModifyRequest, String username) throws Exception; + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSOrchestratorService.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSOrchestratorService.java new file mode 100644 index 0000000000..b397e358c1 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSOrchestratorService.java @@ -0,0 +1,55 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import java.util.*; + +import com.webank.wedatasphere.dss.framework.common.exception.DSSFrameworkErrorException; +import com.webank.wedatasphere.dss.framework.project.entity.*; +import com.webank.wedatasphere.dss.framework.project.entity.request.*; +import com.webank.wedatasphere.dss.framework.project.entity.vo.OrchestratorBaseInfo; +import com.webank.wedatasphere.dss.framework.project.exception.DSSProjectErrorException; +import com.webank.wedatasphere.dss.orchestrator.common.protocol.RequestProjectImportOrchestrator; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorCreateResponseRef; + + +public interface DSSOrchestratorService extends IService { + + + void saveOrchestrator(OrchestratorCreateRequest orchestratorCreateRequest, OrchestratorCreateResponseRef responseRef, String username) throws DSSFrameworkErrorException, DSSProjectErrorException; + + + void updateOrchestrator(OrchestratorModifyRequest orchestratorModifyRequest, String username) throws DSSFrameworkErrorException, DSSProjectErrorException; + + + List getListByPage(OrchestratorRequest orchestratorRequest, String username); + + + boolean deleteOrchestrator(OrchestratorDeleteRequest orchestratorDeleteRequest, String username) throws DSSProjectErrorException; + + + void isExistSameNameBeforeCreate(Long workspaceId, Long projectId, String orchestratorName) throws DSSFrameworkErrorException; + + + Long isExistSameNameBeforeUpdate(OrchestratorModifyRequest orchestratorModifRequest)throws DSSFrameworkErrorException; + + + DSSOrchestrator getOrchestratorById(Long id); + + Long importOrchestrator(RequestProjectImportOrchestrator orchestratorInfo) throws Exception; +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSProjectService.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSProjectService.java new file mode 100644 index 0000000000..6d1d02d845 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSProjectService.java @@ -0,0 +1,67 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.framework.project.entity.DSSProjectDO; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectCreateRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectDeleteRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectModifyRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectQueryRequest; +import com.webank.wedatasphere.dss.framework.project.entity.response.ProjectResponse; +import com.webank.wedatasphere.dss.framework.project.entity.vo.ProjectInfoVo; +import com.webank.wedatasphere.dss.framework.project.exception.DSSProjectErrorException; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo; +import com.webank.wedatasphere.dss.orchestrator.common.protocol.RequestProjectImportOrchestrator; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.dss.standard.common.desc.AppInstance; + +import java.util.List; +import java.util.Map; + +public interface DSSProjectService extends IService { + + + DSSProjectDO createProject(String username, ProjectCreateRequest projectCreateRequest); + + + void modifyProject(String username, ProjectModifyRequest modifyRequest) throws DSSProjectErrorException; + + + DSSProjectDO getProjectByName(String name); + + + DSSProjectDO getProjectById(Long id); + + + List getListByParam(ProjectQueryRequest projectRequest); + + + ProjectInfoVo getProjectInfoById(Long id); + + void saveProjectRelation(DSSProjectDO project, Map projectMap); + + Long getAppConnProjectId(Long dssProjectId, String appConnName, List dssLabels) throws Exception; + + void deleteProject(String username, ProjectDeleteRequest projectDeleteRequest, Workspace workspace) throws Exception; + + List getProjectAbilities(String username); + + + Long importOrchestrator(RequestProjectImportOrchestrator orchestratorInfo) throws Exception; +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSProjectUserService.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSProjectUserService.java new file mode 100644 index 0000000000..65b3b4e75f --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/DSSProjectUserService.java @@ -0,0 +1,46 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.service; + +import com.webank.wedatasphere.dss.framework.project.entity.DSSProjectDO; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectCreateRequest; +import com.webank.wedatasphere.dss.framework.project.entity.DSSProjectUser; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectModifyRequest; +import com.webank.wedatasphere.dss.framework.project.exception.DSSProjectErrorException; + +import java.util.List; + +public interface DSSProjectUserService { + + + boolean isEditProjectAuth(Long projectId,String username) throws DSSProjectErrorException; + + + List getEditProjectList(Long projectId, String username); + + + void saveProjectUser(Long projectID, String username, ProjectCreateRequest dssProjectCreateRequest)throws Exception; + + + void modifyProjectUser(DSSProjectDO dbProject, ProjectModifyRequest projectModifyRequest, String loginuser)throws Exception; + + + List getListByParam(Long workspaceId, String username); + + + boolean isAdminByUsername(Long workspaceId,String username); +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSFrameworkOrchestratorServiceImpl.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSFrameworkOrchestratorServiceImpl.java new file mode 100644 index 0000000000..54642b9584 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSFrameworkOrchestratorServiceImpl.java @@ -0,0 +1,295 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.service.impl; + + +import com.webank.wedatasphere.dss.appconn.core.ext.OnlyDevelopmentAppConn; +import com.webank.wedatasphere.dss.appconn.manager.AppConnManager; +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.common.label.EnvDSSLabel; +import com.webank.wedatasphere.dss.common.utils.DSSExceptionUtils; +import com.webank.wedatasphere.dss.framework.project.conf.ProjectConf; +import com.webank.wedatasphere.dss.framework.project.contant.OrchestratorTypeEnum; +import com.webank.wedatasphere.dss.framework.project.contant.ProjectServerResponse; +import com.webank.wedatasphere.dss.framework.project.dao.DSSOrchestratorMapper; +import com.webank.wedatasphere.dss.framework.project.entity.DSSOrchestrator; +import com.webank.wedatasphere.dss.framework.project.entity.request.OrchestratorCreateRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.OrchestratorDeleteRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.OrchestratorModifyRequest; +import com.webank.wedatasphere.dss.framework.project.entity.vo.CommonOrchestratorVo; +import com.webank.wedatasphere.dss.framework.project.entity.vo.ProjectInfoVo; +import com.webank.wedatasphere.dss.framework.project.exception.DSSProjectErrorException; +import com.webank.wedatasphere.dss.framework.project.service.DSSFrameworkOrchestratorService; +import com.webank.wedatasphere.dss.framework.project.service.DSSOrchestratorService; +import com.webank.wedatasphere.dss.framework.project.service.DSSProjectService; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo; +import com.webank.wedatasphere.dss.orchestrator.common.ref.DefaultOrchestratorCreateRequestRef; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorCreateRequestRef; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorCreateResponseRef; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorFrameworkAppConn; +import com.webank.wedatasphere.dss.orchestrator.common.ref.impl.WorkflowOrchestratoDeleteRequestRef; +import com.webank.wedatasphere.dss.orchestrator.common.ref.impl.WorkflowOrchestratorUpdateRequestRef; +import com.webank.wedatasphere.dss.orchestrator.core.type.OrchestratorKindEnum; +import com.webank.wedatasphere.dss.standard.app.development.operation.RefCreationOperation; +import com.webank.wedatasphere.dss.standard.app.development.operation.RefDeletionOperation; +import com.webank.wedatasphere.dss.standard.app.development.operation.RefUpdateOperation; +import com.webank.wedatasphere.dss.standard.app.development.ref.CommonResponseRef; +import com.webank.wedatasphere.dss.standard.app.development.service.RefCRUDService; +import com.webank.wedatasphere.dss.standard.app.development.standard.DevelopmentIntegrationStandard; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.dss.standard.common.desc.AppInstance; +import com.webank.wedatasphere.dss.standard.common.exception.operation.ExternalOperationFailedException; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +public class DSSFrameworkOrchestratorServiceImpl implements DSSFrameworkOrchestratorService { + + protected final Logger LOGGER = LoggerFactory.getLogger(getClass()); + + @Autowired + private DSSOrchestratorMapper orchestratorMapper; + @Autowired + private DSSOrchestratorService orchestratorService; + @Autowired + private DSSProjectService projectService; + + /** + * 1.拿到的dss orchestrator的appconn + * 2.然后创建 + * + * @param orchestratorCreateRequest 创建参数 + * @return + */ + @Override + @SuppressWarnings("ConstantConditions") + public CommonOrchestratorVo createOrchestrator(String username, OrchestratorCreateRequest orchestratorCreateRequest, + Workspace workspace) throws Exception { + //是否存在相同的编排名称 + orchestratorService.isExistSameNameBeforeCreate(orchestratorCreateRequest.getProjectId(),orchestratorCreateRequest.getWorkspaceId(),orchestratorCreateRequest.getOrchestratorName()); + //判断工程是否存在,并且取出工程名称和空间名称 + ProjectInfoVo projectInfoVo = projectService.getProjectInfoById(orchestratorCreateRequest.getProjectId()); + if (projectInfoVo == null) { + DSSExceptionUtils.dealErrorException(ProjectServerResponse.PROJECT_NOT_EXIST.getCode(), + ProjectServerResponse.PROJECT_NOT_EXIST.getMsg(), DSSProjectErrorException.class); + } + //1.去orchestratorFramework创建编排模式 + //2.将工程和orchestrator的关系存储到的数据库中 + LOGGER.info("{} begins to create a orchestrator {}", username, orchestratorCreateRequest); + //新建编排模式需要将编排模式的类型等内容提交给OrchestratorFramework + CommonOrchestratorVo orchestratorVo = new CommonOrchestratorVo(); + try { + OrchestratorKindEnum orchestratorKindEnum = OrchestratorKindEnum. + getType(OrchestratorTypeEnum.getTypeByKey(orchestratorCreateRequest.getOrchestratorMode())); + List dssLabels = Arrays.asList(new EnvDSSLabel(orchestratorCreateRequest.getLabels().getRoute())); + OrchestratorCreateRequestRef orchestratorCreateRequestRef = null; + String appconnName = "workflow"; + switch (orchestratorKindEnum) { + case WORKFLOW: + orchestratorCreateRequestRef = new DefaultOrchestratorCreateRequestRef(); + appconnName = "workflow"; + break; + case COMBINED: + appconnName = "combined"; + break; + case SINGLE_TASK: + appconnName = "singleTask"; + break; + default: + orchestratorCreateRequestRef = new DefaultOrchestratorCreateRequestRef(); + } + orchestratorCreateRequestRef.setUserName(username); + orchestratorCreateRequestRef.setDSSLabels(dssLabels); + orchestratorCreateRequestRef.setProjectId(orchestratorCreateRequest.getProjectId()); + orchestratorCreateRequestRef.setProjectName(StringUtils.isBlank(orchestratorCreateRequest.getProjectName()) ? projectInfoVo.getProjectName() : orchestratorCreateRequest.getProjectName()); + orchestratorCreateRequestRef.setWorkspaceName(StringUtils.isBlank(orchestratorCreateRequest.getWorkspaceName()) ? projectInfoVo.getWorkspaceName() : orchestratorCreateRequest.getWorkspaceName()); + DSSOrchestratorInfo dssOrchestratorInfo = new DSSOrchestratorInfo(); + dssOrchestratorInfo.setType(orchestratorKindEnum.getName()); + dssOrchestratorInfo.setDesc(orchestratorCreateRequest.getDescription()); + dssOrchestratorInfo.setCreateTime(new Date(System.currentTimeMillis())); + dssOrchestratorInfo.setAppConnName(appconnName); + dssOrchestratorInfo.setName(orchestratorCreateRequest.getOrchestratorName()); + dssOrchestratorInfo.setCreator(username); + dssOrchestratorInfo.setProjectId(orchestratorCreateRequest.getProjectId()); + dssOrchestratorInfo.setComment(orchestratorCreateRequest.getDescription()); + dssOrchestratorInfo.setSecondaryType(orchestratorCreateRequest.getOrchestratorWays().toString()); + orchestratorCreateRequestRef.setDssOrchestratorInfo(dssOrchestratorInfo); + //根据label获取对应label的创建operation + RefCreationOperation refCreationOperation = + getRefCreationOperation(dssLabels).getRefCreationOperation(); + //调用orchestrator服务 创建编排模式、编排模式版本 + OrchestratorCreateResponseRef responseRef =(OrchestratorCreateResponseRef) refCreationOperation.createRef(orchestratorCreateRequestRef); + LOGGER.info("operation ends to create ref, content is {}", responseRef.getContent()); + Long orchestratorId = responseRef.getOrcId(); + Long versionId = responseRef.getOrchestratorVersionId(); + LOGGER.info("orchestratorId is {}, and version is {}", orchestratorId, versionId); + orchestratorVo.setOrchestratorId(orchestratorId); + //保存编排模式到数据库 + orchestratorService.saveOrchestrator(orchestratorCreateRequest, responseRef, username); + } catch (final Exception e) { + DSSExceptionUtils.dealErrorException(60033, "failed to create orchestrator", e, DSSProjectErrorException.class); + } + return orchestratorVo; + } + + @Override + public CommonOrchestratorVo modifyOrchestrator(String username, OrchestratorModifyRequest orchestratorModifyRequest, Workspace workspace) throws Exception { + //判断工程是否存在,并且取出工程名称和空间名称 + ProjectInfoVo projectInfoVo = projectService.getProjectInfoById(orchestratorModifyRequest.getProjectId()); + if (projectInfoVo == null) { + DSSExceptionUtils.dealErrorException(ProjectServerResponse.PROJECT_NOT_EXIST.getCode(), + ProjectServerResponse.PROJECT_NOT_EXIST.getMsg(), DSSProjectErrorException.class); + } + //是否存在相同的编排名称 + Long orchestratorId = orchestratorService.isExistSameNameBeforeUpdate(orchestratorModifyRequest); + //1.去orchestratorFramework创建编排模式 + //2.将工程和orchestrator的关系存储到的数据库中 + LOGGER.info("{} begins to update a orchestrator {}", username, orchestratorModifyRequest); + //新建编排模式需要将编排模式的类型等内容提交给OrchestratorFramework + CommonOrchestratorVo orchestratorVo = new CommonOrchestratorVo(); + try { + OrchestratorKindEnum orchestratorKindEnum = OrchestratorKindEnum. + getType(OrchestratorTypeEnum.getTypeByKey(orchestratorModifyRequest.getOrchestratorMode())); + List dssLabels = Arrays.asList(new EnvDSSLabel(orchestratorModifyRequest.getLabels().getRoute())); + String appconnName = "workflow"; + WorkflowOrchestratorUpdateRequestRef orchestratorUpdateRequestRef = new WorkflowOrchestratorUpdateRequestRef(); + switch (orchestratorKindEnum) { + case COMBINED: + appconnName = "combined"; + break; + case SINGLE_TASK: + appconnName = "singleTask"; + break; + default: + appconnName = "workflow"; + orchestratorUpdateRequestRef = new WorkflowOrchestratorUpdateRequestRef(); + } + DSSOrchestratorInfo dssOrchestratorInfo = new DSSOrchestratorInfo(); + dssOrchestratorInfo.setId(orchestratorId); + dssOrchestratorInfo.setType(orchestratorKindEnum.getName()); + dssOrchestratorInfo.setDesc(orchestratorModifyRequest.getDescription()); + dssOrchestratorInfo.setCreateTime(new Date(System.currentTimeMillis())); + dssOrchestratorInfo.setAppConnName(appconnName); + dssOrchestratorInfo.setName(orchestratorModifyRequest.getOrchestratorName()); + dssOrchestratorInfo.setCreator(username); + dssOrchestratorInfo.setProjectId(orchestratorModifyRequest.getProjectId()); + dssOrchestratorInfo.setComment(orchestratorModifyRequest.getDescription()); + dssOrchestratorInfo.setSecondaryType(orchestratorModifyRequest.getOrchestratorWays().toString()); + String workspaceName = projectInfoVo.getWorkspaceName(); + + orchestratorUpdateRequestRef.setUserName(username); + orchestratorUpdateRequestRef.setWorkspaceName(workspaceName); + orchestratorUpdateRequestRef.setDssOrchestratorInfo(dssOrchestratorInfo); + orchestratorUpdateRequestRef.setDSSLabels(dssLabels); + + //根据label获取对应label的创建operation + RefUpdateOperation updateOperation = getRefCreationOperation(dssLabels).getRefUpdateOperation(); + //调用orchestrator服务 更新编排模式、编排模式版本 + LOGGER.info("----orchestratorUpdateRequestRef---> {}", orchestratorUpdateRequestRef); + CommonResponseRef responseRef = (CommonResponseRef)updateOperation.updateRef(orchestratorUpdateRequestRef); + LOGGER.info("operation ends to updateOrchestrator ref, UpdateResult is {},ErrorMsg is {}", responseRef.getResult(),responseRef.getErrorMsg()); + + //保存编排模式 + orchestratorService.updateOrchestrator(orchestratorModifyRequest, username); + } catch (final Exception e) { + DSSExceptionUtils.dealErrorException(60034, "failed to create orchestrator", e, DSSProjectErrorException.class); + } + return orchestratorVo; + } + + @Override + public CommonOrchestratorVo deleteOrchestrator(String username, OrchestratorDeleteRequest orchestratorDeleteRequest, Workspace workspace) throws Exception { + //判断工程是否存在,并且取出工程名称和空间名称 + ProjectInfoVo projectInfoVo = projectService.getProjectInfoById(orchestratorDeleteRequest.getProjectId()); + if (projectInfoVo == null) { + DSSExceptionUtils.dealErrorException(ProjectServerResponse.PROJECT_NOT_EXIST.getCode(), + ProjectServerResponse.PROJECT_NOT_EXIST.getMsg(), DSSProjectErrorException.class); + } + + DSSOrchestrator orchestrator = orchestratorService.getOrchestratorById(orchestratorDeleteRequest.getId()); + //1.去orchestratorFramework创建编排模式 + //2.将工程和orchestrator的关系存储到的数据库中 + LOGGER.info("{} begins to delete a orchestrator {}", username, orchestratorDeleteRequest); + //新建编排模式需要将编排模式的类型等内容提交给OrchestratorFramework + CommonOrchestratorVo orchestratorVo = new CommonOrchestratorVo(); + try { + String uuid = orchestratorMapper.getUUID(orchestrator.getOrchestratorId()); + if(StringUtils.isBlank(uuid)){ + DSSExceptionUtils.dealErrorException(60035,"工作流不存在", DSSProjectErrorException.class); + } + List dssLabels = Arrays.asList(new EnvDSSLabel(orchestratorDeleteRequest.getLabels().getRoute())); + WorkflowOrchestratoDeleteRequestRef orchestratorDeleteRequestRef = new WorkflowOrchestratoDeleteRequestRef(); + String workspaceName = projectInfoVo.getWorkspaceName(); + String projectName = projectInfoVo.getProjectName(); + orchestratorDeleteRequestRef.setUserName(username); + orchestratorDeleteRequestRef.setWorkspaceName(workspaceName); + orchestratorDeleteRequestRef.setProjectName(projectName); + orchestratorDeleteRequestRef.setDSSLabels(dssLabels); + orchestratorDeleteRequestRef.setOrcId(orchestrator.getOrchestratorId()); + RefDeletionOperation refDeletionOperation = + getRefCreationOperation(dssLabels).getRefDeletionOperation(); + + deleteOperation(refDeletionOperation, orchestratorDeleteRequestRef, uuid); + + //删除编排模式 + orchestratorService.deleteOrchestrator(orchestratorDeleteRequest, username); + } catch (final Exception e) { + DSSExceptionUtils.dealErrorException(60035, "failed to delete orchestrator", e, DSSProjectErrorException.class); + } + return orchestratorVo; + } + + protected void deleteOperation(RefDeletionOperation refDeletionOperation, + WorkflowOrchestratoDeleteRequestRef orchestratorDeleteRequestRef, String uuid) throws ExternalOperationFailedException { + //调用orchestrator服务 创建编排模式、编排模式版本 + refDeletionOperation.deleteRef(orchestratorDeleteRequestRef); + LOGGER.info("Operation deleteOrchestrator[DEV] for uuid {} success.", uuid); + } + + /** + * 获取更新的operation + * + * @param dssLabels 根据label获取对应label的创建operation + * todo 目前已经写死 + * @return + * @throws Exception + */ + public RefCRUDService getRefCreationOperation(List dssLabels) throws Exception { + OrchestratorFrameworkAppConn orcAppConn = AppConnManager.getAppConnManager().getAppConn(OrchestratorFrameworkAppConn.class); + + if (orcAppConn == null) { + LOGGER.error("orcAppConn is null, will not go on creating orchestrator"); + DSSExceptionUtils.dealErrorException(60028, "orcAppConn is null", DSSProjectErrorException.class); + } + + DevelopmentIntegrationStandard standard = ((OnlyDevelopmentAppConn)orcAppConn).getOrCreateDevelopmentStandard(); + if (standard == null) { + LOGGER.error("standard is null, will not go on creating orchestrator"); + DSSExceptionUtils.dealErrorException(60028, "standard is null", DSSProjectErrorException.class); + } + AppInstance appInstance = orcAppConn.getAppDesc().getAppInstancesByLabels(dssLabels).get(0); + + RefCRUDService service = standard.getRefCRUDService(appInstance); + return service; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSFrameworkProjectServiceImpl.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSFrameworkProjectServiceImpl.java new file mode 100644 index 0000000000..fd1f2b6bf8 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSFrameworkProjectServiceImpl.java @@ -0,0 +1,226 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.service.impl; + +import com.webank.wedatasphere.dss.appconn.core.AppConn; +import com.webank.wedatasphere.dss.appconn.core.ext.OnlyStructureAppConn; +import com.webank.wedatasphere.dss.appconn.manager.AppConnManager; +import com.webank.wedatasphere.dss.common.utils.DSSExceptionUtils; +import com.webank.wedatasphere.dss.framework.project.contant.ProjectServerResponse; +import com.webank.wedatasphere.dss.framework.project.entity.DSSProjectDO; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectCreateRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectModifyRequest; +import com.webank.wedatasphere.dss.framework.project.entity.vo.DSSProjectDetailVo; +import com.webank.wedatasphere.dss.framework.project.entity.vo.DSSProjectVo; +import com.webank.wedatasphere.dss.framework.project.exception.DSSProjectErrorException; +import com.webank.wedatasphere.dss.framework.project.exception.LambdaWarnException; +import com.webank.wedatasphere.dss.framework.project.service.DSSFrameworkProjectService; +import com.webank.wedatasphere.dss.framework.project.service.DSSProjectService; +import com.webank.wedatasphere.dss.framework.project.service.DSSProjectUserService; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.dss.standard.app.structure.StructureIntegrationStandard; +import com.webank.wedatasphere.dss.standard.app.structure.project.ProjectCreationOperation; +import com.webank.wedatasphere.dss.standard.app.structure.project.ProjectDeletionOperation; +import com.webank.wedatasphere.dss.standard.app.structure.project.ProjectRequestRef; +import com.webank.wedatasphere.dss.standard.app.structure.project.ProjectRequestRefImpl; +import com.webank.wedatasphere.dss.standard.app.structure.project.ProjectResponseRef; +import com.webank.wedatasphere.dss.standard.app.structure.project.ProjectService; +import com.webank.wedatasphere.dss.standard.app.structure.project.ProjectUpdateOperation; +import com.webank.wedatasphere.dss.standard.common.desc.AppInstance; +import com.webank.wedatasphere.dss.standard.common.exception.operation.ExternalOperationFailedException; +import com.webank.wedatasphere.linkis.common.conf.CommonVars; +import java.util.HashMap; +import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + + +@Component +public class DSSFrameworkProjectServiceImpl implements DSSFrameworkProjectService { + private static final Logger LOGGER = LoggerFactory.getLogger(DSSFrameworkProjectServiceImpl.class); + @Autowired + private DSSProjectService projectService; + @Autowired + private DSSProjectUserService projectUserService; + + public static final String MODE_SPLIT = ","; + + private static final boolean STRICT_PROJECT_CREATE_MODE = CommonVars.apply("wds.dss.project.strict.mode", false).getValue(); + + @Override + public DSSProjectDetailVo getProjectSettings(Long projectId) { + return null; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public DSSProjectVo createProject(ProjectCreateRequest projectCreateRequest, String username, Workspace workspace) throws Exception { + //1.新建DSS工程,这样才能进行回滚,如果后面去DSS工程,可能会由于DSS工程建立失败了,但是仍然无法去回滚第三方系统的工程 + //2.开始创建appconn的相关的工程,如果失败了,抛异常,然后进行数据库进行回滚 + + //判断工程是否存在相同的名称 + DSSProjectDO dbProject = projectService.getProjectByName(projectCreateRequest.getName()); + if (dbProject != null) { + DSSExceptionUtils.dealErrorException(60022, String.format("project name already has the same name %s ", projectCreateRequest.getName()), DSSProjectErrorException.class); + } + //todo 创建appconn的相关的工程 还没有调试通过 + Map projectMap = createAppConnProject(projectCreateRequest, username, workspace); + if (null == projectMap) { + LOGGER.error("projectMap is null, it means some appConns create project failed"); + throw new DSSProjectErrorException(71000, "projectMap is null, create project in appconn failed"); + } + //3.保存dss_project + DSSProjectDO project = projectService.createProject(username, projectCreateRequest); + //4.保存dss_project_user 工程与用户关系 + projectUserService.saveProjectUser(project.getId(), username, projectCreateRequest); + //5.保存dss工程与其他工程的对应关系,应该都是以id来作为标识 + if (null != projectMap && projectMap.size() > 0) { + projectService.saveProjectRelation(project, projectMap); + } + DSSProjectVo dssProjectVo = new DSSProjectVo(); + dssProjectVo.setDescription(project.getDescription()); + dssProjectVo.setId(project.getId()); + dssProjectVo.setName(project.getName()); + return dssProjectVo; + } + + + @Override + public void modifyProject(ProjectModifyRequest projectModifyRequest, String username) throws Exception { + DSSProjectDO dbProject = projectService.getProjectById(projectModifyRequest.getId()); + //如果不是工程的创建人,则校验是否管理员 + if (!username.equalsIgnoreCase(dbProject.getCreateBy())) { + boolean isAdmin = projectUserService.isAdminByUsername(projectModifyRequest.getWorkspaceId(), username); + //非管理员 + if (!isAdmin) { + DSSExceptionUtils.dealErrorException(ProjectServerResponse.PROJECT_IS_NOT_ADMIN.getCode(), ProjectServerResponse.PROJECT_IS_NOT_ADMIN.getMsg(), DSSProjectErrorException.class); + } + } + //工程不存在 + if (dbProject == null) { + LOGGER.error("{} project id is null, can not modify", projectModifyRequest.getName()); + DSSExceptionUtils.dealErrorException(60021, + String.format("%s project id is null, can not modify", projectModifyRequest.getName()), DSSProjectErrorException.class); + } + //不允许修改工程名称 + if (!dbProject.getName().toUpperCase().equals(projectModifyRequest.getName().toUpperCase())) { + DSSExceptionUtils.dealErrorException(ProjectServerResponse.PROJECT_NOT_EDIT_NAME.getCode(), ProjectServerResponse.PROJECT_NOT_EDIT_NAME.getMsg(), DSSProjectErrorException.class); + } + //1.统一修改各个接入的第三方的系统的工程状态信息 + //todo 第三方的工程修改接口还是没有调试通过 +// modifyThirdProject(projectModifyRequest, username); + //2.修改dss_project DSS基本工程信息 + projectService.modifyProject(username, projectModifyRequest); + try { + //todo 3.修改dss_project_user 工程与用户关系 这一步还没有调试通过 + projectUserService.modifyProjectUser(dbProject, projectModifyRequest, username); + } catch (Exception e) { + LOGGER.error("modifyProjectUserError:", e); + } + } + + //统一修改各个接入的第三方的系统的工程状态信息 修改dss_project调用 + private void modifyThirdProject(ProjectModifyRequest projectModifyRequest, String username) { + for (AppConn appConn : AppConnManager.getAppConnManager().listAppConns()) { + ProjectRequestRef projectRequestRef = new ProjectRequestRefImpl(); + projectRequestRef.setDescription(projectModifyRequest.getDescription()); + projectRequestRef.setUpdateBy(username); + projectRequestRef.setName(projectModifyRequest.getName()); + if (appConn instanceof OnlyStructureAppConn) { + StructureIntegrationStandard appStandard = ((OnlyStructureAppConn) appConn).getOrCreateStructureStandard(); + for (AppInstance appInstance : appConn.getAppDesc().getAppInstances()) { + ProjectService projectService = appStandard.getProjectService(appInstance); + ProjectUpdateOperation operation = projectService.getProjectUpdateOperation(); + try { + ProjectResponseRef responseRef = operation.updateProject(projectRequestRef); + } catch (ExternalOperationFailedException e) { + DSSExceptionUtils.dealWarnException(60015, + String.format("failed to update project %s", projectModifyRequest.getName()), e, LambdaWarnException.class); + } + } + } + } + } + + //1.新建DSS工程,这样才能进行回滚,如果后面去DSS工程,可能会由于DSS工程建立失败了,但是仍然无法去回滚第三方系统的工程 新增dss_project调用 + private Map createAppConnProject(ProjectCreateRequest dssProjectCreateRequest, String username, + Workspace workspace) throws DSSProjectErrorException { + Map projectMap = new HashMap<>(16); + Map successAppConns = new HashMap<>(16); + boolean createFailed = false; + ProjectRequestRefImpl requestRef = new ProjectRequestRefImpl(); + requestRef.setName(dssProjectCreateRequest.getName()); + requestRef.setCreateBy(username); + requestRef.setDescription(dssProjectCreateRequest.getDescription()); + requestRef.setWorkspaceName(dssProjectCreateRequest.getWorkspaceName()); + requestRef.setWorkspace(workspace); + for (AppConn appConn : AppConnManager.getAppConnManager().listAppConns()) { + if (appConn instanceof OnlyStructureAppConn) { + OnlyStructureAppConn onlyStructureAppConn = (OnlyStructureAppConn) appConn; + StructureIntegrationStandard appStandard = onlyStructureAppConn.getOrCreateStructureStandard(); + //如果该AppConn是有structureIntegrationStandard的话,那么所有的appinstance都要进行新建工程 + for (AppInstance appInstance : appConn.getAppDesc().getAppInstances()) { + ProjectService projectService = appStandard.getProjectService(appInstance); + if(projectService == null) { + continue; + } + ProjectCreationOperation projectCreationOperation = projectService.getProjectCreationOperation(); + try { + LOGGER.info("Begin to create project {} in {}", dssProjectCreateRequest.getName(), appConn.getAppDesc().getAppName()); + ProjectResponseRef responseRef = projectCreationOperation.createProject(requestRef); + LOGGER.info("End to create project {} in {}, response projectId is {} ", + dssProjectCreateRequest.getName(), appConn.getAppDesc().getAppName(), responseRef.getProjectRefId()); + successAppConns.put(appConn, responseRef); + Long projectRefId = responseRef.getProjectRefId(); + projectMap.put(appInstance, projectRefId); + } catch (final Exception e) { + LOGGER.error("Failed to create project {} in {}", dssProjectCreateRequest.getName(), appConn.getAppDesc().getAppInstances(), e); + createFailed = true; + //break; + } + } + } + } + //如果创建失败并且是严格创建模式 + if (createFailed && STRICT_PROJECT_CREATE_MODE) { + //如果一个AppInstance实例是失败的,那么我们将所有已经建的工程给撤销掉 + for (AppConn appConn : successAppConns.keySet()) { + StructureIntegrationStandard appStandard = null; + if (appConn instanceof OnlyStructureAppConn) { + OnlyStructureAppConn onlyStructureAppConn = (OnlyStructureAppConn) appConn; + appStandard = onlyStructureAppConn.getOrCreateStructureStandard(); + for (AppInstance appInstance : appConn.getAppDesc().getAppInstances()) { + ProjectService projectService = appStandard.getProjectService(appInstance); + ProjectDeletionOperation operation = projectService.getProjectDeletionOperation(); + try { + operation.deleteProject(requestRef); + } catch (ExternalOperationFailedException e) { + LOGGER.error("Failed to delete project {} in {}", + requestRef.getName(), appConn.getAppDesc().getAppName(), e); + //TODO 如果删除不了,可以先不管 + } + } + } + } + projectMap = null; + } + return projectMap; + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSOrchestratorServiceImpl.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSOrchestratorServiceImpl.java new file mode 100644 index 0000000000..d301a718f5 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSOrchestratorServiceImpl.java @@ -0,0 +1,306 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.webank.wedatasphere.dss.framework.common.exception.DSSFrameworkErrorException; +import com.webank.wedatasphere.dss.framework.project.contant.OrchestratorTypeEnum; +import com.webank.wedatasphere.dss.framework.project.contant.ProjectServerResponse; +import com.webank.wedatasphere.dss.framework.project.dao.DSSOrchestratorMapper; +import com.webank.wedatasphere.dss.framework.project.dao.DSSProjectMapper; +import com.webank.wedatasphere.dss.framework.project.entity.DSSOrchestrator; +import com.webank.wedatasphere.dss.framework.project.entity.DSSProjectDO; +import com.webank.wedatasphere.dss.framework.project.entity.DSSProjectUser; +import com.webank.wedatasphere.dss.framework.project.entity.request.OrchestratorCreateRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.OrchestratorDeleteRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.OrchestratorModifyRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.OrchestratorRequest; +import com.webank.wedatasphere.dss.framework.project.entity.vo.OrchestratorBaseInfo; +import com.webank.wedatasphere.dss.framework.project.exception.DSSProjectErrorException; +import com.webank.wedatasphere.dss.framework.project.service.DSSOrchestratorService; +import com.webank.wedatasphere.dss.framework.project.service.DSSProjectUserService; +import com.webank.wedatasphere.dss.framework.project.utils.ProjectStringUtils; +import com.webank.wedatasphere.dss.orchestrator.common.protocol.RequestProjectImportOrchestrator; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorCreateResponseRef; +import com.webank.wedatasphere.dss.sender.service.DSSSenderServiceFactory; +import com.webank.wedatasphere.linkis.rpc.Sender; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +@Service +public class DSSOrchestratorServiceImpl extends ServiceImpl implements DSSOrchestratorService { + private static final Logger LOGGER = LoggerFactory.getLogger(DSSOrchestratorServiceImpl.class); + public static final String MODE_SPLIT = ","; + @Autowired + private DSSOrchestratorMapper orchestratorMapper; + @Autowired + private DSSProjectUserService projectUserService; + @Autowired + private DSSProjectMapper dssProjectMapper; + + private final Sender orcSender = DSSSenderServiceFactory.getOrCreateServiceInstance().getScheduleOrcSender(); + + /** + * 保存编排模式 + * + * @param orchestratorCreateRequest + * @param responseRef + * @param username + * @throws DSSFrameworkErrorException + * @throws DSSProjectErrorException + */ + @Override + public void saveOrchestrator(OrchestratorCreateRequest orchestratorCreateRequest, OrchestratorCreateResponseRef responseRef, String username) throws DSSFrameworkErrorException, DSSProjectErrorException { + //todo 使用工程的权限关系来限定 校验当前登录用户是否含有修改权限 + projectUserService.isEditProjectAuth(orchestratorCreateRequest.getProjectId(), username); + DSSOrchestrator orchestrator = new DSSOrchestrator(); + orchestrator.setWorkspaceId(orchestratorCreateRequest.getWorkspaceId()); + orchestrator.setProjectId(orchestratorCreateRequest.getProjectId()); + //编排模式id(工作流,调用orchestrator服务返回的orchestratorId) + orchestrator.setOrchestratorId(responseRef.getOrcId()); + //编排模式版本id(工作流,调用orchestrator服务返回的orchestratorVersionId) + orchestrator.setOrchestratorVersionId(responseRef.getOrchestratorVersionId()); + //编排模式-名称 + orchestrator.setOrchestratorName(orchestratorCreateRequest.getOrchestratorName()); + //编排模式-类型 + orchestrator.setOrchestratorMode(orchestratorCreateRequest.getOrchestratorMode()); + //编排模式-方式 + orchestrator.setOrchestratorWay(ProjectStringUtils.getModeStr(orchestratorCreateRequest.getOrchestratorWays())); + //编排模式-用途 + orchestrator.setUses(orchestratorCreateRequest.getUses()); + //编排模式-描述 + orchestrator.setDescription(orchestratorCreateRequest.getDescription()); + //编排模式-创建人 + orchestrator.setCreateUser(username); + orchestrator.setCreateTime(new Date()); + orchestrator.setUpdateTime(new Date()); + this.save(orchestrator); + } + + /** + * 更新编排模式 + * + * @param orchestratorModifRequest + * @param username + * @throws DSSFrameworkErrorException + * @throws DSSProjectErrorException + */ + @Override + public void updateOrchestrator(OrchestratorModifyRequest orchestratorModifRequest, String username) throws DSSFrameworkErrorException, DSSProjectErrorException { + //todo 使用工程的权限关系来限定 校验当前登录用户是否含有修改权限 + projectUserService.isEditProjectAuth(orchestratorModifRequest.getProjectId(), username); + + DSSOrchestrator orchestrator = new DSSOrchestrator(); + orchestrator.setId(orchestratorModifRequest.getId()); + //编排模式-名称 + orchestrator.setOrchestratorName(orchestratorModifRequest.getOrchestratorName()); + //编排模式 + orchestrator.setOrchestratorMode(orchestratorModifRequest.getOrchestratorMode()); + //编排模式-方式 + orchestrator.setOrchestratorWay(ProjectStringUtils.getModeStr(orchestratorModifRequest.getOrchestratorWays())); + //编排模式-用途 + orchestrator.setUses(orchestratorModifRequest.getUses()); + //编排模式-描述 + orchestrator.setDescription(orchestratorModifRequest.getDescription()); + //编排模式-更新人 + orchestrator.setUpdateUser(username); + //编排模式-更新时间 + orchestrator.setUpdateTime(new Date()); + this.updateById(orchestrator); + } + + //新建前是否存在相同的编排名称 + @Override + public void isExistSameNameBeforeCreate(Long workspaceId, Long projectId, String arrangeName) throws DSSFrameworkErrorException { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("workspace_id", workspaceId); + queryWrapper.eq("project_id", projectId); + queryWrapper.eq("orchestrator_name", arrangeName); + List list = this.list(queryWrapper); + if (!CollectionUtils.isEmpty(list)) { + DSSFrameworkErrorException.dealErrorException(60000, "编排名称已经存在"); + } + } + + //是否存在相同的编排名称,如果不存在相同的编排名称則返回编排id + @Override + public Long isExistSameNameBeforeUpdate(OrchestratorModifyRequest orchestratorModifRequest) throws DSSFrameworkErrorException { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("workspace_id", orchestratorModifRequest.getWorkspaceId()); + queryWrapper.eq("project_id", orchestratorModifRequest.getProjectId()); + queryWrapper.eq("id", orchestratorModifRequest.getId()); + List list = this.list(queryWrapper); + if (CollectionUtils.isEmpty(list)) { + DSSFrameworkErrorException.dealErrorException(60000, "编排模式ID=" + orchestratorModifRequest.getId() + "不存在"); + } + //是否存在相同的编排名称 + if (!orchestratorModifRequest.getOrchestratorName().equals(list.get(0).getOrchestratorName())) { + isExistSameNameBeforeCreate(orchestratorModifRequest.getWorkspaceId(), orchestratorModifRequest.getProjectId(), orchestratorModifRequest.getOrchestratorName()); + } + return list.get(0).getOrchestratorId(); + } + + + /** + * 查询编排模式 + * + * @param orchestratorRequest + * @param username + * @return + */ + @Override + public List getListByPage(OrchestratorRequest orchestratorRequest, String username) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("workspace_id", orchestratorRequest.getWorkspaceId()); + queryWrapper.eq("project_id", orchestratorRequest.getProjectId()); + if (StringUtils.isNotBlank(orchestratorRequest.getOrchestratorMode())) { + queryWrapper.eq("orchestrator_mode", orchestratorRequest.getOrchestratorMode()); + } + List list = this.list(queryWrapper); + List retList = new ArrayList(list.size()); + if (!CollectionUtils.isEmpty(list)) { + //获取工程的权限等级 + List projectUserList = projectUserService.getEditProjectList(orchestratorRequest.getProjectId(), username); + //获取最大权限 + + Integer priv = CollectionUtils.isEmpty(projectUserList) ? null : projectUserList.stream().mapToInt(DSSProjectUser::getPriv).max().getAsInt(); + OrchestratorBaseInfo orchestratorBaseInfo = null; + for (DSSOrchestrator orchestrator : list) { + orchestratorBaseInfo = new OrchestratorBaseInfo(); + BeanUtils.copyProperties(orchestrator, orchestratorBaseInfo); + orchestratorBaseInfo.setOrchestratorWays(ProjectStringUtils.convertList(orchestrator.getOrchestratorWay())); + orchestratorBaseInfo.setPriv(priv); + retList.add(orchestratorBaseInfo); + } + } + return retList; + } + + /** + * 删除编排模式 + * + * @param orchestratorDeleteRequest + * @param username + * @return + * @throws DSSProjectErrorException + */ + @Override + @SuppressWarnings("all") + public boolean deleteOrchestrator(OrchestratorDeleteRequest orchestratorDeleteRequest, String username) throws DSSProjectErrorException { + //todo 使用工程的权限关系来限定 校验当前登录用户是否含有修改权限 + projectUserService.isEditProjectAuth(orchestratorDeleteRequest.getProjectId(), username); + + UpdateWrapper updateWrapper = new UpdateWrapper(); + updateWrapper.eq("workspace_id", orchestratorDeleteRequest.getWorkspaceId()); + updateWrapper.eq("project_id", orchestratorDeleteRequest.getProjectId()); + updateWrapper.eq("id", orchestratorDeleteRequest.getId()); + return this.remove(updateWrapper); + } + + @Override + public DSSOrchestrator getOrchestratorById(Long id) { + return this.getById(id); + } + + @Override + public Long importOrchestrator(RequestProjectImportOrchestrator orchestratorInfo) throws Exception { + DSSProjectDO projectDO = dssProjectMapper.selectById(orchestratorInfo.getProjectId()); + if (projectDO == null) { + DSSFrameworkErrorException.dealErrorException(ProjectServerResponse.PROJECT_NOT_EXIST.getCode(), + ProjectServerResponse.PROJECT_NOT_EXIST.getMsg()); + } + //校验参数 + String type = orchestratorInfo.getType(); + if (StringUtils.isEmpty(type)) { + DSSFrameworkErrorException.dealErrorException(60000, "编排模式类型不能为不存在"); + } + Long orcId = orchestratorInfo.getId(); + String orchestratorMode = OrchestratorTypeEnum.getKeyByOrcType(type); + String orchestratorWay = orchestratorInfo.getSecondaryType(); + if (StringUtils.isNotBlank(orchestratorWay)) { + orchestratorWay = orchestratorWay.replace("[", ",").replace("]", ","); + } + //查询是否存在相同的编排模式 + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("orchestrator_id", orcId); + queryWrapper.eq("project_id", projectDO.getId()); + List list = this.list(queryWrapper); + //如果存在即更新既可以 + if (!CollectionUtils.isEmpty(list)) { + //导入更新 + return updateOrcByImport(list.get(0), orchestratorMode,orchestratorWay,orchestratorInfo); + } else { + //导入新增 + return insertOrcByImport(projectDO,orchestratorMode,orchestratorWay,orchestratorInfo); + } + } + + //导入更新 + public Long updateOrcByImport(DSSOrchestrator dbEntity, String orchestratorMode, String orchestratorWay, RequestProjectImportOrchestrator orchestratorInfo) { + DSSOrchestrator updateEntity = new DSSOrchestrator(); + BeanUtils.copyProperties(dbEntity, updateEntity); + //更新字段 + updateEntity.setOrchestratorName(orchestratorInfo.getName()); + updateEntity.setOrchestratorMode(orchestratorMode); + updateEntity.setOrchestratorWay(orchestratorWay); + updateEntity.setDescription(orchestratorInfo.getDesc()); + updateEntity.setUpdateUser(orchestratorInfo.getCreator()); + updateEntity.setUpdateTime(new Date()); + //数据库更新 + this.updateById(updateEntity); + return 0L; + } + + //导入新增 + public Long insertOrcByImport(DSSProjectDO projectDO, String orchestratorMode, String orchestratorWay, RequestProjectImportOrchestrator orchestratorInfo) + throws DSSFrameworkErrorException { + //新增,查看是否含有同名的编排模式 + /* QueryWrapper queryNameWrapper = new QueryWrapper(); + queryNameWrapper.eq("workspace_id", projectDO.getWorkspaceId()); + queryNameWrapper.eq("project_id", orchestratorInfo.getProjectId()); + queryNameWrapper.eq("orchestrator_name", orchestratorInfo.getName()); + List sameNameList = this.list(queryNameWrapper); + if (!CollectionUtils.isEmpty(sameNameList)) { + DSSFrameworkErrorException.dealErrorException(60000, "编排名称已经存在"); + }*/ + DSSOrchestrator orchestrator = new DSSOrchestrator(); + orchestrator.setProjectId(projectDO.getId()); + orchestrator.setOrchestratorId(orchestratorInfo.getId()); + orchestrator.setOrchestratorVersionId(orchestratorInfo.getVersionId()); + orchestrator.setOrchestratorName(orchestratorInfo.getName()); + orchestrator.setOrchestratorMode(orchestratorMode); + orchestrator.setOrchestratorWay(orchestratorWay); + orchestrator.setDescription(orchestratorInfo.getDesc()); + orchestrator.setCreateUser(orchestratorInfo.getCreator()); + orchestrator.setCreateTime(new Date()); + orchestrator.setUpdateTime(new Date()); + orchestrator.setWorkspaceId(projectDO.getWorkspaceId()); + this.save(orchestrator); + return orchestrator.getId(); + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSProjectServiceImpl.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSProjectServiceImpl.java new file mode 100644 index 0000000000..9a64e66f27 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSProjectServiceImpl.java @@ -0,0 +1,259 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.webank.wedatasphere.dss.appconn.core.AppConn; +import com.webank.wedatasphere.dss.appconn.core.ext.OnlyStructureAppConn; +import com.webank.wedatasphere.dss.appconn.manager.AppConnManager; +import com.webank.wedatasphere.dss.common.exception.DSSErrorException; +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.common.utils.DSSExceptionUtils; +import com.webank.wedatasphere.dss.framework.project.conf.ProjectConf; +import com.webank.wedatasphere.dss.framework.project.contant.ProjectUserPrivEnum; +import com.webank.wedatasphere.dss.framework.project.dao.DSSProjectMapper; +import com.webank.wedatasphere.dss.framework.project.entity.DSSProjectDO; +import com.webank.wedatasphere.dss.framework.project.entity.po.ProjectRelationPo; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectCreateRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectDeleteRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectModifyRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectQueryRequest; +import com.webank.wedatasphere.dss.framework.project.entity.response.ProjectResponse; +import com.webank.wedatasphere.dss.framework.project.entity.vo.ProjectInfoVo; +import com.webank.wedatasphere.dss.framework.project.entity.vo.QueryProjectVo; +import com.webank.wedatasphere.dss.framework.project.exception.DSSProjectErrorException; +import com.webank.wedatasphere.dss.framework.project.service.DSSOrchestratorService; +import com.webank.wedatasphere.dss.framework.project.service.DSSProjectService; +import com.webank.wedatasphere.dss.framework.project.service.DSSProjectUserService; +import com.webank.wedatasphere.dss.framework.project.utils.ProjectStringUtils; +import com.webank.wedatasphere.dss.orchestrator.common.protocol.RequestProjectImportOrchestrator; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.dss.standard.app.structure.project.ProjectDeletionOperation; +import com.webank.wedatasphere.dss.standard.app.structure.project.ProjectRequestRef; +import com.webank.wedatasphere.dss.standard.app.structure.project.ProjectRequestRefImpl; +import com.webank.wedatasphere.dss.standard.app.structure.project.ProjectService; +import com.webank.wedatasphere.dss.standard.common.desc.AppInstance; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + + +public class DSSProjectServiceImpl extends ServiceImpl implements DSSProjectService { + private static final Logger LOGGER = LoggerFactory.getLogger(DSSProjectServiceImpl.class); + @Autowired + private DSSProjectMapper projectMapper; + @Autowired + private DSSProjectUserService projectUserService; + @Autowired + private DSSOrchestratorService orchestratorService; + public static final String MODE_SPLIT = ","; + public static final String KEY_SPLIT = "-"; + private final String SUPPORT_ABILITY = ProjectConf.SUPPORT_ABILITY.getValue(); + + @Override + public DSSProjectDO createProject(String username, ProjectCreateRequest projectCreateRequest) { + DSSProjectDO project = new DSSProjectDO(); + project.setName(projectCreateRequest.getName()); + project.setWorkspaceId(projectCreateRequest.getWorkspaceId()); + project.setCreateBy(username); + project.setUsername(username); + project.setCreateTime(new Date()); + project.setBusiness(projectCreateRequest.getBusiness()); + project.setProduct(projectCreateRequest.getProduct()); + project.setUpdateTime(new Date()); + project.setDescription(projectCreateRequest.getDescription()); + project.setApplicationArea(projectCreateRequest.getApplicationArea()); + //开发流程,编排模式组拼接 前后进行英文逗号接口 + project.setDevProcess(ProjectStringUtils.getModeStr(projectCreateRequest.getDevProcessList())); + project.setOrchestratorMode(ProjectStringUtils.getModeStr(projectCreateRequest.getOrchestratorModeList())); + projectMapper.insert(project); + return project; + } + + //修改dss_project工程字段 + @Override + public void modifyProject(String username, ProjectModifyRequest projectModifyRequest) throws DSSProjectErrorException { + //校验当前登录用户是否含有修改权限 + projectUserService.isEditProjectAuth(projectModifyRequest.getId(), username); + DSSProjectDO project = new DSSProjectDO(); + //修改的字段 + project.setDescription(projectModifyRequest.getDescription()); + project.setUpdateTime(new Date()); + project.setUpdateByStr(username); + project.setDevProcess(ProjectStringUtils.getModeStr(projectModifyRequest.getDevProcessList())); + if (StringUtils.isNotBlank(projectModifyRequest.getApplicationArea())) { + project.setApplicationArea(Integer.valueOf(projectModifyRequest.getApplicationArea())); + } + project.setOrchestratorMode(ProjectStringUtils.getModeStr(projectModifyRequest.getOrchestratorModeList())); + project.setBusiness(projectModifyRequest.getBusiness()); + project.setProduct(projectModifyRequest.getProduct()); + + UpdateWrapper updateWrapper = new UpdateWrapper(); + updateWrapper.eq("id", projectModifyRequest.getId()); + updateWrapper.eq("workspace_id", projectModifyRequest.getWorkspaceId()); + projectMapper.update(project, updateWrapper); + } + + @Override + public DSSProjectDO getProjectByName(String name) { + QueryWrapper projectQueryWrapper = new QueryWrapper(); + projectQueryWrapper.eq("name", name); + List projectList = projectMapper.selectList(projectQueryWrapper); + return CollectionUtils.isEmpty(projectList) ? null : projectList.get(0); + } + + @Override + public DSSProjectDO getProjectById(Long id) { + return projectMapper.selectById(id); + } + + @Override + public List getListByParam(ProjectQueryRequest projectRequest) { + //根据dss_project、dss_project_user查询出所在空间登录用户相关的工程 + List list = projectMapper.getListByParam(projectRequest); + if (CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + + List projectResponseList = new ArrayList<>(); + ProjectResponse projectResponse = null; + for (QueryProjectVo projectVo : list) { + if (projectVo.getVisible() == 0) { + continue; + } + projectResponse = new ProjectResponse(); + projectResponse.setApplicationArea(projectVo.getApplicationArea()); + projectResponse.setId(projectVo.getId()); + projectResponse.setBusiness(projectVo.getBusiness()); + projectResponse.setCreateBy(projectVo.getCreateBy()); + projectResponse.setDescription(projectVo.getDescription()); + projectResponse.setName(projectVo.getName()); + projectResponse.setProduct(projectVo.getProduct()); + projectResponse.setSource(projectVo.getSource()); + projectResponse.setArchive(projectVo.getArchive()); + projectResponse.setCreateTime(projectVo.getCreateTime()); + projectResponse.setUpdateTime(projectVo.getUpdateTime()); + projectResponse.setDevProcessList(ProjectStringUtils.convertList(projectVo.getDevProcess())); + projectResponse.setOrchestratorModeList(ProjectStringUtils.convertList(projectVo.getOrchestratorMode())); + projectResponseList.add(projectResponse); + /** + * 拆分有projectId +"-" + priv + "-" + username的拼接而成的字段, + * 从而得到:查看权限用户、编辑权限用户、发布权限用户 + */ + String pusername = projectVo.getPusername(); + if (StringUtils.isEmpty(pusername)) { + continue; + } + Map> userPricMap = new HashMap<>(); + String[] tempstrArr = pusername.split(MODE_SPLIT); + + for (String s : tempstrArr) { + String[] strArr = s.split(KEY_SPLIT); + String key = strArr[0] + KEY_SPLIT + strArr[1]; + userPricMap.computeIfAbsent(key, k -> new ArrayList<>()); + userPricMap.get(key).add(strArr[2]); + } + List accessUsers = userPricMap.get(projectVo.getId() + KEY_SPLIT + ProjectUserPrivEnum.PRIV_ACCESS.getRank()); + List editUsers = userPricMap.get(projectVo.getId() + KEY_SPLIT + ProjectUserPrivEnum.PRIV_EDIT.getRank()); + List releaseUsers = userPricMap.get(projectVo.getId() + KEY_SPLIT + ProjectUserPrivEnum.PRIV_RELEASE.getRank()); + projectResponse.setAccessUsers(CollectionUtils.isEmpty(accessUsers) ? new ArrayList<>() : accessUsers.stream().distinct().collect(Collectors.toList())); + projectResponse.setEditUsers(CollectionUtils.isEmpty(editUsers) ? new ArrayList<>() : editUsers.stream().distinct().collect(Collectors.toList())); + projectResponse.setReleaseUsers(CollectionUtils.isEmpty(releaseUsers) ? new ArrayList<>() : releaseUsers.stream().distinct().collect(Collectors.toList())); + } + return projectResponseList; + } + + @Override + public ProjectInfoVo getProjectInfoById(Long id) { + return projectMapper.getProjectInfoById(id); + } + + + @Override + public void saveProjectRelation(DSSProjectDO project, Map projectMap) { + List relationPos = new ArrayList<>(); + projectMap.forEach((k, v) -> { + relationPos.add(new ProjectRelationPo(project.getId(), k.getId(), v)); + }); + projectMapper.saveProjectRelation(relationPos); + } + + + @Override + public Long getAppConnProjectId(Long dssProjectId, String appConnName, List dssLabels) throws Exception { + AppConn appConn = AppConnManager.getAppConnManager().getAppConn(appConnName); + List appInstances = appConn.getAppDesc().getAppInstancesByLabels(dssLabels); + if (appInstances.get(0) != null) { + Long appInstanceId = appInstances.get(0).getId(); + return projectMapper.getAppConnProjectId(appInstanceId, dssProjectId); + } else { + LOGGER.error("appInstances is null {}", appInstances); + return null; + } + } + + @Override + public void deleteProject(String username, ProjectDeleteRequest projectDeleteRequest, Workspace workspace) throws Exception { + LOGGER.warn("user {} begins to delete project {}.", username, projectDeleteRequest); + DSSProjectDO DSSProjectDO = projectMapper.selectById(projectDeleteRequest.getId()); + if (DSSProjectDO == null) { + throw new DSSErrorException(600001, "工程不存在" ); + } + if(projectDeleteRequest.isIfDelOtherSys()) { + ProjectRequestRef projectRequestRef = new ProjectRequestRefImpl(); + projectRequestRef.setName(DSSProjectDO.getName()); + projectRequestRef.setWorkspace(workspace); + AppConnManager.getAppConnManager().listAppConns().stream().filter(appConn -> appConn instanceof OnlyStructureAppConn).forEach(appConn -> { + OnlyStructureAppConn structureAppConn = (OnlyStructureAppConn) appConn; + appConn.getAppDesc().getAppInstances().forEach(DSSExceptionUtils.handling(appInstance -> { + ProjectService projectService = structureAppConn.getOrCreateStructureStandard().getProjectService(appInstance); + if(projectService != null) { + ProjectDeletionOperation projectDeletionOperation = projectService.getProjectDeletionOperation(); + if(projectDeletionOperation != null) { + projectDeletionOperation.deleteProject(projectRequestRef); + } + } + })); + }); + } + projectMapper.deleteProject(projectDeleteRequest.getId()); + LOGGER.warn("User {} deleted project {}.", username, DSSProjectDO.getName()); + } + + @Override + public List getProjectAbilities(String username) { + LOGGER.info("{} begins to get project ability", username); + return Arrays.asList(SUPPORT_ABILITY.trim().split(",")); + } + + @Override + public Long importOrchestrator(RequestProjectImportOrchestrator orchestratorInfo) throws Exception { + return orchestratorService.importOrchestrator(orchestratorInfo); + } + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSProjectUserServiceImpl.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSProjectUserServiceImpl.java new file mode 100644 index 0000000000..b3103736e2 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/service/impl/DSSProjectUserServiceImpl.java @@ -0,0 +1,188 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.webank.wedatasphere.dss.common.utils.DSSExceptionUtils; +import com.webank.wedatasphere.dss.framework.project.contant.ProjectServerResponse; +import com.webank.wedatasphere.dss.framework.project.contant.ProjectUserPrivEnum; +import com.webank.wedatasphere.dss.framework.project.dao.DSSProjectUserMapper; +import com.webank.wedatasphere.dss.framework.project.entity.DSSProjectDO; +import com.webank.wedatasphere.dss.framework.project.entity.DSSProjectUser; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectCreateRequest; +import com.webank.wedatasphere.dss.framework.project.entity.request.ProjectModifyRequest; +import com.webank.wedatasphere.dss.framework.project.exception.DSSProjectErrorException; +import com.webank.wedatasphere.dss.framework.project.server.service.BMLService; +import com.webank.wedatasphere.dss.framework.project.service.DSSProjectUserService; +import com.webank.wedatasphere.dss.framework.project.utils.ProjectUserUtils; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import org.apache.commons.collections.CollectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; + + +public class DSSProjectUserServiceImpl implements DSSProjectUserService { + + protected final Logger LOGGER = LoggerFactory.getLogger(getClass()); + + @Autowired + private DSSProjectUserMapper projectUserMapper; + @Autowired + @Qualifier("projectServerBMLService") + private BMLService bmlService; + + /** + * 是否有修改工程权限 + * @param projectId + * @param username + * @return + */ + @Override + public boolean isEditProjectAuth(Long projectId, String username) throws DSSProjectErrorException { + //校验当前登录用户是否含有修改权限 + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("project_id",projectId); + queryWrapper.eq("username",username); + queryWrapper.ge("priv",ProjectUserPrivEnum.PRIV_EDIT.getRank());//编辑权限 + long count = projectUserMapper.selectCount(queryWrapper); + if(count == 0){ + DSSExceptionUtils.dealErrorException(ProjectServerResponse.PROJECT_NOT_EDIT_AUTH.getCode(),ProjectServerResponse.PROJECT_NOT_EDIT_AUTH.getMsg(), DSSProjectErrorException.class); + } + return true; + } + /** + * 根据用户名和工程id获取工程权限 + * @param projectId + * @param username + * @return + */ + @Override + public List getEditProjectList(Long projectId, String username){ + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("project_id",projectId); + queryWrapper.eq("username",username); + return projectUserMapper.selectList(queryWrapper); + } + + /** + * 保存工程与用户关系 + * @param projectID + * @param request + */ + @Override + public void saveProjectUser(Long projectID,String username, ProjectCreateRequest request)throws Exception{ + //將创建人默认为发布权限 + List releaseUsers = request.getReleaseUsers(); + if(!request.getEditUsers().contains(username)){ + request.getEditUsers().add(username); + } + if(releaseUsers == null){ + releaseUsers = new ArrayList<>(); + } + if(!releaseUsers.contains(username)){ + releaseUsers.add(username); + } + + //批量保存 + saveBatch(request.getWorkspaceId(),projectID,releaseUsers,request.getEditUsers(),request.getAccessUsers()); + + //获取所有编辑权限的用户 + List sumEditUsers = ProjectUserUtils.getEditUserList(releaseUsers, request.getEditUsers()); + //去bml建一个工程 + bmlService.createBmlProject(username, request.getName(), sumEditUsers, request.getAccessUsers()); + } + + /** + * 修改工程与用户关系 + * @param dbProject + * @param modifyRequest + */ + @Override + public void modifyProjectUser(DSSProjectDO dbProject, ProjectModifyRequest modifyRequest, String loginuser) throws Exception{ + projectUserMapper.deleteAllPriv(dbProject.getId()); + //將创建人默认为发布权限 + List releaseUsers = modifyRequest.getReleaseUsers(); + String username = dbProject.getCreateBy(); + if(!modifyRequest.getEditUsers().contains(username)){ + modifyRequest.getEditUsers().add(username); + } + if(releaseUsers == null){ + releaseUsers = new ArrayList<>(); + } + if(!releaseUsers.contains(username)){ + releaseUsers.add(username); + } + + //批量保存 + saveBatch(modifyRequest.getWorkspaceId(),dbProject.getId(),releaseUsers,modifyRequest.getEditUsers(),modifyRequest.getAccessUsers()); + + //获取所有编辑权限的用户 + List sumEditUsers = ProjectUserUtils.getEditUserList(releaseUsers, modifyRequest.getEditUsers()); + //更新底层的权限 + bmlService.updateProjectPriv(dbProject.getName(), username, sumEditUsers, modifyRequest.getAccessUsers()); + } + + + + @Override + public List getListByParam(Long workspaceId, String username) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("workspace_id",workspaceId); + queryWrapper.eq("username",username); + queryWrapper.ge("priv",ProjectUserPrivEnum.PRIV_ACCESS.getRank()); + List DSSProjectUserList = projectUserMapper.selectList(queryWrapper); + return DSSProjectUserList; + } + + //批量保存 + public void saveBatch(Long workspaceId,Long projectID,List releaseUsers,List editUsers,List accessUsers){ + List realReleaseUsers = releaseUsers.stream().distinct().collect(Collectors.toList()); + List realEditUsers = editUsers.stream().distinct().collect(Collectors.toList()); + List realAccessUsers = accessUsers.stream().distinct().collect(Collectors.toList()); + List addList = new ArrayList<>(); + addList.addAll(ProjectUserUtils.createPUser(workspaceId,projectID,realReleaseUsers,ProjectUserPrivEnum.PRIV_RELEASE.getRank())); + addList.addAll(ProjectUserUtils.createPUser(workspaceId,projectID,realEditUsers, ProjectUserPrivEnum.PRIV_EDIT.getRank())); + addList.addAll(ProjectUserUtils.createPUser(workspaceId,projectID,realAccessUsers,ProjectUserPrivEnum.PRIV_ACCESS.getRank())); + if(CollectionUtils.isEmpty(addList)){ + return; + } + //分批插入 + List tempAddList = new ArrayList<>(); + for (int i = 0; i < addList.size(); i++) { + tempAddList.add(addList.get(i)); + if (i > 0 && i % 200 == 0) { + projectUserMapper.insertBatchProjectUser(tempAddList); + tempAddList.clear(); + } + } + if (tempAddList.size() > 0) { + projectUserMapper.insertBatchProjectUser(tempAddList); + } + } + + @Override + public boolean isAdminByUsername(Long workspaceId, String username) { + //管理员ID,这里写死 + int roleId = 1; + return projectUserMapper.isAdminByUsername(workspaceId, username, roleId).longValue() > 0; + } + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/ApplicationArea.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/ApplicationArea.java new file mode 100644 index 0000000000..a06799f607 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/ApplicationArea.java @@ -0,0 +1,52 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.utils; + + +public enum ApplicationArea { + // Operational optimization, risk management, marketing recommendation, trend prediction, customer management + // 运营优化,风险管理,营销推荐,趋势预测,客户管理; + OO("运营优化","Operational Optimization",0), + RM("风险管理","Risk Management",1), + MR("营销推荐","Marketing Recommendation",2), + TP("趋势预测","Trend Prediction",3), + CM("客户管理","Customer Management",4); + + + private int id; + private String name; + private String enName; + + ApplicationArea(String name, String enName, int id) { + this.name = name; + this.enName = enName; + this.id = id; + } + + public String getName() { + return name; + } + + public int getId(){ + return this.id; + } + + public String getEnName(){ + return this.enName; + } + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/LambdaHelper.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/LambdaHelper.java new file mode 100644 index 0000000000..234d1bdad0 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/LambdaHelper.java @@ -0,0 +1,41 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.utils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.function.Consumer; + + + +public class LambdaHelper { + + private static final Logger LOGGER = LoggerFactory.getLogger(LambdaHelper.class); + + public static Consumer consumerWrapper(Consumer consumer){ + return t -> { + try{ + consumer.accept(t); + }catch(Exception e){ + LOGGER.error("Failed to do with {} ", t, e); + } + }; + } + + +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/ProjectStringUtils.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/ProjectStringUtils.java new file mode 100644 index 0000000000..4bbe902733 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/ProjectStringUtils.java @@ -0,0 +1,67 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.utils; + + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.*; +import java.util.stream.Collectors; + +public class ProjectStringUtils { + + + private static final Logger LOGGER = LoggerFactory.getLogger(ProjectStringUtils.class); + + private static final String REDIRECT_FORMAT = "%s?redirect=%s&dssurl=${dssurl}&cookies=${cookies}"; + + public static final String MODE_SPLIT = ","; + public static final String KEY_SPLIT = "-"; + + public static List convertList(String str){ + if(org.apache.commons.lang.StringUtils.isEmpty(str)){ + return new ArrayList<>(); + } + return Arrays.stream(str.split(MODE_SPLIT)).map(String::trim).filter((s)-> StringUtils.isNotBlank(s)).distinct().collect(Collectors.toList()); + } + + //拼接 前后使用英文逗号结尾 + public static String getModeStr(List strList){ + if(CollectionUtils.isEmpty(strList)){ + return null; + } + return strList.stream().map(String::trim).filter((s)-> StringUtils.isNotBlank(s)).distinct().collect(Collectors.joining(MODE_SPLIT,MODE_SPLIT,MODE_SPLIT)); + } + + private static String URLEndoder(String str){ + try { + return URLEncoder.encode(str,"utf-8"); + } catch (UnsupportedEncodingException e) { + LOGGER.warn("endoe failed:",e); + return str; + } + } + + public static String redirectUrlFormat(String redirectUrl,String url){ + return String.format(REDIRECT_FORMAT,redirectUrl,URLEndoder(url)); + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/ProjectUserUtils.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/ProjectUserUtils.java new file mode 100644 index 0000000000..2fe2ac2535 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/ProjectUserUtils.java @@ -0,0 +1,52 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.utils; + +import com.webank.wedatasphere.dss.framework.project.entity.DSSProjectUser; +import org.apache.commons.collections.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class ProjectUserUtils { + + + public static List createPUser(Long wid, Long pid, List users, int priv){ + List retList = new ArrayList<>(); + if(CollectionUtils.isEmpty(users)){ + return retList; + } + users.forEach(tname->{ + DSSProjectUser DSSProjectUser = new DSSProjectUser(wid, pid, tname,priv); + retList.add(DSSProjectUser); + }); + return retList; + } + + + public static List getEditUserList(List releaseUsers, List editUsers){ + List sumEditUsers = new ArrayList<>(); + if (!CollectionUtils.isEmpty(releaseUsers)) { + sumEditUsers.addAll(releaseUsers); + } + if (!CollectionUtils.isEmpty(editUsers)) { + sumEditUsers.addAll(editUsers); + } + return sumEditUsers.stream().distinct().collect(Collectors.toList()); + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/RestfulUtils.java b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/RestfulUtils.java new file mode 100644 index 0000000000..ad0115397f --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/java/com/webank/wedatasphere/dss/framework/project/utils/RestfulUtils.java @@ -0,0 +1,46 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.utils; + +import com.webank.wedatasphere.linkis.server.Message; +import org.apache.commons.math3.util.Pair; + +import javax.ws.rs.core.Response; +import java.util.Arrays; + + +public class RestfulUtils { + + public static Response dealError(String reason){ + Message message = Message.error(reason); + return Message.messageToResponse(message); + } + + public static Response dealOk(String msg){ + Message message = Message.ok(msg); + return Message.messageToResponse(message); + } + + @SafeVarargs + public static Response dealOk(String msg, Pair... data){ + Message message = Message.ok(msg); + Arrays.stream(data).forEach(p -> message.data(p.getKey(), p.getValue())); + return Message.messageToResponse(message); + } + + +} diff --git a/dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/DSSProjectServerApplication.scala b/dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/DSSProjectServerApplication.scala new file mode 100644 index 0000000000..3e801a0666 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/DSSProjectServerApplication.scala @@ -0,0 +1,38 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.server +import com.webank.wedatasphere.dss.common.utils.DSSMainHelper +import com.webank.wedatasphere.linkis.DataWorkCloudApplication +import com.webank.wedatasphere.linkis.common.utils.{Logging, Utils} + + +object DSSProjectServerApplication extends Logging { + + val userName: String = System.getProperty("user.name") + val hostName: String = Utils.getComputerName + + def main(args: Array[String]): Unit = { + val serviceName = System.getProperty("serviceName")//ProjectConf.SERVICE_NAME.getValue + DSSMainHelper.formatPropertyFiles(serviceName) + val allArgs = args ++ DSSMainHelper.getExtraSpringOptions + System.setProperty("hostName", hostName) + System.setProperty("userName", userName) + info(s"Ready to start $serviceName with args: ${allArgs.toList}.") + println(s"Test Ready to start $serviceName with args: ${allArgs.toList}.") + DataWorkCloudApplication.main(allArgs) + } +} \ No newline at end of file diff --git a/dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/rpc/ProjectReceiver.scala b/dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/rpc/ProjectReceiver.scala new file mode 100644 index 0000000000..1d0d3e89fe --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/rpc/ProjectReceiver.scala @@ -0,0 +1,80 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.server.rpc + +import java.util + +import com.webank.wedatasphere.dss.common.entity.project.DSSProject +import com.webank.wedatasphere.dss.common.protocol.project.{ProjectInfoRequest, ProjectRelationRequest, ProjectRelationResponse} +import com.webank.wedatasphere.dss.framework.project.entity.DSSProjectDO +import com.webank.wedatasphere.dss.framework.project.service.DSSProjectService +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceUserService +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo +import com.webank.wedatasphere.dss.orchestrator.common.protocol.RequestProjectImportOrchestrator +import com.webank.wedatasphere.linkis.protocol.usercontrol.{RequestUserListFromWorkspace, RequestUserWorkspace, ResponseUserWorkspace, ResponseWorkspaceUserList} +import com.webank.wedatasphere.linkis.rpc.{Receiver, Sender} +import org.springframework.beans.BeanUtils +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.stereotype.Component + +import scala.collection.JavaConversions._ +import scala.concurrent.duration.Duration + + +@Component +class ProjectReceiver(projectService: DSSProjectService) extends Receiver { + + @Autowired + var dssWorkspaceUserService:DSSWorkspaceUserService = _ + + + override def receive(message: Any, sender: Sender): Unit = { + + } + + override def receiveAndReply(message: Any, sender: Sender): Any = { + message match { + case projectRelationRequest: ProjectRelationRequest => + val dssProjectId = projectRelationRequest.getDssProjectId + val dssLabels = projectRelationRequest.getDssLabels + val appConnName = projectRelationRequest.getAppconnName + val appConnProjectId = projectService.getAppConnProjectId(dssProjectId, appConnName, dssLabels) + new ProjectRelationResponse(dssProjectId, appConnName, dssLabels, appConnProjectId) + case requestUserWorkspace:RequestUserWorkspace => + val userWorkspaceIds: util.List[Integer] = dssWorkspaceUserService.getUserWorkspaceIds(requestUserWorkspace.getUserName) + new ResponseUserWorkspace(userWorkspaceIds) + + case requestUserListFromWorkspace: RequestUserListFromWorkspace=> + val userList = requestUserListFromWorkspace.getUserWorkspaceIds.flatMap(id => dssWorkspaceUserService.getAllWorkspaceUsers(id)).distinct + new ResponseWorkspaceUserList(userList) + + case projectInfoRequest: ProjectInfoRequest => + val dssProjectDO: DSSProjectDO = projectService.getProjectById(projectInfoRequest.getProjectId) + val DSSProject = new DSSProject() + BeanUtils.copyProperties(dssProjectDO, DSSProject) + DSSProject + + case projectImportOrchestrator: RequestProjectImportOrchestrator => + projectService.importOrchestrator(projectImportOrchestrator) + } + } + + + override def receiveAndReply(message: Any, duration: Duration, sender: Sender): Any = { + null + } +} diff --git a/dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/rpc/ProjectReceiverChooser.scala b/dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/rpc/ProjectReceiverChooser.scala new file mode 100644 index 0000000000..350722ce8e --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/rpc/ProjectReceiverChooser.scala @@ -0,0 +1,47 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.server.rpc + +import com.webank.wedatasphere.dss.common.protocol.project.ProjectRelationRequest +import com.webank.wedatasphere.dss.framework.project.service.DSSProjectService +import com.webank.wedatasphere.linkis.rpc.{RPCMessageEvent, Receiver, ReceiverChooser} +import javax.annotation.PostConstruct +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.stereotype.Component + + +@Component +class ProjectReceiverChooser extends ReceiverChooser { + + + @Autowired + var projectService: DSSProjectService = _ + + private var receiver: Option[ProjectReceiver] = _ + + @PostConstruct + def init(): Unit = receiver = Some(new ProjectReceiver(projectService)) + + override def chooseReceiver(event: RPCMessageEvent): Option[Receiver] = event.message match { + case _: ProjectRelationRequest => receiver + case _ => None + } +} + + + + diff --git a/dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/service/BMLService.scala b/dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/service/BMLService.scala new file mode 100644 index 0000000000..3a5d837da7 --- /dev/null +++ b/dss-framework/dss-framework-project-server/src/main/scala/com/webank/wedatasphere/dss/framework/project/server/service/BMLService.scala @@ -0,0 +1,183 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.project.server.service + +import java.io.{ByteArrayInputStream, InputStream} +import java.util +import java.util.UUID + +import com.webank.wedatasphere.dss.common.exception.DSSErrorException +import com.webank.wedatasphere.dss.common.utils.IoUtils +import com.webank.wedatasphere.linkis.bml.client.{BmlClient, BmlClientFactory} +import com.webank.wedatasphere.linkis.bml.protocol.{BmlDownloadResponse, BmlUpdateResponse, BmlUploadResponse} +import com.webank.wedatasphere.linkis.common.utils.{JavaLog, Logging, Utils} +import org.apache.commons.io.IOUtils +import org.springframework.stereotype.Component + +import scala.collection.JavaConversions._ + + +@Component("projectServerBMLService") +class BMLService extends Logging{ + + def upload(userName: String, content: String, fileName: String, projectName:String): util.Map[String, Object] = { + val inputStream = new ByteArrayInputStream(content.getBytes("utf-8")) + val client: BmlClient = createBMLClient(userName) + val resource: BmlUploadResponse = client.uploadShareResource(userName, projectName, fileName, inputStream) + if (!resource.isSuccess) throw new DSSErrorException(911113, "上传失败") + val map = new util.HashMap[String, Object] + map += "resourceId" -> resource.resourceId + map += "version" -> resource.version + } + + def upload(userName: String, inputStream: InputStream, fileName: String, projectName:String): util.Map[String, Object] = { + val client: BmlClient = createBMLClient(userName) + val resource: BmlUploadResponse = client.uploadShareResource(userName, projectName, fileName, inputStream) + if (!resource.isSuccess) throw new DSSErrorException(911113, "上传失败") + val map = new util.HashMap[String, Object] + map += "resourceId" -> resource.resourceId + map += "version" -> resource.version + } + + def update(userName: String, resourceId: String, inputStream: InputStream): util.Map[String, Object] = { + val client: BmlClient = createBMLClient(userName) + val resource: BmlUpdateResponse = client.updateShareResource(userName, resourceId, "", inputStream) + if (!resource.isSuccess) throw new DSSErrorException(911114, "更新失败") + val map = new util.HashMap[String, Object] + map += "resourceId" -> resource.resourceId + map += "version" -> resource.version + } + + def update(userName: String, resourceId: String, content: String): util.Map[String, Object] = { + val inputStream = new ByteArrayInputStream(content.getBytes("utf-8")) + val client: BmlClient = createBMLClient(userName) + val resource: BmlUpdateResponse = client.updateShareResource(userName, resourceId, UUID.randomUUID().toString+".json", inputStream) + if (!resource.isSuccess) throw new DSSErrorException(911114, "更新失败") + val map = new util.HashMap[String, Object] + map += "resourceId" -> resource.resourceId + map += "version" -> resource.version + } + + def query(userName: String, resourceId: String, version: String): util.Map[String, Object] = { + val client: BmlClient = createBMLClient(userName) + var resource: BmlDownloadResponse = null + if (version == null) { + resource = client.downloadShareResource(userName, resourceId) + } else { + resource = client.downloadShareResource(userName, resourceId, version) + } + if (!resource.isSuccess) throw new DSSErrorException(911115, "下载失败") + val map = new util.HashMap[String, Object] + map += "path" -> resource.fullFilePath + map += "string" -> inputstremToString(resource.inputStream) + } + + def download(userName: String, resourceId: String, version: String): util.Map[String, Object] = { + val client: BmlClient = createBMLClient(userName) + var resource: BmlDownloadResponse = null + if (version == null) { + resource = client.downloadShareResource(userName, resourceId) + } else { + resource = client.downloadShareResource(userName, resourceId, version) + } + if (!resource.isSuccess) throw new DSSErrorException(911115, "下载失败") + val map = new util.HashMap[String, Object] + map += "path" -> resource.fullFilePath + map += "is" -> resource.inputStream + } + + def downloadToLocalPath(userName: String, resourceId: String, version: String, path: String): String = { + val result = download(userName,resourceId,version) + val is = result.get("is").asInstanceOf[InputStream] + val os = IoUtils.generateExportOutputStream(path) + Utils.tryFinally(IOUtils.copy(is,os)){ + IOUtils.closeQuietly(os) + IOUtils.closeQuietly(is) + } + path + } + + def downloadAndGetFlowJson(userName: String, resourceId: String, version: String, path: String): String = { + downloadToLocalPath(userName,resourceId,version,path) + //因为下载到指定目录后返回的resource的Stream为null,只能从文件重新读取。 + val is = IoUtils.generateInputInputStream(path) + Utils.tryFinally(inputstremToString(is))(IOUtils.closeQuietly(is)) + } + + def readLocalResourceFile(userName: String,readPath: String): InputStream ={ + IoUtils.generateInputInputStream(readPath) + } + + def readLocalFlowJsonFile(userName: String,readPath: String): String ={ + var inputStream:InputStream = null + var flowJson:String = null + Utils.tryFinally{ + inputStream = IoUtils.generateInputInputStream(readPath) + flowJson = inputstremToString(inputStream) + }{ + IOUtils.closeQuietly(inputStream) + } + flowJson + } + + private def inputstremToString(inputStream: InputStream): String = { + scala.io.Source.fromInputStream(inputStream).mkString + } + + private def createBMLClient(userName: String): BmlClient = { + if (userName == null) + BmlClientFactory.createBmlClient() + else + BmlClientFactory.createBmlClient(userName) + } + + def createBmlProject(username:String, projectName:String, editUsers:util.List[String], + accessUsers:util.List[String] ): Unit ={ + val client = createBMLClient(username) + val response = client.createBmlProject(username, projectName, accessUsers, editUsers) + if (response.isSuccess){ + logger.info(s"for user $username create bml project $projectName success") + }else{ + logger.error(s"for user $username create bml project $projectName failed") + } + } + + def attachResourceAndProject(username:String, projectName:String, resourceId:String):Unit = { + val client = createBMLClient(username) + val response = client.attachResourceAndProject(projectName, resourceId) + if (response.isSuccess){ + logger.info(s"attach $username and $projectName success") + }else{ + logger.error(s"attach $username and $projectName failed") + } + } + + + def updateProjectPriv(projectName:String, username:String, editUsers:util.List[String], + accessUsers:util.List[String]): Unit ={ + val client = createBMLClient(username) + val response = client.updateProjectPriv(username, projectName, editUsers, accessUsers) + if (response.isSuccess){ + logger.info(s"attach $username and $projectName success") + }else{ + logger.error(s"attach $username and $projectName failed") + } + } + + + +} diff --git a/dss-framework/dss-framework-workspace-server/bin/start-dss-framework-workspace-server.sh b/dss-framework/dss-framework-workspace-server/bin/start-dss-framework-workspace-server.sh new file mode 100644 index 0000000000..971d93d9ed --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/bin/start-dss-framework-workspace-server.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +cd `dirname $0` +cd .. +HOME=`pwd` +export DWS_ENGINE_MANAGER_HOME=$HOME + +export DWS_ENGINE_MANAGER_PID=$HOME/bin/linkis.pid + +if [[ -f "${DWS_ENGINE_MANAGER_PID}" ]]; then + pid=$(cat ${DWS_ENGINE_MANAGER_PID}) + if kill -0 ${pid} >/dev/null 2>&1; then + echo "DSS SERVER is already running." + return 0; + fi +fi + +export DWS_ENGINE_MANAGER_LOG_PATH=$HOME/logs +export DWS_ENGINE_MANAGER_HEAP_SIZE="1G" + +export DWS_ENGINE_MANAGER_JAVA_OPTS="-Xms$DWS_ENGINE_MANAGER_HEAP_SIZE -Xmx$DWS_ENGINE_MANAGER_HEAP_SIZE -XX:+UseG1GC -XX:MaxPermSize=500m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=20014" + +#export DWS_ENGINE_MANAGER_JAVA_OPTS="-Xms$DWS_ENGINE_MANAGER_HEAP_SIZE -Xmx$DWS_ENGINE_MANAGER_HEAP_SIZE -XX:+UseG1GC -XX:MaxPermSize=500m" + +nohup java $DWS_ENGINE_MANAGER_JAVA_OPTS -cp $HOME/conf:$HOME/lib/* com.webank.wedatasphere.linkis.DataWorkCloudApplication 2>&1 > $DWS_ENGINE_MANAGER_LOG_PATH/linkis.out & +pid=$! +if [[ -z "${pid}" ]]; then + echo "DSS SERVER start failed!" + sleep 1 + exit 1 +else + echo "DSS SERVER start succeeded!" + echo $pid > $DWS_ENGINE_MANAGER_PID + sleep 1 +fi +exit 1 \ No newline at end of file diff --git a/dss-framework/dss-framework-workspace-server/bin/stop-dss-framework-workspace-server.sh b/dss-framework/dss-framework-workspace-server/bin/stop-dss-framework-workspace-server.sh new file mode 100644 index 0000000000..2ca464de62 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/bin/stop-dss-framework-workspace-server.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +cd `dirname $0` +cd .. +HOME=`pwd` + +export FLOW_ENTRANCE_HOME_PID=$HOME/bin/linkis.pid + +function wait_for_FLOW_ENTRANCE_HOME_to_die() { + local pid + local count + pid=$1 + timeout=$2 + count=0 + timeoutTime=$(date "+%s") + let "timeoutTime+=$timeout" + currentTime=$(date "+%s") + forceKill=1 + + while [[ $currentTime -lt $timeoutTime ]]; do + $(kill ${pid} > /dev/null 2> /dev/null) + if kill -0 ${pid} > /dev/null 2>&1; then + sleep 3 + else + forceKill=0 + break + fi + currentTime=$(date "+%s") + done + + if [[ forceKill -ne 0 ]]; then + $(kill -9 ${pid} > /dev/null 2> /dev/null) + fi +} + +if [[ ! -f "${FLOW_ENTRANCE_HOME_PID}" ]]; then + echo "DSS SERVER is not running" +else + pid=$(cat ${FLOW_ENTRANCE_HOME_PID}) + if [[ -z "${pid}" ]]; then + echo "DSS SERVER is not running" + else + wait_for_FLOW_ENTRANCE_HOME_to_die $pid 40 + $(rm -f ${FLOW_ENTRANCE_HOME_PID}) + echo "DSS SERVER is stopped." + fi +fi \ No newline at end of file diff --git a/dss-framework/dss-framework-workspace-server/pom.xml b/dss-framework/dss-framework-workspace-server/pom.xml new file mode 100644 index 0000000000..5541740e31 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/pom.xml @@ -0,0 +1,133 @@ + + + + + + dss + com.webank.wedatasphere.dss + 1.0.0 + + + 4.0.0 + + dss-framework-workspace-server + + + + + com.webank.wedatasphere.linkis + linkis-module + ${linkis.version} + provided + + + + + com.webank.wedatasphere.dss + dss-common + ${dss.version} + provided + + + + org.apache.commons + commons-lang3 + ${commons.lang3.version} + provided + + + com.webank.wedatasphere.linkis + linkis-httpclient + ${linkis.version} + + + linkis-common + com.webank.wedatasphere.linkis + + + + + + com.webank.wedatasphere.dss + dss-framework-common + ${dss.version} + + + com.webank.wedatasphere.linkis + linkis-mybatis + ${linkis.version} + provided + + + + org.apache.commons + commons-math3 + provided + + + com.webank.wedatasphere.dss + dss-appconn-manager-client + ${dss.version} + provided + + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + + + net.alchim31.maven + scala-maven-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + + + src/main/java + + **/*.xml + + + + + + \ No newline at end of file diff --git a/dss-framework/dss-framework-workspace-server/src/main/assembly/distribution.xml b/dss-framework/dss-framework-workspace-server/src/main/assembly/distribution.xml new file mode 100644 index 0000000000..5303b0f554 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/assembly/distribution.xml @@ -0,0 +1,320 @@ + + + + dss-framework-workspace-server + + zip + + true + dss-framework-workspace-server + + + + + + lib + true + true + false + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${basedir}/src/main/resources + + * + + 0777 + conf + unix + + + ${basedir}/bin + + * + + 0777 + bin + unix + + + . + + */** + + logs + + + + + diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/annotation/DSSWorkspaceUM.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/annotation/DSSWorkspaceUM.java new file mode 100644 index 0000000000..74e80506d4 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/annotation/DSSWorkspaceUM.java @@ -0,0 +1,29 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD}) +public @interface DSSWorkspaceUM { + String value() default ""; +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/annotation/WorkspaceIdChecker.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/annotation/WorkspaceIdChecker.java new file mode 100644 index 0000000000..3de0c1ef9d --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/annotation/WorkspaceIdChecker.java @@ -0,0 +1,29 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD}) +public @interface WorkspaceIdChecker { + String value() default ""; +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/aop/DSSPrivCheckerAspect.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/aop/DSSPrivCheckerAspect.java new file mode 100644 index 0000000000..ff8e4b8188 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/aop/DSSPrivCheckerAspect.java @@ -0,0 +1,28 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.aop; + +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; + + +@Aspect +@Component +public class DSSPrivCheckerAspect { + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/aop/DSSUWorkspaceIdCheckerAspect.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/aop/DSSUWorkspaceIdCheckerAspect.java new file mode 100644 index 0000000000..3f09b9f162 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/aop/DSSUWorkspaceIdCheckerAspect.java @@ -0,0 +1,29 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.aop; + +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; + + +@Aspect +@Component +public class DSSUWorkspaceIdCheckerAspect { + + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/aop/DSSWorkspaceUMAspect.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/aop/DSSWorkspaceUMAspect.java new file mode 100644 index 0000000000..e42e2b6a95 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/aop/DSSWorkspaceUMAspect.java @@ -0,0 +1,26 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.aop; + +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; + + +@Aspect +@Component +public class DSSWorkspaceUMAspect { +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/BaseEntity.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/BaseEntity.java new file mode 100644 index 0000000000..0f99605604 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/BaseEntity.java @@ -0,0 +1,63 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import java.util.Date; + + +public class BaseEntity { + + private String createBy; + + private Date createTime = new Date(); + + private Date lastUpdateTime = new Date(); + + private String lastUpdateUser; + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(Date lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + public String getLastUpdateUser() { + return lastUpdateUser; + } + + public void setLastUpdateUser(String lastUpdateUser) { + this.lastUpdateUser = lastUpdateUser; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSApplication.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSApplication.java new file mode 100644 index 0000000000..a7b214b2d9 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSApplication.java @@ -0,0 +1,169 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; + + +@TableName(value = "dss_application") +public class DSSApplication implements Serializable { + + private static final long serialVersionUID=1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + private String name; + + private String url; + + private Boolean isUserNeedInit; + + private Integer level; + + private String userInitUrl; + + private Boolean existsProjectService; + + private String projectUrl; + + private String enhanceJson; + + private Boolean ifIframe; + + private String homepageUrl; + + private String redirectUrl; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public Boolean getUserNeedInit() { + return isUserNeedInit; + } + + public void setUserNeedInit(Boolean userNeedInit) { + isUserNeedInit = userNeedInit; + } + + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + + public String getUserInitUrl() { + return userInitUrl; + } + + public void setUserInitUrl(String userInitUrl) { + this.userInitUrl = userInitUrl; + } + + public Boolean getExistsProjectService() { + return existsProjectService; + } + + public void setExistsProjectService(Boolean existsProjectService) { + this.existsProjectService = existsProjectService; + } + + public String getProjectUrl() { + return projectUrl; + } + + public void setProjectUrl(String projectUrl) { + this.projectUrl = projectUrl; + } + + public String getEnhanceJson() { + return enhanceJson; + } + + public void setEnhanceJson(String enhanceJson) { + this.enhanceJson = enhanceJson; + } + + public Boolean getIfIframe() { + return ifIframe; + } + + public void setIfIframe(Boolean ifIframe) { + this.ifIframe = ifIframe; + } + + public String getHomepageUrl() { + return homepageUrl; + } + + public void setHomepageUrl(String homepageUrl) { + this.homepageUrl = homepageUrl; + } + + public String getRedirectUrl() { + return redirectUrl; + } + + public void setRedirectUrl(String redirectUrl) { + this.redirectUrl = redirectUrl; + } + + @Override + public String toString() { + return "DssApplication{" + + "id=" + id + + ", name='" + name + '\'' + + ", url='" + url + '\'' + + ", isUserNeedInit=" + isUserNeedInit + + ", level=" + level + + ", userInitUrl='" + userInitUrl + '\'' + + ", existsProjectService=" + existsProjectService + + ", projectUrl='" + projectUrl + '\'' + + ", enhanceJson='" + enhanceJson + '\'' + + ", ifIframe=" + ifIframe + + ", homepageUrl='" + homepageUrl + '\'' + + ", redirectUrl='" + redirectUrl + '\'' + + '}'; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSApplicationBean.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSApplicationBean.java new file mode 100644 index 0000000000..c0ead44315 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSApplicationBean.java @@ -0,0 +1,57 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + + +public class DSSApplicationBean { + private Integer id; + private String name; + private String homepageUrl; + private String projectUrl; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getHomepageUrl() { + return homepageUrl; + } + + public void setHomepageUrl(String homepageUrl) { + this.homepageUrl = homepageUrl; + } + + public String getProjectUrl() { + return projectUrl; + } + + public void setProjectUrl(String projectUrl) { + this.projectUrl = projectUrl; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSComponentRole.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSComponentRole.java new file mode 100644 index 0000000000..9cac8a2681 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSComponentRole.java @@ -0,0 +1,102 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.Date; + + +@TableName(value = "dss_component_role") +public class DSSComponentRole implements Serializable { + private static final long serialVersionUID=1L; + + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + private Long workspaceId; + + private Integer componentId; + + private Integer roleId; + + private Integer priv; + + private Date updateTime; + + private String updateby; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Long workspaceId) { + this.workspaceId = workspaceId; + } + + public Integer getComponentId() { + return componentId; + } + + public void setComponentId(Integer componentId) { + this.componentId = componentId; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + public Integer getPriv() { + return priv; + } + + public void setPriv(Integer priv) { + this.priv = priv; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateby() { + return updateby; + } + + public void setUpdateby(String updateby) { + this.updateby = updateby; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSDictionary.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSDictionary.java new file mode 100644 index 0000000000..6214e75b48 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSDictionary.java @@ -0,0 +1,304 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.Date; + + +@TableName(value = "dss_dictionary") +public class DSSDictionary implements Serializable { + + private static final long serialVersionUID=1L; + + /** + * 主键ID,默认为0,所有空间都有 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + /** + * 空间ID,默认为0,所有空间都有 + */ + private Integer workspaceId; + + /** + * 父key + */ + private String parentKey; + + /** + * 名称 + */ + private String dicName; + /** + * 名称(英文) + */ + private String dicNameEn; + + /** + * key 相当于编码,空间是w_开头,工程是p_ + */ + private String dicKey; + + /** + * key对应的值 + */ + private String dicValue; + + /** + * key对应的值(英文) + */ + private String dicValueEn; + + /** + * 标题 + */ + private String title; + + /** + * 标题(英文) + */ + private String titleEn; + + /** + * url + */ + private String url; + + /** + * url类型: 0-内部系统,1-外部系统;默认是内部 + */ + private Integer urlType; + + /** + * 图标 + */ + private String icon; + + /** + * 序号 + */ + private Integer orderNum; + + /** + * 备注 + */ + private String remark; + + /** + * 创建人 + */ + private String createUser; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新人 + */ + private String updateUser; + + /** + * 更新时间 + */ + private Date updateTime; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Integer workspaceId) { + this.workspaceId = workspaceId; + } + + public String getParentKey() { + return parentKey; + } + + public void setParentKey(String parentKey) { + this.parentKey = parentKey; + } + + public String getDicName() { + return dicName; + } + + public void setDicName(String dicName) { + this.dicName = dicName; + } + + public String getDicKey() { + return dicKey; + } + + public void setDicKey(String dicKey) { + this.dicKey = dicKey; + } + + public String getDicValue() { + return dicValue; + } + + public void setDicValue(String dicValue) { + this.dicValue = dicValue; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public Integer getUrlType() { + return urlType; + } + + public void setUrlType(Integer urlType) { + this.urlType = urlType; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public Integer getOrderNum() { + return orderNum; + } + + public void setOrderNum(Integer orderNum) { + this.orderNum = orderNum; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getCreateUser() { + return createUser; + } + + public void setCreateUser(String createUser) { + this.createUser = createUser; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getUpdateUser() { + return updateUser; + } + + public void setUpdateUser(String updateUser) { + this.updateUser = updateUser; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getDicNameEn() { + return dicNameEn; + } + + public void setDicNameEn(String dicNameEn) { + this.dicNameEn = dicNameEn; + } + + public String getDicValueEn() { + return dicValueEn; + } + + public void setDicValueEn(String dicValueEn) { + this.dicValueEn = dicValueEn; + } + + public String getTitleEn() { + return titleEn; + } + + public void setTitleEn(String titleEn) { + this.titleEn = titleEn; + } + + @Override + public String toString() { + return "DSSDictionary{" + + "id=" + id + + ", workspaceId=" + workspaceId + + ", parentKey='" + parentKey + '\'' + + ", dicName='" + dicName + '\'' + + ", dicNameEn='" + dicNameEn + '\'' + + ", dicKey='" + dicKey + '\'' + + ", dicValue='" + dicValue + '\'' + + ", dicValueEn='" + dicValueEn + '\'' + + ", title='" + title + '\'' + + ", titleEn='" + titleEn + '\'' + + ", url='" + url + '\'' + + ", urlType=" + urlType + + ", icon='" + icon + '\'' + + ", orderNum=" + orderNum + + ", remark='" + remark + '\'' + + ", createUser='" + createUser + '\'' + + ", createTime=" + createTime + + ", updateUser='" + updateUser + '\'' + + ", updateTime=" + updateTime + + '}'; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSFavorite.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSFavorite.java new file mode 100644 index 0000000000..40f691d8cf --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSFavorite.java @@ -0,0 +1,70 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.webank.wedatasphere.dss.framework.workspace.bean; + + +public class DSSFavorite extends BaseEntity{ + + private Long id; + + private String username; + + private Long workspaceId; + + private Long menuApplicationId; + + private Integer order; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public Long getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Long workspaceId) { + this.workspaceId = workspaceId; + } + + public Long getMenuApplicationId() { + return menuApplicationId; + } + + public void setMenuApplicationId(Long menuApplicationId) { + this.menuApplicationId = menuApplicationId; + } + + public Integer getOrder() { + return order; + } + + public void setOrder(Integer order) { + this.order = order; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSHomepage.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSHomepage.java new file mode 100644 index 0000000000..48ab10de3c --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSHomepage.java @@ -0,0 +1,48 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + + +public class DSSHomepage { + private int id; + private String name; + private String url; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSMenu.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSMenu.java new file mode 100644 index 0000000000..d3c1ba28fb --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSMenu.java @@ -0,0 +1,169 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.google.common.base.Objects; + +import java.io.Serializable; + + +@TableName(value = "dss_menu") +public class DSSMenu implements Serializable { + private static final long serialVersionUID=1L; + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + private String name; + private int level; + private int upperMenuId; + private String frontName; + private String comment; + private String description; + private boolean isActive; + private boolean isComponent; + @TableField(exist = false) + private String url; + private String icon; + private int applicationId; + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getLevel() { + return level; + } + + public void setLevel(int level) { + this.level = level; + } + + public int getUpperMenuId() { + return upperMenuId; + } + + public void setUpperMenuId(int upperMenuId) { + this.upperMenuId = upperMenuId; + } + + public String getFrontName() { + return frontName; + } + + public void setFrontName(String frontName) { + this.frontName = frontName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isActive() { + return isActive; + } + + public void setActive(boolean active) { + isActive = active; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public boolean isComponent() { + return isComponent; + } + + public void setComponent(boolean component) { + isComponent = component; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public int getApplicationId() { + return applicationId; + } + + public void setApplicationId(int applicationId) { + this.applicationId = applicationId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + DSSMenu dssMenu = (DSSMenu) o; + return id == dssMenu.id && + level == dssMenu.level && + upperMenuId == dssMenu.upperMenuId && + isActive == dssMenu.isActive && + isComponent == dssMenu.isComponent && + applicationId == dssMenu.applicationId && + Objects.equal(name, dssMenu.name) && + Objects.equal(frontName, dssMenu.frontName) && + Objects.equal(description, dssMenu.description) && + Objects.equal(url, dssMenu.url) && + Objects.equal(icon, dssMenu.icon); + } + + @Override + public int hashCode() { + return Objects.hashCode(id, name, level, upperMenuId, frontName, description, isActive, isComponent, url, icon, applicationId); + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSMenuRole.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSMenuRole.java new file mode 100644 index 0000000000..69dca39def --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSMenuRole.java @@ -0,0 +1,115 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.Date; + + +@TableName(value = "dss_menu_role") +public class DSSMenuRole implements Serializable { + + private static final long serialVersionUID=1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + private Integer workspaceId; + + private Integer menuId; + + private Integer roleId; + + private Integer priv; + + private Date updateTime; + + private String updateby; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Integer workspaceId) { + this.workspaceId = workspaceId; + } + + public Integer getMenuId() { + return menuId; + } + + public void setMenuId(Integer menuId) { + this.menuId = menuId; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + public Integer getPriv() { + return priv; + } + + public void setPriv(Integer priv) { + this.priv = priv; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateby() { + return updateby; + } + + public void setUpdateby(String updateby) { + this.updateby = updateby; + } + + @Override + public String toString() { + return "DssMenuRole{" + + "id=" + id + + ", workspaceId=" + workspaceId + + ", menuId=" + menuId + + ", roleId=" + roleId + + ", priv=" + priv + + ", updateTime=" + updateTime + + ", updateby='" + updateby + '\'' + + '}'; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSRole.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSRole.java new file mode 100644 index 0000000000..152fe05734 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSRole.java @@ -0,0 +1,89 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import java.util.Date; + + +public class DSSRole { + private int id; + private int workspaceId; + private String name; + private String frontName; + private Date createTime; + private String description; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(int workspaceId) { + this.workspaceId = workspaceId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getFrontName() { + return frontName; + } + + public void setFrontName(String frontName) { + this.frontName = frontName; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "DSSRole{" + + "id=" + id + + ", workspaceId=" + workspaceId + + ", name='" + name + '\'' + + ", frontName='" + frontName + '\'' + + ", createTime=" + createTime + + ", description='" + description + '\'' + + '}'; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSUser.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSUser.java new file mode 100644 index 0000000000..4820b7c299 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSUser.java @@ -0,0 +1,93 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; + + +@TableName(value = "dss_user") +public class DSSUser implements Serializable { + + private static final long serialVersionUID = -5404077122214161197L; + + @TableId(type = IdType.AUTO) + private Long id; + + private String username; + + private String name; + + private Boolean isFirstLogin; + + private Boolean isAdmin; + + public DSSUser() { + } + + public DSSUser(Long id, String username, String name, Boolean isFirstLogin, Boolean isAdmin) { + this.id = id; + this.username = username; + this.name = name; + this.isFirstLogin = isFirstLogin; + this.isAdmin = isAdmin; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Boolean getFirstLogin() { + return isFirstLogin; + } + + public void setFirstLogin(Boolean firstLogin) { + isFirstLogin = firstLogin; + } + + public Boolean getAdmin() { + return isAdmin; + } + + public void setAdmin(Boolean admin) { + isAdmin = admin; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspace.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspace.java new file mode 100644 index 0000000000..d0731b7b68 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspace.java @@ -0,0 +1,124 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import java.util.Date; + + +public class DSSWorkspace { + private int id; + private String name; + private String label; + private String description; + private String createBy; + private Date createTime; + private String department; + private String product; + private String source; + private Date lastUpdateTime; + private String lastUpdateUser; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public String getProduct() { + return product; + } + + public void setProduct(String product) { + this.product = product; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public Date getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(Date lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + public String getLastUpdateUser() { + return lastUpdateUser; + } + + public void setLastUpdateUser(String lastUpdateUser) { + this.lastUpdateUser = lastUpdateUser; + } + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponent.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponent.java new file mode 100644 index 0000000000..39e791a45d --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponent.java @@ -0,0 +1,48 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + + +public class DSSWorkspaceComponent { + private int id; + private String componentName; + private String homepageUrl; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getComponentName() { + return componentName; + } + + public void setComponentName(String componentName) { + this.componentName = componentName; + } + + public String getHomepageUrl() { + return homepageUrl; + } + + public void setHomepageUrl(String homepageUrl) { + this.homepageUrl = homepageUrl; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponentInfo.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponentInfo.java new file mode 100644 index 0000000000..d7040c83b6 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponentInfo.java @@ -0,0 +1,106 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + + +import java.util.List; + + +public class DSSWorkspaceComponentInfo { + private String title; + + private String icon; + + private String desc; + + private String buttonText; +/* + private List statistics;*/ + + private String componentUrl; + + private String userManualUrl; + + private String indicatorUrl; + + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getButtonText() { + return buttonText; + } + + public void setButtonText(String buttonText) { + this.buttonText = buttonText; + } + +/* + public List getStatistics() { + return statistics; + } + + public void setStatistics(List statistics) { + this.statistics = statistics; + } +*/ + + public String getComponentUrl() { + return componentUrl; + } + + public void setComponentUrl(String componentUrl) { + this.componentUrl = componentUrl; + } + + public String getUserManualUrl() { + return userManualUrl; + } + + public void setUserManualUrl(String userManualUrl) { + this.userManualUrl = userManualUrl; + } + + public String getIndicatorUrl() { + return indicatorUrl; + } + + public void setIndicatorUrl(String indicatorUrl) { + this.indicatorUrl = indicatorUrl; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponentPriv.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponentPriv.java new file mode 100644 index 0000000000..3b05f00376 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponentPriv.java @@ -0,0 +1,100 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import java.util.Date; + + +public class DSSWorkspaceComponentPriv { + + private int id; + private int workspaceId; + private int roleId; + private int componentId; + private int priv; + private Date updateTime; + private String updateBy; + + + public DSSWorkspaceComponentPriv() { + } + + public DSSWorkspaceComponentPriv(int workspaceId, int roleId, int componentId, int priv, Date updateTime, String updateBy) { + this.workspaceId = workspaceId; + this.roleId = roleId; + this.componentId = componentId; + this.priv = priv; + this.updateTime = updateTime; + this.updateBy = updateBy; + } + + public int getComponentId() { + return componentId; + } + + public void setComponentId(int componentId) { + this.componentId = componentId; + } + + public int getPriv() { + return priv; + } + + public void setPriv(int priv) { + this.priv = priv; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(int workspaceId) { + this.workspaceId = workspaceId; + } + + public int getRoleId() { + return roleId; + } + + public void setRoleId(int roleId) { + this.roleId = roleId; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateBy() { + return updateBy; + } + + public void setUpdateBy(String updateBy) { + this.updateBy = updateBy; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponentRolePriv.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponentRolePriv.java new file mode 100644 index 0000000000..87fdd4a7ea --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceComponentRolePriv.java @@ -0,0 +1,106 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import com.google.common.base.Objects; + +import java.util.Date; + + +public class DSSWorkspaceComponentRolePriv { + private Integer id; + private Integer workspaceId; + private Integer componentId; + private Integer roleId; + private Integer priv; + private Date lastUpdateTime; + private String updateBy; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Integer workspaceId) { + this.workspaceId = workspaceId; + } + + public Integer getComponentId() { + return componentId; + } + + public void setComponentId(Integer componentId) { + this.componentId = componentId; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + public Integer getPriv() { + return priv; + } + + public void setPriv(Integer priv) { + this.priv = priv; + } + + public Date getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(Date lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + public String getUpdateBy() { + return updateBy; + } + + public void setUpdateBy(String updateBy) { + this.updateBy = updateBy; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DSSWorkspaceComponentRolePriv that = (DSSWorkspaceComponentRolePriv) o; + return Objects.equal(componentId, that.componentId) && + Objects.equal(roleId, that.roleId); + } + + @Override + public int hashCode() { + return Objects.hashCode(componentId, roleId); + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceHomepage.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceHomepage.java new file mode 100644 index 0000000000..22e218cd51 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceHomepage.java @@ -0,0 +1,88 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.time.LocalDateTime; +import java.util.Date; + + +@TableName(value = "dss_workspace_homepage") +public class DSSWorkspaceHomepage { + private static final long serialVersionUID=1L; + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + private Integer workspaceId; + private Integer roleId; + private String homepageUrl; + private Date updateTime; + + + public DSSWorkspaceHomepage(){ + + } + + public DSSWorkspaceHomepage(Integer workspaceId, Integer roleId, String homepageUrl, Date updateTime) { + this.workspaceId = workspaceId; + this.roleId = roleId; + this.homepageUrl = homepageUrl; + this.updateTime = updateTime; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Integer workspaceId) { + this.workspaceId = workspaceId; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + public String getHomepageUrl() { + return homepageUrl; + } + + public void setHomepageUrl(String homepageUrl) { + this.homepageUrl = homepageUrl; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceHomepageSetting.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceHomepageSetting.java new file mode 100644 index 0000000000..899741f72c --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceHomepageSetting.java @@ -0,0 +1,68 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import java.util.Date; + + +public class DSSWorkspaceHomepageSetting { + private Integer id; + private Integer workspaceId; + private Integer roleId; + private String homepageUrl; + private Date updateTime; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Integer workspaceId) { + this.workspaceId = workspaceId; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + public String getHomepageUrl() { + return homepageUrl; + } + + public void setHomepageUrl(String homepageUrl) { + this.homepageUrl = homepageUrl; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceMenuComponentUrl.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceMenuComponentUrl.java new file mode 100644 index 0000000000..23348c5bf0 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceMenuComponentUrl.java @@ -0,0 +1,86 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import java.util.Date; + + +public class DSSWorkspaceMenuComponentUrl { + private int id; + private int menuId; + private int dssApplicationId; + private String url; + private String manulUrl; + private String operationUrl; + private Date updateTime; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getMenuId() { + return menuId; + } + + public void setMenuId(int menuId) { + this.menuId = menuId; + } + + public int getDssApplicationId() { + return dssApplicationId; + } + + public void setDssApplicationId(int dssApplicationId) { + this.dssApplicationId = dssApplicationId; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getManulUrl() { + return manulUrl; + } + + public void setManulUrl(String manulUrl) { + this.manulUrl = manulUrl; + } + + public String getOperationUrl() { + return operationUrl; + } + + public void setOperationUrl(String operationUrl) { + this.operationUrl = operationUrl; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceMenuRole.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceMenuRole.java new file mode 100644 index 0000000000..74c51704fb --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceMenuRole.java @@ -0,0 +1,95 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import java.util.Date; + + +public class DSSWorkspaceMenuRole { + private int id; + private int workspaceId; + private int menuId; + private int roleId; + private int priv; + private Date updateTime; + private String updateBy; + + public DSSWorkspaceMenuRole(int workspaceId, int menuId, int roleId, int priv, Date updateTime, String updateBy) { + this.workspaceId = workspaceId; + this.menuId = menuId; + this.roleId = roleId; + this.priv = priv; + this.updateTime = updateTime; + this.updateBy = updateBy; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(int workspaceId) { + this.workspaceId = workspaceId; + } + + public int getMenuId() { + return menuId; + } + + public void setMenuId(int menuId) { + this.menuId = menuId; + } + + public int getRoleId() { + return roleId; + } + + public void setRoleId(int roleId) { + this.roleId = roleId; + } + + public int getPriv() { + return priv; + } + + public void setPriv(int priv) { + this.priv = priv; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateBy() { + return updateBy; + } + + public void setUpdateBy(String updateBy) { + this.updateBy = updateBy; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceMenuRolePriv.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceMenuRolePriv.java new file mode 100644 index 0000000000..f380e54498 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceMenuRolePriv.java @@ -0,0 +1,86 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import java.util.Date; + + +public class DSSWorkspaceMenuRolePriv { + private int id; + private int workspaceId; + private int menuId; + private int roleId; + private int priv; + private Date updateTime; + private String updateBy; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(int workspaceId) { + this.workspaceId = workspaceId; + } + + public int getMenuId() { + return menuId; + } + + public void setMenuId(int menuId) { + this.menuId = menuId; + } + + public int getRoleId() { + return roleId; + } + + public void setRoleId(int roleId) { + this.roleId = roleId; + } + + public int getPriv() { + return priv; + } + + public void setPriv(int priv) { + this.priv = priv; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateBy() { + return updateBy; + } + + public void setUpdateBy(String updateBy) { + this.updateBy = updateBy; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceUser.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceUser.java new file mode 100644 index 0000000000..8f57569089 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/DSSWorkspaceUser.java @@ -0,0 +1,63 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import java.util.Date; + + +public class DSSWorkspaceUser { + + private String username; + + private int workspaceId; + + private String creator; + + private Date joinTime; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public int getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(int workspaceId) { + this.workspaceId = workspaceId; + } + + public String getCreator() { + return creator; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public Date getJoinTime() { + return joinTime; + } + + public void setJoinTime(Date joinTime) { + this.joinTime = joinTime; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/LinkisUser.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/LinkisUser.java new file mode 100644 index 0000000000..ec6aa9c9b7 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/LinkisUser.java @@ -0,0 +1,84 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.util.Date; + +@TableName(value = "linkis_user") +public class LinkisUser { + @TableId(type = IdType.AUTO) + private Long id; + private String username; + private String name; + private Boolean isFirstLogin; + private Date updateTime; + private Date createTime; + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Boolean getFirstLogin() { + return isFirstLogin; + } + + public void setFirstLogin(Boolean firstLogin) { + isFirstLogin = firstLogin; + } + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/Sidebar.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/Sidebar.java new file mode 100644 index 0000000000..8a743fdd6c --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/Sidebar.java @@ -0,0 +1,185 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.Date; + + +@TableName(value = "dss_sidebar") +public class Sidebar implements Serializable { + + private static final long serialVersionUID = -5404077122214161197L; + + @TableId(type = IdType.AUTO) + private Integer id; + + //名称 + private String name; + + //名称(英文) + private String nameEn; + + //标题 + private String title; + + //标题(英文) + private String titleEn; + + //类型: 0-知识库,1-菜单,2-常见问题 + private Integer type; + + //序号 + private Integer orderNum; + + //备注 + private String remark; + + //创建人 + private String createUser; + + //创建时间 + private Date createTime; + + //更新人 + private String updateUser; + + //更新时间 + private Date updateTime; + + + public Sidebar() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Integer getOrderNum() { + return orderNum; + } + + public void setOrderNum(Integer orderNum) { + this.orderNum = orderNum; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getCreateUser() { + return createUser; + } + + public void setCreateUser(String createUser) { + this.createUser = createUser; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getUpdateUser() { + return updateUser; + } + + public void setUpdateUser(String updateUser) { + this.updateUser = updateUser; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getNameEn() { + return nameEn; + } + + public void setNameEn(String nameEn) { + this.nameEn = nameEn; + } + + public String getTitleEn() { + return titleEn; + } + + public void setTitleEn(String titleEn) { + this.titleEn = titleEn; + } + + @Override + public String toString() { + return "Sidebar{" + + "id=" + id + + ", name='" + name + '\'' + + ", nameEn='" + nameEn + '\'' + + ", title='" + title + '\'' + + ", titleEn='" + titleEn + '\'' + + ", type=" + type + + ", orderNum=" + orderNum + + ", remark='" + remark + '\'' + + ", createUser='" + createUser + '\'' + + ", createTime=" + createTime + + ", updateUser='" + updateUser + '\'' + + ", updateTime=" + updateTime + + '}'; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/SidebarContent.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/SidebarContent.java new file mode 100644 index 0000000000..100ba03bb1 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/SidebarContent.java @@ -0,0 +1,223 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.Date; + + +@TableName(value = "dss_sidebar_content") +public class SidebarContent implements Serializable { + + private static final long serialVersionUID = -5404077122214161197L; + + @TableId(type = IdType.AUTO) + private Integer id; + + //侧边栏ID + private Integer sidebarId; + + //名称 + private String name; + + //名称(英文) + private String nameEn; + + //标题 + private String title; + + //标题(英文) + private String titleEn; + + //url + private String url; + + /** + * url类型: 0-内部系统,1-外部系统;默认是内部 + */ + private Integer urlType; + + //icon + private String icon; + + //序号 + private Integer orderNum; + + //备注 + private String remark; + + //创建人 + private String createUser; + + //创建时间 + private Date createTime; + + //更新人 + private String updateUser; + + //更新时间 + private Date updateTime; + + + public SidebarContent() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getSidebarId() { + return sidebarId; + } + + public void setSidebarId(Integer sidebarId) { + this.sidebarId = sidebarId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public Integer getUrlType() { + return urlType; + } + + public void setUrlType(Integer urlType) { + this.urlType = urlType; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public Integer getOrderNum() { + return orderNum; + } + + public void setOrderNum(Integer orderNum) { + this.orderNum = orderNum; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getCreateUser() { + return createUser; + } + + public void setCreateUser(String createUser) { + this.createUser = createUser; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getUpdateUser() { + return updateUser; + } + + public void setUpdateUser(String updateUser) { + this.updateUser = updateUser; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getNameEn() { + return nameEn; + } + + public void setNameEn(String nameEn) { + this.nameEn = nameEn; + } + + public String getTitleEn() { + return titleEn; + } + + public void setTitleEn(String titleEn) { + this.titleEn = titleEn; + } + + @Override + public String toString() { + return "SidebarContent{" + + "id=" + id + + ", sidebarId=" + sidebarId + + ", name='" + name + '\'' + + ", nameEn='" + nameEn + '\'' + + ", title='" + title + '\'' + + ", titleEn='" + titleEn + '\'' + + ", url='" + url + '\'' + + ", urlType=" + urlType + + ", icon='" + icon + '\'' + + ", orderNum=" + orderNum + + ", remark='" + remark + '\'' + + ", createUser='" + createUser + '\'' + + ", createTime=" + createTime + + ", updateUser='" + updateUser + '\'' + + ", updateTime=" + updateTime + + '}'; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/StaffInfo.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/StaffInfo.java new file mode 100644 index 0000000000..7200c12da9 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/StaffInfo.java @@ -0,0 +1,147 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.annotate.JsonProperty; + + +@JsonIgnoreProperties(ignoreUnknown = true) +public class StaffInfo { + @JsonProperty(value = "ID") + private String id; + @JsonProperty(value = "StaffID") + private String staffId; + @JsonProperty(value = "OID") + private String oId; + @JsonProperty(value = "ChineseName") + private String chineseName; + @JsonProperty(value = "EnglishName") + private String englishName; + @JsonProperty(value = "FullName") + private String fullName; + @JsonProperty(value = "OrgName") + private String orgName; + @JsonProperty(value = "OrgFullName") + private String orgFullName; + @JsonProperty(value = "Status") + private String status; + @JsonProperty(value = "PersonGroup") + private String personGroup; + + public StaffInfo(String id,String englishName, String orgFullName){ + this.id = id; + this.englishName = englishName; + this.orgFullName = orgFullName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getStaffId() { + return staffId; + } + + public void setStaffId(String staffId) { + this.staffId = staffId; + } + + public String getoId() { + return oId; + } + + public void setoId(String oId) { + this.oId = oId; + } + + public String getChineseName() { + return chineseName; + } + + public void setChineseName(String chineseName) { + this.chineseName = chineseName; + } + + public String getEnglishName() { + return englishName; + } + + public void setEnglishName(String englishName) { + this.englishName = englishName; + } + + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + public String getOrgName() { + return orgName; + } + + public void setOrgName(String orgName) { + this.orgName = orgName; + } + + public String getOrgFullName() { + return orgFullName; + } + + public void setOrgFullName(String orgFullName) { + this.orgFullName = orgFullName; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getPersonGroup() { + return personGroup; + } + + public void setPersonGroup(String personGroup) { + this.personGroup = personGroup; + } + + @Override + public String toString() { + return "StaffInfo{" + + "id='" + id + '\'' + + ", staffId='" + staffId + '\'' + + ", oId='" + oId + '\'' + + ", chineseName='" + chineseName + '\'' + + ", englishName='" + englishName + '\'' + + ", fullName='" + fullName + '\'' + + ", orgName='" + orgName + '\'' + + ", orgFullName='" + orgFullName + '\'' + + ", status='" + status + '\'' + + ", personGroup='" + personGroup + '\'' + + '}'; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/WorkSpaceUserAndRole.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/WorkSpaceUserAndRole.java new file mode 100644 index 0000000000..d2fef62de7 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/WorkSpaceUserAndRole.java @@ -0,0 +1,80 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean; + +import java.util.Date; + + +public class WorkSpaceUserAndRole { + + private int id; + private int roleId; + private int workspaceId; + private Long userID; + private String creator; + private Date date; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getRoleId() { + return roleId; + } + + public void setRoleId(int roleId) { + this.roleId = roleId; + } + + public int getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(int workspaceId) { + this.workspaceId = workspaceId; + } + + public Long getUserID() { + return userID; + } + + public void setUserID(Long userID) { + this.userID = userID; + } + + public String getCreator() { + return creator; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/HomepageDemoInstanceVo.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/HomepageDemoInstanceVo.java new file mode 100644 index 0000000000..2845aba13a --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/HomepageDemoInstanceVo.java @@ -0,0 +1,93 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.webank.wedatasphere.dss.framework.workspace.bean.dto.response; + + +public class HomepageDemoInstanceVo { + + private Long id; + private Long menuId; + private String name; + private String url; + private String title; + private String description; + private String icon; + private Integer order; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getMenuId() { + return menuId; + } + + public void setMenuId(Long menuId) { + this.menuId = menuId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public Integer getOrder() { + return order; + } + + public void setOrder(Integer order) { + this.order = order; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/HomepageDemoMenuVo.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/HomepageDemoMenuVo.java new file mode 100644 index 0000000000..04b7558c58 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/HomepageDemoMenuVo.java @@ -0,0 +1,86 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.webank.wedatasphere.dss.framework.workspace.bean.dto.response; + +import java.util.List; + + +public class HomepageDemoMenuVo { + + private Long id; + private String name; + private String title; + private String description; + private String icon; + private Integer order; + private List demoInstances; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public Integer getOrder() { + return order; + } + + public void setOrder(Integer order) { + this.order = order; + } + + public List getDemoInstances() { + return demoInstances; + } + + public void setDemoInstances(List demoInstances) { + this.demoInstances = demoInstances; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/HomepageVideoVo.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/HomepageVideoVo.java new file mode 100644 index 0000000000..956c039f43 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/HomepageVideoVo.java @@ -0,0 +1,75 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.webank.wedatasphere.dss.framework.workspace.bean.dto.response; + + +public class HomepageVideoVo { + + private Long id; + private String name; + private String url; + private String title; + private String description; + private Integer order; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Integer getOrder() { + return order; + } + + public void setOrder(Integer order) { + this.order = order; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/OnestopMenuAppInstanceVo.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/OnestopMenuAppInstanceVo.java new file mode 100644 index 0000000000..6f093bf025 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/OnestopMenuAppInstanceVo.java @@ -0,0 +1,158 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.webank.wedatasphere.dss.framework.workspace.bean.dto.response; + +import java.util.Map; + + +public class OnestopMenuAppInstanceVo { + private Long id; + private String title; + private String description; + private String labels; + private String accessButton; + private String accessButtonUrl; + private String manualButton; + private String manualButtonUrl; + private String projectUrl; + private String name; + private Boolean isActive; + private String icon; + private Integer order; + private Map nameAndUrls; + //图片 + private String image; + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getLabels() { + return labels; + } + + public void setLabels(String labels) { + this.labels = labels; + } + + public String getAccessButton() { + return accessButton; + } + + public void setAccessButton(String accessButton) { + this.accessButton = accessButton; + } + + public String getAccessButtonUrl() { + return accessButtonUrl; + } + + public void setAccessButtonUrl(String accessButtonUrl) { + this.accessButtonUrl = accessButtonUrl; + } + + public String getManualButton() { + return manualButton; + } + + public void setManualButton(String manualButton) { + this.manualButton = manualButton; + } + + public String getManualButtonUrl() { + return manualButtonUrl; + } + + public void setManualButtonUrl(String manualButtonUrl) { + this.manualButtonUrl = manualButtonUrl; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public Integer getOrder() { + return order; + } + + public void setOrder(Integer order) { + this.order = order; + } + + public String getProjectUrl() { + return projectUrl; + } + + public void setProjectUrl(String projectUrl) { + this.projectUrl = projectUrl; + } + + public Boolean getActive() { + return isActive; + } + + public void setActive(Boolean active) { + isActive = active; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Map getNameAndUrls() { + return nameAndUrls; + } + + public void setNameAndUrls(Map nameAndUrls) { + this.nameAndUrls = nameAndUrls; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/OnestopMenuVo.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/OnestopMenuVo.java new file mode 100644 index 0000000000..e9dadd0cbb --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/OnestopMenuVo.java @@ -0,0 +1,59 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.dto.response; + +import java.util.List; + + +public class OnestopMenuVo { + private Long id; + private String title; + private Integer order; + private List appInstances; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getOrder() { + return order; + } + + public void setOrder(Integer order) { + this.order = order; + } + + public List getAppInstances() { + return appInstances; + } + + public void setAppInstances(List appInstances) { + this.appInstances = appInstances; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/WorkspaceDepartmentVo.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/WorkspaceDepartmentVo.java new file mode 100644 index 0000000000..fb96389d70 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/WorkspaceDepartmentVo.java @@ -0,0 +1,41 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.dto.response; + + +public class WorkspaceDepartmentVo { + + private Long id; + + private String name; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/WorkspaceFavoriteVo.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/WorkspaceFavoriteVo.java new file mode 100644 index 0000000000..af7d354bca --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/dto/response/WorkspaceFavoriteVo.java @@ -0,0 +1,98 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.dto.response; + +import com.google.common.base.Objects; + + +public class WorkspaceFavoriteVo { + private Long id; + + private Long menuApplicationId; + + private String name; + + private String url; + + private String icon; + + private String title; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getMenuApplicationId() { + return menuApplicationId; + } + + public void setMenuApplicationId(Long menuApplicationId) { + this.menuApplicationId = menuApplicationId; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WorkspaceFavoriteVo that = (WorkspaceFavoriteVo) o; + return Objects.equal(name, that.name); + } + + @Override + public int hashCode() { + return Objects.hashCode(name); + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/AbstractDSSVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/AbstractDSSVO.java new file mode 100644 index 0000000000..a18bdfd4c7 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/AbstractDSSVO.java @@ -0,0 +1,21 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + + +public abstract class AbstractDSSVO { +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSDatasourceVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSDatasourceVO.java new file mode 100644 index 0000000000..7121142f42 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSDatasourceVO.java @@ -0,0 +1,123 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.util.Arrays; + + +public class DSSDatasourceVO { + private int id; + private String name; + private String type; + private String createTime; + private String env; + private String creator; + private String responser; + private String lastUpdater; + private String lastUpdateTime; + + public DSSDatasourceVO() { + } + + public DSSDatasourceVO(int id, String name, String type, String createTime, String env, String creator, String responser, String lastUpdater, String lastUpdateTime) { + this.id = id; + this.name = name; + this.type = type; + this.createTime = createTime; + this.env = env; + this.creator = creator; + this.responser = responser; + this.lastUpdater = lastUpdater; + this.lastUpdateTime = lastUpdateTime; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getEnv() { + return env; + } + + public void setEnv(String env) { + this.env = env; + } + + public String getCreator() { + return creator; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public String getResponser() { + return responser; + } + + public void setResponser(String responser) { + this.responser = responser; + } + + public String getLastUpdater() { + return lastUpdater; + } + + public void setLastUpdater(String lastUpdater) { + this.lastUpdater = lastUpdater; + } + + public String getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(String lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSDictionaryRequestVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSDictionaryRequestVO.java new file mode 100644 index 0000000000..2d15d34cb5 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSDictionaryRequestVO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.io.Serializable; +import java.util.List; + +public class DSSDictionaryRequestVO { + + private Integer workspaceId; + + private String dicKey; + + private String parentKey; + + public Integer getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(Integer workspaceId) { + this.workspaceId = workspaceId; + } + + public String getDicKey() { + return dicKey; + } + + public void setDicKey(String dicKey) { + this.dicKey = dicKey; + } + + public String getParentKey() { + return parentKey; + } + + public void setParentKey(String parentKey) { + this.parentKey = parentKey; + } +} \ No newline at end of file diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSPersonalWorkflowVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSPersonalWorkflowVO.java new file mode 100644 index 0000000000..2909ce4600 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSPersonalWorkflowVO.java @@ -0,0 +1,83 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.util.Arrays; +import java.util.List; + + +public class DSSPersonalWorkflowVO extends AbstractDSSVO{ + private int workflowId; + private String name; + private String json; + private String description; + private List tags; + + public DSSPersonalWorkflowVO() { + } + + public DSSPersonalWorkflowVO(int workflowId, String name, String json, String description, List tags) { + this.workflowId = workflowId; + this.name = name; + this.json = json; + this.description = description; + this.tags = tags; + } + + public int getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(int workflowId) { + this.workflowId = workflowId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getJson() { + return json; + } + + public void setJson(String json) { + this.json = json; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSProjectUserVo.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSProjectUserVo.java new file mode 100644 index 0000000000..9318f5261c --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSProjectUserVo.java @@ -0,0 +1,82 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.util.Date; + + +public class DSSProjectUserVo { + private int id; + private int projectId; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getProjectId() { + return projectId; + } + + public void setProjectId(int projectId) { + this.projectId = projectId; + } + + public int getUserId() { + return userId; + } + + public void setUserId(int userId) { + this.userId = userId; + } + + public String getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(String workspaceId) { + this.workspaceId = workspaceId; + } + + + + public Date getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(Date lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + private int userId; + private String workspaceId; + + public int getPriv_param() { + return priv_param; + } + + public void setPriv_param(int priv_param) { + this.priv_param = priv_param; + } + + private int priv_param; + private Date lastUpdateTime; + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSPublicTableVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSPublicTableVO.java new file mode 100644 index 0000000000..563972575c --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSPublicTableVO.java @@ -0,0 +1,123 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.util.Arrays; + + +public class DSSPublicTableVO extends AbstractDSSVO{ + private int id; + private String name; + private String status; + private String type; + private Boolean isPartitionTable; + private String creator; + private String authority; + private String lastOperator; + private String lastOperateTime; + + public DSSPublicTableVO() { + } + + public DSSPublicTableVO(int id, String name, String status, String type, Boolean isPartitionTable, String creator, String authority, String lastOperator, String lastOperateTime) { + this.id = id; + this.name = name; + this.status = status; + this.type = type; + this.isPartitionTable = isPartitionTable; + this.creator = creator; + this.authority = authority; + this.lastOperator = lastOperator; + this.lastOperateTime = lastOperateTime; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Boolean getPartitionTable() { + return isPartitionTable; + } + + public void setPartitionTable(Boolean partitionTable) { + isPartitionTable = partitionTable; + } + + public String getCreator() { + return creator; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public String getLastOperator() { + return lastOperator; + } + + public void setLastOperator(String lastOperator) { + this.lastOperator = lastOperator; + } + + public String getLastOperateTime() { + return lastOperateTime; + } + + public void setLastOperateTime(String lastOperateTime) { + this.lastOperateTime = lastOperateTime; + } + + + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSScheduledWorkFlow.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSScheduledWorkFlow.java new file mode 100644 index 0000000000..6fb7e9b7d7 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSScheduledWorkFlow.java @@ -0,0 +1,21 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + + +public class DSSScheduledWorkFlow { +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSScheduledWorkFlowVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSScheduledWorkFlowVO.java new file mode 100644 index 0000000000..0afa182337 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSScheduledWorkFlowVO.java @@ -0,0 +1,131 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.util.Date; + + +public class DSSScheduledWorkFlowVO extends AbstractDSSVO{ + private String workflowName; + private String project; + private Date scheduledTime; + private String newestVersion; + private String lastScheduledStatus; + private String committer; + private String lastOperator; + private Date lastOperateTime; + private String workflowJson; + private int workflowId; + public DSSScheduledWorkFlowVO() { + } + + public DSSScheduledWorkFlowVO(String workflowName, String project, Date scheduledTime, String newestVersion, + String lastScheduledStatus, String committer, String lastOperator, Date lastOperateTime) { + this.workflowName = workflowName; + this.project = project; + this.scheduledTime = scheduledTime; + this.newestVersion = newestVersion; + this.lastScheduledStatus = lastScheduledStatus; + this.committer = committer; + this.lastOperator = lastOperator; + this.lastOperateTime = lastOperateTime; + } + + public String getWorkflowName() { + return workflowName; + } + + public void setWorkflowName(String workflowName) { + this.workflowName = workflowName; + } + + public String getProject() { + return project; + } + + public void setProject(String project) { + this.project = project; + } + + public Date getScheduledTime() { + return scheduledTime; + } + + public void setScheduledTime(Date scheduledTime) { + this.scheduledTime = scheduledTime; + } + + public String getNewestVersion() { + return newestVersion; + } + + public void setNewestVersion(String newestVersion) { + this.newestVersion = newestVersion; + } + + public String getLastScheduledStatus() { + return lastScheduledStatus; + } + + public void setLastScheduledStatus(String lastScheduledStatus) { + this.lastScheduledStatus = lastScheduledStatus; + } + + public String getCommitter() { + return committer; + } + + public void setCommitter(String committer) { + this.committer = committer; + } + + public String getLastOperator() { + return lastOperator; + } + + public void setLastOperator(String lastOperator) { + this.lastOperator = lastOperator; + } + + public Date getLastOperateTime() { + return lastOperateTime; + } + + public void setLastOperateTime(Date lastOperateTime) { + this.lastOperateTime = lastOperateTime; + } + + public String getWorkflowJson() { + return workflowJson; + } + + public void setWorkflowJson(String workflowJson) { + this.workflowJson = workflowJson; + } + + public int getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(int workflowId) { + this.workflowId = workflowId; + } + + + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkflowVersionVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkflowVersionVO.java new file mode 100644 index 0000000000..5d13aa5a02 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkflowVersionVO.java @@ -0,0 +1,93 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.util.Arrays; +import java.util.List; + + +public class DSSWorkflowVersionVO { + private int workflowId; + private String version; + private String creator; + private String comment; + private String createTime; + private String workflowJson; + + public DSSWorkflowVersionVO() { + } + + public DSSWorkflowVersionVO(int workflowId, String version, String creator, String comment, String createTime, String workflowJson) { + this.workflowId = workflowId; + this.version = version; + this.creator = creator; + this.comment = comment; + this.createTime = createTime; + this.workflowJson = workflowJson; + } + + public int getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(int workflowId) { + this.workflowId = workflowId; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getCreator() { + return creator; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getWorkflowJson() { + return workflowJson; + } + + public void setWorkflowJson(String workflowJson) { + this.workflowJson = workflowJson; + } + + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceComponentPrivVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceComponentPrivVO.java new file mode 100644 index 0000000000..7e217f7fee --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceComponentPrivVO.java @@ -0,0 +1,72 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.io.Serializable; +import java.util.Map; + + +public class DSSWorkspaceComponentPrivVO extends AbstractDSSVO implements Serializable { + private static final long serialVersionUID=1L; + + private int id; + private String name; + private Map componentPrivs; + + + public DSSWorkspaceComponentPrivVO() { + } + + public DSSWorkspaceComponentPrivVO(int id, String name, Map componentPrivs) { + this.id = id; + this.name = name; + this.componentPrivs = componentPrivs; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Map getComponentPrivs() { + return componentPrivs; + } + + public void setComponentPrivs(Map componentPrivs) { + this.componentPrivs = componentPrivs; + } + + @Override + public String toString() { + return "DSSWorkspaceComponentPrivVO{" + + "id=" + id + + ", name='" + name + '\'' + + ", componentPrivs=" + componentPrivs + + '}'; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceHomePageVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceHomePageVO.java new file mode 100644 index 0000000000..35591554ec --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceHomePageVO.java @@ -0,0 +1,63 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + + +public class DSSWorkspaceHomePageVO { + private int workspaceId; + private String roleName; + private String homePageUrl; + + public DSSWorkspaceHomePageVO() { + } + + public DSSWorkspaceHomePageVO(int workspaceId, String roleName, String username, String homePageUrl) { + this.workspaceId = workspaceId; + this.roleName = roleName; + this.homePageUrl = homePageUrl; + } + + + public int getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(int workspaceId) { + this.workspaceId = workspaceId; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + + + public String getHomePageUrl() { + return homePageUrl; + } + + public void setHomePageUrl(String homePageUrl) { + this.homePageUrl = homePageUrl; + } + + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceHomepageSettingVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceHomepageSettingVO.java new file mode 100644 index 0000000000..180e0da6df --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceHomepageSettingVO.java @@ -0,0 +1,86 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.util.List; +import java.util.Map; + + +public class DSSWorkspaceHomepageSettingVO { + + public static class RoleHomepage{ + private String roleName; + private String homepageName; + private String homepageUrl; + private int roleId; + private String roleFrontName; + + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public String getHomepageName() { + return homepageName; + } + + public void setHomepageName(String homepageName) { + this.homepageName = homepageName; + } + + public String getHomepageUrl() { + return homepageUrl; + } + + public void setHomepageUrl(String homepageUrl) { + this.homepageUrl = homepageUrl; + } + + + public int getRoleId() { + return roleId; + } + + public void setRoleId(int roleId) { + this.roleId = roleId; + } + + public String getRoleFrontName() { + return roleFrontName; + } + + public void setRoleFrontName(String roleFrontName) { + this.roleFrontName = roleFrontName; + } + } + + private List roleHomepages; + + public List getRoleHomepages() { + return roleHomepages; + } + + public void setRoleHomepages(List roleHomepages) { + this.roleHomepages = roleHomepages; + } + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceMenuPrivVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceMenuPrivVO.java new file mode 100644 index 0000000000..ed4c866204 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceMenuPrivVO.java @@ -0,0 +1,70 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.io.Serializable; +import java.util.Map; + + +public class DSSWorkspaceMenuPrivVO extends AbstractDSSVO implements Serializable { + private static final long serialVersionUID=1L; + private int id; + private String name; + private Map menuPrivs; + + public DSSWorkspaceMenuPrivVO() { + } + + public DSSWorkspaceMenuPrivVO(int id, String name, Map menuPrivs) { + this.id = id; + this.name = name; + this.menuPrivs = menuPrivs; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Map getMenuPrivs() { + return menuPrivs; + } + + public void setMenuPrivs(Map menuPrivs) { + this.menuPrivs = menuPrivs; + } + + @Override + public String toString() { + return "DSSWorkspaceMenuPrivVO{" + + "id=" + id + + ", name='" + name + '\'' + + ", menuPrivs=" + menuPrivs + + '}'; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceMenuPrivsVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceMenuPrivsVO.java new file mode 100644 index 0000000000..85e513b749 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceMenuPrivsVO.java @@ -0,0 +1,48 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + + +public class DSSWorkspaceMenuPrivsVO { + public int getRoleId() { + return roleId; + } + + public void setRoleId(int roleId) { + this.roleId = roleId; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public Boolean getVisable() { + return isVisable; + } + + public void setVisable(Boolean visable) { + isVisable = visable; + } + + private int roleId; + private String roleName; + private Boolean isVisable; +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceMenuVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceMenuVO.java new file mode 100644 index 0000000000..22055243b1 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceMenuVO.java @@ -0,0 +1,75 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.util.ArrayList; +import java.util.List; + + +public class DSSWorkspaceMenuVO { + private int id; + private String name; + private String icon; + private List subMenus; + + public DSSWorkspaceMenuVO(){ + + } + + public DSSWorkspaceMenuVO(int id, String name, List subMenus) { + this.id = id; + this.name = name; + this.subMenus = subMenus; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getSubMenus() { + return subMenus; + } + + public void setSubMenus(List subMenus) { + this.subMenus = subMenus; + } + + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceOverviewVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceOverviewVO.java new file mode 100644 index 0000000000..885b204936 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceOverviewVO.java @@ -0,0 +1,119 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.util.List; +import java.util.Map; + + +public class DSSWorkspaceOverviewVO { + private String title; + + + private String description; + + private String dssDescription; + + + + + private List videos; + + + Map> demos; + + public static class OverviewInfo{ + private int id; + private String title; + private String url; + + public OverviewInfo(){ + + } + + public OverviewInfo(String title, String url){ + this.title = title; + this.url = url; + } + + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDssDescription() { + return dssDescription; + } + + public void setDssDescription(String dssDescription) { + this.dssDescription = dssDescription; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + + public Map> getDemos() { + return demos; + } + + public void setDemos(Map> demos) { + this.demos = demos; + } + + public List getVideos() { + return videos; + } + + public void setVideos(List videos) { + this.videos = videos; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspacePrivVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspacePrivVO.java new file mode 100644 index 0000000000..fe5e3771de --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspacePrivVO.java @@ -0,0 +1,88 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.io.Serializable; +import java.util.List; + + +public class DSSWorkspacePrivVO implements Serializable { + private static final long serialVersionUID=1L; + private int workspaceId; + private List menuPrivVOS; + private List componentPrivVOS; + private List roleVOS; + + public List getRoleVOS() { + return roleVOS; + } + + public void setRoleVOS(List roleVOS) { + this.roleVOS = roleVOS; + } + + + + + public DSSWorkspacePrivVO() { + } + + public DSSWorkspacePrivVO(int workspaceId, List menuPrivVOS, List componentPrivVOS,List roleVOS) { + this.workspaceId = workspaceId; + this.menuPrivVOS = menuPrivVOS; + this.componentPrivVOS = componentPrivVOS; + this.roleVOS=roleVOS; + } + + public int getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(int workspaceId) { + this.workspaceId = workspaceId; + } + + public List getMenuPrivVOS() { + return menuPrivVOS; + } + + public void setMenuPrivVOS(List menuPrivVOS) { + this.menuPrivVOS = menuPrivVOS; + } + + public List getComponentPrivVOS() { + return componentPrivVOS; + } + + public void setComponentPrivVOS(List componentPrivVOS) { + this.componentPrivVOS = componentPrivVOS; + } + + @Override + public String toString() { + return "DSSWorkspacePrivVO{" + + "workspaceId=" + workspaceId + + ", menuPrivVOS=" + menuPrivVOS + + ", componentPrivVOS=" + componentPrivVOS + + ", roleVOS=" + roleVOS + + '}'; + } + + + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceRoleVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceRoleVO.java new file mode 100644 index 0000000000..3e0d681df8 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceRoleVO.java @@ -0,0 +1,62 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.io.Serializable; + + +public class DSSWorkspaceRoleVO implements Serializable { + private static final long serialVersionUID=1L; + + private int roleId; + private String roleName; + private String roleFrontName; + + + public int getRoleId() { + return roleId; + } + + public void setRoleId(int roleId) { + this.roleId = roleId; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public String getRoleFrontName() { + return roleFrontName; + } + + public void setRoleFrontName(String roleFrontName) { + this.roleFrontName = roleFrontName; + } + + @Override + public String toString() { + return "DSSWorkspaceRoleVO{" + + "roleId=" + roleId + + ", roleName='" + roleName + '\'' + + ", roleFrontName='" + roleFrontName + '\'' + + '}'; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceScriptisStatiticVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceScriptisStatiticVO.java new file mode 100644 index 0000000000..8331e46b08 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceScriptisStatiticVO.java @@ -0,0 +1,65 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.util.HashMap; +import java.util.Map; + + +public class DSSWorkspaceScriptisStatiticVO extends DSSWorkspaceStatisticVO{ + private String name; + + private String status; + + private Map statistics; + + public DSSWorkspaceScriptisStatiticVO() { + } + + public DSSWorkspaceScriptisStatiticVO(String name, String status, Map statistics) { + this.name = name; + this.status = status; + this.statistics = statistics; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Map getStatistics() { + return statistics; + } + + public void setStatistics(Map statistics) { + this.statistics = statistics; + } + + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceStatisticVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceStatisticVO.java new file mode 100644 index 0000000000..259a97740c --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceStatisticVO.java @@ -0,0 +1,22 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + + +public class DSSWorkspaceStatisticVO extends AbstractDSSVO{ + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceUserVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceUserVO.java new file mode 100644 index 0000000000..a3aa5775f9 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceUserVO.java @@ -0,0 +1,97 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + + +public class DSSWorkspaceUserVO extends AbstractDSSVO{ + private int id; + private String name; + private List roles; + private String department; + private String office; + private String creator; + private Date joinTime; + + public DSSWorkspaceUserVO() { + } + + + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public String getOffice() { + return office; + } + + public void setOffice(String office) { + this.office = office; + } + + public String getCreator() { + return creator; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public Date getJoinTime() { + return joinTime; + } + + public void setJoinTime(Date joinTime) { + this.joinTime = joinTime; + } + + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceVO.java new file mode 100644 index 0000000000..c5f90b30a8 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DSSWorkspaceVO.java @@ -0,0 +1,89 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + + +public class DSSWorkspaceVO extends AbstractDSSVO{ + + + private int id; + private String name; + private String tags; + private String department; + private String description; + private String product; + + + public DSSWorkspaceVO() { + } + + public DSSWorkspaceVO(int id, String name){ + this.id = id; + this.name = name; + } + + + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTags() { + return tags; + } + + public void setTags(String tags) { + this.tags = tags; + } + + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getProduct() { + return product; + } + + public void setProduct(String product) { + this.product = product; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DepartmentVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DepartmentVO.java new file mode 100644 index 0000000000..3e5a705826 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/DepartmentVO.java @@ -0,0 +1,58 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + + +public class DepartmentVO { + private int id; + private String name; + private String frontName; + + public DepartmentVO(){ + + } + + public DepartmentVO(int id, String name, String frontName) { + this.id = id; + this.name = name; + this.frontName = frontName; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getFrontName() { + return frontName; + } + + public void setFrontName(String frontName) { + this.frontName = frontName; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/SecondaryWorkspaceMenuVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/SecondaryWorkspaceMenuVO.java new file mode 100644 index 0000000000..e8cd562c4e --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/SecondaryWorkspaceMenuVO.java @@ -0,0 +1,57 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + + +public class SecondaryWorkspaceMenuVO { + private int id; + private String name; + private String url; + + public SecondaryWorkspaceMenuVO() { + } + + public SecondaryWorkspaceMenuVO(int id, String name, String url) { + this.id = id; + this.name = name; + this.url = url; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/SidebarContentVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/SidebarContentVO.java new file mode 100644 index 0000000000..694b93a42b --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/SidebarContentVO.java @@ -0,0 +1,74 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +public class SidebarContentVO { + + //名称 + private String name; + //标题 + private String title; + + private String url; + /** + * url类型: 0-内部系统,1-外部系统;默认是内部 + */ + private Integer urlType; + /** + * icon是表示Content的图标,如果为空就是没有 + */ + private String icon; + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public Integer getUrlType() { + return urlType; + } + + public void setUrlType(Integer urlType) { + this.urlType = urlType; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/SidebarVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/SidebarVO.java new file mode 100644 index 0000000000..a9dfb8f351 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/SidebarVO.java @@ -0,0 +1,64 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import java.util.List; + +public class SidebarVO { + + + private String name; + + + private String title; + + private Integer type; + + private List contents; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public List getContents() { + return contents; + } + + public void setContents(List contents) { + this.contents = contents; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/StaffInfoVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/StaffInfoVO.java new file mode 100644 index 0000000000..caeb7a8e64 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/StaffInfoVO.java @@ -0,0 +1,57 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + + +public class StaffInfoVO { + private String id; + private String username; + private String department; + private String office; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public String getOffice() { + return office; + } + + public void setOffice(String office) { + this.office = office; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/VOUtils.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/VOUtils.java new file mode 100644 index 0000000000..bc70f999a1 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/VOUtils.java @@ -0,0 +1,28 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + + +public class VOUtils { +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/AbstractWorkspaceComponentInfoVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/AbstractWorkspaceComponentInfoVO.java new file mode 100644 index 0000000000..cd67ffe352 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/AbstractWorkspaceComponentInfoVO.java @@ -0,0 +1,131 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo.info; + +import java.util.List; + + +public abstract class AbstractWorkspaceComponentInfoVO { + + private String title; + + private String icon; + + private String desc; + + private String buttonText; + + private List statistics; + + private String componentUrl; + + private String userManualUrl; + + private String indicatorUrl; + + public String getTitle() { + return title; + } + + public static class ComponentStatistic{ + private String name; + private String value; + + public ComponentStatistic(String name, String value) { + this.name = name; + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + } + + + public void setTitle(String title) { + this.title = title; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getButtonText() { + return buttonText; + } + + public void setButtonText(String buttonText) { + this.buttonText = buttonText; + } + + + public List getStatistics() { + return statistics; + } + + public void setStatistics(List statistics) { + this.statistics = statistics; + } + + public String getComponentUrl() { + return componentUrl; + } + + public void setComponentUrl(String componentUrl) { + this.componentUrl = componentUrl; + } + + public String getUserManualUrl() { + return userManualUrl; + } + + public void setUserManualUrl(String userManualUrl) { + this.userManualUrl = userManualUrl; + } + + public String getIndicatorUrl() { + return indicatorUrl; + } + + public void setIndicatorUrl(String indicatorUrl) { + this.indicatorUrl = indicatorUrl; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/DSSWorkspaceScriptisInfoVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/DSSWorkspaceScriptisInfoVO.java new file mode 100644 index 0000000000..b161dbdc14 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/DSSWorkspaceScriptisInfoVO.java @@ -0,0 +1,39 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo.info; + + +public class DSSWorkspaceScriptisInfoVO extends AbstractWorkspaceComponentInfoVO { + + private static final String SCRIPTIS_DESC = "Scriptis是微众银行微数域(WeDataSphere)打造的一站式交互式数据探索分析工具,以任意桥(Linkis)做为内核,提供多种计算存储引擎(如Spark、Hive、TiSpark等)、Hive数据库管理功能、资源(如Yarn资源、服务器资源)管理、应用管理和各种用户资源(如UDF、变量等)管理的能力。"; + + private static final String SCRIPTIS_BUTTON_TEXT = "进入Scriptis"; + + private static final String SCRIPTIS_ICON = "fi-scriptis"; + + private static final String SCRIPTIS_MANUAL_URL = "http://127.0.0.1:8088/wiki/scriptis/manual/feature_overview_cn.html"; + + private static final String SCRIPTIS_TITLE = "Scriptis"; + + public DSSWorkspaceScriptisInfoVO() { + this.setTitle(SCRIPTIS_TITLE); + this.setButtonText(SCRIPTIS_BUTTON_TEXT); + this.setDesc(SCRIPTIS_DESC); + this.setIcon(SCRIPTIS_ICON); + this.setUserManualUrl(SCRIPTIS_MANUAL_URL); + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/DSSWorkspaceVisualisInfoVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/DSSWorkspaceVisualisInfoVO.java new file mode 100644 index 0000000000..d11c1c7a3f --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/DSSWorkspaceVisualisInfoVO.java @@ -0,0 +1,40 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo.info; + + +public class DSSWorkspaceVisualisInfoVO extends AbstractWorkspaceComponentInfoVO{ + + private static final String VISUALIS_DESC = "Visualis是一个可视化BI工具,支持拖拽式报表定义、图表联动、钻取、全局筛选、多维分析、实时查询等数据开发探索的可视化分析模式。"; + + private static final String VISUALIS_BUTTON_TEXT = "进入Visualis"; + + private static final String VISUALIS_ICON = "fi-visualis"; + + private static final String VISUALIS_MANUAL_URL = "http://127.0.0.1:8088/wiki/scriptis/manual/feature_overview_cn.html"; + + private static final String VISUALIS_TITLE = "Visualis"; + + public DSSWorkspaceVisualisInfoVO() { + this.setTitle(VISUALIS_TITLE); + this.setButtonText(VISUALIS_BUTTON_TEXT); + this.setDesc(VISUALIS_DESC); + this.setIcon(VISUALIS_ICON); + this.setUserManualUrl(VISUALIS_MANUAL_URL); + } + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/DSSWorkspaceWorkflowInfoVO.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/DSSWorkspaceWorkflowInfoVO.java new file mode 100644 index 0000000000..04dedf4994 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/bean/vo/info/DSSWorkspaceWorkflowInfoVO.java @@ -0,0 +1,45 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.bean.vo.info; + + +public class DSSWorkspaceWorkflowInfoVO extends AbstractWorkspaceComponentInfoVO{ + + //private static final String WORKFLOW_DESC = "DSS系统工作流开发是支持以可视化编辑方式进行工作流编排," + + //"同时支持工作流实时执行并能够一键发布到WTSS进行定时调度的组件,工作流开发已经支持Scriptis、Visualis以及Qualitis等子系统的接入。"; + + private static final String WORKFLOW_DESC = "DataSphere Studio workflow development is a component which supports workflow editing " + + "through visual editing, and supports real-time execution of workflows and releasing workflows to WTSS by one-click scheduling as well. " + + "Now it has supported the connection of subsystems such as Scriptis, Visualis, and Qualitis etc. "; + + private static final String WORKFLOW_BUTTON_TEXT = "Enter Workflow Development"; + + private static final String WORKFLOW_ICON = "fi-workflow"; + + private static final String WORKFLOW_MANUAL_URL = "http://127.0.0.1:8088/wiki/scriptis/manual/feature_overview_cn.html"; + + private static final String WORKFLOW_TITLE = "Workflow Development"; + + public DSSWorkspaceWorkflowInfoVO() { + this.setTitle(WORKFLOW_TITLE); + this.setButtonText(WORKFLOW_BUTTON_TEXT); + this.setDesc(WORKFLOW_DESC); + this.setIcon(WORKFLOW_ICON); + this.setUserManualUrl(WORKFLOW_MANUAL_URL); + } + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/constant/ApplicationConf.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/constant/ApplicationConf.java new file mode 100644 index 0000000000..196a59d9e0 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/constant/ApplicationConf.java @@ -0,0 +1,42 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.constant; + + +import com.webank.wedatasphere.linkis.common.conf.CommonVars; + + +public class ApplicationConf { + + public static final CommonVars FAQ = CommonVars.apply("wds.linkis.application.dws.params","http://127.0.0.1:8088/wiki/scriptis/manual/feature_overview_cn.html"); + public static final CommonVars SCHEDULIS_URL = + CommonVars.apply("wds.linkis.schedulis.url", "http://127.0.0.1:8088"); + + public static final CommonVars HOMEPAGE_MODULE_NAME = + CommonVars.apply("wds.linkis.special.homepage.module.name", "apiServices"); + + public static final CommonVars HOMEPAGE_URL = + CommonVars.apply("wds.linkis.special.homepage.module.url", "/newHome?workspaceId="); + + public static final CommonVars DSS_ENV_PROD_LABEL = + CommonVars.apply("wds.dss.env.prod.label", "PROD"); + + public static final String SCHEDULER_APP_CONN_NAME = CommonVars.apply("wds.dss.appconn.scheduler.name", "schedulis").getValue(); + + public static final String ESB_APPID = CommonVars.apply("wds.dss.esb.appid", "").getValue(); + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSApplicationMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSApplicationMapper.java new file mode 100644 index 0000000000..031ff87144 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSApplicationMapper.java @@ -0,0 +1,28 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSApplication; +import com.webank.wedatasphere.dss.framework.workspace.bean.Sidebar; +import org.apache.ibatis.annotations.Mapper; + + +@Mapper +public interface DSSApplicationMapper extends BaseMapper { + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSComponentRoleMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSComponentRoleMapper.java new file mode 100644 index 0000000000..a52fb355b7 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSComponentRoleMapper.java @@ -0,0 +1,33 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSComponentRole; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspaceComponentPriv; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspaceHomepage; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +public interface DSSComponentRoleMapper extends BaseMapper { + + + public void insertBatch(@Param("list") List list); + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSDictionaryMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSDictionaryMapper.java new file mode 100644 index 0000000000..e120caec74 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSDictionaryMapper.java @@ -0,0 +1,27 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSDictionary; +import org.apache.ibatis.annotations.Mapper; + + +@Mapper +public interface DSSDictionaryMapper extends BaseMapper { + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSMenuRoleMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSMenuRoleMapper.java new file mode 100644 index 0000000000..d7f215aaea --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSMenuRoleMapper.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspaceMenuRole; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSMenuRole; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +public interface DSSMenuRoleMapper extends BaseMapper { + + public void insertBatch(@Param("list") List menuRoles); + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSUserMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSUserMapper.java new file mode 100644 index 0000000000..1f8375d473 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSUserMapper.java @@ -0,0 +1,26 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSUser; +import org.apache.ibatis.annotations.Mapper; + + +@Mapper +public interface DSSUserMapper extends BaseMapper { +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceHomepageMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceHomepageMapper.java new file mode 100644 index 0000000000..c183ad978c --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceHomepageMapper.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspaceHomepage; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspaceMenuRole; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +public interface DSSWorkspaceHomepageMapper extends BaseMapper { + + public void insertBatch(@Param("list") List homepageList); + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceInfoMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceInfoMapper.java new file mode 100644 index 0000000000..a1f6807e86 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceInfoMapper.java @@ -0,0 +1,41 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + + +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspace; +import org.apache.ibatis.annotations.*; + + +@Mapper +public interface DSSWorkspaceInfoMapper { + + @Select("select name from dss_workspace where id = #{workspaceId} ") + String getWorkspaceNameById(@Param("workspaceId") int workspaceId); + + @Select("select id from dss_workspace where name = #{workspaceName}") + int getWorkspaceIdByName(@Param("workspaceName") String workspaceName); + + @Select("select * from dss_workspace where id = #{workspaceId}") + @Results({ + @Result(property = "createBy", column = "create_by"), + @Result(property = "createTime", column = "create_time"), + @Result(property = "lastUpdateTime", column = "last_update_time"), + @Result(property = "lastUpdateUser", column = "last_update_user"), + }) + DSSWorkspace getWorkspace(@Param("workspaceId") int workspaceId); +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceMapper.java new file mode 100644 index 0000000000..a4e0adc719 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceMapper.java @@ -0,0 +1,50 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + +import com.webank.wedatasphere.dss.framework.workspace.bean.*; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +@Mapper +public interface DSSWorkspaceMapper { + + void createWorkSpace(DSSWorkspace dssWorkspace); + + List getWorkspaces(String username); + + List getMenuId(int roleId, String workspaceId); + + DSSMenu getSpaceMenu(int menuId); + + List getDSSWorkspaceMenuPriv(String workspaceId); + + @Insert({ + "" + }) + void setDefaultComponentRoles(@Param("privs") List dssWorkspaceComponentPrivs); +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceMenuMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceMenuMapper.java new file mode 100644 index 0000000000..10f2e07f62 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceMenuMapper.java @@ -0,0 +1,75 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + + +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspaceComponentRolePriv; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspaceHomepageSetting; +import org.apache.ibatis.annotations.*; + +import java.util.List; + + +@Mapper +public interface DSSWorkspaceMenuMapper { + + + + @Select("select url from dss_menu_component_url where menu_id = #{menuId}") + String getSubMenuUrl(@Param("menuId") int menuId); + + + @Select("select * from dss_component_role where workspace_id = #{workspaceId}") + @Results({ + @Result(property = "workspaceId", column = "workspace_id"), + @Result(property = "componentId", column = "component_id"), + @Result(property = "roleId", column = "role_id"), + @Result(property = "lastUpdateTime", column = "last_update_time"), + @Result(property = "updateBy", column = "update_by") + }) + List getComponentRolePriv(@Param("workspaceId") int workspaceId); + + @Select("select * from dss_workspace_homepage where workspace_id = #{workspaceId}") + @Results({ + @Result(property = "workspaceId", column = "workspace_id"), + @Result(property = "homepageUrl", column = "homepage_url"), + @Result(property = "roleId", column = "role_id"), + @Result(property = "updateTime", column = "update_time") + }) + List getWorkspaceHompageSettings(@Param("workspaceId") int workspaceId); + + @Select("select priv from dss_component_role where workspace_id = #{workspaceId} " + + "and role_id = #{roleId} and " + + "component_id = #{applicationId}") + Integer getOneCompoentRolePriv(@Param("workspaceId") int workspaceId, + @Param("roleId") int roleId, @Param("applicationId") int applicationId); + + /** + * 如果在dss_component_role中是有workspace_id=-1的情况, + * 默认是-1的时候,就要全部拿出来 + * @return + */ + @Select("select * from dss_component_role where workspace_id = -1") + @Results({ + @Result(property = "workspaceId", column = "workspace_id"), + @Result(property = "componentId", column = "component_id"), + @Result(property = "roleId", column = "role_id"), + @Result(property = "lastUpdateTime", column = "last_update_time"), + @Result(property = "updateBy", column = "update_by") + }) + List getDefaultComponentRolePriv(); +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspacePrivMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspacePrivMapper.java new file mode 100644 index 0000000000..5938af5683 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspacePrivMapper.java @@ -0,0 +1,48 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + + +@Mapper +public interface DSSWorkspacePrivMapper { + + @Update("update dss_menu_role set priv = #{priv}, update_time = now() " + + "where workspace_id = #{workspaceId} and menu_id = #{menuId} and role_id = #{roleId}") + void updateRoleMenuPriv(@Param("workspaceId") int workspaceId, @Param("menuId") int menuId, + @Param("roleId") int roleId, @Param("priv") int priv); + + @Update("update dss_component_role set priv = #{priv} , update_time = now()" + + "where workspace_id = #{workspaceId} and component_id = #{componentId} and role_id = #{roleId}") + void updateRoleComponentPriv(@Param("workspaceId") int workspaceId, @Param("componentId") int componentId, + @Param("roleId") int roleId, @Param("priv") int priv); + + @Select("select id from dss_role where workspace_id = #{workspaceId} and name = #{key}") + Integer getRoleId(@Param("workspaceId") int workspaceId, @Param("key") String key); + + @Select("select count(*) from dss_component_role where workspace_id = #{workspaceId} and component_id = #{componentId} and role_id = #{roleId}") + int queryCntOfRCP(@Param("workspaceId") int workspaceId, @Param("componentId") int componentId, @Param("roleId") int roleId); + + @Select("insert into dss_component_role (`workspace_id`, `component_id`, `role_id`, `priv`, `update_time`, `updateby`) " + + "values(#{workspaceId}, #{componentId}, #{roleId}, #{priv}, now(), 'cooperyang')") + void insertRolComponentPriv(@Param("workspaceId") int workspaceId, @Param("componentId") int componentId, @Param("roleId") int roleId, + @Param("priv") int priv); +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceProjectMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceProjectMapper.java new file mode 100644 index 0000000000..03073c9fa4 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceProjectMapper.java @@ -0,0 +1,157 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + +import org.apache.ibatis.annotations.*; + +import java.util.Date; +import java.util.List; + + +@Mapper +public interface DSSWorkspaceProjectMapper { + + + + + + /*@Select("select * from dss_project where workspace_id = #{workspaceId} and name = #{projectName}") + @Results(id ="dss_project_map", value = { + @Result(property = "workspaceId", column = "workspace_id"), + @Result(property = "isPersonal", column = "is_personal"), + @Result(property = "id", column = "id"), + @Result(property = "updateTime",column = "update_time") + }) + DSSPersonalProject searchPersonalProjectInWorkspace(@Param("workspaceId") int workspaceId, + @Param("username") String username, @Param("projectName") String projectName);*/ + + + @Insert({ + "" + }) + void setProjectPriv(@Param("workspaceId") int workspaceId, @Param("projectId") Long projectId, + @Param("usernames") List usernames, @Param("priv") int priv, @Param("lastUpdateTime") Date date); + + + + /*@Select("select * from dss_project where id in (" + + "select project_id from dss_project_user where " + + "workspace_id = #{workspaceId} and username = #{username} and priv >= 1" + + ") and is_personal = 0 or username = #{username} and workspace_id = #{workspaceId} and is_personal = 0") + @ResultMap(value = "dss_project_map") + List listCooperateProjects(@Param("workspaceId") int workspaceId, @Param("username") String username);*/ + + @Select("select priv from dss_project_user where workspace_id = #{workspaceId} " + + "and username = #{username} " + + "and project_id = #{projectId}") + int selectPriv(@Param("projectId") Long projectId, @Param("workspaceId") int workspaceId, @Param("username") String username); + + + /*@Select("select * from dss_flow where project_id in " + + "(select distinct project_id from dss_project_user " + + "where workspace_id = #{workspaceId} and priv >=1 and username = #{username}) " + + "or id in " + + "(select flow_id from dss_flow_user where workspace_id = #{workspaceId} and priv >= 1 " + + "and username = #{username})") + @Results({ + @Result(property = "creatorID", column = "creator_id"), + @Result(property = "createTime", column = "create_time"), + @Result(property = "projectID", column = "project_id"), + @Result(property = "isRootFlow", column = "is_root_flow") + }) + List getReleasedWorkflows(@Param("workspaceId") int workspaceId, + @Param("username") String username); +*/ + @Select("select name from dss_project where id = #{projectId}") + String getProjectNameById(@Param("projectId") Long projectId); + + @Select("select max(version) from dss_flow_version where flow_id = #{flowId}") + String getFlowLatestVersion(@Param("flowId") Long flowId); + + @Select("select username from dss_flow_user where flow_id = #{flowId} and project_id = #{projectId} and workspace_id = #{workspaceId}") + List getAccessUsersByFlowId(@Param("flowId") Long flowId, @Param("projectId") Long projectId, + @Param("workspaceId") int workspaceId); + + @Delete("delete from dss_flow_user where workspace_id = #{workspaceId} and project_id = #{projectId} and flow_id = #{flowId}") + void deleteAllWorkflowPriv(@Param("workspaceId") int workspaceId, + @Param("projectId") int projectId, + @Param("flowId") int flowId); + + @Delete("delete from dss_project_user where workspace_id = #{workspaceId} and project_id = #{projectId}") + void deleteAllProjectPriv(@Param("workspaceId") int workspaceId, @Param("projectId") int projectId); + + @Insert({ + "" + }) + void setWorkflowPriv(@Param("workspaceId") int workspaceId, + @Param("projectId") int projectId, + @Param("flowId") int flowId, + @Param("accessUsers") List accessUsers, + @Param("priv") int priv, + @Param("updateTime") Date updateTime); + + @Select("select name from dss_flow where id = #{flowId}") + String getFlowNameById(@Param("flowId") int flowId); + + @Select("select id from dss_project where name = #{projectName}") + int getProjectIdByName(@Param("projectName") String projectName); + + /* @Select("select * from dss_flow_schedule_info where flow_id = #{flowId}") + @Results({ + @Result(property = "scheduleTime", column = "schedule_time"), + @Result(property = "alarmLevel", column = "alarm_level"), + @Result(property = "alarmUserEmails", column = "alarm_user_emails") + }) + DSSReleasedFlowVO.ScheduleInfo getScheduleInfo(@Param("flowId") Long flowId); +*/ + + + @Insert("insert into dss_flow_schedule_info(flow_id, schedule_time, alarm_user_emails, alarm_level) " + + "values(#{flowId},#{scheduleTime}, #{alarmEmails}, #{alarmLevel})") + void setScheduleInfo(@Param("scheduleTime") String scheduleTime, @Param("alarmEmails") String alarmEmails, + @Param("alarmLevel") String alarmLevel, @Param("flowId") int flowId); + + @Delete("delete from dss_flow_schedule_info where flow_id = #{flowId}") + void deleteScheduleInfo(@Param("flowId") int flowId); + + @Select("select username from dss_project_user WHERE project_id = #{projectId} and priv = 1") + List getAccessUsersByProjectId(@Param("projectId") Long projectId); + + + @Select("select username from dss_project_user WHERE project_id = #{projectId} and priv = 2") + List getEditUsersByProjectId(Long id); + + @Select("select project_id from dss_project_version where id = #{projectVersionId}") + Long getProjectIdByVersionId(@Param("projectVersionId") Long projectVersionId); + + @Update("update dss_project set workspace_id = #{workspaceId} where id = #{projectId}") + void setWorkspaceIdForProject(@Param("workspaceId") Integer workspaceId, @Param("projectId") Long projectId); +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceRoleMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceRoleMapper.java new file mode 100644 index 0000000000..2db75f9f0e --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceRoleMapper.java @@ -0,0 +1,138 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + +import com.webank.wedatasphere.dss.framework.workspace.bean.*; +import org.apache.ibatis.annotations.*; + +import java.util.List; + + +@Mapper +public interface DSSWorkspaceRoleMapper { + + @Select("select * from dss_role") + @Results({ + @Result(property = "workspaceId", column = "workspace_id"), + @Result(property = "frontName", column = "front_name"), + @Result(property = "createTime", column = "update_time") + }) + List getRoles(); + + + @Select("select a.`name` from dss_role a join dss_workspace_user_role b on a.id = b.role_id" + + " and b.`username` = #{username} and b.workspace_id = #{workspaceId}") + List getAllRoles(@Param("username") String username, @Param("workspaceId") int workspaceId); + + + @Select("select * from dss_menu") + @Results({ + @Result(property = "upperMenuId", column = "upper_menu_id"), + @Result(property = "frontName", column = "front_name"), + @Result(property = "isActive", column = "is_active") + }) + List getMenus(); + + + @Select("select * from dss_menu_component_url") + @Results({ + @Result(property = "menuId", column = "menu_id"), + @Result(property = "dssApplicationId", column = "dss_application_id"), + @Result(property = "manulUrl", column = "manul_url"), + @Result(property = "operationUrl", column = "operation_url"), + @Result(property = "updateTime", column = "update_time"), + }) + List getMenuComponentUrl(); + + + @Select("select homepage_url from dss_application where id = #{applicationId}") + String getEntryUrl(@Param("applicationId") int applicationId); + + + + @Select("select * from dss_application") + @Results(id = "dss_application_map", value = { + @Result(property = "id", column = "id"), + @Result(property = "homepageUrl", column = "hoempage_url"), + @Result(property = "componentName", column = "name") + }) + List getComponents(); + + + @Select("select * from dss_application") + @Results(value = { + @Result(property = "id", column = "id"), + @Result(property = "name", column = "name"), + @Result(property = "homepageUrl", column = "homepage_url"), + @Result(property = "projectUrl", column = "project_url") + }) + List getDSSApplications(); + + @Insert("insert into dss_role(workspace_id, name, front_name, update_time) " + + "values(#{dssRole.workspaceId}, #{dssRole.name}, #{dssRole.frontName}, #{dssRole.createTime})") + @Options(useGeneratedKeys = true, keyProperty = "dssRole.id", keyColumn = "id") + int addNewRole(@Param("dssRole") DSSRole dssRole); + + + @Insert({ + "" + }) + void updateRoleMenu(@Param("roleId") int roleId, @Param("workspaceId") int workspaceId, + @Param("menuIds") List menuIds, @Param("username") String username, + @Param("priv") Integer priv); + + + + @Insert({ + "" + }) + void updateRoleComponent(@Param("roleId") int roleId, @Param("workspaceId") int workspaceId, + @Param("componentIds") List componentIds, @Param("username") String username, + @Param("priv") Integer priv); + + + @Select("select workspace_id from dss_workspace_user where username = #{username}") + List getWorkspaceIds(@Param("username") String username); + + @Select("select workspace_id from dss_workspace where `name` = #{defaultWorkspaceName}") + Integer getDefaultWorkspaceId(@Param("defaultWorkspaceName") String defaultWorkspaceName); + + @Select("select id from dss_role where workspace_id = #{workspaceId} and name = #{apiUser}") + int getRoleId(@Param("apiUser") String apiUser, @Param("workspaceId") int workspaceId); + + @Select("Select count(*) from dss_component_role where workspace_id = #{workspaceId} and role_id = #{roleId} and component_id = #{componentId}") + int getCount(@Param("workspaceId") Integer workspaceId, @Param("componentId") int componentId, @Param("roleId") int roleId); + + @Select("select priv from dss_component_role where workspace_id = #{workspaceId} and role_id = #{roleId} and " + + "component_id = #{componentId}") + Integer getPriv(@Param("workspaceId") Integer workspaceId, @Param("roleId") int roleId, @Param("componentId") int componentId); + + @Select("select id from dss_application where `name` = #{appName}") + int getComponentId(@Param("appName") String appName); +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceUserMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceUserMapper.java new file mode 100644 index 0000000000..7f574d4665 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/DSSWorkspaceUserMapper.java @@ -0,0 +1,99 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + + +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSUser; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspaceUser; +import org.apache.ibatis.annotations.*; + +import java.util.List; + + +@Mapper +public interface DSSWorkspaceUserMapper { + + Long getUserID(String userName); + + String getUserName(Long userID); + + @Insert("insert into dss_workspace_user(workspace_id, username, join_time, created_by)" + + "values(#{workspaceId}, #{username}, now(), #{creator})") + void insertUser(@Param("username") String username, + @Param("workspaceId") int workspaceId, @Param("creator") String creator); + + + @Insert("insert into dss_workspace_user_role(workspace_id, username, role_id, create_time, created_by)" + + "values(#{workspaceId}, #{username}, #{roleId}, now(), #{createdBy})") + void setUserRoleInWorkspace(@Param("workspaceId") int workspaceId, @Param("roleId") int roleId, + @Param("username") String username, @Param("createdBy") String createdBy); + + @Select("select role_id from dss_workspace_user_role where workspace_id = #{workspaceId} and username = #{username}") + List getRoleInWorkspace(@Param("workspaceId") int workspaceId, @Param("username") String username); + + + @Delete("delete from dss_workspace_user_role where username = #{username} and workspace_id = #{workspaceId}") + void removeAllRolesForUser(@Param("username") String username, @Param("workspaceId") int workspaceId); + + @Delete("delete from dss_workspace_user where username = #{username} and workspace_id = #{workspaceId}") + void removeUserInWorkspace(@Param("username") String username, @Param("workspaceId") int workspaceId); + + @Select("select workspace_id from dss_workspace_user where username = #{username}") + List getWorkspaceIds(@Param("username") String username); + + @Select("select homepage_url from dss_workspace_homepage where workspace_id = #{workspaceId} and role_id = #{roleId}") + String getHomepageUrl(@Param("workspaceId") int workspaceId, @Param("roleId") int roleId); + + @Select("select * from dss_user") + List listAllDSSUsers(); + + @Select("select username from dss_workspace_user where workspace_id = #{workspaceId}") + List getAllWorkspaceUsers(@Param("workspaceId") int workspaceId); + + @Select("select username from dss_flow_user where flow_id = #{flowId}") + List getFlowUser(@Param("flowId") Long flowId); + + @Select("select is_admin from dss_user where username = #{userName}") + boolean isAdmin(@Param("userName") String userName); + + @Select({ + "" + }) + @Results({ + @Result(property = "creator", column = "created_by"), + @Result(property = "username", column = "username"), + @Result(property = "joinTime", column = "join_time"), + @Result(property = "workspaceId", column = "workspace_id") + }) + List getWorkspaceUsers(@Param("workspaceId") String workspaceId, + @Param("department") String department, + @Param("username") String username, @Param("roleId") int roleId); + + @Select("select * from dss_workspace_user where username in " + + "(select username from dss_workspace_user_role where role_id = #{roleId} and workspace_id = #{workspaceId})" + + "and workspace_id = #{workspaceId}") + @Results({ + @Result(property = "creator", column = "created_by"), + @Result(property = "username", column = "username"), + @Result(property = "joinTime", column = "join_time"), + @Result(property = "workspaceId", column = "workspace_id") + }) + List getWorkspaceUsersByRole(@Param("workspaceId") int workspaceId, @Param("roleId") int roleId); +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/LinkisUserMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/LinkisUserMapper.java new file mode 100644 index 0000000000..9b2f603fe7 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/LinkisUserMapper.java @@ -0,0 +1,26 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.webank.wedatasphere.dss.framework.workspace.bean.LinkisUser; +import org.apache.ibatis.annotations.Mapper; + + +@Mapper +public interface LinkisUserMapper extends BaseMapper { +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/SidebarContentMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/SidebarContentMapper.java new file mode 100644 index 0000000000..2043bf493a --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/SidebarContentMapper.java @@ -0,0 +1,26 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.webank.wedatasphere.dss.framework.workspace.bean.SidebarContent; +import org.apache.ibatis.annotations.Mapper; + + +@Mapper +public interface SidebarContentMapper extends BaseMapper { +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/SidebarMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/SidebarMapper.java new file mode 100644 index 0000000000..7533055d51 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/SidebarMapper.java @@ -0,0 +1,29 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.webank.wedatasphere.dss.framework.workspace.bean.Sidebar; +import org.apache.ibatis.annotations.Mapper; + + +@Mapper +public interface SidebarMapper extends BaseMapper { + + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/WorkspaceMapper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/WorkspaceMapper.java new file mode 100644 index 0000000000..9e4c05697c --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/WorkspaceMapper.java @@ -0,0 +1,68 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.dao; + + +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSFavorite; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspace; +import com.webank.wedatasphere.dss.framework.workspace.bean.dto.response.*; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + + +public interface WorkspaceMapper { + + List getWorkspaces(); + + /** + * 获取空间名称 + * @param name + * @return + */ + List findByWorkspaceName(@Param("name") String name); + + void addWorkSpace(DSSWorkspace dssWorkspace); + + List getHomepageDemoMenusEn(); + List getHomepageDemoMenusCn(); + + List getHomepageInstancesByMenuIdCn(Long id); + List getHomepageInstancesByMenuIdEn(Long id); + + List getHomepageVideosEn(); + List getHomepageVideosCn(); + + DSSWorkspace getWorkspaceById(@Param("workspaceId") Long workspaceId); + + List getManagementMenuCn(); + List getManagementMenuEn(); + + List getApplicationMenuCn(); + List getApplicationMenuEn(); + + List getMenuAppInstancesCn(Long id); + List getMenuAppInstancesEn(Long id); + + List getWorkspaceFavoritesCn(@Param("username") String username, @Param("workspaceId") Long workspaceId); + + List getWorkspaceFavoritesEn(@Param("username") String username, @Param("workspaceId") Long workspaceId); + + void addFavorite(DSSFavorite dssFavorite); + + void deleteFavorite(Long favouritesId); +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSComponentRoleMapper.xml b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSComponentRoleMapper.xml new file mode 100644 index 0000000000..d3bcb4c77c --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSComponentRoleMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + insert into dss_component_role (workspace_id, component_id, role_id, + priv, update_time, updateby) + values + + (#{item.workspaceId},#{item.componentId},#{item.roleId}, + #{item.priv},#{item.updateTime},#{item.updateBy}) + + + + \ No newline at end of file diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSMenuRoleMapper.xml b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSMenuRoleMapper.xml new file mode 100644 index 0000000000..b66b89cc7c --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSMenuRoleMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + insert into dss_menu_role (workspace_id,menu_id,role_id,priv, update_time,updateby) + values + + ( #{item.workspaceId},#{item.menuId},#{item.roleId}, + #{item.priv},#{item.updateTime},#{item.updateBy}) + + + + + \ No newline at end of file diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSWorkspaceHomepageMapper.xml b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSWorkspaceHomepageMapper.xml new file mode 100644 index 0000000000..6638c62dfd --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSWorkspaceHomepageMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + insert into dss_workspace_homepage (workspace_id, role_id, homepage_url, update_time) + values + + #{homepage.workspaceId}, #{homepage.roleId}, #{homepage.homepageUrl}, #{homepage.updateTime} + + + + \ No newline at end of file diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSWorkspaceMapper.xml b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSWorkspaceMapper.xml new file mode 100644 index 0000000000..895f0d9eb3 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSWorkspaceMapper.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id,`name`,`label`,`description`,`create_by`,`create_time`,`department`,`product`,`source`,`last_update_time`,`last_update_user` + + + + INSERT INTO dss_workspace() + VALUES + (#{id},#{name},#{label},#{description},#{createBy},#{createTime},#{department},#{product},#{source},#{lastUpdateTime},#{lastUpdateUser}) + + + + id,`workspace_id`,`username`,`join_time`,`created_by` + + + + + + + + + + + \ No newline at end of file diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSWorkspaceUserMapper.xml b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSWorkspaceUserMapper.xml new file mode 100644 index 0000000000..5640baf265 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/DSSWorkspaceUserMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/WorkspaceMapper.xml b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/WorkspaceMapper.xml new file mode 100644 index 0000000000..202314df7c --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/dao/impl/WorkspaceMapper.xml @@ -0,0 +1,193 @@ + + + + + + + + id,`name`,`label`,`description`,`department`,`product`,`source`,`create_by`,`create_time`,`last_update_user`,`last_update_time` + + + + m.`id`,m.`title_cn` AS `title`, m.`desc_cn` AS `description`,m.`labels_cn` AS `labels`,m.image, + m.`access_button_cn` AS `access_button`,m.`manual_button_cn` AS `manualButton`,m.`is_active`, + m.`manual_button_url`,m.`icon`,m.`order`,app.`homepage_url` AS `access_button_url`,app.project_url, app.`name` + + + m.`id`,m.`title_en` AS `title`, m.`desc_en` AS `description`,m.`labels_en` AS `labels`,m.image, + m.`access_button_en` AS `access_button`,m.`manual_button_en` AS `manualButton`,m.`is_active`, + m.`manual_button_url`,m.`icon`,m.`order`,app.`homepage_url` AS `access_button_url`,app.project_url, app.`name` + + + + id,`username`,`workspace_id`,`menu_application_id`,`order`,`create_by`,`create_time`,`last_update_user`,`last_update_time` + + + + + + + + + + INSERT INTO dss_workspace () + VALUES + (#{id},#{name},#{label},#{description},#{department},#{product},#{source},#{createBy},#{createTime},#{lastUpdateUser},#{lastUpdateTime}) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO dss_onestop_user_favorites () + VALUES + (#{id},#{username},#{workspaceId},#{menuApplicationId},#{order},#{createBy},#{createTime},#{lastUpdateUser},#{lastUpdateTime}) + + + + DELETE + FROM + dss_onestop_user_favorites + WHERE + id = #{favouritesId} + + \ No newline at end of file diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/exception/DSSWorkspaceDuplicateNameException.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/exception/DSSWorkspaceDuplicateNameException.java new file mode 100644 index 0000000000..1d7e8900be --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/exception/DSSWorkspaceDuplicateNameException.java @@ -0,0 +1,28 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.exception; + +import com.webank.wedatasphere.linkis.common.exception.ErrorException; + + +public class DSSWorkspaceDuplicateNameException extends ErrorException { + + public DSSWorkspaceDuplicateNameException(int errCode, String desc) { + super(errCode, desc); + } + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/exception/DSSWorkspaceLoginFailException.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/exception/DSSWorkspaceLoginFailException.java new file mode 100644 index 0000000000..0fb0359bef --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/exception/DSSWorkspaceLoginFailException.java @@ -0,0 +1,30 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.exception; + +import com.webank.wedatasphere.linkis.common.exception.ErrorException; + + +public class DSSWorkspaceLoginFailException extends ErrorException { + public DSSWorkspaceLoginFailException(int errCode, String desc) { + super(errCode, desc); + } + + public DSSWorkspaceLoginFailException(int errCode, String desc, String ip, int port, String serviceKind) { + super(errCode, desc, ip, port, serviceKind); + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSDictionaryRestful.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSDictionaryRestful.java new file mode 100644 index 0000000000..a3ce4d7643 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSDictionaryRestful.java @@ -0,0 +1,134 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.restful; + +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSDictionary; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSDictionaryRequestVO; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSDictionaryService; +import com.webank.wedatasphere.dss.framework.workspace.util.RestfulUtils; +import com.webank.wedatasphere.linkis.server.Message; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.math3.util.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestBody; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.List; +import java.util.Map; + + +@Component +@Path("/dss/framework/workspace/") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class DSSDictionaryRestful { + + private static final Logger LOGGER = LoggerFactory.getLogger(DSSDictionaryRestful.class); + + @Autowired + private DSSDictionaryService dictionaryService; + + /** + * 数据字典 - 根据key获取 + * @param request + * @param dictionaryRequestVO + * @return + */ + @POST + @Path("getDicList") + public Response getDevFlowList(@Context HttpServletRequest request, @RequestBody DSSDictionaryRequestVO dictionaryRequestVO){ + try{ + if(dictionaryRequestVO.getWorkspaceId()==null){ + return Message.messageToResponse(Message.error("workspaceId(空间id)不能为空")); + } + if(StringUtils.isEmpty(dictionaryRequestVO.getParentKey())&&StringUtils.isEmpty(dictionaryRequestVO.getDicKey())){ + return Message.messageToResponse(Message.error("获取的parentKey和dicKey不能同时为空")); + } + List dictionaries = dictionaryService.getListByParam(dictionaryRequestVO); + boolean isEnglish = "en".equals(request.getHeader("Content-language")); + if(CollectionUtils.isNotEmpty(dictionaries) && isEnglish){ + dictionaries.stream().forEach(e->international(e)); + } + return RestfulUtils.dealOk("获取数据字典成功", new Pair<>("list", dictionaries)); + }catch(Exception e){ + LOGGER.error("Fail to get getDevFlowListError for user {} in workspace {}",dictionaryRequestVO.getWorkspaceId(), e); + return RestfulUtils.dealError("获取数据字典失败:"+e.getMessage()); + } + } + + @POST + @Path("getDicSecondList") + public Response getDicSecondList(@Context HttpServletRequest request, @RequestBody DSSDictionaryRequestVO dictionaryRequestVO){ + try{ + if(dictionaryRequestVO.getWorkspaceId()==null){ + return Message.messageToResponse(Message.error("workspaceId(空间id)不能为空")); + } + if(StringUtils.isEmpty(dictionaryRequestVO.getParentKey())&&StringUtils.isEmpty(dictionaryRequestVO.getDicKey())){ + return Message.messageToResponse(Message.error("获取的parentKey和dicKey不能同时为空")); + } + Map map = dictionaryService.getDicSecondList(dictionaryRequestVO); + boolean isEnglish = "en".equals(request.getHeader("Content-language")); + if(map!=null && map.size() > 0 && isEnglish){ + List dictionaries = (List) map.get("list"); + if(CollectionUtils.isNotEmpty(dictionaries)){ + dictionaries.stream().forEach(e->international(e)); + } + Map> mapList = ( Map>) map.get("mapList"); + if(mapList!=null && mapList.size() > 0){ + for(String key : mapList.keySet()){ + mapList.get(key).stream().forEach(e->international(e)); + } + } + } + return RestfulUtils.dealOk("获取数据字典成功", new Pair<>("list", map)); + }catch(Exception e){ + LOGGER.error("Fail to get getDicSecondListError for user {} in workspace {}",dictionaryRequestVO.getWorkspaceId(), e); + return RestfulUtils.dealError("获取数据字典失败:"+e.getMessage()); + } + } + + + //国际化,由于前端只是使用dicName,所以在英文的时候直接将dicNameEn赋值给dicName即可 + public void international(DSSDictionary dssDictionary){ + if(dssDictionary==null){ + return; + } + if(StringUtils.isNotBlank(dssDictionary.getDicNameEn())){ + dssDictionary.setDicName(dssDictionary.getDicNameEn()); + dssDictionary.setDicNameEn(null); + } + if(StringUtils.isNotBlank(dssDictionary.getDicValueEn())){ + dssDictionary.setDicValue(dssDictionary.getDicValueEn()); + dssDictionary.setDicValueEn(null); + } + if(StringUtils.isNotBlank(dssDictionary.getTitleEn())){ + dssDictionary.setTitle(dssDictionary.getTitleEn()); + dssDictionary.setTitleEn(null); + } + } +} \ No newline at end of file diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSSideInfoRestful.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSSideInfoRestful.java new file mode 100644 index 0000000000..259707f815 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSSideInfoRestful.java @@ -0,0 +1,59 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.restful; + +import com.webank.wedatasphere.dss.framework.workspace.service.DSSSideInfoService; +import com.webank.wedatasphere.dss.framework.workspace.util.RestfulUtils; +import com.webank.wedatasphere.linkis.server.security.SecurityFilter; +import org.apache.commons.math3.util.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + + +@Component +@Path("/dss/framework/workspace/") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class DSSSideInfoRestful { + + private static final Logger LOGGER = LoggerFactory.getLogger(DSSSideInfoRestful.class); + + @Autowired + private DSSSideInfoService dssSideInfoService; + + @GET + @Path("getSideInfos") + public Response getSideInfos(@Context HttpServletRequest request, @QueryParam("workspaceId") Integer workspaceId){ + String username = SecurityFilter.getLoginUsername(request); + try{ + boolean isEnglish = "en".equals(request.getHeader("Content-language")); + return RestfulUtils.dealOk("获取侧边栏成功", new Pair<>("presentations", dssSideInfoService.getSidebarVOList(username, workspaceId,isEnglish))); + }catch(Exception e){ + LOGGER.info("Fail to get sideinfos for user {} in workspace {}",username, workspaceId, e); + return RestfulUtils.dealError("获取侧边栏失败"); + } + } + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspacePrivRestful.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspacePrivRestful.java new file mode 100644 index 0000000000..bc96526fc8 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspacePrivRestful.java @@ -0,0 +1,122 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.restful; + + +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceHomepageSettingVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspacePrivVO; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspacePrivService; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceService; +import com.webank.wedatasphere.dss.framework.workspace.util.WorkspaceDBHelper; +import com.webank.wedatasphere.linkis.server.Message; +import com.webank.wedatasphere.linkis.server.security.SecurityFilter; +import org.apache.commons.math3.util.Pair; +import org.codehaus.jackson.JsonNode; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; + +import static com.webank.wedatasphere.dss.framework.workspace.util.DSSWorkspaceConstant.WORKSPACE_ID_STR; + + +@Component +@Path("/dss/framework/workspace") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class DSSWorkspacePrivRestful { + + @Autowired + DSSWorkspaceService dssWorkspaceService; + @Autowired + DSSWorkspacePrivService dssWorkspacePrivService; + @Autowired + WorkspaceDBHelper workspaceDBHelper; + + @GET + @Path("getWorkspaceMenuPrivs") + public Response getWorkspaceMenuPrivs(@Context HttpServletRequest request, @QueryParam(WORKSPACE_ID_STR) String workspaceId){ + //todo 返回工作空间中角色对菜单的访问权限 + DSSWorkspacePrivVO workspaceMenuPrivs = dssWorkspaceService.getWorkspaceMenuPrivs(workspaceId); + return Message.messageToResponse(Message.ok().data("workspaceMenuPrivs", workspaceMenuPrivs)); + } + + @GET + @Path("getWorkspaceComponentPrivs") + public Response getWorkspaceComponentPrivs(@Context HttpServletRequest request, @QueryParam(WORKSPACE_ID_STR) String workspaceId){ + return Message.messageToResponse(Message.ok("接口废弃")); + } + + @GET + @Path("getWorkspaceHomepageSettings") + public Response getWorkspaceHomepageSettings(@Context HttpServletRequest request, @QueryParam(WORKSPACE_ID_STR) int workspaceId){ + String username = SecurityFilter.getLoginUsername(request); + DSSWorkspaceHomepageSettingVO dssWorkspaceHomepageSettingVO = dssWorkspaceService.getWorkspaceHomepageSettings(workspaceId); + return Message.messageToResponse(Message.ok().data("homepageSettings", dssWorkspaceHomepageSettingVO)); + } + + @POST + @Path("updateRoleMenuPriv") + public Response updateRoleMenuPriv(@Context HttpServletRequest request, JsonNode jsonNode){ + String updater = SecurityFilter.getLoginUsername(request); + int menuId = jsonNode.get("menuId").getIntValue(); + int workspaceId = jsonNode.get("workspaceId").getIntValue(); + JsonNode menuPrivs = jsonNode.get("menuPrivs"); + List> pairs = new ArrayList<>(); + menuPrivs.getFields().forEachRemaining(field -> { + Integer roleId = dssWorkspacePrivService.getRoleId(workspaceId, field.getKey()); + if (roleId == null) { + roleId = workspaceDBHelper.getRoleIdByName(field.getKey()); + } + pairs.add(new Pair(roleId, field.getValue().getBooleanValue())); + }); + dssWorkspacePrivService.updateRoleMenuPriv(workspaceId, menuId, updater, pairs); + return Message.messageToResponse(Message.ok("更新角色对于菜单的权限成功")); + } + + @POST + @Path("updateRoleComponentPriv") + public Response updateRoleComponentPriv(@Context HttpServletRequest request, JsonNode jsonNode){ + //todo 更新工作空间中角色对于component的权限 + String username = SecurityFilter.getLoginUsername(request); + int menuId = jsonNode.get("componentId").getIntValue(); + int workspaceId = jsonNode.get("workspaceId").getIntValue(); + JsonNode componentPrivs = jsonNode.get("componentPrivs"); + List> pairs = new ArrayList<>(); + componentPrivs.getFields().forEachRemaining(field -> { + Integer roleId = dssWorkspacePrivService.getRoleId(workspaceId, field.getKey()); + if (roleId == null) { + roleId = workspaceDBHelper.getRoleIdByName(field.getKey()); + } + pairs.add(new Pair(roleId, field.getValue().getBooleanValue())); + }); + dssWorkspacePrivService.updateRoleComponentPriv(workspaceId, menuId, username, pairs); + return Message.messageToResponse(Message.ok().data("updateRoleComponentPriv","更新组件权限成功")); + } + + @POST + @Path("updateRoleHomepage") + public Response updateRoleHomepage(@Context HttpServletRequest request, JsonNode jsonNode){ + return null; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceRestful.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceRestful.java new file mode 100644 index 0000000000..b931eafb2e --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceRestful.java @@ -0,0 +1,134 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.restful; + + +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspace; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceHomePageVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceOverviewVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DepartmentVO; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceMenuService; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceService; +import com.webank.wedatasphere.dss.framework.workspace.util.WorkspaceDBHelper; +import com.webank.wedatasphere.linkis.common.exception.ErrorException; +import com.webank.wedatasphere.linkis.server.Message; +import com.webank.wedatasphere.linkis.server.security.SecurityFilter; +import org.codehaus.jackson.JsonNode; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; + +import static com.webank.wedatasphere.dss.framework.workspace.util.DSSWorkspaceConstant.WORKSPACE_ID_STR; + + + + +@Component +@Path("/dss/framework/workspace") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class DSSWorkspaceRestful { + @Autowired + private DSSWorkspaceService dssWorkspaceService; + @Autowired + private DSSWorkspaceMenuService dssWorkspaceMenuService; + @Autowired + private WorkspaceDBHelper workspaceDBHelper; + + @POST + @Path("/createWorkspace") + public Response createWorkspace(@Context HttpServletRequest request, JsonNode node)throws ErrorException { + String userName = SecurityFilter.getLoginUsername(request); + if (!dssWorkspaceService.checkAdmin(userName)){ + return Message.messageToResponse(Message.error("您好,您不是管理员,没有权限建立工作空间")); + } + String workSpaceName = node.get("workspaceName").getTextValue(); + String department = node.get("department").getTextValue(); + String description = node.get("description").getTextValue(); + String stringTags = node.get("tags").getTextValue(); + String productName = node.get("productName").getTextValue(); + int workspaceId = dssWorkspaceService.createWorkspace(workSpaceName, stringTags, userName, description, department, productName); + return Message.messageToResponse(Message.ok().data("workspaceId", workspaceId).data("workspaceName",workSpaceName)); + } + + @GET + @Path("listDepartments") + public Response listDepartments(@Context HttpServletRequest request, @QueryParam(WORKSPACE_ID_STR) String workspaceId){ + //todo 要从um中获取 + List departments = dssWorkspaceService.getDepartments(); + return Message.messageToResponse(Message.ok().data("departments", departments)); + } + + @GET + @Path("getWorkspaces") + public Response getWorkspaces(@Context HttpServletRequest request){ + String username = SecurityFilter.getLoginUsername(request); + List workspaces = dssWorkspaceService.getWorkspaces(username); + List dssWorkspaceVOS = new ArrayList<>(); + for (DSSWorkspace workspace:workspaces ){ + String name = workspace.getName(); + int id = workspace.getId(); + String labels = workspace.getLabel(); + DSSWorkspaceVO dssWorkspaceVO = new DSSWorkspaceVO(); + dssWorkspaceVO.setId(id); + dssWorkspaceVO.setName(name); + dssWorkspaceVO.setTags(labels); + dssWorkspaceVO.setDepartment(workspace.getDepartment()); + dssWorkspaceVO.setDescription(workspace.getDescription()); + dssWorkspaceVO.setProduct(workspace.getProduct()); + dssWorkspaceVOS.add(dssWorkspaceVO); + } + //todo 获取用户所有所有能够访问的工作空间 + return Message.messageToResponse(Message.ok().data("workspaces", dssWorkspaceVOS)); + } + + @GET + @Path("getWorkspaceHomePage") + public Response getWorkspaceHomePage(@Context HttpServletRequest request, @QueryParam("micro_module") String moduleName){ + //如果用户的工作空间大于两个,那么就直接返回/workspace页面 + String username = SecurityFilter.getLoginUsername(request); + DSSWorkspaceHomePageVO dssWorkspaceHomePageVO = dssWorkspaceService.getWorkspaceHomePage(username,moduleName); + return Message.messageToResponse(Message.ok().data("workspaceHomePage", dssWorkspaceHomePageVO)); + } + + @GET + @Path("getOverview") + public Response getOverview(@Context HttpServletRequest request, @QueryParam(WORKSPACE_ID_STR) int workspaceId){ + String username = SecurityFilter.getLoginUsername(request); + String language = request.getHeader("Content-language"); + boolean isEnglish = "en".equals(language); + DSSWorkspaceOverviewVO dssWorkspaceOverviewVO = dssWorkspaceService.getOverview(username, workspaceId, isEnglish); + return Message.messageToResponse(Message.ok().data("overview", dssWorkspaceOverviewVO)); + } + + @GET + @Path("refreshCache") + public Response refreshCache(@Context HttpServletRequest request){ + workspaceDBHelper.retrieveFromDB(); + return Message.messageToResponse(Message.ok("refresh ok")); + } + +} + diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceRoleRestful.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceRoleRestful.java new file mode 100644 index 0000000000..62c046f98b --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceRoleRestful.java @@ -0,0 +1,212 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.restful; + + +import com.google.gson.Gson; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSApplication; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceRoleVO; +import com.webank.wedatasphere.dss.framework.workspace.constant.ApplicationConf; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSApplicationMapper; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSUserService; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceRoleService; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceService; +import com.webank.wedatasphere.dss.framework.workspace.util.ApplicationUtils; +import com.webank.wedatasphere.linkis.server.Message; +import com.webank.wedatasphere.linkis.server.security.SecurityFilter; +import org.apache.commons.lang.StringUtils; +import org.codehaus.jackson.JsonNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; + + +@Component +@Path("/dss/framework/workspace") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class DSSWorkspaceRoleRestful { + + private static final Logger LOGGER = LoggerFactory.getLogger(DSSWorkspaceRoleRestful.class); + private static final String WORKSPACE_ID_STR = "workspaceId"; + private static final String DEFAULT_PATH = "/api/rest_j/v1"; + @Autowired + DSSWorkspaceService dssWorkspaceService; + @Autowired + private DSSWorkspaceRoleService dssWorkspaceRoleService; + @Autowired + private DSSUserService userService; + @Autowired + private DSSApplicationMapper applicationMapper; + + @GET + @Path("getBaseInfo") + public Response getBaseInfo(@Context HttpServletRequest req) { + String username = SecurityFilter.getLoginUsername(req); + userService.saveWorkspaceUser(username); + List applicationList = applicationMapper.selectList(null); + DSSApplication schedulis = new DSSApplication(); + schedulis.setName(ApplicationConf.SCHEDULER_APP_CONN_NAME); + String url = ApplicationConf.SCHEDULIS_URL.getValue(); + schedulis.setUrl(url); + schedulis.setHomepageUrl(url + "/homepage"); + schedulis.setProjectUrl(url + "/manager?project=${projectName}"); + schedulis.setRedirectUrl(url + "/api/v1/redirect"); + schedulis.setIfIframe(true); + applicationList.add(schedulis); + for (DSSApplication application : applicationList) { + String redirectUrl = application.getRedirectUrl(); + String enhanceJson = application.getEnhanceJson(); + if (redirectUrl != null) { + application.setHomepageUrl(ApplicationUtils.redirectUrlFormat(redirectUrl, application.getHomepageUrl())); + application.setProjectUrl(ApplicationUtils.redirectUrlFormat(redirectUrl, application.getProjectUrl())); + if (StringUtils.isNotEmpty(enhanceJson) && enhanceJson.contains("scheduleHistory")) { + Gson gson = new Gson(); + HashMap scheduleHistoryMap = gson.fromJson(enhanceJson, HashMap.class); + String oldUrl = scheduleHistoryMap.get("scheduleHistory").toString(); + String formatUrl = ApplicationUtils.redirectUrlFormat(redirectUrl, oldUrl); + scheduleHistoryMap.replace("scheduleHistory", formatUrl); + application.setEnhanceJson(gson.toJson(scheduleHistoryMap)); + } + } + } + //返回FAQ地址 + String faqUrl = ApplicationConf.FAQ.getValue(); + boolean isAdmin = userService.isAdminUser(username); + //前台需要返回username + return Message.messageToResponse(Message.ok().data("applications", applicationList). + data("username", username).data("isAdmin", isAdmin) + .data("DWSParams", Collections.singletonMap("faq", faqUrl))); + } + + @GET + @Path("getWorkspaceRoles") + public Response getWorkspaceRoles(@Context HttpServletRequest request, @QueryParam(WORKSPACE_ID_STR) int workspaceId){ + //todo 获取工作空间中所有的角色 + List workspaceRoles = dssWorkspaceService.getWorkspaceRoles(workspaceId); + return Message.messageToResponse(Message.ok().data("workspaceRoles", workspaceRoles)); + } + + + @POST + @Path("addWorkspaceRole") + public Response addWorkspaceRole(@Context HttpServletRequest request, JsonNode jsonNode){ + String username = SecurityFilter.getLoginUsername(request); + int workspaceId = jsonNode.get("workspaceId").getIntValue(); + String roleName = jsonNode.get("roleName").getTextValue(); + List menuIds = new ArrayList<>(); + List componentIds = new ArrayList<>(); + JsonNode menuIdsNode = jsonNode.get("menuIds"); + if (menuIdsNode != null && menuIdsNode.isArray()){ + menuIdsNode.forEach(tmpMenuId -> menuIds.add(tmpMenuId.getIntValue())); + } + JsonNode componentIdsNode = jsonNode.get("componentIds"); + if (componentIdsNode != null && componentIdsNode.isArray()){ + componentIdsNode.forEach(tmpMenuId -> componentIds.add(tmpMenuId.getIntValue())); + } + dssWorkspaceRoleService.addWorkspaceRole(roleName, workspaceId, menuIds, componentIds, username); + return Message.messageToResponse(Message.ok("创建角色成功")); + } + + @POST + @Path("deleteWorkspaceRole") + public Response deleteWorkspaceRole(@Context HttpServletRequest request, JsonNode jsonNode){ + + return null; + } + + @GET + @Path("getWorkspaceBaseInfo") + public Response getWorkspaceInfo(@Context HttpServletRequest request, + @Context HttpServletResponse response, + @QueryParam(WORKSPACE_ID_STR) Integer workspaceId){ + String username = SecurityFilter.getLoginUsername(request); + //如果workspaceId为null的话,那么就找到这个用户工作空间 + if (workspaceId == null || workspaceId <= 0){ + workspaceId = dssWorkspaceRoleService.getWorkspaceIdByUser(username); + } + //将workspaceId作为cookie写入 + Cookie[] cookies = request.getCookies(); + for(Cookie cookie : cookies){ + if(WORKSPACE_ID_STR.equals(cookie.getName())){ + cookie.setMaxAge(0); + cookie.setPath("/"); + cookie.setValue(null); + response.addCookie(cookie); + break; + } + } + Cookie workspaceCookie = new Cookie(WORKSPACE_ID_STR, workspaceId.toString()); + workspaceCookie.setPath("/"); + response.addCookie(workspaceCookie); + List roles = dssWorkspaceRoleService.getRoleInWorkspace(username, workspaceId); + if(roles == null || roles.isEmpty()){ + LOGGER.error("username {}, in workspace {} roles are null or empty", username, workspaceId); + return Message.messageToResponse(Message.error("can not get roles information")); + } + //判断如果是没有权限的,那么就直接干掉 + if (roles.contains("apiUser")){ + int priv = dssWorkspaceRoleService.getApiPriv(username, workspaceId, "apiUser", "apiService"); + if(priv <= 0) { + roles.remove("apiUser"); + } + } + Message retMessage = Message.ok(); + //工作空间中,加上用户在顶部的菜单 + if (roles.contains("analyser")){ + retMessage.data("topName", "Scriptis"); + retMessage.data("topUrl", "/home"); + } else if (roles.contains("developer")){ + retMessage.data("topName", "Scriptis"); + retMessage.data("topUrl", "/home"); + }else if(roles.contains("apiUser") && roles.size() == 1){ + retMessage.data("topName","Scriptis"); + retMessage.data("topUrl", "/home"); + }else{ + retMessage.data("topName", "Scriptis"); + retMessage.data("topUrl", "/home"); + } + //如果其他的角色也是有这个api权限的,那么就加上这个apiUser + boolean flag = false; + for (String role : roles){ + int priv = dssWorkspaceRoleService.getApiPriv(username, workspaceId, role, "apiService"); + if (priv >= 1) { + flag = true; + break; + } + } + if(flag && !roles.contains("apiUser")){ + roles.add("apiUser"); + } + //roles.add("apiUser"); + return Message.messageToResponse(retMessage.data("roles", roles).data("workspaceId", workspaceId)); + } + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceUserRestful.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceUserRestful.java new file mode 100644 index 0000000000..46b063216c --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/DSSWorkspaceUserRestful.java @@ -0,0 +1,169 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.restful; + +import com.github.pagehelper.PageInfo; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSUser; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceRoleVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceUserVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.StaffInfoVO; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceMenuService; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceService; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceUserService; +import com.webank.wedatasphere.dss.framework.workspace.util.WorkspaceDBHelper; +import com.webank.wedatasphere.linkis.server.Message; +import com.webank.wedatasphere.linkis.server.security.SecurityFilter; +import org.apache.commons.lang.StringUtils; +import org.codehaus.jackson.JsonNode; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import static com.webank.wedatasphere.dss.framework.workspace.util.DSSWorkspaceConstant.WORKSPACE_ID_STR; + + + +@Component +@Path("/dss/framework/workspace") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class DSSWorkspaceUserRestful { + + @Autowired + private DSSWorkspaceService dssWorkspaceService; + @Autowired + private DSSWorkspaceMenuService dssWorkspaceMenuService; + @Autowired + private WorkspaceDBHelper workspaceDBHelper; + @Autowired + private DSSWorkspaceUserService dssWorkspaceUserService; + + @GET + @Path("getWorkspaceUsers") + public Response getWorkspaceUsers(@Context HttpServletRequest request, @QueryParam(WORKSPACE_ID_STR) String workspaceId, + @QueryParam("pageNow") Integer pageNow, @QueryParam("pageSize") Integer pageSize, + @QueryParam("department") String department, @QueryParam("username") String username, + @QueryParam("roleName") String roleName){ + //todo 获取工作空间中所有的用户以及他们的角色信息 + if(pageNow == null){ + pageNow = 1; + } + if(pageSize == null){ + //默认改成20 + pageSize = 20; + } + if(StringUtils.isNotEmpty(roleName)){ + //如果roleName不是空的话,就按照roleName来吧 + List totals = new ArrayList<>(); + List workspaceUsers = + dssWorkspaceService.getWorkspaceUsersByRole(Integer.parseInt(workspaceId),roleName, totals, pageNow, pageSize); + PageInfo pageInfo = new PageInfo<>(workspaceUsers); + List list = pageInfo.getList(); + long total = pageInfo.getTotal(); + List dssRoles = workspaceDBHelper.getRoleVOs(Integer.parseInt(workspaceId)); + return Message.messageToResponse(Message.ok().data("roles", dssRoles).data("workspaceUsers", list).data("total", totals.get(0))); + }else{ + List totals = new ArrayList<>(); + List workspaceUsers = + dssWorkspaceService.getWorkspaceUsers(workspaceId, department, username, roleName, pageNow, pageSize, totals); + PageInfo pageInfo = new PageInfo<>(workspaceUsers); + List list = pageInfo.getList(); + long total = pageInfo.getTotal(); + List dssRoles = workspaceDBHelper.getRoleVOs(Integer.parseInt(workspaceId)); + return Message.messageToResponse(Message.ok().data("roles", dssRoles).data("workspaceUsers", list).data("total", totals.get(0))); + } + } + + @GET + @Path("getAllWorkspaceUsers") + public Response getAllWorkspaceUsers(@Context HttpServletRequest request, @QueryParam(WORKSPACE_ID_STR) int workspaceId ){ + String username = SecurityFilter.getLoginUsername(request); + List users = dssWorkspaceUserService.getAllWorkspaceUsers(workspaceId); + return Message.messageToResponse(Message.ok().data("users", users)); + } + + @POST + @Path("addWorkspaceUser") + public Response addWorkspaceUser(@Context HttpServletRequest request, JsonNode jsonNode){ + //todo 工作空间添加用户 + String creator = SecurityFilter.getLoginUsername(request); + List roles = new ArrayList<>(); + if (jsonNode.get("roles").isArray()){ + for (JsonNode role : jsonNode.get("roles")){ + roles.add(role.getIntValue()); + } + } + int workspaceId = jsonNode.get("workspaceId").getIntValue(); + String userName = jsonNode.get("username").getTextValue(); + dssWorkspaceService.addWorkspaceUser(roles, workspaceId, userName, creator); + return Message.messageToResponse(Message.ok()); + } + + @POST + @Path("updateWorkspaceUser") + public Response updateWorkspaceUser(@Context HttpServletRequest request, JsonNode jsonNode){ + String creator = SecurityFilter.getLoginUsername(request); + List roles = new ArrayList<>(); + if (jsonNode.get("roles").isArray()){ + for (JsonNode role : jsonNode.get("roles")){ + roles.add(role.getIntValue()); + } + } + int workspaceId = jsonNode.get("workspaceId").getIntValue(); + String userName = jsonNode.get("username").getTextValue(); + dssWorkspaceUserService.updateWorkspaceUser(roles, workspaceId, userName, creator); + return Message.messageToResponse(Message.ok()); + } + + @POST + @Path("deleteWorkspaceUser") + public Response deleteWorkspaceUser(@Context HttpServletRequest request, JsonNode jsonNode){ + //todo 删除工作空间中的用户 + String userName = jsonNode.get("username").getTextValue(); + int workspaceId = jsonNode.get("workspaceId").getIntValue(); + dssWorkspaceUserService.deleteWorkspaceUser(userName,workspaceId); + return Message.messageToResponse(Message.ok()); + } + + @GET + @Path("listAllUsers") + public Response listAllUsers(@Context HttpServletRequest request){ + List dssUsers = dssWorkspaceUserService.listAllDSSUsers(); + return Message.messageToResponse(Message.ok().data("users", dssUsers)); + } + + @GET + @Path("getWorkspaceIdByUserName") + public Response getWorkspaceIdByUserName(@Context HttpServletRequest request,@QueryParam("userName") String userName){ + String loginUserName = SecurityFilter.getLoginUsername(request); + String queryUserName = userName; + if(StringUtils.isEmpty(userName)){ + queryUserName = loginUserName; + } + List userWorkspaceIds = dssWorkspaceUserService.getUserWorkspaceIds(queryUserName); + String userWorkspaceIdStr = userWorkspaceIds.stream().map(x->x.toString()).collect(Collectors.joining(",")); + return Message.messageToResponse(Message.ok().data("userWorkspaceIds", userWorkspaceIdStr)); + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/WorkspaceRestfulApi.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/WorkspaceRestfulApi.java new file mode 100644 index 0000000000..95ab2093a0 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/restful/WorkspaceRestfulApi.java @@ -0,0 +1,177 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.restful; + +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspace; +import com.webank.wedatasphere.dss.framework.workspace.bean.dto.response.HomepageDemoMenuVo; +import com.webank.wedatasphere.dss.framework.workspace.bean.dto.response.HomepageVideoVo; +import com.webank.wedatasphere.dss.framework.workspace.bean.dto.response.OnestopMenuVo; +import com.webank.wedatasphere.dss.framework.workspace.bean.dto.response.WorkspaceFavoriteVo; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DepartmentVO; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceService; +import com.webank.wedatasphere.linkis.common.exception.ErrorException; +import com.webank.wedatasphere.linkis.server.Message; +import com.webank.wedatasphere.linkis.server.security.SecurityFilter; +import org.codehaus.jackson.JsonNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + + +@Component +@Path("/dss/framework/workspace") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class WorkspaceRestfulApi { + private static final Logger LOGGER = LoggerFactory.getLogger(WorkspaceRestfulApi.class); + @Autowired + private DSSWorkspaceService dssWorkspaceService; + + @GET + @Path("/workspaces") + public Response getAllWorkspaces(@Context HttpServletRequest req) { + // TODO: Order By time + String username = SecurityFilter.getLoginUsername(req); + List workspaces = dssWorkspaceService.getWorkspaces(username); + return Message.messageToResponse(Message.ok().data("workspaces", workspaces)); + } + + @GET + @Path("/workspaces/{id}") + public Response getWorkspacesById(@Context HttpServletRequest req, @PathParam("id") Long id) { + DSSWorkspace workspace = dssWorkspaceService.getWorkspacesById(id); + return Message.messageToResponse(Message.ok().data("workspace", workspace)); + } + + @GET + @Path("/workspaces/departments") + public Response getAllWorkspaceDepartments(@Context HttpServletRequest req) { + List departments = dssWorkspaceService.getDepartments(); + return Message.messageToResponse(Message.ok().data("departments", departments)); + } + + @GET + @Path("/workspaces/exists") + public Response getUsernameExistence(@Context HttpServletRequest req, @QueryParam("name") String name) { + boolean exists = dssWorkspaceService.existWorkspaceName(name); + return Message.messageToResponse(Message.ok().data("workspaceNameExists", exists)); + } + + @POST + @Path("/workspaces") + public Response addWorkspace(@Context HttpServletRequest req, JsonNode json) throws ErrorException { + String userName = SecurityFilter.getLoginUsername(req); + if (!dssWorkspaceService.checkAdmin(userName)){ + return Message.messageToResponse(Message.error("您好,您不是管理员,没有权限建立工作空间")); + } + String name = json.get("name").getTextValue(); + if (dssWorkspaceService.existWorkspaceName(name)) { + return Message.messageToResponse(Message.error("工作空间名重复")); + } + String department = json.get("department").getTextValue(); + String label = json.get("label").getTextValue(); + String description = json.get("description").getTextValue(); + String productName = "DSS"; + int workspaceId = dssWorkspaceService.createWorkspace(name, label, userName, description, department, productName); + return Message.messageToResponse(Message.ok().data("workspaceId", workspaceId)); + } + + @GET + @Path("/workspaces/demos") + public Response getAllHomepageDemos(@Context HttpServletRequest req) { + String header = req.getHeader("Content-language").trim(); + boolean isChinese = "zh-CN".equals(header); + List homepageDemos = dssWorkspaceService.getHomepageDemos(isChinese); + return Message.messageToResponse(Message.ok().data("demos", homepageDemos)); + } + + @GET + @Path("/workspaces/videos") + public Response getAllVideos(@Context HttpServletRequest req) { + String header = req.getHeader("Content-language").trim(); + boolean isChinese = "zh-CN".equals(header); + List homepageVideos = dssWorkspaceService.getHomepageVideos(isChinese); + return Message.messageToResponse(Message.ok().data("videos", homepageVideos)); + } + + @GET + @Path("workspaces/{workspaceId}/managements") + public Response getWorkspaceManagements(@Context HttpServletRequest req, @PathParam("workspaceId") Long workspaceId) { + String header = req.getHeader("Content-language").trim(); + boolean isChinese = "zh-CN".equals(header); + String username = SecurityFilter.getLoginUsername(req); + List managements = dssWorkspaceService.getWorkspaceManagements(workspaceId, username, isChinese); + return Message.messageToResponse(Message.ok().data("managements", managements)); + } + + @GET + @Path("workspaces/{workspaceId}/applications") + public Response getWorkspaceApplications(@Context HttpServletRequest req, @PathParam("workspaceId") Long workspaceId) { + String header = req.getHeader("Content-language").trim(); + boolean isChinese = "zh-CN".equals(header); + String username = SecurityFilter.getLoginUsername(req); + List applications = dssWorkspaceService.getWorkspaceApplications(workspaceId, username, isChinese); + return Message.messageToResponse(Message.ok().data("applications", applications)); + } + + @GET + @Path("/workspaces/{workspaceId}/favorites") + public Response getWorkspaceFavorites(@Context HttpServletRequest req, @PathParam("workspaceId") Long workspaceId) { + String header = req.getHeader("Content-language").trim(); + boolean isChinese = "zh-CN".equals(header); + String username = SecurityFilter.getLoginUsername(req); + List favorites = dssWorkspaceService.getWorkspaceFavorites(workspaceId, username, isChinese); + Set favoriteVos = new HashSet<>(favorites); + return Message.messageToResponse(Message.ok().data("favorites", favoriteVos)); + } + + /** + * 应用加入收藏,返回收藏后id + * + * @param req + * @param json + * @return + */ + @POST + @Path("/workspaces/{workspaceId}/favorites") + public Response addFavorite(@Context HttpServletRequest req, @PathParam("workspaceId") Long workspaceId, JsonNode json) { + String username = SecurityFilter.getLoginUsername(req); + Long menuApplicationId = json.get("menuApplicationId").getLongValue(); + Long favoriteId = dssWorkspaceService.addFavorite(username, workspaceId, menuApplicationId); + return Message.messageToResponse(Message.ok().data("favoriteId", favoriteId)); + } + + @DELETE + @Path("/workspaces/{workspaceId}/favorites/{favouritesId}") + public Response deleteFavorite(@Context HttpServletRequest req, @PathParam("workspaceId") Long workspaceId, @PathParam("favouritesId") Long favouritesId) { + LOGGER.info("deleteFavorite--workspaceId={}--favouritesId={}",workspaceId,favouritesId); + String username = SecurityFilter.getLoginUsername(req); + Long favoriteId = dssWorkspaceService.deleteFavorite(username, favouritesId); + return Message.messageToResponse(Message.ok().data("favoriteId", favoriteId)); + } + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSDictionaryService.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSDictionaryService.java new file mode 100644 index 0000000000..ab71a8185d --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSDictionaryService.java @@ -0,0 +1,45 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service; + + +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSDictionary; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSDictionaryRequestVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DepartmentVO; + +import java.util.List; +import java.util.Map; + + +public interface DSSDictionaryService { + + public List getListByParam(DSSDictionaryRequestVO dictionaryRequestVO) ; + + /** + * 获取编排模式 + * @param dictionaryRequestVO + * @return + */ + public Map getDicSecondList(DSSDictionaryRequestVO dictionaryRequestVO) ; + + /** + * 获取空间默认部门 + * @return + */ + public List getDefaultDepartmentVOList(); + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSSideInfoService.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSSideInfoService.java new file mode 100644 index 0000000000..230e914dd9 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSSideInfoService.java @@ -0,0 +1,28 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service; + + +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.SidebarVO; + +import java.util.List; + + +public interface DSSSideInfoService { + + List getSidebarVOList(String username, Integer workspaceId,boolean isEnglish); +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSUserService.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSUserService.java new file mode 100644 index 0000000000..f63f95ac16 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSUserService.java @@ -0,0 +1,32 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service; + +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSUser; + +public interface DSSUserService { + + public void saveWorkspaceUser(String userName); + + + public Long getUserID(String userName); + + + public DSSUser getByUsername(String userName); + + public boolean isAdminUser(String username); +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceMenuService.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceMenuService.java new file mode 100644 index 0000000000..777bfc64b8 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceMenuService.java @@ -0,0 +1,30 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service; + + + +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSMenu; + +import java.util.List; + + +public interface DSSWorkspaceMenuService { + + + List getRealComponents(List subMenus, String workspaceId, String username); +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspacePrivService.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspacePrivService.java new file mode 100644 index 0000000000..c964d0e509 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspacePrivService.java @@ -0,0 +1,30 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service; + +import org.apache.commons.math3.util.Pair; + +import java.util.List; + + +public interface DSSWorkspacePrivService { + void updateRoleMenuPriv(int workspaceId, int menuId, String updater, List> pairs); + + void updateRoleComponentPriv(int workspaceId, int menuId, String username, List> pairs); + + Integer getRoleId(int workspaceId, String key); +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceRoleService.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceRoleService.java new file mode 100644 index 0000000000..c8de173f92 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceRoleService.java @@ -0,0 +1,30 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service; + +import java.util.List; + + +public interface DSSWorkspaceRoleService { + void addWorkspaceRole(String roleName, int workspaceId, List menuIds, List componentIds, String username); + + List getRoleInWorkspace(String username, int workspaceId); + + Integer getWorkspaceIdByUser(String username); + + int getApiPriv(String username, Integer workspaceId, String roleName, String appName); +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceService.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceService.java new file mode 100644 index 0000000000..87d461b42d --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceService.java @@ -0,0 +1,86 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service; + +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSMenu; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspace; +import com.webank.wedatasphere.dss.framework.workspace.bean.dto.response.*; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.*; +import com.webank.wedatasphere.linkis.common.exception.ErrorException; + +import java.util.List; + + +public interface DSSWorkspaceService { + + + int createWorkspace(String workspaceName, String tags, String userName, String description, String department, String productName) throws ErrorException; + + void addWorkspaceUser(List roleIds, int workspaceId, String userName, String creater); + + List getWorkspaces(String userName); + + DSSWorkspaceHomePageVO getWorkspaceHomePage(String userName,String moduleName); + + List getWorkspaceMenus(String userName, String workspaceId); + + List getWorkspaceUsers(String workspaceId, String department, String username, + String roleName, int pageNow, int pageSize, List total); + + List getWorkspaceRoles(int workspaceId); + + DSSWorkspacePrivVO getWorkspaceMenuPrivs(String workspaceId); + + DSSWorkspaceOverviewVO getOverview(String username, int workspaceId, boolean isEnglish); + + DSSWorkspaceHomepageSettingVO getWorkspaceHomepageSettings(int workspaceId); + + String getWorkspaceName(String workspaceId); + + boolean checkAdmin(String userName); + + List getDepartments(); + + List getWorkspaceUsersByRole(int workspaceId, String roleName, List totals, + int pageNow, int pageSize); + + List getWorkspaces(); + + Long addWorkspace(String userName, String name, String department, String label, String description); + + boolean existWorkspaceName(String name); + + List getWorkSpaceDepartments(); + + List getHomepageDemos(boolean isChinese); + + List getHomepageVideos(boolean isChinese); + + List getWorkspaceManagements(Long workspaceId, String username, boolean isChinese); + + List getWorkspaceApplications(Long workspaceId, String username, boolean isChinese); + + DSSWorkspace getWorkspacesById(Long id); + + List getWorkspaceFavorites(Long workspaceId, String username, boolean isChinese); + + Long addFavorite(String username, Long workspaceId, Long menuApplicationId); + + Long deleteFavorite(String username, Long favouritesId); + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceUserService.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceUserService.java new file mode 100644 index 0000000000..a6202690d8 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/DSSWorkspaceUserService.java @@ -0,0 +1,39 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service; + + + +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSUser; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.StaffInfoVO; + +import java.util.List; + + +public interface DSSWorkspaceUserService { + + + void updateWorkspaceUser(List roles, int workspaceId, String userName, String creator); + + void deleteWorkspaceUser(String userName, int workspaceId); + + List listAllDSSUsers(); + + List getAllWorkspaceUsers(int workspaceId); + + List getUserWorkspaceIds(String userName); +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/StaffInfoGetter.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/StaffInfoGetter.java new file mode 100644 index 0000000000..38391858f7 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/StaffInfoGetter.java @@ -0,0 +1,30 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service; + +import com.webank.wedatasphere.dss.framework.workspace.bean.StaffInfo; + +import java.util.List; + + +public interface StaffInfoGetter { + + List getAllUsers(); + + String getFullOrgNameByUsername(String username); + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSDictionaryServiceImpl.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSDictionaryServiceImpl.java new file mode 100644 index 0000000000..88e3980bd9 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSDictionaryServiceImpl.java @@ -0,0 +1,120 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSDictionary; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSDictionaryRequestVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DepartmentVO; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSDictionaryMapper; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSDictionaryService; +import com.webank.wedatasphere.dss.framework.workspace.util.DSSDictionaryConstant; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + + +@Service +public class DSSDictionaryServiceImpl implements DSSDictionaryService { + + private static final Logger LOGGER = LoggerFactory.getLogger(DSSDictionaryServiceImpl.class); + + @Autowired + private DSSDictionaryMapper dssDictionaryMapper; + + @Override + public List getListByParam(DSSDictionaryRequestVO dictionaryRequestVO) { + //查询所在工作空间以及默认空间的开发流程或编码模式配置 + QueryWrapper dictionaryQueryWrapper = new QueryWrapper<>(); + dictionaryQueryWrapper.in("workspace_id", Arrays.asList(dictionaryRequestVO.getWorkspaceId(),0)); + if(StringUtils.isNotBlank(dictionaryRequestVO.getDicKey())){ + dictionaryQueryWrapper.eq("dic_key",dictionaryRequestVO.getDicKey()); + } + if(StringUtils.isNotBlank(dictionaryRequestVO.getParentKey())){ + dictionaryQueryWrapper.eq("parent_key",dictionaryRequestVO.getParentKey()); + } + dictionaryQueryWrapper.orderByAsc("order_num"); + List dictionaries = dssDictionaryMapper.selectList(dictionaryQueryWrapper); + return dictionaries; + } + + @Override + public Map getDicSecondList(DSSDictionaryRequestVO dictionaryRequestVO) { + //一级字典 + List dictionaries = getListByParam(dictionaryRequestVO); + + //二级字典 + List keyList = dictionaries.stream().map(DSSDictionary::getDicKey).collect(Collectors.toList()); + QueryWrapper dictionaryQueryWrapper = new QueryWrapper<>(); + dictionaryQueryWrapper.in("workspace_id", Arrays.asList(dictionaryRequestVO.getWorkspaceId(),0)); + dictionaryQueryWrapper.in("parent_key",keyList); + dictionaryQueryWrapper.orderByAsc("order_num"); + List dictionarieSelectList = dssDictionaryMapper.selectList(dictionaryQueryWrapper); + + //封装返回 + Map> mapList = new HashMap<>(); + for(DSSDictionary dssDictionary : dictionarieSelectList){ + String parentKey = dssDictionary.getParentKey(); + if(mapList.get(parentKey)==null){ + mapList.put(parentKey,new ArrayList<>()); + } + mapList.get(parentKey).add(dssDictionary); + } + Map retMap = new HashMap<>(); + retMap.put("list",dictionaries); + retMap.put("mapList",mapList); + return retMap; + } + + + /** + * 获取空间默认部门 + * @return + */ + @Override + public List getDefaultDepartmentVOList(){ + QueryWrapper dictionaryQueryWrapper = new QueryWrapper<>(); + dictionaryQueryWrapper.eq("workspace_id", 0); + dictionaryQueryWrapper.eq("dic_key", DSSDictionaryConstant.W_WORKSPACE_DEPARTMENT); + List dictionarieList = dssDictionaryMapper.selectList(dictionaryQueryWrapper); + List retList = new ArrayList<>(); + if(CollectionUtils.isEmpty(dictionarieList)){ + return retList; + } + String dicValue = dictionarieList.get(0).getDicValue(); + if(StringUtils.isBlank(dicValue)){ + return retList; + } + String[] tempStrArr = dicValue.split(";"); + DepartmentVO departmentVO = null; + for(int i=0;i getSidebarVOList(String username, Integer workspaceId,boolean isEnglish) { + //查询所在工作空间以及默认空间的侧边栏 + List retList = new ArrayList<>(); + QueryWrapper sidebarQueryWrapper = new QueryWrapper<>(); + sidebarQueryWrapper.in("workspace_id", Arrays.asList(workspaceId,0)); + sidebarQueryWrapper.orderByAsc("order_num"); + List sidebarList = sidebarMapper.selectList(sidebarQueryWrapper); + if(CollectionUtils.isEmpty(sidebarList)){ + return retList; + } + //查询所在工作空间以及默认空间的侧边栏对应的侧边栏-内容 + List sideBarIds = sidebarList.stream().map(Sidebar::getId).collect(Collectors.toList()); + QueryWrapper sidebarQueryContentWrapper = new QueryWrapper<>(); + sidebarQueryContentWrapper.in("workspace_id", Arrays.asList(workspaceId,0)); + sidebarQueryContentWrapper.in("sidebar_id", sideBarIds); + sidebarQueryContentWrapper.orderByAsc("order_num"); + List sidebarContentList = sidebarContentMapper.selectList(sidebarQueryContentWrapper); + + //封装返回数据 + return getSidebarVOS(retList, sidebarList, sidebarContentList,isEnglish); + } + + //封装返回数据 + private List getSidebarVOS(List retList, List sidebarList, List sidebarContentList,boolean isEnglish) { + Map> contentMap = new HashMap<>(); + for(SidebarContent sidebarContent : sidebarContentList){ + Integer sidebarId = sidebarContent.getSidebarId(); + if(contentMap.get(sidebarId)==null){ + contentMap.put(sidebarId,new ArrayList<>()); + } + contentMap.get(sidebarId).add(sidebarContent); + } + for (Sidebar sidebar : sidebarList){ + SidebarVO sidebarVO = new SidebarVO(); + BeanUtils.copyProperties(sidebar,sidebarVO); + international(isEnglish,sidebar, sidebarVO); + List sidebarContentVOList = new ArrayList<>(); + List sidebarContents = contentMap.get(sidebar.getId()); + if(!CollectionUtils.isEmpty(sidebarContents)){ + for (SidebarContent sidebarContent : sidebarContents){ + SidebarContentVO sidebarContentVO = new SidebarContentVO(); + BeanUtils.copyProperties(sidebarContent,sidebarContentVO); + international(isEnglish,sidebarContent,sidebarContentVO); + sidebarContentVOList.add(sidebarContentVO); + } + } + sidebarVO.setContents(sidebarContentVOList); + retList.add(sidebarVO); + } + return retList; + } + + //国际化 + public void international(boolean isEnglish,Sidebar sidebar, SidebarVO sidebarVO){ + if(sidebar==null||!isEnglish){ + return; + } + if(StringUtils.isNotBlank(sidebar.getNameEn())){ + sidebarVO.setName(sidebar.getNameEn()); + } + if(StringUtils.isNotBlank(sidebar.getTitleEn())){ + sidebarVO.setTitle(sidebar.getTitleEn()); + } + } + + //国际化 + public void international(boolean isEnglish,SidebarContent sidebarContent, SidebarContentVO sidebarContentVO){ + if(sidebarContent==null||!isEnglish){ + return; + } + if(StringUtils.isNotBlank(sidebarContent.getNameEn())){ + sidebarContentVO.setName(sidebarContent.getNameEn()); + } + if(StringUtils.isNotBlank(sidebarContent.getTitleEn())){ + sidebarContentVO.setTitle(sidebarContent.getTitleEn()); + } + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSUserServiceImpl.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSUserServiceImpl.java new file mode 100644 index 0000000000..69fe64441e --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSUserServiceImpl.java @@ -0,0 +1,98 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSUser; +import com.webank.wedatasphere.dss.framework.workspace.bean.LinkisUser; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSUserMapper; +import com.webank.wedatasphere.dss.framework.workspace.dao.LinkisUserMapper; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSUserService; +import org.apache.commons.collections.CollectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + + +@Service +public class DSSUserServiceImpl implements DSSUserService { + + private static final Logger LOGGER = LoggerFactory.getLogger(DSSUserServiceImpl.class); + @Autowired + private DSSUserMapper dssUserMapper; + @Autowired + private LinkisUserMapper linkisUserMapper; + + /** + * 在用户及角色添加到工作空间 之前, + * 判断是否存在 username是否存在dss_user + * 不存在保存 : 将username以及默认信息分别保存到dss_user、linkis_user两张表中 + * @param userName + */ + @Override + public void saveWorkspaceUser(String userName) { + if (getUserID(userName)==null) { + LOGGER.info("User first enter dss, insert table dss_user"); + DSSUser dssUser = new DSSUser(); + dssUser.setUsername(userName); + dssUser.setName(userName); + dssUser.setFirstLogin(true); + //INSERT INTO dss_user() + // VALUES (#{id},#{username},#{name},#{isFirstLogin}) + dssUserMapper.insert(dssUser); + + /* INSERT INTO linkis_user(`username`,`name`,`create_time`,`update_time`,`is_first_login`) + VALUES (#{username},#{name},now(),now(),1)*/ + LinkisUser linkisUser = new LinkisUser(); + linkisUser.setUsername(userName); + linkisUser.setName(userName); + linkisUser.setCreateTime(new Date()); + linkisUser.setUpdateTime(new Date()); + linkisUser.setFirstLogin(true); + linkisUserMapper.insert(linkisUser); + } + } + + //根据用户名获取userId + @Override + public Long getUserID(String userName) { + DSSUser user = getByUsername(userName); + return user!=null?user.getId():null; + } + + //根据用户名获取userId + @Override + public DSSUser getByUsername(String userName) { + QueryWrapper userQueryWrapper = new QueryWrapper<>(); + userQueryWrapper.eq("username", userName); + List dssUserList = dssUserMapper.selectList(userQueryWrapper); + if (!CollectionUtils.isEmpty(dssUserList)) { + return dssUserList.get(0); + } + return null; + } + + @Override + public boolean isAdminUser(String username) { + DSSUser user = getByUsername(username); + return user!=null?user.getAdmin().booleanValue():false; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceMenuServiceImpl.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceMenuServiceImpl.java new file mode 100644 index 0000000000..413712e84f --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceMenuServiceImpl.java @@ -0,0 +1,63 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service.impl; + +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSMenu; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSWorkspaceMenuMapper; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSWorkspaceUserMapper; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceMenuService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + + +@Service +public class DSSWorkspaceMenuServiceImpl implements DSSWorkspaceMenuService { + + + @Autowired + private DSSWorkspaceMenuMapper dssWorkspaceMenuMapper; + + @Autowired + private DSSWorkspaceUserMapper dssWorkspaceUserMapper; + + @Override + public List getRealComponents(List subMenus, String workspaceId, String username) { + Set dssMenuSet = new HashSet<>(subMenus); + subMenus.forEach(subMenu -> { + if (subMenu.isComponent()){ + int applicationId = subMenu.getApplicationId(); + List roles = dssWorkspaceUserMapper.getRoleInWorkspace(Integer.parseInt(workspaceId),username); + int priv = 0; + for (Integer role : roles) { + Integer rolePriv = dssWorkspaceMenuMapper.getOneCompoentRolePriv(Integer.parseInt(workspaceId), role, applicationId); + if(rolePriv != null){ + priv += rolePriv; + } + } + if (priv == 0){ + dssMenuSet.remove(subMenu); + } + } + }); + return new ArrayList<>(dssMenuSet); + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspacePrivServiceImpl.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspacePrivServiceImpl.java new file mode 100644 index 0000000000..59c085368c --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspacePrivServiceImpl.java @@ -0,0 +1,65 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service.impl; + +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSWorkspacePrivMapper; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspacePrivService; +import org.apache.commons.math3.util.Pair; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + + +@Service +public class DSSWorkspacePrivServiceImpl implements DSSWorkspacePrivService { + + + @Autowired + private DSSWorkspacePrivMapper dssWorkspacePrivMapper; + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateRoleMenuPriv(int workspaceId, int menuId, String updater, List> pairs) { + pairs.forEach(pair -> { + int roleId = pair.getKey(); + int priv = pair.getValue() ? 1 : 0; + dssWorkspacePrivMapper.updateRoleMenuPriv(workspaceId, menuId, roleId, priv); + }); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateRoleComponentPriv(int workspaceId, int componentId, String username, List> pairs) { + pairs.forEach(pair -> { + int roleId = pair.getKey(); + int priv = pair.getValue() ? 1 : 0; + int count = dssWorkspacePrivMapper.queryCntOfRCP(workspaceId, componentId, roleId); + if (count >= 1) { + dssWorkspacePrivMapper.updateRoleComponentPriv(workspaceId, componentId, roleId, priv); + }else { + dssWorkspacePrivMapper.insertRolComponentPriv(workspaceId, componentId, roleId, priv); + } + }); + } + + @Override + public Integer getRoleId(int workspaceId, String key) { + return dssWorkspacePrivMapper.getRoleId(workspaceId, key); + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceRoleServiceImpl.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceRoleServiceImpl.java new file mode 100644 index 0000000000..75b2177ee9 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceRoleServiceImpl.java @@ -0,0 +1,108 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service.impl; + +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSRole; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSWorkspaceRoleMapper; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceRoleService; +import com.webank.wedatasphere.dss.framework.workspace.util.DSSWorkspaceConstant; +import com.webank.wedatasphere.dss.framework.workspace.util.WorkspaceDBHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + + +@Service +public class DSSWorkspaceRoleServiceImpl implements DSSWorkspaceRoleService { + + + private static final Logger LOGGER = LoggerFactory.getLogger(DSSWorkspaceRoleServiceImpl.class); + + @Autowired + private DSSWorkspaceRoleMapper dssWorkspaceRoleMapper; + + @Autowired + private WorkspaceDBHelper workspaceDBHelper; + + @Override + @Transactional(rollbackFor = Exception.class) + public void addWorkspaceRole(String roleName, int workspaceId, List menuIds, List componentIds, String username) { + DSSRole dssRole = new DSSRole(); + dssRole.setWorkspaceId(workspaceId); + dssRole.setFrontName(roleName); + dssRole.setName(roleName); + dssRole.setCreateTime(new Date()); + dssRole.setDescription("workspace{ " + workspaceId + " }添加的role"); + dssWorkspaceRoleMapper.addNewRole(dssRole); + List allMenuIds = workspaceDBHelper.getAllMenuIds(); + if (menuIds.size() > 0){ + dssWorkspaceRoleMapper.updateRoleMenu(dssRole.getId(), workspaceId, menuIds, username, 1); + } + if (menuIds.size() < allMenuIds.size()){ + allMenuIds.removeAll(menuIds); + dssWorkspaceRoleMapper.updateRoleMenu(dssRole.getId(), workspaceId, allMenuIds, username, 0); + } + List allComponentIds = workspaceDBHelper.getAllComponentIds(); + if (componentIds.size() > 0){ + dssWorkspaceRoleMapper.updateRoleComponent(dssRole.getId(), workspaceId, componentIds, username, 1); + } + if (componentIds.size() < allComponentIds.size()){ + allComponentIds.removeAll(componentIds); + dssWorkspaceRoleMapper.updateRoleComponent(dssRole.getId(), workspaceId, allComponentIds, username, 0); + } + workspaceDBHelper.retrieveFromDB(); + } + + @Override + public List getRoleInWorkspace(String username, int workspaceId) { + LOGGER.info("get roles for user {} in workspace {}", username, workspaceId); + return dssWorkspaceRoleMapper.getAllRoles(username, workspaceId); + } + + @Override + public Integer getWorkspaceIdByUser(String username) { + List workspaceIds = dssWorkspaceRoleMapper.getWorkspaceIds(username); + Integer defaultWorkspaceId = dssWorkspaceRoleMapper.getDefaultWorkspaceId(DSSWorkspaceConstant.DEFAULT_WORKSPACE_NAME.getValue()); + if (workspaceIds.isEmpty()){ + return defaultWorkspaceId; + } else if (workspaceIds.size() == 1){ + return workspaceIds.get(0); + } else { + workspaceIds.remove(defaultWorkspaceId); + return workspaceIds.get(0); + } + } + + @Override + public int getApiPriv(String username, Integer workspaceId, String roleName, String appName) { + int roleId = dssWorkspaceRoleMapper.getRoleId(roleName, -1); + int componentId = dssWorkspaceRoleMapper.getComponentId(appName); + int count = dssWorkspaceRoleMapper.getCount(workspaceId, componentId, roleId); + if (count >= 1){ + Integer tmpPriv = dssWorkspaceRoleMapper.getPriv(workspaceId, roleId, componentId); + return tmpPriv!=null ? tmpPriv.intValue() : 0; + }else{ + Integer tmpPriv = dssWorkspaceRoleMapper.getPriv(-1,roleId, componentId); + return tmpPriv!=null ? tmpPriv.intValue() : 0; + } + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceServiceImpl.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceServiceImpl.java new file mode 100644 index 0000000000..613da6c7c7 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceServiceImpl.java @@ -0,0 +1,604 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service.impl; + +import static com.webank.wedatasphere.dss.framework.workspace.util.DSSWorkspaceConstant.DEFAULT_DEMO_WORKSPACE_NAME; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.webank.wedatasphere.dss.appconn.core.AppConn; +import com.webank.wedatasphere.dss.appconn.manager.AppConnManager; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSFavorite; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSMenu; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspace; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspaceComponentRolePriv; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspaceHomepageSetting; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspaceMenuRolePriv; +import com.webank.wedatasphere.dss.framework.workspace.bean.DSSWorkspaceUser; +import com.webank.wedatasphere.dss.framework.workspace.bean.dto.response.HomepageDemoInstanceVo; +import com.webank.wedatasphere.dss.framework.workspace.bean.dto.response.HomepageDemoMenuVo; +import com.webank.wedatasphere.dss.framework.workspace.bean.dto.response.HomepageVideoVo; +import com.webank.wedatasphere.dss.framework.workspace.bean.dto.response.OnestopMenuAppInstanceVo; +import com.webank.wedatasphere.dss.framework.workspace.bean.dto.response.OnestopMenuVo; +import com.webank.wedatasphere.dss.framework.workspace.bean.dto.response.WorkspaceDepartmentVo; +import com.webank.wedatasphere.dss.framework.workspace.bean.dto.response.WorkspaceFavoriteVo; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceComponentPrivVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceHomePageVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceHomepageSettingVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceMenuPrivVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceOverviewVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspacePrivVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceRoleVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceUserVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DepartmentVO; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.SecondaryWorkspaceMenuVO; +import com.webank.wedatasphere.dss.framework.workspace.constant.ApplicationConf; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSComponentRoleMapper; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSMenuRoleMapper; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSWorkspaceHomepageMapper; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSWorkspaceInfoMapper; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSWorkspaceMapper; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSWorkspaceMenuMapper; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSWorkspaceUserMapper; +import com.webank.wedatasphere.dss.framework.workspace.dao.WorkspaceMapper; +import com.webank.wedatasphere.dss.framework.workspace.exception.DSSWorkspaceDuplicateNameException; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSUserService; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceMenuService; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceService; +import com.webank.wedatasphere.dss.framework.workspace.service.StaffInfoGetter; +import com.webank.wedatasphere.dss.framework.workspace.util.CommonRoleEnum; +import com.webank.wedatasphere.dss.framework.workspace.util.DSSWorkspaceConstant; +import com.webank.wedatasphere.dss.framework.workspace.util.WorkspaceDBHelper; +import com.webank.wedatasphere.dss.framework.workspace.util.WorkspaceServerConstant; +import com.webank.wedatasphere.linkis.common.exception.ErrorException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class DSSWorkspaceServiceImpl implements DSSWorkspaceService { + private static final Logger LOGGER = LoggerFactory.getLogger(DSSWorkspaceServiceImpl.class); + + @Autowired + private DSSWorkspaceMapper dssWorkspaceMapper; + @Autowired + private DSSWorkspaceUserMapper dssWorkspaceUserMapper; + @Autowired + private DSSWorkspaceMenuMapper dssWorkspaceMenuMapper; + @Autowired + private DSSWorkspaceInfoMapper dssWorkspaceInfoMapper; + @Autowired + private WorkspaceDBHelper workspaceDBHelper; + @Autowired + private StaffInfoGetter staffInfoGetter; + @Autowired + private DSSUserService dssUserService; + @Autowired + private DSSMenuRoleMapper dssMenuRoleMapper; + @Autowired + private DSSWorkspaceHomepageMapper dssWorkspaceHomepageMapper; + @Autowired + private DSSComponentRoleMapper dssComponentRoleMapper; + @Autowired + private DSSWorkspaceMenuService dssWorkspaceMenuService; + @Autowired + private WorkspaceMapper workspaceMapper; + + //创建工作空间 + @Override + @Transactional(rollbackFor = Exception.class) + public int createWorkspace(String workspaceName, String tags, String userName, + String description, String department, String productName) throws ErrorException { + DSSWorkspace dssWorkspace = new DSSWorkspace(); + dssWorkspace.setDescription(description); + dssWorkspace.setName(workspaceName); + dssWorkspace.setLabel(tags); + dssWorkspace.setCreateBy(userName); + dssWorkspace.setDepartment(department); + dssWorkspace.setProduct(productName); + dssWorkspace.setCreateTime(new Date()); + dssWorkspace.setLastUpdateTime(new Date()); + dssWorkspace.setLastUpdateUser(userName); + try{ + dssWorkspaceMapper.createWorkSpace(dssWorkspace); + }catch(Exception e){ + DSSWorkspaceDuplicateNameException exception1 = new DSSWorkspaceDuplicateNameException(50010, "工作空间名重复"); + exception1.initCause(e); + throw exception1; + } + dssWorkspaceUserMapper.insertUser(userName, dssWorkspace.getId(), userName); + dssWorkspaceUserMapper.setUserRoleInWorkspace(dssWorkspace.getId(), CommonRoleEnum.ADMIN.getId(), userName, userName); + dssMenuRoleMapper.insertBatch(workspaceDBHelper.generateDefaultWorkspaceMenuRole(dssWorkspace.getId(), userName)); + dssWorkspaceHomepageMapper.insertBatch(workspaceDBHelper.generateDefaultWorkspaceHomepage(dssWorkspace.getId(), userName)); + dssComponentRoleMapper.insertBatch(workspaceDBHelper.generateDefaultWorkspaceComponentPrivs(dssWorkspace.getId(), userName)); + return dssWorkspace.getId(); + } + + + //把用户及角色添加到工作空间 + @Override + @Transactional(rollbackFor = Exception.class) + public void addWorkspaceUser(List roleIds, int workspaceId, String userName, String creator) { + //根据用户名 从用户表拿到用户id + Long userId = dssUserService.getUserID(userName); + if(userId == null){ + //保存 - dss_user、linkis_user + dssUserService.saveWorkspaceUser(userName); + } + //保存 - dss_workspace_user + dssWorkspaceUserMapper.insertUser(userName, workspaceId, creator); + //保存 - 保存用户角色关系 dss_workspace_user_role + for (Integer roleId : roleIds) { + dssWorkspaceUserMapper.setUserRoleInWorkspace(workspaceId, roleId, userName, creator); + } + } + + //获取所有的工作空间 + @Override + public List getWorkspaces(String userName){ + List workspaces = dssWorkspaceMapper.getWorkspaces(userName); + //用于展示demo的工作空间是不应该返回的,除非用户是管理员 + if(dssWorkspaceUserMapper.isAdmin(userName)) { + return workspaces; + }else{ + //踢掉那个演示demo工作空间 + List retWorkspaces = new ArrayList<>(); + String defaultDemoWorkspaceName = DEFAULT_DEMO_WORKSPACE_NAME.getValue(); + for (DSSWorkspace workspace : workspaces) { + if (!workspace.getName().equals(defaultDemoWorkspaceName)){ + retWorkspaces.add(workspace); + } + } + return retWorkspaces; + } + } + + @Override + public DSSWorkspaceHomePageVO getWorkspaceHomePage(String userName,String moduleName) { + //根据用户名 拿到用户ID + //根据用户id 和工作空间id 拿到 角色id + //根据role id 和工作空间id 拿到 重定向的 url + List tempWorkspaceIds = dssWorkspaceUserMapper.getWorkspaceIds(userName); + List workspaceIds = new ArrayList<>(); + tempWorkspaceIds.stream(). + map(dssWorkspaceInfoMapper::getWorkspaceNameById). + filter(name -> !DEFAULT_DEMO_WORKSPACE_NAME.getValue().equals(name)). + map(dssWorkspaceInfoMapper::getWorkspaceIdByName). + forEach(workspaceIds::add); + DSSWorkspaceHomePageVO dssWorkspaceHomePageVO = new DSSWorkspaceHomePageVO(); + if (workspaceIds.size() == 0){ +// while(userId == null || userId.intValue() < 0){ +// userId = dssWorkspaceUserMapper.getUserID(userName); +// } + int workspaceId = dssWorkspaceInfoMapper.getWorkspaceIdByName(DSSWorkspaceConstant.DEFAULT_WORKSPACE_NAME.getValue()); + dssWorkspaceUserMapper.insertUser(userName, workspaceId, "system"); + dssWorkspaceUserMapper.setUserRoleInWorkspace(workspaceId, CommonRoleEnum.ANALYSER.getId(), userName, "system"); + String homepageUrl = dssWorkspaceUserMapper.getHomepageUrl(workspaceId, CommonRoleEnum.ANALYSER.getId()); + if(ApplicationConf.HOMEPAGE_MODULE_NAME.getValue().equalsIgnoreCase(moduleName)){ + homepageUrl= ApplicationConf.HOMEPAGE_URL.getValue() + workspaceIds.get(0); + } + if(StringUtils.isEmpty(homepageUrl)) { + homepageUrl = "/home" + "?workspaceId=" + workspaceId; + } + dssWorkspaceHomePageVO.setHomePageUrl(homepageUrl); + dssWorkspaceHomePageVO.setWorkspaceId(workspaceId); + dssWorkspaceHomePageVO.setRoleName(CommonRoleEnum.ANALYSER.getName()); + }else if(workspaceIds.size() == 1){ + //只有一个工作空间,那么就返回该工作空间的首页 + List roleIds = dssWorkspaceUserMapper.getRoleInWorkspace(workspaceIds.get(0), userName); + int minRoleId = Collections.min(roleIds); + String homepageUrl = dssWorkspaceUserMapper.getHomepageUrl(workspaceIds.get(0), minRoleId); + if(StringUtils.isNotEmpty(homepageUrl)) { + homepageUrl = "/home" + "?workspaceId=" + workspaceIds.get(0); + }else{ + homepageUrl = "/home" + "?workspaceId=" + workspaceIds.get(0); + } + if(ApplicationConf.HOMEPAGE_MODULE_NAME.getValue().equalsIgnoreCase(moduleName)){ + homepageUrl= ApplicationConf.HOMEPAGE_URL.getValue() + workspaceIds.get(0); + } + dssWorkspaceHomePageVO.setHomePageUrl(homepageUrl); + dssWorkspaceHomePageVO.setWorkspaceId(workspaceIds.get(0)); + dssWorkspaceHomePageVO.setRoleName(workspaceDBHelper.getRoleNameById(minRoleId)); + }else{ + //排除掉默认的默认工作空间bdapWorkspace + String homepageUrl="/workspaceHome?workspaceId=" + workspaceIds.get(0); + if(ApplicationConf.HOMEPAGE_MODULE_NAME.getValue().equalsIgnoreCase(moduleName)){ + homepageUrl= ApplicationConf.HOMEPAGE_URL.getValue() + workspaceIds.get(0); + } + dssWorkspaceHomePageVO.setHomePageUrl(homepageUrl); + } + return dssWorkspaceHomePageVO; + } + + @Override + public List getWorkspaceMenus(String userName, String workspaceId) { + //根据用户及工作空间id获取到用户角色id,根据角色和工作空间id 获取菜单id,根据菜单id 封装1级2级菜单并返回 + List roleIds = dssWorkspaceUserMapper.getRoleInWorkspace(Integer.parseInt(workspaceId), userName); + Set menuIds = new HashSet<>(); + for (Integer roleId : roleIds) { + List menuList = dssWorkspaceMapper.getMenuId(roleId, workspaceId); + menuIds.addAll(menuList); + } + List dssMenuList = new ArrayList<>(); + for (int menuId : menuIds){ + DSSMenu dssMenu = dssWorkspaceMapper.getSpaceMenu(menuId); + dssMenuList.add(dssMenu); + } + return dssMenuList; + } + + @Override + public List getWorkspaceUsers(String workspaceId, String department, String username, + String roleName, int pageNow, int pageSize, List total) { + int roleId = -1; + if (StringUtils.isNotEmpty(roleName)){ + roleId = workspaceDBHelper.getRoleIdByName(roleName); + } + PageHelper.startPage(pageNow, pageSize); + List workspaceUsers = new ArrayList<>(); + try{ + workspaceUsers = dssWorkspaceUserMapper.getWorkspaceUsers(workspaceId, department,username, roleId); + }finally { + PageHelper.clearPage(); + } + PageInfo pageInfo = new PageInfo<>(workspaceUsers); + total.add(pageInfo.getTotal()); + List dssWorkspaceUserVOs = new ArrayList<>(); + for (DSSWorkspaceUser workspaceUser : workspaceUsers) { + List roles = dssWorkspaceUserMapper.getRoleInWorkspace(Integer.parseInt(workspaceId), workspaceUser.getUsername()); + dssWorkspaceUserVOs.add(changeToUserVO(workspaceUser, roles)); + } + return dssWorkspaceUserVOs; + } + + private DSSWorkspaceUserVO changeToUserVO(DSSWorkspaceUser dssWorkspaceUser, List roles){ + DSSWorkspaceUserVO vo = new DSSWorkspaceUserVO(); + String userName = dssWorkspaceUser.getUsername(); + vo.setName(userName); + String orgFullName = staffInfoGetter.getFullOrgNameByUsername(userName); + if (StringUtils.isNotEmpty(orgFullName)){ + try{ + String departmentName = orgFullName.split(WorkspaceServerConstant.DEFAULT_STAFF_SPLIT)[0]; + String officeName = orgFullName.split(WorkspaceServerConstant.DEFAULT_STAFF_SPLIT)[1]; + vo.setDepartment(departmentName); + vo.setOffice(officeName); + }catch(Exception e){ + //LOGGER.warn("fail to get department and office {} ", e.getMessage()); + vo.setDepartment(WorkspaceServerConstant.DEFAULT_DEPARTMENT); + vo.setOffice(WorkspaceServerConstant.DEFAULT_OFFICE); + } + } + vo.setRoles(roles); + vo.setCreator(dssWorkspaceUser.getCreator()); + vo.setJoinTime(dssWorkspaceUser.getJoinTime()); + return vo; + } + + @Override + public List getWorkspaceRoles(int workspaceId) { + return workspaceDBHelper.getRoleVOs(workspaceId); + } + + @Override + public DSSWorkspacePrivVO getWorkspaceMenuPrivs(String workspaceId) { + DSSWorkspacePrivVO dssWorkspacePrivVO = new DSSWorkspacePrivVO(); + dssWorkspacePrivVO.setWorkspaceId(Integer.parseInt(workspaceId)); + dssWorkspacePrivVO.setRoleVOS(workspaceDBHelper.getRoleVOs(Integer.parseInt(workspaceId))); + List dssWorkspaceMenuPrivVOList = new ArrayList<>(); + List dssWorkspaceMenuRolePrivList = dssWorkspaceMapper.getDSSWorkspaceMenuPriv(workspaceId); + Map> map = new HashMap<>(); + for (DSSWorkspaceMenuRolePriv dssWorkspaceMenuPriv : dssWorkspaceMenuRolePrivList){ + int menuId = dssWorkspaceMenuPriv.getMenuId(); + if(!map.containsKey(menuId)){ + map.put(menuId, new ArrayList<>()); + } + map.get(menuId).add(dssWorkspaceMenuPriv); + } + map.forEach((k,v) ->{ + DSSWorkspaceMenuPrivVO vo = new DSSWorkspaceMenuPrivVO(); + vo.setId(k); + vo.setName(workspaceDBHelper.getMenuNameById(k).getFrontName()); + Map menuPrivs = new HashMap<>(); + v.forEach(priv -> { + menuPrivs.put(workspaceDBHelper.getRoleNameById(priv.getRoleId()), priv.getPriv() == 1); + }); + vo.setMenuPrivs(menuPrivs); + dssWorkspaceMenuPrivVOList.add(vo); + }); + dssWorkspacePrivVO.setMenuPrivVOS(dssWorkspaceMenuPrivVOList); + + List dssWorkspaceComponentPrivVOList = new ArrayList<>(); + List dssWorkspaceComponentRolePrivList = + dssWorkspaceMenuMapper.getComponentRolePriv(Integer.parseInt(workspaceId)); + List defaultDssWorkspaceComponentRolePrivList = dssWorkspaceMenuMapper.getDefaultComponentRolePriv(); + for (DSSWorkspaceComponentRolePriv p : defaultDssWorkspaceComponentRolePrivList){ + if (!dssWorkspaceComponentRolePrivList.contains(p)) { + dssWorkspaceComponentRolePrivList.add(p); + } + } + Map> map1 = new HashMap<>(); + for (DSSWorkspaceComponentRolePriv dssWorkspaceComponentRolePriv : dssWorkspaceComponentRolePrivList){ + int componentId = dssWorkspaceComponentRolePriv.getComponentId(); + if(!map1.containsKey(componentId)){ + List tempList = new ArrayList<>(); + tempList.add(dssWorkspaceComponentRolePriv); + map1.put(componentId, tempList); + }else{ + map1.get(componentId).add(dssWorkspaceComponentRolePriv); + } + } + map1.forEach((k,v) ->{ + DSSWorkspaceComponentPrivVO vo = new DSSWorkspaceComponentPrivVO(); + vo.setId(k); + if (workspaceDBHelper.getComponent(k) != null){ + vo.setName(workspaceDBHelper.getComponent(k).getName()); + } else { + vo.setName("linkis"); + } + Map componentPrivs = new HashMap<>(); + v.forEach(priv -> { + componentPrivs.put(workspaceDBHelper.getRoleNameById(priv.getRoleId()), priv.getPriv() == 1); + }); + vo.setComponentPrivs(componentPrivs); + dssWorkspaceComponentPrivVOList.add(vo); + }); + dssWorkspacePrivVO.setComponentPrivVOS(dssWorkspaceComponentPrivVOList); + return dssWorkspacePrivVO; + } + + @Override + public DSSWorkspaceOverviewVO getOverview(String username, int workspaceId, boolean isEnglish) { + DSSWorkspaceOverviewVO dssWorkspaceOverviewVO = new DSSWorkspaceOverviewVO(); + DSSWorkspace dssWorkspace = dssWorkspaceInfoMapper.getWorkspace(workspaceId); + dssWorkspaceOverviewVO.setTitle(dssWorkspace.getName()); + dssWorkspaceOverviewVO.setDescription(dssWorkspace.getDescription()); + return dssWorkspaceOverviewVO; + } + + private SecondaryWorkspaceMenuVO menuChangeToVO(DSSMenu dssMenu){ + SecondaryWorkspaceMenuVO secondaryWorkspaceMenuVO = new SecondaryWorkspaceMenuVO(); + secondaryWorkspaceMenuVO.setId(dssMenu.getId()); + secondaryWorkspaceMenuVO.setName(dssMenu.getFrontName()); + secondaryWorkspaceMenuVO.setUrl(dssMenu.getUrl()); + return secondaryWorkspaceMenuVO; + } + + + @Override + public DSSWorkspaceHomepageSettingVO getWorkspaceHomepageSettings(int workspaceId) { + DSSWorkspaceHomepageSettingVO dssWorkspaceHomepageSettingVO = new DSSWorkspaceHomepageSettingVO(); + + List dssWorkspaceHomepageSettings = dssWorkspaceMenuMapper.getWorkspaceHompageSettings(workspaceId); + List roleHomepageList = new ArrayList<>(); + dssWorkspaceHomepageSettings.forEach(homepage -> { + DSSWorkspaceHomepageSettingVO.RoleHomepage roleHomepage = new DSSWorkspaceHomepageSettingVO.RoleHomepage(); + roleHomepage.setHomepageName(workspaceDBHelper.getHomepageName(homepage.getHomepageUrl())); + roleHomepage.setHomepageUrl(homepage.getHomepageUrl()); + roleHomepage.setRoleId(homepage.getRoleId()); + roleHomepage.setRoleName(workspaceDBHelper.getRoleNameById(homepage.getRoleId())); + roleHomepage.setRoleFrontName(workspaceDBHelper.getRoleFrontName(homepage.getRoleId())); + roleHomepageList.add(roleHomepage); + }); + dssWorkspaceHomepageSettingVO.setRoleHomepages(roleHomepageList); + return dssWorkspaceHomepageSettingVO; + } + + @Override + public String getWorkspaceName(String workspaceId) { + return dssWorkspaceInfoMapper.getWorkspaceNameById(Integer.parseInt(workspaceId)); + } + + @Override + public boolean checkAdmin(String userName) { + return dssWorkspaceUserMapper.isAdmin(userName); + } + + @Override + public List getDepartments() { + List allDepartments = Arrays.asList("WeDataSphere","DataSP", "linkis"); + List departmentVOs = new ArrayList<>(); + int count = 1; + for (String department : allDepartments){ + DepartmentVO departmentVO = new DepartmentVO(); + departmentVO.setFrontName(department); + departmentVO.setName(department); + departmentVO.setId(count); + departmentVOs.add(departmentVO); + count ++; + } + return departmentVOs; + } + + @Override + public List getWorkspaceUsersByRole(int workspaceId, String roleName, List totals, int pageNow, int pageSize) { + int roleId = workspaceDBHelper.getRoleIdByName(roleName); + PageHelper.startPage(pageNow, pageSize); + List workspaceUsers = new ArrayList<>(); + try{ + workspaceUsers = dssWorkspaceUserMapper.getWorkspaceUsersByRole(workspaceId, roleId); + }finally { + PageHelper.clearPage(); + } + PageInfo pageInfo = new PageInfo<>(workspaceUsers); + totals.add(pageInfo.getTotal()); + List dssWorkspaceUserVOs = new ArrayList<>(); + for (DSSWorkspaceUser workspaceUser : workspaceUsers) { + List roles = dssWorkspaceUserMapper.getRoleInWorkspace(workspaceId, workspaceUser.getUsername()); + dssWorkspaceUserVOs.add(changeToUserVO(workspaceUser, roles)); + } + return dssWorkspaceUserVOs; + } + + + @Override + public List getWorkspaces() { + + return workspaceMapper.getWorkspaces(); + } + + @Override + public DSSWorkspace getWorkspacesById(Long id) { + return workspaceMapper.getWorkspaceById(id); + } + + + @Override + public Long addWorkspace(String userName, String name, String department, String label, String description) { + DSSWorkspace dssWorkspace = new DSSWorkspace(); + dssWorkspace.setName(name); + dssWorkspace.setDepartment(department); + dssWorkspace.setDescription(description); + dssWorkspace.setLabel(label); + dssWorkspace.setCreateBy(userName); + dssWorkspace.setSource("create by user"); + dssWorkspace.setLastUpdateUser(userName); + workspaceMapper.addWorkSpace(dssWorkspace); + return (long) dssWorkspace.getId(); + } + + @Override + public boolean existWorkspaceName(String name) { + return !workspaceMapper.findByWorkspaceName(name).isEmpty(); + } + + @Override + public List getWorkSpaceDepartments() { + // TODO: service层和dao层完善 + WorkspaceDepartmentVo dp = new WorkspaceDepartmentVo(); + dp.setId(1L); + dp.setName("应用开发组"); + WorkspaceDepartmentVo di = new WorkspaceDepartmentVo(); + di.setId(2L); + di.setName("平台研发组"); + List departments = new ArrayList<>(); + departments.add(dp); + departments.add(di); + return departments; + } + + @Override + public List getHomepageDemos(boolean isChinese) { + List demoMenuVos = isChinese ? workspaceMapper.getHomepageDemoMenusCn() : workspaceMapper.getHomepageDemoMenusEn(); + for (HomepageDemoMenuVo demoMenuVo : demoMenuVos) { + Long menuId = demoMenuVo.getId(); + List demoInstanceVos = isChinese ? workspaceMapper.getHomepageInstancesByMenuIdCn(menuId) : workspaceMapper.getHomepageInstancesByMenuIdEn(menuId); + demoMenuVo.setDemoInstances(demoInstanceVos); + } + return demoMenuVos; + } + + @Override + public List getHomepageVideos(boolean isChinese) { + return isChinese ? workspaceMapper.getHomepageVideosCn() : workspaceMapper.getHomepageVideosEn(); + } + + @Override + public List getWorkspaceManagements(Long workspaceId, String username, boolean isChinese) { + if (!isAdminUser(workspaceId, username)) { + return new ArrayList<>(); + } + List managementMenuVos = isChinese ? workspaceMapper.getManagementMenuCn() : workspaceMapper.getManagementMenuEn(); + return getMenuAppInstances(managementMenuVos, isChinese); + } + + private List getMenuAppInstances(List menuVos, boolean isChinese) { + for (OnestopMenuVo menuVo : menuVos) { + List appConns = AppConnManager.getAppConnManager().listAppConns(); + + Long menuId = menuVo.getId(); + List menuAppInstanceVos = isChinese ? workspaceMapper.getMenuAppInstancesCn(menuId) : workspaceMapper.getMenuAppInstancesEn(menuId); + for (OnestopMenuAppInstanceVo menuAppInstanceVo : menuAppInstanceVos) { + Map nameAndUrl = new HashMap<>(); + appConns.forEach(appConn -> { + if(appConn.getAppDesc().getAppName().equalsIgnoreCase(menuAppInstanceVo.getName())) { + if (appConn.getAppDesc().getAppInstances().size() == 2) { + appConn.getAppDesc().getAppInstances().forEach(appInstance -> { + + nameAndUrl.put("进入开发中心", appInstance.getBaseUrl()); + + }); + } + } + }); + if(nameAndUrl.size()==0) { + nameAndUrl.put(menuAppInstanceVo.getAccessButton(), menuAppInstanceVo.getAccessButtonUrl()); + } + + menuAppInstanceVo.setNameAndUrls(nameAndUrl); + } + menuVo.setAppInstances(menuAppInstanceVos); + } + return menuVos; + } + + @Override + public List getWorkspaceApplications(Long workspaceId, String username, boolean isChinese) { + List applicationMenuVos = isChinese ? workspaceMapper.getApplicationMenuCn() : workspaceMapper.getApplicationMenuEn(); + return getMenuAppInstances(applicationMenuVos, isChinese); + } + + @Override + public List getWorkspaceFavorites(Long workspaceId, String username, boolean isChinese) { + return isChinese ? workspaceMapper.getWorkspaceFavoritesCn(username, workspaceId) : workspaceMapper.getWorkspaceFavoritesEn(username, workspaceId); + } + + @Override + public Long addFavorite(String username, Long workspaceId, Long menuApplicationId) { + DSSFavorite dssFavorite = new DSSFavorite(); + dssFavorite.setUsername(username); + dssFavorite.setWorkspaceId(workspaceId); + dssFavorite.setMenuApplicationId(menuApplicationId); + // todo: order will from the front end + dssFavorite.setOrder(1); + dssFavorite.setCreateBy(username); + dssFavorite.setLastUpdateUser(username); + workspaceMapper.addFavorite(dssFavorite); + return dssFavorite.getId(); + } + + @Override + public Long deleteFavorite(String username, Long favouritesId) { + workspaceMapper.deleteFavorite(favouritesId); + return favouritesId; + } + + private boolean isAdminUser(Long workspaceId, String username) { + DSSWorkspace workspace = workspaceMapper.getWorkspaceById(workspaceId); + List roles = dssWorkspaceUserMapper.getRoleInWorkspace(workspaceId.intValue(), username); + if(roles != null && roles.size() > 0) { + for (Integer role : roles){ + if (role == 1){ + return true; + } + } + + } + return username != null && workspace != null && username.equals(workspace.getCreateBy()); + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceUserServiceImpl.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceUserServiceImpl.java new file mode 100644 index 0000000000..7cdf4864e3 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DSSWorkspaceUserServiceImpl.java @@ -0,0 +1,99 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service.impl; + +import com.webank.wedatasphere.dss.framework.workspace.bean.StaffInfo; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.StaffInfoVO; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSWorkspaceUserMapper; +import com.webank.wedatasphere.dss.framework.workspace.service.DSSWorkspaceUserService; +import com.webank.wedatasphere.dss.framework.workspace.service.StaffInfoGetter; +import com.webank.wedatasphere.dss.framework.workspace.util.WorkspaceServerConstant; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.stream.Collectors; + + +@Service +public class DSSWorkspaceUserServiceImpl implements DSSWorkspaceUserService { + + private static final Logger LOGGER = LoggerFactory.getLogger(DSSWorkspaceUserServiceImpl.class); + @Autowired + private DSSWorkspaceUserMapper dssWorkspaceUserMapper; + + @Autowired + StaffInfoGetter staffInfoGetter; + + @Override + @Transactional(rollbackFor = Throwable.class) + public void updateWorkspaceUser(List roles, int workspaceId, String userName, String creator) { + dssWorkspaceUserMapper.removeAllRolesForUser(userName, workspaceId); + roles.forEach(role ->{ + dssWorkspaceUserMapper.setUserRoleInWorkspace(workspaceId, role, userName, creator); + }); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteWorkspaceUser(String userName, int workspaceId) { + dssWorkspaceUserMapper.removeAllRolesForUser(userName, workspaceId); + dssWorkspaceUserMapper.removeUserInWorkspace(userName, workspaceId); + } + + @Override + public List listAllDSSUsers() { + //需要将esb带来的所有用户进行返回 + List staffInfos = staffInfoGetter.getAllUsers(); + return staffInfos.stream().map(this::staffToDSSUser).collect(Collectors.toList()); + } + + private StaffInfoVO staffToDSSUser(StaffInfo staffInfo){ + StaffInfoVO staffInfoVO = new StaffInfoVO(); + String orgFullName = staffInfo.getOrgFullName(); + if (StringUtils.isNotEmpty(orgFullName)){ + try{ + String departmentName = orgFullName.split(WorkspaceServerConstant.DEFAULT_STAFF_SPLIT)[0]; + String officeName = orgFullName.split(WorkspaceServerConstant.DEFAULT_STAFF_SPLIT)[1]; + staffInfoVO.setDepartment(departmentName); + staffInfoVO.setOffice(officeName); + }catch(Exception e){ + //LOGGER.warn("fail to get department and office {} ", e.getMessage()); + staffInfoVO.setDepartment(WorkspaceServerConstant.DEFAULT_DEPARTMENT); + staffInfoVO.setOffice(WorkspaceServerConstant.DEFAULT_OFFICE); + } + } + staffInfoVO.setUsername(staffInfo.getEnglishName()); + staffInfoVO.setId(staffInfo.getId()); + return staffInfoVO; + } + + @Override + public List getAllWorkspaceUsers(int workspaceId) { + return dssWorkspaceUserMapper.getAllWorkspaceUsers(workspaceId); + } + + @Override + public List getUserWorkspaceIds(String userName){ + List tempWorkspaceIds = dssWorkspaceUserMapper.getWorkspaceIds(userName); + return tempWorkspaceIds; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DefaultStaffInfoGetter.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DefaultStaffInfoGetter.java new file mode 100644 index 0000000000..24e6d6b02a --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/service/impl/DefaultStaffInfoGetter.java @@ -0,0 +1,40 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.service.impl; + +import com.google.common.collect.Lists; +import com.webank.wedatasphere.dss.framework.workspace.bean.StaffInfo; +import com.webank.wedatasphere.dss.framework.workspace.service.StaffInfoGetter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.stereotype.Component; + +import java.util.List; + + + +public class DefaultStaffInfoGetter implements StaffInfoGetter { + + @Override + public List getAllUsers() { + return Lists.newArrayList(new StaffInfo("1","hadoop", "WeDataSphere")); + } + + @Override + public String getFullOrgNameByUsername(String username) { + return "WeDataSphere"; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/ApplicationUtils.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/ApplicationUtils.java new file mode 100644 index 0000000000..2ab47b5495 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/ApplicationUtils.java @@ -0,0 +1,50 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.util; + +import com.webank.wedatasphere.dss.common.exception.DSSErrorException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + + +public class ApplicationUtils { + + private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationUtils.class); + + private static final String REDIRECT_FORMAT = "%s?redirect=%s&dssurl=${dssurl}&cookies=${cookies}"; + + private static String URLEndoder(String str){ + try { + return URLEncoder.encode(str,"utf-8"); + } catch (UnsupportedEncodingException e) { + LOGGER.warn("endoe failed:",e); + return str; + } + } + + public static String redirectUrlFormat(String redirectUrl, String url){ + return String.format(REDIRECT_FORMAT,redirectUrl,URLEndoder(url)); + } + + public static void main(String[] args) throws DSSErrorException { + System.out.println(redirectUrlFormat("http://127.0..0.1:8090/qualitis/api/v1/redirect","http://127.0..0.1:8090/#/projects/list?id={projectId}&flow=true")); + } + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/CommonRoleEnum.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/CommonRoleEnum.java new file mode 100644 index 0000000000..d2d9e370a4 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/CommonRoleEnum.java @@ -0,0 +1,64 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.util; + + +public enum CommonRoleEnum { + /** + * 通用角色的枚举 + */ + ADMIN(1, "admin", "管理员"), + MAINTENANCE(2, "maintaince","运维人员"), + DEVELOPER(3, "developer", "开发人员"), + ANALYSER(4, "analyser", "分析用户"), + OPERATOR(5, "operator", "运营用户"), + BOSS(6, "boss", "领导"); + + private int id; + private String name; + private String frontName; + + private CommonRoleEnum(int id, String name, String frontName){ + this.id = id; + this.name = name; + this.frontName = frontName; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getFrontName() { + return frontName; + } + + public void setFrontName(String frontName) { + this.frontName = frontName; + } +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/DSSDictionaryConstant.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/DSSDictionaryConstant.java new file mode 100644 index 0000000000..ccac16879c --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/DSSDictionaryConstant.java @@ -0,0 +1,22 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.util; + + +public class DSSDictionaryConstant { + public static final String W_WORKSPACE_DEPARTMENT = "w_workspace_department"; +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/DSSWorkspaceConstant.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/DSSWorkspaceConstant.java new file mode 100644 index 0000000000..6d8537e5b1 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/DSSWorkspaceConstant.java @@ -0,0 +1,32 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.util; + +import com.webank.wedatasphere.linkis.common.conf.CommonVars; + + +public interface DSSWorkspaceConstant { + public static final String WORKSPACE_ID_STR = "workspaceId"; + + public static final CommonVars DEFAULT_WORKSPACE_NAME + = CommonVars.apply("wds.dss.workspace.default.name", "bdapWorkspace"); + + public static final String COMMON_URL_PREFIX = "/workspaceHome/common/"; + + CommonVars DEFAULT_DEMO_WORKSPACE_NAME = CommonVars.apply("wds.dss.default.demo.workspace", "WDS_DSS_DEMO"); + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/RestfulUtils.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/RestfulUtils.java new file mode 100644 index 0000000000..e019a774c2 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/RestfulUtils.java @@ -0,0 +1,49 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.util; + +import com.webank.wedatasphere.linkis.server.Message; +import org.apache.commons.math3.util.Pair; + + +import javax.ws.rs.core.Response; +import java.util.Arrays; + + +public class RestfulUtils { + + public static Response dealError(String reason){ + Message message = Message.error(reason); + return Message.messageToResponse(message); + } + + public static Response dealOk(String msg){ + Message message = Message.ok(msg); + return Message.messageToResponse(message); + } + + + + @SafeVarargs + public static Response dealOk(String msg, Pair... data){ + Message message = Message.ok(msg); + Arrays.stream(data).forEach(p -> message.data(p.getKey(), p.getValue())); + return Message.messageToResponse(message); + } + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/RestulHelper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/RestulHelper.java new file mode 100644 index 0000000000..9cd51e7fb3 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/RestulHelper.java @@ -0,0 +1,45 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.util; + + +import com.webank.wedatasphere.dss.framework.workspace.exception.DSSWorkspaceLoginFailException; +import com.webank.wedatasphere.linkis.common.exception.ErrorException; +import com.webank.wedatasphere.linkis.server.security.SecurityFilter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; + + +@Component +public class RestulHelper { + + @Autowired + private WorkspaceDBHelper workspaceDBHelper; + + public String getLoginUser(HttpServletRequest request)throws ErrorException { + try{ + return SecurityFilter.getLoginUsername(request); + }catch(Exception e){ + throw new DSSWorkspaceLoginFailException(80013, "You are not logged in"); + } + } + + + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/WorkspaceDBHelper.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/WorkspaceDBHelper.java new file mode 100644 index 0000000000..f988d47ee3 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/WorkspaceDBHelper.java @@ -0,0 +1,337 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.util; + + +import com.webank.wedatasphere.dss.framework.workspace.bean.*; +import com.webank.wedatasphere.dss.framework.workspace.bean.vo.DSSWorkspaceRoleVO; +import com.webank.wedatasphere.dss.framework.workspace.constant.ApplicationConf; +import com.webank.wedatasphere.dss.framework.workspace.dao.DSSWorkspaceRoleMapper; +import com.webank.wedatasphere.linkis.common.utils.Utils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + + +@Component +public class WorkspaceDBHelper { + + private static final Logger LOGGER = LoggerFactory.getLogger(WorkspaceDBHelper.class); + + @Autowired + private DSSWorkspaceRoleMapper dssWorkspaceRoleMapper; + + + + private List dssRoles; + + private final Object lock = new Object(); + + private List dssMenus; + + private List dssWorkspaceMenuComponentUrls; + + private List dssWorkspaceComponents; + + private List dssApplicationBeans; + + private Map dssHomepageNameMap = new HashMap<>(); + + + @PostConstruct + public void init(){ + Utils.defaultScheduler().scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + synchronized (lock){ + dssRoles = dssWorkspaceRoleMapper.getRoles(); + } + } + },0, 1, TimeUnit.MINUTES); + + Utils.defaultScheduler().scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + synchronized (lock){ + dssMenus = dssWorkspaceRoleMapper.getMenus(); + } + } + },0, 1, TimeUnit.MINUTES); + + Utils.defaultScheduler().scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + synchronized (lock){ + dssWorkspaceMenuComponentUrls = dssWorkspaceRoleMapper.getMenuComponentUrl(); + } + } + },0, 1, TimeUnit.MINUTES); + + Utils.defaultScheduler().scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + synchronized (lock){ + dssWorkspaceComponents = dssWorkspaceRoleMapper.getComponents(); + } + } + },0 ,1, TimeUnit.MINUTES); + + Utils.defaultScheduler().scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + synchronized (lock){ + dssApplicationBeans = dssWorkspaceRoleMapper.getDSSApplications(); + } + } + }, 0, 1, TimeUnit.MINUTES); + + + Utils.defaultScheduler().scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + synchronized (lock){ + String defaultUrl = "/workspace"; + String maintenanceUrl = "/workspaceHome/scheduleCenter"; + String developerUrl = + dssApplicationBeans.stream(). + filter(dssApplicationBean -> "workflow".equals(dssApplicationBean.getName().toLowerCase())). + findFirst().map(DSSApplicationBean::getHomepageUrl).orElse(defaultUrl); + String analyserUrl = dssApplicationBeans.stream(). + filter(dssApplicationBean -> "linkis".equals(dssApplicationBean.getName().toLowerCase())). + findFirst().map(DSSApplicationBean::getHomepageUrl).orElse(defaultUrl); + dssHomepageNameMap.put("/workspace", "工作空间首页"); + dssHomepageNameMap.put(developerUrl, "工作流开发"); + dssHomepageNameMap.put(analyserUrl, "意书(Scriptis)"); + dssHomepageNameMap.put(maintenanceUrl, "调度中心首页"); + } + } + }, 1, 1, TimeUnit.MINUTES); + } + + public void retrieveFromDB(){ + synchronized (lock){ + dssApplicationBeans = dssWorkspaceRoleMapper.getDSSApplications(); + dssWorkspaceComponents = dssWorkspaceRoleMapper.getComponents(); + dssWorkspaceMenuComponentUrls = dssWorkspaceRoleMapper.getMenuComponentUrl(); + dssMenus = dssWorkspaceRoleMapper.getMenus(); + dssRoles = dssWorkspaceRoleMapper.getRoles(); + } + } + + + + public List generateDefaultWorkspaceMenuRole(int workspaceId, String username){ + List list = new ArrayList<>(); + Date date = new Date(System.currentTimeMillis()); + + list.add(new DSSWorkspaceMenuRole(workspaceId, 2,1,1, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 3,1,1, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 28,1,1, date, username)); + + list.add(new DSSWorkspaceMenuRole(workspaceId, 2,2,0, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 3,2,0, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 28,2,0, date, username)); + + list.add(new DSSWorkspaceMenuRole(workspaceId, 2,3,1, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 3,3,0, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 28,3,0, date, username)); + + list.add(new DSSWorkspaceMenuRole(workspaceId, 2,4,0, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 3,4,1, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 28,4,0, date, username)); + + list.add(new DSSWorkspaceMenuRole(workspaceId, 2,5,0, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 3,5,0, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 28,5,0, date, username)); + + list.add(new DSSWorkspaceMenuRole(workspaceId, 2,6,1, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 3,6,1, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 28,6,0, date, username)); + + if(StringUtils.isNotBlank(ApplicationConf.ESB_APPID)){ + list.add(new DSSWorkspaceMenuRole(workspaceId, 1,1,1, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 1,2,1, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 1,3,0, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 1,4,0, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 1,5,0, date, username)); + list.add(new DSSWorkspaceMenuRole(workspaceId, 1,6,1, date, username)); + } + return list; + } + + + public List generateDefaultWorkspaceHomepage(int workspaceId, String username){ + String defaultUrl = "/workspace"; + String maintenanceUrl = "/workspaceHome/scheduleCenter"; + String developerUrl = + dssApplicationBeans.stream(). + filter(dssApplicationBean -> "workflow".equals(dssApplicationBean.getName().toLowerCase())). + findFirst().map(DSSApplicationBean::getHomepageUrl).orElse(defaultUrl); + String analyserUrl = dssApplicationBeans.stream(). + filter(dssApplicationBean -> "linkis".equals(dssApplicationBean.getName().toLowerCase())). + findFirst().map(DSSApplicationBean::getHomepageUrl).orElse(defaultUrl); + List dssWorkspaceHomepages = new ArrayList<>(); + Date date = new Date(System.currentTimeMillis()); + dssWorkspaceHomepages.add(new DSSWorkspaceHomepage(workspaceId, 1, defaultUrl, date)); + dssWorkspaceHomepages.add(new DSSWorkspaceHomepage(workspaceId, 2, analyserUrl, date)); + dssWorkspaceHomepages.add(new DSSWorkspaceHomepage(workspaceId, 3, analyserUrl, date)); + dssWorkspaceHomepages.add(new DSSWorkspaceHomepage(workspaceId, 4, analyserUrl, date)); + dssWorkspaceHomepages.add(new DSSWorkspaceHomepage(workspaceId, 5, defaultUrl, date)); + dssWorkspaceHomepages.add(new DSSWorkspaceHomepage(workspaceId, 6, defaultUrl, date)); + return dssWorkspaceHomepages; + } + + + public List generateDefaultWorkspaceComponentPrivs(int workspaceId, + String username){ + List dssWorkspaceComponentPrivs = new ArrayList<>(); + Date updateTime = new Date(System.currentTimeMillis()); + //admin + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 1, 1, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 1, 2, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 1, 4, 1, updateTime, username)); + //运维 + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 2, 1, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 2, 2, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 2, 4, 1, updateTime, username)); + //开发人员 + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 3, 1, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 3, 2, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 3, 4, 1, updateTime, username)); + //分析人员 + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 4, 1, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 4, 2, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 4, 4, 1, updateTime, username)); + //运营人员 + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 5, 1, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 5, 2, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 5, 4, 1, updateTime, username)); + //领导 + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 6, 1, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 6, 2, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 6, 4, 1, updateTime, username)); + if(StringUtils.isNotBlank(ApplicationConf.ESB_APPID)){ + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 1, 3, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 2, 3, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 3, 3, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 4, 3, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 5, 3, 1, updateTime, username)); + dssWorkspaceComponentPrivs.add(new DSSWorkspaceComponentPriv(workspaceId, 6, 3, 1, updateTime, username)); + } + return dssWorkspaceComponentPrivs; + } + + public List getRoles(){ + return this.dssRoles; + } + + public List getRoles(int workspaceId){ + return this.dssRoles.stream(). + filter(dssRole -> dssRole.getWorkspaceId() == workspaceId || dssRole.getWorkspaceId() == -1). + collect(Collectors.toList()); + } + + + + public List getComponentUrlsById(int componentId){ + Optional optional = dssWorkspaceMenuComponentUrls. + stream().filter(obj -> obj.getMenuId() == componentId). + findFirst(); + if (optional.isPresent()){ + int applicationId = optional.get().getDssApplicationId(); + String homepageUrl = dssWorkspaceRoleMapper.getEntryUrl(applicationId); + return Collections.singletonList(homepageUrl); + }else{ + return null; + } + } + + + + public String getRoleFrontName(int roleId) { + DSSRole role = dssRoles.stream().filter(dssRole -> dssRole.getId() == roleId).findFirst().orElse(null); + if (role != null){ + return role.getFrontName(); + }else{ + return null; + } + } + + public int getRoleIdByName(String roleName){ + if (StringUtils.isBlank(roleName)){ + return -1; + } + return dssRoles.stream(). + filter(dssRole -> roleName.equals(dssRole.getName())). + findFirst(). + map(DSSRole::getId). + orElse(-1); + } + + + public List getRoleVOs(int workspaceId) { + return getRoles(workspaceId).stream().map(this::changeToRoleVO).collect(Collectors.toList()); + } + + private DSSWorkspaceRoleVO changeToRoleVO(DSSRole dssRole){ + DSSWorkspaceRoleVO vo = new DSSWorkspaceRoleVO(); + vo.setRoleFrontName(dssRole.getFrontName()); + vo.setRoleId(dssRole.getId()); + vo.setRoleName(dssRole.getName()); + return vo; + } + + public DSSMenu getMenuNameById(int menuId){ + if(dssMenus.stream().anyMatch(dssMenu -> dssMenu.getId() == menuId)){ + return dssMenus.stream().filter(dssMenu -> dssMenu.getId() == menuId).findFirst().get(); + }else{ + return null; + } + } + + + public String getRoleNameById(int roleId) { + return dssRoles.stream().filter(dssRole -> dssRole.getId() == roleId).findFirst().orElse(new DSSRole()).getName(); + } + + public DSSApplicationBean getComponent(int componentId) { + return dssApplicationBeans.stream(). + filter(dssApplicationBean -> dssApplicationBean.getId() == componentId). + findFirst(). + orElse(null); + } + + public String getHomepageName(String homepage){ + return this.dssHomepageNameMap.get(homepage); + } + + public List getAllMenuIds() { + return dssMenus.stream().filter(dssMenu -> dssMenu.getLevel() == 1).map(DSSMenu::getId).collect(Collectors.toList()); + } + + public List getAllComponentIds() { + return dssWorkspaceComponents.stream().map(DSSWorkspaceComponent::getId).collect(Collectors.toList()); + } + +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/WorkspaceServerConstant.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/WorkspaceServerConstant.java new file mode 100644 index 0000000000..ab75cda431 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/WorkspaceServerConstant.java @@ -0,0 +1,24 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.util; + + +public interface WorkspaceServerConstant { + String DEFAULT_DEPARTMENT = "基础科技部"; + String DEFAULT_OFFICE = "大数据平台室"; + String DEFAULT_STAFF_SPLIT = "-"; +} diff --git a/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/WorkspaceSpringConfig.java b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/WorkspaceSpringConfig.java new file mode 100644 index 0000000000..43ac0fbb13 --- /dev/null +++ b/dss-framework/dss-framework-workspace-server/src/main/java/com/webank/wedatasphere/dss/framework/workspace/util/WorkspaceSpringConfig.java @@ -0,0 +1,36 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.framework.workspace.util; + +import com.webank.wedatasphere.dss.framework.workspace.service.StaffInfoGetter; +import com.webank.wedatasphere.dss.framework.workspace.service.impl.DefaultStaffInfoGetter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + + +@Configuration +public class WorkspaceSpringConfig { + + @Bean + @ConditionalOnMissingBean + public StaffInfoGetter getStaffInfoGetter(){ + return new DefaultStaffInfoGetter(); + } + +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/pom.xml b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/pom.xml new file mode 100644 index 0000000000..d39a584796 --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/pom.xml @@ -0,0 +1,114 @@ + + + + + + dss + com.webank.wedatasphere.dss + 1.0.0 + + 4.0.0 + + dss-framework-orchestrator-publish + + + + com.webank.wedatasphere.dss + dss-orchestrator-core + ${dss.version} + compile + + + linkis-common + com.webank.wedatasphere.linkis + + + + + + com.webank.wedatasphere.dss + dss-orchestrator-db + ${dss.version} + compile + + + + com.webank.wedatasphere.dss + dss-orchestrator-loader + ${dss.version} + compile + + + org.springframework + spring-tx + ${spring.version} + provided + + + com.webank.wedatasphere.dss + dss-common + ${dss.version} + provided + + + com.webank.wedatasphere.dss + dss-sender-service + ${dss.version} + provided + + + com.webank.wedatasphere.linkis + linkis-rpc + ${linkis.version} + provided + + + org.springframework + spring-context + ${spring.version} + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + UTF-8 + + + + org.apache.maven.plugins + maven-deploy-plugin + + + + org.apache.maven.plugins + maven-jar-plugin + + + + + + \ No newline at end of file diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/ConversionDSSOrchestratorPlugin.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/ConversionDSSOrchestratorPlugin.java new file mode 100644 index 0000000000..7db889a256 --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/ConversionDSSOrchestratorPlugin.java @@ -0,0 +1,35 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish; + +import com.webank.wedatasphere.dss.common.entity.project.DSSProject; +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.orchestrator.common.protocol.ResponseOperateOrchestrator; +import com.webank.wedatasphere.dss.orchestrator.core.plugin.DSSOrchestratorPlugin; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import java.util.List; + + +public interface ConversionDSSOrchestratorPlugin extends DSSOrchestratorPlugin { + + ResponseOperateOrchestrator convert(String userName, + DSSProject project, + Workspace workspace, + List orcAppIdList, + List dssLabels); + +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/ExportDSSOrchestratorPlugin.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/ExportDSSOrchestratorPlugin.java new file mode 100644 index 0000000000..74de660e0e --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/ExportDSSOrchestratorPlugin.java @@ -0,0 +1,47 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish; + +import com.webank.wedatasphere.dss.common.exception.DSSErrorException; +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo; +import com.webank.wedatasphere.dss.orchestrator.core.plugin.DSSOrchestratorPlugin; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import java.util.List; +import java.util.Map; + + +public interface ExportDSSOrchestratorPlugin extends DSSOrchestratorPlugin { + + + Map exportOrchestrator(String userName, + String workspaceName, + Long orchestratorId, + Long orcVersionId, + String projectName, + List dssLabels, + boolean addOrcVersion, Workspace workspace) throws DSSErrorException; + + Long orchestratorVersionIncrease(Long orcId, + String userName, + String comment, + String workspaceName, + DSSOrchestratorInfo dssOrchestratorInfo, + String projectName, + List dssLabels) throws DSSErrorException; + +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/ImportDSSOrchestratorPlugin.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/ImportDSSOrchestratorPlugin.java new file mode 100644 index 0000000000..64ccffc870 --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/ImportDSSOrchestratorPlugin.java @@ -0,0 +1,54 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish; + +import com.webank.wedatasphere.dss.common.exception.DSSErrorException; +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.orchestrator.core.plugin.DSSOrchestratorPlugin; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.dss.standard.common.exception.operation.ExternalOperationFailedException; +import java.io.IOException; +import java.util.List; + + +public interface ImportDSSOrchestratorPlugin extends DSSOrchestratorPlugin { + + /** + * 导入Orchestrator + * @param userName 用户名 + * @param workspaceName 工作空间名 + * @param projectName 工程名 + * @param projectId 工程id + * @param resourceId bml resourceId + * @param version bml version + * @param dssLabels dss标签 + * @param workspace + * @return + * @throws DSSErrorException + * @throws IOException + * @throws ExternalOperationFailedException + */ + Long importOrchestrator(String userName, + String workspaceName, + String projectName, + Long projectId, + String resourceId, + String version, + List dssLabels, + Workspace workspace) throws Exception; + +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/conf/DSSOrchestratorConf.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/conf/DSSOrchestratorConf.java new file mode 100644 index 0000000000..99544e26ab --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/conf/DSSOrchestratorConf.java @@ -0,0 +1,24 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish.conf; + +import com.webank.wedatasphere.linkis.common.conf.CommonVars; + + +public class DSSOrchestratorConf { + public static final CommonVars DSS_EXPORT_ENV = CommonVars.apply("wds.dss.server.export.env", "dev"); +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/impl/ConversionDSSOrchestratorPluginImpl.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/impl/ConversionDSSOrchestratorPluginImpl.java new file mode 100644 index 0000000000..feaec126f2 --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/impl/ConversionDSSOrchestratorPluginImpl.java @@ -0,0 +1,50 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish.impl; + +import com.webank.wedatasphere.dss.common.entity.project.DSSProject; +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.orchestrator.common.protocol.RequestConvertOrchestrations; +import com.webank.wedatasphere.dss.orchestrator.common.protocol.ResponseOperateOrchestrator; +import com.webank.wedatasphere.dss.orchestrator.core.plugin.AbstractDSSOrchestratorPlugin; +import com.webank.wedatasphere.dss.orchestrator.publish.ConversionDSSOrchestratorPlugin; +import com.webank.wedatasphere.dss.sender.service.DSSSenderServiceFactory; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.linkis.rpc.Sender; +import java.util.List; + + +public class ConversionDSSOrchestratorPluginImpl extends AbstractDSSOrchestratorPlugin implements ConversionDSSOrchestratorPlugin { + + @Override + public ResponseOperateOrchestrator convert(String userName, + DSSProject project, + Workspace workspace, + List orcAppIdList, + List dssLabels) { + //1、导出第三方应用信息,如工作流、Visualis、Qualities + RequestConvertOrchestrations requestConvertOrchestrator = new RequestConvertOrchestrations(); + requestConvertOrchestrator.setOrcAppIds(orcAppIdList); + requestConvertOrchestrator.setProject(project); + requestConvertOrchestrator.setWorkspace(workspace); + requestConvertOrchestrator.setDSSLabels(dssLabels); + requestConvertOrchestrator.setUserName(userName); + Sender sender = DSSSenderServiceFactory.getOrCreateServiceInstance().getWorkflowSender(dssLabels); + ResponseOperateOrchestrator response = (ResponseOperateOrchestrator) sender.ask(requestConvertOrchestrator); + return response; + } +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/impl/ExportDSSOrchestratorPluginImpl.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/impl/ExportDSSOrchestratorPluginImpl.java new file mode 100644 index 0000000000..43b963594d --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/impl/ExportDSSOrchestratorPluginImpl.java @@ -0,0 +1,221 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish.impl; + +import static com.webank.wedatasphere.dss.common.utils.ZipHelper.zipExportProject; + +import com.webank.wedatasphere.dss.common.entity.IOType; +import com.webank.wedatasphere.dss.common.exception.DSSErrorException; +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.common.utils.DSSExceptionUtils; +import com.webank.wedatasphere.dss.common.utils.IoUtils; +import com.webank.wedatasphere.dss.contextservice.service.ContextService; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorVersion; +import com.webank.wedatasphere.dss.orchestrator.core.exception.DSSOrchestratorErrorException; +import com.webank.wedatasphere.dss.orchestrator.core.plugin.AbstractDSSOrchestratorPlugin; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorCopyRequestRef; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorCopyResponseRef; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorExportRequestRef; +import com.webank.wedatasphere.dss.orchestrator.core.service.BMLService; +import com.webank.wedatasphere.dss.orchestrator.core.utils.OrchestratorUtils; +import com.webank.wedatasphere.dss.orchestrator.db.dao.OrchestratorMapper; +import com.webank.wedatasphere.dss.orchestrator.loader.utils.OrchestratorLoaderUtils; +import com.webank.wedatasphere.dss.orchestrator.publish.ExportDSSOrchestratorPlugin; +import com.webank.wedatasphere.dss.orchestrator.publish.io.export.MetaExportService; +import com.webank.wedatasphere.dss.standard.app.development.service.RefCRUDService; +import com.webank.wedatasphere.dss.standard.app.development.service.RefExportService; +import com.webank.wedatasphere.dss.standard.app.development.standard.DevelopmentIntegrationStandard; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.dss.standard.common.desc.AppInstance; +import com.webank.wedatasphere.dss.standard.common.entity.ref.AbstractResponseRef; +import com.webank.wedatasphere.dss.standard.common.entity.ref.AppConnRefFactoryUtils; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Field; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Date; +import java.util.List; +import java.util.Map; +import javafx.util.Pair; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + + +@Component +public class ExportDSSOrchestratorPluginImpl extends AbstractDSSOrchestratorPlugin implements ExportDSSOrchestratorPlugin { + + static final String DEFAULT_ORC_NAME = "default_orc"; + + @Autowired + private BMLService bmlService; + @Autowired + private OrchestratorMapper orchestratorMapper; + @Autowired + private MetaExportService metaExportService; + @Autowired + private ContextService contextService; + + @Override + @Transactional(rollbackFor = Exception.class) + public Map exportOrchestrator(String userName, String workspaceName, Long orchestratorId, Long orcVersionId, String projectName, + List dssLabels, boolean addOrcVersion, Workspace workspace) throws DSSErrorException { + //1、导出info信息 + if (orcVersionId == null || orcVersionId < 0){ + LOGGER.info("orchestratorVersionId is {}", orcVersionId); + //最简单的就是通过orcId来找到最新的versionId + orcVersionId = orchestratorMapper.findLatestOrcVersionId(orchestratorId); + } + DSSOrchestratorVersion dssOrchestratorVersion = orchestratorMapper.getOrchestratorVersion(orcVersionId); + DSSOrchestratorInfo dssOrchestratorInfo = orchestratorMapper.getOrchestrator(dssOrchestratorVersion.getOrchestratorId()); + if (dssOrchestratorInfo != null) { + String orcExportSaveBasePath = IoUtils.generateIOPath(userName, DEFAULT_ORC_NAME, ""); + try { + Files.createDirectories(Paths.get(orcExportSaveBasePath).toAbsolutePath().normalize()); + //标记当前导出为project导出 + IoUtils.generateIOType(IOType.ORCHESTRATOR, orcExportSaveBasePath); + //标记当前导出环境env + IoUtils.generateIOEnv(orcExportSaveBasePath); + metaExportService.export(dssOrchestratorInfo, orcExportSaveBasePath); + } catch (IOException e) { + LOGGER.error("Failed to export metaInfo in orchestrator server for orc({}) in version {}.", orchestratorId, orcVersionId, e); + DSSExceptionUtils.dealErrorException(60099, "Failed to export metaInfo in orchestrator server.", e, DSSOrchestratorErrorException.class); + } + LOGGER.info("{} 开始导出Orchestrator: {} 版本ID为: {} ", userName, dssOrchestratorInfo.getName(), orcVersionId); + + //2、导出第三方应用信息,如工作流、Visualis、Qualities + Pair standardPair = OrchestratorLoaderUtils + .getOrcDevelopStandard(userName, workspaceName, dssOrchestratorInfo, dssLabels); + if (null != standardPair) { + RefExportService refExportService = standardPair.getValue().getRefExportService(standardPair.getKey()); + + if (refExportService == null) { + LOGGER.error("for {} to export orchestrator {} refExportService is null", userName, dssOrchestratorInfo.getName()); + DSSExceptionUtils.dealErrorException(60089, "refExportService is null", DSSErrorException.class); + } + OrchestratorExportRequestRef orchestratorExportRequestRef = + AppConnRefFactoryUtils.newAppConnRef(OrchestratorExportRequestRef.class, + refExportService.getClass().getClassLoader(), dssOrchestratorInfo.getType()); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("orchestrator Export Request Ref class is {}", orchestratorExportRequestRef.getClass()); + } + orchestratorExportRequestRef.setAppId(dssOrchestratorVersion.getAppId()); + orchestratorExportRequestRef.setProjectId(dssOrchestratorVersion.getProjectId()); + orchestratorExportRequestRef.setProjectName(projectName); + orchestratorExportRequestRef.setUserName(userName); + orchestratorExportRequestRef.setWorkspace(workspace); + AbstractResponseRef responseRef = (AbstractResponseRef) refExportService.getRefExportOperation(). + exportRef(orchestratorExportRequestRef); + String resourceId = responseRef.getValue("resourceId").toString(); + String version = responseRef.getValue("version").toString(); + bmlService.downloadToLocalPath(userName, resourceId, version, orcExportSaveBasePath + "orc_flow.zip"); + } + + //打包导出工程 + String exportPath = zipExportProject(orcExportSaveBasePath); + + //3、打包新的zip包上传BML + InputStream inputStream = bmlService.readLocalResourceFile(userName, exportPath); + Map resultMap = bmlService.upload(userName, inputStream, + dssOrchestratorInfo.getName() + ".OrcExport", projectName); + + //4、判断导出后是否改变Orc的版本 + if (addOrcVersion) { + Long orcIncreaseVersionId = orchestratorVersionIncrease(dssOrchestratorInfo.getId(), + userName, dssOrchestratorInfo.getComment(), + workspaceName, dssOrchestratorInfo, projectName, dssLabels); + resultMap.put("orcVersionId", orcIncreaseVersionId); + } else { + resultMap.put("orcVersionId", orcVersionId); + } + return resultMap; + //4、返回BML存储信息 + } else { + throw new DSSErrorException(90038, "该Orchestrator的版本号不存在,请检查版本号是否正确"); + } + } + + @Override + public Long orchestratorVersionIncrease(Long orcId, + String userName, + String comment, + String workspaceName, + DSSOrchestratorInfo dssOrchestratorInfo, + String projectName, + List dssLabels) throws DSSErrorException { + //对于导出来说,json需替换 subflowID + DSSOrchestratorVersion dssOrchestratorVersion = orchestratorMapper.getLatestOrchestratorVersionById(orcId); + + // TODO: 2020/3/25 set updator(userID 修改为userName后) + dssOrchestratorVersion.setUpdateTime(new Date()); + Long oldOrcVersionId = dssOrchestratorVersion.getId(); + String oldOrcVersion = dssOrchestratorVersion.getVersion(); + dssOrchestratorVersion.setId(null); + // 如果是project发布 ,version都是01,如果是工作流发布,version + 1 + dssOrchestratorVersion.setVersion(OrchestratorUtils.increaseVersion(oldOrcVersion)); + + //发布的comment应该更新到上个版本,而当前最新版本的comment应该修改为release from.. + dssOrchestratorVersion.setComment(String.format("release from version %s", oldOrcVersion)); + //更新老版本的comment + DSSOrchestratorVersion updateCommentVersion = new DSSOrchestratorVersion(); + updateCommentVersion.setId(oldOrcVersionId); + String realComment = comment != null ? comment : "release comment"; + updateCommentVersion.setComment(realComment); + orchestratorMapper.updateOrchestratorVersion(updateCommentVersion); + + //要求AppConn对应第三方应用拷贝一个新的app出来关联,如工作流,需要新建一个新的工作流进行关联。 + + Pair standardPair = OrchestratorLoaderUtils.getOrcDevelopStandard(userName, workspaceName, dssOrchestratorInfo, dssLabels); + if(standardPair == null){ + LOGGER.error("dev Process Service is null"); + throw new DSSOrchestratorErrorException(61105, "dev Process Service is null"); + } + RefCRUDService refcrudservice =standardPair.getValue().getRefCRUDService (standardPair.getKey()); + if (null != refcrudservice) { + try { + OrchestratorCopyRequestRef orchestratorCopyRequestRef = + AppConnRefFactoryUtils.newAppConnRef(OrchestratorCopyRequestRef.class, + refcrudservice.getClass().getClassLoader(), dssOrchestratorInfo.getAppConnName()); + orchestratorCopyRequestRef.setCopyOrcAppId(dssOrchestratorVersion.getAppId()); + orchestratorCopyRequestRef.setCopyOrcVersionId(dssOrchestratorVersion.getOrchestratorId()); + orchestratorCopyRequestRef.setUserName(userName); + orchestratorCopyRequestRef.setProjectName(projectName); + + //5、生成上下文ContextId + String contextId = contextService.createContextID(workspaceName, projectName, dssOrchestratorInfo.getName(), dssOrchestratorVersion.getVersion(), userName); + dssOrchestratorVersion.setContextId(contextId); + LOGGER.info("Create a new ContextId for increase: {} ", contextId); + orchestratorCopyRequestRef.setContextID(contextId); + OrchestratorCopyResponseRef orchestratorCopyResponseRef = + (OrchestratorCopyResponseRef) refcrudservice.getRefCopyOperation().copyRef(orchestratorCopyRequestRef); + dssOrchestratorVersion.setAppId(orchestratorCopyResponseRef.getCopyTargetAppId()); + dssOrchestratorVersion.setContent(orchestratorCopyResponseRef.getCopyTargetContent()); + //update appconn node contextId + dssOrchestratorVersion.setFormatContextId(contextId); + orchestratorMapper.addOrchestratorVersion(dssOrchestratorVersion); + } catch (final Exception t) { + LOGGER.error("Failed to copy new orcVersion in orchestrator server for orc({}).", orcId, t); + DSSExceptionUtils.dealErrorException(60099, "Failed to copy app in orchestrator server", t, DSSOrchestratorErrorException.class); + } + return dssOrchestratorVersion.getId(); + } else { + throw new DSSOrchestratorErrorException(10023, "获取第三方应用的Ref为空,不能完成拷贝操作!"); + } + } +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/impl/ImportDSSOrchestratorPluginImpl.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/impl/ImportDSSOrchestratorPluginImpl.java new file mode 100644 index 0000000000..0064c9471a --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/impl/ImportDSSOrchestratorPluginImpl.java @@ -0,0 +1,194 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish.impl; + +import static com.webank.wedatasphere.dss.orchestrator.publish.impl.ExportDSSOrchestratorPluginImpl.DEFAULT_ORC_NAME; + +import com.webank.wedatasphere.dss.appconn.core.AppConn; +import com.webank.wedatasphere.dss.common.entity.IOEnv; +import com.webank.wedatasphere.dss.common.exception.DSSErrorException; +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.common.utils.DSSExceptionUtils; +import com.webank.wedatasphere.dss.common.utils.IoUtils; +import com.webank.wedatasphere.dss.common.utils.ZipHelper; +import com.webank.wedatasphere.dss.contextservice.service.ContextService; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorVersion; +import com.webank.wedatasphere.dss.orchestrator.common.protocol.RequestProjectImportOrchestrator; +import com.webank.wedatasphere.dss.orchestrator.core.DSSOrchestrator; +import com.webank.wedatasphere.dss.orchestrator.core.plugin.AbstractDSSOrchestratorPlugin; +import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorImportRequestRef; +import com.webank.wedatasphere.dss.orchestrator.core.service.BMLService; +import com.webank.wedatasphere.dss.orchestrator.core.utils.OrchestratorUtils; +import com.webank.wedatasphere.dss.orchestrator.db.dao.OrchestratorMapper; +import com.webank.wedatasphere.dss.orchestrator.loader.OrchestratorManager; +import com.webank.wedatasphere.dss.orchestrator.loader.utils.OrchestratorLoaderUtils; +import com.webank.wedatasphere.dss.orchestrator.publish.ImportDSSOrchestratorPlugin; +import com.webank.wedatasphere.dss.orchestrator.publish.io.input.MetaInputService; +import com.webank.wedatasphere.dss.sender.service.DSSSenderServiceFactory; +import com.webank.wedatasphere.dss.standard.app.development.ref.CommonResponseRef; +import com.webank.wedatasphere.dss.standard.app.development.service.RefImportService; +import com.webank.wedatasphere.dss.standard.app.development.standard.DevelopmentIntegrationStandard; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.dss.standard.common.desc.AppInstance; +import com.webank.wedatasphere.dss.standard.common.entity.ref.RefFactory; +import java.io.File; +import java.io.InputStream; +import java.util.Date; +import java.util.List; +import java.util.Map; +import javafx.util.Pair; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + + +@Component +public class ImportDSSOrchestratorPluginImpl extends AbstractDSSOrchestratorPlugin implements ImportDSSOrchestratorPlugin { + + @Autowired + private MetaInputService metaInputService; + @Autowired + private OrchestratorMapper orchestratorMapper; + @Autowired + private BMLService bmlService; + @Autowired + private ContextService contextService; + @Autowired + private OrchestratorManager orchestratorManager; + + @Override + @Transactional(rollbackFor = Exception.class) + public Long importOrchestrator(String userName, String workspaceName, String projectName, Long projectId, String resourceId, String version, + List dssLabels, Workspace workspace) throws Exception { + Long appId = null; + //1、下载BML的Orchestrator的导入包 + String inputZipPath = IoUtils.generateIOPath(userName, projectName, DEFAULT_ORC_NAME + ".zip"); + bmlService.downloadToLocalPath(userName, resourceId, version, inputZipPath); + String inputPath = ZipHelper.unzip(inputZipPath); + + IOEnv ioEnv = IoUtils.readIOEnv(inputPath); + //2、导入Info信息(导入冲突处理) + List dssOrchestratorInfos = metaInputService.importOrchestrator(inputPath); + DSSOrchestratorInfo importDssOrchestratorInfo = dssOrchestratorInfos.get(0); + + //根据工程ID和编排名称查询 + String uuid = orchestratorMapper.getOrcNameByParam(importDssOrchestratorInfo.getProjectId(),importDssOrchestratorInfo.getName()); + //通过UUID查找是否已经导入过 + DSSOrchestratorInfo existFlag = orchestratorMapper.getOrchestratorByUUID(importDssOrchestratorInfo.getUUID()); + //add 和update都需要更新成当前环境id信息,放到新的版本记录中 + //todo 跨环境必须保证工程ID一样,或者需要更新导入包中的所有工程ID为当前最新ID,不一致的话关系到上下文、第三方工程的映射问题 + if (null != existFlag) { + //判断是否存在相同名称的编排名称 + if (StringUtils.isNotBlank(uuid) && !uuid.equals(importDssOrchestratorInfo.getUUID())) { + DSSExceptionUtils + .dealErrorException(61002, "The same orchestration name already exists" ,DSSErrorException.class); + + } + //如果Orchestrator已经导入过,目前只更新版本信息,并更新基础信息name,其它信息不修改。 + orchestratorMapper.updateOrchestrator(importDssOrchestratorInfo); + } else { + //判断是否存在相同名称的编排名称 + if (StringUtils.isNotBlank(uuid)) { + DSSExceptionUtils + .dealErrorException(61002, "The same orchestration name already exists" ,DSSErrorException.class); + } + orchestratorMapper.addOrchestrator(importDssOrchestratorInfo); + } + String flowZipPath = inputPath + File.separator + "orc_flow.zip"; + //3、上传工作流zip包到bml + InputStream inputStream = bmlService.readLocalResourceFile(userName, flowZipPath); + Map resultMap = bmlService.upload(userName, inputStream, importDssOrchestratorInfo.getName() + "_orc_flow.zip", projectName); + String orcResourceId = resultMap.get("resourceId").toString(); + String orcBmlVersion = resultMap.get("version").toString(); + + + //4、导入版本Version信息 + DSSOrchestratorVersion dssOrchestratorVersion = new DSSOrchestratorVersion(); + dssOrchestratorVersion.setAppId(null); + dssOrchestratorVersion.setComment("orchestrator import"); + dssOrchestratorVersion.setOrchestratorId(importDssOrchestratorInfo.getId()); + dssOrchestratorVersion.setContent(""); + dssOrchestratorVersion.setProjectId(projectId); + dssOrchestratorVersion.setSource("Orchestrator create"); + dssOrchestratorVersion.setUpdater(userName); + + String oldVersion = orchestratorMapper.getLatestVersion(importDssOrchestratorInfo.getId()); + if (StringUtils.isNotEmpty(oldVersion)){ + dssOrchestratorVersion.setVersion(OrchestratorUtils.increaseVersion(oldVersion)); + }else{ + dssOrchestratorVersion.setVersion(OrchestratorUtils.generateNewVersion()); + } + + //5、生成上下文ContextId + String contextId = contextService.createContextID(workspaceName, projectName, importDssOrchestratorInfo.getName(), dssOrchestratorVersion.getVersion(), userName); + dssOrchestratorVersion.setFormatContextId(contextId); + LOGGER.info("Create a new ContextId for import: {} ", contextId); + + dssOrchestratorVersion.setUpdateTime(new Date()); + orchestratorMapper.addOrchestratorVersion(dssOrchestratorVersion); + + //6、导出第三方应用信息,如工作流、Visualis、Qualities + DSSOrchestrator dssOrchestrator = orchestratorManager.getOrCreateOrchestrator(userName, + workspaceName, importDssOrchestratorInfo.getType(), importDssOrchestratorInfo.getAppConnName(), dssLabels); + AppConn orchestratorAppConn = dssOrchestrator.getAppConn(); + Pair standardPair = OrchestratorLoaderUtils + .getOrcDevelopStandard(userName, workspaceName, importDssOrchestratorInfo, dssLabels); + if (null != standardPair) { + RefImportService refImportService = standardPair.getValue().getRefImportService(standardPair.getKey()); + OrchestratorImportRequestRef orchestratorImportRequestRef = null; + try { + orchestratorImportRequestRef = + (OrchestratorImportRequestRef) RefFactory.INSTANCE.newRef(OrchestratorImportRequestRef.class, + orchestratorAppConn.getClass().getClassLoader(), "com.webank.wedatasphere.dss.appconn.workflow.ref"); + } catch (final Exception e) { + DSSExceptionUtils + .dealErrorException(61001, "failed to new ref with class " + OrchestratorImportRequestRef.class.getName(), e, DSSErrorException.class); + } + orchestratorImportRequestRef.setResourceId(orcResourceId); + orchestratorImportRequestRef.setBmlVersion(orcBmlVersion); + orchestratorImportRequestRef.setProjectId(projectId); + orchestratorImportRequestRef.setUserName(userName); + orchestratorImportRequestRef.setWorkspaceName(workspaceName); + orchestratorImportRequestRef.setWorkspace(workspace); + orchestratorImportRequestRef.setProjectName(projectName); + orchestratorImportRequestRef.setContextID(contextId); + //todo getSourceEnv + orchestratorImportRequestRef.setSourceEnv(ioEnv); + orchestratorImportRequestRef.setOrcVersion(dssOrchestratorVersion.getVersion()); + CommonResponseRef responseRef = (CommonResponseRef) refImportService.getRefImportOperation().importRef(orchestratorImportRequestRef); + appId = responseRef.getOrcId(); + String appContent = responseRef.getContent(); + + //更新返回內容 + dssOrchestratorVersion.setAppId(appId); + dssOrchestratorVersion.setContent(appContent); + orchestratorMapper.updateOrchestratorVersion(dssOrchestratorVersion); + + } + + RequestProjectImportOrchestrator projectImportOrchestrator = new RequestProjectImportOrchestrator(); + BeanUtils.copyProperties(importDssOrchestratorInfo,projectImportOrchestrator); + projectImportOrchestrator.setVersionId(dssOrchestratorVersion.getId()); + //保存工程级别的编排模式 + DSSSenderServiceFactory.getOrCreateServiceInstance().getProjectServerSender() + .ask(projectImportOrchestrator); + return dssOrchestratorVersion.getOrchestratorId(); + } +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/export/MetaExportService.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/export/MetaExportService.java new file mode 100644 index 0000000000..c35c817eb4 --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/export/MetaExportService.java @@ -0,0 +1,37 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish.io.export; + + +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo; + +import java.io.IOException; + + +public interface MetaExportService { + + + /** + * + * @param dssOrchestratorInfo + * @param savePath + * @throws IOException + */ + void export(DSSOrchestratorInfo dssOrchestratorInfo, String savePath) throws IOException; + + +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/export/MetaWriter.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/export/MetaWriter.java new file mode 100644 index 0000000000..16b706e580 --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/export/MetaWriter.java @@ -0,0 +1,172 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish.io.export; + +import com.webank.wedatasphere.dss.common.utils.DSSExceptionUtils; +import com.webank.wedatasphere.dss.orchestrator.publish.conf.DSSOrchestratorConf; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class MetaWriter { + + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + private final Class tClass; + private final String tableName; + private List datas = new ArrayList<>(); + private List ignoreFields = new ArrayList<>(); + private List fields = null; + private List comments = new ArrayList<>(); + private List table = new ArrayList<>(); + private String commentPrefix = "#"; + private String seperator = "|"; + + public MetaWriter(Class tClass, String tableName) { + this.tClass = tClass; + this.tableName = tableName; + } + + public static MetaWriter of(String tableName, Class tClass) { + return new MetaWriter<>(tClass, tableName); + } + + public MetaWriter ignore(String... fields) { + ignoreFields.addAll(Arrays.stream(fields).collect(Collectors.toList())); + return this; + } + + public MetaWriter data(List datas) { + this.datas.addAll(datas); + return this; + } + + public MetaWriter data(T data) { + this.datas.add(data); + return this; + } + + public MetaWriter comment(String... comments) { + this.comments.addAll(Arrays.stream(comments).collect(Collectors.toList())); + return this; + } + + /** + * 上传bml + * + * @return + */ + public InputStream write() { + writeComment(); + writeHead(); + writeBody(); + //table 添加换行符进行转流 + String tableStr = table.stream().reduce((a, b) -> a + "\n" + b).orElse("") + "\n"; + logger.info("\n" + tableStr); + return new ByteArrayInputStream(tableStr.getBytes()); + } + + /** + * 写入本地 + * + * @param outputStream + */ + public void write(OutputStream outputStream) throws IOException { + writeComment(); + writeHead(); + writeBody(); + IOUtils.writeLines(table, "\n", outputStream); + } + + private void writeBody() { + datas.forEach(DSSExceptionUtils.handling(this::writeBody)); + } + + private void writeBody(T t) throws NoSuchFieldException, IllegalAccessException { + ArrayList line = new ArrayList<>(); + for (String field : fields) { + Field declaredField = tClass.getDeclaredField(field); + declaredField.setAccessible(true); + Object o = declaredField.get(t); + if (o != null) { + line.add(o.toString()); + } else { + line.add(null); + } + } + table.add(reduce(line)); + } + + private String reduce(List strs) { + return strs.stream().reduce((a, b) -> a + seperator + b).orElse(""); + } + + /** + * 写表的头部 + * 1.过滤ignore的属性 + * 2.驼峰转mysql的 _ (暂时略过) + * 3.写入List table + */ + private void writeHead() { + fields = Arrays.stream(tClass.getDeclaredFields()) + .map(Field::getName) + .filter(n -> !ignoreFields.contains(n)) + .collect(Collectors.toList()); + table.add(reduce(fields)); + } + + /** + * 驼峰转_ + * + * @param str + * @return + */ + private String unCamel(String str) { + // TODO: 2020/3/9 + return null; + } + + /** + * 写comment,包括表名,class名,和外部自定义的comment + */ + private void writeComment() { + table.add(connectCommentPrefix(String.format("tableName:%s", tableName))); + table.add(connectCommentPrefix(String.format("class:%s", tClass.getName()))); + table.add(connectCommentPrefix(String.format("env:%s", DSSOrchestratorConf.DSS_EXPORT_ENV.getValue()))); + comments.stream().map(this::connectCommentPrefix).forEach(table::add); + } + + /** + * str前加上comment标识 + * + * @param str + * @return + */ + private String connectCommentPrefix(String str) { + return commentPrefix + str; + } + +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/export/impl/MetaExportServiceImpl.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/export/impl/MetaExportServiceImpl.java new file mode 100644 index 0000000000..929148fafb --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/export/impl/MetaExportServiceImpl.java @@ -0,0 +1,61 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish.io.export.impl; + + +import com.webank.wedatasphere.dss.common.utils.IoUtils; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo; +import com.webank.wedatasphere.dss.orchestrator.publish.io.export.MetaExportService; +import com.webank.wedatasphere.dss.orchestrator.publish.io.export.MetaWriter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import java.io.*; + + +@Service +public class MetaExportServiceImpl implements MetaExportService { + + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + + private final String fileName = "meta.txt"; + + + @Override + public void export(DSSOrchestratorInfo dssOrchestratorInfo, String savePath) throws IOException { + + try ( + OutputStream outputStream = generateOutputStream(savePath) + ) { + exportOrchestratorBaseInfo(dssOrchestratorInfo, outputStream); + } + } + + + private OutputStream generateOutputStream(String basePath) throws IOException { + return IoUtils.generateExportOutputStream(basePath + File.separator + fileName); + } + + + private void exportOrchestratorBaseInfo(DSSOrchestratorInfo dssOrchestratorInfo,OutputStream outputStream) throws IOException { + + MetaWriter.of("dss_orchestrator", DSSOrchestratorInfo.class).data(dssOrchestratorInfo).write(outputStream); + + } + +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/input/MetaInputService.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/input/MetaInputService.java new file mode 100644 index 0000000000..230ad50b76 --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/input/MetaInputService.java @@ -0,0 +1,34 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish.io.input; + + + + + +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo; + +import java.io.IOException; +import java.util.List; + +public interface MetaInputService { + + + + List importOrchestrator(String basePath) throws IOException; + +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/input/MetaReader.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/input/MetaReader.java new file mode 100644 index 0000000000..7b08541063 --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/input/MetaReader.java @@ -0,0 +1,166 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish.io.input; + +import com.webank.wedatasphere.dss.common.utils.DSSExceptionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Field; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.stream.Collectors; + +public class MetaReader { + + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + private final Class tClass; + private final String tableName; + private String commentPrefix = "#"; + private String seperator = "\\|"; + private List datas = new ArrayList<>(); + private List fields = null; + private List comments = new ArrayList<>(); + private List> body = new ArrayList<>(); + private boolean finded = false; + private boolean firstLine = true; + + public MetaReader(Class tClass, String tableName) { + this.tClass = tClass; + this.tableName = tableName; + } + + public static MetaReader of(String tableName, Class tClass) { + return new MetaReader<>(tClass, tableName); + } + + public List read(InputStream inputStream) throws IOException { + try (InputStreamReader streamReader = new InputStreamReader(inputStream); + BufferedReader reader = new BufferedReader(streamReader);) { + readTable(reader); + } + readT(); + return datas; + } + + public String read(InputStream inputStream, String key) throws IOException { + try (InputStreamReader streamReader = new InputStreamReader(inputStream); + BufferedReader reader = new BufferedReader(streamReader);) { + readTable(reader); + } + String comment = comments.stream().filter(c -> c.contains(key + ":")).findFirst().orElse(""); + String[] split = comment.split(":"); + if (split.length > 1) return split[1]; + return ""; + } + + private void readT() { + body.stream().map(DSSExceptionUtils.map(this::lineToT)).forEach(datas::add); + } + + private T lineToT(List list) throws IllegalAccessException, InstantiationException, NoSuchFieldException, ParseException { + T t = tClass.newInstance(); + for (int i = 0; i < list.size(); i++) { + String valueStr = list.get(i); + if ("null".equalsIgnoreCase(valueStr)) continue; + Field declaredField = tClass.getDeclaredField(fields.get(i)); + declaredField.setAccessible(true); + Object value = null; + String type = declaredField.getType().getSimpleName(); + switch (type) { + case "String": + value = valueStr; + break; + case "Date": + value = new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZ yyyy", Locale.ENGLISH).parse(valueStr); + break; + case "Long": + case "long": + value = Long.valueOf(valueStr); + break; + case "Boolean": + value = Boolean.valueOf(valueStr); + break; + case "Integer": + value = Integer.valueOf(valueStr); + break; + default: + logger.warn(String.format("unsupport type %s", type)); + } + declaredField.set(t, value); + } + return t; + } + + private void readTable(BufferedReader reader) throws IOException { + String line = null; + while ((line = reader.readLine()) != null) { + if (!finded && !shut(line)) { + continue; + } + if (finded && isTableName(line)) { + break; + } + if (shut(line)) { + finded = true; + continue; + } + // TODO: 2020/3/9 + if (isComment(line)) { + comments.add(line); + continue; + } + if (firstLine) { + //handle head + fields = Arrays.stream(line.split(seperator)).collect(Collectors.toList()); + firstLine = false; + continue; + } + body.add(Arrays.stream(line.split(seperator)).collect(Collectors.toList())); + //handle body + } + } + + private boolean isComment(String str) { + return str.startsWith(commentPrefix); + } + + private boolean isTableName(String str) { + return isComment(str) && str.contains(commentPrefix + "tableName:"); + } + + private boolean isClass(String str) { + return isComment(str) && str.contains(commentPrefix + "class:"); + } + + private String getComment(String str) { + return str.substring(1); + } + + private boolean shut(String str) { + return isTableName(str) && getComment(str).equals(String.format("tableName:%s", tableName)); + } +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/input/impl/MetaInputServiceImpl.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/input/impl/MetaInputServiceImpl.java new file mode 100644 index 0000000000..52b9babbcc --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/io/input/impl/MetaInputServiceImpl.java @@ -0,0 +1,61 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish.io.input.impl; + + +import com.webank.wedatasphere.dss.common.utils.IoUtils; +import com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo; +import com.webank.wedatasphere.dss.orchestrator.publish.io.input.MetaInputService; +import com.webank.wedatasphere.dss.orchestrator.publish.io.input.MetaReader; + +import org.springframework.stereotype.Service; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + + +@Service +public class MetaInputServiceImpl implements MetaInputService { + + // TODO: 2020/3/13 防止表结构发生改变的version 字段的添加 + + private final String fileName = "meta.txt"; + + @Override + public List importOrchestrator(String basePath) throws IOException { + try (InputStream inputStream = generateInputstream(basePath)) { + return MetaReader.of("dss_orchestrator", DSSOrchestratorInfo.class).read(inputStream); + } + } + + + /** + * 获取inputStream + * + * @param basePath + * @return + * @throws FileNotFoundException + */ + private InputStream generateInputstream(String basePath) throws IOException { + return IoUtils.generateInputInputStream(basePath + File.separator + fileName); + } + + +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/job/ConversionJobEntity.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/job/ConversionJobEntity.java new file mode 100644 index 0000000000..cef04dd32d --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/job/ConversionJobEntity.java @@ -0,0 +1,119 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish.job; + +import com.webank.wedatasphere.dss.common.entity.project.DSSProject; +import com.webank.wedatasphere.dss.common.label.DSSLabel; +import com.webank.wedatasphere.dss.orchestrator.common.protocol.ResponseOperateOrchestrator; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import java.util.Date; +import java.util.List; + + +public class ConversionJobEntity { + + private DSSProject project; + + private List orcIdList; + + private List refAppIdList; + + private Workspace workspace; + + private String userName; + + private List labels; + + private Date createTime; + + private Date updateTime; + + private ResponseOperateOrchestrator response; + + public DSSProject getProject() { + return project; + } + + public void setProject(DSSProject project) { + this.project = project; + } + + public List getOrcIdList() { + return orcIdList; + } + + public void setOrcIdList(List orcIdList) { + this.orcIdList = orcIdList; + } + + public List getRefAppIdList() { + return refAppIdList; + } + + public void setRefAppIdList(List refAppIdList) { + this.refAppIdList = refAppIdList; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public ResponseOperateOrchestrator getResponse() { + return response; + } + + public void setResponse(ResponseOperateOrchestrator response) { + updateTime = new Date(); + this.response = response; + } + + public List getLabels() { + return labels; + } + + public void setLabels(List labels) { + this.labels = labels; + } + + public Workspace getWorkspace() { + return workspace; + } + + public void setWorkspace(Workspace workspace) { + this.workspace = workspace; + } +} diff --git a/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/job/OrchestratorConversionJob.java b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/job/OrchestratorConversionJob.java new file mode 100644 index 0000000000..3e53f411c3 --- /dev/null +++ b/dss-framework/framework-plugins/dss-framework-orchestrator-publish/src/main/java/com/webank/wedatasphere/dss/orchestrator/publish/job/OrchestratorConversionJob.java @@ -0,0 +1,107 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.webank.wedatasphere.dss.orchestrator.publish.job; + +import com.webank.wedatasphere.dss.common.entity.project.DSSProject; +import com.webank.wedatasphere.dss.common.exception.DSSErrorException; +import com.webank.wedatasphere.dss.common.protocol.project.ProjectInfoRequest; +import com.webank.wedatasphere.dss.orchestrator.common.protocol.ResponseOperateOrchestrator; +import com.webank.wedatasphere.dss.orchestrator.core.plugin.DSSOrchestratorPlugin; +import com.webank.wedatasphere.dss.orchestrator.publish.ConversionDSSOrchestratorPlugin; +import com.webank.wedatasphere.dss.sender.service.DSSSenderServiceFactory; +import com.webank.wedatasphere.dss.standard.app.sso.Workspace; +import com.webank.wedatasphere.linkis.common.utils.ByteTimeUtils; +import java.util.List; +import java.util.function.Consumer; +import org.apache.commons.lang.exception.ExceptionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public final class OrchestratorConversionJob implements Runnable { + + private static final Logger LOGGER = LoggerFactory.getLogger(OrchestratorConversionJob.class); + + private String id; + + private ConversionJobEntity conversionJobEntity; + private List conversionDSSOrchestratorPlugins; + private Consumer consumer; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public void setConversionJobEntity(ConversionJobEntity conversionJobEntity) { + this.conversionJobEntity = conversionJobEntity; + } + + public ConversionJobEntity getConversionJobEntity() { + return conversionJobEntity; + } + + public void setConversionDSSOrchestratorPlugins(List conversionDSSOrchestratorPlugins) { + this.conversionDSSOrchestratorPlugins = conversionDSSOrchestratorPlugins; + } + + public void afterConversion(Consumer consumer) { + this.consumer = consumer; + } + + @Override + public void run() { + //1.从编排中心导出一次工作流,进行一次版本升级 + //2.进行发布到schedulis等调度系统 + LOGGER.info("Begin to convert project {} for user {} to scheduler, the orcIdList is {}.", + conversionJobEntity.getProject().getId(), conversionJobEntity.getUserName(), conversionJobEntity.getOrcIdList()); + conversionJobEntity.setResponse(ResponseOperateOrchestrator.running()); + ConversionDSSOrchestratorPlugin conversionDSSOrchestratorPlugin = null; + for (DSSOrchestratorPlugin plugin: conversionDSSOrchestratorPlugins) { + if(plugin instanceof ConversionDSSOrchestratorPlugin) { + conversionDSSOrchestratorPlugin = (ConversionDSSOrchestratorPlugin) plugin; + } + } + ProjectInfoRequest projectInfoRequest = new ProjectInfoRequest(); + projectInfoRequest.setProjectId(conversionJobEntity.getProject().getId()); + try{ + DSSProject project = (DSSProject) DSSSenderServiceFactory.getOrCreateServiceInstance().getProjectServerSender() + .ask(projectInfoRequest); + conversionJobEntity.setProject(project); + Workspace workspace = conversionJobEntity.getWorkspace(); + ResponseOperateOrchestrator response = conversionDSSOrchestratorPlugin.convert(conversionJobEntity.getUserName(), project, workspace, + conversionJobEntity.getRefAppIdList(), conversionJobEntity.getLabels()); + if(response.isFailed()) { + String msg = response.getMessage() == null ? "Unknown reason, please ask admin for help!" : response.getMessage(); + throw new DSSErrorException(50000, msg); + } + //3.如果都没有报错,那么默认任务应该是成功的,那么则将所有的状态进行置为完成 + consumer.accept(response); + conversionJobEntity.setResponse(response); + } catch (final Exception t){ + LOGGER.error("Convert for project {} failed.", conversionJobEntity.getProject(), t); + ResponseOperateOrchestrator response = ResponseOperateOrchestrator.failed(ExceptionUtils.getRootCauseMessage(t)); + conversionJobEntity.setResponse(response); + consumer.accept(response); + } + LOGGER.info("convert project {} for user {} to scheduler {}, costs {}.", conversionJobEntity.getResponse().getJobStatus(), conversionJobEntity.getProject().getId(), + conversionJobEntity.getUserName(), ByteTimeUtils.msDurationToString(conversionJobEntity.getUpdateTime().getTime() - conversionJobEntity.getCreateTime().getTime())); + } +} diff --git a/dss-framework/pom.xml b/dss-framework/pom.xml new file mode 100644 index 0000000000..7a1d8c2cec --- /dev/null +++ b/dss-framework/pom.xml @@ -0,0 +1,40 @@ + + + + + + dss + com.webank.wedatasphere.dss + 1.0.0 + + 4.0.0 + + dss-framework + pom + + + dss-framework-common + dss-appconn-framework + dss-framework-workspace-server + framework-plugins/dss-framework-orchestrator-publish + dss-framework-orchestrator-server + dss-framework-project-server + + + \ No newline at end of file From b7b59b3f8a9aa880659fee3dc5914b13965d0108 Mon Sep 17 00:00:00 2001 From: yangzhiyue <904666286@qq.com> Date: Fri, 20 Aug 2021 10:21:29 +0800 Subject: [PATCH 2/2] delete start and stop shell --- ...start-dss-framework-orchestrator-server.sh | 36 -------------- .../stop-dss-framework-orchestrator-server.sh | 47 ------------------- .../bin/start-dss-framework-project-server.sh | 36 -------------- .../bin/stop-dss-framework-project-server.sh | 47 ------------------- .../start-dss-framework-workspace-server.sh | 36 -------------- .../stop-dss-framework-workspace-server.sh | 47 ------------------- 6 files changed, 249 deletions(-) delete mode 100644 dss-framework/dss-framework-orchestrator-server/bin/start-dss-framework-orchestrator-server.sh delete mode 100644 dss-framework/dss-framework-orchestrator-server/bin/stop-dss-framework-orchestrator-server.sh delete mode 100644 dss-framework/dss-framework-project-server/bin/start-dss-framework-project-server.sh delete mode 100644 dss-framework/dss-framework-project-server/bin/stop-dss-framework-project-server.sh delete mode 100644 dss-framework/dss-framework-workspace-server/bin/start-dss-framework-workspace-server.sh delete mode 100644 dss-framework/dss-framework-workspace-server/bin/stop-dss-framework-workspace-server.sh diff --git a/dss-framework/dss-framework-orchestrator-server/bin/start-dss-framework-orchestrator-server.sh b/dss-framework/dss-framework-orchestrator-server/bin/start-dss-framework-orchestrator-server.sh deleted file mode 100644 index 7e592a27a6..0000000000 --- a/dss-framework/dss-framework-orchestrator-server/bin/start-dss-framework-orchestrator-server.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -cd `dirname $0` -cd .. -HOME=`pwd` -export DWS_ENGINE_MANAGER_HOME=$HOME - -export DWS_ENGINE_MANAGER_PID=$HOME/bin/linkis.pid - -if [[ -f "${DWS_ENGINE_MANAGER_PID}" ]]; then - pid=$(cat ${DWS_ENGINE_MANAGER_PID}) - if kill -0 ${pid} >/dev/null 2>&1; then - echo "DSS SERVER is already running." - return 0; - fi -fi - -export DWS_ENGINE_MANAGER_LOG_PATH=$HOME/logs -export DWS_ENGINE_MANAGER_HEAP_SIZE="1G" - -export DWS_ENGINE_MANAGER_JAVA_OPTS="-Xms$DWS_ENGINE_MANAGER_HEAP_SIZE -Xmx$DWS_ENGINE_MANAGER_HEAP_SIZE -XX:+UseG1GC -XX:MaxPermSize=500m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=20012" - -#export DWS_ENGINE_MANAGER_JAVA_OPTS="-Xms$DWS_ENGINE_MANAGER_HEAP_SIZE -Xmx$DWS_ENGINE_MANAGER_HEAP_SIZE -XX:+UseG1GC -XX:MaxPermSize=500m" - -nohup java $DWS_ENGINE_MANAGER_JAVA_OPTS -cp $HOME/conf:$HOME/lib/* com.webank.wedatasphere.linkis.DataWorkCloudApplication 2>&1 > $DWS_ENGINE_MANAGER_LOG_PATH/linkis.out & -pid=$! -if [[ -z "${pid}" ]]; then - echo "DSS SERVER start failed!" - sleep 1 - exit 1 -else - echo "DSS SERVER start succeeded!" - echo $pid > $DWS_ENGINE_MANAGER_PID - sleep 1 -fi -exit 1 \ No newline at end of file diff --git a/dss-framework/dss-framework-orchestrator-server/bin/stop-dss-framework-orchestrator-server.sh b/dss-framework/dss-framework-orchestrator-server/bin/stop-dss-framework-orchestrator-server.sh deleted file mode 100644 index 2ca464de62..0000000000 --- a/dss-framework/dss-framework-orchestrator-server/bin/stop-dss-framework-orchestrator-server.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -cd `dirname $0` -cd .. -HOME=`pwd` - -export FLOW_ENTRANCE_HOME_PID=$HOME/bin/linkis.pid - -function wait_for_FLOW_ENTRANCE_HOME_to_die() { - local pid - local count - pid=$1 - timeout=$2 - count=0 - timeoutTime=$(date "+%s") - let "timeoutTime+=$timeout" - currentTime=$(date "+%s") - forceKill=1 - - while [[ $currentTime -lt $timeoutTime ]]; do - $(kill ${pid} > /dev/null 2> /dev/null) - if kill -0 ${pid} > /dev/null 2>&1; then - sleep 3 - else - forceKill=0 - break - fi - currentTime=$(date "+%s") - done - - if [[ forceKill -ne 0 ]]; then - $(kill -9 ${pid} > /dev/null 2> /dev/null) - fi -} - -if [[ ! -f "${FLOW_ENTRANCE_HOME_PID}" ]]; then - echo "DSS SERVER is not running" -else - pid=$(cat ${FLOW_ENTRANCE_HOME_PID}) - if [[ -z "${pid}" ]]; then - echo "DSS SERVER is not running" - else - wait_for_FLOW_ENTRANCE_HOME_to_die $pid 40 - $(rm -f ${FLOW_ENTRANCE_HOME_PID}) - echo "DSS SERVER is stopped." - fi -fi \ No newline at end of file diff --git a/dss-framework/dss-framework-project-server/bin/start-dss-framework-project-server.sh b/dss-framework/dss-framework-project-server/bin/start-dss-framework-project-server.sh deleted file mode 100644 index 93242ae192..0000000000 --- a/dss-framework/dss-framework-project-server/bin/start-dss-framework-project-server.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -cd `dirname $0` -cd .. -HOME=`pwd` -export DWS_ENGINE_MANAGER_HOME=$HOME - -export DWS_ENGINE_MANAGER_PID=$HOME/bin/linkis.pid - -if [[ -f "${DWS_ENGINE_MANAGER_PID}" ]]; then - pid=$(cat ${DWS_ENGINE_MANAGER_PID}) - if kill -0 ${pid} >/dev/null 2>&1; then - echo "DSS SERVER is already running." - return 0; - fi -fi - -export DWS_ENGINE_MANAGER_LOG_PATH=$HOME/logs -export DWS_ENGINE_MANAGER_HEAP_SIZE="1G" - -export DWS_ENGINE_MANAGER_JAVA_OPTS="-Xms$DWS_ENGINE_MANAGER_HEAP_SIZE -Xmx$DWS_ENGINE_MANAGER_HEAP_SIZE -XX:+UseG1GC -XX:MaxPermSize=500m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=20013" - -#export DWS_ENGINE_MANAGER_JAVA_OPTS="-Xms$DWS_ENGINE_MANAGER_HEAP_SIZE -Xmx$DWS_ENGINE_MANAGER_HEAP_SIZE -XX:+UseG1GC -XX:MaxPermSize=500m" - -nohup java $DWS_ENGINE_MANAGER_JAVA_OPTS -cp $HOME/conf:$HOME/lib/* com.webank.wedatasphere.linkis.DataWorkCloudApplication 2>&1 > $DWS_ENGINE_MANAGER_LOG_PATH/linkis.out & -pid=$! -if [[ -z "${pid}" ]]; then - echo "DSS SERVER start failed!" - sleep 1 - exit 1 -else - echo "DSS SERVER start succeeded!" - echo $pid > $DWS_ENGINE_MANAGER_PID - sleep 1 -fi -exit 1 \ No newline at end of file diff --git a/dss-framework/dss-framework-project-server/bin/stop-dss-framework-project-server.sh b/dss-framework/dss-framework-project-server/bin/stop-dss-framework-project-server.sh deleted file mode 100644 index 2ca464de62..0000000000 --- a/dss-framework/dss-framework-project-server/bin/stop-dss-framework-project-server.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -cd `dirname $0` -cd .. -HOME=`pwd` - -export FLOW_ENTRANCE_HOME_PID=$HOME/bin/linkis.pid - -function wait_for_FLOW_ENTRANCE_HOME_to_die() { - local pid - local count - pid=$1 - timeout=$2 - count=0 - timeoutTime=$(date "+%s") - let "timeoutTime+=$timeout" - currentTime=$(date "+%s") - forceKill=1 - - while [[ $currentTime -lt $timeoutTime ]]; do - $(kill ${pid} > /dev/null 2> /dev/null) - if kill -0 ${pid} > /dev/null 2>&1; then - sleep 3 - else - forceKill=0 - break - fi - currentTime=$(date "+%s") - done - - if [[ forceKill -ne 0 ]]; then - $(kill -9 ${pid} > /dev/null 2> /dev/null) - fi -} - -if [[ ! -f "${FLOW_ENTRANCE_HOME_PID}" ]]; then - echo "DSS SERVER is not running" -else - pid=$(cat ${FLOW_ENTRANCE_HOME_PID}) - if [[ -z "${pid}" ]]; then - echo "DSS SERVER is not running" - else - wait_for_FLOW_ENTRANCE_HOME_to_die $pid 40 - $(rm -f ${FLOW_ENTRANCE_HOME_PID}) - echo "DSS SERVER is stopped." - fi -fi \ No newline at end of file diff --git a/dss-framework/dss-framework-workspace-server/bin/start-dss-framework-workspace-server.sh b/dss-framework/dss-framework-workspace-server/bin/start-dss-framework-workspace-server.sh deleted file mode 100644 index 971d93d9ed..0000000000 --- a/dss-framework/dss-framework-workspace-server/bin/start-dss-framework-workspace-server.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -cd `dirname $0` -cd .. -HOME=`pwd` -export DWS_ENGINE_MANAGER_HOME=$HOME - -export DWS_ENGINE_MANAGER_PID=$HOME/bin/linkis.pid - -if [[ -f "${DWS_ENGINE_MANAGER_PID}" ]]; then - pid=$(cat ${DWS_ENGINE_MANAGER_PID}) - if kill -0 ${pid} >/dev/null 2>&1; then - echo "DSS SERVER is already running." - return 0; - fi -fi - -export DWS_ENGINE_MANAGER_LOG_PATH=$HOME/logs -export DWS_ENGINE_MANAGER_HEAP_SIZE="1G" - -export DWS_ENGINE_MANAGER_JAVA_OPTS="-Xms$DWS_ENGINE_MANAGER_HEAP_SIZE -Xmx$DWS_ENGINE_MANAGER_HEAP_SIZE -XX:+UseG1GC -XX:MaxPermSize=500m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=20014" - -#export DWS_ENGINE_MANAGER_JAVA_OPTS="-Xms$DWS_ENGINE_MANAGER_HEAP_SIZE -Xmx$DWS_ENGINE_MANAGER_HEAP_SIZE -XX:+UseG1GC -XX:MaxPermSize=500m" - -nohup java $DWS_ENGINE_MANAGER_JAVA_OPTS -cp $HOME/conf:$HOME/lib/* com.webank.wedatasphere.linkis.DataWorkCloudApplication 2>&1 > $DWS_ENGINE_MANAGER_LOG_PATH/linkis.out & -pid=$! -if [[ -z "${pid}" ]]; then - echo "DSS SERVER start failed!" - sleep 1 - exit 1 -else - echo "DSS SERVER start succeeded!" - echo $pid > $DWS_ENGINE_MANAGER_PID - sleep 1 -fi -exit 1 \ No newline at end of file diff --git a/dss-framework/dss-framework-workspace-server/bin/stop-dss-framework-workspace-server.sh b/dss-framework/dss-framework-workspace-server/bin/stop-dss-framework-workspace-server.sh deleted file mode 100644 index 2ca464de62..0000000000 --- a/dss-framework/dss-framework-workspace-server/bin/stop-dss-framework-workspace-server.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -cd `dirname $0` -cd .. -HOME=`pwd` - -export FLOW_ENTRANCE_HOME_PID=$HOME/bin/linkis.pid - -function wait_for_FLOW_ENTRANCE_HOME_to_die() { - local pid - local count - pid=$1 - timeout=$2 - count=0 - timeoutTime=$(date "+%s") - let "timeoutTime+=$timeout" - currentTime=$(date "+%s") - forceKill=1 - - while [[ $currentTime -lt $timeoutTime ]]; do - $(kill ${pid} > /dev/null 2> /dev/null) - if kill -0 ${pid} > /dev/null 2>&1; then - sleep 3 - else - forceKill=0 - break - fi - currentTime=$(date "+%s") - done - - if [[ forceKill -ne 0 ]]; then - $(kill -9 ${pid} > /dev/null 2> /dev/null) - fi -} - -if [[ ! -f "${FLOW_ENTRANCE_HOME_PID}" ]]; then - echo "DSS SERVER is not running" -else - pid=$(cat ${FLOW_ENTRANCE_HOME_PID}) - if [[ -z "${pid}" ]]; then - echo "DSS SERVER is not running" - else - wait_for_FLOW_ENTRANCE_HOME_to_die $pid 40 - $(rm -f ${FLOW_ENTRANCE_HOME_PID}) - echo "DSS SERVER is stopped." - fi -fi \ No newline at end of file