Search in sources :

Example 1 with Resource

use of org.apache.dolphinscheduler.dao.entity.Resource in project dolphinscheduler by apache.

the class BaseController method returnDataListPaging.

/**
 * return data list with paging
 * @param result result code
 * @return result code
 */
public Result returnDataListPaging(Map<String, Object> result) {
    Status status = (Status) result.get(Constants.STATUS);
    if (status == Status.SUCCESS) {
        result.put(Constants.MSG, Status.SUCCESS.getMsg());
        PageInfo<Resource> pageInfo = (PageInfo<Resource>) result.get(Constants.DATA_LIST);
        return success(pageInfo.getLists(), pageInfo.getCurrentPage(), pageInfo.getTotalCount(), pageInfo.getTotalPage());
    } else {
        Integer code = status.getCode();
        String msg = (String) result.get(Constants.MSG);
        return error(code, msg);
    }
}
Also used : Status(org.apache.dolphinscheduler.api.enums.Status) PageInfo(org.apache.dolphinscheduler.api.utils.PageInfo) Resource(org.apache.dolphinscheduler.dao.entity.Resource)

Example 2 with Resource

use of org.apache.dolphinscheduler.dao.entity.Resource in project dolphinscheduler by apache.

the class ResourceFilter method listAllParent.

/**
 * list all parent dir
 * @return parent resource dir set
 */
Set<Resource> listAllParent() {
    Set<Resource> parentList = new HashSet<>();
    Set<Resource> filterFileList = fileFilter();
    for (Resource file : filterFileList) {
        parentList.add(file);
        setAllParent(file, parentList);
    }
    return parentList;
}
Also used : Resource(org.apache.dolphinscheduler.dao.entity.Resource) HashSet(java.util.HashSet)

Example 3 with Resource

use of org.apache.dolphinscheduler.dao.entity.Resource in project dolphinscheduler by apache.

the class UdfFuncServiceTest method getResource.

/**
 * get resourceId
 */
private Resource getResource() {
    Resource resource = new Resource();
    resource.setId(1);
    resource.setAlias("test");
    return resource;
}
Also used : Resource(org.apache.dolphinscheduler.dao.entity.Resource)

Example 4 with Resource

use of org.apache.dolphinscheduler.dao.entity.Resource in project dolphinscheduler by apache.

the class ResourcesServiceTest method getUdfResource.

private Resource getUdfResource() {
    Resource resource = new Resource();
    resource.setUserId(1);
    resource.setDescription("udfTest");
    resource.setAlias("udfTest.jar");
    resource.setFullName("/udfTest.jar");
    resource.setType(ResourceType.UDF);
    return resource;
}
Also used : Resource(org.apache.dolphinscheduler.dao.entity.Resource)

Example 5 with Resource

use of org.apache.dolphinscheduler.dao.entity.Resource in project dolphinscheduler by apache.

the class ResourceFilterTest method filterTest.

@Test
public void filterTest() {
    List<Resource> allList = new ArrayList<>();
    Resource resource1 = new Resource(3, -1, "b", "/b", true);
    Resource resource2 = new Resource(4, 2, "a1.txt", "/a/a1.txt", false);
    Resource resource3 = new Resource(5, 3, "b1.txt", "/b/b1.txt", false);
    Resource resource4 = new Resource(6, 3, "b2.jar", "/b/b2.jar", false);
    Resource resource5 = new Resource(7, -1, "b2", "/b2", true);
    Resource resource6 = new Resource(8, -1, "b2", "/b/b2", true);
    Resource resource7 = new Resource(9, 8, "c2.jar", "/b/b2/c2.jar", false);
    allList.add(resource1);
    allList.add(resource2);
    allList.add(resource3);
    allList.add(resource4);
    allList.add(resource5);
    allList.add(resource6);
    allList.add(resource7);
    Set<String> suffixSet = new HashSet<>();
    suffixSet.add(".jar");
    suffixSet.add(".txt");
    ResourceFilter resourceFilter = new ResourceFilter(suffixSet, allList);
    List<Resource> resourceList = resourceFilter.filter();
    Assert.assertNotNull(resourceList);
    resourceList.stream().forEach(t -> logger.info(t.toString()));
}
Also used : Resource(org.apache.dolphinscheduler.dao.entity.Resource) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Resource (org.apache.dolphinscheduler.dao.entity.Resource)40 Test (org.junit.Test)23 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)14 ArrayList (java.util.ArrayList)10 User (org.apache.dolphinscheduler.dao.entity.User)10 ResourcesUser (org.apache.dolphinscheduler.dao.entity.ResourcesUser)7 Date (java.util.Date)5 List (java.util.List)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 IPage (com.baomidou.mybatisplus.core.metadata.IPage)3 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)3 ResourceComponent (org.apache.dolphinscheduler.api.dto.resources.ResourceComponent)3 ResourceInfo (org.apache.dolphinscheduler.common.process.ResourceInfo)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 PageInfo (org.apache.dolphinscheduler.api.utils.PageInfo)2 Result (org.apache.dolphinscheduler.api.utils.Result)2 Tenant (org.apache.dolphinscheduler.dao.entity.Tenant)2 UdfFunc (org.apache.dolphinscheduler.dao.entity.UdfFunc)2 Arrays (java.util.Arrays)1