macksonmu commented on code in PR #1866:
URL:
https://github.com/apache/incubator-streampark/pull/1866#discussion_r1000110882
##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/VariableServiceImpl.java:
##########
@@ -17,48 +17,74 @@
package org.apache.streampark.console.core.service.impl;
+import org.apache.streampark.common.util.DeflaterUtils;
import org.apache.streampark.console.base.domain.RestRequest;
import org.apache.streampark.console.base.exception.ApiAlertException;
import org.apache.streampark.console.base.mybatis.pager.MybatisPager;
+import org.apache.streampark.console.core.entity.Application;
+import org.apache.streampark.console.core.entity.FlinkSql;
import org.apache.streampark.console.core.entity.Variable;
import org.apache.streampark.console.core.mapper.VariableMapper;
import org.apache.streampark.console.core.service.ApplicationService;
import org.apache.streampark.console.core.service.CommonService;
+import org.apache.streampark.console.core.service.FlinkSqlService;
import org.apache.streampark.console.core.service.VariableService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
+import java.util.Iterator;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
@Slf4j
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true,
rollbackFor = Exception.class)
public class VariableServiceImpl extends ServiceImpl<VariableMapper, Variable>
implements VariableService {
+ private final Pattern placeholderPattern =
Pattern.compile("\\$\\{([A-Za-z])+([A-Za-z0-9._-])+\\}");
+
+ private final String placeholderLeft = "${";
+
+ private final String placeholderRight = "}";
+
@Autowired
private ApplicationService applicationService;
+ @Autowired
+ private FlinkSqlService flinkSqlService;
+
@Autowired
private CommonService commonService;
@Override
@Transactional(rollbackFor = Exception.class)
- public void createVariable(Variable variable) throws Exception {
+ public void createVariable(Variable variable) {
if (this.findByVariableCode(variable.getTeamId(),
variable.getVariableCode()) != null) {
throw new ApiAlertException("Sorry, the variable code already
exists.");
}
variable.setCreatorId(commonService.getUserId());
this.save(variable);
}
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void deleteVariable(Variable variable) {
+ if (isDependByApplications(variable)) {
+ throw new ApiAlertException("Sorry, the variable is actually
used.");
Review Comment:
Yes, I was planning to do the next PR, since you brought it up, I can submit
it together.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]