You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@linkis.apache.org by GitBox <gi...@apache.org> on 2022/11/19 14:30:55 UTC

[GitHub] [incubator-linkis] ichenfeiyang opened a new pull request, #3865: [ISSUE-2442][linkis-basedata-manager] engine config template manage

ichenfeiyang opened a new pull request, #3865:
URL: https://github.com/apache/incubator-linkis/pull/3865

   <!--
   Thank you for sending the PR! We appreciate you spending the time to work on these changes.
   You can learn more about contributing to Apache Linkis here: https://linkis.apache.org/community/how-to-contribute
   Happy contributing!
   -->
   
   ### What is the purpose of the change
   
   At present, the new engine needs to manually enter sql to prepare the engine parameters. This submission is the basic data management module, and the related interfaces for the configuration management of the engine parameters are added:
   
   1.Query all engine lists
   /api/rest_j/v1/basedata-manager/engin-list
   2.Add/modify configuration item template interface
   /api/rest_j/v1/basedata-manager/configuration-template/save
   3.Delete configuration item template interface
   /api/rest_j/v1/basedata-manager/configuration-template/{keyId}
   4.Query the list of configuration templates according to the engine tag
   /api/rest_j/v1/basedata-manager/configuration-template/template-list-by-label
   
   目前新增引擎需要手动录入sql进行引擎参数准备,该次提交是基础数据管理模块,新增引擎参数配置管理的相关接口:
   1.查询所有引擎列表
   /api/rest_j/v1/basedata-manager/engin-list
   2.新增/修改配置项模板接口
   /api/rest_j/v1/basedata-manager/configuration-template/save
   3. 删除配置项模板接口
   /api/rest_j/v1/basedata-manager/configuration-template/{keyId}
   4.根据引擎标签查询配置模板列表
   /api/rest_j/v1/basedata-manager/configuration-template/template-list-by-label


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org


[GitHub] [incubator-linkis] jacktao007 commented on a diff in pull request #3865: [ISSUE-2442][linkis-basedata-manager] engine config template manage

Posted by GitBox <gi...@apache.org>.
jacktao007 commented on code in PR #3865:
URL: https://github.com/apache/incubator-linkis/pull/3865#discussion_r1027103376


##########
linkis-public-enhancements/linkis-basedata-manager/src/main/java/org/apache/linkis/basedatamanager/server/service/impl/ConfigurationTemplateServiceImpl.java:
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.basedatamanager.server.service.impl;
+
+import org.apache.linkis.basedatamanager.server.dao.CgManagerLabelMapper;
+import org.apache.linkis.basedatamanager.server.dao.ConfigurationConfigKeyMapper;
+import org.apache.linkis.basedatamanager.server.dao.ConfigurationConfigValueMapper;
+import org.apache.linkis.basedatamanager.server.dao.ConfigurationKeyEngineRelationMapper;
+import org.apache.linkis.basedatamanager.server.domain.CgManagerLabel;
+import org.apache.linkis.basedatamanager.server.domain.ConfigurationConfigKey;
+import org.apache.linkis.basedatamanager.server.domain.ConfigurationConfigValue;
+import org.apache.linkis.basedatamanager.server.domain.ConfigurationKeyEngineRelation;
+import org.apache.linkis.basedatamanager.server.request.ConfigurationTemplateSaveRequest;
+import org.apache.linkis.basedatamanager.server.response.EngineLabelResponse;
+import org.apache.linkis.basedatamanager.server.service.ConfigurationTemplateService;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.Resource;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import com.google.common.collect.Lists;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** This module is designed to manage configuration parameter templates */
+@Service
+public class ConfigurationTemplateServiceImpl implements ConfigurationTemplateService {
+  private static final Logger LOG = LoggerFactory.getLogger(ConfigurationTemplateService.class);
+  @Resource ConfigurationConfigKeyMapper configKeyMapper;
+  @Resource ConfigurationKeyEngineRelationMapper relationMapper;
+  @Resource CgManagerLabelMapper managerLabelMapper;
+  @Resource ConfigurationConfigValueMapper configValueMapper;
+
+  @Override
+  @Transactional(rollbackFor = Exception.class)
+  public Boolean saveConfigurationTemplate(ConfigurationTemplateSaveRequest request) {
+    // query engine label
+    CgManagerLabel label = managerLabelMapper.selectById(request.getEngineLabelId());
+
+    // build key&value
+    ConfigurationConfigKey configKey = new ConfigurationConfigKey();
+    BeanUtils.copyProperties(request, configKey);
+    Long keyId = request.getId();
+    ConfigurationConfigValue configValue = new ConfigurationConfigValue();
+    configValue.setConfigLabelId(label.getId());
+    configValue.setConfigValue(request.getDefaultValue());
+
+    // update
+    if (!StringUtils.isEmpty(keyId)) {
+      LOG.info("update configuration config key: [ keyId: " + keyId + " ]");
+      int updateKey = configKeyMapper.updateById(configKey);
+      configValue.setConfigKeyId(configKey.getId());
+      LOG.info("update configuration config value: [ keyId: " + keyId + " ]");
+      int updateValue = configValueMapper.updateByKeyId(configValue);
+      return updateKey > 0 && updateValue > 0;
+    }
+
+    // 1.insert into ps_configuration_config_key
+    int insertKey = configKeyMapper.insert(configKey);
+    LOG.info("insert a configuration config key: [ keyId: " + configKey.getKey() + " ]");
+    // 2.insert into ps_configuration_key_engine_relation
+    ConfigurationKeyEngineRelation relation = new ConfigurationKeyEngineRelation();
+    relation.setConfigKeyId(configKey.getId());
+    relation.setEngineTypeLabelId(label.getId().longValue());
+    int insertRelation = relationMapper.insert(relation);
+    LOG.info(
+        "insert a configuration key engine relation: [ relationId: " + relation.getId() + " ]");
+    // 3.insert into ps_configuration_config_value
+    configValue.setConfigKeyId(configKey.getId());
+    int insertValue = configValueMapper.insert(configValue);
+    LOG.info("insert a configuration config value: [ valueId: " + configValue.getId() + " ]");
+
+    return insertKey > 0 & insertRelation > 0 & insertValue > 0;
+  }
+
+  @Override
+  @Transactional(rollbackFor = Exception.class)
+  public Boolean deleteConfigurationTemplate(Long keyId) {
+    // 1.delete ps_configuration_config_value by keyId
+    int deleteValue = configValueMapper.deleteByKeyId(keyId);
+    LOG.info("delete a configuration config value: [ keyId: " + keyId + " ]");
+
+    // 2.delete ps_configuration_key_engine_relation by keyId
+    int deleteRelation = relationMapper.deleteByKeyId(keyId);
+    LOG.info("delete a configuration key engine relation: [ keyId: " + keyId + " ]");
+
+    // 3.delete ps_configuration_config_key by id
+    int deleteKey = configKeyMapper.deleteById(keyId);
+    LOG.info("delete a configuration config key: [ keyId: " + keyId + " ]");
+
+    return deleteValue > 0 & deleteRelation > 0 & deleteKey > 0;
+  }
+
+  @Override
+  public List<EngineLabelResponse> getEngineList() {
+    List<CgManagerLabel> cgEngineList = managerLabelMapper.getEngineList();
+    if (CollectionUtils.isEmpty(cgEngineList)) {
+      return Lists.newArrayList();
+    }
+    return cgEngineList.stream()
+        .map(
+            e -> {
+              String labelValue = e.getLabelValue().split(",")[1];
+              if ("*-*".equals(labelValue)) {
+                labelValue = "全局设置";

Review Comment:
   是否需要设置成英文?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org


[GitHub] [incubator-linkis] casionone merged pull request #3865: [ISSUE-2442][linkis-basedata-manager] engine config template manage

Posted by GitBox <gi...@apache.org>.
casionone merged PR #3865:
URL: https://github.com/apache/incubator-linkis/pull/3865


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org