use of org.apache.dolphinscheduler.api.utils.Result in project dolphinscheduler by apache.
the class DataSourceService method verifyDataSourceName.
/**
* verify datasource exists
*
* @param loginUser login user
* @param name datasource name
* @return true if data datasource not exists, otherwise return false
*/
public Result verifyDataSourceName(User loginUser, String name) {
Result result = new Result();
List<DataSource> dataSourceList = dataSourceMapper.queryDataSourceByName(name);
if (dataSourceList != null && dataSourceList.size() > 0) {
logger.error("datasource name:{} has exist, can't create again.", name);
putMsg(result, Status.DATASOURCE_EXIST);
} else {
putMsg(result, Status.SUCCESS);
}
return result;
}
use of org.apache.dolphinscheduler.api.utils.Result in project dolphinscheduler by apache.
the class BaseController method success.
/**
* success does not need to return data
*
* @param msg success message
* @return success result code
*/
public Result success(String msg) {
Result result = new Result();
result.setCode(Status.SUCCESS.getCode());
result.setMsg(msg);
return result;
}
use of org.apache.dolphinscheduler.api.utils.Result in project dolphinscheduler by apache.
the class BaseController method success.
/**
* return data with paging
*
* @param totalList success object list
* @param currentPage current page
* @param total total
* @param totalPage total page
* @return success result code
*/
public Result success(Object totalList, Integer currentPage, Integer total, Integer totalPage) {
Result result = new Result();
result.setCode(Status.SUCCESS.getCode());
result.setMsg(Status.SUCCESS.getMsg());
Map<String, Object> map = new HashMap<>(4);
map.put(Constants.TOTAL_LIST, totalList);
map.put(Constants.CURRENT_PAGE, currentPage);
map.put(Constants.TOTAL_PAGE, totalPage);
map.put(Constants.TOTAL, total);
result.setData(map);
return result;
}
use of org.apache.dolphinscheduler.api.utils.Result in project dolphinscheduler by apache.
the class BaseController method success.
/**
* success
*
* @return success result code
*/
public Result success() {
Result result = new Result();
result.setCode(Status.SUCCESS.getCode());
result.setMsg(Status.SUCCESS.getMsg());
return result;
}
use of org.apache.dolphinscheduler.api.utils.Result in project dolphinscheduler by apache.
the class LoggerServiceTest method testQueryDataSourceList.
@Test
public void testQueryDataSourceList() {
TaskInstance taskInstance = new TaskInstance();
Mockito.when(processService.findTaskInstanceById(1)).thenReturn(taskInstance);
Result result = loggerService.queryLog(2, 1, 1);
// TASK_INSTANCE_NOT_FOUND
Assert.assertEquals(Status.TASK_INSTANCE_NOT_FOUND.getCode(), result.getCode().intValue());
try {
// HOST NOT FOUND OR ILLEGAL
result = loggerService.queryLog(1, 1, 1);
} catch (RuntimeException e) {
Assert.assertTrue(true);
logger.error("testQueryDataSourceList error {}", e.getMessage());
}
Assert.assertEquals(Status.TASK_INSTANCE_NOT_FOUND.getCode(), result.getCode().intValue());
// SUCCESS
taskInstance.setHost("127.0.0.1:8080");
taskInstance.setLogPath("/temp/log");
Mockito.when(processService.findTaskInstanceById(1)).thenReturn(taskInstance);
result = loggerService.queryLog(1, 1, 1);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
}
Aggregations