mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-01 11:47:51 +08:00
Initial module escheduler-dao commit
This commit is contained in:
parent
e6f14cf33d
commit
b825b9c513
153
escheduler-dao/pom.xml
Normal file
153
escheduler-dao/pom.xml
Normal file
@ -0,0 +1,153 @@
|
||||
<?xml version="1.0"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>cn.analysys</groupId>
|
||||
<artifactId>escheduler</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<artifactId>escheduler-dao</artifactId>
|
||||
<name>escheduler-dao</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-autoconfigure</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
<artifactId>tomcat-jdbc</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.cronutils</groupId>
|
||||
<artifactId>cron-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz-jobs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-configuration</groupId>
|
||||
<artifactId>commons-configuration</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.analysys</groupId>
|
||||
<artifactId>escheduler-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao;
|
||||
|
||||
/**
|
||||
* base dao
|
||||
*/
|
||||
public abstract class AbstractBaseDao {
|
||||
|
||||
protected abstract void init();
|
||||
|
||||
|
||||
}
|
137
escheduler-dao/src/main/java/cn/escheduler/dao/AlertDao.java
Normal file
137
escheduler-dao/src/main/java/cn/escheduler/dao/AlertDao.java
Normal file
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao;
|
||||
|
||||
import cn.escheduler.common.enums.AlertStatus;
|
||||
import cn.escheduler.common.enums.AlertType;
|
||||
import cn.escheduler.common.enums.ShowType;
|
||||
import cn.escheduler.dao.datasource.ConnectionFactory;
|
||||
import cn.escheduler.dao.mapper.AlertMapper;
|
||||
import cn.escheduler.dao.mapper.UserAlertGroupMapper;
|
||||
import cn.escheduler.dao.model.Alert;
|
||||
import cn.escheduler.dao.model.User;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class AlertDao extends AbstractBaseDao {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Autowired
|
||||
private AlertMapper alertMapper;
|
||||
|
||||
@Autowired
|
||||
private UserAlertGroupMapper userAlertGroupMapper;
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
alertMapper = ConnectionFactory.getSqlSession().getMapper(AlertMapper.class);
|
||||
userAlertGroupMapper = ConnectionFactory.getSqlSession().getMapper(UserAlertGroupMapper.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* insert alert
|
||||
* @param alert
|
||||
* @return
|
||||
*/
|
||||
public int addAlert(Alert alert){
|
||||
return alertMapper.insert(alert);
|
||||
}
|
||||
|
||||
/**
|
||||
* update alert
|
||||
* @param alertStatus
|
||||
* @param log
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public int updateAlert(AlertStatus alertStatus,String log,int id){
|
||||
return alertMapper.update(alertStatus, log, new Date(), id);
|
||||
}
|
||||
|
||||
/**
|
||||
* query user list by alert group id
|
||||
* @param alerGroupId
|
||||
* @return
|
||||
*/
|
||||
public List<User> queryUserByAlertGroupId(int alerGroupId){
|
||||
return userAlertGroupMapper.queryForUser(alerGroupId);
|
||||
}
|
||||
/**
|
||||
* MasterServer or WorkerServer stoped
|
||||
*/
|
||||
public void sendServerStopedAlert(int alertgroupId,String host,String serverType){
|
||||
Alert alert = new Alert();
|
||||
String content = String.format("[{'type':'%s','host':'%s','event':'服务挂掉','警告级别':'严重'}]",serverType,host);
|
||||
alert.setTitle("容错告警");
|
||||
alert.setShowType(ShowType.TABLE);
|
||||
alert.setContent(content);
|
||||
alert.setAlertType(AlertType.EMAIL);
|
||||
alert.setAlertGroupId(alertgroupId);
|
||||
alert.setCreateTime(new Date());
|
||||
alert.setUpdateTime(new Date());
|
||||
alertMapper.insert(alert);
|
||||
}
|
||||
|
||||
/**
|
||||
* task timeout warn
|
||||
*/
|
||||
public void sendTaskTimeoutAlert(int alertgroupId,String receivers,String receiversCc,int taskId,String taskName){
|
||||
Alert alert = new Alert();
|
||||
String content = String.format("[{'id':'%d','name':'%s','event':'timeout','warnLevel':'middle'}]",taskId,taskName);
|
||||
alert.setTitle("Task Timeout Warn");
|
||||
alert.setShowType(ShowType.TABLE);
|
||||
alert.setContent(content);
|
||||
alert.setAlertType(AlertType.EMAIL);
|
||||
alert.setAlertGroupId(alertgroupId);
|
||||
if (StringUtils.isNotEmpty(receivers)) {
|
||||
alert.setReceivers(receivers);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(receiversCc)) {
|
||||
alert.setReceiversCc(receiversCc);
|
||||
}
|
||||
alert.setCreateTime(new Date());
|
||||
alert.setUpdateTime(new Date());
|
||||
alertMapper.insert(alert);
|
||||
}
|
||||
|
||||
/**
|
||||
* list the alert information of waiting to be executed
|
||||
* @return
|
||||
*/
|
||||
public List<Alert> listWaitExecutionAlert(){
|
||||
return alertMapper.listAlertByStatus(AlertStatus.WAIT_EXECUTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* list user information by alert group id
|
||||
* @param alergroupId
|
||||
* @return
|
||||
*/
|
||||
public List<User> listUserByAlertgroupId(int alergroupId){
|
||||
return userAlertGroupMapper.listUserByAlertgroupId(alergroupId);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* dao factory
|
||||
*/
|
||||
public class DaoFactory {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DaoFactory.class);
|
||||
|
||||
private static Map<String, AbstractBaseDao> daoMap = new ConcurrentHashMap<>();
|
||||
|
||||
private DaoFactory(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Dao 实例
|
||||
*
|
||||
* @param clazz
|
||||
* @return Dao实例
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends AbstractBaseDao> T getDaoInstance(Class<T> clazz) {
|
||||
String className = clazz.getName();
|
||||
synchronized (daoMap) {
|
||||
if (!daoMap.containsKey(className)) {
|
||||
try {
|
||||
T t = clazz.getConstructor().newInstance();
|
||||
// 实例初始化
|
||||
t.init();
|
||||
daoMap.put(className, t);
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (T) daoMap.get(className);
|
||||
}
|
||||
}
|
1540
escheduler-dao/src/main/java/cn/escheduler/dao/ProcessDao.java
Normal file
1540
escheduler-dao/src/main/java/cn/escheduler/dao/ProcessDao.java
Normal file
File diff suppressed because it is too large
Load Diff
162
escheduler-dao/src/main/java/cn/escheduler/dao/ServerDao.java
Normal file
162
escheduler-dao/src/main/java/cn/escheduler/dao/ServerDao.java
Normal file
@ -0,0 +1,162 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao;
|
||||
|
||||
import cn.escheduler.dao.mapper.MasterServerMapper;
|
||||
import cn.escheduler.dao.mapper.WorkerServerMapper;
|
||||
import cn.escheduler.dao.model.MasterServer;
|
||||
import cn.escheduler.dao.model.WorkerServer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.escheduler.dao.datasource.ConnectionFactory.getMapper;
|
||||
|
||||
/**
|
||||
* master server
|
||||
*/
|
||||
public class ServerDao extends AbstractBaseDao {
|
||||
|
||||
@Autowired
|
||||
MasterServerMapper masterServerMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
WorkerServerMapper workerServerMapper;
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
masterServerMapper = getMapper(MasterServerMapper.class);
|
||||
workerServerMapper = getMapper(WorkerServerMapper.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* register master
|
||||
*
|
||||
* @param host
|
||||
* @param port
|
||||
* @param zkDirectory
|
||||
* @param resInfo
|
||||
* @param createTime
|
||||
* @param lastHeartbeatTime
|
||||
* @return
|
||||
*/
|
||||
public int registerMaster(String host, int port , String zkDirectory , String resInfo ,
|
||||
Date createTime , Date lastHeartbeatTime) {
|
||||
|
||||
MasterServer masterServer = new MasterServer();
|
||||
|
||||
masterServer.setHost(host);
|
||||
masterServer.setPort(port);
|
||||
masterServer.setZkDirectory(zkDirectory);
|
||||
masterServer.setResInfo(resInfo);
|
||||
masterServer.setCreateTime(createTime);
|
||||
masterServer.setLastHeartbeatTime(lastHeartbeatTime);
|
||||
|
||||
return masterServerMapper.insert(masterServer);
|
||||
}
|
||||
|
||||
/**
|
||||
* update master
|
||||
*
|
||||
* @param host
|
||||
* @param port
|
||||
* @param resInfo
|
||||
* @param lastHeartbeatTime
|
||||
* @return
|
||||
*/
|
||||
public int updateMaster(String host, int port , String resInfo , Date lastHeartbeatTime) {
|
||||
|
||||
MasterServer masterServer = new MasterServer();
|
||||
|
||||
masterServer.setHost(host);
|
||||
masterServer.setPort(port);
|
||||
masterServer.setResInfo(resInfo);
|
||||
masterServer.setLastHeartbeatTime(lastHeartbeatTime);
|
||||
|
||||
return masterServerMapper.update(masterServer);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete master
|
||||
*
|
||||
* @param host
|
||||
* @return
|
||||
*/
|
||||
public int deleteMaster(String host) {
|
||||
return masterServerMapper.deleteWorkerByHost(host);
|
||||
}
|
||||
|
||||
/**
|
||||
* register master
|
||||
* @param host
|
||||
* @param port
|
||||
* @param zkDirectory
|
||||
* @param resInfo
|
||||
* @param createTime
|
||||
* @param lastHeartbeatTime
|
||||
* @return
|
||||
*/
|
||||
public int registerWorker(String host, int port , String zkDirectory , String resInfo ,
|
||||
Date createTime , Date lastHeartbeatTime) {
|
||||
|
||||
WorkerServer workerServer = new WorkerServer();
|
||||
|
||||
workerServer.setHost(host);
|
||||
workerServer.setPort(port);
|
||||
workerServer.setZkDirectory(zkDirectory);
|
||||
workerServer.setResInfo(resInfo);
|
||||
workerServer.setCreateTime(createTime);
|
||||
workerServer.setLastHeartbeatTime(lastHeartbeatTime);
|
||||
|
||||
return workerServerMapper.insert(workerServer);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* update worker
|
||||
* @param host
|
||||
* @param port
|
||||
* @param resInfo
|
||||
* @param lastHeartbeatTime
|
||||
* @return
|
||||
*/
|
||||
public int updateWorker(String host, int port , String resInfo , Date lastHeartbeatTime) {
|
||||
|
||||
WorkerServer workerServer = new WorkerServer();
|
||||
|
||||
workerServer.setHost(host);
|
||||
workerServer.setPort(port);
|
||||
workerServer.setResInfo(resInfo);
|
||||
workerServer.setLastHeartbeatTime(lastHeartbeatTime);
|
||||
|
||||
return workerServerMapper.update(workerServer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* delete worker by host
|
||||
*
|
||||
* @param host
|
||||
* @return
|
||||
*/
|
||||
public int deleteWorker(String host) {
|
||||
return workerServerMapper.deleteWorkerByHost(host);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,253 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao;
|
||||
|
||||
import cn.escheduler.common.Constants;
|
||||
import cn.escheduler.dao.model.TaskRecord;
|
||||
import org.apache.commons.configuration.Configuration;
|
||||
import org.apache.commons.configuration.ConfigurationException;
|
||||
import org.apache.commons.configuration.PropertiesConfiguration;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* task record dao
|
||||
*/
|
||||
public class TaskRecordDao {
|
||||
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(TaskRecordDao.class.getName());
|
||||
|
||||
/**
|
||||
* 加载配置文件
|
||||
*/
|
||||
private static Configuration conf;
|
||||
|
||||
static {
|
||||
try {
|
||||
conf = new PropertiesConfiguration(Constants.TASK_RECORD_PROPERTIES_PATH);
|
||||
}catch (ConfigurationException e){
|
||||
logger.error("load configuration excetpion",e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* create connection
|
||||
* @return
|
||||
*/
|
||||
private static Connection getConn() {
|
||||
if(!conf.getBoolean(Constants.TASK_RECORD_FLAG)){
|
||||
return null;
|
||||
}
|
||||
String driver = "com.mysql.jdbc.Driver";
|
||||
String url = conf.getString(Constants.TASK_RECORD_URL);
|
||||
String username = conf.getString(Constants.TASK_RECORD_USER);
|
||||
String password = conf.getString(Constants.TASK_RECORD_PWD);
|
||||
Connection conn = null;
|
||||
try {
|
||||
//classLoader,加载对应驱动
|
||||
Class.forName(driver);
|
||||
conn = DriverManager.getConnection(url, username, password);
|
||||
} catch (ClassNotFoundException e) {
|
||||
logger.error("Exception ", e);
|
||||
} catch (SQLException e) {
|
||||
logger.error("Exception ", e);
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
/**
|
||||
* generate where sql string
|
||||
* @param filterMap
|
||||
* @return
|
||||
*/
|
||||
private static String getWhereString(Map<String, String> filterMap)
|
||||
{
|
||||
if(filterMap.size() ==0){
|
||||
return "";
|
||||
}
|
||||
|
||||
String result = " where 1=1 ";
|
||||
|
||||
Object taskName = filterMap.get("taskName");
|
||||
if(taskName != null && StringUtils.isNotEmpty(taskName.toString())){
|
||||
result += " and PROC_NAME like concat('%', '" + taskName.toString() + "', '%') ";
|
||||
}
|
||||
|
||||
Object taskDate = filterMap.get("taskDate");
|
||||
if(taskDate != null && StringUtils.isNotEmpty(taskDate.toString())){
|
||||
result += " and PROC_DATE='" + taskDate.toString() + "'";
|
||||
}
|
||||
|
||||
Object state = filterMap.get("state");
|
||||
if(state != null && StringUtils.isNotEmpty(state.toString())){
|
||||
result += " and NOTE='" + state.toString() + "'";
|
||||
}
|
||||
|
||||
Object sourceTable = filterMap.get("sourceTable");
|
||||
if(sourceTable!= null && StringUtils.isNotEmpty(sourceTable.toString())){
|
||||
result += " and SOURCE_TAB like concat('%', '" + sourceTable.toString()+ "', '%')";
|
||||
}
|
||||
|
||||
Object targetTable = filterMap.get("targetTable");
|
||||
if(sourceTable!= null && StringUtils.isNotEmpty(targetTable.toString())){
|
||||
result += " and TARGET_TAB like concat('%', '"+ targetTable.toString()+"', '%') " ;
|
||||
}
|
||||
|
||||
Object start = filterMap.get("startTime");
|
||||
if(start != null && StringUtils.isNotEmpty(start.toString())){
|
||||
result += " and STARTDATE>='" + start.toString() + "'";
|
||||
}
|
||||
|
||||
Object end = filterMap.get("endTime");
|
||||
if(end != null && StringUtils.isNotEmpty(end.toString())){
|
||||
result += " and ENDDATE>='" + end.toString()+ "'";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* count task record
|
||||
* @param filterMap
|
||||
* @return
|
||||
*/
|
||||
public static int countTaskRecord(Map<String, String> filterMap){
|
||||
|
||||
int count = 0;
|
||||
Connection conn = null;
|
||||
try {
|
||||
conn = getConn();
|
||||
if(conn == null){
|
||||
return count;
|
||||
}
|
||||
String sql = "select count(1) as count from eamp_hive_log_hd";
|
||||
sql += getWhereString(filterMap);
|
||||
PreparedStatement pstmt;
|
||||
pstmt = conn.prepareStatement(sql);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while(rs.next()){
|
||||
count = rs.getInt("count");
|
||||
break;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.error("Exception ", e);
|
||||
}finally {
|
||||
try {
|
||||
if(conn != null){
|
||||
conn.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.error("Exception ", e);
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* query task record by filter map paging
|
||||
* @param filterMap
|
||||
* @return
|
||||
*/
|
||||
public static List<TaskRecord> queryAllTaskRecord(Map<String,String> filterMap ) {
|
||||
|
||||
String sql = "select * from eamp_hive_log_hd ";
|
||||
sql += getWhereString(filterMap);
|
||||
|
||||
int offset = Integer.parseInt(filterMap.get("offset"));
|
||||
int pageSize = Integer.parseInt(filterMap.get("pageSize"));
|
||||
sql += String.format(" order by STARTDATE desc limit %d,%d", offset, pageSize);
|
||||
|
||||
List<TaskRecord> recordList = new ArrayList<>();
|
||||
try{
|
||||
recordList = getQueryResult(sql);
|
||||
}catch (Exception e){
|
||||
logger.error("Exception ", e);
|
||||
}
|
||||
return recordList;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert result set to task record
|
||||
* @param resultSet
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
private static TaskRecord convertToTaskRecord(ResultSet resultSet) throws SQLException {
|
||||
|
||||
TaskRecord taskRecord = new TaskRecord();
|
||||
taskRecord.setId(resultSet.getInt("ID"));
|
||||
taskRecord.setProcId(resultSet.getInt("PROC_ID"));
|
||||
taskRecord.setProcName(resultSet.getString("PROC_NAME"));
|
||||
taskRecord.setProcDate(resultSet.getString("PROC_DATE"));
|
||||
taskRecord.setStartDate(resultSet.getDate("STARTDATE"));
|
||||
taskRecord.setEndDate(resultSet.getDate("ENDDATE"));
|
||||
taskRecord.setResult(resultSet.getString("RESULT"));
|
||||
taskRecord.setDuration(resultSet.getInt("DURATION"));
|
||||
taskRecord.setNote(resultSet.getString("NOTE"));
|
||||
taskRecord.setSchema(resultSet.getString("SCHEMA"));
|
||||
taskRecord.setJobId(resultSet.getString("JOB_ID"));
|
||||
taskRecord.setSourceTab(resultSet.getString("SOURCE_TAB"));
|
||||
taskRecord.setSourceRowCount(resultSet.getLong("SOURCE_ROW_COUNT"));
|
||||
taskRecord.setTargetTab(resultSet.getString("TARGET_TAB"));
|
||||
taskRecord.setTargetRowCount(resultSet.getLong("TARGET_ROW_COUNT"));
|
||||
taskRecord.setErrorCode(resultSet.getString("ERROR_CODE"));
|
||||
return taskRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* query task list by select sql
|
||||
* @param selectSql
|
||||
* @return
|
||||
*/
|
||||
private static List<TaskRecord> getQueryResult(String selectSql) {
|
||||
List<TaskRecord> recordList = new ArrayList<>();
|
||||
Connection conn = null;
|
||||
try {
|
||||
conn = getConn();
|
||||
if(conn == null){
|
||||
return recordList;
|
||||
}
|
||||
PreparedStatement pstmt;
|
||||
pstmt = conn.prepareStatement(selectSql);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
|
||||
while(rs.next()){
|
||||
TaskRecord taskRecord = convertToTaskRecord(rs);
|
||||
recordList.add(taskRecord);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.error("Exception ", e);
|
||||
}finally {
|
||||
try {
|
||||
if(conn != null){
|
||||
conn.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.error("Exception ", e);
|
||||
}
|
||||
}
|
||||
return recordList;
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.datasource;
|
||||
|
||||
import cn.escheduler.common.Constants;
|
||||
import cn.escheduler.common.utils.CommonUtils;
|
||||
import cn.escheduler.dao.mapper.ProjectMapper;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import org.apache.ibatis.mapping.Environment;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
|
||||
import org.apache.ibatis.transaction.TransactionFactory;
|
||||
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static cn.escheduler.dao.utils.PropertyUtils.*;
|
||||
|
||||
|
||||
/**
|
||||
* data source connection factory
|
||||
*/
|
||||
public class ConnectionFactory {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ConnectionFactory.class);
|
||||
|
||||
private static SqlSessionFactory sqlSessionFactory;
|
||||
|
||||
/**
|
||||
* get the data source
|
||||
*/
|
||||
public static DruidDataSource getDataSource() {
|
||||
DruidDataSource druidDataSource = new DruidDataSource();
|
||||
|
||||
druidDataSource.setDriverClassName(getString(Constants.SPRING_DATASOURCE_DRIVER_CLASS_NAME));
|
||||
druidDataSource.setUrl(getString(Constants.SPRING_DATASOURCE_URL));
|
||||
druidDataSource.setUsername(getString(Constants.SPRING_DATASOURCE_USERNAME));
|
||||
druidDataSource.setPassword(getString(Constants.SPRING_DATASOURCE_PASSWORD));
|
||||
druidDataSource.setValidationQuery(getString(Constants.SPRING_DATASOURCE_VALIDATION_QUERY));
|
||||
|
||||
druidDataSource.setPoolPreparedStatements(getBoolean(Constants.SPRING_DATASOURCE_POOL_PREPARED_STATEMENTS));
|
||||
druidDataSource.setTestWhileIdle(getBoolean(Constants.SPRING_DATASOURCE_TEST_WHILE_IDLE));
|
||||
druidDataSource.setTestOnBorrow(getBoolean(Constants.SPRING_DATASOURCE_TEST_ON_BORROW));
|
||||
druidDataSource.setTestOnReturn(getBoolean(Constants.SPRING_DATASOURCE_TEST_ON_RETURN));
|
||||
druidDataSource.setKeepAlive(getBoolean(Constants.SPRING_DATASOURCE_KEEP_ALIVE));
|
||||
//just for development
|
||||
if (CommonUtils.isDevelopMode()) {
|
||||
//Configure filters that are intercepted by monitoring statistics, and SQL can not be counted after removing them.'wall'is used for firewall
|
||||
try {
|
||||
druidDataSource.setFilters("stat,wall,log4j");
|
||||
} catch (SQLException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
druidDataSource.setMinIdle(getInt(Constants.SPRING_DATASOURCE_MIN_IDLE));
|
||||
druidDataSource.setMaxActive(getInt(Constants.SPRING_DATASOURCE_MAX_ACTIVE));
|
||||
druidDataSource.setMaxWait(getInt(Constants.SPRING_DATASOURCE_MAX_WAIT));
|
||||
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(getInt(Constants.SPRING_DATASOURCE_MAX_POOL_PREPARED_STATEMENT_PER_CONNECTION_SIZE));
|
||||
druidDataSource.setInitialSize(getInt(Constants.SPRING_DATASOURCE_INITIAL_SIZE));
|
||||
druidDataSource.setTimeBetweenEvictionRunsMillis(getLong(Constants.SPRING_DATASOURCE_TIME_BETWEEN_EVICTION_RUNS_MILLIS));
|
||||
druidDataSource.setTimeBetweenConnectErrorMillis(getLong(Constants.SPRING_DATASOURCE_TIME_BETWEEN_CONNECT_ERROR_MILLIS));
|
||||
druidDataSource.setMinEvictableIdleTimeMillis(getLong(Constants.SPRING_DATASOURCE_MIN_EVICTABLE_IDLE_TIME_MILLIS));
|
||||
druidDataSource.setValidationQueryTimeout(getInt(Constants.SPRING_DATASOURCE_VALIDATION_QUERY_TIMEOUT));
|
||||
//auto commit
|
||||
druidDataSource.setDefaultAutoCommit(getBoolean(Constants.SPRING_DATASOURCE_DEFAULT_AUTO_COMMIT));
|
||||
|
||||
return druidDataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* get sql session factory
|
||||
*/
|
||||
public static SqlSessionFactory getSqlSessionFactory() {
|
||||
if (sqlSessionFactory == null) {
|
||||
synchronized (ConnectionFactory.class) {
|
||||
if (sqlSessionFactory == null) {
|
||||
DataSource dataSource = getDataSource();
|
||||
TransactionFactory transactionFactory = new JdbcTransactionFactory();
|
||||
|
||||
Environment environment = new Environment(Constants.DEVELOPMENT, transactionFactory, dataSource);
|
||||
|
||||
Configuration configuration = new Configuration(environment);
|
||||
configuration.setLazyLoadingEnabled(true);
|
||||
|
||||
configuration.addMappers(ProjectMapper.class.getPackage().getName());
|
||||
|
||||
SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
|
||||
sqlSessionFactory = builder.build(configuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sqlSessionFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* get sql session
|
||||
*/
|
||||
public static SqlSession getSqlSession() {
|
||||
return new SqlSessionTemplate(getSqlSessionFactory());
|
||||
}
|
||||
|
||||
public static <T> T getMapper(Class<T> type){
|
||||
return getSqlSession().getMapper(type);
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.datasource;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* data base configuration
|
||||
*/
|
||||
@Configuration
|
||||
@PropertySource({"classpath:dao/data_source.properties"})
|
||||
@MapperScan(basePackages = "cn.escheduler.dao.mapper", sqlSessionFactoryRef = "SqlSessionFactory")
|
||||
public class DatabaseConfiguration {
|
||||
|
||||
/**
|
||||
* register data source
|
||||
*/
|
||||
@Primary
|
||||
@Bean(name = "DataSource", initMethod = "init", destroyMethod = "close")
|
||||
public DruidDataSource dataSource() {
|
||||
return ConnectionFactory.getDataSource();
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean(name = "SqlSessionFactory")
|
||||
public SqlSessionFactory sqlSessionFactory() throws Exception {
|
||||
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
|
||||
sqlSessionFactoryBean.setDataSource(dataSource());
|
||||
|
||||
return sqlSessionFactoryBean.getObject();
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean(name = "TransactionManager")
|
||||
public PlatformTransactionManager transactionManager() throws SQLException {
|
||||
return new DataSourceTransactionManager(dataSource());
|
||||
}
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.AlertType;
|
||||
import cn.escheduler.dao.model.AlertGroup;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.EnumOrdinalTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* alert group mapper
|
||||
*/
|
||||
public interface AlertGroupMapper {
|
||||
/**
|
||||
* insert warning group
|
||||
* @param alertGroup
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = AlertGroupMapperProvider.class, method = "insert")
|
||||
@Options(useGeneratedKeys = true,keyProperty = "alertGroup.id")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "alertGroup.id", before = false, resultType = int.class)
|
||||
int insert(@Param("alertGroup") AlertGroup alertGroup);
|
||||
|
||||
|
||||
/**
|
||||
* delete alert group by id
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = AlertGroupMapperProvider.class, method = "delete")
|
||||
int delete(@Param("id") int id);
|
||||
|
||||
|
||||
/**
|
||||
* update alert group information
|
||||
* @param alertGroup
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = AlertGroupMapperProvider.class, method = "update")
|
||||
int update(@Param("alertGroup") AlertGroup alertGroup);
|
||||
|
||||
|
||||
/**
|
||||
* query alert group by id
|
||||
* @param alertGroupId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "groupName", column = "group_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "groupType", column = "group_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = AlertType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = AlertGroupMapperProvider.class, method = "queryById")
|
||||
AlertGroup queryById(@Param("alertGroupId") int alertGroupId);
|
||||
|
||||
|
||||
/**
|
||||
* query all alert group list
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "groupName", column = "group_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "groupType", column = "group_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = AlertType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = AlertGroupMapperProvider.class, method = "queryAllGroupList")
|
||||
List<AlertGroup> queryAllGroupList();
|
||||
|
||||
/**
|
||||
* count alert group
|
||||
* @param searchVal
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = AlertGroupMapperProvider.class, method = "countAlertGroupPaging")
|
||||
Integer countAlertGroupPaging(@Param("searchVal") String searchVal);
|
||||
|
||||
/**
|
||||
* query alert groups paging
|
||||
* @param searchVal
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "groupName", column = "group_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "groupType", column = "group_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = AlertType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = AlertGroupMapperProvider.class, method = "queryAlertGroupPaging")
|
||||
List<AlertGroup> queryAlertGroupPaging(@Param("searchVal") String searchVal,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("pageSize") Integer pageSize);
|
||||
|
||||
/**
|
||||
* query alert group by user id
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "groupName", column = "group_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "groupType", column = "group_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = AlertType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = AlertGroupMapperProvider.class, method = "queryByUserId")
|
||||
List<AlertGroup> queryByUserId(@Param("userId") int userId);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* query alert group by name
|
||||
* @param groupName
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "groupName", column = "group_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "groupType", column = "group_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = AlertType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = AlertGroupMapperProvider.class, method = "queryByGroupName")
|
||||
AlertGroup queryByGroupName(@Param("groupName") String groupName);
|
||||
}
|
@ -0,0 +1,194 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.AlertType;
|
||||
import cn.escheduler.common.utils.EnumFieldUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* alert group mapper provider
|
||||
*/
|
||||
public class AlertGroupMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_alertgroup";
|
||||
|
||||
/**
|
||||
* insert one alert group
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
VALUES("`group_name`", "#{alertGroup.groupName}");
|
||||
VALUES("`group_type`", EnumFieldUtil.genFieldStr("alertGroup.groupType", AlertType.class));
|
||||
VALUES("`desc`", "#{alertGroup.desc}");
|
||||
VALUES("`create_time`", "#{alertGroup.createTime}");
|
||||
VALUES("`update_time`", "#{alertGroup.updateTime}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete alert group by id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String delete(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id`=#{id}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update alert group
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`group_name`=#{alertGroup.groupName}");
|
||||
SET("`group_type`="+EnumFieldUtil.genFieldStr("alertGroup.groupType", AlertType.class));
|
||||
SET("`desc`=#{alertGroup.desc}");
|
||||
SET("`update_time`=#{alertGroup.updateTime}");
|
||||
|
||||
WHERE("`id`=#{alertGroup.id}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query alert group by id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryById(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id` = #{alertGroupId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query all alert group list
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryAllGroupList(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
ORDER_BY( "update_time desc");
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* count alert group by search key
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countAlertGroupPaging(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("count(0)");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " group_name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query alert group list paging by search key
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryAlertGroupPaging(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " group_name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
ORDER_BY(" update_time desc limit #{offset},#{pageSize} ");
|
||||
}
|
||||
}.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query alert group by user id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByUserId(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("g.*");
|
||||
|
||||
FROM(TABLE_NAME + " g,t_escheduler_relation_user_alertgroup rel");
|
||||
|
||||
WHERE("rel.alertgroup_id = g.id and rel.user_id = #{userId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query alert group by name
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByGroupName(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("group_name = #{groupName}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.AlertStatus;
|
||||
import cn.escheduler.common.enums.AlertType;
|
||||
import cn.escheduler.common.enums.ShowType;
|
||||
import cn.escheduler.dao.model.Alert;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.EnumOrdinalTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface AlertMapper {
|
||||
|
||||
/**
|
||||
* insert alert information
|
||||
* @param alert
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = AlertMapperProvider.class, method = "insert")
|
||||
@Options(useGeneratedKeys = true,keyProperty = "alert.id")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "alert.id", before = false, resultType = int.class)
|
||||
int insert(@Param("alert") Alert alert);
|
||||
|
||||
|
||||
/**
|
||||
* query alert list by status
|
||||
* @param alertStatus
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "title", column = "title", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "showType", column = "show_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = ShowType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "content", column = "content", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "alertType", column = "alert_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = AlertType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "alertStatus", column = "alert_status", typeHandler = EnumOrdinalTypeHandler.class, javaType = AlertStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "log", column = "log", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "alertGroupId", column = "alertgroup_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "receivers", column = "receivers", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "receiversCc", column = "receivers_cc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = AlertMapperProvider.class, method = "queryAlertByStatus")
|
||||
List<Alert> queryAlertByStatus(@Param("alertStatus") AlertStatus alertStatus);
|
||||
|
||||
|
||||
/**
|
||||
* update alert information
|
||||
* @param alertStatus
|
||||
* @param log
|
||||
* @param updateTime
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = AlertMapperProvider.class, method = "update")
|
||||
int update(@Param("alertStatus") AlertStatus alertStatus,@Param("log") String log,
|
||||
@Param("updateTime") Date updateTime,@Param("id") int id);
|
||||
|
||||
/**
|
||||
* delete by alert id
|
||||
* @param alertId
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = AlertMapperProvider.class, method = "deleteById")
|
||||
int delete(@Param("alertId") int alertId);
|
||||
|
||||
/**
|
||||
* list alert information by field alertStatus
|
||||
* @param alertStatus
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "title", column = "title", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "showType", column = "show_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = ShowType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "content", column = "content", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "alertType", column = "alert_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = AlertType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "alertStatus", column = "alert_status", typeHandler = EnumOrdinalTypeHandler.class, javaType = AlertStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "log", column = "log", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "alertGroupId", column = "alertgroup_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "receivers", column = "receivers", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "receiversCc", column = "receivers_cc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = AlertMapperProvider.class, method = "listAlertByStatus")
|
||||
List<Alert> listAlertByStatus(@Param("alertStatus") AlertStatus alertStatus);
|
||||
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.AlertStatus;
|
||||
import cn.escheduler.common.enums.AlertType;
|
||||
import cn.escheduler.common.enums.ShowType;
|
||||
import cn.escheduler.common.utils.EnumFieldUtil;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AlertMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_alert";
|
||||
|
||||
/**
|
||||
* 插入告警信息
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
VALUES("`title`", "#{alert.title}");
|
||||
VALUES("`show_type`", EnumFieldUtil.genFieldStr("alert.showType", ShowType.class));
|
||||
VALUES("`content`", "#{alert.content}");
|
||||
VALUES("`alert_type`", EnumFieldUtil.genFieldStr("alert.alertType", AlertType.class));
|
||||
VALUES("`alertgroup_id`", "#{alert.alertGroupId}");
|
||||
VALUES("`receivers`", "#{alert.receivers}");
|
||||
VALUES("`receivers_cc`", "#{alert.receiversCc}");
|
||||
VALUES("`create_time`", "#{alert.createTime}");
|
||||
VALUES("`update_time`", "#{alert.updateTime}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据告警状态查询
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryAlertByStatus(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`alert_status` = "+EnumFieldUtil.genFieldStr("alertStatus", AlertStatus.class));
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete by id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String deleteById(Map<String, Object> parameter){
|
||||
|
||||
return new SQL() {
|
||||
{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
WHERE("`id`=#{alertId}");
|
||||
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新消息信息
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
SET("`alert_status`="+EnumFieldUtil.genFieldStr("alertStatus", AlertType.class));
|
||||
SET("`log`=#{log}");
|
||||
SET("`update_time`=#{updateTime}");
|
||||
|
||||
WHERE("`id` = #{id}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* list alert information by field alertStatus
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String listAlertByStatus(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`alert_status` = "+EnumFieldUtil.genFieldStr("alertStatus", AlertStatus.class));
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.*;
|
||||
import cn.escheduler.dao.model.Command;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.EnumOrdinalTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* command mapper
|
||||
*/
|
||||
public interface CommandMapper {
|
||||
|
||||
/**
|
||||
* inert command
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = CommandMapperProvider.class, method = "insert")
|
||||
@Options(useGeneratedKeys = true,keyProperty = "command.id")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "command.id", before = false, resultType = int.class)
|
||||
int insert(@Param("command") Command command);
|
||||
|
||||
|
||||
/**
|
||||
* delete command
|
||||
* @param cmdId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = CommandMapperProvider.class, method = "delete")
|
||||
int delete(@Param("cmdId") int cmdId);
|
||||
|
||||
|
||||
/**
|
||||
* update command
|
||||
*
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = CommandMapperProvider.class, method = "update")
|
||||
int update(@Param("command") Command command);
|
||||
|
||||
|
||||
/**
|
||||
* query a command that can run normally
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "commandType", column = "command_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = CommandType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "executorId", column = "executor_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "commandParam", column = "command_param", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskDependType", column = "task_depend_type", javaType = TaskDependType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", javaType = FailureStrategy.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", javaType = WarningType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "scheduleTime", column = "schedule_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = CommandMapperProvider.class, method = "queryOneCommand")
|
||||
Command queryOneCommand();
|
||||
|
||||
|
||||
/**
|
||||
* query all commands
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "commandType", column = "command_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = CommandType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "executorId", column = "executor_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "commandParam", column = "command_param", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskDependType", column = "task_depend_type", javaType = TaskDependType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", javaType = FailureStrategy.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", javaType = WarningType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "scheduleTime", column = "schedule_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = CommandMapperProvider.class, method = "queryAllCommand")
|
||||
List<Command> queryAllCommand();
|
||||
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.*;
|
||||
import cn.escheduler.common.utils.EnumFieldUtil;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* command mapper provider
|
||||
*/
|
||||
public class CommandMapperProvider {
|
||||
private static final String TABLE_NAME = "t_escheduler_command";
|
||||
private static final String DEFINE_TABLE_NAME = "t_escheduler_process_definition";
|
||||
|
||||
/**
|
||||
* inert command
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
VALUES("`command_type`", EnumFieldUtil.genFieldStr("command.commandType", CommandType.class));
|
||||
VALUES("`process_definition_id`", "#{command.processDefinitionId}");
|
||||
VALUES("`executor_id`", "#{command.executorId}");
|
||||
VALUES("`command_param`", "#{command.commandParam}");
|
||||
VALUES("`task_depend_type`", EnumFieldUtil.genFieldStr("command.taskDependType", TaskDependType.class));
|
||||
VALUES("`failure_strategy`", EnumFieldUtil.genFieldStr("command.failureStrategy", FailureStrategy.class));
|
||||
VALUES("`warning_type`", EnumFieldUtil.genFieldStr("command.warningType", WarningType.class));
|
||||
VALUES("`process_instance_priority`", EnumFieldUtil.genFieldStr("command.processInstancePriority", Priority.class));
|
||||
VALUES("`warning_group_id`", "#{command.warningGroupId}");
|
||||
VALUES("`schedule_time`", "#{command.scheduleTime}");
|
||||
VALUES("`update_time`", "#{command.updateTime}");
|
||||
VALUES("`start_time`", "#{command.startTime}");
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete command
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String delete(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id`=#{cmdId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update command
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`command_type`=" + EnumFieldUtil.genFieldStr("command.commandType", CommandType.class));
|
||||
SET("`process_definition_id`=#{command.processDefinitionId}");
|
||||
SET("`executor_id`=#{command.executorId}");
|
||||
SET("`command_param`=#{command.commandParam}");
|
||||
SET("`task_depend_type`="+ EnumFieldUtil.genFieldStr("command.taskDependType", TaskDependType.class));
|
||||
SET("`failure_strategy`="+ EnumFieldUtil.genFieldStr("command.failureStrategy", FailureStrategy.class));
|
||||
SET("`warning_type`="+ EnumFieldUtil.genFieldStr("command.warningType", WarningType.class));
|
||||
SET("`process_instance_priority`="+ EnumFieldUtil.genFieldStr("command.processInstancePriority", Priority.class));
|
||||
SET("`warning_group_id`=#{command.warningGroupId}");
|
||||
SET("`schedule_time`=#{command.scheduleTime}");
|
||||
SET("`update_time`=#{command.updateTime}");
|
||||
SET("`start_time`=#{command.startTime}");
|
||||
|
||||
WHERE("`id`=#{command.id}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query a command that can run normally
|
||||
* command must be release on line, usable.
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryOneCommand(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("cmd.*,process_define.id as process_definition_id");
|
||||
|
||||
FROM(TABLE_NAME + " cmd");
|
||||
|
||||
JOIN( DEFINE_TABLE_NAME + " process_define ON cmd.process_definition_id = process_define.id");
|
||||
WHERE("process_define.release_state =1 AND process_define.flag = 1");
|
||||
ORDER_BY("update_time asc");
|
||||
|
||||
|
||||
}
|
||||
}.toString() + " limit 1";
|
||||
}
|
||||
|
||||
/**
|
||||
* query all commands
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryAllCommand(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("cmd.*");
|
||||
|
||||
FROM(TABLE_NAME + " cmd");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,219 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.DbType;
|
||||
import cn.escheduler.dao.model.DataSource;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.EnumOrdinalTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* data source mapper
|
||||
*/
|
||||
public interface DataSourceMapper {
|
||||
/**
|
||||
* insert data source
|
||||
*
|
||||
* @param dataSource
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = DataSourceMapperProvider.class, method = "insert")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID() as id", resultType = Integer.class, keyProperty = "dataSource.id", before = false)
|
||||
int insert(@Param("dataSource") DataSource dataSource);
|
||||
|
||||
/**
|
||||
* update data source
|
||||
*
|
||||
* @param dataSource
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = DataSourceMapperProvider.class, method = "update")
|
||||
int update(@Param("dataSource") DataSource dataSource);
|
||||
|
||||
/**
|
||||
* delete data source by id
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = DataSourceMapperProvider.class, method = "deleteDataSourceById")
|
||||
int deleteDataSourceById(@Param("id") int id);
|
||||
|
||||
/**
|
||||
* query data source list by type
|
||||
* @param userId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "note", column = "note", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = DbType.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "connectionParams", column = "connection_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = DataSourceMapperProvider.class, method = "queryDataSourceByType")
|
||||
List<DataSource> queryDataSourceByType(@Param("userId") int userId, @Param("type") Integer type);
|
||||
|
||||
/**
|
||||
* query data source by id
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "note", column = "note", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = DbType.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "projectId", column = "project_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "projectName", column = "project_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connectionParams", column = "connection_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = DataSourceMapperProvider.class, method = "queryById")
|
||||
DataSource queryById(@Param("id") Integer id);
|
||||
|
||||
/**
|
||||
* count data source by user id
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = DataSourceMapperProvider.class, method = "countUserDatasource")
|
||||
int countUserDatasource(@Param("userId") int userId);
|
||||
|
||||
/**
|
||||
* count data source number
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = DataSourceMapperProvider.class, method = "countAllDatasource")
|
||||
int countAllDatasource();
|
||||
|
||||
/**
|
||||
* query data source list paging
|
||||
*
|
||||
* @param userId
|
||||
* @param searchVal
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "note", column = "note", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = DbType.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "connectionParams", column = "connection_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = DataSourceMapperProvider.class, method = "queryDataSourcePaging")
|
||||
List<DataSource> queryDataSourcePaging(@Param("userId") int userId, @Param("searchVal") String searchVal,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize);
|
||||
|
||||
/**
|
||||
* query data source list paging
|
||||
*
|
||||
* @param searchVal
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "note", column = "note", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = DbType.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "connectionParams", column = "connection_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = DataSourceMapperProvider.class, method = "queryAllDataSourcePaging")
|
||||
List<DataSource> queryAllDataSourcePaging(@Param("searchVal") String searchVal,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize);
|
||||
|
||||
/**
|
||||
* query data source by name
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "note", column = "note", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = DbType.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "connectionParams", column = "connection_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = DataSourceMapperProvider.class, method = "queryDataSourceByName")
|
||||
List<DataSource> queryDataSourceByName(@Param("name") String name);
|
||||
|
||||
/**
|
||||
* authed data source to user
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "note", column = "note", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = DbType.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "connectionParams", column = "connection_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = DataSourceMapperProvider.class, method = "authedDatasource")
|
||||
List<DataSource> authedDatasource(@Param("userId") int userId);
|
||||
|
||||
|
||||
/**
|
||||
* query data source except user
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "note", column = "note", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = DbType.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "connectionParams", column = "connection_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = DataSourceMapperProvider.class, method = "queryDatasourceExceptUserId")
|
||||
List<DataSource> queryDatasourceExceptUserId(@Param("userId") int userId);
|
||||
|
||||
}
|
@ -0,0 +1,231 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.DbType;
|
||||
import cn.escheduler.common.utils.EnumFieldUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* data source mapper provider
|
||||
*/
|
||||
public class DataSourceMapperProvider {
|
||||
|
||||
public static final String TABLE_NAME = "t_escheduler_datasource";
|
||||
public static final String USER_TABLE_NAME = "t_escheduler_user";
|
||||
public static final String PROJECT_TABLE_NAME = "t_escheduler_project";
|
||||
public static final String USER_DATASOURCE_RELATION_TABLE_NAME = "t_escheduler_relation_datasource_user";
|
||||
|
||||
/**
|
||||
* insert data source
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
|
||||
VALUES("`name`", "#{dataSource.name}");
|
||||
VALUES("`note`", "#{dataSource.note}");
|
||||
VALUES("`type`", EnumFieldUtil.genFieldStr("dataSource.type", DbType.class));
|
||||
VALUES("`user_id`", "#{dataSource.userId}");
|
||||
VALUES("`connection_params`", "#{dataSource.connectionParams}");
|
||||
VALUES("`create_time`", "#{dataSource.createTime}");
|
||||
VALUES("`update_time`", "#{dataSource.updateTime}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* update data source
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`name` = #{dataSource.name}");
|
||||
SET("`note` = #{dataSource.note}");
|
||||
SET("`user_id` = #{dataSource.userId}");
|
||||
SET("`type` = "+ EnumFieldUtil.genFieldStr("dataSource.type", DbType.class));
|
||||
SET("`connection_params` = #{dataSource.connectionParams}");
|
||||
SET("`update_time` = #{dataSource.updateTime}");
|
||||
|
||||
WHERE("`id` = #{dataSource.id}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete datasource by id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String deleteDataSourceById(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id` = #{id}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query datasource list by type
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryDataSourceByType(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME );
|
||||
WHERE("type = #{type}");
|
||||
WHERE("id in (select datasource_id from "+USER_DATASOURCE_RELATION_TABLE_NAME+" where user_id=#{userId} union select id as datasource_id from "+TABLE_NAME+" where user_id=#{userId})");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query data source by id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryById(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("r.*,u.user_name as userName");
|
||||
|
||||
FROM(TABLE_NAME + " r");
|
||||
|
||||
JOIN(new MessageFormat("{0} as u on u.id = r.user_id").format(new Object[]{USER_TABLE_NAME}));
|
||||
|
||||
WHERE("r.id = #{id}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query data source paging
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryDataSourcePaging(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME );
|
||||
WHERE("id in (select datasource_id from "+USER_DATASOURCE_RELATION_TABLE_NAME+" where user_id=#{userId} union select id as datasource_id from "+TABLE_NAME+" where user_id=#{userId})");
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
ORDER_BY("update_time desc limit #{offset},#{pageSize} ");
|
||||
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* query data source list paging
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryAllDataSourcePaging(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME );
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
ORDER_BY("update_time desc limit #{offset},#{pageSize} ");
|
||||
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* count data source by user id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countUserDatasource(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("count(0)");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("id in (select datasource_id from "+USER_DATASOURCE_RELATION_TABLE_NAME+" where user_id=#{userId} union select id as datasource_id from "+TABLE_NAME+" where user_id=#{userId})");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询总的数据源数目
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countAllDatasource(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("count(0)");
|
||||
FROM(TABLE_NAME);
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query data source by name
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryDataSourceByName(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME );
|
||||
WHERE("name = #{name}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* authed data source to user
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String authedDatasource(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("d.*");
|
||||
FROM(TABLE_NAME + " d,t_escheduler_relation_datasource_user rel");
|
||||
WHERE(" d.id = rel.datasource_id AND rel.user_id = #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query data source except user
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryDatasourceExceptUserId(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("user_id <> #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.dao.model.DatasourceUser;
|
||||
import org.apache.ibatis.annotations.DeleteProvider;
|
||||
import org.apache.ibatis.annotations.InsertProvider;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* data source user relation mapper
|
||||
*/
|
||||
public interface DatasourceUserMapper {
|
||||
/**
|
||||
* insert data source user relation
|
||||
*
|
||||
* @param datasourceUser
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = DatasourceUserMapperProvider.class, method = "insert")
|
||||
int insert(@Param("datasourceUser") DatasourceUser datasourceUser);
|
||||
|
||||
|
||||
/**
|
||||
* delete data source user relation by user id
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = DatasourceUserMapperProvider.class, method = "deleteByUserId")
|
||||
int deleteByUserId(@Param("userId") int userId);
|
||||
|
||||
/**
|
||||
* delete by data source id
|
||||
* @param datasourceId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = DatasourceUserMapperProvider.class, method = "deleteByDatasourceId")
|
||||
int deleteByDatasourceId(@Param("datasourceId") int datasourceId);
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.escheduler.dao.mapper;
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class DatasourceUserMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_relation_datasource_user";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
|
||||
VALUES("`datasource_id`", "#{datasourceUser.datasourceId}");
|
||||
VALUES("`user_id`", "#{datasourceUser.userId}");
|
||||
VALUES("`perm`", "#{datasourceUser.perm}");
|
||||
VALUES("`create_time`", "#{datasourceUser.createTime}");
|
||||
VALUES("`update_time`", "#{datasourceUser.updateTime}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String deleteByUserId(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`user_id` = #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String deleteByDatasourceId(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`datasource_id` = #{datasourceId}");
|
||||
}}.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.dao.model.MasterServer;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface MasterServerMapper {
|
||||
|
||||
/**
|
||||
* query all masters
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "port", column = "port", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "zkDirectory", column = "zk_directory", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "resInfo", column = "res_info", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "lastHeartbeatTime", column = "last_heartbeat_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP)
|
||||
})
|
||||
@SelectProvider(type = MasterServerMapperProvider.class, method = "queryAllMaster")
|
||||
List<MasterServer> queryAllMaster();
|
||||
|
||||
/**
|
||||
* insert one master
|
||||
*
|
||||
* @param masterServer
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = MasterServerMapperProvider.class, method = "insert")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID() as id", resultType = Integer.class, keyProperty = "masterServer.id", before = false)
|
||||
int insert(@Param("masterServer") MasterServer masterServer);
|
||||
|
||||
/**
|
||||
* update master
|
||||
*
|
||||
* @param masterServer
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = MasterServerMapperProvider.class, method = "update")
|
||||
int update(@Param("masterServer") MasterServer masterServer);
|
||||
|
||||
/**
|
||||
* delete master
|
||||
*/
|
||||
@DeleteProvider(type = MasterServerMapperProvider.class, method = "delete")
|
||||
void delete();
|
||||
|
||||
/**
|
||||
* delete master by host
|
||||
*
|
||||
* @param host
|
||||
*/
|
||||
@DeleteProvider(type = MasterServerMapperProvider.class, method = "deleteWorkerByHost")
|
||||
int deleteWorkerByHost(@Param("host") String host);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class MasterServerMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_master_server";
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String queryAllMaster() {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
|
||||
VALUES("host", "#{masterServer.host}");
|
||||
VALUES("port", "#{masterServer.port}");
|
||||
VALUES("zk_directory", "#{masterServer.zkDirectory}");
|
||||
VALUES("res_info", "#{masterServer.resInfo}");
|
||||
VALUES("create_time", "#{masterServer.createTime}");
|
||||
VALUES("last_heartbeat_time", "#{masterServer.lastHeartbeatTime}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("last_heartbeat_time = #{masterServer.lastHeartbeatTime}");
|
||||
SET("port = #{masterServer.port}");
|
||||
SET("res_info = #{masterServer.resInfo}");
|
||||
|
||||
WHERE("host = #{masterServer.host}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String delete() {
|
||||
return new SQL() {{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String deleteWorkerByHost(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("host = #{host}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,248 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.Flag;
|
||||
import cn.escheduler.common.enums.ReleaseState;
|
||||
import cn.escheduler.common.enums.UserType;
|
||||
import cn.escheduler.dao.model.DefinitionGroupByUser;
|
||||
import cn.escheduler.dao.model.ProcessDefinition;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.EnumOrdinalTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* process definition mapper
|
||||
*/
|
||||
public interface ProcessDefinitionMapper {
|
||||
|
||||
/**
|
||||
* insert process define
|
||||
* @param processDefinition
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = ProcessDefinitionMapperProvider.class, method = "insert")
|
||||
@Options(useGeneratedKeys = true,keyProperty = "processDefinition.id")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "processDefinition.id", before = false, resultType = int.class)
|
||||
int insert(@Param("processDefinition") ProcessDefinition processDefinition);
|
||||
|
||||
|
||||
/**
|
||||
* delete process define
|
||||
* @param processDefinitionId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = ProcessDefinitionMapperProvider.class, method = "delete")
|
||||
int delete(@Param("processDefinitionId") int processDefinitionId);
|
||||
|
||||
|
||||
/**
|
||||
* update process define
|
||||
*
|
||||
* @param processDefinition
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = ProcessDefinitionMapperProvider.class, method = "update")
|
||||
int update(@Param("processDefinition") ProcessDefinition processDefinition);
|
||||
|
||||
/**
|
||||
* update release state
|
||||
* @param processDefinitionId
|
||||
* @param releaseState
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = ProcessDefinitionMapperProvider.class, method = "updateProcessDefinitionReleaseState")
|
||||
int updateProcessDefinitionReleaseState(@Param("processDefinitionId") int processDefinitionId,
|
||||
@Param("releaseState") ReleaseState releaseState);
|
||||
|
||||
|
||||
/**
|
||||
* query definition by id
|
||||
* @param processDefinitionId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "version", column = "version", javaType = Integer.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "releaseState", column = "release_state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ReleaseState.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "projectId", column = "project_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionJson", column = "process_definition_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "globalParams", column = "global_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "flag", column = "flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "locations", column = "locations", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connects", column = "connects", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "projectName", column = "project_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "receivers", column = "receivers", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "receiversCc", column = "receivers_cc", javaType = String.class, jdbcType = JdbcType.VARCHAR)
|
||||
|
||||
})
|
||||
@SelectProvider(type = ProcessDefinitionMapperProvider.class, method = "queryByDefineId")
|
||||
ProcessDefinition queryByDefineId(@Param("processDefinitionId") int processDefinitionId);
|
||||
|
||||
/**
|
||||
* query process definition by project id and name
|
||||
* @param projectId
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "version", column = "version", javaType = Integer.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "releaseState", column = "release_state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ReleaseState.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "projectId", column = "project_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionJson", column = "process_definition_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "flag", column = "flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "locations", column = "locations", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connects", column = "connects", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "projectName", column = "project_name", javaType = String.class, jdbcType = JdbcType.VARCHAR)
|
||||
})
|
||||
@SelectProvider(type = ProcessDefinitionMapperProvider.class, method = "queryByDefineName")
|
||||
ProcessDefinition queryByDefineName(@Param("projectId") int projectId,
|
||||
@Param("processDefinitionName") String name);
|
||||
|
||||
|
||||
/**
|
||||
* count definition number
|
||||
* @param projectId
|
||||
* @param userId
|
||||
* @param searchVal
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = ProcessDefinitionMapperProvider.class, method = "countDefineNumber")
|
||||
Integer countDefineNumber(@Param("projectId") int projectId,
|
||||
@Param("userId") int userId,
|
||||
@Param("searchVal") String searchVal
|
||||
);
|
||||
|
||||
/**
|
||||
* query all definition list
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "version", column = "version", javaType = Integer.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "releaseState", column = "release_state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ReleaseState.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "projectId", column = "project_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "flag", column = "flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "projectName", column = "project_name", javaType = String.class, jdbcType = JdbcType.VARCHAR)
|
||||
})
|
||||
@SelectProvider(type = ProcessDefinitionMapperProvider.class, method = "queryAllDefinitionList")
|
||||
List<ProcessDefinition> queryAllDefinitionList(@Param("projectId") int projectId);
|
||||
|
||||
/**
|
||||
* query definition list paging
|
||||
* @param projectId
|
||||
* @param searchVal
|
||||
* @param userId
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "version", column = "version", javaType = Integer.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "releaseState", column = "release_state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ReleaseState.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "projectId", column = "project_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "flag", column = "flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "scheduleReleaseState", column = "schedule_release_state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ReleaseState.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "projectName", column = "project_name", javaType = String.class, jdbcType = JdbcType.VARCHAR)
|
||||
})
|
||||
@SelectProvider(type = ProcessDefinitionMapperProvider.class, method = "queryDefineListPaging")
|
||||
List<ProcessDefinition> queryDefineListPaging(@Param("projectId") int projectId,
|
||||
@Param("searchVal") String searchVal,
|
||||
@Param("userId") Integer userId,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize);
|
||||
|
||||
/**
|
||||
* query definition list by define id list
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "version", column = "version", javaType = Integer.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "releaseState", column = "release_state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ReleaseState.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "projectId", column = "project_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionJson", column = "process_definition_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "flag", column = "flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "locations", column = "locations", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connects", column = "connects", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "projectName", column = "project_name", javaType = String.class, jdbcType = JdbcType.VARCHAR)
|
||||
})
|
||||
@SelectProvider(type = ProcessDefinitionMapperProvider.class, method = "queryDefinitionListByIdList")
|
||||
List<ProcessDefinition> queryDefinitionListByIdList(@Param("ids") List<String> ids);
|
||||
|
||||
/**
|
||||
* count definition number group by users
|
||||
* @param userId
|
||||
* @param userType
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "count", column = "count", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
})
|
||||
@SelectProvider(type = ProcessDefinitionMapperProvider.class, method = "countDefinitionGroupByUser")
|
||||
List<DefinitionGroupByUser> countDefinitionGroupByUser(
|
||||
@Param("userId") Integer userId,
|
||||
@Param("userType") UserType userType,
|
||||
@Param("projectId") Integer projectId);
|
||||
|
||||
/**
|
||||
* update receivers and cc by definition id
|
||||
* @param receivers
|
||||
* @param receiversCc
|
||||
* @param processDefinitionId
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = ProcessDefinitionMapperProvider.class, method = "updateReceiversAndCcById")
|
||||
int updateReceiversAndCcById(@Param("receivers") String receivers,
|
||||
@Param("receiversCc") String receiversCc,
|
||||
@Param("processDefinitionId") int processDefinitionId);
|
||||
}
|
@ -0,0 +1,292 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.Flag;
|
||||
import cn.escheduler.common.enums.ReleaseState;
|
||||
import cn.escheduler.common.utils.EnumFieldUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* process definition mapper provider
|
||||
*/
|
||||
public class ProcessDefinitionMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_process_definition";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 插入流程定义
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
VALUES("`name`", "#{processDefinition.name}");
|
||||
VALUES("`version`", "#{processDefinition.version}");
|
||||
VALUES("`release_state`", EnumFieldUtil.genFieldStr("processDefinition.releaseState", ReleaseState.class));
|
||||
VALUES("`project_id`", "#{processDefinition.projectId}");
|
||||
VALUES("`process_definition_json`", "#{processDefinition.processDefinitionJson}");
|
||||
VALUES("`desc`", "#{processDefinition.desc}");
|
||||
VALUES("`global_params`", "#{processDefinition.globalParams}");
|
||||
VALUES("`locations`", "#{processDefinition.locations}");
|
||||
VALUES("`connects`", "#{processDefinition.connects}");
|
||||
VALUES("`create_time`", "#{processDefinition.createTime}");
|
||||
VALUES("`update_time`", "#{processDefinition.updateTime}");
|
||||
VALUES("`flag`", EnumFieldUtil.genFieldStr("processDefinition.flag", ReleaseState.class));
|
||||
VALUES("`user_id`", "#{processDefinition.userId}");
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流程定义
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String delete(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id`=#{processDefinitionId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新流程定义
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`name`=#{processDefinition.name}");
|
||||
SET("`version`=#{processDefinition.version}");
|
||||
SET("`release_state`="+EnumFieldUtil.genFieldStr("processDefinition.releaseState", ReleaseState.class));
|
||||
SET("`project_id`=#{processDefinition.projectId}");
|
||||
SET("`process_definition_json`=#{processDefinition.processDefinitionJson}");
|
||||
SET("`desc`=#{processDefinition.desc}");
|
||||
SET("`locations`=#{processDefinition.locations}");
|
||||
SET("`connects`=#{processDefinition.connects}");
|
||||
SET("`global_params`=#{processDefinition.globalParams}");
|
||||
SET("`create_time`=#{processDefinition.createTime}");
|
||||
SET("`update_time`=#{processDefinition.updateTime}");
|
||||
SET("`flag`="+EnumFieldUtil.genFieldStr("processDefinition.flag", Flag.class));
|
||||
SET("`user_id`=#{processDefinition.userId}");
|
||||
|
||||
WHERE("`id`=#{processDefinition.id}");
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
public String updateProcessDefinitionReleaseState(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`release_state`="+EnumFieldUtil.genFieldStr("releaseState", ReleaseState.class));
|
||||
|
||||
|
||||
WHERE("`id`=#{processDefinitionId}");
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据流程定义 id 查询 sql
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByDefineId(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("pd.*,u.user_name,p.name as projectName");
|
||||
|
||||
FROM(TABLE_NAME + " pd");
|
||||
JOIN("t_escheduler_user u ON pd.user_id = u.id");
|
||||
JOIN("t_escheduler_project p ON pd.project_id = p.id");
|
||||
WHERE("pd.id = #{processDefinitionId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query By Define Name
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByDefineName(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("pd.*,u.user_name,p.name as project_name,t.tenant_code,t.tenant_name,q.queue,q.queue_name");
|
||||
|
||||
FROM(TABLE_NAME + " pd");
|
||||
JOIN("t_escheduler_user u ON pd.user_id = u.id");
|
||||
JOIN("t_escheduler_project p ON pd.project_id = p.id");
|
||||
JOIN("t_escheduler_tenant t ON t.id = u.tenant_id");
|
||||
JOIN("t_escheduler_queue q ON t.queue_id = q.id");
|
||||
WHERE("p.id = #{projectId}");
|
||||
WHERE("pd.name = #{processDefinitionName}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query define list paging
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryDefineListPaging(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("td.id,td.name,td.version,td.release_state,td.project_id,td.user_id,td.`desc`,td.create_time,td.update_time,td.flag,td.global_params,td.receivers,td.receivers_cc,sc.schedule_release_state");
|
||||
FROM(TABLE_NAME + " td");
|
||||
LEFT_OUTER_JOIN(" (select process_definition_id,release_state as schedule_release_state from `t_escheduler_schedules` " +
|
||||
"group by `process_definition_id`,`release_state`) sc on sc.process_definition_id = td.id");
|
||||
|
||||
WHERE("td.project_id = #{projectId} ");
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " td.name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
Object userId = parameter.get("userId");
|
||||
if(userId != null && 0 != Integer.parseInt(userId.toString())){
|
||||
WHERE("td.user_id = #{userId}");
|
||||
}
|
||||
ORDER_BY(" td.update_time desc limit #{offset},#{pageSize} ");
|
||||
}}.toString();
|
||||
}
|
||||
/**
|
||||
* query all define list by project id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryAllDefinitionList(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("id,name,version,release_state,project_id,user_id,`desc`,create_time,update_time,flag,global_params,receivers,receivers_cc");
|
||||
|
||||
FROM(TABLE_NAME );
|
||||
|
||||
WHERE("project_id = #{projectId}");
|
||||
ORDER_BY("create_time desc ");
|
||||
}}.toString();
|
||||
}
|
||||
/**
|
||||
* count definition number group by project id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countDefineNumber(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("count(0)");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("project_id = #{projectId}");
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
Object userId = parameter.get("userId");
|
||||
if(userId != null && 0 != Integer.parseInt(userId.toString())){
|
||||
WHERE("user_id = #{userId}");
|
||||
}
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* count definition number by user type
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countDefinitionGroupByUser(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
|
||||
SELECT("td.user_id as user_id, tu.user_name as user_name, count(0) as count");
|
||||
FROM(TABLE_NAME + " td");
|
||||
JOIN("t_escheduler_user tu on tu.id=td.user_id");
|
||||
|
||||
if(parameter.get("projectId") != null && (int)parameter.get("projectId") != 0){
|
||||
WHERE( "td.project_id = #{projectId} ");
|
||||
}else{
|
||||
if(parameter.get("userType") != null && String.valueOf(parameter.get("userType")) == "GENERAL_USER") {
|
||||
AND();
|
||||
WHERE("td.project_id in (select id as project_id from t_escheduler_project tp where tp.user_id= #{userId} " +
|
||||
"union select project_id from t_escheduler_relation_project_user tr where tr.user_id= #{userId} )");
|
||||
|
||||
}
|
||||
}
|
||||
GROUP_BY("td.user_id");
|
||||
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query definition list by define id list
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryDefinitionListByIdList(Map<String, Object> parameter){
|
||||
List<String> ids = (List<String>) parameter.get("ids");
|
||||
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id` in (" + String.join(",", ids) + ")");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update receivers and cc by definition id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String updateReceiversAndCcById(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
SET("`receivers`=#{receivers}");
|
||||
SET("`receivers_cc`=#{receiversCc}");
|
||||
WHERE("`id`=#{processDefinitionId}");
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.dao.model.ProcessInstanceMap;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
/**
|
||||
* work process instance map mapper
|
||||
*/
|
||||
public interface ProcessInstanceMapMapper {
|
||||
|
||||
/**
|
||||
* insert process instance relation
|
||||
* @param processInstanceMap
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = ProcessInstanceMapMapperProvider.class, method = "insert")
|
||||
@Options(useGeneratedKeys = true,keyProperty = "processInstanceMap.id")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "processInstanceMap.id", before = false, resultType = int.class)
|
||||
int insert(@Param("processInstanceMap") ProcessInstanceMap processInstanceMap);
|
||||
|
||||
|
||||
/**
|
||||
* delete process instance relation by id
|
||||
* @param processInstanceMapId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = ProcessInstanceMapMapperProvider.class, method = "delete")
|
||||
int delete(@Param("processInstanceMapId") int processInstanceMapId);
|
||||
|
||||
/**
|
||||
* delete process instance relation by parent work process id
|
||||
* @param parentProcessId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = ProcessInstanceMapMapperProvider.class, method = "deleteByParentProcessId")
|
||||
int deleteByParentProcessId(@Param("parentProcessId") int parentProcessId);
|
||||
|
||||
/**
|
||||
* update process instance relation
|
||||
*
|
||||
* @param processInstanceMap
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = ProcessInstanceMapMapperProvider.class, method = "update")
|
||||
int update(@Param("processInstanceMap") ProcessInstanceMap processInstanceMap);
|
||||
|
||||
/**
|
||||
* query process instance relation by id
|
||||
* @param processMapId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "parentProcessInstanceId", column = "parent_process_instance_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "parentTaskInstanceId", column = "parent_task_instance_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstanceId", column = "process_instance_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER)
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapMapperProvider.class, method = "queryById")
|
||||
ProcessInstanceMap queryById(@Param("processMapId") int processMapId);
|
||||
|
||||
/**
|
||||
* query by parent instance id
|
||||
* @param parentProcessId
|
||||
* @param parentTaskId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "parentProcessInstanceId", column = "parent_process_instance_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "parentTaskInstanceId", column = "parent_task_instance_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstanceId", column = "process_instance_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER)
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapMapperProvider.class, method = "queryByParentId")
|
||||
ProcessInstanceMap queryByParentId(@Param("parentProcessId") int parentProcessId, @Param("parentTaskId") int parentTaskId);
|
||||
|
||||
/**
|
||||
* query relation by sub process id
|
||||
* @param subProcessId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "parentProcessInstanceId", column = "parent_process_instance_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "parentTaskInstanceId", column = "parent_task_instance_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstanceId", column = "process_instance_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER)
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapMapperProvider.class, method = "queryBySubProcessId")
|
||||
ProcessInstanceMap queryBySubProcessId(@Param("subProcessId")Integer subProcessId);
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* process instance map mapper provider
|
||||
*/
|
||||
public class ProcessInstanceMapMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_relation_process_instance";
|
||||
|
||||
/**
|
||||
* insert process instance relation
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
VALUES("`parent_process_instance_id`", "#{processInstanceMap.parentProcessInstanceId}");
|
||||
VALUES("`parent_task_instance_id`", "#{processInstanceMap.parentTaskInstanceId}");
|
||||
VALUES("`process_instance_id`", "#{processInstanceMap.processInstanceId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete process instance relation
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String delete(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id`=#{processInstanceMapId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete by parent process id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String deleteByParentProcessId(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`parent_process_instance_id`=#{parentProcessId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update process map
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`parent_process_instance_id`=#{processInstanceMap.parentProcessInstanceId}");
|
||||
SET("`parent_task_instance_id`=#{processInstanceMap.parentTaskInstanceId}");
|
||||
SET("`process_instance_id`=#{processInstanceMap.processInstanceId}");
|
||||
WHERE("`id`=#{processInstanceMap.id}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query by map id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryById(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id` = #{processMapId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query by parent process instance id and parent task id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByParentId(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("`parent_process_instance_id` = #{parentProcessId}");
|
||||
WHERE("`parent_task_instance_id` = #{parentTaskId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query by sub process instance id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryBySubProcessId(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("`process_instance_id` = #{subProcessId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,614 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.*;
|
||||
import cn.escheduler.dao.model.ExecuteStatusCount;
|
||||
import cn.escheduler.dao.model.ProcessInstance;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.EnumOrdinalTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* process instance mapper
|
||||
*/
|
||||
public interface ProcessInstanceMapper {
|
||||
|
||||
/**
|
||||
* insert process instance
|
||||
* @param processInstance
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = ProcessInstanceMapperProvider.class, method = "insert")
|
||||
@Options(useGeneratedKeys = true,keyProperty = "processInstance.id")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "processInstance.id", before = false, resultType = int.class)
|
||||
int insert(@Param("processInstance") ProcessInstance processInstance);
|
||||
|
||||
|
||||
/**
|
||||
* delete process instance
|
||||
* @param processId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = ProcessInstanceMapperProvider.class, method = "delete")
|
||||
int delete(@Param("processId") int processId);
|
||||
|
||||
/**
|
||||
* update process instance
|
||||
*
|
||||
* @param processInstance
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = ProcessInstanceMapperProvider.class, method = "update")
|
||||
int update(@Param("processInstance") ProcessInstance processInstance);
|
||||
|
||||
|
||||
/**
|
||||
* query instance detail by id
|
||||
* @param processId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "recovery", column = "recovery", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "runTimes", column = "run_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "commandType", column = "command_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = CommandType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "commandParam", column = "command_param", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskDependType", column = "task_depend_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = TaskDependType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "maxTryTimes", column = "max_try_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", javaType = WarningType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "scheduleTime", column = "schedule_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "commandStartTime", column = "command_start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "globalParams", column = "global_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executorId", column = "executor_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstanceJson", column = "process_instance_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "isSubProcess", column = "is_sub_process", javaType = Flag.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "locations", column = "locations", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connects", column = "connects", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "historyCmd", column = "history_cmd", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "dependenceScheduleTimes", column = "dependence_schedule_times", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "duration", column = "duration", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "tenantCode", column = "tenant_code", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapperProvider.class, method = "queryDetailById")
|
||||
ProcessInstance queryDetailById(@Param("processId") int processId);
|
||||
|
||||
|
||||
/**
|
||||
* query instance by id
|
||||
* @param processId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "recovery", column = "recovery", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "runTimes", column = "run_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "commandType", column = "command_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = CommandType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "commandParam", column = "command_param", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskDependType", column = "task_depend_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = TaskDependType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "maxTryTimes", column = "max_try_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", javaType = WarningType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "scheduleTime", column = "schedule_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "commandStartTime", column = "command_start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "globalParams", column = "global_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executorId", column = "executor_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstanceJson", column = "process_instance_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "isSubProcess", column = "is_sub_process", javaType = Flag.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "locations", column = "locations", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connects", column = "connects", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "historyCmd", column = "history_cmd", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "dependenceScheduleTimes", column = "dependence_schedule_times", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapperProvider.class, method = "queryById")
|
||||
ProcessInstance queryById(@Param("processId") int processId);
|
||||
|
||||
/**
|
||||
* query instance list by host and state array
|
||||
* @param host
|
||||
* @param stateArray
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "recovery", column = "recovery", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "runTimes", column = "run_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "commandType", column = "command_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = CommandType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "commandParam", column = "command_param", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskDependType", column = "task_depend_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = TaskDependType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "maxTryTimes", column = "max_try_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", javaType = WarningType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "scheduleTime", column = "schedule_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "commandStartTime", column = "command_start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "globalParams", column = "global_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executorId", column = "executor_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "isSubProcess", column = "is_sub_process", javaType = Flag.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "locations", column = "locations", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connects", column = "connects", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "historyCmd", column = "history_cmd", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "dependenceScheduleTimes", column = "dependence_schedule_times", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstanceJson", column = "process_instance_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapperProvider.class, method = "queryByHostAndStatus")
|
||||
List<ProcessInstance> queryByHostAndStatus(@Param("host") String host, @Param("states")int[] stateArray);
|
||||
|
||||
/**
|
||||
* query instance list by state array
|
||||
* @param stateArray
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "recovery", column = "recovery", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "runTimes", column = "run_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "commandType", column = "command_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = CommandType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "commandParam", column = "command_param", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskDependType", column = "task_depend_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = TaskDependType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "maxTryTimes", column = "max_try_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", javaType = WarningType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "scheduleTime", column = "schedule_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "commandStartTime", column = "command_start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "globalParams", column = "global_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executorId", column = "executor_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "isSubProcess", column = "is_sub_process", javaType = Flag.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "locations", column = "locations", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connects", column = "connects", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "historyCmd", column = "history_cmd", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "dependenceScheduleTimes", column = "dependence_schedule_times", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstanceJson", column = "process_instance_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapperProvider.class, method = "listByStatus")
|
||||
List<ProcessInstance> listByStatus(@Param("states")int[] stateArray);
|
||||
|
||||
/**
|
||||
* query list paging
|
||||
*
|
||||
* @param projectId
|
||||
* @param processDefinitionId
|
||||
* @param searchVal
|
||||
* @param statusArray
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "recovery", column = "recovery", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "runTimes", column = "run_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "commandType", column = "command_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = CommandType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "commandParam", column = "command_param", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskDependType", column = "task_depend_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = TaskDependType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "maxTryTimes", column = "max_try_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", javaType = WarningType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "scheduleTime", column = "schedule_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "commandStartTime", column = "command_start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "globalParams", column = "global_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executorId", column = "executor_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "isSubProcess", column = "is_sub_process", javaType = Flag.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "locations", column = "locations", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connects", column = "connects", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "historyCmd", column = "history_cmd", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "dependenceScheduleTimes", column = "dependence_schedule_times", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "duration", column = "duration", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "processInstanceJson", column = "process_instance_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapperProvider.class, method = "queryProcessInstanceListPaging")
|
||||
List<ProcessInstance> queryProcessInstanceListPaging(@Param("projectId") int projectId,
|
||||
@Param("processDefinitionId") Integer processDefinitionId,
|
||||
@Param("searchVal") String searchVal,
|
||||
@Param("states")String statusArray,
|
||||
@Param("host")String host,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize);
|
||||
|
||||
/**
|
||||
* count process numbers
|
||||
* @param projectId
|
||||
* @param processDefinitionId
|
||||
* @param statusArray
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @param searchVal
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = ProcessInstanceMapperProvider.class, method = "countProcessInstance")
|
||||
Integer countProcessInstance(@Param("projectId") int projectId,
|
||||
@Param("processDefinitionId") Integer processDefinitionId,
|
||||
@Param("states")String statusArray,
|
||||
@Param("host")String host,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime,
|
||||
@Param("searchVal") String searchVal
|
||||
);
|
||||
|
||||
/**
|
||||
* update process instance by host and status
|
||||
* @param host
|
||||
* @param stateArray
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = ProcessInstanceMapperProvider.class, method = "setFailoverByHostAndStateArray")
|
||||
int setFailoverByHostAndStateArray(@Param("host") String host,@Param("states")int[] stateArray);
|
||||
|
||||
/**
|
||||
* update process instance by state
|
||||
* @param originState
|
||||
* @param destState
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = ProcessInstanceMapperProvider.class, method = "updateProcessInstanceByState")
|
||||
int updateProcessInstanceByState(@Param("originState")ExecutionStatus originState, @Param("destState")ExecutionStatus destState);
|
||||
|
||||
/**
|
||||
* update state
|
||||
* @param processId
|
||||
* @param executionStatus
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = ProcessInstanceMapperProvider.class, method = "updateState")
|
||||
int updateState(@Param("processId")Integer processId, @Param("executionStatus")ExecutionStatus executionStatus);
|
||||
|
||||
|
||||
/**
|
||||
* query process instance by task id
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "recovery", column = "recovery", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "runTimes", column = "run_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "commandType", column = "command_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = CommandType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "commandParam", column = "command_param", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskDependType", column = "task_depend_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = TaskDependType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "maxTryTimes", column = "max_try_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", javaType = WarningType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "scheduleTime", column = "schedule_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "commandStartTime", column = "command_start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "globalParams", column = "global_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executorId", column = "executor_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "isSubProcess", column = "is_sub_process", javaType = Flag.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "locations", column = "locations", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connects", column = "connects", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "historyCmd", column = "history_cmd", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "duration", column = "duration", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "dependenceScheduleTimes", column = "dependence_schedule_times", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "duration", column = "duration", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "processInstanceJson", column = "process_instance_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapperProvider.class, method = "queryByTaskId")
|
||||
ProcessInstance queryByTaskId(@Param("taskId") int taskId);
|
||||
|
||||
|
||||
/**
|
||||
* update process instance
|
||||
* @param processId
|
||||
* @param processJson
|
||||
* @param globalParams
|
||||
* @param scheduleTime
|
||||
* @param locations
|
||||
* @param connects
|
||||
* @param flag
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = ProcessInstanceMapperProvider.class, method = "updateProcessInstance")
|
||||
int updateProcessInstance(@Param("processId") Integer processId,
|
||||
@Param("processJson") String processJson,
|
||||
@Param("globalParams") String globalParams,
|
||||
@Param("scheduleTime") Date scheduleTime,
|
||||
@Param("locations") String locations,
|
||||
@Param("connects") String connects,
|
||||
@Param("flag") Flag flag);
|
||||
|
||||
/**
|
||||
* count process number group by state and user
|
||||
* @param userId
|
||||
* @param userType
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "count", column = "count", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapperProvider.class, method = "countInstanceStateByUser")
|
||||
List<ExecuteStatusCount> countInstanceStateByUser(
|
||||
@Param("userId") int userId,
|
||||
@Param("userType") UserType userType,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime,
|
||||
@Param("projectId") int projectId);
|
||||
|
||||
/**
|
||||
* query sub process id list by father process instance id
|
||||
*
|
||||
* @param parentInstanceId
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = ProcessInstanceMapperProvider.class, method = "querySubIdListByParentId")
|
||||
List<Integer> querySubIdListByParentId(@Param("parentInstanceId") int parentInstanceId);
|
||||
|
||||
/**
|
||||
* query instance by definition id
|
||||
* @param processDefinitionId
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "recovery", column = "recovery", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "runTimes", column = "run_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "commandType", column = "command_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = CommandType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "commandParam", column = "command_param", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskDependType", column = "task_depend_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = TaskDependType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "maxTryTimes", column = "max_try_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", javaType = WarningType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "scheduleTime", column = "schedule_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "commandStartTime", column = "command_start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "globalParams", column = "global_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executorId", column = "executor_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "isSubProcess", column = "is_sub_process", javaType = Flag.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "locations", column = "locations", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connects", column = "connects", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "historyCmd", column = "history_cmd", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "duration", column = "duration", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "dependenceScheduleTimes", column = "dependence_schedule_times", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "duration", column = "duration", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "processInstanceJson", column = "process_instance_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapperProvider.class, method = "queryByProcessDefineId")
|
||||
List<ProcessInstance> queryByProcessDefineId(@Param("processDefinitionId") int processDefinitionId,@Param("size") int size);
|
||||
|
||||
|
||||
/**
|
||||
* query process instance by definition and scheduler time
|
||||
* @param processDefinitionId
|
||||
* @param scheduleTime
|
||||
* @param excludeId
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "recovery", column = "recovery", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "runTimes", column = "run_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "commandType", column = "command_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = CommandType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "commandParam", column = "command_param", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskDependType", column = "task_depend_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = TaskDependType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "maxTryTimes", column = "max_try_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", javaType = WarningType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "scheduleTime", column = "schedule_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "commandStartTime", column = "command_start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "globalParams", column = "global_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executorId", column = "executor_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "isSubProcess", column = "is_sub_process", javaType = Flag.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "locations", column = "locations", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connects", column = "connects", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "historyCmd", column = "history_cmd", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "dependenceScheduleTimes", column = "dependence_schedule_times", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "duration", column = "duration", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "processInstanceJson", column = "process_instance_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapperProvider.class, method = "queryByScheduleTime")
|
||||
ProcessInstance queryByScheduleTime(@Param("processDefinitionId") int processDefinitionId,
|
||||
@Param("scheduleTime") String scheduleTime,
|
||||
@Param("excludeId") int excludeId,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
/**
|
||||
* get last scheduler process intance between start time and end time
|
||||
* @param definitionId
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "recovery", column = "recovery", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "runTimes", column = "run_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "commandType", column = "command_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = CommandType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "commandParam", column = "command_param", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskDependType", column = "task_depend_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = TaskDependType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "maxTryTimes", column = "max_try_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", javaType = WarningType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "scheduleTime", column = "schedule_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "commandStartTime", column = "command_start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "globalParams", column = "global_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executorId", column = "executor_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "isSubProcess", column = "is_sub_process", javaType = Flag.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "locations", column = "locations", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connects", column = "connects", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "historyCmd", column = "history_cmd", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "dependenceScheduleTimes", column = "dependence_schedule_times", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstanceJson", column = "process_instance_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapperProvider.class, method = "queryLastSchedulerProcess")
|
||||
ProcessInstance queryLastSchedulerProcess(@Param("processDefinitionId") int definitionId,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
/**
|
||||
* get last running process instance between start time and end time
|
||||
* @param definitionId
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "recovery", column = "recovery", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "runTimes", column = "run_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "commandType", column = "command_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = CommandType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "commandParam", column = "command_param", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskDependType", column = "task_depend_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = TaskDependType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "maxTryTimes", column = "max_try_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", javaType = WarningType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "scheduleTime", column = "schedule_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "commandStartTime", column = "command_start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "globalParams", column = "global_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executorId", column = "executor_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "isSubProcess", column = "is_sub_process", javaType = Flag.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "locations", column = "locations", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connects", column = "connects", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "historyCmd", column = "history_cmd", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "dependenceScheduleTimes", column = "dependence_schedule_times", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstanceJson", column = "process_instance_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapperProvider.class, method = "queryLastRunningProcess")
|
||||
ProcessInstance queryLastRunningProcess(@Param("processDefinitionId") int definitionId,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime,
|
||||
@Param("states")int[] stateArray);
|
||||
|
||||
/**
|
||||
* get last manual process instance between start time and end time
|
||||
* @param definitionId
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "recovery", column = "recovery", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "runTimes", column = "run_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "commandType", column = "command_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = CommandType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "commandParam", column = "command_param", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskDependType", column = "task_depend_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = TaskDependType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "maxTryTimes", column = "max_try_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", javaType = WarningType.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "scheduleTime", column = "schedule_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "commandStartTime", column = "command_start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "globalParams", column = "global_params", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executorId", column = "executor_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "isSubProcess", column = "is_sub_process", javaType = Flag.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "locations", column = "locations", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "connects", column = "connects", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "historyCmd", column = "history_cmd", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "dependenceScheduleTimes", column = "dependence_schedule_times", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstanceJson", column = "process_instance_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = ProcessInstanceMapperProvider.class, method = "queryLastManualProcess")
|
||||
ProcessInstance queryLastManualProcess(@Param("processDefinitionId") int definitionId,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
}
|
@ -0,0 +1,582 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.*;
|
||||
import cn.escheduler.common.utils.EnumFieldUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* process instance mapper provider
|
||||
*/
|
||||
public class ProcessInstanceMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_process_instance";
|
||||
private static final String TABLE_NAME_MAP = "t_escheduler_relation_process_instance";
|
||||
private static final String DEFINE_TABLE_NAME = "t_escheduler_process_definition";
|
||||
|
||||
/**
|
||||
* insert process instance
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
VALUES("`process_definition_id`", "#{processInstance.processDefinitionId}");
|
||||
VALUES("`state`", EnumFieldUtil.genFieldStr("processInstance.state", ExecutionStatus.class));
|
||||
VALUES("`recovery`", EnumFieldUtil.genFieldStr("processInstance.recovery", Flag.class));
|
||||
VALUES("`start_time`", "#{processInstance.startTime}");
|
||||
VALUES("`end_time`", "#{processInstance.endTime}");
|
||||
VALUES("`run_times`", "#{processInstance.runTimes}");
|
||||
VALUES("`name`", "#{processInstance.name}");
|
||||
VALUES("`host`", "#{processInstance.host}");
|
||||
VALUES("`command_type`", EnumFieldUtil.genFieldStr("processInstance.commandType", CommandType.class));
|
||||
VALUES("`command_param`", "#{processInstance.commandParam}");
|
||||
VALUES("`task_depend_type`", EnumFieldUtil.genFieldStr("processInstance.taskDependType", TaskDependType.class));
|
||||
VALUES("`max_try_times`", "#{processInstance.maxTryTimes}");
|
||||
VALUES("`failure_strategy`", EnumFieldUtil.genFieldStr("processInstance.failureStrategy", FailureStrategy.class));
|
||||
VALUES("`warning_type`", EnumFieldUtil.genFieldStr("processInstance.warningType", WarningType.class));
|
||||
VALUES("`warning_group_id`", "#{processInstance.warningGroupId}");
|
||||
VALUES("`schedule_time`", "#{processInstance.scheduleTime}");
|
||||
VALUES("`command_start_time`", "#{processInstance.commandStartTime}");
|
||||
VALUES("`global_params`", "#{processInstance.globalParams}");
|
||||
VALUES("`process_instance_json`", "#{processInstance.processInstanceJson}");
|
||||
VALUES("`locations`", "#{processInstance.locations}");
|
||||
VALUES("`connects`", "#{processInstance.connects}");
|
||||
VALUES("`history_cmd`", "#{processInstance.historyCmd}");
|
||||
VALUES("`dependence_schedule_times`", "#{processInstance.dependenceScheduleTimes}");
|
||||
VALUES("`is_sub_process`", EnumFieldUtil.genFieldStr("processInstance.isSubProcess", Flag.class));
|
||||
VALUES("`executor_id`", "#{processInstance.executorId}");
|
||||
VALUES("`process_instance_priority`", EnumFieldUtil.genFieldStr("processInstance.processInstancePriority", Priority.class));
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete process instance
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String delete(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
WHERE("id=#{processId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据父工作流id查询子工作流list
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String querySubIdListByParentId(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT( "process_instance_id");
|
||||
FROM(TABLE_NAME_MAP);
|
||||
WHERE("parent_process_instance_id = #{parentInstanceId}" );
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新流程实例
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`process_definition_id`=#{processInstance.processDefinitionId}");
|
||||
SET("`state`="+EnumFieldUtil.genFieldStr("processInstance.state", ExecutionStatus.class));
|
||||
SET("`recovery`="+EnumFieldUtil.genFieldStr("processInstance.recovery", Flag.class));
|
||||
SET("`start_time`=#{processInstance.startTime}");
|
||||
SET("`end_time`=#{processInstance.endTime}");
|
||||
SET("`run_times`=#{processInstance.runTimes}");
|
||||
SET("`name`=#{processInstance.name}");
|
||||
SET("`host`=#{processInstance.host}");
|
||||
SET("`command_type`="+EnumFieldUtil.genFieldStr("processInstance.commandType", CommandType.class));
|
||||
SET("`command_param`=#{processInstance.commandParam}");
|
||||
SET("`task_depend_type`="+EnumFieldUtil.genFieldStr("processInstance.taskDependType", TaskDependType.class));
|
||||
SET("`max_try_times`=#{processInstance.maxTryTimes}");
|
||||
SET("`failure_strategy`="+EnumFieldUtil.genFieldStr("processInstance.failureStrategy", FailureStrategy.class));
|
||||
SET("`warning_type`="+ EnumFieldUtil.genFieldStr("processInstance.warningType", WarningType.class));
|
||||
SET("`warning_group_id`=#{processInstance.warningGroupId}");
|
||||
SET("`schedule_time`=#{processInstance.scheduleTime}");
|
||||
SET("`command_start_time`=#{processInstance.commandStartTime}");
|
||||
SET("`process_instance_json`=#{processInstance.processInstanceJson}");
|
||||
SET("`global_params`=#{processInstance.globalParams}");
|
||||
SET("`locations`=#{processInstance.locations}");
|
||||
SET("`connects`=#{processInstance.connects}");
|
||||
SET("`history_cmd`=#{processInstance.historyCmd}");
|
||||
SET("`dependence_schedule_times`=#{processInstance.dependenceScheduleTimes}");
|
||||
SET("`is_sub_process`="+EnumFieldUtil.genFieldStr("processInstance.isSubProcess", Flag.class));
|
||||
SET("`executor_id`=#{processInstance.executorId}");
|
||||
|
||||
WHERE("`id`=#{processInstance.id}");
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
public String updateProcessInstance(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
if(parameter.get("flag") != null){
|
||||
SET("`flag`="+ EnumFieldUtil.genFieldStr("flag", Flag.class));
|
||||
}
|
||||
|
||||
if(parameter.get("scheduleTime") != null){
|
||||
SET("`schedule_time`=#{scheduleTime}");
|
||||
}
|
||||
|
||||
if(parameter.get("processJson") != null){
|
||||
SET("`process_instance_json`=#{processJson}");
|
||||
SET("`global_params`=#{globalParams}");
|
||||
}
|
||||
if(parameter.get("locations") != null){
|
||||
SET("`locations`=#{locations}");
|
||||
}
|
||||
if(parameter.get("connects") != null){
|
||||
SET("`connects`=#{connects}");
|
||||
}
|
||||
WHERE("`id`=#{processId}");
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update process instance by state
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String updateProcessInstanceByState(Map<String, Object> parameter) {
|
||||
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`state`=" + EnumFieldUtil.genFieldStr("destState", ExecutionStatus.class));
|
||||
WHERE("`state`=" + EnumFieldUtil.genFieldStr("originState", ExecutionStatus.class));
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update state
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String updateState(Map<String, Object> parameter) {
|
||||
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`state`=" + EnumFieldUtil.genFieldStr("executionStatus", ExecutionStatus.class));
|
||||
WHERE("`id`=#{processId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query detail by id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryDetailById(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("inst.*,q.queue_name as queue,t.tenant_code as tenantCode,UNIX_TIMESTAMP(inst.end_time)-UNIX_TIMESTAMP(inst.start_time) as duration");
|
||||
|
||||
FROM(TABLE_NAME + " inst, t_escheduler_user u,t_escheduler_tenant t,t_escheduler_queue q");
|
||||
|
||||
WHERE("inst.executor_id = u.id AND u.tenant_id = t.id AND t.queue_id = q.id AND inst.id = #{processId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query by id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryById(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME );
|
||||
|
||||
WHERE("`id` = #{processId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query list paging
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryProcessInstanceListPaging(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("instance.*, (UNIX_TIMESTAMP(instance.end_time) - UNIX_TIMESTAMP(instance.start_time)) as duration");
|
||||
|
||||
FROM(TABLE_NAME + " instance");
|
||||
|
||||
JOIN(DEFINE_TABLE_NAME + " define ON instance.process_definition_id = define.id");
|
||||
|
||||
if(parameter.get("processDefinitionId") != null && (int)parameter.get("processDefinitionId") != 0){
|
||||
WHERE( "instance.process_definition_id = #{processDefinitionId} ");
|
||||
}
|
||||
|
||||
WHERE("instance.is_sub_process=0 and define.project_id = #{projectId}");
|
||||
|
||||
Object start = parameter.get("startTime");
|
||||
if(start != null && StringUtils.isNotEmpty(start.toString())){
|
||||
WHERE("instance.start_time > #{startTime} and instance.start_time <= #{endTime}");
|
||||
}
|
||||
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " instance.name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
Object states = parameter.get("states");
|
||||
if(states != null && StringUtils.isNotEmpty(states.toString())){
|
||||
String stateStr = states.toString();
|
||||
WHERE("instance.state in ( "+ stateStr + " )");
|
||||
}
|
||||
Object host = parameter.get("host");
|
||||
if(host != null && StringUtils.isNotEmpty(host.toString())){
|
||||
WHERE( "instance.host like concat('%', #{host}, '%') ");
|
||||
}
|
||||
ORDER_BY("instance.start_time desc limit #{offset},#{pageSize} ");
|
||||
}
|
||||
}.toString();
|
||||
|
||||
}
|
||||
|
||||
public String countProcessInstance(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("count(1)");
|
||||
FROM(TABLE_NAME + " instance");
|
||||
JOIN(DEFINE_TABLE_NAME + " define ON instance.process_definition_id = define.id");
|
||||
WHERE(" define.project_id = #{projectId}");
|
||||
if(parameter.get("processDefinitionId") != null && (int)parameter.get("processDefinitionId") != 0){
|
||||
WHERE( "instance.process_definition_id = #{processDefinitionId} ");
|
||||
}
|
||||
WHERE(" instance.is_sub_process=0");
|
||||
Object startTime = parameter.get("startTime");
|
||||
if(startTime != null && StringUtils.isNotEmpty(startTime.toString())) {
|
||||
WHERE("instance.start_time > #{startTime} and instance.start_time <= #{endTime}");
|
||||
}
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " instance.name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
Object states = parameter.get("states");
|
||||
if(states != null && StringUtils.isNotEmpty(states.toString())){
|
||||
String stateStr = states.toString();
|
||||
WHERE("instance.state in ( "+ stateStr + " )");
|
||||
}
|
||||
Object host = parameter.get("host");
|
||||
if(host != null && StringUtils.isNotEmpty(host.toString())){
|
||||
WHERE( "instance.host like concat('%', #{host}, '%') ");
|
||||
}
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
public String countInstanceStateByUser(Map<String, Object> parameter){
|
||||
return new SQL(){
|
||||
{
|
||||
SELECT ("state, count(0) as count");
|
||||
FROM(TABLE_NAME + " t");
|
||||
JOIN(DEFINE_TABLE_NAME + " d on d.id=t.process_definition_id");
|
||||
JOIN("t_escheduler_project p on p.id=d.project_id");
|
||||
WHERE("t.flag = 1 and t.is_sub_process = 0");
|
||||
WHERE("t.start_time > #{startTime} and t.start_time <= #{endTime}");
|
||||
if(parameter.get("projectId") != null && (int)parameter.get("projectId") != 0){
|
||||
WHERE( "p.id = #{projectId} ");
|
||||
}else{
|
||||
if(parameter.get("userType") != null && String.valueOf(parameter.get("userType")) == "GENERAL_USER") {
|
||||
AND();
|
||||
WHERE(" p.id in (select project_id as id from `t_escheduler_relation_project_user` where user_id=#{userId} \n" +
|
||||
"union select id as id from `t_escheduler_project` where user_id =#{userId})");
|
||||
}
|
||||
}
|
||||
GROUP_BY("t.state");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* list all processes by status
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String listByStatus(Map<String, Object> parameter) {
|
||||
StringBuffer strStates = new StringBuffer();
|
||||
int[] stateArray = (int[]) parameter.get("states");
|
||||
|
||||
for(int i=0;i<stateArray.length;i++){
|
||||
strStates.append(stateArray[i]);
|
||||
if(i<stateArray.length-1){
|
||||
strStates.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
return new SQL() {
|
||||
{
|
||||
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`state` in (" + strStates.toString() +")");
|
||||
ORDER_BY("`id` asc");
|
||||
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query all processes by host and status
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByHostAndStatus(Map<String, Object> parameter) {
|
||||
StringBuffer strStates = new StringBuffer();
|
||||
int[] stateArray = (int[]) parameter.get("states");
|
||||
|
||||
for(int i=0;i<stateArray.length;i++){
|
||||
strStates.append(stateArray[i]);
|
||||
if(i<stateArray.length-1){
|
||||
strStates.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
return new SQL() {
|
||||
{
|
||||
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`host` = #{host} and `state` in (" + strStates.toString() +")");
|
||||
ORDER_BY("`id` asc");
|
||||
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* update host to null by host and status
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String setFailoverByHostAndStateArray(Map<String, Object> parameter) {
|
||||
StringBuffer strStates = new StringBuffer();
|
||||
int[] stateArray = (int[]) parameter.get("states");
|
||||
|
||||
for(int i=0;i<stateArray.length;i++){
|
||||
strStates.append(stateArray[i]);
|
||||
if(i<stateArray.length-1){
|
||||
strStates.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
String strResult = new SQL() {
|
||||
{
|
||||
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`host`=null");
|
||||
|
||||
WHERE("`host` = #{host} and `state` in (" + strStates.toString() + ")");
|
||||
}
|
||||
}.toString();
|
||||
|
||||
|
||||
return new SQL() {
|
||||
{
|
||||
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`host`=null");
|
||||
|
||||
WHERE("`host` = #{host} and `state` in (" + strStates.toString() + ")");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* query by task id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByTaskId(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("process.*, UNIX_TIMESTAMP(process.end_time)-UNIX_TIMESTAMP(process.start_time) as duration");
|
||||
|
||||
FROM(TABLE_NAME + " process");
|
||||
|
||||
JOIN("t_escheduler_task_instance task");
|
||||
|
||||
WHERE("task.process_instance_id = process.id");
|
||||
|
||||
WHERE("task.id=#{taskId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query instance by definition id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByProcessDefineId(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*,UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time) as duration");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("process_definition_id=#{processDefinitionId}");
|
||||
ORDER_BY("start_time desc limit #{size}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query process instance by definition and scheduler time
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByScheduleTime(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*,UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time) as duration");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("process_definition_id=#{processDefinitionId} ");
|
||||
if(parameter.get("scheduleTime") != null){
|
||||
WHERE("schedule_time=#{scheduleTime}");
|
||||
}
|
||||
if(parameter.get("startTime") != null && parameter.get("endTime")!= null){
|
||||
WHERE("command_start_time between #{startTime} and #{endTime}");
|
||||
}
|
||||
if(parameter.get("excludeId") != null && Integer.parseInt(parameter.get("excludeId").toString())!= 0){
|
||||
WHERE(" id not in ( #{excludeId}) ");
|
||||
}
|
||||
ORDER_BY("start_time desc limit 1");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
public String queryLastSchedulerProcess(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("process_definition_id=#{processDefinitionId} ");
|
||||
if(parameter.get("startTime") != null && parameter.get("endTime") != null){
|
||||
WHERE("schedule_time between #{startTime} and #{endTime}");
|
||||
}
|
||||
|
||||
ORDER_BY("end_time desc limit 1");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
public String queryLastManualProcess(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("process_definition_id=#{processDefinitionId} ");
|
||||
if(parameter.get("startTime") != null && parameter.get("endTime") != null){
|
||||
WHERE("start_time between #{startTime} and #{endTime}");
|
||||
WHERE("`schedule_time` is null");
|
||||
}
|
||||
ORDER_BY("end_time desc limit 1");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
public String queryLastRunningProcess(Map<String, Object> parameter) {
|
||||
StringBuffer strStates = new StringBuffer();
|
||||
int[] stateArray = (int[]) parameter.get("states");
|
||||
|
||||
for(int i=0;i<stateArray.length;i++){
|
||||
strStates.append(stateArray[i]);
|
||||
if(i<stateArray.length-1){
|
||||
strStates.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("process_definition_id=#{processDefinitionId} ");
|
||||
if(parameter.get("startTime") != null && parameter.get("endTime") != null
|
||||
){
|
||||
WHERE("schedule_time between #{startTime} and #{endTime} " +
|
||||
"or start_time between #{startTime} and #{endTime}");
|
||||
}
|
||||
WHERE("`state` in (" + strStates.toString() + ")");
|
||||
ORDER_BY("start_time desc limit 1");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,190 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.dao.model.Project;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* project mapper
|
||||
*/
|
||||
public interface ProjectMapper {
|
||||
|
||||
/**
|
||||
* insert project
|
||||
* @param project
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = ProjectMapperProvider.class, method = "insert")
|
||||
@Options(useGeneratedKeys = true,keyProperty = "project.id")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "project.id", before = false, resultType = int.class)
|
||||
int insert(@Param("project") Project project);
|
||||
|
||||
|
||||
/**
|
||||
* delete project
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = ProjectMapperProvider.class, method = "delete")
|
||||
int delete(@Param("projectId") int projectId);
|
||||
|
||||
|
||||
/**
|
||||
* update project
|
||||
*
|
||||
* @param project
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = ProjectMapperProvider.class, method = "update")
|
||||
int update(@Param("project") Project project);
|
||||
|
||||
|
||||
/**
|
||||
* query project by name
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
})
|
||||
@SelectProvider(type = ProjectMapperProvider.class, method = "queryByName")
|
||||
Project queryByName(@Param("name") String name);
|
||||
|
||||
/**
|
||||
* query project by id
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
})
|
||||
@SelectProvider(type = ProjectMapperProvider.class, method = "queryById")
|
||||
Project queryById(@Param("projectId") Integer projectId);
|
||||
|
||||
/**
|
||||
* count project by user id and search value
|
||||
* @param userId
|
||||
* @param searchVal
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = ProjectMapperProvider.class, method = "countProjects")
|
||||
Integer countProjects(@Param("userId") Integer userId,
|
||||
@Param("searchVal") String searchVal
|
||||
);
|
||||
|
||||
/**
|
||||
* query project list paging
|
||||
* @param userId
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @param searchVal
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "perm", column = "perm", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
})
|
||||
@SelectProvider(type = ProjectMapperProvider.class, method = "queryProjectListPaging")
|
||||
List<Project> queryProjectListPaging(@Param("userId") Integer userId,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("pageSize") Integer pageSize,
|
||||
@Param("searchVal") String searchVal);
|
||||
|
||||
/**
|
||||
* count all projects
|
||||
* @param searchVal
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = ProjectMapperProvider.class, method = "countAllProjects")
|
||||
Integer countAllProjects(@Param("searchVal") String searchVal);
|
||||
|
||||
/**
|
||||
* query all project list paging
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @param searchVal
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "perm", column = "perm", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
})
|
||||
@SelectProvider(type = ProjectMapperProvider.class, method = "queryAllProjectListPaging")
|
||||
List<Project> queryAllProjectListPaging(
|
||||
@Param("offset") Integer offset,
|
||||
@Param("pageSize") Integer pageSize,
|
||||
@Param("searchVal") String searchVal);
|
||||
|
||||
/**
|
||||
* authed project to user
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "perm", column = "perm", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
})
|
||||
@SelectProvider(type = ProjectMapperProvider.class, method = "authedProject")
|
||||
List<Project> authedProject(@Param("userId") Integer userId);
|
||||
|
||||
/**
|
||||
* query project except user
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "perm", column = "perm", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
})
|
||||
@SelectProvider(type = ProjectMapperProvider.class, method = "queryProjectExceptUserId")
|
||||
List<Project> queryProjectExceptUserId(@Param("userId") Integer userId);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,242 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* project mapper provider
|
||||
*/
|
||||
public class ProjectMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_project";
|
||||
private static final String RELEATION_TABLE_NAME = "t_escheduler_relation_project_user";
|
||||
|
||||
/**
|
||||
* insert project
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
VALUES("`user_id`", "#{project.userId}");
|
||||
VALUES("`name`", "#{project.name}");
|
||||
VALUES("`desc`", "#{project.desc}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete project
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String delete(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
SET("flag=0");
|
||||
WHERE("`id`=#{projectId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update project
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`user_id`=#{project.userId}");
|
||||
SET("`name`=#{project.name}");
|
||||
SET("`desc`=#{project.desc}");
|
||||
SET("`update_time`=#{project.updateTime}");
|
||||
WHERE("`id`=#{project.id}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* query project by id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryById(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("p.user_id");
|
||||
SELECT("u.user_name as userName");
|
||||
SELECT("p.*");
|
||||
|
||||
FROM(TABLE_NAME + " p");
|
||||
|
||||
JOIN("t_escheduler_user u on p.user_id = u.id");
|
||||
|
||||
WHERE("p.id = #{projectId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query project by name
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByName(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("p.user_id");
|
||||
SELECT("u.user_name as userName");
|
||||
SELECT("p.*");
|
||||
|
||||
FROM(TABLE_NAME + " p");
|
||||
|
||||
JOIN("t_escheduler_user u on p.user_id = u.id");
|
||||
|
||||
WHERE("p.name = #{name}");
|
||||
WHERE("p.flag = 1");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* count project by user id and search value
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countProjects(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("count(0)");
|
||||
|
||||
FROM(TABLE_NAME + " p");
|
||||
WHERE("p.id in " +
|
||||
"(select project_id from "+ RELEATION_TABLE_NAME+" where user_id=#{userId} " +
|
||||
"union select id as project_id from "+ TABLE_NAME+" where user_id=#{userId})");
|
||||
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " p.name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
WHERE("p.flag = 1");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query project list paging
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryProjectListPaging(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("p.*");
|
||||
SELECT("u.user_name as user_name");
|
||||
|
||||
FROM(TABLE_NAME + " p");
|
||||
JOIN("t_escheduler_user u on u.id=p.user_id");
|
||||
WHERE("p.id in " +
|
||||
"(select project_id from "+ RELEATION_TABLE_NAME+" where user_id=#{userId} " +
|
||||
"union select id as project_id from "+ TABLE_NAME+" where user_id=#{userId})");
|
||||
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " p.name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
WHERE(" p.flag = 1");
|
||||
ORDER_BY("p.create_time desc limit #{offset},#{pageSize} ");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* count all projects
|
||||
* @return
|
||||
*/
|
||||
public String countAllProjects(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("count(0)");
|
||||
|
||||
FROM(TABLE_NAME );
|
||||
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
WHERE("flag = 1");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query all project list paging
|
||||
* @return
|
||||
*/
|
||||
public String queryAllProjectListPaging(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("p.*");
|
||||
SELECT("u.user_name as user_name");
|
||||
|
||||
FROM(TABLE_NAME + " p");
|
||||
JOIN("t_escheduler_user u on p.user_id = u.id");
|
||||
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " p.name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
WHERE(" p.flag = 1");
|
||||
ORDER_BY("p.create_time desc limit #{offset},#{pageSize} ");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* authed project to user
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String authedProject(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("p.*");
|
||||
FROM(TABLE_NAME + " p,t_escheduler_relation_project_user rel");
|
||||
WHERE(" p.id = rel.project_id AND p.flag = 1 AND rel.user_id = #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query project except user
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryProjectExceptUserId(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("flag = 1 AND user_id <> #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.dao.model.ProjectUser;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* project user relation mapper
|
||||
*/
|
||||
public interface ProjectUserMapper {
|
||||
|
||||
/**
|
||||
* insert project user relation
|
||||
*
|
||||
* @param projectUser
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = ProjectUserMapperProvider.class, method = "insert")
|
||||
int insert(@Param("projectUser") ProjectUser projectUser);
|
||||
|
||||
/**
|
||||
* delete project user relation
|
||||
* @param projectId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = ProjectUserMapperProvider.class, method = "delete")
|
||||
int delete(@Param("projectId") int projectId, @Param("userId") int userId);
|
||||
|
||||
/**
|
||||
* update project user relation
|
||||
*
|
||||
* @param projectUser
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = ProjectUserMapperProvider.class, method = "update")
|
||||
int update(@Param("projectUser") ProjectUser projectUser);
|
||||
|
||||
/**
|
||||
* query project user relation by project id and user id
|
||||
*
|
||||
* @param projectId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "projectId", column = "project_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "projectName", column = "project_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "perm", column = "perm", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP)})
|
||||
@SelectProvider(type = ProjectUserMapperProvider.class, method = "query")
|
||||
ProjectUser query(@Param("projectId") int projectId, @Param("userId") int userId);
|
||||
|
||||
|
||||
/**
|
||||
* delete project relation by user id
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = ProjectUserMapperProvider.class, method = "deleteByUserId")
|
||||
int deleteByUserId(@Param("userId") int userId);
|
||||
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* project user mapper provider
|
||||
*/
|
||||
public class ProjectUserMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_relation_project_user";
|
||||
private static final String USER_TABLE_NAME = "t_escheduler_user";
|
||||
private static final String PROJECT_TABLE_NAME = "t_escheduler_project";
|
||||
|
||||
|
||||
/**
|
||||
* insert project user relation
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
|
||||
VALUES("`project_id`", "#{projectUser.projectId}");
|
||||
VALUES("`user_id`", "#{projectUser.userId}");
|
||||
VALUES("`perm`", "#{projectUser.perm}");
|
||||
VALUES("`create_time`", "#{projectUser.createTime}");
|
||||
VALUES("`update_time`", "#{projectUser.updateTime}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update project user relation
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`perm`=#{projectUser.perm}");
|
||||
SET("`update_time`=#{projectUser.updateTime}");
|
||||
|
||||
WHERE("`project_id` = #{projectUser.projectId}");
|
||||
WHERE("`user_id` = #{projectUser.userId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete project user relation
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String delete(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`project_id` = #{projectId}");
|
||||
WHERE("`user_id` = #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query project user relation by project id and user id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String query(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("p_u.*");
|
||||
SELECT("u.user_name as user_name, p.name as project_name");
|
||||
|
||||
FROM(TABLE_NAME + " p_u");
|
||||
|
||||
JOIN(USER_TABLE_NAME + " u on p_u.user_id = u.id");
|
||||
JOIN(PROJECT_TABLE_NAME + " p on p_u.project_id = p.id");
|
||||
WHERE("p_u.project_id = #{projectId} ");
|
||||
WHERE("p_u.user_id = #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete project relation by user id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String deleteByUserId(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`user_id` = #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.dao.model.Queue;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* queue mapper
|
||||
*/
|
||||
public interface QueueMapper {
|
||||
|
||||
/**
|
||||
* insert queue
|
||||
* @param queue
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = QueueMapperProvider.class, method = "insert")
|
||||
@Options(useGeneratedKeys = true,keyProperty = "queue.id")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "queue.id", before = false, resultType = int.class)
|
||||
int insert(@Param("queue") Queue queue);
|
||||
|
||||
|
||||
/**
|
||||
* delete queue
|
||||
* @param queueId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = QueueMapperProvider.class, method = "delete")
|
||||
int delete(@Param("queueId") int queueId);
|
||||
|
||||
|
||||
/**
|
||||
* update queue
|
||||
*
|
||||
* @param queue
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = QueueMapperProvider.class, method = "update")
|
||||
int update(@Param("queue") Queue queue);
|
||||
|
||||
|
||||
/**
|
||||
* query queue by id
|
||||
* @param queueId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "queueName", column = "queue_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "queue", column = "queue", javaType = String.class, jdbcType = JdbcType.VARCHAR)
|
||||
})
|
||||
@SelectProvider(type = QueueMapperProvider.class, method = "queryById")
|
||||
Queue queryById(@Param("queueId") int queueId);
|
||||
|
||||
|
||||
/**
|
||||
* query all queue list
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "queueName", column = "queue_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "queue", column = "queue", javaType = String.class, jdbcType = JdbcType.VARCHAR)
|
||||
})
|
||||
@SelectProvider(type = QueueMapperProvider.class, method = "queryAllQueue")
|
||||
List<Queue> queryAllQueue();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* queue mapper provider
|
||||
*/
|
||||
public class QueueMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_queue";
|
||||
|
||||
/**
|
||||
* insert queue
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
VALUES("`queue_name`", "#{queue.queueName}");
|
||||
VALUES("`queue`", "#{queue.queue}");
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete queue
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String delete(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id`=#{queueId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update queue
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`queue_name`=#{queue.queueName}");
|
||||
SET("`queue`=#{queue.queue}");
|
||||
|
||||
WHERE("`id`=#{queue.id}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* query queue by id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryById(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id` = #{queueId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query all queue list
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryAllQueue(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,278 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.ResourceType;
|
||||
import cn.escheduler.dao.model.Resource;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.EnumOrdinalTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* resource mapper
|
||||
*/
|
||||
public interface ResourceMapper {
|
||||
|
||||
/**
|
||||
* insert resource
|
||||
*
|
||||
* @param resource
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = ResourceMapperProvider.class, method = "insert")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID() AS id", keyProperty = "resource.id", resultType = int.class, before = false)
|
||||
int insert(@Param("resource") Resource resource);
|
||||
|
||||
/**
|
||||
* query resource by alias
|
||||
*
|
||||
* @param alias
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "alias", column = "alias", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "fileName", column = "file_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = ResourceType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = ResourceMapperProvider.class, method = "queryResource")
|
||||
Resource queryResource(@Param("alias") String alias);
|
||||
|
||||
/**
|
||||
* query resource by name and resource type
|
||||
* @param alias
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "alias", column = "alias", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "fileName", column = "file_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = ResourceType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = ResourceMapperProvider.class, method = "queryResourceByNameAndType")
|
||||
Resource queryResourceByNameAndType(@Param("alias") String alias,@Param("type") int type);
|
||||
|
||||
/**
|
||||
* query resource by id
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "alias", column = "alias", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "fileName", column = "file_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = ResourceType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = ResourceMapperProvider.class, method = "queryResourceById")
|
||||
Resource queryResourceById(@Param("id") int id);
|
||||
|
||||
/**
|
||||
* update resource
|
||||
*
|
||||
* @param resource
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = ResourceMapperProvider.class, method = "update")
|
||||
int update(@Param("resource") Resource resource);
|
||||
|
||||
/**
|
||||
* delete resource
|
||||
*
|
||||
* @param resourceId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = ResourceMapperProvider.class, method = "delete")
|
||||
int delete(@Param("resourceId") int resourceId);
|
||||
|
||||
/**
|
||||
* query resource list that the appointed user has permission
|
||||
* @param userId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "alias", column = "alias", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "fileName", column = "file_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = ResourceType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "size", column = "size", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = ResourceMapperProvider.class, method = "queryResourceListAuthored")
|
||||
List<Resource> queryResourceListAuthored(@Param("userId") int userId, @Param("type") int type);
|
||||
|
||||
/**
|
||||
* query resource list paging by user id
|
||||
* @param userId
|
||||
* @param type
|
||||
* @param searchVal
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "alias", column = "alias", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "fileName", column = "file_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = ResourceType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "size", column = "size", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = ResourceMapperProvider.class, method = "queryResourceAuthoredPaging")
|
||||
List<Resource> queryResourceAuthoredPaging(@Param("userId") int userId, @Param("type") int type,
|
||||
@Param("searchVal") String searchVal,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize);
|
||||
|
||||
/**
|
||||
* query all resource list paging
|
||||
* @param type
|
||||
* @param searchVal
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "alias", column = "alias", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "fileName", column = "file_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = ResourceType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "size", column = "size", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = ResourceMapperProvider.class, method = "queryAllResourceListPaging")
|
||||
List<Resource> queryAllResourceListPaging(@Param("type") int type,
|
||||
@Param("searchVal") String searchVal,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize);
|
||||
|
||||
/**
|
||||
* count resource number by user id
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = ResourceMapperProvider.class, method = "countResourceNumber")
|
||||
int countResourceNumber(@Param("userId") int userId);
|
||||
|
||||
/**
|
||||
* count resource number by user id and type
|
||||
*
|
||||
* @param userId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = ResourceMapperProvider.class, method = "countResourceNumberByType")
|
||||
int countResourceNumberByType(@Param("userId") int userId,@Param("type") int type);
|
||||
|
||||
/**
|
||||
* count resource number by type
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = ResourceMapperProvider.class, method = "countAllResourceNumberByType")
|
||||
int countAllResourceNumberByType(@Param("type") int type);
|
||||
|
||||
/**
|
||||
* query resource list authorized appointed user
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "alias", column = "alias", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "fileName", column = "file_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = ResourceType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "size", column = "size", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = ResourceMapperProvider.class, method = "queryAuthorizedResourceList")
|
||||
List<Resource> queryAuthorizedResourceList(@Param("userId") int userId);
|
||||
|
||||
/**
|
||||
*
|
||||
* query all resource list except user
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "alias", column = "alias", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "fileName", column = "file_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = ResourceType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "size", column = "size", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = ResourceMapperProvider.class, method = "queryResourceExceptUserId")
|
||||
List<Resource> queryResourceExceptUserId(@Param("userId") int userId);
|
||||
|
||||
/**
|
||||
* query resource list that created by the appointed user
|
||||
* @param userId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "alias", column = "alias", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "fileName", column = "file_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = ResourceType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "size", column = "size", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = ResourceMapperProvider.class, method = "queryResourceCreatedByUser")
|
||||
List<Resource> queryResourceCreatedByUser(@Param("userId") int userId, @Param("type") int type);
|
||||
|
||||
|
||||
/**
|
||||
* query tenant code by resource name
|
||||
*
|
||||
* @param resName
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = ResourceMapperProvider.class, method = "queryTenantCodeByResourceName")
|
||||
String queryTenantCodeByResourceName(@Param("resName") String resName);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,297 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.ResourceType;
|
||||
import cn.escheduler.common.utils.EnumFieldUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* resource mapper provider
|
||||
*/
|
||||
public class ResourceMapperProvider {
|
||||
|
||||
private final String TABLE_NAME = "t_escheduler_resources";
|
||||
|
||||
public static final String USER_TABLE_NAME = "t_escheduler_user";
|
||||
public static final String USER_RESOURCE_RELATION_TABLE_NAME = "t_escheduler_relation_resources_user";
|
||||
public static final String PROJECT_TABLE_NAME = "t_escheduler_project";
|
||||
public static final String TENANT_TABLE_NAME="t_escheduler_tenant";
|
||||
|
||||
/**
|
||||
* insert resource
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
|
||||
VALUES("`alias`", "#{resource.alias}");
|
||||
VALUES("`file_name`", "#{resource.fileName}");
|
||||
VALUES("`desc`", "#{resource.desc}");
|
||||
VALUES("`user_id`", "#{resource.userId}");
|
||||
VALUES("`create_time`", "#{resource.createTime}");
|
||||
VALUES("`update_time`", "#{resource.updateTime}");
|
||||
VALUES("`type`", EnumFieldUtil.genFieldStr("resource.type", ResourceType.class));
|
||||
VALUES("`size`", "#{resource.size}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query resource by name
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryResource(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("alias = #{alias}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query resource by name and resource type
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryResourceByNameAndType(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("alias = #{alias}");
|
||||
WHERE("type = #{type}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query resource by id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryResourceById(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("id = #{id}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update resource
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`alias` = #{resource.alias}");
|
||||
SET("`desc` = #{resource.desc}");
|
||||
SET("`update_time` = #{resource.updateTime}");
|
||||
WHERE("`id` = #{resource.id}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete resource by id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String delete(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id` = #{resourceId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query resource list by user id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryResourceListAuthored(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("type=#{type}");
|
||||
WHERE("id in (select resources_id from "+USER_RESOURCE_RELATION_TABLE_NAME+" where user_id=#{userId} union select id as resources_id from "+TABLE_NAME+" where user_id=#{userId})");
|
||||
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query resource list paging by user id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryResourceAuthoredPaging(Map<String, Object> parameter) {
|
||||
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME );
|
||||
WHERE("type=#{type}");
|
||||
WHERE("id in (select resources_id from "+USER_RESOURCE_RELATION_TABLE_NAME+" where user_id=#{userId} union select id as resources_id from "+TABLE_NAME+" where user_id=#{userId})");
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " alias like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
ORDER_BY("update_time desc limit #{offset},#{pageSize} ");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* query all resource list paging
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryAllResourceListPaging(Map<String, Object> parameter) {
|
||||
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("type=#{type}");
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " alias like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
ORDER_BY("update_time desc limit #{offset},#{pageSize} ");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* count resource number by user id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countResourceNumber(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("count(0)");
|
||||
|
||||
FROM("(select resources_id from t_escheduler_relation_resources_user where user_id=#{userId} union select id as resources_id from t_escheduler_resources where user_id=#{userId}) t");
|
||||
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* count resource number by user id and type
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countResourceNumberByType(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("count(0)");
|
||||
FROM(TABLE_NAME );
|
||||
WHERE("type=#{type}");
|
||||
WHERE("id in (select resources_id from " + USER_RESOURCE_RELATION_TABLE_NAME + " where user_id=#{userId} union select id as resources_id from " + TABLE_NAME + " where user_id=#{userId})");
|
||||
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* count resource number by type
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countAllResourceNumberByType(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("count(0)");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("type=#{type}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* query resource list authorized appointed user
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryAuthorizedResourceList(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("r.*");
|
||||
FROM(TABLE_NAME + " r,t_escheduler_relation_resources_user rel");
|
||||
WHERE(" r.id = rel.resources_id AND rel.user_id = #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query all resource list except user
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryResourceExceptUserId(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("user_id <> #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query tenant code by resource name
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryTenantCodeByResourceName(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("tenant_code");
|
||||
FROM(TENANT_TABLE_NAME + " t," + USER_TABLE_NAME + " u," + TABLE_NAME + " res");
|
||||
WHERE(" t.id = u.tenant_id and u.id = res.user_id and res.type=0 and res.alias= #{resName}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query resource list that created by the appointed user
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryResourceCreatedByUser(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("type = #{type} and user_id = #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.dao.model.ResourcesUser;
|
||||
import org.apache.ibatis.annotations.DeleteProvider;
|
||||
import org.apache.ibatis.annotations.InsertProvider;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* resource user mapper
|
||||
*/
|
||||
public interface ResourcesUserMapper {
|
||||
/**
|
||||
* insert resource user
|
||||
*
|
||||
* @param resourcesUser
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = ResourcesUserMapperProvider.class, method = "insert")
|
||||
int insert(@Param("resourcesUser") ResourcesUser resourcesUser);
|
||||
|
||||
|
||||
/**
|
||||
* delete resource relation by user id
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = ResourcesUserMapperProvider.class, method = "deleteByUserId")
|
||||
int deleteByUserId(@Param("userId") int userId);
|
||||
|
||||
/**
|
||||
* delete resource relation by resource id
|
||||
* @param resourceId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = ResourcesUserMapperProvider.class, method = "deleteByResourceId")
|
||||
int deleteByResourceId(@Param("resourceId") int resourceId);
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* resource user mapper provider
|
||||
*/
|
||||
public class ResourcesUserMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_relation_resources_user";
|
||||
|
||||
|
||||
/**
|
||||
* insert resource user
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
|
||||
VALUES("`resources_id`", "#{resourcesUser.resourcesId}");
|
||||
VALUES("`user_id`", "#{resourcesUser.userId}");
|
||||
VALUES("`perm`", "#{resourcesUser.perm}");
|
||||
VALUES("`create_time`", "#{resourcesUser.createTime}");
|
||||
VALUES("`update_time`", "#{resourcesUser.updateTime}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* delete resource relation by user id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String deleteByUserId(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`user_id` = #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete resource relation by resource id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String deleteByResourceId(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`resources_id` = #{resourceId}");
|
||||
}}.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,174 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
|
||||
import cn.escheduler.common.enums.FailureStrategy;
|
||||
import cn.escheduler.common.enums.Priority;
|
||||
import cn.escheduler.common.enums.ReleaseState;
|
||||
import cn.escheduler.common.enums.WarningType;
|
||||
import cn.escheduler.dao.model.Schedule;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.EnumOrdinalTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* scheduler mapper
|
||||
*/
|
||||
public interface ScheduleMapper {
|
||||
|
||||
/**
|
||||
* insert scheduler
|
||||
* @param schedule
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = ScheduleMapperProvider.class, method = "insert")
|
||||
int insert(@Param("schedule") Schedule schedule);
|
||||
|
||||
/**
|
||||
* update schedule info
|
||||
* @param schedule
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = ScheduleMapperProvider.class, method = "update")
|
||||
int update(@Param("schedule") Schedule schedule);
|
||||
|
||||
/**
|
||||
* query schedule list by process define id
|
||||
*
|
||||
* @param processDefinitionId
|
||||
* @param searchVal
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id",javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionName", column = "process_definition_name", javaType =String.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "projectName", column = "project_name", javaType = String.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "crontab", column = "crontab", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = WarningType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "releaseState", column = "release_state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ReleaseState.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = ScheduleMapperProvider.class, method = "queryByProcessDefineIdPaging")
|
||||
List<Schedule> queryByProcessDefineIdPaging(@Param("processDefinitionId") int processDefinitionId,
|
||||
@Param("searchVal") String searchVal,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize);
|
||||
|
||||
/**
|
||||
* count schedule number by process definition id and search value
|
||||
* @param processDefinitionId
|
||||
* @param searchVal
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = ScheduleMapperProvider.class, method = "countByProcessDefineId")
|
||||
Integer countByProcessDefineId(@Param("processDefinitionId") Integer processDefinitionId,
|
||||
@Param("searchVal") String searchVal
|
||||
);
|
||||
|
||||
/**
|
||||
* query schedule list by project id
|
||||
*
|
||||
* @param projectName
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "projectName", column = "project_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processDefinitionName", column = "process_definition_name", id = true, javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", id = true, javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "crontab", column = "crontab", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = WarningType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "releaseState", column = "release_state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ReleaseState.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = ScheduleMapperProvider.class, method = "querySchedulerListByProjectName")
|
||||
List<Schedule> querySchedulerListByProjectName(@Param("projectName") String projectName);
|
||||
|
||||
|
||||
/**
|
||||
* query schedule by id
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "crontab", column = "crontab", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = WarningType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "releaseState", column = "release_state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ReleaseState.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = ScheduleMapperProvider.class, method = "queryById")
|
||||
Schedule queryById(@Param("id") int id);
|
||||
|
||||
/**
|
||||
* query schedule list by definition array
|
||||
* @param processDefineIds
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "crontab", column = "crontab", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningType", column = "warning_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = WarningType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "releaseState", column = "release_state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ReleaseState.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "warningGroupId", column = "warning_group_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = ScheduleMapperProvider.class, method = "selectAllByProcessDefineArray")
|
||||
List<Schedule> selectAllByProcessDefineArray(@Param("processDefineIds") int[] processDefineIds);
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.FailureStrategy;
|
||||
import cn.escheduler.common.enums.Priority;
|
||||
import cn.escheduler.common.enums.ReleaseState;
|
||||
import cn.escheduler.common.enums.WarningType;
|
||||
import cn.escheduler.common.utils.EnumFieldUtil;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* scheduler mapper provider
|
||||
*/
|
||||
public class ScheduleMapperProvider {
|
||||
|
||||
public static final String DB_NAME = "t_escheduler_schedules";
|
||||
public static final String DEFINE_TABLE_NAME = "t_escheduler_process_definition";
|
||||
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
INSERT_INTO(DB_NAME);
|
||||
|
||||
VALUES("`process_definition_id`", "#{schedule.processDefinitionId}");
|
||||
VALUES("`start_time`", "#{schedule.startTime}");
|
||||
VALUES("`end_time`", "#{schedule.endTime}");
|
||||
VALUES("`crontab`", "#{schedule.crontab}");
|
||||
VALUES("`failure_strategy`", EnumFieldUtil.genFieldStr("schedule.failureStrategy", FailureStrategy.class));
|
||||
VALUES("`warning_type`", EnumFieldUtil.genFieldStr("schedule.warningType", WarningType.class));
|
||||
VALUES("`create_time`", "#{schedule.createTime}");
|
||||
VALUES("`update_time`", "#{schedule.updateTime}");
|
||||
VALUES("`user_id`", "#{schedule.userId}");
|
||||
VALUES("`release_state`", EnumFieldUtil.genFieldStr("schedule.releaseState", ReleaseState.class));
|
||||
VALUES("`warning_group_id`", "#{schedule.warningGroupId}");
|
||||
VALUES("`process_instance_priority`", EnumFieldUtil.genFieldStr("schedule.processInstancePriority", Priority.class));
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(DB_NAME);
|
||||
|
||||
SET("`start_time`=#{schedule.startTime}");
|
||||
SET("`end_time`=#{schedule.endTime}");
|
||||
SET("`crontab`=#{schedule.crontab}");
|
||||
SET("`failure_strategy`=" + EnumFieldUtil.genFieldStr("schedule.failureStrategy", FailureStrategy.class));
|
||||
SET("`warning_type`=" + EnumFieldUtil.genFieldStr("schedule.warningType", WarningType.class));
|
||||
SET("`create_time`=#{schedule.createTime}");
|
||||
SET("`update_time`=#{schedule.updateTime}");
|
||||
SET("`user_id`=#{schedule.userId}");
|
||||
SET("`release_state`=" + EnumFieldUtil.genFieldStr("schedule.releaseState", ReleaseState.class));
|
||||
SET("`warning_group_id`=#{schedule.warningGroupId}");
|
||||
SET("`process_instance_priority`="+ EnumFieldUtil.genFieldStr("schedule.processInstancePriority", Priority.class));
|
||||
|
||||
WHERE("`id` = #{schedule.id}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query schedule by id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryById(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(DB_NAME);
|
||||
WHERE("`id` = #{id}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query schedule list by process define id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByProcessDefineIdPaging(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("p_f.name as process_definition_name");
|
||||
SELECT("p.name as project_name");
|
||||
SELECT("u.user_name");
|
||||
SELECT("s.*");
|
||||
|
||||
FROM(DB_NAME + " as s");
|
||||
|
||||
JOIN(DEFINE_TABLE_NAME + " as p_f on s.process_definition_id = p_f.id");
|
||||
JOIN("t_escheduler_project as p on p_f.project_id = p.id");
|
||||
JOIN("t_escheduler_user as u on s.user_id = u.id");
|
||||
if(parameter.get("processDefinitionId") != null && (int)parameter.get("processDefinitionId") != 0) {
|
||||
WHERE("s.process_definition_id = #{processDefinitionId}");
|
||||
}
|
||||
ORDER_BY("s.update_time desc limit #{offset},#{pageSize}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* count schedule number by process definition id and search value
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countByProcessDefineId(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("count(0)");
|
||||
|
||||
FROM(DB_NAME + " as s");
|
||||
|
||||
JOIN(DEFINE_TABLE_NAME + " as p_f on s.process_definition_id = p_f.id");
|
||||
JOIN("t_escheduler_project as p on p_f.project_id = p.id");
|
||||
JOIN("t_escheduler_user as u on s.user_id = u.id");
|
||||
if(parameter.get("processDefinitionId") != null && (int)parameter.get("processDefinitionId") != 0) {
|
||||
WHERE("s.process_definition_id = #{processDefinitionId}");
|
||||
}
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query schedule list by project id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String querySchedulerListByProjectName(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("p_f.name as process_definition_name");
|
||||
SELECT("p_f.desc as `desc`");
|
||||
SELECT("p.name as project_name");
|
||||
SELECT("u.user_name");
|
||||
SELECT("s.*");
|
||||
|
||||
FROM(DB_NAME + " as s");
|
||||
|
||||
JOIN( DEFINE_TABLE_NAME + " as p_f on s.process_definition_id = p_f.id");
|
||||
JOIN("t_escheduler_project as p on p_f.project_id = p.id");
|
||||
JOIN("t_escheduler_user as u on s.user_id = u.id");
|
||||
|
||||
WHERE("p.name = #{projectName}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query schedule list by definition array
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String selectAllByProcessDefineArray(Map<String, Object> parameter) {
|
||||
|
||||
StringBuffer strIds = new StringBuffer();
|
||||
int[] idsArray = (int[]) parameter.get("processDefineIds");
|
||||
for(int i=0;i<idsArray.length;i++){
|
||||
strIds.append(idsArray[i]);
|
||||
if(i<idsArray.length-1){
|
||||
strIds.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(DB_NAME);
|
||||
WHERE("`process_definition_id` in (" + String.join(",",strIds.toString()) +")");
|
||||
WHERE("release_state = 1");
|
||||
}}.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.dao.model.Session;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* session mapper
|
||||
*/
|
||||
public interface SessionMapper {
|
||||
|
||||
/**
|
||||
* insert session
|
||||
* @param session
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = SessionMapperProvider.class, method = "insert")
|
||||
int insert(@Param("session") Session session);
|
||||
|
||||
|
||||
/**
|
||||
* delete session
|
||||
* @param sessionId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = SessionMapperProvider.class, method = "delete")
|
||||
int deleteById(@Param("sessionId") String sessionId);
|
||||
|
||||
|
||||
/**
|
||||
* update session
|
||||
*
|
||||
* @param sessionId
|
||||
* @param loginTime
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = SessionMapperProvider.class, method = "update")
|
||||
int update(@Param("sessionId") String sessionId, @Param("loginTime") Date loginTime);
|
||||
|
||||
|
||||
/**
|
||||
* query by session id
|
||||
* @param sessionId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userId", column = "user_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "ip", column = "ip", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "lastLoginTime", column = "last_login_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = SessionMapperProvider.class, method = "queryById")
|
||||
Session queryById(@Param("sessionId") int sessionId);
|
||||
|
||||
|
||||
/**
|
||||
* query by session id and ip
|
||||
*
|
||||
* @param sessionId
|
||||
* @param ip
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "ip", column = "ip", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "lastLoginTime", column = "last_login_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = SessionMapperProvider.class, method = "queryByIdAndIp")
|
||||
Session queryByIdAndIp(@Param("sessionId") String sessionId, @Param("ip") String ip);
|
||||
|
||||
|
||||
/**
|
||||
* query by user id and ip
|
||||
* @param userId
|
||||
* @param ip
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "ip", column = "ip", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "lastLoginTime", column = "last_login_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = SessionMapperProvider.class, method = "queryByUserIdAndIp")
|
||||
Session queryByUserIdAndIp(@Param("userId") int userId, @Param("ip") String ip);
|
||||
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* session mapper provider
|
||||
*/
|
||||
public class SessionMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_session";
|
||||
|
||||
/**
|
||||
* insert session
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
VALUES("`id`", "#{session.id}");
|
||||
VALUES("`user_id`", "#{session.userId}");
|
||||
VALUES("`ip`", "#{session.ip}");
|
||||
VALUES("`last_login_time`", "#{session.lastLoginTime}");
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete session
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String delete(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id`=#{sessionId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update session
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`last_login_time`=#{loginTime}");
|
||||
|
||||
WHERE("`id` = #{sessionId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* query by session id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryById(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id` = #{sessionId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query by session id and ip
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByIdAndIp(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id` = #{sessionId}");
|
||||
WHERE("`ip` = #{ip}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query by user id and ip
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByUserIdAndIp(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`user_id` = #{userId}");
|
||||
WHERE("`ip` = #{ip}");
|
||||
}}.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,307 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.ExecutionStatus;
|
||||
import cn.escheduler.common.enums.Flag;
|
||||
import cn.escheduler.common.enums.Priority;
|
||||
import cn.escheduler.common.enums.UserType;
|
||||
import cn.escheduler.dao.model.ExecuteStatusCount;
|
||||
import cn.escheduler.dao.model.TaskInstance;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.EnumOrdinalTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* task intance mapper
|
||||
*/
|
||||
public interface TaskInstanceMapper {
|
||||
|
||||
/**
|
||||
* insert task instance
|
||||
* @param taskInstance
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = TaskInstanceMapperProvider.class, method = "insert")
|
||||
@Options(useGeneratedKeys = true,keyProperty = "taskInstance.id")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "taskInstance.id", before = false, resultType = int.class)
|
||||
int insert(@Param("taskInstance") TaskInstance taskInstance);
|
||||
|
||||
/**
|
||||
* delete task instance
|
||||
* @param taskInstanceId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = TaskInstanceMapperProvider.class, method = "delete")
|
||||
int delete(@Param("taskInstanceId") int taskInstanceId);
|
||||
|
||||
/**
|
||||
* update task instance
|
||||
*
|
||||
* @param taskInstance
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = TaskInstanceMapperProvider.class, method = "update")
|
||||
int update(@Param("taskInstance") TaskInstance taskInstance);
|
||||
|
||||
/**
|
||||
* query task by id
|
||||
* @param taskInstanceId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskType", column = "task_type",javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id",javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstanceId", column = "process_instance_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "taskJson", column = "task_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "submitTime", column = "submit_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executePath", column = "execute_path", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "logPath", column = "log_path", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "alertFlag", column = "alert_flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "retryTimes", column = "retry_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "pid", column = "pid", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "maxRetryTimes", column = "max_retry_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "retryInterval", column = "retry_interval", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "appLink", column = "app_link", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "duration", column = "duration", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "flag", column = "flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "taskInstancePriority", column = "task_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = TaskInstanceMapperProvider.class, method = "queryById")
|
||||
TaskInstance queryById(@Param("taskInstanceId") int taskInstanceId);
|
||||
|
||||
/**
|
||||
* query task id list by process instance id and state
|
||||
* @param processInstanceId
|
||||
* @param state
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", javaType = Integer.class, jdbcType = JdbcType.INTEGER)})
|
||||
@SelectProvider(type = TaskInstanceMapperProvider.class, method = "queryTaskByProcessIdAndState")
|
||||
List<Integer> queryTaskByProcessIdAndState(@Param("processInstanceId") Integer processInstanceId,
|
||||
@Param("state") Integer state);
|
||||
|
||||
/**
|
||||
* query valid task instance list by process id
|
||||
* @param processInstanceId
|
||||
* @param flag
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskType", column = "task_type",javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id",javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstanceId", column = "process_instance_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "taskJson", column = "task_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "submitTime", column = "submit_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executePath", column = "execute_path", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "logPath", column = "log_path", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "alertFlag", column = "alert_flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "retryTimes", column = "retry_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "maxRetryTimes", column = "max_retry_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "retryInterval", column = "retry_interval", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "pid", column = "pid", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "appLink", column = "app_link", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "duration", column = "duration", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "flag", column = "flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "taskInstancePriority", column = "task_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = TaskInstanceMapperProvider.class, method = "findValidTaskListByProcessId")
|
||||
List<TaskInstance> findValidTaskListByProcessId(@Param("processInstanceId") Integer processInstanceId,
|
||||
@Param("flag") Flag flag);
|
||||
|
||||
/**
|
||||
* query task list by host and state
|
||||
* @param host
|
||||
* @param stateArray
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskType", column = "task_type",javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id",javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstanceId", column = "process_instance_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "taskJson", column = "task_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "submitTime", column = "submit_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executePath", column = "execute_path", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "logPath", column = "log_path", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "alertFlag", column = "alert_flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "retryTimes", column = "retry_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "maxRetryTimes", column = "max_retry_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "retryInterval", column = "retry_interval", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "pid", column = "pid", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "appLink", column = "app_link", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "duration", column = "duration", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "flag", column = "flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "taskInstancePriority", column = "task_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = TaskInstanceMapperProvider.class, method = "queryByHostAndStatus")
|
||||
List<TaskInstance> queryByHostAndStatus(@Param("host") String host,@Param("states") int[] stateArray);
|
||||
|
||||
/**
|
||||
* set task state to need failover when worker down
|
||||
* @param host
|
||||
* @param stateArray
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = TaskInstanceMapperProvider.class, method = "setFailoverByHostAndStateArray")
|
||||
int setFailoverByHostAndStateArray(@Param("host") String host, @Param("states")int[] stateArray);
|
||||
|
||||
/**
|
||||
* count task number group by state and user
|
||||
* @param userId
|
||||
* @param userType
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "count", column = "count", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
})
|
||||
@SelectProvider(type = TaskInstanceMapperProvider.class, method = "countTaskInstanceStateByUser")
|
||||
List<ExecuteStatusCount> countTaskInstanceStateByUser(@Param("userId") int userId,
|
||||
@Param("userType") UserType userType,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime,
|
||||
@Param("projectId") int projectId);
|
||||
|
||||
/**
|
||||
* count task number by search fields
|
||||
* @param projectId
|
||||
* @param processInstanceId
|
||||
* @param taskName
|
||||
* @param statusArray
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @param searchVal
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = TaskInstanceMapperProvider.class, method = "countTaskInstance")
|
||||
Integer countTaskInstance(@Param("projectId") int projectId,
|
||||
@Param("processInstanceId") Integer processInstanceId,
|
||||
@Param("taskName") String taskName,
|
||||
@Param("states") String statusArray,
|
||||
@Param("host") String host,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime,
|
||||
@Param("searchVal") String searchVal
|
||||
);
|
||||
|
||||
/**
|
||||
* query task list paging by search fields
|
||||
* @param projectId
|
||||
* @param processInstanceId
|
||||
* @param searchVal
|
||||
* @param taskName
|
||||
* @param statusArray
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskType", column = "task_type",javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id",javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstanceId", column = "process_instance_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstanceName", column = "process_instance_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskJson", column = "task_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "submitTime", column = "submit_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executePath", column = "execute_path", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "logPath", column = "log_path", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "alertFlag", column = "alert_flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "retryTimes", column = "retry_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "maxRetryTimes", column = "max_retry_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "retryInterval", column = "retry_interval", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "pid", column = "pid", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "appLink", column = "app_link", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "duration", column = "duration", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "flag", column = "flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "taskInstancePriority", column = "task_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = TaskInstanceMapperProvider.class, method = "queryTaskInstanceListPaging")
|
||||
List<TaskInstance> queryTaskInstanceListPaging(
|
||||
@Param("projectId") int projectId,
|
||||
@Param("processInstanceId") Integer processInstanceId,
|
||||
@Param("searchVal") String searchVal,
|
||||
@Param("taskName") String taskName,
|
||||
@Param("states") String statusArray,
|
||||
@Param("host") String host,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize
|
||||
);
|
||||
|
||||
/**
|
||||
* query task list by process id and task name
|
||||
* @param processInstanceId
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskType", column = "task_type",javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "processDefinitionId", column = "process_definition_id",javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstanceId", column = "process_instance_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "processInstanceName", column = "process_instance_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "taskJson", column = "task_json", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "state", column = "state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ExecutionStatus.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "submitTime", column = "submit_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "startTime", column = "start_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "endTime", column = "end_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "executePath", column = "execute_path", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "logPath", column = "log_path", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "alertFlag", column = "alert_flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "retryTimes", column = "retry_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "maxRetryTimes", column = "max_retry_times", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "retryInterval", column = "retry_interval", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "pid", column = "pid", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "appLink", column = "app_link", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "duration", column = "duration", javaType = Long.class, jdbcType = JdbcType.BIGINT),
|
||||
@Result(property = "flag", column = "flag", typeHandler = EnumOrdinalTypeHandler.class, javaType = Flag.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "taskInstancePriority", column = "task_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
|
||||
})
|
||||
@SelectProvider(type = TaskInstanceMapperProvider.class, method = "queryByInstanceIdAndName")
|
||||
TaskInstance queryByInstanceIdAndName(@Param("processInstanceId") int processInstanceId,
|
||||
@Param("name") String name);
|
||||
}
|
@ -0,0 +1,407 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.ExecutionStatus;
|
||||
import cn.escheduler.common.enums.Flag;
|
||||
import cn.escheduler.common.enums.Priority;
|
||||
import cn.escheduler.common.utils.EnumFieldUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* task instance mapper provider
|
||||
*/
|
||||
public class TaskInstanceMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_task_instance";
|
||||
private static final String DEFINE_TABLE_NAME = "t_escheduler_process_definition";
|
||||
private static final String INSTANCE_TABLE_NAME = "t_escheduler_process_instance";
|
||||
|
||||
/**
|
||||
* insert task instance
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
VALUES("`name`", "#{taskInstance.name}");
|
||||
VALUES("`task_type`", "#{taskInstance.taskType}");
|
||||
VALUES("`process_definition_id`","#{taskInstance.processDefinitionId}");
|
||||
VALUES("`process_instance_id`", "#{taskInstance.processInstanceId}");
|
||||
VALUES("`task_json`", "#{taskInstance.taskJson}");
|
||||
VALUES("`state`", EnumFieldUtil.genFieldStr("taskInstance.state", ExecutionStatus.class));
|
||||
VALUES("`submit_time`", "#{taskInstance.submitTime}");
|
||||
VALUES("`start_time`", "#{taskInstance.startTime}");
|
||||
VALUES("`end_time`", "#{taskInstance.endTime}");
|
||||
VALUES("`host`", "#{taskInstance.host}");
|
||||
VALUES("`execute_path`", "#{taskInstance.executePath}");
|
||||
VALUES("`log_path`", "#{taskInstance.logPath}");
|
||||
VALUES("`alert_flag`", EnumFieldUtil.genFieldStr("taskInstance.alertFlag", Flag.class));
|
||||
VALUES("`retry_times`", "#{taskInstance.retryTimes}");
|
||||
VALUES("`pid`", "#{taskInstance.pid}");
|
||||
VALUES("`max_retry_times`", "#{taskInstance.maxRetryTimes}");
|
||||
VALUES("`retry_interval`", "#{taskInstance.retryInterval}");
|
||||
VALUES("`app_link`", "#{taskInstance.appLink}");
|
||||
VALUES("`flag`", EnumFieldUtil.genFieldStr("taskInstance.flag", Flag.class));
|
||||
VALUES("`task_instance_priority`", EnumFieldUtil.genFieldStr("taskInstance.taskInstancePriority", Priority.class));
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete task instance
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String delete(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id`=#{taskInstanceId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update task instance
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`name`=#{taskInstance.name}");
|
||||
SET("`task_type`=#{taskInstance.taskType}");
|
||||
SET("`process_definition_id`=#{taskInstance.processDefinitionId}");
|
||||
SET("`process_instance_id`=#{taskInstance.processInstanceId}");
|
||||
SET("`task_json`=#{taskInstance.taskJson}");
|
||||
SET("`state`="+ EnumFieldUtil.genFieldStr("taskInstance.state", ExecutionStatus.class));
|
||||
SET("`submit_time`=#{taskInstance.submitTime}");
|
||||
SET("`start_time`=#{taskInstance.startTime}");
|
||||
SET("`end_time`=#{taskInstance.endTime}");
|
||||
SET("`host`=#{taskInstance.host}");
|
||||
SET("`execute_path`=#{taskInstance.executePath}");
|
||||
SET("`log_path`=#{taskInstance.logPath}");
|
||||
SET("`alert_flag`="+ EnumFieldUtil.genFieldStr("taskInstance.alertFlag", Flag.class));
|
||||
SET("`retry_times`=#{taskInstance.retryTimes}");
|
||||
SET("`pid`=#{taskInstance.pid}");
|
||||
SET("`max_retry_times`=#{taskInstance.maxRetryTimes}");
|
||||
SET("`retry_interval`=#{taskInstance.retryInterval}");
|
||||
SET("`app_link`=#{taskInstance.appLink}");
|
||||
SET("`flag`="+ EnumFieldUtil.genFieldStr("taskInstance.flag", Flag.class));
|
||||
SET("`task_instance_priority`="+ EnumFieldUtil.genFieldStr("taskInstance.taskInstancePriority", Priority.class));
|
||||
|
||||
WHERE("`id`=#{taskInstance.id}");
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query task by id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryById(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*, UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time) as duration");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("id = #{taskInstanceId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query task id list by process instance id and state
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryTaskByProcessIdAndState(Map<String, Object> parameter){
|
||||
return new SQL(){
|
||||
{
|
||||
SELECT("id");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("`process_instance_id` = #{processInstanceId}");
|
||||
WHERE("`state` = #{state}");
|
||||
WHERE("`flag` = 1 ");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query valid task instance list by process id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String findValidTaskListByProcessId(Map<String, Object> parameter) {
|
||||
return new SQL()
|
||||
{
|
||||
{
|
||||
SELECT("*, UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time) as duration");
|
||||
FROM(TABLE_NAME );
|
||||
WHERE("`process_instance_id` = #{processInstanceId} ");
|
||||
WHERE("`flag` = " + EnumFieldUtil.genFieldStr("flag", Flag.class));
|
||||
ORDER_BY("start_time desc");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* count task number group by state and user
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countTaskInstanceStateByUser(Map<String, Object> parameter){
|
||||
return new SQL(){
|
||||
{
|
||||
SELECT ("state, count(0) as count");
|
||||
FROM(TABLE_NAME + " t");
|
||||
LEFT_OUTER_JOIN(DEFINE_TABLE_NAME+ " d on d.id=t.process_definition_id");
|
||||
LEFT_OUTER_JOIN("t_escheduler_project p on p.id=d.project_id");
|
||||
if(parameter.get("projectId") != null && (int)parameter.get("projectId") != 0){
|
||||
WHERE( "p.id = #{projectId} ");
|
||||
}else{
|
||||
if(parameter.get("userType") != null && String.valueOf(parameter.get("userType")) == "GENERAL_USER") {
|
||||
AND();
|
||||
WHERE("d.project_id in (select id as project_id from t_escheduler_project tp where tp.user_id= #{userId} " +
|
||||
"union select project_id from t_escheduler_relation_project_user tr where tr.user_id= #{userId} )");
|
||||
|
||||
}
|
||||
}
|
||||
WHERE("t.flag = 1 and t.start_time > #{startTime} and t.start_time <= #{endTime}");
|
||||
GROUP_BY("t.state");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query task list by host and state
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByHostAndStatus(Map<String, Object> parameter) {
|
||||
StringBuffer strStates = new StringBuffer();
|
||||
int[] stateArray = (int[]) parameter.get("states");
|
||||
for(int i=0;i<stateArray.length;i++){
|
||||
strStates.append(stateArray[i]);
|
||||
if(i<stateArray.length-1){
|
||||
strStates.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*, UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time) as duration");
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`host` = #{host} and `state` in (" + strStates.toString() +")");
|
||||
ORDER_BY("`id` asc");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query TaskInstance by host and status
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryLimitNumByHostAndStatus(Map<String, Object> parameter) {
|
||||
StringBuffer strStates = new StringBuffer();
|
||||
int[] stateArray = (int[]) parameter.get("states");
|
||||
for(int i=0;i<stateArray.length;i++){
|
||||
strStates.append(stateArray[i]);
|
||||
if(i<stateArray.length-1){
|
||||
strStates.append(",");
|
||||
}
|
||||
}
|
||||
int limitNum = (int) parameter.get("limit_num");
|
||||
|
||||
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*, UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time) as duration");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`host` = #{host} and `state` in (" + strStates.toString() +")");
|
||||
ORDER_BY("`id` asc limit "+ " " + limitNum);
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set task state to need failover when worker down
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String setFailoverByHostAndStateArray(Map<String, Object> parameter) {
|
||||
StringBuffer strStates = new StringBuffer();
|
||||
int[] stateArray = (int[]) parameter.get("states");
|
||||
int state = ExecutionStatus.NEED_FAULT_TOLERANCE.ordinal();
|
||||
for(int i=0;i<stateArray.length;i++){
|
||||
strStates.append(stateArray[i]);
|
||||
if(i<stateArray.length-1){
|
||||
strStates.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
return new SQL() {
|
||||
{
|
||||
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`state`=" + state);
|
||||
|
||||
WHERE("`host` = #{host} and `state` in (" + strStates.toString() + ")");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query task list paging by search fields
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryTaskInstanceListPaging(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("instance.*,process.name as process_instance_name, UNIX_TIMESTAMP(instance.end_time)-UNIX_TIMESTAMP(instance.start_time) as duration");
|
||||
|
||||
FROM(TABLE_NAME + " instance");
|
||||
|
||||
JOIN(DEFINE_TABLE_NAME + " define ON instance.process_definition_id = define.id");
|
||||
JOIN(INSTANCE_TABLE_NAME + " process on process.id=instance.process_instance_id");
|
||||
WHERE("define.project_id = #{projectId}");
|
||||
|
||||
Object start = parameter.get("startTime");
|
||||
if(start != null && StringUtils.isNotEmpty(start.toString())){
|
||||
WHERE("instance.start_time > #{startTime} and instance.start_time <= #{endTime}");
|
||||
}
|
||||
|
||||
if(parameter.get("processInstanceId") != null && (int)parameter.get("processInstanceId") != 0){
|
||||
WHERE( "instance.process_instance_id = #{processInstanceId} ");
|
||||
}
|
||||
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " instance.name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
Object taskName = parameter.get("taskName");
|
||||
if(taskName != null && StringUtils.isNotEmpty(taskName.toString())){
|
||||
WHERE( " instance.name=#{taskName}");
|
||||
}
|
||||
Object states = parameter.get("states");
|
||||
if(states != null && StringUtils.isNotEmpty(states.toString())){
|
||||
String stateStr = states.toString();
|
||||
WHERE("instance.state in ( "+ stateStr + " )");
|
||||
}
|
||||
Object host = parameter.get("host");
|
||||
if(host != null && StringUtils.isNotEmpty(host.toString())){
|
||||
WHERE( "instance.host like concat('%', #{host}, '%') ");
|
||||
}
|
||||
ORDER_BY("instance.start_time desc limit #{offset},#{pageSize} ");
|
||||
}
|
||||
}.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* count task number by search fields
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countTaskInstance(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("count(1)");
|
||||
|
||||
|
||||
FROM(TABLE_NAME + " instance");
|
||||
|
||||
JOIN(DEFINE_TABLE_NAME + " define ON instance.process_definition_id = define.id");
|
||||
WHERE("define.project_id = #{projectId}");
|
||||
|
||||
if(parameter.get("processInstanceId") != null && (int)parameter.get("processInstanceId") != 0){
|
||||
WHERE( "instance.process_instance_id = #{processInstanceId} ");
|
||||
}
|
||||
Object startTime = parameter.get("startTime");
|
||||
if(startTime != null && StringUtils.isNotEmpty(startTime.toString())) {
|
||||
WHERE("instance.start_time > #{startTime} and instance.start_time <= #{endTime}");
|
||||
}
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " instance.name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
Object taskName = parameter.get("taskName");
|
||||
if(taskName != null && StringUtils.isNotEmpty(taskName.toString())){
|
||||
WHERE( " instance.name=#{taskName}");
|
||||
}
|
||||
Object states = parameter.get("states");
|
||||
if(states != null && StringUtils.isNotEmpty(states.toString())){
|
||||
String stateStr = states.toString();
|
||||
WHERE("instance.state in ( "+ stateStr + " )");
|
||||
}
|
||||
Object host = parameter.get("host");
|
||||
if(host != null && StringUtils.isNotEmpty(host.toString())){
|
||||
WHERE( "instance.host like concat('%', #{host}, '%') ");
|
||||
}
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query task list by process id and task name
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByInstanceIdAndName(Map<String, Object> parameter){
|
||||
return new SQL(){
|
||||
{
|
||||
SELECT("*,UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time) as duration");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("`process_instance_id` = #{processInstanceId}");
|
||||
WHERE("`name` = #{name}");
|
||||
WHERE("`flag` = 1 ");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.dao.model.Tenant;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* tenant mapper
|
||||
*/
|
||||
public interface TenantMapper {
|
||||
|
||||
/**
|
||||
* insert tenant
|
||||
* @param tenant
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = TenantMapperProvider.class, method = "insert")
|
||||
@Options(useGeneratedKeys = true,keyProperty = "tenant.id")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "tenant.id", before = false, resultType = int.class)
|
||||
int insert(@Param("tenant") Tenant tenant);
|
||||
|
||||
|
||||
/**
|
||||
* delete tenant
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = TenantMapperProvider.class, method = "deleteById")
|
||||
int deleteById(@Param("id") int id);
|
||||
|
||||
|
||||
/**
|
||||
* update tenant
|
||||
*
|
||||
* @param tenant
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = TenantMapperProvider.class, method = "update")
|
||||
int update(@Param("tenant") Tenant tenant);
|
||||
|
||||
|
||||
/**
|
||||
* query tenant by id
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "tenantCode", column = "tenant_code", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "tenantName", column = "tenant_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "queueId", column = "queue_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
})
|
||||
@SelectProvider(type = TenantMapperProvider.class, method = "queryById")
|
||||
Tenant queryById(@Param("tenantId") int tenantId);
|
||||
|
||||
/**
|
||||
* query tenant by code
|
||||
* @param tenantCode
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "tenantCode", column = "tenant_code", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "tenantName", column = "tenant_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "queueId", column = "queue_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
})
|
||||
@SelectProvider(type = TenantMapperProvider.class, method = "queryByTenantCode")
|
||||
Tenant queryByTenantCode(@Param("tenantCode") String tenantCode);
|
||||
|
||||
/**
|
||||
* count tenant by search value
|
||||
* @param searchVal
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = TenantMapperProvider.class, method = "countTenantPaging")
|
||||
Integer countTenantPaging(@Param("searchVal") String searchVal);
|
||||
|
||||
|
||||
/**
|
||||
* query tenant list paging
|
||||
* @param searchVal
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "tenantCode", column = "tenant_code", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "tenantName", column = "tenant_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "queueId", column = "queue_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "queueName", column = "queue_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = TenantMapperProvider.class, method = "queryTenantPaging")
|
||||
List<Tenant> queryTenantPaging(@Param("searchVal") String searchVal,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("pageSize") Integer pageSize);
|
||||
|
||||
/**
|
||||
* query all tenant list
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "tenantCode", column = "tenant_code", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "tenantName", column = "tenant_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "queueId", column = "queue_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = TenantMapperProvider.class, method = "queryAllTenant")
|
||||
List<Tenant> queryAllTenant();
|
||||
}
|
@ -0,0 +1,182 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* tenant mapper provider
|
||||
*/
|
||||
public class TenantMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_tenant";
|
||||
|
||||
/**
|
||||
* insert tenant
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
VALUES("`tenant_code`", "#{tenant.tenantCode}");
|
||||
VALUES("`tenant_name`", "#{tenant.tenantName}");
|
||||
VALUES("`queue_id`", "#{tenant.queueId}");
|
||||
VALUES("`desc`", "#{tenant.desc}");
|
||||
VALUES("`create_time`", "#{tenant.createTime}");
|
||||
VALUES("`update_time`", "#{tenant.updateTime}");
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete tenant
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String deleteById(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id`=#{id}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update tenant
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`tenant_name`=#{tenant.tenantName}");
|
||||
SET("`tenant_code`=#{tenant.tenantCode}");
|
||||
SET("`desc`=#{tenant.desc}");
|
||||
SET("`queue_id`=#{tenant.queueId}");
|
||||
SET("`update_time`=#{tenant.updateTime}");
|
||||
|
||||
WHERE("`id`=#{tenant.id}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query tenant by id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryById(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id` = #{tenantId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query tenant by code
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByTenantCode(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`tenant_code` = #{tenantCode}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* count tenant by search value
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countTenantPaging(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("count(0)");
|
||||
FROM(TABLE_NAME +" t,t_escheduler_queue q");
|
||||
WHERE( " t.queue_id = q.id");
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " tenant_name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query tenant list paging
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryTenantPaging(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("t.*,q.queue_name as queueName");
|
||||
FROM(TABLE_NAME +" t,t_escheduler_queue q");
|
||||
WHERE( " t.queue_id = q.id");
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " t.tenant_name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
ORDER_BY(" t.update_time desc limit #{offset},#{pageSize} ");
|
||||
}
|
||||
}.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* query all tenant list
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryAllTenant(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
}
|
||||
}.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.dao.model.UDFUser;
|
||||
import org.apache.ibatis.annotations.DeleteProvider;
|
||||
import org.apache.ibatis.annotations.InsertProvider;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
/**
|
||||
* udf user relation mapper
|
||||
*/
|
||||
public interface UDFUserMapper {
|
||||
|
||||
/**
|
||||
* insert udf user
|
||||
* @param udfUser
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = UDFUserMapperProvider.class, method = "insert")
|
||||
int insert(@Param("udfUser") UDFUser udfUser);
|
||||
|
||||
|
||||
/**
|
||||
* delete by user id
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = UDFUserMapperProvider.class, method = "deleteByUserId")
|
||||
int deleteByUserId(@Param("userId") int userId);
|
||||
|
||||
/**
|
||||
* delete by udf function id
|
||||
* @param udfFuncId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = UDFUserMapperProvider.class, method = "deleteByUdfFuncId")
|
||||
int deleteByUdfFuncId(@Param("udfFuncId") int udfFuncId);
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* udf user mapper provider
|
||||
*/
|
||||
public class UDFUserMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_relation_udfs_user";
|
||||
|
||||
|
||||
/**
|
||||
* insert udf user
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
|
||||
VALUES("`udf_id`", "#{udfUser.udfId}");
|
||||
VALUES("`user_id`", "#{udfUser.userId}");
|
||||
VALUES("`perm`", "#{udfUser.perm}");
|
||||
VALUES("`create_time`", "#{udfUser.createTime}");
|
||||
VALUES("`update_time`", "#{udfUser.updateTime}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* delete by user id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String deleteByUserId(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`user_id` = #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete by udf function id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String deleteByUdfFuncId(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`udf_id` = #{udfFuncId}");
|
||||
}}.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,273 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.UdfType;
|
||||
import cn.escheduler.dao.model.UdfFunc;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.EnumOrdinalTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* und function mapper
|
||||
*/
|
||||
public interface UdfFuncMapper {
|
||||
|
||||
/**
|
||||
* insert udf function
|
||||
*
|
||||
* @param udf
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = UdfFuncMapperProvider.class, method = "insert")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID() AS id", keyProperty = "udf.id", resultType = int.class, before = false)
|
||||
int insert(@Param("udf") UdfFunc udf);
|
||||
|
||||
/**
|
||||
* update udf function
|
||||
*
|
||||
* @param udf
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = UdfFuncMapperProvider.class, method = "update")
|
||||
int update(@Param("udf") UdfFunc udf);
|
||||
|
||||
/**
|
||||
* query udf function by id
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "funcName", column = "func_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "className", column = "class_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "argTypes", column = "arg_types", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "database", column = "database", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "resourceId", column = "resource_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "resourceName", column = "resource_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UdfType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UdfFuncMapperProvider.class, method = "queryUdfById")
|
||||
UdfFunc queryUdfById(@Param("id") int id);
|
||||
|
||||
/**
|
||||
* query udf list by id string
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "funcName", column = "func_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "className", column = "class_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "argTypes", column = "arg_types", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "database", column = "database", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "resourceId", column = "resource_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "resourceName", column = "resource_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UdfType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UdfFuncMapperProvider.class, method = "queryUdfByIdStr")
|
||||
List<UdfFunc> queryUdfByIdStr(@Param("ids") String ids);
|
||||
|
||||
/**
|
||||
* count udf number by user id
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = UdfFuncMapperProvider.class, method = "countUserUdfFunc")
|
||||
int countUserUdfFunc(@Param("userId") int userId);
|
||||
|
||||
/**
|
||||
* count udf number
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = UdfFuncMapperProvider.class, method = "countAllUdfFunc")
|
||||
int countAllUdfFunc();
|
||||
|
||||
/**
|
||||
* query udf function paging
|
||||
* @param userId
|
||||
* @param searchVal
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "funcName", column = "func_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "className", column = "class_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "argTypes", column = "arg_types", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "database", column = "database", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "resourceId", column = "resource_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "resourceName", column = "resource_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UdfType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UdfFuncMapperProvider.class, method = "queryUdfFuncPaging")
|
||||
List<UdfFunc> queryUdfFuncPaging(@Param("userId") int userId, @Param("searchVal") String searchVal,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize);
|
||||
|
||||
/**
|
||||
* query all udf function paging
|
||||
* @param searchVal
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "funcName", column = "func_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "className", column = "class_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "argTypes", column = "arg_types", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "database", column = "database", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "resourceId", column = "resource_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "resourceName", column = "resource_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UdfType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UdfFuncMapperProvider.class, method = "queryAllUdfFuncPaging")
|
||||
List<UdfFunc> queryAllUdfFuncPaging(@Param("searchVal") String searchVal,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize);
|
||||
|
||||
|
||||
/**
|
||||
* query udf function by type
|
||||
* @param userId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "funcName", column = "func_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "className", column = "class_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "argTypes", column = "arg_types", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "database", column = "database", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "resourceId", column = "resource_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "resourceName", column = "resource_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UdfType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UdfFuncMapperProvider.class, method = "getUdfFuncByType")
|
||||
List<UdfFunc> getUdfFuncByType(@Param("userId") int userId,@Param("type") Integer type);
|
||||
|
||||
|
||||
/**
|
||||
* query udf function by name
|
||||
* @param funcName
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "funcName", column = "func_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "className", column = "class_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "argTypes", column = "arg_types", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "database", column = "database", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "resourceId", column = "resource_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "resourceName", column = "resource_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UdfType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UdfFuncMapperProvider.class, method = "queryUdfFuncByName")
|
||||
UdfFunc queryUdfFuncByName(@Param("func_name") String funcName);
|
||||
|
||||
/**
|
||||
* delete udf function
|
||||
*
|
||||
* @param udfFuncId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = UdfFuncMapperProvider.class, method = "delete")
|
||||
int delete(@Param("udfFuncId") int udfFuncId);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* query udf function except user
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "funcName", column = "func_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "className", column = "class_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "argTypes", column = "arg_types", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "database", column = "database", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "resourceId", column = "resource_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "resourceName", column = "resource_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UdfType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UdfFuncMapperProvider.class, method = "queryUdfFuncExceptUserId")
|
||||
List<UdfFunc> queryUdfFuncExceptUserId(@Param("userId") int userId);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* query udf function authorized to user
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "funcName", column = "func_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "className", column = "class_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "argTypes", column = "arg_types", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "database", column = "database", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "desc", column = "desc", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "resourceId", column = "resource_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "resourceName", column = "resource_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "type", column = "type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UdfType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UdfFuncMapperProvider.class, method = "authedUdfFunc")
|
||||
List<UdfFunc> authedUdfFunc(@Param("userId") int userId);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,253 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.UdfType;
|
||||
import cn.escheduler.common.utils.EnumFieldUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* und function mapper
|
||||
*/
|
||||
public class UdfFuncMapperProvider {
|
||||
private final String TABLE_NAME = "t_escheduler_udfs";
|
||||
public static final String USER_UDFS_RELATION_TABLE_NAME = "t_escheduler_relation_udfs_user";
|
||||
|
||||
/**
|
||||
* insert udf function
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
VALUES("`user_id`", "#{udf.userId}");
|
||||
VALUES("`func_name`", "#{udf.funcName,jdbcType=VARCHAR}");
|
||||
VALUES("`class_name`", "#{udf.className}");
|
||||
VALUES("`arg_types`", "#{udf.argTypes}");
|
||||
VALUES("`database`", "#{udf.database}");
|
||||
VALUES("`desc`", "#{udf.desc}");
|
||||
VALUES("`resource_id`", "#{udf.resourceId}");
|
||||
VALUES("`resource_name`", "#{udf.resourceName}");
|
||||
VALUES("`type`", EnumFieldUtil.genFieldStr("udf.type", UdfType.class));
|
||||
VALUES("`create_time`", "#{udf.createTime}");
|
||||
VALUES("`update_time`", "#{udf.updateTime}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update udf function
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`user_id`=#{udf.userId}");
|
||||
SET("`func_name`=#{udf.funcName}");
|
||||
SET("`class_name`=#{udf.className}");
|
||||
SET("`arg_types`=#{udf.argTypes}");
|
||||
SET("`database`=#{udf.database}");
|
||||
SET("`desc`=#{udf.desc}");
|
||||
SET("`resource_id`=#{udf.resourceId}");
|
||||
SET("`resource_name`=#{udf.resourceName}");
|
||||
SET("`type`="+EnumFieldUtil.genFieldStr("udf.type", UdfType.class));
|
||||
SET("`update_time`=#{udf.updateTime}");
|
||||
|
||||
WHERE("`id`=#{udf.id}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query udf function by id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryUdfById(Map<String, Object> parameter) {
|
||||
|
||||
return new SQL() {{
|
||||
SELECT("r.*");
|
||||
|
||||
FROM(TABLE_NAME + " r");
|
||||
WHERE("r.id = #{id}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query udf list by id string
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryUdfByIdStr(Map<String, Object> parameter) {
|
||||
|
||||
String ids = (String) parameter.get("ids");
|
||||
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("`id` in (" + ids +")");
|
||||
ORDER_BY("`id` asc");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query all udf function paging
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryUdfFuncPaging(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME );
|
||||
WHERE("id in (select udf_id from "+USER_UDFS_RELATION_TABLE_NAME+" where user_id=#{userId} union select id as udf_id from "+TABLE_NAME+" where user_id=#{userId})");
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
ORDER_BY("create_time desc limit #{offset},#{pageSize} ");
|
||||
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query all udf function paging
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryAllUdfFuncPaging(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME );
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
ORDER_BY("create_time desc limit #{offset},#{pageSize} ");
|
||||
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* count udf number by user id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countUserUdfFunc(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("count(0)");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("id in (select udf_id from "+USER_UDFS_RELATION_TABLE_NAME+" where user_id=#{userId} union select id as udf_id from "+TABLE_NAME+" where user_id=#{userId})");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* count udf number
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countAllUdfFunc(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("count(0)");
|
||||
FROM(TABLE_NAME);
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query udf function by type
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String getUdfFuncByType(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME );
|
||||
WHERE("type = #{type}");
|
||||
WHERE("id in (select udf_id from "+USER_UDFS_RELATION_TABLE_NAME+" where user_id=#{userId} union select id as udf_id from "+TABLE_NAME+" where user_id=#{userId})");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query udf function by name
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryUdfFuncByName(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME );
|
||||
WHERE("func_name = #{func_name}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete udf function
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String delete(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id` = #{udfFuncId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* query udf function authorized to user
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String authedUdfFunc(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("u.*");
|
||||
FROM(TABLE_NAME + " u,t_escheduler_relation_udfs_user rel");
|
||||
WHERE(" u.id = rel.udf_id AND rel.user_id = #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query udf function except user
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryUdfFuncExceptUserId(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("user_id <> #{userId}");
|
||||
}}.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.UserType;
|
||||
import cn.escheduler.dao.model.User;
|
||||
import cn.escheduler.dao.model.UserAlertGroup;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.EnumOrdinalTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* user alert group mapper
|
||||
*/
|
||||
public interface UserAlertGroupMapper {
|
||||
|
||||
/**
|
||||
* insert user alert group
|
||||
* @param userAlertGroup
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = UserAlertGroupMapperProvider.class, method = "insert")
|
||||
@Options(useGeneratedKeys = true,keyProperty = "userAlertGroup.id")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "userAlertGroup.id", before = false, resultType = int.class)
|
||||
int insert(@Param("userAlertGroup") UserAlertGroup userAlertGroup);
|
||||
|
||||
|
||||
/**
|
||||
* query user list by alert group id
|
||||
*
|
||||
* @param alertgroupId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userPassword", column = "user_password", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "email", column = "email", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "phone", column = "phone", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userType", column = "user_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UserType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "tenantId", column = "tenant_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UserAlertGroupMapperProvider.class, method = "queryForUser")
|
||||
List<User> queryForUser(@Param("alertgroupId") int alertgroupId);
|
||||
|
||||
|
||||
/**
|
||||
* delete by alert group id
|
||||
* @param alertgroupId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = UserAlertGroupMapperProvider.class, method = "deleteByAlertgroupId")
|
||||
int deleteByAlertgroupId(@Param("alertgroupId") int alertgroupId);
|
||||
|
||||
/**
|
||||
* list user information by alert group id
|
||||
*
|
||||
* @param alertgroupId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userPassword", column = "user_password", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "email", column = "email", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "phone", column = "phone", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userType", column = "user_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UserType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "tenantId", column = "tenant_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
})
|
||||
@SelectProvider(type = UserAlertGroupMapperProvider.class, method = "listUserByAlertgroupId")
|
||||
List<User> listUserByAlertgroupId(@Param("alertgroupId") int alertgroupId);
|
||||
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* user alert group mapper provider
|
||||
*/
|
||||
public class UserAlertGroupMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_relation_user_alertgroup";
|
||||
|
||||
/**
|
||||
* insert user alert grouExecutorService.p
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
VALUES("`alertgroup_id`", "#{userAlertGroup.alertgroupId}");
|
||||
VALUES("`user_id`", "#{userAlertGroup.userId}");
|
||||
VALUES("`create_time`", "#{userAlertGroup.createTime}");
|
||||
VALUES("`update_time`", "#{userAlertGroup.updateTime}");
|
||||
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query user list by alert group id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryForUser(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("u.*");
|
||||
|
||||
FROM(TABLE_NAME + " g_u");
|
||||
|
||||
JOIN("t_escheduler_user u on g_u.user_id = u.id");
|
||||
|
||||
WHERE("g_u.alertgroup_id = #{alertgroupId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete by alert group id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String deleteByAlertgroupId(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`alertgroup_id` = #{alertgroupId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* list user information by alert group id
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String listUserByAlertgroupId(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("u.*");
|
||||
|
||||
FROM(TABLE_NAME + " g_u");
|
||||
|
||||
JOIN("t_escheduler_user u on g_u.user_id = u.id");
|
||||
|
||||
WHERE("g_u.alertgroup_id = #{alertgroupId}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,225 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.UserType;
|
||||
import cn.escheduler.dao.model.User;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.EnumOrdinalTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
public interface UserMapper {
|
||||
|
||||
/**
|
||||
* insert user
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = UserMapperProvider.class, method = "insert")
|
||||
@Options(useGeneratedKeys = true,keyProperty = "user.id")
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "user.id", before = false, resultType = int.class)
|
||||
int insert(@Param("user") User user);
|
||||
|
||||
|
||||
/**
|
||||
* delete user
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = UserMapperProvider.class, method = "delete")
|
||||
int delete(@Param("userId") int userId);
|
||||
|
||||
|
||||
/**
|
||||
* update user
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = UserMapperProvider.class, method = "update")
|
||||
int update(@Param("user") User user);
|
||||
|
||||
|
||||
/**
|
||||
* query user by id
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userPassword", column = "user_password", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "email", column = "email", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "phone", column = "phone", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userType", column = "user_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UserType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "tenantId", column = "tenant_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UserMapperProvider.class, method = "queryById")
|
||||
User queryById(@Param("userId") int userId);
|
||||
|
||||
/**
|
||||
* query all user list
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userPassword", column = "user_password", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "email", column = "email", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "phone", column = "phone", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userType", column = "user_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UserType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "tenantId", column = "tenant_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UserMapperProvider.class, method = "queryAllUsers")
|
||||
List<User> queryAllUsers();
|
||||
|
||||
|
||||
/**
|
||||
* check user name and password
|
||||
* @param userName
|
||||
* @param userPassword
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userPassword", column = "user_password", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "email", column = "email", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "phone", column = "phone", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userType", column = "user_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UserType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "tenantId", column = "tenant_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UserMapperProvider.class, method = "queryForCheck")
|
||||
User queryForCheck(@Param("userName") String userName, @Param("userPassword") String userPassword);
|
||||
|
||||
|
||||
/**
|
||||
* query user by name
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userPassword", column = "user_password", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "email", column = "email", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "phone", column = "phone", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userType", column = "user_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UserType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "tenantId", column = "tenant_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UserMapperProvider.class, method = "queryByUserName")
|
||||
User queryByUserName(@Param("userName") String userName);
|
||||
|
||||
/**
|
||||
* count user by search value
|
||||
* @param searchVal
|
||||
* @return
|
||||
*/
|
||||
@SelectProvider(type = UserMapperProvider.class, method = "countUserPaging")
|
||||
Integer countUserPaging(@Param("searchVal") String searchVal);
|
||||
|
||||
|
||||
/**
|
||||
* query user list paging
|
||||
* @param searchVal
|
||||
* @param offset
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userPassword", column = "user_password", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "email", column = "email", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "phone", column = "phone", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userType", column = "user_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UserType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "tenantId", column = "tenant_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UserMapperProvider.class, method = "queryUserPaging")
|
||||
List<User> queryUserPaging(@Param("searchVal") String searchVal,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("pageSize") Integer pageSize);
|
||||
|
||||
/**
|
||||
* query detail by user id
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userPassword", column = "user_password", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "email", column = "email", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "phone", column = "phone", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userType", column = "user_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UserType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "tenantId", column = "tenant_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "tenantName", column = "tenant_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "queueName", column = "queue_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UserMapperProvider.class, method = "queryDetailsById")
|
||||
User queryDetailsById(@Param("id") int id);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id查询已经授权的告警组
|
||||
* @param alertgroupId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userPassword", column = "user_password", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "email", column = "email", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "phone", column = "phone", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userType", column = "user_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UserType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "tenantId", column = "tenant_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UserMapperProvider.class, method = "queryUserListByAlertGroupId")
|
||||
List<User> queryUserListByAlertGroupId(@Param("alertgroupId") int alertgroupId);
|
||||
|
||||
|
||||
/**
|
||||
* query tenant code by user id
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "userName", column = "user_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userPassword", column = "user_password", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "email", column = "email", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "phone", column = "phone", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "userType", column = "user_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = UserType.class, jdbcType = JdbcType.TINYINT),
|
||||
@Result(property = "tenantId", column = "tenant_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "tenantCode", column = "tenant_code", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
|
||||
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
|
||||
})
|
||||
@SelectProvider(type = UserMapperProvider.class, method = "queryTenantCodeByUserId")
|
||||
User queryTenantCodeByUserId(@Param("userId") int userId);
|
||||
}
|
@ -0,0 +1,250 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.UserType;
|
||||
import cn.escheduler.common.utils.EnumFieldUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* und function mapper provider
|
||||
*
|
||||
*/
|
||||
public class UserMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_user";
|
||||
|
||||
/**
|
||||
* insert user
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
VALUES("`user_name`", "#{user.userName}");
|
||||
VALUES("`user_password`", "#{user.userPassword}");
|
||||
VALUES("`email`", "#{user.email}");
|
||||
VALUES("`phone`", "#{user.phone}");
|
||||
VALUES("`user_type`", EnumFieldUtil.genFieldStr("user.userType", UserType.class));
|
||||
VALUES("`tenant_id`", "#{user.tenantId}");
|
||||
VALUES("`create_time`", "#{user.createTime}");
|
||||
VALUES("`update_time`", "#{user.updateTime}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete user
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String delete(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id`=#{userId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update user
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("`user_name`=#{user.userName}");
|
||||
SET("`user_password`=#{user.userPassword}");
|
||||
SET("`email`=#{user.email}");
|
||||
SET("`phone`=#{user.phone}");
|
||||
SET("`user_type`="+EnumFieldUtil.genFieldStr("user.userType", UserType.class));
|
||||
SET("`tenant_id`=#{user.tenantId}");
|
||||
SET("`create_time`=#{user.createTime}");
|
||||
SET("`update_time`=#{user.updateTime}");
|
||||
|
||||
WHERE("`id`=#{user.id}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query user by id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryById(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("`id` = #{userId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query all user list
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String queryAllUsers() {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
|
||||
WHERE("user_type = 1");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* check user name and password
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryForCheck(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("`user_name` = #{userName} AND `user_password` = #{userPassword}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query user by name
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryByUserName(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("*");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("`user_name` = #{userName}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* count user number by search value
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String countUserPaging(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
SELECT("count(0)");
|
||||
FROM(TABLE_NAME);
|
||||
WHERE("user_type = 1");
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " user_name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* query user list paging
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryUserPaging(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("u.*,t.tenant_name as tenantName,q.queue_name as queueName");
|
||||
FROM(TABLE_NAME +" u,t_escheduler_tenant t,t_escheduler_queue q");
|
||||
WHERE("u.user_type = 1 AND u.tenant_id = t.id and t.queue_id = q.id");
|
||||
Object searchVal = parameter.get("searchVal");
|
||||
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
|
||||
WHERE( " u.user_name like concat('%', #{searchVal}, '%') ");
|
||||
}
|
||||
ORDER_BY(" u.update_time desc limit #{offset},#{pageSize} ");
|
||||
}
|
||||
}.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* query detail by user id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryDetailsById(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("u.*,q.queue_name as queueName,t.tenant_name as tenantName");
|
||||
|
||||
FROM(TABLE_NAME + " u,t_escheduler_tenant t,t_escheduler_queue q");
|
||||
|
||||
WHERE("u.tenant_id = t.id and t.queue_id = q.id and u.id = #{id}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query user list by alert group id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryUserListByAlertGroupId(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("u.*");
|
||||
FROM(TABLE_NAME + " u,t_escheduler_relation_user_alertgroup rel");
|
||||
WHERE("u.id = rel.user_id AND u.user_type = 1 AND rel.alertgroup_id = #{alertgroupId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query tenant code by user id
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String queryTenantCodeByUserId(Map<String, Object> parameter) {
|
||||
return new SQL() {
|
||||
{
|
||||
SELECT("u.*,t.tenant_code as tenantCode");
|
||||
FROM(TABLE_NAME + " u,t_escheduler_tenant t");
|
||||
WHERE("u.tenant_id = t.id AND u.id = #{userId}");
|
||||
}
|
||||
}.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.dao.model.WorkerServer;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface WorkerServerMapper {
|
||||
|
||||
/**
|
||||
* query worker list
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "host", column = "host", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "port", column = "port", javaType = int.class, jdbcType = JdbcType.INTEGER),
|
||||
@Result(property = "zkDirectory", column = "zk_directory", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "resInfo", column = "res_info", javaType = String.class, jdbcType = JdbcType.VARCHAR),
|
||||
@Result(property = "createTime", column = "create_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(property = "lastHeartbeatTime", column = "last_heartbeat_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP)
|
||||
})
|
||||
@SelectProvider(type = WorkerServerMapperProvider.class, method = "queryAllWorker")
|
||||
List<WorkerServer> queryAllWorker();
|
||||
|
||||
/**
|
||||
* insert worker server
|
||||
*
|
||||
* @param workerServer
|
||||
* @return
|
||||
*/
|
||||
@InsertProvider(type = WorkerServerMapperProvider.class, method = "insert")
|
||||
int insert(@Param("workerServer") WorkerServer workerServer);
|
||||
|
||||
/**
|
||||
* update worker
|
||||
*
|
||||
* @param workerServer
|
||||
* @return
|
||||
*/
|
||||
@UpdateProvider(type = WorkerServerMapperProvider.class, method = "update")
|
||||
int update(@Param("workerServer") WorkerServer workerServer);
|
||||
|
||||
/**
|
||||
* delete work by host
|
||||
* @param host
|
||||
* @return
|
||||
*/
|
||||
@DeleteProvider(type = WorkerServerMapperProvider.class, method = "deleteWorkerByHost")
|
||||
int deleteWorkerByHost(@Param("host") String host);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.escheduler.dao.mapper;
|
||||
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class WorkerServerMapperProvider {
|
||||
|
||||
private static final String TABLE_NAME = "t_escheduler_worker_server";
|
||||
|
||||
/**
|
||||
* query worker list
|
||||
* @return
|
||||
*/
|
||||
public String queryAllWorker() {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
|
||||
FROM(TABLE_NAME);
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* insert worker server
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String insert(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
INSERT_INTO(TABLE_NAME);
|
||||
|
||||
VALUES("host", "#{workerServer.host}");
|
||||
VALUES("port", "#{workerServer.port}");
|
||||
VALUES("zk_directory", "#{workerServer.zkDirectory}");
|
||||
VALUES("res_info", "#{workerServer.resInfo}");
|
||||
VALUES("create_time", "#{workerServer.createTime}");
|
||||
VALUES("last_heartbeat_time", "#{workerServer.lastHeartbeatTime}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* update worker
|
||||
*
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String update(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
UPDATE(TABLE_NAME);
|
||||
|
||||
SET("last_heartbeat_time = #{workerServer.lastHeartbeatTime}");
|
||||
SET("port = #{workerServer.port}");
|
||||
SET("res_info = #{workerServer.resInfo}");
|
||||
|
||||
WHERE("host = #{workerServer.host}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete work by host
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
public String deleteWorkerByHost(Map<String, Object> parameter) {
|
||||
return new SQL() {{
|
||||
DELETE_FROM(TABLE_NAME);
|
||||
|
||||
WHERE("host = #{host}");
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
228
escheduler-dao/src/main/java/cn/escheduler/dao/model/Alert.java
Normal file
228
escheduler-dao/src/main/java/cn/escheduler/dao/model/Alert.java
Normal file
@ -0,0 +1,228 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import cn.escheduler.common.enums.AlertStatus;
|
||||
import cn.escheduler.common.enums.AlertType;
|
||||
import cn.escheduler.common.enums.ShowType;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* alert
|
||||
*/
|
||||
public class Alert {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* title
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* show type
|
||||
*/
|
||||
private ShowType showType;
|
||||
/**
|
||||
* content
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* alert type
|
||||
*/
|
||||
private AlertType alertType;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* alert status
|
||||
*/
|
||||
private AlertStatus alertStatus;
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
private String log;
|
||||
|
||||
/**
|
||||
* alert group id
|
||||
*/
|
||||
private int alertGroupId;
|
||||
|
||||
|
||||
/**
|
||||
* receivers
|
||||
*/
|
||||
private String receivers;
|
||||
|
||||
/**
|
||||
* receivers cc
|
||||
*/
|
||||
private String receiversCc;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
private Map<String,Object> info = new HashMap<>();
|
||||
|
||||
public Map<String, Object> getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(Map<String, Object> info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public Alert() {
|
||||
}
|
||||
|
||||
public Alert(int id,String title) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
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 ShowType getShowType() {
|
||||
return showType;
|
||||
}
|
||||
|
||||
public void setShowType(ShowType showType) {
|
||||
this.showType = showType;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public AlertType getAlertType() {
|
||||
return alertType;
|
||||
}
|
||||
|
||||
public void setAlertType(AlertType alertType) {
|
||||
this.alertType = alertType;
|
||||
}
|
||||
|
||||
|
||||
public AlertStatus getAlertStatus() {
|
||||
return alertStatus;
|
||||
}
|
||||
|
||||
public void setAlertStatus(AlertStatus alertStatus) {
|
||||
this.alertStatus = alertStatus;
|
||||
}
|
||||
|
||||
public String getLog() {
|
||||
return log;
|
||||
}
|
||||
|
||||
public void setLog(String log) {
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
public int getAlertGroupId() {
|
||||
return alertGroupId;
|
||||
}
|
||||
|
||||
public void setAlertGroupId(int alertGroupId) {
|
||||
this.alertGroupId = alertGroupId;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public String getReceivers() {
|
||||
return receivers;
|
||||
}
|
||||
|
||||
public void setReceivers(String receivers) {
|
||||
this.receivers = receivers;
|
||||
}
|
||||
|
||||
public String getReceiversCc() {
|
||||
return receiversCc;
|
||||
}
|
||||
|
||||
public void setReceiversCc(String receiversCc) {
|
||||
this.receiversCc = receiversCc;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Alert{" +
|
||||
"id=" + id +
|
||||
", title='" + title + '\'' +
|
||||
", showType=" + showType +
|
||||
", content='" + content + '\'' +
|
||||
", alertType=" + alertType +
|
||||
", alertStatus=" + alertStatus +
|
||||
", log='" + log + '\'' +
|
||||
", alertGroupId=" + alertGroupId +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
", receivers='" + receivers + '\'' +
|
||||
", receiversCc='" + receiversCc + '\'' +
|
||||
", info=" + info +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import cn.escheduler.common.enums.AlertType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* alert group
|
||||
*/
|
||||
public class AlertGroup {
|
||||
/**
|
||||
* primary key
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* alert group name
|
||||
*/
|
||||
private String groupName;
|
||||
/**
|
||||
* alert group type
|
||||
*/
|
||||
private AlertType groupType;
|
||||
|
||||
/**
|
||||
* alert group description
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public void setGroupName(String groupName) {
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
public AlertType getGroupType() {
|
||||
return groupType;
|
||||
}
|
||||
|
||||
public void setGroupType(AlertType groupType) {
|
||||
this.groupType = groupType;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AlertGroup{" +
|
||||
"id=" + id +
|
||||
", groupName='" + groupName + '\'' +
|
||||
", groupType=" + groupType +
|
||||
", desc='" + desc + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,250 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import cn.escheduler.common.enums.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* command
|
||||
*/
|
||||
public class Command {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* command type
|
||||
*/
|
||||
private CommandType commandType;
|
||||
|
||||
/**
|
||||
* process definition id
|
||||
*/
|
||||
private int processDefinitionId;
|
||||
|
||||
/**
|
||||
* executor id
|
||||
*/
|
||||
private int executorId;
|
||||
|
||||
/**
|
||||
* command parameter, format json
|
||||
*/
|
||||
private String commandParam;
|
||||
|
||||
/**
|
||||
* task depend type
|
||||
*/
|
||||
private TaskDependType taskDependType;
|
||||
|
||||
/**
|
||||
* failure strategy
|
||||
*/
|
||||
private FailureStrategy failureStrategy;
|
||||
|
||||
/**
|
||||
* warning type
|
||||
*/
|
||||
private WarningType warningType;
|
||||
|
||||
/**
|
||||
* warning group id
|
||||
*/
|
||||
private Integer warningGroupId;
|
||||
|
||||
/**
|
||||
* schedule time
|
||||
*/
|
||||
private Date scheduleTime;
|
||||
|
||||
/**
|
||||
* start time
|
||||
*/
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* process instance priority
|
||||
*/
|
||||
private Priority processInstancePriority;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
public Command(){
|
||||
this.taskDependType = TaskDependType.TASK_POST;
|
||||
this.failureStrategy = FailureStrategy.CONTINUE;
|
||||
this.startTime = new Date();
|
||||
this.updateTime = new Date();
|
||||
}
|
||||
|
||||
public Command(
|
||||
CommandType commandType,
|
||||
TaskDependType taskDependType,
|
||||
FailureStrategy failureStrategy,
|
||||
int executorId,
|
||||
int processDefinitionId,
|
||||
String commandParam,
|
||||
WarningType warningType,
|
||||
int warningGroupId,
|
||||
Date scheduleTime,
|
||||
Priority processInstancePriority){
|
||||
this.commandType = commandType;
|
||||
this.executorId = executorId;
|
||||
this.processDefinitionId = processDefinitionId;
|
||||
this.commandParam = commandParam;
|
||||
this.warningType = warningType;
|
||||
this.warningGroupId = warningGroupId;
|
||||
this.scheduleTime = scheduleTime;
|
||||
this.taskDependType = taskDependType;
|
||||
this.failureStrategy = failureStrategy;
|
||||
this.startTime = new Date();
|
||||
this.updateTime = new Date();
|
||||
this.processInstancePriority = processInstancePriority;
|
||||
}
|
||||
|
||||
|
||||
public TaskDependType getTaskDependType() {
|
||||
return taskDependType;
|
||||
}
|
||||
|
||||
public void setTaskDependType(TaskDependType taskDependType) {
|
||||
this.taskDependType = taskDependType;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public CommandType getCommandType() {
|
||||
return commandType;
|
||||
}
|
||||
|
||||
public void setCommandType(CommandType commandType) {
|
||||
this.commandType = commandType;
|
||||
}
|
||||
|
||||
public int getProcessDefinitionId() {
|
||||
return processDefinitionId;
|
||||
}
|
||||
|
||||
public void setProcessDefinitionId(int processDefinitionId) {
|
||||
this.processDefinitionId = processDefinitionId;
|
||||
}
|
||||
|
||||
|
||||
public FailureStrategy getFailureStrategy() {
|
||||
return failureStrategy;
|
||||
}
|
||||
|
||||
public void setFailureStrategy(FailureStrategy failureStrategy) {
|
||||
this.failureStrategy = failureStrategy;
|
||||
}
|
||||
|
||||
public void setCommandParam(String commandParam) {
|
||||
this.commandParam = commandParam;
|
||||
}
|
||||
|
||||
public String getCommandParam() {
|
||||
return commandParam;
|
||||
}
|
||||
|
||||
public WarningType getWarningType() {
|
||||
return warningType;
|
||||
}
|
||||
|
||||
public void setWarningType(WarningType warningType) {
|
||||
this.warningType = warningType;
|
||||
}
|
||||
|
||||
public Integer getWarningGroupId() {
|
||||
return warningGroupId;
|
||||
}
|
||||
|
||||
public void setWarningGroupId(Integer warningGroupId) {
|
||||
this.warningGroupId = warningGroupId;
|
||||
}
|
||||
|
||||
public Date getScheduleTime() {
|
||||
return scheduleTime;
|
||||
}
|
||||
|
||||
public void setScheduleTime(Date scheduleTime) {
|
||||
this.scheduleTime = scheduleTime;
|
||||
}
|
||||
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Date startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public int getExecutorId() {
|
||||
return executorId;
|
||||
}
|
||||
|
||||
public void setExecutorId(int executorId) {
|
||||
this.executorId = executorId;
|
||||
}
|
||||
|
||||
public Priority getProcessInstancePriority() {
|
||||
return processInstancePriority;
|
||||
}
|
||||
|
||||
public void setProcessInstancePriority(Priority processInstancePriority) {
|
||||
this.processInstancePriority = processInstancePriority;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Command{" +
|
||||
"id=" + id +
|
||||
", commandType=" + commandType +
|
||||
", processDefinitionId=" + processDefinitionId +
|
||||
", executorId=" + executorId +
|
||||
", commandParam='" + commandParam + '\'' +
|
||||
", taskDependType=" + taskDependType +
|
||||
", failureStrategy=" + failureStrategy +
|
||||
", warningType=" + warningType +
|
||||
", warningGroupId=" + warningGroupId +
|
||||
", scheduleTime=" + scheduleTime +
|
||||
", startTime=" + startTime +
|
||||
", processInstancePriority=" + processInstancePriority +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import cn.escheduler.common.enums.CycleEnum;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* cycle dependency
|
||||
*/
|
||||
public class CycleDependency {
|
||||
/**
|
||||
* process define id
|
||||
*/
|
||||
private int processDefineId;
|
||||
/**
|
||||
* last schedule time
|
||||
*/
|
||||
private Date lastScheduleTime;
|
||||
/**
|
||||
* expiration time
|
||||
*/
|
||||
private Date expirationTime;
|
||||
/**
|
||||
* cycle enum
|
||||
*/
|
||||
private CycleEnum cycleEnum;
|
||||
|
||||
|
||||
public CycleDependency(int processDefineId, Date lastScheduleTime, Date expirationTime, CycleEnum cycleEnum) {
|
||||
this.processDefineId = processDefineId;
|
||||
this.lastScheduleTime = lastScheduleTime;
|
||||
this.expirationTime = expirationTime;
|
||||
this.cycleEnum = cycleEnum;
|
||||
}
|
||||
|
||||
public int getProcessDefineId() {
|
||||
return processDefineId;
|
||||
}
|
||||
|
||||
public void setProcessDefineId(int processDefineId) {
|
||||
this.processDefineId = processDefineId;
|
||||
}
|
||||
|
||||
public Date getLastScheduleTime() {
|
||||
return lastScheduleTime;
|
||||
}
|
||||
|
||||
public void setLastScheduleTime(Date lastScheduleTime) {
|
||||
this.lastScheduleTime = lastScheduleTime;
|
||||
}
|
||||
|
||||
public Date getExpirationTime() {
|
||||
return expirationTime;
|
||||
}
|
||||
|
||||
public void setExpirationTime(Date expirationTime) {
|
||||
this.expirationTime = expirationTime;
|
||||
}
|
||||
|
||||
public CycleEnum getCycleEnum() {
|
||||
return cycleEnum;
|
||||
}
|
||||
|
||||
public void setCycleEnum(CycleEnum cycleEnum) {
|
||||
this.cycleEnum = cycleEnum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CycleDependency{" +
|
||||
"processDefineId=" + processDefineId +
|
||||
", lastScheduleTime=" + lastScheduleTime +
|
||||
", expirationTime=" + expirationTime +
|
||||
", cycleEnum=" + cycleEnum +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
|
||||
import cn.escheduler.common.enums.DbType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class DataSource {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* user id
|
||||
*/
|
||||
private int userId;
|
||||
|
||||
/**
|
||||
* user name
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* data source name
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* note
|
||||
*/
|
||||
private String note;
|
||||
|
||||
/**
|
||||
* data source type
|
||||
*/
|
||||
private DbType type;
|
||||
|
||||
/**
|
||||
* connection parameters
|
||||
*/
|
||||
private String connectionParams;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public DataSource() {
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
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 String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public DbType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(DbType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getConnectionParams() {
|
||||
return connectionParams;
|
||||
}
|
||||
|
||||
public void setConnectionParams(String connectionParams) {
|
||||
this.connectionParams = connectionParams;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DataSource{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", userName='" + userName + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", note='" + note + '\'' +
|
||||
", type=" + type +
|
||||
", connectionParams='" + connectionParams + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DataSource that = (DataSource) o;
|
||||
|
||||
if (id != that.id) {
|
||||
return false;
|
||||
}
|
||||
return name.equals(that.name);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id;
|
||||
result = 31 * result + name.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* data source user relation
|
||||
*/
|
||||
public class DatasourceUser {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* user id
|
||||
*/
|
||||
private int userId;
|
||||
|
||||
/**
|
||||
* data source id
|
||||
*/
|
||||
private int datasourceId;
|
||||
|
||||
/**
|
||||
* permission
|
||||
*/
|
||||
private int perm;
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getDatasourceId() {
|
||||
return datasourceId;
|
||||
}
|
||||
|
||||
public void setDatasourceId(int datasourceId) {
|
||||
this.datasourceId = datasourceId;
|
||||
}
|
||||
|
||||
public int getPerm() {
|
||||
return perm;
|
||||
}
|
||||
|
||||
public void setPerm(int perm) {
|
||||
this.perm = perm;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DatasourceUser{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", datasourceId=" + datasourceId +
|
||||
", perm=" + perm +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
/**
|
||||
* count definition number group by user
|
||||
*/
|
||||
public class DefinitionGroupByUser {
|
||||
|
||||
/**
|
||||
* user name
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* user id
|
||||
*/
|
||||
private Integer userId;
|
||||
|
||||
/**
|
||||
* count number
|
||||
*/
|
||||
private int count;
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import cn.escheduler.common.enums.SelfDependStrategy;
|
||||
|
||||
/**
|
||||
* dependency
|
||||
*/
|
||||
public class Dependency {
|
||||
|
||||
/**
|
||||
* self depend strategy
|
||||
*/
|
||||
private SelfDependStrategy self;
|
||||
|
||||
/**
|
||||
* outer dependency string
|
||||
*/
|
||||
private String outer;
|
||||
|
||||
|
||||
public Dependency(){}
|
||||
|
||||
public Dependency(String outer, SelfDependStrategy self){
|
||||
|
||||
this.outer = outer;
|
||||
this.self = self;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public SelfDependStrategy getSelf() {
|
||||
return self;
|
||||
}
|
||||
|
||||
public void setSelf(SelfDependStrategy self) {
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public String getOuter() {
|
||||
return outer;
|
||||
}
|
||||
|
||||
public void setOuter(String outer) {
|
||||
this.outer = outer;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.escheduler.dao.model;
|
||||
|
||||
|
||||
import cn.escheduler.common.enums.ExecutionStatus;
|
||||
|
||||
/**
|
||||
* count execute state
|
||||
*
|
||||
*/
|
||||
public class ExecuteStatusCount {
|
||||
|
||||
/**
|
||||
* execution state
|
||||
*/
|
||||
private ExecutionStatus state;
|
||||
|
||||
/**
|
||||
* count for state
|
||||
*/
|
||||
private int count;
|
||||
|
||||
public ExecutionStatus getExecutionStatus() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setExecutionStatus(ExecutionStatus executionStatus) {
|
||||
this.state = executionStatus;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* master server
|
||||
*/
|
||||
public class MasterServer {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* host
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* port
|
||||
*/
|
||||
private int port;
|
||||
|
||||
/**
|
||||
* master direcotry in zookeeper
|
||||
*/
|
||||
private String zkDirectory;
|
||||
|
||||
/**
|
||||
* resource info: CPU and memory
|
||||
*/
|
||||
private String resInfo;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* laster heart beat time
|
||||
*/
|
||||
private Date lastHeartbeatTime;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getZkDirectory() {
|
||||
return zkDirectory;
|
||||
}
|
||||
|
||||
public void setZkDirectory(String zkDirectory) {
|
||||
this.zkDirectory = zkDirectory;
|
||||
}
|
||||
|
||||
public Date getLastHeartbeatTime() {
|
||||
return lastHeartbeatTime;
|
||||
}
|
||||
|
||||
public void setLastHeartbeatTime(Date lastHeartbeatTime) {
|
||||
this.lastHeartbeatTime = lastHeartbeatTime;
|
||||
}
|
||||
|
||||
public String getResInfo() {
|
||||
return resInfo;
|
||||
}
|
||||
|
||||
public void setResInfo(String resInfo) {
|
||||
this.resInfo = resInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MasterServer{" +
|
||||
"id=" + id +
|
||||
", host='" + host + '\'' +
|
||||
", port=" + port +
|
||||
", zkDirectory='" + zkDirectory + '\'' +
|
||||
", resInfo='" + resInfo + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", lastHeartbeatTime=" + lastHeartbeatTime +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import cn.escheduler.common.model.TaskNode;
|
||||
import cn.escheduler.common.process.Property;
|
||||
import cn.escheduler.common.utils.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* definition json data structure
|
||||
*/
|
||||
public class ProcessData {
|
||||
/**
|
||||
* task list
|
||||
*/
|
||||
private List<TaskNode> tasks;
|
||||
|
||||
/**
|
||||
* global parameters
|
||||
*/
|
||||
private List<Property> globalParams;
|
||||
|
||||
|
||||
public ProcessData() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param tasks
|
||||
* @param globalParams
|
||||
*/
|
||||
public ProcessData(List<TaskNode> tasks, List<Property> globalParams) {
|
||||
this.tasks = tasks;
|
||||
this.globalParams = globalParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ProcessData that = (ProcessData) o;
|
||||
|
||||
return CollectionUtils.equalLists(tasks, that.tasks) &&
|
||||
CollectionUtils.equalLists(globalParams, that.globalParams);
|
||||
}
|
||||
|
||||
public List<TaskNode> getTasks() {
|
||||
return tasks;
|
||||
}
|
||||
|
||||
public void setTasks(List<TaskNode> tasks) {
|
||||
this.tasks = tasks;
|
||||
}
|
||||
|
||||
public List<Property> getGlobalParams() {
|
||||
return globalParams;
|
||||
}
|
||||
|
||||
public void setGlobalParams(List<Property> globalParams) {
|
||||
this.globalParams = globalParams;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,345 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import cn.escheduler.common.enums.Flag;
|
||||
import cn.escheduler.common.enums.ReleaseState;
|
||||
import cn.escheduler.common.process.Property;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* process definition
|
||||
*/
|
||||
public class ProcessDefinition {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* version
|
||||
*/
|
||||
private int version;
|
||||
|
||||
/**
|
||||
* release state : online/offline
|
||||
*/
|
||||
private ReleaseState releaseState;
|
||||
|
||||
/**
|
||||
* project id
|
||||
*/
|
||||
private int projectId;
|
||||
|
||||
/**
|
||||
* definition json string
|
||||
*/
|
||||
private String processDefinitionJson;
|
||||
|
||||
/**
|
||||
* description
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* user defined parameters
|
||||
*/
|
||||
private String globalParams;
|
||||
|
||||
/**
|
||||
* user defined parameter list
|
||||
*/
|
||||
private List<Property> globalParamList;
|
||||
|
||||
/**
|
||||
* user define parameter map
|
||||
*/
|
||||
private Map<String,String> globalParamMap;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* process is valid: yes/no
|
||||
*/
|
||||
private Flag flag;
|
||||
|
||||
/**
|
||||
* process user id
|
||||
*/
|
||||
private int userId;
|
||||
|
||||
/**
|
||||
* user name
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* project name
|
||||
*/
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* locations array for web
|
||||
*/
|
||||
private String locations;
|
||||
|
||||
/**
|
||||
* connects array for web
|
||||
*/
|
||||
private String connects;
|
||||
|
||||
/**
|
||||
* receivers
|
||||
*/
|
||||
private String receivers;
|
||||
|
||||
/**
|
||||
* receivers cc
|
||||
*/
|
||||
private String receiversCc;
|
||||
|
||||
/**
|
||||
* schedule release state : online/offline
|
||||
*/
|
||||
private ReleaseState scheduleReleaseState;
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public ReleaseState getReleaseState() {
|
||||
return releaseState;
|
||||
}
|
||||
|
||||
public void setReleaseState(ReleaseState releaseState) {
|
||||
this.releaseState = releaseState;
|
||||
}
|
||||
|
||||
public String getProcessDefinitionJson() {
|
||||
return processDefinitionJson;
|
||||
}
|
||||
|
||||
public void setProcessDefinitionJson(String processDefinitionJson) {
|
||||
this.processDefinitionJson = processDefinitionJson;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public int getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
public void setProjectId(int projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Flag getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(Flag flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
|
||||
public String getGlobalParams() {
|
||||
return globalParams;
|
||||
}
|
||||
|
||||
public void setGlobalParams(String globalParams) {
|
||||
this.globalParamList = JSONObject.parseArray(globalParams, Property.class);
|
||||
this.globalParams = globalParams;
|
||||
}
|
||||
|
||||
public List<Property> getGlobalParamList() {
|
||||
return globalParamList;
|
||||
}
|
||||
|
||||
public void setGlobalParamList(List<Property> globalParamList) {
|
||||
this.globalParams = JSONObject.toJSONString(globalParamList);
|
||||
this.globalParamList = globalParamList;
|
||||
}
|
||||
|
||||
public Map<String, String> getGlobalParamMap() {
|
||||
List<Property> propList;
|
||||
|
||||
if (globalParamMap == null && StringUtils.isNotEmpty(globalParams)) {
|
||||
propList = JSONObject.parseArray(globalParams, Property.class);
|
||||
globalParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue));
|
||||
}
|
||||
|
||||
return globalParamMap;
|
||||
}
|
||||
|
||||
public void setGlobalParamMap(Map<String, String> globalParamMap) {
|
||||
this.globalParamMap = globalParamMap;
|
||||
}
|
||||
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getLocations() {
|
||||
return locations;
|
||||
}
|
||||
|
||||
public void setLocations(String locations) {
|
||||
this.locations = locations;
|
||||
}
|
||||
|
||||
public String getConnects() {
|
||||
return connects;
|
||||
}
|
||||
|
||||
public void setConnects(String connects) {
|
||||
this.connects = connects;
|
||||
}
|
||||
|
||||
public String getReceivers() {
|
||||
return receivers;
|
||||
}
|
||||
|
||||
public void setReceivers(String receivers) {
|
||||
this.receivers = receivers;
|
||||
}
|
||||
|
||||
public String getReceiversCc() {
|
||||
return receiversCc;
|
||||
}
|
||||
|
||||
public void setReceiversCc(String receiversCc) {
|
||||
this.receiversCc = receiversCc;
|
||||
}
|
||||
|
||||
public ReleaseState getScheduleReleaseState() {
|
||||
return scheduleReleaseState;
|
||||
}
|
||||
|
||||
public void setScheduleReleaseState(ReleaseState scheduleReleaseState) {
|
||||
this.scheduleReleaseState = scheduleReleaseState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProcessDefinition{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", version=" + version +
|
||||
", releaseState=" + releaseState +
|
||||
", projectId=" + projectId +
|
||||
", processDefinitionJson='" + processDefinitionJson + '\'' +
|
||||
", desc='" + desc + '\'' +
|
||||
", globalParams='" + globalParams + '\'' +
|
||||
", globalParamList=" + globalParamList +
|
||||
", globalParamMap=" + globalParamMap +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
", flag=" + flag +
|
||||
", userId=" + userId +
|
||||
", userName='" + userName + '\'' +
|
||||
", projectName='" + projectName + '\'' +
|
||||
", locations='" + locations + '\'' +
|
||||
", connects='" + connects + '\'' +
|
||||
", receivers='" + receivers + '\'' +
|
||||
", receiversCc='" + receiversCc + '\'' +
|
||||
", scheduleReleaseState=" + scheduleReleaseState +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,521 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import cn.escheduler.common.enums.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* process instance
|
||||
*/
|
||||
public class ProcessInstance {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
/**
|
||||
* process definition id
|
||||
*/
|
||||
private int processDefinitionId;
|
||||
/**
|
||||
* process state
|
||||
*/
|
||||
private ExecutionStatus state;
|
||||
/**
|
||||
* recovery flag for failover
|
||||
*/
|
||||
private Flag recovery;
|
||||
/**
|
||||
* start time
|
||||
*/
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* end time
|
||||
*/
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* run time
|
||||
*/
|
||||
private int runTimes;
|
||||
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* host
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* process definition structure
|
||||
*/
|
||||
private ProcessDefinition processDefinition;
|
||||
/**
|
||||
* process command type
|
||||
*/
|
||||
private CommandType commandType;
|
||||
|
||||
/**
|
||||
* command parameters
|
||||
*/
|
||||
private String commandParam;
|
||||
|
||||
/**
|
||||
* node depend type
|
||||
*/
|
||||
private TaskDependType taskDependType;
|
||||
|
||||
/**
|
||||
* task max try times
|
||||
*/
|
||||
private int maxTryTimes;
|
||||
|
||||
/**
|
||||
* failure strategy when task failed.
|
||||
*/
|
||||
private FailureStrategy failureStrategy;
|
||||
|
||||
/**
|
||||
* warning type
|
||||
*/
|
||||
private WarningType warningType;
|
||||
|
||||
/**
|
||||
* warning group
|
||||
*/
|
||||
private Integer warningGroupId;
|
||||
|
||||
/**
|
||||
* schedule time
|
||||
*/
|
||||
private Date scheduleTime;
|
||||
|
||||
/**
|
||||
* command start time
|
||||
*/
|
||||
private Date commandStartTime;
|
||||
|
||||
/**
|
||||
* user define parameters string
|
||||
*/
|
||||
private String globalParams;
|
||||
|
||||
/**
|
||||
* process instance json
|
||||
*/
|
||||
private String processInstanceJson;
|
||||
|
||||
/**
|
||||
* executor id
|
||||
*/
|
||||
private int executorId;
|
||||
|
||||
/**
|
||||
* tenant code
|
||||
*/
|
||||
private String tenantCode;
|
||||
|
||||
/**
|
||||
* queue
|
||||
*/
|
||||
private String queue;
|
||||
|
||||
/**
|
||||
* process is sub process
|
||||
*/
|
||||
private Flag isSubProcess;
|
||||
|
||||
/**
|
||||
* task locations for web
|
||||
*/
|
||||
private String locations;
|
||||
|
||||
/**
|
||||
* task connects for web
|
||||
*/
|
||||
private String connects;
|
||||
|
||||
/**
|
||||
* history command
|
||||
*/
|
||||
private String historyCmd;
|
||||
|
||||
/**
|
||||
* depend processes schedule time
|
||||
*/
|
||||
private String dependenceScheduleTimes;
|
||||
|
||||
/**
|
||||
* process duration
|
||||
* @return
|
||||
*/
|
||||
private Long duration;
|
||||
|
||||
/**
|
||||
* process instance priority
|
||||
*/
|
||||
private Priority processInstancePriority;
|
||||
|
||||
public ProcessInstance(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* set the process name with process define version and timestamp
|
||||
* @param processDefinition
|
||||
*/
|
||||
public ProcessInstance(ProcessDefinition processDefinition){
|
||||
this.processDefinition = processDefinition;
|
||||
this.name = processDefinition.getName() + "-" +
|
||||
processDefinition.getVersion() + "-" +
|
||||
System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public ProcessDefinition getProcessDefinition() {
|
||||
return processDefinition;
|
||||
}
|
||||
|
||||
public void setProcessDefinition(ProcessDefinition processDefinition) {
|
||||
this.processDefinition = processDefinition;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getProcessDefinitionId() {
|
||||
return processDefinitionId;
|
||||
}
|
||||
|
||||
public void setProcessDefinitionId(int processDefinitionId) {
|
||||
this.processDefinitionId = processDefinitionId;
|
||||
}
|
||||
|
||||
public ExecutionStatus getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(ExecutionStatus state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Flag getRecovery() {
|
||||
return recovery;
|
||||
}
|
||||
|
||||
public void setRecovery(Flag recovery) {
|
||||
this.recovery = recovery;
|
||||
}
|
||||
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Date startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Date endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public int getRunTimes() {
|
||||
return runTimes;
|
||||
}
|
||||
|
||||
public void setRunTimes(int runTimes) {
|
||||
this.runTimes = runTimes;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
|
||||
public CommandType getCommandType() {
|
||||
return commandType;
|
||||
}
|
||||
|
||||
public void setCommandType(CommandType commandType) {
|
||||
this.commandType = commandType;
|
||||
}
|
||||
|
||||
public String getCommandParam() {
|
||||
return commandParam;
|
||||
}
|
||||
|
||||
public void setCommandParam(String commandParam) {
|
||||
this.commandParam = commandParam;
|
||||
}
|
||||
|
||||
public TaskDependType getTaskDependType() {
|
||||
return taskDependType;
|
||||
}
|
||||
|
||||
public void setTaskDependType(TaskDependType taskDependType) {
|
||||
this.taskDependType = taskDependType;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxTryTimes() {
|
||||
return maxTryTimes;
|
||||
}
|
||||
|
||||
public void setMaxTryTimes(int maxTryTimes) {
|
||||
this.maxTryTimes = maxTryTimes;
|
||||
}
|
||||
|
||||
public FailureStrategy getFailureStrategy() {
|
||||
return failureStrategy;
|
||||
}
|
||||
|
||||
public void setFailureStrategy(FailureStrategy failureStrategy) {
|
||||
this.failureStrategy = failureStrategy;
|
||||
}
|
||||
|
||||
|
||||
public boolean IsProcessInstanceStop(){
|
||||
return this.state.typeIsFinished();
|
||||
}
|
||||
|
||||
public WarningType getWarningType() {
|
||||
return warningType;
|
||||
}
|
||||
|
||||
public void setWarningType(WarningType warningType) {
|
||||
this.warningType = warningType;
|
||||
}
|
||||
|
||||
public Integer getWarningGroupId() {
|
||||
return warningGroupId;
|
||||
}
|
||||
|
||||
public void setWarningGroupId(Integer warningGroupId) {
|
||||
this.warningGroupId = warningGroupId;
|
||||
}
|
||||
|
||||
public Date getScheduleTime() {
|
||||
return scheduleTime;
|
||||
}
|
||||
|
||||
public void setScheduleTime(Date scheduleTime) {
|
||||
this.scheduleTime = scheduleTime;
|
||||
}
|
||||
|
||||
public Date getCommandStartTime() {
|
||||
return commandStartTime;
|
||||
}
|
||||
|
||||
public void setCommandStartTime(Date commandStartTime) {
|
||||
this.commandStartTime = commandStartTime;
|
||||
}
|
||||
|
||||
public String getGlobalParams() {
|
||||
return globalParams;
|
||||
}
|
||||
|
||||
public void setGlobalParams(String globalParams) {
|
||||
this.globalParams = globalParams;
|
||||
}
|
||||
|
||||
public String getProcessInstanceJson() {
|
||||
return processInstanceJson;
|
||||
}
|
||||
|
||||
public void setProcessInstanceJson(String processInstanceJson) {
|
||||
this.processInstanceJson = processInstanceJson;
|
||||
}
|
||||
|
||||
public String getTenantCode() {
|
||||
return tenantCode;
|
||||
}
|
||||
|
||||
public void setTenantCode(String tenantCode) {
|
||||
this.tenantCode = tenantCode;
|
||||
}
|
||||
|
||||
public String getQueue() {
|
||||
return queue;
|
||||
}
|
||||
|
||||
public void setQueue(String queue) {
|
||||
this.queue = queue;
|
||||
}
|
||||
|
||||
public int getExecutorId() {
|
||||
return executorId;
|
||||
}
|
||||
|
||||
public void setExecutorId(int executorId) {
|
||||
this.executorId = executorId;
|
||||
}
|
||||
|
||||
|
||||
public Flag getIsSubProcess() {
|
||||
return isSubProcess;
|
||||
}
|
||||
|
||||
public void setIsSubProcess(Flag isSubProcess) {
|
||||
this.isSubProcess = isSubProcess;
|
||||
}
|
||||
|
||||
public Priority getProcessInstancePriority() {
|
||||
return processInstancePriority;
|
||||
}
|
||||
|
||||
public void setProcessInstancePriority(Priority processInstancePriority) {
|
||||
this.processInstancePriority = processInstancePriority;
|
||||
}
|
||||
public String getLocations() {
|
||||
return locations;
|
||||
}
|
||||
|
||||
public void setLocations(String locations) {
|
||||
this.locations = locations;
|
||||
}
|
||||
|
||||
public String getConnects() {
|
||||
return connects;
|
||||
}
|
||||
|
||||
public void setConnects(String connects) {
|
||||
this.connects = connects;
|
||||
}
|
||||
|
||||
public String getHistoryCmd() {
|
||||
return historyCmd;
|
||||
}
|
||||
|
||||
public void setHistoryCmd(String historyCmd) {
|
||||
this.historyCmd = historyCmd;
|
||||
}
|
||||
|
||||
/**
|
||||
* add command to history
|
||||
* @param cmd
|
||||
*/
|
||||
public void addHistoryCmd(CommandType cmd){
|
||||
if(StringUtils.isNotEmpty(this.historyCmd)){
|
||||
this.historyCmd = String.format("%s,%s", this.historyCmd, cmd.toString());
|
||||
}else{
|
||||
this.historyCmd = cmd.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check this process is start complement data
|
||||
*/
|
||||
public Boolean isComplementData(){
|
||||
if(!StringUtils.isNotEmpty(this.historyCmd)){
|
||||
return false;
|
||||
}
|
||||
return historyCmd.startsWith(CommandType.COMPLEMENT_DATA.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* get current command type,
|
||||
* if start with complement data,return complement
|
||||
*/
|
||||
public CommandType getCmdTypeIfComplement(){
|
||||
if(isComplementData()){
|
||||
return CommandType.COMPLEMENT_DATA;
|
||||
}
|
||||
return commandType;
|
||||
}
|
||||
|
||||
public String getDependenceScheduleTimes() {
|
||||
return dependenceScheduleTimes;
|
||||
}
|
||||
|
||||
public void setDependenceScheduleTimes(String dependenceScheduleTimes) {
|
||||
this.dependenceScheduleTimes = dependenceScheduleTimes;
|
||||
}
|
||||
|
||||
public Long getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(Long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProcessInstance{" +
|
||||
"id=" + id +
|
||||
", processDefinitionId=" + processDefinitionId +
|
||||
", state=" + state +
|
||||
", recovery=" + recovery +
|
||||
", startTime=" + startTime +
|
||||
", endTime=" + endTime +
|
||||
", runTimes=" + runTimes +
|
||||
", name='" + name + '\'' +
|
||||
", host='" + host + '\'' +
|
||||
", processDefinition=" + processDefinition +
|
||||
", commandType=" + commandType +
|
||||
", commandParam='" + commandParam + '\'' +
|
||||
", taskDependType=" + taskDependType +
|
||||
", maxTryTimes=" + maxTryTimes +
|
||||
", failureStrategy=" + failureStrategy +
|
||||
", warningType=" + warningType +
|
||||
", warningGroupId=" + warningGroupId +
|
||||
", scheduleTime=" + scheduleTime +
|
||||
", commandStartTime=" + commandStartTime +
|
||||
", globalParams='" + globalParams + '\'' +
|
||||
", processInstanceJson='" + processInstanceJson + '\'' +
|
||||
", executorId=" + executorId +
|
||||
", tenantCode='" + tenantCode + '\'' +
|
||||
", queue='" + queue + '\'' +
|
||||
", isSubProcess=" + isSubProcess +
|
||||
", locations='" + locations + '\'' +
|
||||
", connects='" + connects + '\'' +
|
||||
", historyCmd='" + historyCmd + '\'' +
|
||||
", dependenceScheduleTimes='" + dependenceScheduleTimes + '\'' +
|
||||
", duration=" + duration +
|
||||
", processInstancePriority=" + processInstancePriority +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
/**
|
||||
* process instance map
|
||||
*/
|
||||
public class ProcessInstanceMap {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* parent process instance id
|
||||
*/
|
||||
private int parentProcessInstanceId;
|
||||
|
||||
/**
|
||||
* parent task instance id
|
||||
*/
|
||||
private int parentTaskInstanceId;
|
||||
|
||||
/**
|
||||
* process instance id
|
||||
*/
|
||||
private int processInstanceId;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getParentProcessInstanceId() {
|
||||
return parentProcessInstanceId;
|
||||
}
|
||||
|
||||
public void setParentProcessInstanceId(int parentProcessInstanceId) {
|
||||
this.parentProcessInstanceId = parentProcessInstanceId;
|
||||
}
|
||||
|
||||
public int getParentTaskInstanceId() {
|
||||
return parentTaskInstanceId;
|
||||
}
|
||||
|
||||
public void setParentTaskInstanceId(int parentTaskInstanceId) {
|
||||
this.parentTaskInstanceId = parentTaskInstanceId;
|
||||
}
|
||||
|
||||
public int getProcessInstanceId() {
|
||||
return processInstanceId;
|
||||
}
|
||||
|
||||
public void setProcessInstanceId(int processInstanceId) {
|
||||
this.processInstanceId = processInstanceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProcessInstanceMap{" +
|
||||
"id=" + id +
|
||||
", parentProcessInstanceId=" + parentProcessInstanceId +
|
||||
", parentTaskInstanceId=" + parentTaskInstanceId +
|
||||
", processInstanceId=" + processInstanceId +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,167 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* project
|
||||
*/
|
||||
public class Project {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* user id
|
||||
*/
|
||||
private int userId;
|
||||
|
||||
/**
|
||||
* user name
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* project name
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* project description
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* permission
|
||||
*/
|
||||
private int perm;
|
||||
|
||||
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 getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
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 int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public int getPerm() {
|
||||
return perm;
|
||||
}
|
||||
|
||||
public void setPerm(int perm) {
|
||||
this.perm = perm;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Project{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", userName='" + userName + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", desc='" + desc + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Project project = (Project) o;
|
||||
|
||||
if (id != project.id) {
|
||||
return false;
|
||||
}
|
||||
return name.equals(project.name);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id;
|
||||
result = 31 * result + name.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* project user relation
|
||||
*/
|
||||
public class ProjectUser {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
/**
|
||||
* project id
|
||||
*/
|
||||
private int projectId;
|
||||
|
||||
/**
|
||||
* project name
|
||||
*/
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* user id
|
||||
*/
|
||||
private int userId;
|
||||
|
||||
/**
|
||||
* user name
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* permission
|
||||
*/
|
||||
private int perm;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
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 String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public int getPerm() {
|
||||
return perm;
|
||||
}
|
||||
|
||||
public void setPerm(int perm) {
|
||||
this.perm = perm;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectUser{" +
|
||||
"id=" + id +
|
||||
", projectId=" + projectId +
|
||||
", projectName='" + projectName + '\'' +
|
||||
", userId=" + userId +
|
||||
", userName='" + userName + '\'' +
|
||||
", perm=" + perm +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.escheduler.dao.model;
|
||||
|
||||
/**
|
||||
* queue
|
||||
*/
|
||||
public class Queue {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
/**
|
||||
* queue name
|
||||
*/
|
||||
private String queueName;
|
||||
/**
|
||||
* yarn queue name
|
||||
*/
|
||||
private String queue;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getQueueName() {
|
||||
return queueName;
|
||||
}
|
||||
|
||||
public void setQueueName(String queueName) {
|
||||
this.queueName = queueName;
|
||||
}
|
||||
|
||||
public String getQueue() {
|
||||
return queue;
|
||||
}
|
||||
|
||||
public void setQueue(String queue) {
|
||||
this.queue = queue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Queue{" +
|
||||
"id=" + id +
|
||||
", queueName='" + queueName + '\'' +
|
||||
", queue='" + queue + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,209 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import cn.escheduler.common.enums.ResourceType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class Resource {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* resource alias
|
||||
*/
|
||||
private String alias;
|
||||
|
||||
/**
|
||||
* description
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* file alias
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* user id
|
||||
*/
|
||||
private int userId;
|
||||
|
||||
/**
|
||||
* resource type
|
||||
*/
|
||||
private ResourceType type;
|
||||
|
||||
/**
|
||||
* resource size
|
||||
*/
|
||||
private long size;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public Resource() {
|
||||
}
|
||||
|
||||
public Resource(int id, String alias, String fileName, String desc, int userId,
|
||||
ResourceType type, long size,
|
||||
Date createTime, Date updateTime) {
|
||||
this.id = id;
|
||||
this.alias = alias;
|
||||
this.fileName = fileName;
|
||||
this.desc = desc;
|
||||
this.userId = userId;
|
||||
this.type = type;
|
||||
this.size = size;
|
||||
this.createTime = createTime;
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Resource(String alias, String fileName, String desc, int userId, ResourceType type, long size, Date createTime, Date updateTime) {
|
||||
this.alias = alias;
|
||||
this.fileName = fileName;
|
||||
this.desc = desc;
|
||||
this.userId = userId;
|
||||
this.type = type;
|
||||
this.size = size;
|
||||
this.createTime = createTime;
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
public void setAlias(String alias) {
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
|
||||
public ResourceType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ResourceType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Resource{" +
|
||||
"id=" + id +
|
||||
", alias='" + alias + '\'' +
|
||||
", fileName='" + fileName + '\'' +
|
||||
", desc='" + desc + '\'' +
|
||||
", userId=" + userId +
|
||||
", type=" + type +
|
||||
", size=" + size +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Resource resource = (Resource) o;
|
||||
|
||||
if (id != resource.id) {
|
||||
return false;
|
||||
}
|
||||
return alias.equals(resource.alias);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id;
|
||||
result = 31 * result + alias.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* resource user relation
|
||||
*/
|
||||
public class ResourcesUser {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* user id
|
||||
*/
|
||||
private int userId;
|
||||
|
||||
/**
|
||||
* resource id
|
||||
*/
|
||||
private int resourcesId;
|
||||
|
||||
/**
|
||||
* permission
|
||||
*/
|
||||
private int perm;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getResourcesId() {
|
||||
return resourcesId;
|
||||
}
|
||||
|
||||
public void setResourcesId(int resourcesId) {
|
||||
this.resourcesId = resourcesId;
|
||||
}
|
||||
|
||||
public int getPerm() {
|
||||
return perm;
|
||||
}
|
||||
|
||||
public void setPerm(int perm) {
|
||||
this.perm = perm;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ResourcesUser{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", resourcesId=" + resourcesId +
|
||||
", perm=" + perm +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,281 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import cn.escheduler.common.enums.FailureStrategy;
|
||||
import cn.escheduler.common.enums.Priority;
|
||||
import cn.escheduler.common.enums.ReleaseState;
|
||||
import cn.escheduler.common.enums.WarningType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* schedule
|
||||
*
|
||||
*/
|
||||
public class Schedule {
|
||||
|
||||
private int id;
|
||||
/**
|
||||
* process definition id
|
||||
*/
|
||||
private int processDefinitionId;
|
||||
|
||||
/**
|
||||
* process definition name
|
||||
*/
|
||||
private String processDefinitionName;
|
||||
|
||||
/**
|
||||
* project name
|
||||
*/
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* schedule description
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* schedule start time
|
||||
*/
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* schedule end time
|
||||
*/
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* crontab expression
|
||||
*/
|
||||
private String crontab;
|
||||
|
||||
/**
|
||||
* failure strategy
|
||||
*/
|
||||
private FailureStrategy failureStrategy;
|
||||
|
||||
/**
|
||||
* warning type
|
||||
*/
|
||||
private WarningType warningType;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* created user id
|
||||
*/
|
||||
private int userId;
|
||||
|
||||
/**
|
||||
* created user name
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* release state
|
||||
*/
|
||||
private ReleaseState releaseState;
|
||||
|
||||
/**
|
||||
* warning group id
|
||||
*/
|
||||
private int warningGroupId;
|
||||
|
||||
|
||||
/**
|
||||
* process instance priority
|
||||
*/
|
||||
private Priority processInstancePriority;
|
||||
|
||||
public int getWarningGroupId() {
|
||||
return warningGroupId;
|
||||
}
|
||||
|
||||
public void setWarningGroupId(int warningGroupId) {
|
||||
this.warningGroupId = warningGroupId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Schedule() {
|
||||
}
|
||||
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Date getStartTime() {
|
||||
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Date startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Date endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getCrontab() {
|
||||
return crontab;
|
||||
}
|
||||
|
||||
public void setCrontab(String crontab) {
|
||||
this.crontab = crontab;
|
||||
}
|
||||
|
||||
public FailureStrategy getFailureStrategy() {
|
||||
return failureStrategy;
|
||||
}
|
||||
|
||||
public void setFailureStrategy(FailureStrategy failureStrategy) {
|
||||
this.failureStrategy = failureStrategy;
|
||||
}
|
||||
|
||||
public WarningType getWarningType() {
|
||||
return warningType;
|
||||
}
|
||||
|
||||
public void setWarningType(WarningType warningType) {
|
||||
this.warningType = warningType;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
|
||||
public ReleaseState getReleaseState() {
|
||||
return releaseState;
|
||||
}
|
||||
|
||||
public void setReleaseState(ReleaseState releaseState) {
|
||||
this.releaseState = releaseState;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public int getProcessDefinitionId() {
|
||||
return processDefinitionId;
|
||||
}
|
||||
|
||||
public void setProcessDefinitionId(int processDefinitionId) {
|
||||
this.processDefinitionId = processDefinitionId;
|
||||
}
|
||||
|
||||
public String getProcessDefinitionName() {
|
||||
return processDefinitionName;
|
||||
}
|
||||
|
||||
public void setProcessDefinitionName(String processDefinitionName) {
|
||||
this.processDefinitionName = processDefinitionName;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Priority getProcessInstancePriority() {
|
||||
return processInstancePriority;
|
||||
}
|
||||
|
||||
public void setProcessInstancePriority(Priority processInstancePriority) {
|
||||
this.processInstancePriority = processInstancePriority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Schedule{" +
|
||||
"id=" + id +
|
||||
", processDefinitionId=" + processDefinitionId +
|
||||
", processDefinitionName='" + processDefinitionName + '\'' +
|
||||
", projectName='" + projectName + '\'' +
|
||||
", desc='" + desc + '\'' +
|
||||
", startTime=" + startTime +
|
||||
", endTime=" + endTime +
|
||||
", crontab='" + crontab + '\'' +
|
||||
", failureStrategy=" + failureStrategy +
|
||||
", warningType=" + warningType +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
", userId=" + userId +
|
||||
", userName='" + userName + '\'' +
|
||||
", releaseState=" + releaseState +
|
||||
", warningGroupId=" + warningGroupId +
|
||||
", processInstancePriority=" + processInstancePriority +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* session
|
||||
*/
|
||||
public class Session {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* user id
|
||||
*/
|
||||
private int userId;
|
||||
|
||||
/**
|
||||
* last login time
|
||||
*/
|
||||
private Date lastLoginTime;
|
||||
|
||||
/**
|
||||
* user login ip
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public Date getLastLoginTime() {
|
||||
return lastLoginTime;
|
||||
}
|
||||
|
||||
public void setLastLoginTime(Date lastLoginTime) {
|
||||
this.lastLoginTime = lastLoginTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Session{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", ip='" + ip + '\'' +
|
||||
", lastLoginTime=" + lastLoginTime +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,483 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import cn.escheduler.common.enums.ExecutionStatus;
|
||||
import cn.escheduler.common.enums.Flag;
|
||||
import cn.escheduler.common.enums.Priority;
|
||||
import cn.escheduler.common.enums.TaskType;
|
||||
import cn.escheduler.common.model.TaskNode;
|
||||
import cn.escheduler.common.utils.JSONUtils;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* task instance
|
||||
*/
|
||||
public class TaskInstance {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* task name
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* task type
|
||||
*/
|
||||
private String taskType;
|
||||
|
||||
/**
|
||||
* process definition id
|
||||
*/
|
||||
private int processDefinitionId;
|
||||
|
||||
/**
|
||||
* process instance id
|
||||
*/
|
||||
private int processInstanceId;
|
||||
|
||||
/**
|
||||
* process instance name
|
||||
*/
|
||||
private String processInstanceName;
|
||||
|
||||
/**
|
||||
* task json
|
||||
*/
|
||||
private String taskJson;
|
||||
|
||||
/**
|
||||
* state
|
||||
*/
|
||||
private ExecutionStatus state;
|
||||
|
||||
/**
|
||||
* task submit time
|
||||
*/
|
||||
private Date submitTime;
|
||||
|
||||
/**
|
||||
* task start time
|
||||
*/
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* task end time
|
||||
*/
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* task host
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* task shell execute path and the resource down from hdfs
|
||||
* default path: $base_run_dir/processInstanceId/taskInstanceId/retryTimes
|
||||
*/
|
||||
private String executePath;
|
||||
|
||||
/**
|
||||
* task log path
|
||||
* default path: $base_run_dir/processInstanceId/taskInstanceId/retryTimes
|
||||
*/
|
||||
private String logPath;
|
||||
|
||||
/**
|
||||
* retry times
|
||||
*/
|
||||
private int retryTimes;
|
||||
|
||||
/**
|
||||
* alert flag
|
||||
*/
|
||||
private Flag alertFlag;
|
||||
|
||||
/**
|
||||
* run flag
|
||||
*/
|
||||
private Flag runFlag;
|
||||
|
||||
/**
|
||||
* process instance
|
||||
*/
|
||||
private ProcessInstance processInstance;
|
||||
|
||||
/**
|
||||
* process definition
|
||||
*/
|
||||
private ProcessDefinition processDefine;
|
||||
|
||||
/**
|
||||
* process id
|
||||
*/
|
||||
private int pid;
|
||||
|
||||
/**
|
||||
* appLink
|
||||
*/
|
||||
private String appLink;
|
||||
|
||||
/**
|
||||
* flag
|
||||
*/
|
||||
private Flag flag;
|
||||
|
||||
/**
|
||||
* dependency
|
||||
*/
|
||||
private String dependency;
|
||||
|
||||
/**
|
||||
* duration
|
||||
* @return
|
||||
*/
|
||||
private Long duration;
|
||||
|
||||
/**
|
||||
* max retry times
|
||||
* @return
|
||||
*/
|
||||
private int maxRetryTimes;
|
||||
|
||||
/**
|
||||
* task retry interval, unit: minute
|
||||
* @return
|
||||
*/
|
||||
private int retryInterval;
|
||||
|
||||
/**
|
||||
* task intance priority
|
||||
*/
|
||||
private Priority taskInstancePriority;
|
||||
|
||||
/**
|
||||
* process intance priority
|
||||
*/
|
||||
private Priority processInstancePriority;
|
||||
|
||||
/**
|
||||
* dependent state
|
||||
* @return
|
||||
*/
|
||||
private String dependentResult;
|
||||
|
||||
|
||||
public ProcessInstance getProcessInstance() {
|
||||
return processInstance;
|
||||
}
|
||||
|
||||
public void setProcessInstance(ProcessInstance processInstance) {
|
||||
this.processInstance = processInstance;
|
||||
}
|
||||
|
||||
public ProcessDefinition getProcessDefine() {
|
||||
return processDefine;
|
||||
}
|
||||
|
||||
public void setProcessDefine(ProcessDefinition processDefine) {
|
||||
this.processDefine = processDefine;
|
||||
}
|
||||
|
||||
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 getTaskType() {
|
||||
return taskType;
|
||||
}
|
||||
|
||||
public void setTaskType(String taskType) {
|
||||
this.taskType = taskType;
|
||||
}
|
||||
|
||||
public int getProcessDefinitionId() {
|
||||
return processDefinitionId;
|
||||
}
|
||||
|
||||
public void setProcessDefinitionId(int processDefinitionId) {
|
||||
this.processDefinitionId = processDefinitionId;
|
||||
}
|
||||
|
||||
public int getProcessInstanceId() {
|
||||
return processInstanceId;
|
||||
}
|
||||
|
||||
public void setProcessInstanceId(int processInstanceId) {
|
||||
this.processInstanceId = processInstanceId;
|
||||
}
|
||||
|
||||
public String getTaskJson() {
|
||||
return taskJson;
|
||||
}
|
||||
|
||||
public void setTaskJson(String taskJson) {
|
||||
this.taskJson = taskJson;
|
||||
}
|
||||
|
||||
public ExecutionStatus getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(ExecutionStatus state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Date getSubmitTime() {
|
||||
return submitTime;
|
||||
}
|
||||
|
||||
public void setSubmitTime(Date submitTime) {
|
||||
this.submitTime = submitTime;
|
||||
}
|
||||
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Date startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Date endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getExecutePath() {
|
||||
return executePath;
|
||||
}
|
||||
|
||||
public void setExecutePath(String executePath) {
|
||||
this.executePath = executePath;
|
||||
}
|
||||
|
||||
public String getLogPath() {
|
||||
return logPath;
|
||||
}
|
||||
|
||||
public void setLogPath(String logPath) {
|
||||
this.logPath = logPath;
|
||||
}
|
||||
|
||||
public Flag getAlertFlag() {
|
||||
return alertFlag;
|
||||
}
|
||||
|
||||
public void setAlertFlag(Flag alertFlag) {
|
||||
this.alertFlag = alertFlag;
|
||||
}
|
||||
|
||||
public int getRetryTimes() {
|
||||
return retryTimes;
|
||||
}
|
||||
|
||||
public void setRetryTimes(int retryTimes) {
|
||||
this.retryTimes = retryTimes;
|
||||
}
|
||||
|
||||
public Boolean isTaskSuccess(){
|
||||
return this.state == ExecutionStatus.SUCCESS;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getAppLink() {
|
||||
return appLink;
|
||||
}
|
||||
|
||||
public void setAppLink(String appLink) {
|
||||
this.appLink = appLink;
|
||||
}
|
||||
|
||||
|
||||
public Boolean isSubProcess(){
|
||||
return TaskType.SUB_PROCESS.toString().equals(this.taskType.toUpperCase());
|
||||
}
|
||||
|
||||
public String getDependency(){
|
||||
|
||||
if(this.dependency != null){
|
||||
return this.dependency;
|
||||
}
|
||||
TaskNode taskNode = JSONUtils.parseObject(taskJson, TaskNode.class);
|
||||
|
||||
return taskNode.getDependence();
|
||||
}
|
||||
|
||||
public Flag getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(Flag flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
public String getProcessInstanceName() {
|
||||
return processInstanceName;
|
||||
}
|
||||
|
||||
public void setProcessInstanceName(String processInstanceName) {
|
||||
this.processInstanceName = processInstanceName;
|
||||
}
|
||||
|
||||
public Flag getRunFlag() {
|
||||
return runFlag;
|
||||
}
|
||||
|
||||
public void setRunFlag(Flag runFlag) {
|
||||
this.runFlag = runFlag;
|
||||
}
|
||||
|
||||
public Long getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(Long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public int getMaxRetryTimes() {
|
||||
return maxRetryTimes;
|
||||
}
|
||||
|
||||
public void setMaxRetryTimes(int maxRetryTimes) {
|
||||
this.maxRetryTimes = maxRetryTimes;
|
||||
}
|
||||
|
||||
public int getRetryInterval() {
|
||||
return retryInterval;
|
||||
}
|
||||
|
||||
public void setRetryInterval(int retryInterval) {
|
||||
this.retryInterval = retryInterval;
|
||||
}
|
||||
|
||||
public Boolean isTaskComplete() {
|
||||
|
||||
return this.getState().typeIsPause()
|
||||
|| this.getState().typeIsSuccess()
|
||||
|| this.getState().typeIsCancel()
|
||||
|| (this.getState().typeIsFailure() && !taskCanRetry());
|
||||
}
|
||||
/**
|
||||
* 判断是否可以重试
|
||||
* @return
|
||||
*/
|
||||
public boolean taskCanRetry() {
|
||||
if(this.isSubProcess()){
|
||||
return false;
|
||||
}
|
||||
return (this.getState().typeIsFailure()
|
||||
&& this.getRetryTimes() < this.getMaxRetryTimes());
|
||||
}
|
||||
|
||||
public void setDependency(String dependency) {
|
||||
this.dependency = dependency;
|
||||
}
|
||||
|
||||
public Priority getTaskInstancePriority() {
|
||||
return taskInstancePriority;
|
||||
}
|
||||
|
||||
public void setTaskInstancePriority(Priority taskInstancePriority) {
|
||||
this.taskInstancePriority = taskInstancePriority;
|
||||
}
|
||||
|
||||
public Priority getProcessInstancePriority() {
|
||||
return processInstancePriority;
|
||||
}
|
||||
|
||||
public void setProcessInstancePriority(Priority processInstancePriority) {
|
||||
this.processInstancePriority = processInstancePriority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TaskInstance{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", taskType='" + taskType + '\'' +
|
||||
", processDefinitionId=" + processDefinitionId +
|
||||
", processInstanceId=" + processInstanceId +
|
||||
", processInstanceName='" + processInstanceName + '\'' +
|
||||
", taskJson='" + taskJson + '\'' +
|
||||
", state=" + state +
|
||||
", submitTime=" + submitTime +
|
||||
", startTime=" + startTime +
|
||||
", endTime=" + endTime +
|
||||
", host='" + host + '\'' +
|
||||
", executePath='" + executePath + '\'' +
|
||||
", logPath='" + logPath + '\'' +
|
||||
", retryTimes=" + retryTimes +
|
||||
", alertFlag=" + alertFlag +
|
||||
", runFlag=" + runFlag +
|
||||
", processInstance=" + processInstance +
|
||||
", processDefine=" + processDefine +
|
||||
", pid=" + pid +
|
||||
", appLink='" + appLink + '\'' +
|
||||
", flag=" + flag +
|
||||
", dependency=" + dependency +
|
||||
", duration=" + duration +
|
||||
", maxRetryTimes=" + maxRetryTimes +
|
||||
", retryInterval=" + retryInterval +
|
||||
", taskInstancePriority=" + taskInstancePriority +
|
||||
", processInstancePriority=" + processInstancePriority +
|
||||
'}';
|
||||
}
|
||||
|
||||
public String getDependentResult() {
|
||||
return dependentResult;
|
||||
}
|
||||
|
||||
public void setDependentResult(String dependentResult) {
|
||||
this.dependentResult = dependentResult;
|
||||
}
|
||||
}
|
@ -0,0 +1,256 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* task record for qianfan
|
||||
*/
|
||||
public class TaskRecord {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* process id
|
||||
*/
|
||||
private int procId;
|
||||
|
||||
/**
|
||||
* procedure name
|
||||
*/
|
||||
private String procName;
|
||||
|
||||
/**
|
||||
* procedure date
|
||||
*/
|
||||
private String procDate;
|
||||
|
||||
/**
|
||||
* start date
|
||||
*/
|
||||
private Date startDate;
|
||||
|
||||
/**
|
||||
* end date
|
||||
*/
|
||||
private Date endDate;
|
||||
|
||||
/**
|
||||
* result
|
||||
*/
|
||||
private String result;
|
||||
|
||||
/**
|
||||
* duration unit: second
|
||||
*/
|
||||
private int duration;
|
||||
|
||||
/**
|
||||
* note
|
||||
*/
|
||||
private String note;
|
||||
|
||||
/**
|
||||
* schema
|
||||
*/
|
||||
private String schema;
|
||||
|
||||
/**
|
||||
* job id
|
||||
*/
|
||||
private String jobId;
|
||||
|
||||
|
||||
/**
|
||||
* source tab
|
||||
*/
|
||||
private String sourceTab;
|
||||
|
||||
/**
|
||||
* source row count
|
||||
*/
|
||||
private Long sourceRowCount;
|
||||
|
||||
/**
|
||||
* target tab
|
||||
*/
|
||||
private String targetTab;
|
||||
|
||||
/**
|
||||
* target row count
|
||||
*/
|
||||
private Long targetRowCount;
|
||||
|
||||
/**
|
||||
* error code
|
||||
*/
|
||||
private String errorCode;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getProcId() {
|
||||
return procId;
|
||||
}
|
||||
|
||||
public void setProcId(int procId) {
|
||||
this.procId = procId;
|
||||
}
|
||||
|
||||
public String getProcName() {
|
||||
return procName;
|
||||
}
|
||||
|
||||
public void setProcName(String procName) {
|
||||
this.procName = procName;
|
||||
}
|
||||
|
||||
public String getProcDate() {
|
||||
return procDate;
|
||||
}
|
||||
|
||||
public void setProcDate(String procDate) {
|
||||
this.procDate = procDate;
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Date startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public String getSchema() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
public void setSchema(String schema) {
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
public String getJobId() {
|
||||
return jobId;
|
||||
}
|
||||
|
||||
public void setJobId(String jobId) {
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
public String getSourceTab() {
|
||||
return sourceTab;
|
||||
}
|
||||
|
||||
public void setSourceTab(String sourceTab) {
|
||||
this.sourceTab = sourceTab;
|
||||
}
|
||||
|
||||
public Long getSourceRowCount() {
|
||||
return sourceRowCount;
|
||||
}
|
||||
|
||||
public void setSourceRowCount(Long sourceRowCount) {
|
||||
this.sourceRowCount = sourceRowCount;
|
||||
}
|
||||
|
||||
public String getTargetTab() {
|
||||
return targetTab;
|
||||
}
|
||||
|
||||
public void setTargetTab(String targetTab) {
|
||||
this.targetTab = targetTab;
|
||||
}
|
||||
|
||||
public Long getTargetRowCount() {
|
||||
return targetRowCount;
|
||||
}
|
||||
|
||||
public void setTargetRowCount(Long targetRowCount) {
|
||||
this.targetRowCount = targetRowCount;
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode(String errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "task record, id:" + id
|
||||
+" proc id:" + procId
|
||||
+ " proc name:" + procName
|
||||
+ " proc date: " + procDate
|
||||
+ " start date:" + startDate
|
||||
+ " end date:" + endDate
|
||||
+ " result : " + result
|
||||
+ " duration : " + duration
|
||||
+ " note : " + note
|
||||
+ " schema : " + schema
|
||||
+ " job id : " + jobId
|
||||
+ " source table : " + sourceTab
|
||||
+ " source row count: " + sourceRowCount
|
||||
+ " target table : " + targetTab
|
||||
+ " target row count: " + targetRowCount
|
||||
+ " error code: " + errorCode
|
||||
;
|
||||
}
|
||||
|
||||
}
|
142
escheduler-dao/src/main/java/cn/escheduler/dao/model/Tenant.java
Normal file
142
escheduler-dao/src/main/java/cn/escheduler/dao/model/Tenant.java
Normal file
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* tenant
|
||||
*/
|
||||
public class Tenant {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* tenant code
|
||||
*/
|
||||
private String tenantCode;
|
||||
|
||||
/**
|
||||
* tenant name
|
||||
*/
|
||||
private String tenantName;
|
||||
|
||||
/**
|
||||
* description
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* queue id
|
||||
*/
|
||||
private int queueId;
|
||||
|
||||
/**
|
||||
* queue name
|
||||
*/
|
||||
private String queueName;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTenantCode() {
|
||||
return tenantCode;
|
||||
}
|
||||
|
||||
public void setTenantCode(String tenantCode) {
|
||||
this.tenantCode = tenantCode;
|
||||
}
|
||||
|
||||
public String getTenantName() {
|
||||
return tenantName;
|
||||
}
|
||||
|
||||
public void setTenantName(String tenantName) {
|
||||
this.tenantName = tenantName;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public int getQueueId() {
|
||||
return queueId;
|
||||
}
|
||||
|
||||
public void setQueueId(int queueId) {
|
||||
this.queueId = queueId;
|
||||
}
|
||||
|
||||
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 String getQueueName() {
|
||||
return queueName;
|
||||
}
|
||||
|
||||
public void setQueueName(String queueName) {
|
||||
this.queueName = queueName;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Tenant{" +
|
||||
"id=" + id +
|
||||
", tenantCode='" + tenantCode + '\'' +
|
||||
", tenantName='" + tenantName + '\'' +
|
||||
", desc='" + desc + '\'' +
|
||||
", queueId=" + queueId +
|
||||
", queueName='" + queueName + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* udf user relation
|
||||
*/
|
||||
public class UDFUser {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int userId;
|
||||
|
||||
/**
|
||||
* udf id
|
||||
*/
|
||||
private int udfId;
|
||||
|
||||
/**
|
||||
* permission
|
||||
*/
|
||||
private int perm;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getUdfId() {
|
||||
return udfId;
|
||||
}
|
||||
|
||||
public void setUdfId(int udfId) {
|
||||
this.udfId = udfId;
|
||||
}
|
||||
|
||||
public int getPerm() {
|
||||
return perm;
|
||||
}
|
||||
|
||||
public void setPerm(int perm) {
|
||||
this.perm = perm;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UDFUser{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", udfId=" + udfId +
|
||||
", perm=" + perm +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,225 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import cn.escheduler.common.enums.UdfType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* udf function
|
||||
*/
|
||||
public class UdfFunc {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
/**
|
||||
* user id
|
||||
*/
|
||||
private int userId;
|
||||
|
||||
/**
|
||||
* udf function name
|
||||
*/
|
||||
private String funcName;
|
||||
|
||||
/**
|
||||
* udf class name
|
||||
*/
|
||||
private String className;
|
||||
|
||||
/**
|
||||
* udf argument types
|
||||
*/
|
||||
private String argTypes;
|
||||
|
||||
/**
|
||||
* udf data base
|
||||
*/
|
||||
private String database;
|
||||
|
||||
/**
|
||||
* udf description
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* resource id
|
||||
*/
|
||||
private int resourceId;
|
||||
|
||||
/**
|
||||
* resource name
|
||||
*/
|
||||
private String resourceName;
|
||||
|
||||
/**
|
||||
* udf function type: hive / spark
|
||||
*/
|
||||
private UdfType type;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getFuncName() {
|
||||
return funcName;
|
||||
}
|
||||
|
||||
public void setFuncName(String funcName) {
|
||||
this.funcName = funcName;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public void setClassName(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public String getArgTypes() {
|
||||
return argTypes;
|
||||
}
|
||||
|
||||
public void setArgTypes(String argTypes) {
|
||||
this.argTypes = argTypes;
|
||||
}
|
||||
|
||||
public String getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public void setDatabase(String database) {
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public int getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
public void setResourceId(int resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public String getResourceName() {
|
||||
return resourceName;
|
||||
}
|
||||
|
||||
public void setResourceName(String resourceName) {
|
||||
this.resourceName = resourceName;
|
||||
}
|
||||
|
||||
public UdfType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(UdfType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UdfFunc{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", funcName='" + funcName + '\'' +
|
||||
", className='" + className + '\'' +
|
||||
", argTypes='" + argTypes + '\'' +
|
||||
", database='" + database + '\'' +
|
||||
", desc='" + desc + '\'' +
|
||||
", resourceId=" + resourceId +
|
||||
", resourceName='" + resourceName + '\'' +
|
||||
", type=" + type +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UdfFunc udfFunc = (UdfFunc) o;
|
||||
|
||||
if (id != udfFunc.id) {
|
||||
return false;
|
||||
}
|
||||
return !(funcName != null ? !funcName.equals(udfFunc.funcName) : udfFunc.funcName != null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id;
|
||||
result = 31 * result + (funcName != null ? funcName.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
240
escheduler-dao/src/main/java/cn/escheduler/dao/model/User.java
Normal file
240
escheduler-dao/src/main/java/cn/escheduler/dao/model/User.java
Normal file
@ -0,0 +1,240 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import cn.escheduler.common.enums.UserType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* user
|
||||
*/
|
||||
public class User {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* user name
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* user password
|
||||
*/
|
||||
private String userPassword;
|
||||
|
||||
/**
|
||||
* mail
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* phone
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* user type
|
||||
*/
|
||||
private UserType userType;
|
||||
|
||||
/**
|
||||
* tenant id
|
||||
*/
|
||||
private int tenantId;
|
||||
|
||||
/**
|
||||
* tenant code
|
||||
*/
|
||||
private String tenantCode;
|
||||
|
||||
/**
|
||||
* tenant name
|
||||
*/
|
||||
private String tenantName;
|
||||
|
||||
/**
|
||||
* queue name
|
||||
*/
|
||||
private String queueName;
|
||||
|
||||
/**
|
||||
* alert group
|
||||
*/
|
||||
private String alertGroup;
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getUserPassword() {
|
||||
return userPassword;
|
||||
}
|
||||
|
||||
public void setUserPassword(String userPassword) {
|
||||
this.userPassword = userPassword;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public UserType getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(UserType userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
public int getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(int tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
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 String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getQueueName() {
|
||||
return queueName;
|
||||
}
|
||||
|
||||
public void setQueueName(String queueName) {
|
||||
this.queueName = queueName;
|
||||
}
|
||||
|
||||
public String getAlertGroup() {
|
||||
return alertGroup;
|
||||
}
|
||||
|
||||
public void setAlertGroup(String alertGroup) {
|
||||
this.alertGroup = alertGroup;
|
||||
}
|
||||
|
||||
public String getTenantName() {
|
||||
return tenantName;
|
||||
}
|
||||
|
||||
public void setTenantName(String tenantName) {
|
||||
this.tenantName = tenantName;
|
||||
}
|
||||
|
||||
public String getTenantCode() {
|
||||
return tenantCode;
|
||||
}
|
||||
|
||||
public void setTenantCode(String tenantCode) {
|
||||
this.tenantCode = tenantCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
"id=" + id +
|
||||
", userName='" + userName + '\'' +
|
||||
", userPassword='" + userPassword + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
", phone='" + phone + '\'' +
|
||||
", userType=" + userType +
|
||||
", tenantId=" + tenantId +
|
||||
", tenantCode='" + tenantCode + '\'' +
|
||||
", tenantName='" + tenantName + '\'' +
|
||||
", queueName='" + queueName + '\'' +
|
||||
", alertGroup='" + alertGroup + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
User user = (User) o;
|
||||
|
||||
if (id != user.id) {
|
||||
return false;
|
||||
}
|
||||
return userName.equals(user.userName);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id;
|
||||
result = 31 * result + userName.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* user alert group
|
||||
*/
|
||||
public class UserAlertGroup {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int alertgroupId;
|
||||
|
||||
/**
|
||||
* alert group name
|
||||
*/
|
||||
private String alertgroupName;
|
||||
|
||||
/**
|
||||
* user id
|
||||
*/
|
||||
private int userId;
|
||||
|
||||
/**
|
||||
* user name
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getAlertgroupId() {
|
||||
return alertgroupId;
|
||||
}
|
||||
|
||||
public void setAlertgroupId(int alertgroupId) {
|
||||
this.alertgroupId = alertgroupId;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
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 String getAlertgroupName() {
|
||||
return alertgroupName;
|
||||
}
|
||||
|
||||
public void setAlertgroupName(String alertgroupName) {
|
||||
this.alertgroupName = alertgroupName;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserAlertGroup{" +
|
||||
"id=" + id +
|
||||
", alertgroupId=" + alertgroupId +
|
||||
", alertgroupName='" + alertgroupName + '\'' +
|
||||
", userId=" + userId +
|
||||
", userName='" + userName + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class WorkerServer {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* host
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* port
|
||||
*/
|
||||
private int port;
|
||||
|
||||
|
||||
/**
|
||||
* zookeeper directory
|
||||
*/
|
||||
private String zkDirectory;
|
||||
|
||||
/**
|
||||
* resource info
|
||||
*/
|
||||
private String resInfo;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* last heart beat time
|
||||
*/
|
||||
private Date lastHeartbeatTime;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getZkDirectory() {
|
||||
return zkDirectory;
|
||||
}
|
||||
|
||||
public void setZkDirectory(String zkDirectory) {
|
||||
this.zkDirectory = zkDirectory;
|
||||
}
|
||||
|
||||
public Date getLastHeartbeatTime() {
|
||||
return lastHeartbeatTime;
|
||||
}
|
||||
|
||||
public void setLastHeartbeatTime(Date lastHeartbeatTime) {
|
||||
this.lastHeartbeatTime = lastHeartbeatTime;
|
||||
}
|
||||
|
||||
public String getResInfo() {
|
||||
return resInfo;
|
||||
}
|
||||
|
||||
public void setResInfo(String resInfo) {
|
||||
this.resInfo = resInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WorkerServer{" +
|
||||
"id=" + id +
|
||||
", host='" + host + '\'' +
|
||||
", port=" + port +
|
||||
", zkDirectory='" + zkDirectory + '\'' +
|
||||
", resInfo='" + resInfo + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", lastHeartbeatTime=" + lastHeartbeatTime +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,213 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.utils;
|
||||
|
||||
|
||||
import cn.escheduler.common.enums.TaskDependType;
|
||||
import cn.escheduler.common.model.TaskNode;
|
||||
import cn.escheduler.common.model.TaskNodeRelation;
|
||||
import cn.escheduler.common.process.ProcessDag;
|
||||
import cn.escheduler.common.utils.JSONUtils;
|
||||
import cn.escheduler.dao.model.ProcessData;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* dag tools
|
||||
*/
|
||||
public class DagHelper {
|
||||
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DagHelper.class);
|
||||
|
||||
/**
|
||||
* generate flow node relation list by task node list;
|
||||
* Edges that are not in the task Node List will not be added to the result
|
||||
* 根据task Node List生成node关系列表,不在task Node List中的边不会被添加到结果中
|
||||
*
|
||||
* @param taskNodeList
|
||||
* @return
|
||||
*/
|
||||
private static List<TaskNodeRelation> generateRelationListByFlowNodes(List<TaskNode> taskNodeList) {
|
||||
List<TaskNodeRelation> nodeRelationList = new ArrayList<>();
|
||||
for (TaskNode taskNode : taskNodeList) {
|
||||
String preTasks = taskNode.getPreTasks();
|
||||
List<String> preTaskList = JSONUtils.toList(preTasks, String.class);
|
||||
if (preTaskList != null) {
|
||||
for (String depNodeName : preTaskList) {
|
||||
if (null != findNodeByName(taskNodeList, depNodeName)) {
|
||||
nodeRelationList.add(new TaskNodeRelation(depNodeName, taskNode.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nodeRelationList;
|
||||
}
|
||||
|
||||
/**
|
||||
* generate task nodes needed by dag
|
||||
* 生成dag需要的task nodes
|
||||
*
|
||||
* @param taskNodeList
|
||||
* @param taskDependType
|
||||
* @return
|
||||
*/
|
||||
private static List<TaskNode> generateFlowNodeListByStartNode(List<TaskNode> taskNodeList, List<String> startNodeNameList,
|
||||
List<String> recoveryNodeNameList, TaskDependType taskDependType) {
|
||||
List<TaskNode> destFlowNodeList = new ArrayList<>();
|
||||
List<String> startNodeList = startNodeNameList;
|
||||
|
||||
if(taskDependType != TaskDependType.TASK_POST
|
||||
&& startNodeList.size() == 0){
|
||||
logger.error("start node list is empty! cannot continue run the process ");
|
||||
return destFlowNodeList;
|
||||
}
|
||||
List<TaskNode> destTaskNodeList = new ArrayList<>();
|
||||
List<TaskNode> tmpTaskNodeList = new ArrayList<>();
|
||||
if (taskDependType == TaskDependType.TASK_POST
|
||||
&& recoveryNodeNameList.size() > 0) {
|
||||
startNodeList = recoveryNodeNameList;
|
||||
}
|
||||
if (startNodeList == null || startNodeList.size() == 0) {
|
||||
// 没有特殊的指定start nodes
|
||||
tmpTaskNodeList = taskNodeList;
|
||||
} else {
|
||||
// 指定了start nodes or 恢复执行
|
||||
for (String startNodeName : startNodeList) {
|
||||
TaskNode startNode = findNodeByName(taskNodeList, startNodeName);
|
||||
List<TaskNode> childNodeList = new ArrayList<>();
|
||||
if (TaskDependType.TASK_POST == taskDependType) {
|
||||
childNodeList = getFlowNodeListPost(startNode, taskNodeList);
|
||||
} else if (TaskDependType.TASK_PRE == taskDependType) {
|
||||
childNodeList = getFlowNodeListPre(startNode, recoveryNodeNameList, taskNodeList);
|
||||
} else {
|
||||
childNodeList.add(startNode);
|
||||
}
|
||||
tmpTaskNodeList.addAll(childNodeList);
|
||||
}
|
||||
}
|
||||
|
||||
for (TaskNode taskNode : tmpTaskNodeList) {
|
||||
if ( !taskNode.isForbidden()
|
||||
&& null == findNodeByName(destTaskNodeList, taskNode.getName())) {
|
||||
destTaskNodeList.add(taskNode);
|
||||
}
|
||||
}
|
||||
return destTaskNodeList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* find all the nodes that depended on the start node
|
||||
* 找到所有依赖start node的node
|
||||
*
|
||||
* @param startNode
|
||||
* @param taskNodeList
|
||||
* @return
|
||||
*/
|
||||
private static List<TaskNode> getFlowNodeListPost(TaskNode startNode, List<TaskNode> taskNodeList) {
|
||||
List<TaskNode> resultList = new ArrayList<>();
|
||||
for (TaskNode taskNode : taskNodeList) {
|
||||
List<String> depList = taskNode.getDepList();
|
||||
if (depList != null) {
|
||||
if (depList.contains(startNode.getName())) {
|
||||
resultList.addAll(getFlowNodeListPost(taskNode, taskNodeList));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
resultList.add(startNode);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* find all nodes that start nodes depend on.
|
||||
* 找到所有start node依赖的node
|
||||
*
|
||||
* @param startNode
|
||||
* @param taskNodeList
|
||||
* @return
|
||||
*/
|
||||
private static List<TaskNode> getFlowNodeListPre(TaskNode startNode, List<String> recoveryNodeNameList, List<TaskNode> taskNodeList) {
|
||||
|
||||
List<TaskNode> resultList = new ArrayList<>();
|
||||
|
||||
List<String> depList = startNode.getDepList();
|
||||
resultList.add(startNode);
|
||||
if (depList == null || depList.size() == 0) {
|
||||
return resultList;
|
||||
}
|
||||
for (String depNodeName : depList) {
|
||||
TaskNode start = findNodeByName(taskNodeList, depNodeName);
|
||||
if (recoveryNodeNameList.contains(depNodeName)) {
|
||||
resultList.add(start);
|
||||
} else {
|
||||
resultList.addAll(getFlowNodeListPre(start, recoveryNodeNameList, taskNodeList));
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* generate dag by start nodes and recovery nodes
|
||||
* 根据start nodes 和 recovery nodes 生成dag
|
||||
* @param processDefinitionJson
|
||||
* @param startNodeNameList
|
||||
* @param recoveryNodeNameList
|
||||
* @param depNodeType
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static ProcessDag generateFlowDag(String processDefinitionJson,
|
||||
List<String> startNodeNameList,
|
||||
List<String> recoveryNodeNameList,
|
||||
TaskDependType depNodeType) throws Exception {
|
||||
ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class);
|
||||
|
||||
List<TaskNode> taskNodeList = processData.getTasks();
|
||||
List<TaskNode> destTaskNodeList = generateFlowNodeListByStartNode(taskNodeList, startNodeNameList, recoveryNodeNameList, depNodeType);
|
||||
if (destTaskNodeList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
List<TaskNodeRelation> taskNodeRelations = generateRelationListByFlowNodes(destTaskNodeList);
|
||||
ProcessDag processDag = new ProcessDag();
|
||||
processDag.setEdges(taskNodeRelations);
|
||||
processDag.setNodes(destTaskNodeList);
|
||||
return processDag;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* find node by node name
|
||||
* 通过 name 获取节点
|
||||
* @param nodeDetails
|
||||
* @param nodeName
|
||||
* @return
|
||||
* @see TaskNode
|
||||
*/
|
||||
public static TaskNode findNodeByName(List<TaskNode> nodeDetails, String nodeName) {
|
||||
for (TaskNode taskNode : nodeDetails) {
|
||||
if (taskNode.getName().equals(nodeName)) {
|
||||
return taskNode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,192 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.utils;
|
||||
|
||||
import cn.escheduler.common.Constants;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
/**
|
||||
* property utils
|
||||
* single instance
|
||||
*/
|
||||
public class PropertyUtils {
|
||||
|
||||
/**
|
||||
* logger
|
||||
*/
|
||||
private static final Logger logger = LoggerFactory.getLogger(PropertyUtils.class);
|
||||
|
||||
private static final Properties properties = new Properties();
|
||||
|
||||
private static final PropertyUtils propertyUtils = new PropertyUtils();
|
||||
|
||||
private PropertyUtils(){
|
||||
init();
|
||||
}
|
||||
|
||||
private void init(){
|
||||
String[] propertyFiles = new String[]{Constants.DAO_PROPERTIES_PATH};
|
||||
for (String fileName : propertyFiles) {
|
||||
InputStream fis = null;
|
||||
try {
|
||||
fis = PropertyUtils.class.getResourceAsStream(fileName);
|
||||
properties.load(fis);
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
System.exit(1);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(fis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public static PropertyUtils getInstance(){
|
||||
return propertyUtils;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* get property value
|
||||
*
|
||||
* @param key property name
|
||||
* @return
|
||||
*/
|
||||
public static String getString(String key) {
|
||||
return properties.getProperty(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* get property value
|
||||
*
|
||||
* @param key property name
|
||||
* @return get property int value , if key == null, then return -1
|
||||
*/
|
||||
public static int getInt(String key) {
|
||||
return getInt(key, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param key
|
||||
* @param defaultValue
|
||||
* @return
|
||||
*/
|
||||
public static int getInt(String key, int defaultValue) {
|
||||
String value = getString(key);
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
try {
|
||||
return Integer.parseInt(value);
|
||||
} catch (NumberFormatException e) {
|
||||
logger.info(e.getMessage(),e);
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* get property value
|
||||
*
|
||||
* @param key property name
|
||||
* @return
|
||||
*/
|
||||
public static Boolean getBoolean(String key) {
|
||||
String value = properties.getProperty(key.trim());
|
||||
if(null != value){
|
||||
return Boolean.parseBoolean(value);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static long getLong(String key) {
|
||||
return getLong(key,-1);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param key
|
||||
* @param defaultVal
|
||||
* @return
|
||||
*/
|
||||
public static long getLong(String key, long defaultVal) {
|
||||
String val = getString(key);
|
||||
return val == null ? defaultVal : Long.parseLong(val);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param key
|
||||
* @param defaultVal
|
||||
* @return
|
||||
*/
|
||||
public double getDouble(String key, double defaultVal) {
|
||||
String val = getString(key);
|
||||
return val == null ? defaultVal : Double.parseDouble(val);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get array
|
||||
* @param key property name
|
||||
* @param splitStr separator
|
||||
* @return
|
||||
*/
|
||||
public static String[] getArray(String key, String splitStr) {
|
||||
String value = getString(key);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
String[] propertyArray = value.split(splitStr);
|
||||
return propertyArray;
|
||||
} catch (NumberFormatException e) {
|
||||
logger.info(e.getMessage(),e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param key
|
||||
* @param type
|
||||
* @param defaultValue
|
||||
* @param <T>
|
||||
* @return get enum value
|
||||
*/
|
||||
public <T extends Enum<T>> T getEnum(String key, Class<T> type,
|
||||
T defaultValue) {
|
||||
String val = getString(key);
|
||||
return val == null ? defaultValue : Enum.valueOf(type, val);
|
||||
}
|
||||
}
|
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.utils.cron;
|
||||
|
||||
import cn.escheduler.common.enums.CycleEnum;
|
||||
import com.cronutils.model.Cron;
|
||||
import com.cronutils.model.field.CronField;
|
||||
import com.cronutils.model.field.CronFieldName;
|
||||
import com.cronutils.model.field.expression.*;
|
||||
|
||||
/**
|
||||
* Cycle
|
||||
*/
|
||||
public abstract class AbstractCycle {
|
||||
|
||||
protected Cron cron;
|
||||
|
||||
protected CronField minField;
|
||||
protected CronField hourField;
|
||||
protected CronField dayOfMonthField;
|
||||
protected CronField dayOfWeekField;
|
||||
protected CronField monthField;
|
||||
protected CronField yearField;
|
||||
|
||||
public CycleLinks addCycle(AbstractCycle cycle) {
|
||||
return new CycleLinks(this.cron).addCycle(this).addCycle(cycle);
|
||||
}
|
||||
|
||||
public AbstractCycle(Cron cron) {
|
||||
if (cron == null) {
|
||||
throw new IllegalArgumentException("cron must not be null!");
|
||||
}
|
||||
|
||||
this.cron = cron;
|
||||
this.minField = cron.retrieve(CronFieldName.MINUTE);
|
||||
this.hourField = cron.retrieve(CronFieldName.HOUR);
|
||||
this.dayOfMonthField = cron.retrieve(CronFieldName.DAY_OF_MONTH);
|
||||
this.dayOfWeekField = cron.retrieve(CronFieldName.DAY_OF_WEEK);
|
||||
this.monthField = cron.retrieve(CronFieldName.MONTH);
|
||||
this.yearField = cron.retrieve(CronFieldName.YEAR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the minute field has a value
|
||||
* @return
|
||||
*/
|
||||
protected boolean minFiledIsSetAll(){
|
||||
FieldExpression minFieldExpression = minField.getExpression();
|
||||
return (minFieldExpression instanceof Every || minFieldExpression instanceof Always
|
||||
|| minFieldExpression instanceof Between || minFieldExpression instanceof And
|
||||
|| minFieldExpression instanceof On);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether the minute field has a value of every or always
|
||||
* @return
|
||||
*/
|
||||
protected boolean minFiledIsEvery(){
|
||||
FieldExpression minFieldExpression = minField.getExpression();
|
||||
return (minFieldExpression instanceof Every || minFieldExpression instanceof Always);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the hour field has a value
|
||||
* @return
|
||||
*/
|
||||
protected boolean hourFiledIsSetAll(){
|
||||
FieldExpression hourFieldExpression = hourField.getExpression();
|
||||
return (hourFieldExpression instanceof Every || hourFieldExpression instanceof Always
|
||||
|| hourFieldExpression instanceof Between || hourFieldExpression instanceof And
|
||||
|| hourFieldExpression instanceof On);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the hour field has a value of every or always
|
||||
* @return
|
||||
*/
|
||||
protected boolean hourFiledIsEvery(){
|
||||
FieldExpression hourFieldExpression = hourField.getExpression();
|
||||
return (hourFieldExpression instanceof Every || hourFieldExpression instanceof Always);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the day Of month field has a value
|
||||
* @return
|
||||
*/
|
||||
protected boolean dayOfMonthFieldIsSetAll(){
|
||||
return (dayOfMonthField.getExpression() instanceof Every || dayOfMonthField.getExpression() instanceof Always
|
||||
|| dayOfMonthField.getExpression() instanceof Between || dayOfMonthField.getExpression() instanceof And
|
||||
|| dayOfMonthField.getExpression() instanceof On);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether the day Of Month field has a value of every or always
|
||||
* @return
|
||||
*/
|
||||
protected boolean dayOfMonthFieldIsEvery(){
|
||||
return (dayOfMonthField.getExpression() instanceof Every || dayOfMonthField.getExpression() instanceof Always);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether month field has a value
|
||||
* @return
|
||||
*/
|
||||
protected boolean monthFieldIsSetAll(){
|
||||
FieldExpression monthFieldExpression = monthField.getExpression();
|
||||
return (monthFieldExpression instanceof Every || monthFieldExpression instanceof Always
|
||||
|| monthFieldExpression instanceof Between || monthFieldExpression instanceof And
|
||||
|| monthFieldExpression instanceof On);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the month field has a value of every or always
|
||||
* @return
|
||||
*/
|
||||
protected boolean monthFieldIsEvery(){
|
||||
FieldExpression monthFieldExpression = monthField.getExpression();
|
||||
return (monthFieldExpression instanceof Every || monthFieldExpression instanceof Always);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the day Of week field has a value
|
||||
* @return
|
||||
*/
|
||||
protected boolean dayofWeekFieldIsSetAll(){
|
||||
FieldExpression dayOfWeekFieldExpression = dayOfWeekField.getExpression();
|
||||
return (dayOfWeekFieldExpression instanceof Every || dayOfWeekFieldExpression instanceof Always
|
||||
|| dayOfWeekFieldExpression instanceof Between || dayOfWeekFieldExpression instanceof And
|
||||
|| dayOfWeekFieldExpression instanceof On);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the day Of week field has a value of every or always
|
||||
* @return
|
||||
*/
|
||||
protected boolean dayofWeekFieldIsEvery(){
|
||||
FieldExpression dayOfWeekFieldExpression = dayOfWeekField.getExpression();
|
||||
return (dayOfWeekFieldExpression instanceof Every || dayOfWeekFieldExpression instanceof Always);
|
||||
}
|
||||
/**
|
||||
* get cycle enum
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract CycleEnum getCycle();
|
||||
|
||||
/**
|
||||
* get mini level cycle enum
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract CycleEnum getMiniCycle();
|
||||
}
|
@ -0,0 +1,207 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.utils.cron;
|
||||
|
||||
|
||||
import cn.escheduler.common.enums.CycleEnum;
|
||||
import cn.escheduler.common.thread.Stopper;
|
||||
import cn.escheduler.common.utils.DateUtils;
|
||||
import com.cronutils.model.Cron;
|
||||
import com.cronutils.model.definition.CronDefinitionBuilder;
|
||||
import com.cronutils.parser.CronParser;
|
||||
import org.quartz.CronExpression;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.escheduler.dao.utils.cron.CycleFactory.*;
|
||||
import static com.cronutils.model.CronType.QUARTZ;
|
||||
|
||||
|
||||
/**
|
||||
* cron utils
|
||||
*/
|
||||
public class CronUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CronUtils.class);
|
||||
|
||||
|
||||
private static final CronParser QUARTZ_CRON_PARSER = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(QUARTZ));
|
||||
|
||||
/**
|
||||
* Parse string with cron expression to Cron
|
||||
*
|
||||
* @param cronExpression
|
||||
* - cron expression, never null
|
||||
* @return Cron instance, corresponding to cron expression received
|
||||
* @throws java.lang.IllegalArgumentException
|
||||
* if expression does not match cron definition
|
||||
*/
|
||||
public static Cron parse2Cron(String cronExpression) {
|
||||
return QUARTZ_CRON_PARSER.parse(cronExpression);
|
||||
}
|
||||
|
||||
/**
|
||||
* build a new <CODE>CronExpression</CODE> based on the string cronExpression.
|
||||
*
|
||||
* @param cronExpression String representation of the cron expression the
|
||||
* new object should represent
|
||||
* @throws java.text.ParseException
|
||||
* if the string expression cannot be parsed into a valid
|
||||
* <CODE>CronExpression</CODE>
|
||||
*/
|
||||
public static CronExpression parse2CronExpression(String cronExpression) throws ParseException {
|
||||
return new CronExpression(cronExpression);
|
||||
}
|
||||
|
||||
/**
|
||||
* get cycle enum
|
||||
* @param cron
|
||||
* @return
|
||||
*/
|
||||
public static CycleEnum getMaxCycle(Cron cron) {
|
||||
return min(cron).addCycle(hour(cron)).addCycle(day(cron)).addCycle(week(cron)).addCycle(month(cron)).getCycle();
|
||||
}
|
||||
|
||||
/**
|
||||
* get cycle enum
|
||||
* @param cron
|
||||
* @return
|
||||
*/
|
||||
public static CycleEnum getMiniCycle(Cron cron) {
|
||||
return min(cron).addCycle(hour(cron)).addCycle(day(cron)).addCycle(week(cron)).addCycle(month(cron)).getMiniCycle();
|
||||
}
|
||||
|
||||
/**
|
||||
* get mini level of cycle enum
|
||||
*
|
||||
* @param crontab
|
||||
* @return
|
||||
*/
|
||||
public static CycleEnum getMiniCycle(String crontab) {
|
||||
return getMiniCycle(parse2Cron(crontab));
|
||||
}
|
||||
|
||||
/**
|
||||
* get cycle enum
|
||||
*
|
||||
* @param crontab
|
||||
* @return
|
||||
*/
|
||||
public static CycleEnum getMaxCycle(String crontab) {
|
||||
return getMaxCycle(parse2Cron(crontab));
|
||||
}
|
||||
|
||||
/**
|
||||
* gets all scheduled times for a period of time based on not self dependency
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @param cronExpression
|
||||
* @return
|
||||
*/
|
||||
public static List<Date> getFireDateList(Date startTime, Date endTime, CronExpression cronExpression) {
|
||||
List<Date> dateList = new ArrayList<>();
|
||||
|
||||
while (Stopper.isRunning()) {
|
||||
startTime = cronExpression.getNextValidTimeAfter(startTime);
|
||||
if (startTime.after(endTime)) {
|
||||
break;
|
||||
}
|
||||
dateList.add(startTime);
|
||||
}
|
||||
|
||||
return dateList;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets all scheduled times for a period of time based on self dependency
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @param cronExpression
|
||||
* @return
|
||||
*/
|
||||
public static List<Date> getSelfFireDateList(Date startTime, Date endTime, CronExpression cronExpression) {
|
||||
List<Date> dateList = new ArrayList<>();
|
||||
|
||||
while (Stopper.isRunning()) {
|
||||
startTime = cronExpression.getNextValidTimeAfter(startTime);
|
||||
if (startTime.after(endTime) || startTime.equals(endTime)) {
|
||||
break;
|
||||
}
|
||||
dateList.add(startTime);
|
||||
}
|
||||
|
||||
return dateList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get expiration time
|
||||
* @param startTime
|
||||
* @param cycleEnum
|
||||
* @return
|
||||
*/
|
||||
public static Date getExpirationTime(Date startTime, CycleEnum cycleEnum) {
|
||||
Date maxExpirationTime = null;
|
||||
Date startTimeMax = null;
|
||||
try {
|
||||
startTimeMax = getEndTime(startTime);
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(startTime);
|
||||
switch (cycleEnum) {
|
||||
case HOUR:
|
||||
calendar.add(Calendar.HOUR, 1);
|
||||
break;
|
||||
case DAY:
|
||||
calendar.add(Calendar.DATE, 1);
|
||||
break;
|
||||
case WEEK:
|
||||
calendar.add(Calendar.DATE, 1);
|
||||
break;
|
||||
case MONTH:
|
||||
calendar.add(Calendar.DATE, 1);
|
||||
break;
|
||||
default:
|
||||
logger.error("Dependent process definition's cycleEnum is {},not support!!", cycleEnum.name());
|
||||
break;
|
||||
}
|
||||
maxExpirationTime = calendar.getTime();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
}
|
||||
return DateUtils.compare(startTimeMax,maxExpirationTime)?maxExpirationTime:startTimeMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the end time of the day by value of date
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
private static Date getEndTime(Date date) {
|
||||
Calendar end = new GregorianCalendar();
|
||||
end.setTime(date);
|
||||
end.set(Calendar.HOUR_OF_DAY,23);
|
||||
end.set(Calendar.MINUTE,59);
|
||||
end.set(Calendar.SECOND,59);
|
||||
end.set(Calendar.MILLISECOND,999);
|
||||
return end.getTime();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,211 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.utils.cron;
|
||||
|
||||
import cn.escheduler.common.enums.CycleEnum;
|
||||
import com.cronutils.model.Cron;
|
||||
import com.cronutils.model.field.expression.Always;
|
||||
import com.cronutils.model.field.expression.QuestionMark;
|
||||
|
||||
/**
|
||||
* Crontab Cycle Tool Factory
|
||||
*/
|
||||
public class CycleFactory {
|
||||
|
||||
public static AbstractCycle min(Cron cron) {
|
||||
return new MinCycle(cron);
|
||||
}
|
||||
|
||||
public static AbstractCycle hour(Cron cron) {
|
||||
return new HourCycle(cron);
|
||||
}
|
||||
|
||||
public static AbstractCycle day(Cron cron) {
|
||||
return new DayCycle(cron);
|
||||
}
|
||||
|
||||
public static AbstractCycle week(Cron cron) {
|
||||
return new WeekCycle(cron);
|
||||
}
|
||||
|
||||
public static AbstractCycle month(Cron cron) {
|
||||
return new MonthCycle(cron);
|
||||
}
|
||||
|
||||
/**
|
||||
* day cycle
|
||||
*/
|
||||
public static class DayCycle extends AbstractCycle {
|
||||
|
||||
public DayCycle(Cron cron) {
|
||||
super(cron);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CycleEnum getCycle() {
|
||||
|
||||
if (minFiledIsSetAll()
|
||||
&& hourFiledIsSetAll()
|
||||
&& dayOfMonthFieldIsEvery()
|
||||
&& dayOfWeekField.getExpression() instanceof QuestionMark
|
||||
&& monthField.getExpression() instanceof Always) {
|
||||
return CycleEnum.DAY;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CycleEnum getMiniCycle() {
|
||||
if (dayOfMonthFieldIsEvery()) {
|
||||
return CycleEnum.DAY;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* hour cycle
|
||||
*/
|
||||
public static class HourCycle extends AbstractCycle {
|
||||
|
||||
public HourCycle(Cron cron) {
|
||||
super(cron);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CycleEnum getCycle() {
|
||||
if (minFiledIsSetAll()
|
||||
&& hourFiledIsEvery()
|
||||
&& dayOfMonthField.getExpression() instanceof Always
|
||||
&& dayOfWeekField.getExpression() instanceof QuestionMark
|
||||
&& monthField.getExpression() instanceof Always) {
|
||||
return CycleEnum.HOUR;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CycleEnum getMiniCycle() {
|
||||
if(hourFiledIsEvery()){
|
||||
return CycleEnum.HOUR;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* minute cycle
|
||||
*/
|
||||
public static class MinCycle extends AbstractCycle {
|
||||
|
||||
public MinCycle(Cron cron) {
|
||||
super(cron);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CycleEnum getCycle() {
|
||||
if (minFiledIsEvery()
|
||||
&& hourField.getExpression() instanceof Always
|
||||
&& dayOfMonthField.getExpression() instanceof Always
|
||||
&& monthField.getExpression() instanceof Always) {
|
||||
return CycleEnum.MINUTE;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CycleEnum getMiniCycle() {
|
||||
if(minFiledIsEvery()){
|
||||
return CycleEnum.MINUTE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* month cycle
|
||||
*/
|
||||
public static class MonthCycle extends AbstractCycle {
|
||||
|
||||
public MonthCycle(Cron cron) {
|
||||
super(cron);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CycleEnum getCycle() {
|
||||
boolean flag = (minFiledIsSetAll()
|
||||
&& hourFiledIsSetAll()
|
||||
&& dayOfMonthFieldIsSetAll()
|
||||
&& dayOfWeekField.getExpression() instanceof QuestionMark
|
||||
&& monthFieldIsEvery()) ||
|
||||
(minFiledIsSetAll()
|
||||
&& hourFiledIsSetAll()
|
||||
&& dayOfMonthField.getExpression() instanceof QuestionMark
|
||||
&& dayofWeekFieldIsSetAll()
|
||||
&& monthFieldIsEvery());
|
||||
if (flag) {
|
||||
return CycleEnum.MONTH;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CycleEnum getMiniCycle() {
|
||||
if (monthFieldIsEvery()) {
|
||||
return CycleEnum.MONTH;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* week cycle
|
||||
*/
|
||||
public static class WeekCycle extends AbstractCycle {
|
||||
public WeekCycle(Cron cron) {
|
||||
super(cron);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CycleEnum getCycle() {
|
||||
if (minFiledIsSetAll()
|
||||
&& hourFiledIsSetAll()
|
||||
&& dayOfMonthField.getExpression() instanceof QuestionMark
|
||||
&& dayofWeekFieldIsEvery()
|
||||
&& monthField.getExpression() instanceof Always) {
|
||||
return CycleEnum.WEEK;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CycleEnum getMiniCycle() {
|
||||
if (dayofWeekFieldIsEvery()) {
|
||||
return CycleEnum.WEEK;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.utils.cron;
|
||||
|
||||
import cn.escheduler.common.enums.CycleEnum;
|
||||
import com.cronutils.model.Cron;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 链接判断工具
|
||||
*/
|
||||
public class CycleLinks extends AbstractCycle {
|
||||
private final List<AbstractCycle> cycleList = new ArrayList<>();
|
||||
|
||||
public CycleLinks(Cron cron) {
|
||||
super(cron);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CycleLinks addCycle(AbstractCycle cycle) {
|
||||
cycleList.add(cycle);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CycleEnum getCycle() {
|
||||
for (AbstractCycle abstractCycle : cycleList) {
|
||||
CycleEnum cycle = abstractCycle.getCycle();
|
||||
if (cycle != null) {
|
||||
return cycle;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CycleEnum getMiniCycle() {
|
||||
for (AbstractCycle cycleHelper : cycleList) {
|
||||
CycleEnum cycle = cycleHelper.getMiniCycle();
|
||||
if (cycle != null) {
|
||||
return cycle;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
53
escheduler-dao/src/main/resources/dao/data_source.properties
Normal file
53
escheduler-dao/src/main/resources/dao/data_source.properties
Normal file
@ -0,0 +1,53 @@
|
||||
# base spring data source configuration
|
||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://192.168.xx.xx:3306/escheduler?characterEncoding=UTF-8
|
||||
spring.datasource.username=xx
|
||||
spring.datasource.password=xx
|
||||
|
||||
# connection configuration
|
||||
spring.datasource.initialSize=5
|
||||
# min connection number
|
||||
spring.datasource.minIdle=5
|
||||
# max connection number
|
||||
spring.datasource.maxActive=50
|
||||
|
||||
# max wait time for get a connection in milliseconds. if configuring maxWait, fair locks are enabled by default and concurrency efficiency decreases.
|
||||
# If necessary, unfair locks can be used by configuring the useUnfairLock attribute to true.
|
||||
spring.datasource.maxWait=60000
|
||||
|
||||
# milliseconds for check to close free connections
|
||||
spring.datasource.timeBetweenEvictionRunsMillis=60000
|
||||
|
||||
# the Destroy thread detects the connection interval and closes the physical connection in milliseconds if the connection idle time is greater than or equal to minEvictableIdleTimeMillis.
|
||||
spring.datasource.timeBetweenConnectErrorMillis=60000
|
||||
|
||||
# the longest time a connection remains idle without being evicted, in milliseconds
|
||||
spring.datasource.minEvictableIdleTimeMillis=300000
|
||||
|
||||
#the SQL used to check whether the connection is valid requires a query statement. If validation Query is null, testOnBorrow, testOnReturn, and testWhileIdle will not work.
|
||||
spring.datasource.validationQuery=SELECT 1
|
||||
#check whether the connection is valid for timeout, in seconds
|
||||
spring.datasource.validationQueryTimeout=3
|
||||
|
||||
# when applying for a connection, if it is detected that the connection is idle longer than time Between Eviction Runs Millis,
|
||||
# validation Query is performed to check whether the connection is valid
|
||||
spring.datasource.testWhileIdle=true
|
||||
|
||||
#execute validation to check if the connection is valid when applying for a connection
|
||||
spring.datasource.testOnBorrow=true
|
||||
#execute validation to check if the connection is valid when the connection is returned
|
||||
spring.datasource.testOnReturn=false
|
||||
spring.datasource.defaultAutoCommit=true
|
||||
spring.datasource.keepAlive=true
|
||||
|
||||
# open PSCache, specify count PSCache for every connection
|
||||
spring.datasource.poolPreparedStatements=true
|
||||
spring.datasource.maxPoolPreparedStatementPerConnectionSize=20
|
||||
|
||||
# data quality analysis is not currently in use. please ignore the following configuration
|
||||
# task record flag
|
||||
task.record.flag=false
|
||||
task.record.datasource.url=jdbc:mysql://192.168.xx.xx:3306/etl?characterEncoding=UTF-8
|
||||
task.record.datasource.username=xx
|
||||
task.record.datasource.password=xx
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class ProcessDaoTest {
|
||||
|
||||
|
||||
@Autowired
|
||||
ProcessDao processDao;
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.cron;
|
||||
|
||||
import cn.escheduler.common.enums.CycleEnum;
|
||||
import cn.escheduler.dao.utils.cron.CronUtils;
|
||||
import com.cronutils.builder.CronBuilder;
|
||||
import com.cronutils.model.Cron;
|
||||
import com.cronutils.model.CronType;
|
||||
import com.cronutils.model.definition.CronDefinitionBuilder;
|
||||
import com.cronutils.model.field.CronField;
|
||||
import com.cronutils.model.field.CronFieldName;
|
||||
import com.cronutils.model.field.expression.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
import static com.cronutils.model.field.expression.FieldExpressionFactory.*;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CronUtilsTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CronUtilsTest.class);
|
||||
|
||||
@Test
|
||||
public void cronAsStringTest() {
|
||||
Cron cron = CronBuilder.cron(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ))
|
||||
.withYear(always())
|
||||
.withDoW(questionMark())
|
||||
.withMonth(always())
|
||||
.withDoM(always())
|
||||
.withHour(always())
|
||||
.withMinute(every(5))
|
||||
.withSecond(on(0))
|
||||
.instance();
|
||||
// Obtain the string expression
|
||||
String cronAsString = cron.asString(); // 0 */5 * * * ? * 每5分钟一次
|
||||
|
||||
Assert.assertEquals(cronAsString, "0 */5 * * * ? *");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParse() throws ParseException {
|
||||
String strCrontab = "0 1 2 3 * ? *";
|
||||
Cron depCron = CronUtils.parse2Cron(strCrontab);
|
||||
Assert.assertEquals(depCron.retrieve(CronFieldName.SECOND).getExpression().asString(), "0");
|
||||
Assert.assertEquals(depCron.retrieve(CronFieldName.MINUTE).getExpression().asString(), "1");
|
||||
Assert.assertEquals(depCron.retrieve(CronFieldName.HOUR).getExpression().asString(), "2");
|
||||
Assert.assertEquals(depCron.retrieve(CronFieldName.DAY_OF_MONTH).getExpression().asString(), "3");
|
||||
Assert.assertEquals(depCron.retrieve(CronFieldName.MONTH).getExpression().asString(), "*");
|
||||
Assert.assertEquals(depCron.retrieve(CronFieldName.YEAR).getExpression().asString(), "*");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse1() throws ParseException {
|
||||
String strCrontab = "* * 0/1 * * ? *";
|
||||
strCrontab = "0/50 0/59 * * * ? *";
|
||||
strCrontab = "3/5 * 0/5 * * ? *";
|
||||
strCrontab = "1/5 3/5 1/5 3/30 * ? *";
|
||||
Cron depCron = CronUtils.parse2Cron(strCrontab);
|
||||
logger.info(depCron.validate().asString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scheduleTypeTest() throws ParseException {
|
||||
|
||||
CycleEnum cycleEnum = CronUtils.getMaxCycle("0 */1 * * * ? *");
|
||||
Assert.assertEquals(cycleEnum.name(), "MINUTE");
|
||||
|
||||
CycleEnum cycleEnum2 = CronUtils.getMaxCycle("0 * * * * ? *");
|
||||
Assert.assertEquals(cycleEnum2.name(), "MINUTE");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2(){
|
||||
Cron cron1 = CronBuilder.cron(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ))
|
||||
.withYear(always())
|
||||
.withDoW(questionMark())
|
||||
.withMonth(always())
|
||||
.withDoM(always())
|
||||
.withHour(always())
|
||||
.withMinute(every(5))
|
||||
.withSecond(on(0))
|
||||
.instance();
|
||||
|
||||
String cronAsString = cron1.asString(); // 0 */5 * * * ? * 每5分钟一次
|
||||
//logger.info(cronAsString);
|
||||
// Obtain the string expression
|
||||
//String minCrontab = "0 0 * * * ? *";
|
||||
//String minCrontab = "0 0 10,14,16 * * ?";
|
||||
//String minCrontab = "0 0-5 14 * * ? *";
|
||||
//String minCrontab = "0 0 2 ? * SUN *";
|
||||
//String minCrontab = "* 0,3 2 SUN * 1#1 *";
|
||||
//String minCrontab = "* 0,3 * 1W * ? *";
|
||||
//cron = CronUtils.parse2Cron("0 * * * * ? *");
|
||||
// 月份周期
|
||||
/*String[] cronArayy = new String[]{"* 0,3 * 1W * ? *","* 0 0 1W * ? *",
|
||||
"0 0 0 L 3/5 ? *","0 0 0 ? 3/5 2/2 *"};*/
|
||||
// 分钟周期
|
||||
String[] cronArayy = new String[]{"* * * * * ? *","* 0 * * * ? *",
|
||||
"* 5 * * 3/5 ? *","0 0 * * * ? *"};
|
||||
// 周周期
|
||||
/*String[] cronArayy = new String[]{"* * * ? * 2/1 *","0 *//*5 * ? * 2/1 *",
|
||||
"* * *//*5 ? * 2/1 *"};*/
|
||||
for(String minCrontab:cronArayy){
|
||||
if (!org.quartz.CronExpression.isValidExpression(minCrontab)) {
|
||||
throw new RuntimeException(minCrontab+"验证失败,表达式无效");
|
||||
}
|
||||
Cron cron = CronUtils.parse2Cron(minCrontab);
|
||||
CronField minField = cron.retrieve(CronFieldName.MINUTE);
|
||||
logger.info("minField instanceof Between:"+(minField.getExpression() instanceof Between));
|
||||
logger.info("minField instanceof Every:"+(minField.getExpression() instanceof Every));
|
||||
logger.info("minField instanceof Always:" + (minField.getExpression() instanceof Always));
|
||||
logger.info("minField instanceof On:"+(minField.getExpression() instanceof On));
|
||||
logger.info("minField instanceof And:"+(minField.getExpression() instanceof And));
|
||||
CronField hourField = cron.retrieve(CronFieldName.HOUR);
|
||||
logger.info("hourField instanceof Between:"+(hourField.getExpression() instanceof Between));
|
||||
logger.info("hourField instanceof Always:"+(hourField.getExpression() instanceof Always));
|
||||
logger.info("hourField instanceof Every:"+(hourField.getExpression() instanceof Every));
|
||||
logger.info("hourField instanceof On:"+(hourField.getExpression() instanceof On));
|
||||
logger.info("hourField instanceof And:"+(hourField.getExpression() instanceof And));
|
||||
|
||||
CronField dayOfMonthField = cron.retrieve(CronFieldName.DAY_OF_MONTH);
|
||||
logger.info("dayOfMonthField instanceof Between:"+(dayOfMonthField.getExpression() instanceof Between));
|
||||
logger.info("dayOfMonthField instanceof Always:"+(dayOfMonthField.getExpression() instanceof Always));
|
||||
logger.info("dayOfMonthField instanceof Every:"+(dayOfMonthField.getExpression() instanceof Every));
|
||||
logger.info("dayOfMonthField instanceof On:"+(dayOfMonthField.getExpression() instanceof On));
|
||||
logger.info("dayOfMonthField instanceof And:"+(dayOfMonthField.getExpression() instanceof And));
|
||||
logger.info("dayOfMonthField instanceof QuestionMark:"+(dayOfMonthField.getExpression() instanceof QuestionMark));
|
||||
|
||||
CronField monthField = cron.retrieve(CronFieldName.MONTH);
|
||||
logger.info("monthField instanceof Between:"+(monthField.getExpression() instanceof Between));
|
||||
logger.info("monthField instanceof Always:"+(monthField.getExpression() instanceof Always));
|
||||
logger.info("monthField instanceof Every:"+(monthField.getExpression() instanceof Every));
|
||||
logger.info("monthField instanceof On:"+(monthField.getExpression() instanceof On));
|
||||
logger.info("monthField instanceof And:"+(monthField.getExpression() instanceof And));
|
||||
logger.info("monthField instanceof QuestionMark:"+(monthField.getExpression() instanceof QuestionMark));
|
||||
|
||||
CronField dayOfWeekField = cron.retrieve(CronFieldName.DAY_OF_WEEK);
|
||||
logger.info("dayOfWeekField instanceof Between:"+(dayOfWeekField.getExpression() instanceof Between));
|
||||
logger.info("dayOfWeekField instanceof Always:"+(dayOfWeekField.getExpression() instanceof Always));
|
||||
logger.info("dayOfWeekField instanceof Every:"+(dayOfWeekField.getExpression() instanceof Every));
|
||||
logger.info("dayOfWeekField instanceof On:"+(dayOfWeekField.getExpression() instanceof On));
|
||||
logger.info("dayOfWeekField instanceof And:"+(dayOfWeekField.getExpression() instanceof And));
|
||||
logger.info("dayOfWeekField instanceof QuestionMark:"+(dayOfWeekField.getExpression() instanceof QuestionMark));
|
||||
|
||||
CronField yearField = cron.retrieve(CronFieldName.YEAR);
|
||||
|
||||
//CycleEnum cycleEnum = CronUtils.getMaxCycle("0 * * * * ? *");
|
||||
CycleEnum cycleEnum = CronUtils.getMaxCycle(minCrontab);
|
||||
if(cycleEnum !=null){
|
||||
logger.info(cycleEnum.name());
|
||||
}else{
|
||||
logger.info("无法获取到scheduleType");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.AlertType;
|
||||
import cn.escheduler.dao.datasource.ConnectionFactory;
|
||||
import cn.escheduler.dao.model.AlertGroup;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class AlertGroupMapperTest {
|
||||
|
||||
|
||||
AlertGroupMapper alertGroupMapper;
|
||||
|
||||
|
||||
@Before
|
||||
public void before(){
|
||||
alertGroupMapper = ConnectionFactory.getSqlSession().getMapper(AlertGroupMapper.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMapper(){
|
||||
AlertGroup alertGroup = new AlertGroup();
|
||||
alertGroup.setGroupName("alert group test");
|
||||
alertGroup.setDesc("alert group test");
|
||||
alertGroup.setGroupType(AlertType.EMAIL);
|
||||
alertGroup.setUpdateTime(new Date());
|
||||
alertGroup.setCreateTime(new Date());
|
||||
alertGroupMapper.insert(alertGroup);
|
||||
Assert.assertNotEquals(alertGroup.getId(), 0);
|
||||
alertGroup.setDesc("test alert group");
|
||||
alertGroupMapper.update(alertGroup);
|
||||
alertGroup = alertGroupMapper.queryById(alertGroup.getId());
|
||||
Assert.assertEquals(alertGroup.getDesc(), "test alert group");
|
||||
int delete = alertGroupMapper.delete(alertGroup.getId());
|
||||
Assert.assertEquals(delete, 1);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.AlertStatus;
|
||||
import cn.escheduler.common.enums.AlertType;
|
||||
import cn.escheduler.common.enums.ShowType;
|
||||
import cn.escheduler.dao.datasource.ConnectionFactory;
|
||||
import cn.escheduler.dao.model.Alert;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class AlertMapperTest {
|
||||
|
||||
|
||||
AlertMapper alertMapper;
|
||||
|
||||
@Before
|
||||
public void before(){
|
||||
alertMapper = ConnectionFactory.getSqlSession().getMapper(AlertMapper.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapper(){
|
||||
Alert alert = new Alert();
|
||||
alert.setAlertType(AlertType.EMAIL);
|
||||
alert.setContent("content test ");
|
||||
alert.setShowType(ShowType.TABLE);
|
||||
alert.setTitle("alert test");
|
||||
alert.setAlertGroupId(1);
|
||||
alert.setCreateTime(new Date());
|
||||
alert.setUpdateTime(new Date());
|
||||
alert.setAlertStatus(AlertStatus.WAIT_EXECUTION);
|
||||
alertMapper.insert(alert);
|
||||
Assert.assertNotEquals(alert.getId(), 0);
|
||||
|
||||
alert.setTitle("alert title");
|
||||
int update = alertMapper.update(AlertStatus.EXECUTION_SUCCESS, "execute successfully",
|
||||
new Date(), alert.getId());
|
||||
|
||||
Assert.assertEquals(update, 1);
|
||||
int delete = alertMapper.delete(alert.getId());
|
||||
Assert.assertEquals(delete, 1);
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.CommandType;
|
||||
import cn.escheduler.common.enums.FailureStrategy;
|
||||
import cn.escheduler.common.enums.TaskDependType;
|
||||
import cn.escheduler.common.enums.WarningType;
|
||||
import cn.escheduler.dao.datasource.ConnectionFactory;
|
||||
import cn.escheduler.dao.model.Command;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandMapperTest {
|
||||
|
||||
CommandMapper commandMapper;
|
||||
|
||||
|
||||
@Before
|
||||
public void before(){
|
||||
commandMapper = ConnectionFactory.getSqlSession().getMapper(CommandMapper.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapper(){
|
||||
|
||||
Command command = new Command();
|
||||
command.setCommandType(CommandType.START_PROCESS);
|
||||
command.setProcessDefinitionId(1);
|
||||
command.setExecutorId(10);
|
||||
command.setFailureStrategy(FailureStrategy.CONTINUE);
|
||||
command.setWarningType(WarningType.NONE);
|
||||
command.setWarningGroupId(1);
|
||||
command.setTaskDependType(TaskDependType.TASK_POST);
|
||||
commandMapper.insert(command);
|
||||
Assert.assertNotEquals(command.getId(), 0);
|
||||
|
||||
command.setCommandParam("command parameter test");
|
||||
int update = commandMapper.update(command);
|
||||
Assert.assertEquals(update, 1);
|
||||
|
||||
int delete = commandMapper.delete(command.getId());
|
||||
Assert.assertEquals(delete, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuery(){
|
||||
List<Command> commandList = commandMapper.queryAllCommand();
|
||||
Assert.assertNotEquals(commandList, null);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.DbType;
|
||||
import cn.escheduler.dao.datasource.ConnectionFactory;
|
||||
import cn.escheduler.dao.model.DataSource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class DataSourceMapperTest {
|
||||
|
||||
|
||||
DataSourceMapper dataSourceMapper;
|
||||
|
||||
@Before
|
||||
public void before(){
|
||||
dataSourceMapper = ConnectionFactory.getSqlSession().getMapper(DataSourceMapper.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMapper(){
|
||||
|
||||
DataSource dataSource = new DataSource();
|
||||
dataSource.setType(DbType.MYSQL);
|
||||
dataSource.setName("data source");
|
||||
dataSource.setConnectionParams("connections");
|
||||
dataSource.setNote("mysql test");
|
||||
dataSource.setCreateTime(new Date());
|
||||
dataSource.setUpdateTime(new Date());
|
||||
|
||||
dataSourceMapper.insert(dataSource);
|
||||
Assert.assertNotEquals(dataSource.getId(), 0);
|
||||
|
||||
List<DataSource> dataSources = dataSourceMapper.queryAllDataSourcePaging("", 0, 30);
|
||||
DataSource findDataSource = null;
|
||||
for(DataSource dataSource1 : dataSources){
|
||||
if(dataSource1.getId() == dataSource.getId()){
|
||||
findDataSource = dataSource1;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertNotEquals(findDataSource, null);
|
||||
int delete = dataSourceMapper.deleteDataSourceById(dataSource.getId());
|
||||
Assert.assertEquals(delete, 1);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.dao.datasource.ConnectionFactory;
|
||||
import cn.escheduler.dao.model.MasterServer;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
public class MasterServerMapperTest {
|
||||
|
||||
@Autowired
|
||||
MasterServerMapper masterServerMapper;
|
||||
|
||||
@Before
|
||||
public void before(){
|
||||
masterServerMapper =ConnectionFactory.getSqlSession().getMapper(MasterServerMapper.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryAllMaster() {
|
||||
|
||||
MasterServer masterServer = new MasterServer();
|
||||
String host = "127.22.2.1";
|
||||
masterServer.setHost(host);
|
||||
masterServer.setLastHeartbeatTime(new Date());
|
||||
masterServer.setPort(19282);
|
||||
masterServer.setCreateTime(new Date());
|
||||
masterServer.setZkDirectory("/root");
|
||||
|
||||
masterServerMapper.insert(masterServer);
|
||||
Assert.assertNotEquals(masterServer.getId(), 0);
|
||||
|
||||
masterServer.setPort(12892);
|
||||
int update = masterServerMapper.update(masterServer);
|
||||
Assert.assertEquals(update, 1);
|
||||
List<MasterServer> masterServers = masterServerMapper.queryAllMaster();
|
||||
|
||||
MasterServer findMaster = null;
|
||||
for(MasterServer master : masterServers){
|
||||
if(master.getId() == masterServer.getId()){
|
||||
findMaster = master;
|
||||
}
|
||||
}
|
||||
Assert.assertNotEquals(findMaster, null);
|
||||
|
||||
int delete = masterServerMapper.deleteWorkerByHost(host);
|
||||
Assert.assertEquals(delete, 1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.common.enums.Flag;
|
||||
import cn.escheduler.dao.datasource.ConnectionFactory;
|
||||
import cn.escheduler.dao.model.ProcessDefinition;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class ProcessDefinitionMapperTest {
|
||||
|
||||
|
||||
ProcessDefinitionMapper processDefinitionMapper;
|
||||
|
||||
|
||||
@Before
|
||||
public void before(){
|
||||
processDefinitionMapper = ConnectionFactory.getSqlSession().getMapper(ProcessDefinitionMapper.class);
|
||||
}
|
||||
@Test
|
||||
public void testMapper() {
|
||||
ProcessDefinition processDefinition = new ProcessDefinition();
|
||||
|
||||
processDefinition.setProcessDefinitionJson("json field");
|
||||
|
||||
processDefinition.setName("test");
|
||||
processDefinition.setConnects("[]");
|
||||
processDefinition.setLocations("[]");
|
||||
processDefinition.setFlag(Flag.YES);
|
||||
processDefinition.setDesc("test");
|
||||
processDefinition.setProjectId(1024);
|
||||
processDefinition.setUpdateTime(new Date());
|
||||
processDefinition.setCreateTime(new Date());
|
||||
|
||||
processDefinitionMapper.insert(processDefinition);
|
||||
Assert.assertNotEquals(processDefinition.getId(), 0);
|
||||
processDefinition.setName("test definition");
|
||||
int update = processDefinitionMapper.update(processDefinition);
|
||||
Assert.assertEquals(update, 1);
|
||||
|
||||
ProcessDefinition findProcess = null;
|
||||
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryAllDefinitionList(1024);
|
||||
for(ProcessDefinition processDefinition1 : processDefinitionList){
|
||||
if(processDefinition1.getId() == processDefinition.getId()){
|
||||
findProcess = processDefinition1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert.assertNotEquals(findProcess, null);
|
||||
|
||||
int delete = processDefinitionMapper.delete(processDefinition.getId());
|
||||
Assert.assertEquals(delete, 1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 cn.escheduler.dao.mapper;
|
||||
|
||||
import cn.escheduler.dao.datasource.ConnectionFactory;
|
||||
import cn.escheduler.dao.model.Tenant;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class TenantMapperTest {
|
||||
|
||||
|
||||
TenantMapper tenantMapper;
|
||||
|
||||
@Before
|
||||
public void before(){
|
||||
tenantMapper = ConnectionFactory.getSqlSession().getMapper(TenantMapper.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void testMapper(){
|
||||
|
||||
Tenant tenant = new Tenant();
|
||||
tenant.setTenantName("大数据平台部");
|
||||
tenant.setQueueId(1);
|
||||
tenant.setCreateTime(new Date());
|
||||
tenant.setUpdateTime(new Date());
|
||||
tenantMapper.insert(tenant);
|
||||
Assert.assertNotEquals(tenant.getId(), 0);
|
||||
tenant.setTenantName("大数据平台部test");
|
||||
int update = tenantMapper.update(tenant);
|
||||
Assert.assertEquals(update, 1);
|
||||
|
||||
tenant = tenantMapper.queryById(tenant.getId());
|
||||
Assert.assertEquals(tenant.getTenantName(), "大数据平台部test");
|
||||
|
||||
int delete = tenantMapper.deleteById(tenant.getId());
|
||||
Assert.assertEquals(delete, 1);
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user