Search in sources :

Example 11 with ReadWriteLockVO

use of com.dtstack.taier.develop.dto.devlop.ReadWriteLockVO in project Taier by DTStack.

the class ReadWriteLockService method addOrUpdateLock.

/**
 * 新增、更新 锁信息
 * @param tenantId
 * @param userId
 * @param type
 * @param fileId
 * @return
 */
@Transactional(rollbackFor = Exception.class)
public ReadWriteLockVO addOrUpdateLock(Long tenantId, Long userId, String type, Long fileId) {
    ReadWriteLockVO readWriteLockVO;
    BatchReadWriteLock readWriteLock = developReadWriteLockDao.getByTenantIdAndRelationIdAndType(tenantId, fileId, type);
    if (readWriteLock == null) {
        readWriteLockVO = this.insert(tenantId, fileId, type, userId);
    } else {
        Integer result = 0;
        result = developReadWriteLockDao.updateVersionAndModifyUserId(readWriteLock.getId(), null, userId);
        readWriteLock = developReadWriteLockDao.getOne(readWriteLock.getId());
        readWriteLockVO = ReadWriteLockVO.toVO(readWriteLock);
        String userName = userService.getUserName(readWriteLock.getModifyUserId());
        readWriteLockVO.setLastKeepLockUserName(userName);
    }
    return readWriteLockVO;
}
Also used : ReadWriteLockVO(com.dtstack.taier.develop.dto.devlop.ReadWriteLockVO) BatchReadWriteLock(com.dtstack.taier.dao.domain.BatchReadWriteLock) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ReadWriteLockVO (com.dtstack.taier.develop.dto.devlop.ReadWriteLockVO)11 BatchReadWriteLock (com.dtstack.taier.dao.domain.BatchReadWriteLock)9 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)7 Transactional (org.springframework.transaction.annotation.Transactional)4 BatchTask (com.dtstack.taier.dao.domain.BatchTask)3 List (java.util.List)3 ReadWriteLockType (com.dtstack.taier.common.enums.ReadWriteLockType)2 TaskLockStatus (com.dtstack.taier.common.enums.TaskLockStatus)2 ErrorCode (com.dtstack.taier.common.exception.ErrorCode)2 BatchCatalogue (com.dtstack.taier.dao.domain.BatchCatalogue)2 BatchResource (com.dtstack.taier.dao.domain.BatchResource)2 BatchTaskBatchVO (com.dtstack.taier.develop.dto.devlop.BatchTaskBatchVO)2 ArrayList (java.util.ArrayList)2 JSON (com.alibaba.fastjson.JSON)1 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 JSONPath (com.alibaba.fastjson.JSONPath)1 TypeReference (com.alibaba.fastjson.TypeReference)1 ClientCache (com.dtstack.dtcenter.loader.client.ClientCache)1 IClient (com.dtstack.dtcenter.loader.client.IClient)1