Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
3c07d9ba
Unverified
Commit
3c07d9ba
authored
May 07, 2024
by
suxinshuo
Committed by
GitHub
May 07, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature-1134][admin] Task directory supports flexible sorting (#3440)
Co-authored-by:
suxinshuo
<
suxinshuo@itiger.com
>
parent
78d55ad5
Show whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
1623 additions
and
35 deletions
+1623
-35
CatalogueController.java
...c/main/java/org/dinky/controller/CatalogueController.java
+18
-3
CatalogueTreeQueryDTO.java
...c/main/java/org/dinky/data/dto/CatalogueTreeQueryDTO.java
+44
-0
TreeVo.java
dinky-admin/src/main/java/org/dinky/data/vo/TreeVo.java
+49
-0
CatalogueService.java
...in/java/org/dinky/service/catalogue/CatalogueService.java
+13
-3
CatalogueTreeSortFactory.java
...y/service/catalogue/factory/CatalogueTreeSortFactory.java
+67
-0
CatalogueServiceImpl.java
...rg/dinky/service/catalogue/impl/CatalogueServiceImpl.java
+52
-4
CatalogueTreeSortStrategy.java
...service/catalogue/strategy/CatalogueTreeSortStrategy.java
+42
-0
CatalogueTreeSortCreateTimeStrategy.java
...ue/strategy/impl/CatalogueTreeSortCreateTimeStrategy.java
+76
-0
CatalogueTreeSortDefaultStrategy.java
...logue/strategy/impl/CatalogueTreeSortDefaultStrategy.java
+73
-0
CatalogueTreeSortFirstLetterStrategy.java
...e/strategy/impl/CatalogueTreeSortFirstLetterStrategy.java
+80
-0
SchedulerServiceImpl.java
...ain/java/org/dinky/service/impl/SchedulerServiceImpl.java
+1
-1
TaskServiceImpl.java
...src/main/java/org/dinky/service/impl/TaskServiceImpl.java
+1
-1
Safes.java
dinky-admin/src/main/java/org/dinky/utils/Safes.java
+43
-0
CatalogueTreeSortFactoryTest.java
...rvice/catalogue/factory/CatalogueTreeSortFactoryTest.java
+109
-0
CatalogueTreeSortCreateTimeStrategyTest.java
...trategy/impl/CatalogueTreeSortCreateTimeStrategyTest.java
+171
-0
CatalogueTreeSortDefaultStrategyTest.java
...e/strategy/impl/CatalogueTreeSortDefaultStrategyTest.java
+158
-0
CatalogueTreeSortFirstLetterStrategyTest.java
...rategy/impl/CatalogueTreeSortFirstLetterStrategyTest.java
+183
-0
CategoryTreeSortStrategyTestUtils.java
...ogue/strategy/impl/CategoryTreeSortStrategyTestUtils.java
+47
-0
CatalogueSortConstant.java
...n/java/org/dinky/data/constant/CatalogueSortConstant.java
+32
-0
CatalogueSortValueEnum.java
...ain/java/org/dinky/data/enums/CatalogueSortValueEnum.java
+57
-0
SortTypeEnum.java
...mmon/src/main/java/org/dinky/data/enums/SortTypeEnum.java
+106
-0
messages_en_US.properties
...-common/src/main/resources/i18n/messages_en_US.properties
+6
-0
messages_zh_CN.properties
...-common/src/main/resources/i18n/messages_zh_CN.properties
+6
-0
index.tsx
dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx
+5
-3
index.tsx
.../pages/DataStudio/LeftContainer/Project/JobTree/index.tsx
+102
-3
index.tsx
...s/DataStudio/LeftContainer/Project/ProjectTitle/index.tsx
+4
-2
index.tsx
...-web/src/pages/DataStudio/LeftContainer/Project/index.tsx
+9
-6
service.tsx
...eb/src/pages/DataStudio/LeftContainer/Project/service.tsx
+5
-2
function.ts
dinky-web/src/pages/DataStudio/function.ts
+8
-2
index.tsx
dinky-web/src/pages/DataStudio/index.tsx
+7
-3
model.ts
dinky-web/src/pages/DataStudio/model.ts
+47
-1
index.tsx
dinky-web/src/pages/DevOps/JobList/index.tsx
+1
-1
endpoints.tsx
dinky-web/src/services/endpoints.tsx
+1
-0
No files found.
dinky-admin/src/main/java/org/dinky/controller/CatalogueController.java
View file @
3c07d9ba
...
@@ -21,12 +21,14 @@ package org.dinky.controller;
...
@@ -21,12 +21,14 @@ package org.dinky.controller;
import
org.dinky.data.annotations.Log
;
import
org.dinky.data.annotations.Log
;
import
org.dinky.data.dto.CatalogueTaskDTO
;
import
org.dinky.data.dto.CatalogueTaskDTO
;
import
org.dinky.data.dto.CatalogueTreeQueryDTO
;
import
org.dinky.data.enums.BusinessType
;
import
org.dinky.data.enums.BusinessType
;
import
org.dinky.data.enums.Status
;
import
org.dinky.data.enums.Status
;
import
org.dinky.data.model.Catalogue
;
import
org.dinky.data.model.Catalogue
;
import
org.dinky.data.result.Result
;
import
org.dinky.data.result.Result
;
import
org.dinky.data.vo.TreeVo
;
import
org.dinky.function.constant.PathConstant
;
import
org.dinky.function.constant.PathConstant
;
import
org.dinky.service.CatalogueService
;
import
org.dinky.service.
catalogue.
CatalogueService
;
import
java.io.File
;
import
java.io.File
;
import
java.util.List
;
import
java.util.List
;
...
@@ -125,15 +127,28 @@ public class CatalogueController {
...
@@ -125,15 +127,28 @@ public class CatalogueController {
/**
/**
* query catalogue tree data
* query catalogue tree data
*
* @param catalogueTreeQueryDto {@link CatalogueTreeQueryDTO}
* @return {@link Result}< {@link List}< {@link Catalogue}>>}
* @return {@link Result}< {@link List}< {@link Catalogue}>>}
*/
*/
@PostMapping
(
"/getCatalogueTreeData"
)
@PostMapping
(
"/getCatalogueTreeData"
)
@ApiOperation
(
"Get Catalogue Tree Data"
)
@ApiOperation
(
"Get Catalogue Tree Data"
)
public
Result
<
List
<
Catalogue
>>
getCatalogueTree
()
{
public
Result
<
List
<
Catalogue
>>
getCatalogueTree
(
@RequestBody
CatalogueTreeQueryDTO
catalogueTreeQueryDto
)
{
List
<
Catalogue
>
catalogues
=
catalogueService
.
getCatalogueTree
();
List
<
Catalogue
>
catalogues
=
catalogueService
.
getCatalogueTree
(
catalogueTreeQueryDto
);
return
Result
.
succeed
(
catalogues
);
return
Result
.
succeed
(
catalogues
);
}
}
/**
* query catalogue sort type
* @return {@link Result}< {@link List}< {@link TreeVo}>>}
*/
@PostMapping
(
"/getCatalogueSortType"
)
@ApiOperation
(
"Get Catalogue Sort Type"
)
public
Result
<
List
<
TreeVo
>>
getCatalogueSortType
()
{
List
<
TreeVo
>
catalogueSortType
=
catalogueService
.
getCatalogueSortType
();
return
Result
.
succeed
(
catalogueSortType
);
}
/**
/**
* create catalogue and task
* create catalogue and task
* @param catalogueTaskDTO {@link CatalogueTaskDTO}
* @param catalogueTaskDTO {@link CatalogueTaskDTO}
...
...
dinky-admin/src/main/java/org/dinky/data/dto/CatalogueTreeQueryDTO.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
data
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
/**
* CatalogueTreeQueryDTO
*
* @since 2024/4/25 17:59
*/
@Getter
@Setter
@ToString
@ApiModel
(
value
=
"CatalogueTreeQueryDTO"
,
description
=
"DTO for catalogue tree query"
)
public
class
CatalogueTreeQueryDTO
{
@ApiModelProperty
(
value
=
"Sort Value"
,
dataType
=
"String"
,
example
=
"create_time"
)
private
String
sortValue
;
@ApiModelProperty
(
value
=
"Sort Type"
,
dataType
=
"String"
,
example
=
"asc"
)
private
String
sortType
;
}
dinky-admin/src/main/java/org/dinky/data/vo/TreeVo.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
data
.
vo
;
import
java.io.Serializable
;
import
java.util.List
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel
(
value
=
"TreeVo"
,
description
=
"The return value of the tree structure"
)
public
class
TreeVo
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"Name"
,
required
=
true
,
example
=
"Create Time"
,
dataType
=
"String"
)
private
String
name
;
@ApiModelProperty
(
value
=
"Value"
,
required
=
true
,
example
=
"Create Time"
,
dataType
=
"String"
)
private
String
value
;
@ApiModelProperty
(
value
=
"Children objects"
,
notes
=
"List of child TreeVo objects"
,
dataType
=
"List<TreeVo>"
)
private
List
<
TreeVo
>
children
;
}
dinky-admin/src/main/java/org/dinky/service/CatalogueService.java
→
dinky-admin/src/main/java/org/dinky/service/
catalogue/
CatalogueService.java
View file @
3c07d9ba
...
@@ -17,11 +17,13 @@
...
@@ -17,11 +17,13 @@
*
*
*/
*/
package
org
.
dinky
.
service
;
package
org
.
dinky
.
service
.
catalogue
;
import
org.dinky.data.dto.CatalogueTaskDTO
;
import
org.dinky.data.dto.CatalogueTaskDTO
;
import
org.dinky.data.dto.CatalogueTreeQueryDTO
;
import
org.dinky.data.model.Catalogue
;
import
org.dinky.data.model.Catalogue
;
import
org.dinky.data.result.Result
;
import
org.dinky.data.result.Result
;
import
org.dinky.data.vo.TreeVo
;
import
org.dinky.mybatis.service.ISuperService
;
import
org.dinky.mybatis.service.ISuperService
;
import
java.util.List
;
import
java.util.List
;
...
@@ -34,11 +36,19 @@ import java.util.List;
...
@@ -34,11 +36,19 @@ import java.util.List;
public
interface
CatalogueService
extends
ISuperService
<
Catalogue
>
{
public
interface
CatalogueService
extends
ISuperService
<
Catalogue
>
{
/**
/**
* Get the catalogue tree
* Get the catalogue tree
.
*
*
* @param catalogueTreeQueryDto The query conditions.
* @return A list of {@link Catalogue} objects representing the catalogue tree.
* @return A list of {@link Catalogue} objects representing the catalogue tree.
*/
*/
List
<
Catalogue
>
getCatalogueTree
();
List
<
Catalogue
>
getCatalogueTree
(
CatalogueTreeQueryDTO
catalogueTreeQueryDto
);
/**
* Get the catalogue sort type.
*
* @return A list of {@link TreeVo} objects representing the catalogue sort type.
*/
List
<
TreeVo
>
getCatalogueSortType
();
/**
/**
* Find a catalogue by its parent ID and name.
* Find a catalogue by its parent ID and name.
...
...
dinky-admin/src/main/java/org/dinky/service/catalogue/factory/CatalogueTreeSortFactory.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
service
.
catalogue
.
factory
;
import
org.dinky.data.constant.CatalogueSortConstant
;
import
org.dinky.data.exception.BusException
;
import
org.dinky.service.catalogue.strategy.CatalogueTreeSortStrategy
;
import
org.dinky.utils.Safes
;
import
java.util.Map
;
import
java.util.Objects
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
cn.hutool.core.util.StrUtil
;
import
lombok.extern.slf4j.Slf4j
;
/**
* CatalogueTreeSortFactory
*
* @since 2024/4/29 14:19
*/
@Slf4j
@Component
public
class
CatalogueTreeSortFactory
{
@Autowired
private
Map
<
String
,
CatalogueTreeSortStrategy
>
catalogueTreeSortStrategyMap
;
/**
* Get CatalogueTreeSortStrategy.
*
* @param strategyName Strategy Name.
* @return {@link CatalogueTreeSortStrategy} CatalogueTreeSortStrategy.
*/
public
CatalogueTreeSortStrategy
getStrategy
(
String
strategyName
)
{
CatalogueTreeSortStrategy
catalogueTreeSortStrategy
=
Safes
.
of
(
catalogueTreeSortStrategyMap
).
get
(
strategyName
);
if
(
Objects
.
isNull
(
catalogueTreeSortStrategy
))
{
log
.
warn
(
"Strategy {} is not defined. Use DefaultStrategy"
,
strategyName
);
catalogueTreeSortStrategy
=
Safes
.
of
(
catalogueTreeSortStrategyMap
).
get
(
CatalogueSortConstant
.
STRATEGY_DEFAULT
);
}
if
(
Objects
.
isNull
(
catalogueTreeSortStrategy
))
{
throw
new
BusException
(
StrUtil
.
format
(
"Strategy {} is not defined."
,
strategyName
));
}
return
catalogueTreeSortStrategy
;
}
}
dinky-admin/src/main/java/org/dinky/service/impl/CatalogueServiceImpl.java
→
dinky-admin/src/main/java/org/dinky/service/
catalogue/
impl/CatalogueServiceImpl.java
View file @
3c07d9ba
...
@@ -17,16 +17,19 @@
...
@@ -17,16 +17,19 @@
*
*
*/
*/
package
org
.
dinky
.
service
.
impl
;
package
org
.
dinky
.
service
.
catalogue
.
impl
;
import
static
org
.
dinky
.
assertion
.
Asserts
.
isNull
;
import
static
org
.
dinky
.
assertion
.
Asserts
.
isNull
;
import
org.dinky.assertion.Asserts
;
import
org.dinky.assertion.Asserts
;
import
org.dinky.config.Dialect
;
import
org.dinky.config.Dialect
;
import
org.dinky.data.dto.CatalogueTaskDTO
;
import
org.dinky.data.dto.CatalogueTaskDTO
;
import
org.dinky.data.dto.CatalogueTreeQueryDTO
;
import
org.dinky.data.enums.CatalogueSortValueEnum
;
import
org.dinky.data.enums.GatewayType
;
import
org.dinky.data.enums.GatewayType
;
import
org.dinky.data.enums.JobLifeCycle
;
import
org.dinky.data.enums.JobLifeCycle
;
import
org.dinky.data.enums.JobStatus
;
import
org.dinky.data.enums.JobStatus
;
import
org.dinky.data.enums.SortTypeEnum
;
import
org.dinky.data.enums.Status
;
import
org.dinky.data.enums.Status
;
import
org.dinky.data.exception.BusException
;
import
org.dinky.data.exception.BusException
;
import
org.dinky.data.model.Catalogue
;
import
org.dinky.data.model.Catalogue
;
...
@@ -37,20 +40,24 @@ import org.dinky.data.model.job.History;
...
@@ -37,20 +40,24 @@ import org.dinky.data.model.job.History;
import
org.dinky.data.model.job.JobHistory
;
import
org.dinky.data.model.job.JobHistory
;
import
org.dinky.data.model.job.JobInstance
;
import
org.dinky.data.model.job.JobInstance
;
import
org.dinky.data.result.Result
;
import
org.dinky.data.result.Result
;
import
org.dinky.data.vo.TreeVo
;
import
org.dinky.mapper.CatalogueMapper
;
import
org.dinky.mapper.CatalogueMapper
;
import
org.dinky.mybatis.service.impl.SuperServiceImpl
;
import
org.dinky.mybatis.service.impl.SuperServiceImpl
;
import
org.dinky.service.CatalogueService
;
import
org.dinky.service.HistoryService
;
import
org.dinky.service.HistoryService
;
import
org.dinky.service.JobHistoryService
;
import
org.dinky.service.JobHistoryService
;
import
org.dinky.service.JobInstanceService
;
import
org.dinky.service.JobInstanceService
;
import
org.dinky.service.MonitorService
;
import
org.dinky.service.MonitorService
;
import
org.dinky.service.TaskService
;
import
org.dinky.service.TaskService
;
import
org.dinky.service.catalogue.CatalogueService
;
import
org.dinky.service.catalogue.factory.CatalogueTreeSortFactory
;
import
org.dinky.service.catalogue.strategy.CatalogueTreeSortStrategy
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.File
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -62,6 +69,7 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -62,6 +69,7 @@ import org.springframework.transaction.annotation.Transactional;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.google.common.collect.Lists
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
...
@@ -69,17 +77,20 @@ import cn.hutool.core.collection.CollectionUtil;
...
@@ -69,17 +77,20 @@ import cn.hutool.core.collection.CollectionUtil;
import
cn.hutool.core.lang.Opt
;
import
cn.hutool.core.lang.Opt
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
/**
/**
* CatalogueServiceImpl
* CatalogueServiceImpl
*
*
* @since 2021/5/28 14:02
* @since 2021/5/28 14:02
*/
*/
@Slf4j
@Service
@Service
@RequiredArgsConstructor
@RequiredArgsConstructor
public
class
CatalogueServiceImpl
extends
SuperServiceImpl
<
CatalogueMapper
,
Catalogue
>
implements
CatalogueService
{
public
class
CatalogueServiceImpl
extends
SuperServiceImpl
<
CatalogueMapper
,
Catalogue
>
implements
CatalogueService
{
private
final
TaskService
taskService
;
private
final
TaskService
taskService
;
private
final
JobInstanceService
jobInstanceService
;
private
final
JobInstanceService
jobInstanceService
;
private
final
HistoryService
historyService
;
private
final
HistoryService
historyService
;
...
@@ -88,12 +99,18 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
...
@@ -88,12 +99,18 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
private
final
MonitorService
monitorService
;
private
final
MonitorService
monitorService
;
private
final
CatalogueTreeSortFactory
catalogueTreeSortFactory
;
/**
/**
* @return
* @return
*/
*/
@Override
@Override
public
List
<
Catalogue
>
getCatalogueTree
()
{
public
List
<
Catalogue
>
getCatalogueTree
(
CatalogueTreeQueryDTO
catalogueTreeQueryDto
)
{
return
buildCatalogueTree
(
this
.
list
());
log
.
info
(
"getCatalogueTree, catalogueTreeQueryDto: {}"
,
catalogueTreeQueryDto
);
List
<
Catalogue
>
catalogueTree
=
buildCatalogueTree
(
this
.
list
());
// sort
CatalogueTreeSortStrategy
strategy
=
catalogueTreeSortFactory
.
getStrategy
(
catalogueTreeQueryDto
.
getSortValue
());
return
strategy
.
sort
(
catalogueTree
,
SortTypeEnum
.
getByName
(
catalogueTreeQueryDto
.
getSortType
()));
}
}
/**
/**
...
@@ -179,6 +196,37 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
...
@@ -179,6 +196,37 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
return
childList
;
return
childList
;
}
}
/**
* Get the catalogue sort type
*
* @return A list of {@link TreeVo} objects representing the catalogue sort type.
*/
@Override
public
List
<
TreeVo
>
getCatalogueSortType
()
{
List
<
TreeVo
>
treeVoList
=
Lists
.
newArrayList
();
for
(
CatalogueSortValueEnum
catalogueSortValueEnum
:
CatalogueSortValueEnum
.
values
())
{
String
catalogueSortValueEnumName
=
catalogueSortValueEnum
.
getName
();
String
catalogueSortValueEnumI18nValue
=
catalogueSortValueEnum
.
getI18nValue
();
TreeVo
treeVo
=
TreeVo
.
builder
()
.
name
(
catalogueSortValueEnumI18nValue
)
.
value
(
catalogueSortValueEnumName
)
.
build
();
List
<
TreeVo
>
subTreeVoList
=
Arrays
.
stream
(
SortTypeEnum
.
values
())
.
map
(
sortTypeEnum
->
{
String
sortTypeEnumName
=
sortTypeEnum
.
getName
();
String
sortTypeEnumI18nValue
=
sortTypeEnum
.
getI18nValue
();
return
TreeVo
.
builder
()
.
name
(
catalogueSortValueEnumI18nValue
+
" "
+
sortTypeEnumI18nValue
)
.
value
(
catalogueSortValueEnumName
+
"_"
+
sortTypeEnumName
)
.
build
();
})
.
collect
(
Collectors
.
toList
());
treeVo
.
setChildren
(
subTreeVoList
);
treeVoList
.
add
(
treeVo
);
}
return
treeVoList
;
}
@Override
@Override
public
Catalogue
findByParentIdAndName
(
Integer
parentId
,
String
name
)
{
public
Catalogue
findByParentIdAndName
(
Integer
parentId
,
String
name
)
{
return
baseMapper
.
selectOne
(
new
LambdaQueryWrapper
<
Catalogue
>()
return
baseMapper
.
selectOne
(
new
LambdaQueryWrapper
<
Catalogue
>()
...
...
dinky-admin/src/main/java/org/dinky/service/catalogue/strategy/CatalogueTreeSortStrategy.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
service
.
catalogue
.
strategy
;
import
org.dinky.data.enums.SortTypeEnum
;
import
org.dinky.data.model.Catalogue
;
import
java.util.List
;
/**
* CatalogueTreeSortStrategy
*
* @since 2024/4/29 14:10
*/
public
interface
CatalogueTreeSortStrategy
{
/**
* Sort catalogue tree.
*
* @param catalogueTree Catalogue Tree.
* @param sortTypeEnum Sort type.
* @return A list of {@link Catalogue} Sorted catalogue tree.
*/
List
<
Catalogue
>
sort
(
List
<
Catalogue
>
catalogueTree
,
SortTypeEnum
sortTypeEnum
);
}
dinky-admin/src/main/java/org/dinky/service/catalogue/strategy/impl/CatalogueTreeSortCreateTimeStrategy.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
service
.
catalogue
.
strategy
.
impl
;
import
org.dinky.data.constant.CatalogueSortConstant
;
import
org.dinky.data.enums.SortTypeEnum
;
import
org.dinky.data.model.Catalogue
;
import
org.dinky.service.catalogue.strategy.CatalogueTreeSortStrategy
;
import
org.dinky.utils.Safes
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
org.springframework.stereotype.Component
;
import
cn.hutool.core.collection.CollectionUtil
;
import
lombok.extern.slf4j.Slf4j
;
/**
* CatalogueTreeSortCreateTimeStrategy
*
* @since 2024/4/29 14:13
*/
@Slf4j
@Component
(
CatalogueSortConstant
.
STRATEGY_CREATE_TIME
)
public
class
CatalogueTreeSortCreateTimeStrategy
implements
CatalogueTreeSortStrategy
{
/**
* Sort catalogue tree based on creation time.
*
* @param catalogueTree Catalogue Tree.
* @param sortTypeEnum Sort type.
* @return A list of {@link Catalogue} Sorted catalogue tree.
*/
@Override
public
List
<
Catalogue
>
sort
(
List
<
Catalogue
>
catalogueTree
,
SortTypeEnum
sortTypeEnum
)
{
log
.
info
(
"sort catalogue tree based on creation time. catalogueTree: {}, sortTypeEnum: {}"
,
catalogueTree
,
sortTypeEnum
);
return
recursionSortCatalogues
(
catalogueTree
,
sortTypeEnum
);
}
public
List
<
Catalogue
>
recursionSortCatalogues
(
List
<
Catalogue
>
catalogueTree
,
SortTypeEnum
sortTypeEnum
)
{
List
<
Catalogue
>
catalogueList
=
Safes
.
of
(
catalogueTree
).
stream
()
.
sorted
((
o1
,
o2
)
->
sortTypeEnum
.
compare
(
o1
.
getCreateTime
(),
o2
.
getCreateTime
()))
.
collect
(
Collectors
.
toList
());
for
(
Catalogue
catalogue
:
catalogueList
)
{
List
<
Catalogue
>
children
=
catalogue
.
getChildren
();
if
(
CollectionUtil
.
isEmpty
(
children
))
{
continue
;
}
List
<
Catalogue
>
sortedChildren
=
recursionSortCatalogues
(
children
,
sortTypeEnum
);
catalogue
.
setChildren
(
sortedChildren
);
}
return
catalogueList
;
}
}
dinky-admin/src/main/java/org/dinky/service/catalogue/strategy/impl/CatalogueTreeSortDefaultStrategy.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
service
.
catalogue
.
strategy
.
impl
;
import
org.dinky.data.constant.CatalogueSortConstant
;
import
org.dinky.data.enums.SortTypeEnum
;
import
org.dinky.data.model.Catalogue
;
import
org.dinky.service.catalogue.strategy.CatalogueTreeSortStrategy
;
import
org.dinky.utils.Safes
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
org.springframework.stereotype.Component
;
import
cn.hutool.core.collection.CollectionUtil
;
import
lombok.extern.slf4j.Slf4j
;
/**
* CatalogueTreeSortDefaultStrategy
*
* @since 2024/4/29 14:13
*/
@Slf4j
@Component
(
CatalogueSortConstant
.
STRATEGY_DEFAULT
)
public
class
CatalogueTreeSortDefaultStrategy
implements
CatalogueTreeSortStrategy
{
/**
* Sort catalogue tree based on id.
*
* @param catalogueTree Catalogue Tree.
* @param sortTypeEnum Sort type.
* @return A list of {@link Catalogue} Sorted catalogue tree.
*/
@Override
public
List
<
Catalogue
>
sort
(
List
<
Catalogue
>
catalogueTree
,
SortTypeEnum
sortTypeEnum
)
{
log
.
info
(
"sort catalogue tree based on id. catalogueTree: {}, sortTypeEnum: {}"
,
catalogueTree
,
sortTypeEnum
);
return
recursionSortCatalogues
(
catalogueTree
,
sortTypeEnum
);
}
public
List
<
Catalogue
>
recursionSortCatalogues
(
List
<
Catalogue
>
catalogueTree
,
SortTypeEnum
sortTypeEnum
)
{
List
<
Catalogue
>
catalogueList
=
Safes
.
of
(
catalogueTree
).
stream
()
.
sorted
((
o1
,
o2
)
->
sortTypeEnum
.
compare
(
o1
.
getId
(),
o2
.
getId
()))
.
collect
(
Collectors
.
toList
());
for
(
Catalogue
catalogue
:
catalogueList
)
{
List
<
Catalogue
>
children
=
catalogue
.
getChildren
();
if
(
CollectionUtil
.
isEmpty
(
children
))
{
continue
;
}
List
<
Catalogue
>
sortedChildren
=
recursionSortCatalogues
(
children
,
sortTypeEnum
);
catalogue
.
setChildren
(
sortedChildren
);
}
return
catalogueList
;
}
}
dinky-admin/src/main/java/org/dinky/service/catalogue/strategy/impl/CatalogueTreeSortFirstLetterStrategy.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
service
.
catalogue
.
strategy
.
impl
;
import
org.dinky.data.constant.CatalogueSortConstant
;
import
org.dinky.data.enums.SortTypeEnum
;
import
org.dinky.data.model.Catalogue
;
import
org.dinky.service.catalogue.strategy.CatalogueTreeSortStrategy
;
import
org.dinky.utils.Safes
;
import
java.text.Collator
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.stream.Collectors
;
import
org.springframework.stereotype.Component
;
import
cn.hutool.core.collection.CollectionUtil
;
import
lombok.extern.slf4j.Slf4j
;
/**
* CatalogueTreeSortFirstLetterStrategy
*
* @since 2024/4/29 14:13
*/
@Slf4j
@Component
(
CatalogueSortConstant
.
STRATEGY_FIRST_LETTER
)
public
class
CatalogueTreeSortFirstLetterStrategy
implements
CatalogueTreeSortStrategy
{
/**
* Sort catalogue tree based on first letter.
*
* @param catalogueTree Catalogue Tree.
* @param sortTypeEnum Sort type.
* @return A list of {@link Catalogue} Sorted catalogue tree.
*/
@Override
public
List
<
Catalogue
>
sort
(
List
<
Catalogue
>
catalogueTree
,
SortTypeEnum
sortTypeEnum
)
{
log
.
info
(
"sort catalogue tree based on first letter. catalogueTree: {}, sortTypeEnum: {}"
,
catalogueTree
,
sortTypeEnum
);
Collator
collator
=
Collator
.
getInstance
(
Locale
.
CHINA
);
return
recursionSortCatalogues
(
catalogueTree
,
sortTypeEnum
,
collator
);
}
public
List
<
Catalogue
>
recursionSortCatalogues
(
List
<
Catalogue
>
catalogueTree
,
SortTypeEnum
sortTypeEnum
,
Collator
collator
)
{
List
<
Catalogue
>
catalogueList
=
Safes
.
of
(
catalogueTree
).
stream
()
.
sorted
((
o1
,
o2
)
->
sortTypeEnum
.
compare
(
o1
.
getName
(),
o2
.
getName
(),
collator
))
.
collect
(
Collectors
.
toList
());
for
(
Catalogue
catalogue
:
catalogueList
)
{
List
<
Catalogue
>
children
=
catalogue
.
getChildren
();
if
(
CollectionUtil
.
isEmpty
(
children
))
{
continue
;
}
List
<
Catalogue
>
sortedChildren
=
recursionSortCatalogues
(
children
,
sortTypeEnum
,
collator
);
catalogue
.
setChildren
(
sortedChildren
);
}
return
catalogueList
;
}
}
dinky-admin/src/main/java/org/dinky/service/impl/SchedulerServiceImpl.java
View file @
3c07d9ba
...
@@ -39,8 +39,8 @@ import org.dinky.scheduler.model.TaskDefinition;
...
@@ -39,8 +39,8 @@ import org.dinky.scheduler.model.TaskDefinition;
import
org.dinky.scheduler.model.TaskGroup
;
import
org.dinky.scheduler.model.TaskGroup
;
import
org.dinky.scheduler.model.TaskMainInfo
;
import
org.dinky.scheduler.model.TaskMainInfo
;
import
org.dinky.scheduler.model.TaskRequest
;
import
org.dinky.scheduler.model.TaskRequest
;
import
org.dinky.service.CatalogueService
;
import
org.dinky.service.SchedulerService
;
import
org.dinky.service.SchedulerService
;
import
org.dinky.service.catalogue.CatalogueService
;
import
org.dinky.utils.JsonUtils
;
import
org.dinky.utils.JsonUtils
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
...
dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java
View file @
3c07d9ba
...
@@ -74,7 +74,6 @@ import org.dinky.job.JobResult;
...
@@ -74,7 +74,6 @@ import org.dinky.job.JobResult;
import
org.dinky.mapper.TaskMapper
;
import
org.dinky.mapper.TaskMapper
;
import
org.dinky.mybatis.service.impl.SuperServiceImpl
;
import
org.dinky.mybatis.service.impl.SuperServiceImpl
;
import
org.dinky.service.AlertGroupService
;
import
org.dinky.service.AlertGroupService
;
import
org.dinky.service.CatalogueService
;
import
org.dinky.service.ClusterConfigurationService
;
import
org.dinky.service.ClusterConfigurationService
;
import
org.dinky.service.ClusterInstanceService
;
import
org.dinky.service.ClusterInstanceService
;
import
org.dinky.service.DataBaseService
;
import
org.dinky.service.DataBaseService
;
...
@@ -85,6 +84,7 @@ import org.dinky.service.TaskService;
...
@@ -85,6 +84,7 @@ import org.dinky.service.TaskService;
import
org.dinky.service.TaskVersionService
;
import
org.dinky.service.TaskVersionService
;
import
org.dinky.service.UDFTemplateService
;
import
org.dinky.service.UDFTemplateService
;
import
org.dinky.service.UserService
;
import
org.dinky.service.UserService
;
import
org.dinky.service.catalogue.CatalogueService
;
import
org.dinky.service.task.BaseTask
;
import
org.dinky.service.task.BaseTask
;
import
org.dinky.utils.FragmentVariableUtils
;
import
org.dinky.utils.FragmentVariableUtils
;
import
org.dinky.utils.JsonUtils
;
import
org.dinky.utils.JsonUtils
;
...
...
dinky-admin/src/main/java/org/dinky/utils/Safes.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
utils
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
/**
* Safes Tool
*
* @since 2024/4/29 14:21
*/
public
class
Safes
{
public
static
<
K
,
V
>
Map
<
K
,
V
>
of
(
Map
<
K
,
V
>
map
)
{
return
Optional
.
ofNullable
(
map
).
orElse
(
Maps
.
newHashMap
());
}
public
static
<
T
>
List
<
T
>
of
(
List
<
T
>
list
)
{
return
Optional
.
ofNullable
(
list
).
orElse
(
Lists
.
newArrayList
());
}
}
dinky-admin/src/test/java/org/dinky/service/catalogue/factory/CatalogueTreeSortFactoryTest.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
service
.
catalogue
.
factory
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyString
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
org.dinky.service.catalogue.strategy.CatalogueTreeSortStrategy
;
import
org.dinky.service.catalogue.strategy.impl.CatalogueTreeSortCreateTimeStrategy
;
import
org.dinky.service.catalogue.strategy.impl.CatalogueTreeSortDefaultStrategy
;
import
org.dinky.service.catalogue.strategy.impl.CatalogueTreeSortFirstLetterStrategy
;
import
java.util.Map
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
org.powermock.core.classloader.annotations.PowerMockIgnore
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
com.google.common.collect.ImmutableMap
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
@RunWith
(
PowerMockRunner
.
class
)
@PowerMockIgnore
({
"com.sun.org.apache.xerces.*"
,
"javax.xml.*"
,
"org.xml.*"
,
"javax.management.*"
,
"org.w3c.*"
})
public
class
CatalogueTreeSortFactoryTest
{
@Mock
private
Map
<
String
,
CatalogueTreeSortStrategy
>
catalogueTreeSortStrategyMap
;
@InjectMocks
private
CatalogueTreeSortFactory
catalogueTreeSortFactoryTest
;
/** mock strategy */
CatalogueTreeSortDefaultStrategy
defaultStrategy
=
new
CatalogueTreeSortDefaultStrategy
();
CatalogueTreeSortCreateTimeStrategy
catalogueTreeSortCreateTimeStrategy
=
new
CatalogueTreeSortCreateTimeStrategy
();
CatalogueTreeSortFirstLetterStrategy
catalogueTreeSortFirstLetterStrategy
=
new
CatalogueTreeSortFirstLetterStrategy
();
Map
<
String
,
CatalogueTreeSortStrategy
>
mockCatalogueTreeSortStrategyMap
=
ImmutableMap
.
of
(
"default"
,
defaultStrategy
,
"create_time"
,
catalogueTreeSortCreateTimeStrategy
,
"first_letter"
,
catalogueTreeSortFirstLetterStrategy
);
@Test
public
void
getStrategyTest
()
{
when
(
catalogueTreeSortStrategyMap
.
get
(
anyString
())).
thenAnswer
(
invocationOnMock
->
{
String
strategy
=
invocationOnMock
.
getArgument
(
0
);
return
mockCatalogueTreeSortStrategyMap
.
get
(
strategy
);
});
CatalogueTreeSortStrategy
strategy
=
catalogueTreeSortFactoryTest
.
getStrategy
(
"create_time"
);
assertEquals
(
catalogueTreeSortCreateTimeStrategy
,
strategy
);
}
@Test
public
void
getStrategyTest2
()
{
when
(
catalogueTreeSortStrategyMap
.
get
(
anyString
())).
thenAnswer
(
invocationOnMock
->
{
String
strategy
=
invocationOnMock
.
getArgument
(
0
);
return
mockCatalogueTreeSortStrategyMap
.
get
(
strategy
);
});
CatalogueTreeSortStrategy
strategy
=
catalogueTreeSortFactoryTest
.
getStrategy
(
"first_letter"
);
assertEquals
(
catalogueTreeSortFirstLetterStrategy
,
strategy
);
}
@Test
public
void
getStrategyIllegalTest
()
{
when
(
catalogueTreeSortStrategyMap
.
get
(
anyString
())).
thenAnswer
(
invocationOnMock
->
{
String
strategy
=
invocationOnMock
.
getArgument
(
0
);
return
mockCatalogueTreeSortStrategyMap
.
get
(
strategy
);
});
CatalogueTreeSortStrategy
strategy
=
catalogueTreeSortFactoryTest
.
getStrategy
(
"xxx"
);
assertEquals
(
defaultStrategy
,
strategy
);
}
@Test
public
void
getStrategyIllegalTest2
()
{
when
(
catalogueTreeSortStrategyMap
.
get
(
anyString
())).
thenAnswer
(
invocationOnMock
->
{
String
strategy
=
invocationOnMock
.
getArgument
(
0
);
return
mockCatalogueTreeSortStrategyMap
.
get
(
strategy
);
});
CatalogueTreeSortStrategy
strategy
=
catalogueTreeSortFactoryTest
.
getStrategy
(
null
);
assertEquals
(
defaultStrategy
,
strategy
);
}
}
dinky-admin/src/test/java/org/dinky/service/catalogue/strategy/impl/CatalogueTreeSortCreateTimeStrategyTest.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
service
.
catalogue
.
strategy
.
impl
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
org.dinky.data.enums.SortTypeEnum
;
import
org.dinky.data.model.Catalogue
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.powermock.core.classloader.annotations.PowerMockIgnore
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
@RunWith
(
PowerMockRunner
.
class
)
@PowerMockIgnore
({
"com.sun.org.apache.xerces.*"
,
"javax.xml.*"
,
"org.xml.*"
,
"javax.management.*"
,
"org.w3c.*"
})
public
class
CatalogueTreeSortCreateTimeStrategyTest
{
@InjectMocks
private
CatalogueTreeSortCreateTimeStrategy
catalogueTreeSortCreateTimeStrategyTest
;
@Test
public
void
sortAscTest
()
{
SortTypeEnum
sortTypeEnum
=
SortTypeEnum
.
ASC
;
List
<
Catalogue
>
catalogueTree
=
Lists
.
newArrayList
();
Catalogue
catalogue
=
new
Catalogue
();
catalogue
.
setId
(
1
);
catalogue
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
28
,
19
,
22
,
0
));
Catalogue
catalogue11
=
new
Catalogue
();
catalogue11
.
setId
(
2
);
catalogue11
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
28
,
20
,
22
,
0
));
Catalogue
catalogue12
=
new
Catalogue
();
catalogue12
.
setId
(
3
);
catalogue12
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
28
,
21
,
22
,
0
));
catalogue
.
setChildren
(
Lists
.
newArrayList
(
catalogue12
,
catalogue11
));
Catalogue
catalogue2
=
new
Catalogue
();
catalogue2
.
setId
(
4
);
catalogue2
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
29
,
19
,
22
,
0
));
Catalogue
catalogue21
=
new
Catalogue
();
catalogue21
.
setId
(
7
);
catalogue21
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
29
,
21
,
22
,
0
));
Catalogue
catalogue22
=
new
Catalogue
();
catalogue22
.
setId
(
6
);
catalogue22
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
29
,
20
,
22
,
0
));
catalogue2
.
setChildren
(
Lists
.
newArrayList
(
catalogue21
,
catalogue22
));
catalogueTree
.
add
(
catalogue2
);
catalogueTree
.
add
(
catalogue
);
/*
input:
-- 4 (2024-04-29 19:22:00)
-- 7 (2024-04-29 21:22:00)
-- 6 (2024-04-29 20:22:00)
-- 1 (2024-04-28 19:22:00)
-- 3 (2024-04-28 21:22:00)
-- 2 (2024-04-28 20:22:00)
output:
-- 1 (2024-04-28 19:22:00)
-- 2 (2024-04-28 20:22:00)
-- 3 (2024-04-28 21:22:00)
-- 4 (2024-04-29 19:22:00)
-- 6 (2024-04-29 20:22:00)
-- 7 (2024-04-29 21:22:00)
*/
List
<
Catalogue
>
resultList
=
catalogueTreeSortCreateTimeStrategyTest
.
sort
(
catalogueTree
,
sortTypeEnum
);
List
<
Integer
>
resultIdList
=
CategoryTreeSortStrategyTestUtils
.
breadthTraverse
(
resultList
);
assertEquals
(
Lists
.
newArrayList
(
1
,
4
,
2
,
3
,
6
,
7
),
resultIdList
);
}
@Test
public
void
sortDescTest
()
{
SortTypeEnum
sortTypeEnum
=
SortTypeEnum
.
DESC
;
List
<
Catalogue
>
catalogueTree
=
Lists
.
newArrayList
();
Catalogue
catalogue
=
new
Catalogue
();
catalogue
.
setId
(
1
);
catalogue
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
28
,
19
,
22
,
0
));
Catalogue
catalogue11
=
new
Catalogue
();
catalogue11
.
setId
(
2
);
catalogue11
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
28
,
20
,
22
,
0
));
Catalogue
catalogue12
=
new
Catalogue
();
catalogue12
.
setId
(
3
);
catalogue12
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
28
,
21
,
22
,
0
));
catalogue
.
setChildren
(
Lists
.
newArrayList
(
catalogue12
,
catalogue11
));
Catalogue
catalogue2
=
new
Catalogue
();
catalogue2
.
setId
(
4
);
catalogue2
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
29
,
19
,
22
,
0
));
Catalogue
catalogue21
=
new
Catalogue
();
catalogue21
.
setId
(
7
);
catalogue21
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
29
,
21
,
22
,
0
));
Catalogue
catalogue22
=
new
Catalogue
();
catalogue22
.
setId
(
6
);
catalogue22
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
29
,
20
,
22
,
0
));
catalogue2
.
setChildren
(
Lists
.
newArrayList
(
catalogue21
,
catalogue22
));
catalogueTree
.
add
(
catalogue2
);
catalogueTree
.
add
(
catalogue
);
/*
input:
-- 4 (2024-04-29 19:22:00)
-- 7 (2024-04-29 21:22:00)
-- 6 (2024-04-29 20:22:00)
-- 1 (2024-04-28 19:22:00)
-- 3 (2024-04-28 21:22:00)
-- 2 (2024-04-28 20:22:00)
output:
-- 4 (2024-04-29 19:22:00)
-- 7 (2024-04-29 21:22:00)
-- 6 (2024-04-29 20:22:00)
-- 1 (2024-04-28 19:22:00)
-- 3 (2024-04-28 21:22:00)
-- 2 (2024-04-28 20:22:00)
*/
List
<
Catalogue
>
resultList
=
catalogueTreeSortCreateTimeStrategyTest
.
sort
(
catalogueTree
,
sortTypeEnum
);
List
<
Integer
>
resultIdList
=
CategoryTreeSortStrategyTestUtils
.
breadthTraverse
(
resultList
);
assertEquals
(
Lists
.
newArrayList
(
4
,
1
,
7
,
6
,
3
,
2
),
resultIdList
);
}
@Test
public
void
sortEmptyTest
()
{
List
<
Catalogue
>
catalogueTree
=
Lists
.
newArrayList
();
SortTypeEnum
sortTypeEnum
=
SortTypeEnum
.
ASC
;
List
<
Catalogue
>
resultList
=
catalogueTreeSortCreateTimeStrategyTest
.
sort
(
catalogueTree
,
sortTypeEnum
);
assertEquals
(
Lists
.
newArrayList
(),
resultList
);
}
@Test
public
void
sortEmptyTest2
()
{
List
<
Catalogue
>
catalogueTree
=
null
;
SortTypeEnum
sortTypeEnum
=
SortTypeEnum
.
ASC
;
List
<
Catalogue
>
resultList
=
catalogueTreeSortCreateTimeStrategyTest
.
sort
(
catalogueTree
,
sortTypeEnum
);
assertEquals
(
Lists
.
newArrayList
(),
resultList
);
}
}
dinky-admin/src/test/java/org/dinky/service/catalogue/strategy/impl/CatalogueTreeSortDefaultStrategyTest.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
service
.
catalogue
.
strategy
.
impl
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
org.dinky.data.enums.SortTypeEnum
;
import
org.dinky.data.model.Catalogue
;
import
java.util.List
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.powermock.core.classloader.annotations.PowerMockIgnore
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
@RunWith
(
PowerMockRunner
.
class
)
@PowerMockIgnore
({
"com.sun.org.apache.xerces.*"
,
"javax.xml.*"
,
"org.xml.*"
,
"javax.management.*"
,
"org.w3c.*"
})
public
class
CatalogueTreeSortDefaultStrategyTest
{
@InjectMocks
private
CatalogueTreeSortDefaultStrategy
catalogueTreeSortDefaultStrategyTest
;
@Test
public
void
sortAscTest
()
{
SortTypeEnum
sortTypeEnum
=
SortTypeEnum
.
ASC
;
List
<
Catalogue
>
catalogueTree
=
Lists
.
newArrayList
();
Catalogue
catalogue
=
new
Catalogue
();
catalogue
.
setId
(
1
);
Catalogue
catalogue11
=
new
Catalogue
();
catalogue11
.
setId
(
2
);
Catalogue
catalogue12
=
new
Catalogue
();
catalogue12
.
setId
(
3
);
catalogue
.
setChildren
(
Lists
.
newArrayList
(
catalogue12
,
catalogue11
));
Catalogue
catalogue2
=
new
Catalogue
();
catalogue2
.
setId
(
4
);
Catalogue
catalogue21
=
new
Catalogue
();
catalogue21
.
setId
(
7
);
Catalogue
catalogue22
=
new
Catalogue
();
catalogue22
.
setId
(
6
);
catalogue2
.
setChildren
(
Lists
.
newArrayList
(
catalogue21
,
catalogue22
));
catalogueTree
.
add
(
catalogue2
);
catalogueTree
.
add
(
catalogue
);
/*
input:
-- 4
-- 7
-- 6
-- 1
-- 3
-- 2
output:
-- 1
-- 2
-- 3
-- 4
-- 6
-- 7
*/
List
<
Catalogue
>
resultList
=
catalogueTreeSortDefaultStrategyTest
.
sort
(
catalogueTree
,
sortTypeEnum
);
List
<
Integer
>
resultIdList
=
CategoryTreeSortStrategyTestUtils
.
breadthTraverse
(
resultList
);
assertEquals
(
Lists
.
newArrayList
(
1
,
4
,
2
,
3
,
6
,
7
),
resultIdList
);
}
@Test
public
void
sortDescTest
()
{
SortTypeEnum
sortTypeEnum
=
SortTypeEnum
.
DESC
;
List
<
Catalogue
>
catalogueTree
=
Lists
.
newArrayList
();
Catalogue
catalogue
=
new
Catalogue
();
catalogue
.
setId
(
1
);
Catalogue
catalogue11
=
new
Catalogue
();
catalogue11
.
setId
(
2
);
Catalogue
catalogue12
=
new
Catalogue
();
catalogue12
.
setId
(
3
);
catalogue
.
setChildren
(
Lists
.
newArrayList
(
catalogue12
,
catalogue11
));
Catalogue
catalogue2
=
new
Catalogue
();
catalogue2
.
setId
(
4
);
Catalogue
catalogue21
=
new
Catalogue
();
catalogue21
.
setId
(
7
);
Catalogue
catalogue22
=
new
Catalogue
();
catalogue22
.
setId
(
6
);
catalogue2
.
setChildren
(
Lists
.
newArrayList
(
catalogue21
,
catalogue22
));
catalogueTree
.
add
(
catalogue2
);
catalogueTree
.
add
(
catalogue
);
/*
input:
-- 4
-- 7
-- 6
-- 1
-- 3
-- 2
output:
-- 4
-- 7
-- 6
-- 1
-- 3
-- 2
*/
List
<
Catalogue
>
resultList
=
catalogueTreeSortDefaultStrategyTest
.
sort
(
catalogueTree
,
sortTypeEnum
);
List
<
Integer
>
resultIdList
=
CategoryTreeSortStrategyTestUtils
.
breadthTraverse
(
resultList
);
assertEquals
(
Lists
.
newArrayList
(
4
,
1
,
7
,
6
,
3
,
2
),
resultIdList
);
}
@Test
public
void
sortEmptyTest
()
{
List
<
Catalogue
>
catalogueTree
=
Lists
.
newArrayList
();
SortTypeEnum
sortTypeEnum
=
SortTypeEnum
.
ASC
;
List
<
Catalogue
>
resultList
=
catalogueTreeSortDefaultStrategyTest
.
sort
(
catalogueTree
,
sortTypeEnum
);
assertEquals
(
Lists
.
newArrayList
(),
resultList
);
}
@Test
public
void
sortEmptyTest2
()
{
List
<
Catalogue
>
catalogueTree
=
null
;
SortTypeEnum
sortTypeEnum
=
SortTypeEnum
.
ASC
;
List
<
Catalogue
>
resultList
=
catalogueTreeSortDefaultStrategyTest
.
sort
(
catalogueTree
,
sortTypeEnum
);
assertEquals
(
Lists
.
newArrayList
(),
resultList
);
}
}
dinky-admin/src/test/java/org/dinky/service/catalogue/strategy/impl/CatalogueTreeSortFirstLetterStrategyTest.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
service
.
catalogue
.
strategy
.
impl
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
org.dinky.data.enums.SortTypeEnum
;
import
org.dinky.data.model.Catalogue
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.powermock.core.classloader.annotations.PowerMockIgnore
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
@RunWith
(
PowerMockRunner
.
class
)
@PowerMockIgnore
({
"com.sun.org.apache.xerces.*"
,
"javax.xml.*"
,
"org.xml.*"
,
"javax.management.*"
,
"org.w3c.*"
})
public
class
CatalogueTreeSortFirstLetterStrategyTest
{
@InjectMocks
private
CatalogueTreeSortFirstLetterStrategy
catalogueTreeSortFirstLetterStrategyTest
;
@Test
public
void
sortAscTest
()
{
SortTypeEnum
sortTypeEnum
=
SortTypeEnum
.
ASC
;
List
<
Catalogue
>
catalogueTree
=
Lists
.
newArrayList
();
Catalogue
catalogue
=
new
Catalogue
();
catalogue
.
setId
(
1
);
catalogue
.
setName
(
"测试目录"
);
catalogue
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
28
,
19
,
22
,
0
));
Catalogue
catalogue11
=
new
Catalogue
();
catalogue11
.
setId
(
2
);
catalogue11
.
setName
(
"bbb"
);
catalogue11
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
28
,
20
,
22
,
0
));
Catalogue
catalogue12
=
new
Catalogue
();
catalogue12
.
setId
(
3
);
catalogue12
.
setName
(
"aaa"
);
catalogue12
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
28
,
21
,
22
,
0
));
catalogue
.
setChildren
(
Lists
.
newArrayList
(
catalogue12
,
catalogue11
));
Catalogue
catalogue2
=
new
Catalogue
();
catalogue2
.
setId
(
4
);
catalogue2
.
setName
(
"test"
);
catalogue2
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
29
,
19
,
22
,
0
));
Catalogue
catalogue21
=
new
Catalogue
();
catalogue21
.
setId
(
7
);
catalogue21
.
setName
(
"测试目录2"
);
catalogue21
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
29
,
21
,
22
,
0
));
Catalogue
catalogue22
=
new
Catalogue
();
catalogue22
.
setId
(
6
);
catalogue22
.
setName
(
"生产任务"
);
catalogue22
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
29
,
20
,
22
,
0
));
catalogue2
.
setChildren
(
Lists
.
newArrayList
(
catalogue21
,
catalogue22
));
catalogueTree
.
add
(
catalogue2
);
catalogueTree
.
add
(
catalogue
);
/*
input:
-- 4 (2024-04-29 19:22:00) (test)
-- 7 (2024-04-29 21:22:00) (测试目录2)
-- 6 (2024-04-29 20:22:00) (生产任务)
-- 1 (2024-04-28 19:22:00) (测试目录)
-- 3 (2024-04-28 21:22:00) (aaa)
-- 2 (2024-04-28 20:22:00) (bbb)
output:
-- 4 (2024-04-29 19:22:00) (test)
-- 7 (2024-04-29 21:22:00) (测试目录2)
-- 6 (2024-04-29 20:22:00) (生产任务)
-- 1 (2024-04-28 19:22:00) (测试目录)
-- 3 (2024-04-28 21:22:00) (aaa)
-- 2 (2024-04-28 20:22:00) (bbb)
*/
List
<
Catalogue
>
resultList
=
catalogueTreeSortFirstLetterStrategyTest
.
sort
(
catalogueTree
,
sortTypeEnum
);
List
<
Integer
>
resultIdList
=
CategoryTreeSortStrategyTestUtils
.
breadthTraverse
(
resultList
);
assertEquals
(
Lists
.
newArrayList
(
4
,
1
,
7
,
6
,
3
,
2
),
resultIdList
);
}
@Test
public
void
sortDescTest
()
{
SortTypeEnum
sortTypeEnum
=
SortTypeEnum
.
DESC
;
List
<
Catalogue
>
catalogueTree
=
Lists
.
newArrayList
();
Catalogue
catalogue
=
new
Catalogue
();
catalogue
.
setId
(
1
);
catalogue
.
setName
(
"测试目录"
);
catalogue
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
28
,
19
,
22
,
0
));
Catalogue
catalogue11
=
new
Catalogue
();
catalogue11
.
setId
(
2
);
catalogue11
.
setName
(
"bbb"
);
catalogue11
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
28
,
20
,
22
,
0
));
Catalogue
catalogue12
=
new
Catalogue
();
catalogue12
.
setId
(
3
);
catalogue12
.
setName
(
"aaa"
);
catalogue12
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
28
,
21
,
22
,
0
));
catalogue
.
setChildren
(
Lists
.
newArrayList
(
catalogue12
,
catalogue11
));
Catalogue
catalogue2
=
new
Catalogue
();
catalogue2
.
setId
(
4
);
catalogue2
.
setName
(
"test"
);
catalogue2
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
29
,
19
,
22
,
0
));
Catalogue
catalogue21
=
new
Catalogue
();
catalogue21
.
setId
(
7
);
catalogue21
.
setName
(
"测试目录2"
);
catalogue21
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
29
,
21
,
22
,
0
));
Catalogue
catalogue22
=
new
Catalogue
();
catalogue22
.
setId
(
6
);
catalogue22
.
setName
(
"生产任务"
);
catalogue22
.
setCreateTime
(
LocalDateTime
.
of
(
2024
,
4
,
29
,
20
,
22
,
0
));
catalogue2
.
setChildren
(
Lists
.
newArrayList
(
catalogue21
,
catalogue22
));
catalogueTree
.
add
(
catalogue2
);
catalogueTree
.
add
(
catalogue
);
/*
input:
-- 4 (2024-04-29 19:22:00) (test)
-- 7 (2024-04-29 21:22:00) (测试目录2)
-- 6 (2024-04-29 20:22:00) (生产任务)
-- 1 (2024-04-28 19:22:00) (测试目录)
-- 3 (2024-04-28 21:22:00) (aaa)
-- 2 (2024-04-28 20:22:00) (bbb)
output:
-- 1 (2024-04-28 19:22:00) (测试目录)
-- 2 (2024-04-28 20:22:00) (bbb)
-- 3 (2024-04-28 21:22:00) (aaa)
-- 4 (2024-04-29 19:22:00) (test)
-- 6 (2024-04-29 20:22:00) (生产任务)
-- 7 (2024-04-29 21:22:00) (测试目录2)
*/
List
<
Catalogue
>
resultList
=
catalogueTreeSortFirstLetterStrategyTest
.
sort
(
catalogueTree
,
sortTypeEnum
);
List
<
Integer
>
resultIdList
=
CategoryTreeSortStrategyTestUtils
.
breadthTraverse
(
resultList
);
assertEquals
(
Lists
.
newArrayList
(
1
,
4
,
2
,
3
,
6
,
7
),
resultIdList
);
}
@Test
public
void
sortEmptyTest
()
{
List
<
Catalogue
>
catalogueTree
=
Lists
.
newArrayList
();
SortTypeEnum
sortTypeEnum
=
SortTypeEnum
.
ASC
;
List
<
Catalogue
>
resultList
=
catalogueTreeSortFirstLetterStrategyTest
.
sort
(
catalogueTree
,
sortTypeEnum
);
assertEquals
(
Lists
.
newArrayList
(),
resultList
);
}
@Test
public
void
sortEmptyTest2
()
{
List
<
Catalogue
>
catalogueTree
=
null
;
SortTypeEnum
sortTypeEnum
=
SortTypeEnum
.
ASC
;
List
<
Catalogue
>
resultList
=
catalogueTreeSortFirstLetterStrategyTest
.
sort
(
catalogueTree
,
sortTypeEnum
);
assertEquals
(
Lists
.
newArrayList
(),
resultList
);
}
}
dinky-admin/src/test/java/org/dinky/service/catalogue/strategy/impl/CategoryTreeSortStrategyTestUtils.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
service
.
catalogue
.
strategy
.
impl
;
import
org.dinky.data.model.Catalogue
;
import
org.dinky.utils.Safes
;
import
java.util.List
;
import
com.google.common.collect.Lists
;
import
cn.hutool.core.collection.CollectionUtil
;
public
class
CategoryTreeSortStrategyTestUtils
{
public
static
List
<
Integer
>
breadthTraverse
(
List
<
Catalogue
>
catalogueTree
)
{
List
<
Integer
>
resultList
=
Lists
.
newArrayList
();
for
(
Catalogue
catalogue
:
Safes
.
of
(
catalogueTree
))
{
resultList
.
add
(
catalogue
.
getId
());
}
for
(
Catalogue
catalogue
:
Safes
.
of
(
catalogueTree
))
{
List
<
Catalogue
>
children
=
catalogue
.
getChildren
();
if
(
CollectionUtil
.
isEmpty
(
children
))
{
continue
;
}
resultList
.
addAll
(
breadthTraverse
(
children
));
}
return
resultList
;
}
}
dinky-common/src/main/java/org/dinky/data/constant/CatalogueSortConstant.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
data
.
constant
;
/**
* CatalogueSortConstant
*
* @since 2024/4/29 14:15
*/
public
class
CatalogueSortConstant
{
public
static
final
String
STRATEGY_FIRST_LETTER
=
"first_letter"
;
public
static
final
String
STRATEGY_CREATE_TIME
=
"create_time"
;
public
static
final
String
STRATEGY_DEFAULT
=
"default"
;
}
dinky-common/src/main/java/org/dinky/data/enums/CatalogueSortValueEnum.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
data
.
enums
;
import
org.dinky.data.constant.CatalogueSortConstant
;
import
org.dinky.utils.I18n
;
/**
* CatalogueSortValue
*
* @since 2024/4/25
*/
public
enum
CatalogueSortValueEnum
{
/**
* CatalogueSortType
*/
FIRST_LETTER
(
CatalogueSortConstant
.
STRATEGY_FIRST_LETTER
,
"catalogue.sort.value.first_letter"
),
CREATE_TIME
(
CatalogueSortConstant
.
STRATEGY_CREATE_TIME
,
"catalogue.sort.value.create_time"
);
private
final
String
name
;
private
final
String
value
;
CatalogueSortValueEnum
(
String
name
,
String
value
)
{
this
.
name
=
name
;
this
.
value
=
value
;
}
public
String
getName
()
{
return
name
;
}
public
String
getValue
()
{
return
value
;
}
public
String
getI18nValue
()
{
return
I18n
.
getMessage
(
this
.
getValue
());
}
}
dinky-common/src/main/java/org/dinky/data/enums/SortTypeEnum.java
0 → 100644
View file @
3c07d9ba
/*
*
* 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
org
.
dinky
.
data
.
enums
;
import
org.dinky.utils.I18n
;
import
org.apache.commons.codec.binary.StringUtils
;
import
java.util.Arrays
;
import
java.util.Comparator
;
import
cn.hutool.core.util.ObjectUtil
;
/**
* SortType
*
* @since 2024/4/25
*/
public
enum
SortTypeEnum
{
/**
* SortType
*/
ASC
(
"asc"
,
"sort.type.asc"
)
{
@Override
public
<
T
extends
Comparable
<
T
>>
Integer
compare
(
T
a
,
T
b
)
{
return
ObjectUtil
.
compare
(
a
,
b
);
}
@Override
public
<
T
extends
Comparable
<
T
>>
Integer
compare
(
T
a
,
T
b
,
Comparator
<
Object
>
comparator
)
{
return
compareByComparator
(
a
,
b
,
comparator
);
}
},
DESC
(
"desc"
,
"sort.type.desc"
)
{
@Override
public
<
T
extends
Comparable
<
T
>>
Integer
compare
(
T
a
,
T
b
)
{
return
-
ObjectUtil
.
compare
(
a
,
b
);
}
@Override
public
<
T
extends
Comparable
<
T
>>
Integer
compare
(
T
a
,
T
b
,
Comparator
<
Object
>
comparator
)
{
return
-
compareByComparator
(
a
,
b
,
comparator
);
}
};
private
final
String
name
;
private
final
String
value
;
SortTypeEnum
(
String
name
,
String
value
)
{
this
.
name
=
name
;
this
.
value
=
value
;
}
public
String
getName
()
{
return
name
;
}
public
String
getValue
()
{
return
value
;
}
public
String
getI18nValue
()
{
return
I18n
.
getMessage
(
this
.
getValue
());
}
public
abstract
<
T
extends
Comparable
<
T
>>
Integer
compare
(
T
a
,
T
b
);
public
abstract
<
T
extends
Comparable
<
T
>>
Integer
compare
(
T
a
,
T
b
,
Comparator
<
Object
>
comparator
);
public
static
SortTypeEnum
getByName
(
String
name
)
{
return
Arrays
.
stream
(
SortTypeEnum
.
values
())
.
filter
(
sortTypeEnum
->
StringUtils
.
equals
(
sortTypeEnum
.
getName
(),
name
))
.
findFirst
()
.
orElse
(
ASC
);
}
private
static
<
T
extends
Comparable
<
T
>>
Integer
compareByComparator
(
T
a
,
T
b
,
Comparator
<
Object
>
comparator
)
{
if
(
a
==
b
)
{
return
0
;
}
else
if
(
a
==
null
)
{
return
-
1
;
}
else
if
(
b
==
null
)
{
return
1
;
}
else
{
return
comparator
.
compare
(
a
,
b
);
}
}
}
dinky-common/src/main/resources/i18n/messages_en_US.properties
View file @
3c07d9ba
...
@@ -165,6 +165,12 @@ file.rename.failed=File rename failed, reason: {0}
...
@@ -165,6 +165,12 @@ file.rename.failed=File rename failed, reason: {0}
file.delete.failed
=
File delete failed, reason: {0}
file.delete.failed
=
File delete failed, reason: {0}
file.read.failed
=
File read failed, reason: {0}
file.read.failed
=
File read failed, reason: {0}
catalogue.sort.value.first_letter
=
First Letter
catalogue.sort.value.create_time
=
Create Time
sort.type.asc
=
Asc
sort.type.desc
=
Desc
# dinky-alert
# dinky-alert
alert.rule.jobFail
=
Job Failure
alert.rule.jobFail
=
Job Failure
alert.rule.getJobInfoFail
=
Get Job Info Fail
alert.rule.getJobInfoFail
=
Get Job Info Fail
...
...
dinky-common/src/main/resources/i18n/messages_zh_CN.properties
View file @
3c07d9ba
...
@@ -168,6 +168,12 @@ file.read.failed=文件读取失败, 原因: {0}
...
@@ -168,6 +168,12 @@ file.read.failed=文件读取失败, 原因: {0}
daemon.task.config.not.exist
=
线程任务配置不能为空
daemon.task.config.not.exist
=
线程任务配置不能为空
daemon.task.not.support
=
不支持线程任务类型:
daemon.task.not.support
=
不支持线程任务类型:
catalogue.sort.value.first_letter
=
首字母
catalogue.sort.value.create_time
=
创建时间
sort.type.asc
=
升序
sort.type.desc
=
降序
# dinky-alert
# dinky-alert
alert.rule.jobFail
=
作业失败
alert.rule.jobFail
=
作业失败
alert.rule.getJobInfoFail
=
获取作业信息失败
alert.rule.getJobInfoFail
=
获取作业信息失败
...
...
dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx
View file @
3c07d9ba
...
@@ -98,7 +98,8 @@ const HeaderContainer = (props: connect) => {
...
@@ -98,7 +98,8 @@ const HeaderContainer = (props: connect) => {
updateSelectBottomKey
,
updateSelectBottomKey
,
queryDsConfig
,
queryDsConfig
,
queryTaskData
,
queryTaskData
,
enabledDs
enabledDs
,
selectCatalogueSortTypeData
:
{
data
:
selectCatalogueSortTypeData
}
}
=
props
;
}
=
props
;
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
();
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
();
...
@@ -313,7 +314,7 @@ const HeaderContainer = (props: connect) => {
...
@@ -313,7 +314,7 @@ const HeaderContainer = (props: connect) => {
}
}
}
}
saveTabs
({
...
props
.
tabs
});
saveTabs
({
...
props
.
tabs
});
await
queryTaskData
();
await
queryTaskData
(
{
payload
:
selectCatalogueSortTypeData
}
);
};
};
const
showDagGraph
=
async
()
=>
{
const
showDagGraph
=
async
()
=>
{
...
@@ -565,7 +566,8 @@ export default connect(
...
@@ -565,7 +566,8 @@ export default connect(
({ Studio, SysConfig }: { Studio: StateType; SysConfig: SysConfigStateType }) => ({
({ Studio, SysConfig }: { Studio: StateType; SysConfig: SysConfigStateType }) => ({
tabs: Studio.tabs,
tabs: Studio.tabs,
dsConfig: SysConfig.dsConfig,
dsConfig: SysConfig.dsConfig,
enabledDs: SysConfig.enabledDs
enabledDs: SysConfig.enabledDs,
selectCatalogueSortTypeData: Studio.selectCatalogueSortTypeData
}),
}),
mapDispatchToProps
mapDispatchToProps
)(memo(HeaderContainer));
)(memo(HeaderContainer));
dinky-web/src/pages/DataStudio/LeftContainer/Project/JobTree/index.tsx
View file @
3c07d9ba
...
@@ -24,12 +24,21 @@ import {
...
@@ -24,12 +24,21 @@ import {
getLeafKeyList
,
getLeafKeyList
,
getParentKey
getParentKey
}
from
'@/pages/DataStudio/LeftContainer/Project/function'
;
}
from
'@/pages/DataStudio/LeftContainer/Project/function'
;
import
{
StateType
,
STUDIO_MODEL
,
TabsItemType
}
from
'@/pages/DataStudio/model'
;
import
{
StateType
,
STUDIO_MODEL
,
STUDIO_MODEL_ASYNC
,
TabsItemType
,
TreeVo
}
from
'@/pages/DataStudio/model'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
connect
}
from
'@@/exports'
;
import
{
connect
}
from
'@@/exports'
;
import
{
SortAscendingOutlined
}
from
'@ant-design/icons'
;
import
{
Key
}
from
'@ant-design/pro-components'
;
import
{
Key
}
from
'@ant-design/pro-components'
;
import
{
Empty
,
Tree
}
from
'antd'
;
import
type
{
MenuProps
}
from
'antd'
;
import
{
Button
,
Dropdown
,
Empty
,
Space
,
Tree
}
from
'antd'
;
import
Search
from
'antd/es/input/Search'
;
import
Search
from
'antd/es/input/Search'
;
import
{
ItemType
}
from
'rc-menu/es/interface'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
BtnRoute
,
useTasksDispatch
}
from
'../../BtnContext'
;
import
{
BtnRoute
,
useTasksDispatch
}
from
'../../BtnContext'
;
...
@@ -49,6 +58,8 @@ type TreeProps = {
...
@@ -49,6 +58,8 @@ type TreeProps = {
const
JobTree
:
React
.
FC
<
TreeProps
&
connect
>
=
(
props
)
=>
{
const
JobTree
:
React
.
FC
<
TreeProps
&
connect
>
=
(
props
)
=>
{
const
{
const
{
project
:
{
data
:
projectData
,
expandKeys
,
selectKey
},
project
:
{
data
:
projectData
,
expandKeys
,
selectKey
},
catalogueSortType
:
{
data
:
catalogueSortTypeData
},
selectCatalogueSortTypeData
:
{
data
:
selectCatalogueSortTypeData
},
onNodeClick
,
onNodeClick
,
style
,
style
,
height
,
height
,
...
@@ -59,6 +70,8 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
...
@@ -59,6 +70,8 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
}
=
props
;
}
=
props
;
const
[
searchValue
,
setSearchValueValue
]
=
useState
(
''
);
const
[
searchValue
,
setSearchValueValue
]
=
useState
(
''
);
const
[
sortIconType
,
setSortIconType
]
=
useState
(
''
);
const
[
selectedSortValue
,
setSelectedSortValue
]
=
useState
<
string
[]
>
([]);
const
[
data
,
setData
]
=
useState
<
any
[]
>
(
buildProjectTree
(
projectData
,
searchValue
));
const
[
data
,
setData
]
=
useState
<
any
[]
>
(
buildProjectTree
(
projectData
,
searchValue
));
const
btnDispatch
=
useTasksDispatch
();
const
btnDispatch
=
useTasksDispatch
();
...
@@ -66,6 +79,48 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
...
@@ -66,6 +79,48 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
setData
(
buildProjectTree
(
projectData
,
searchValue
));
setData
(
buildProjectTree
(
projectData
,
searchValue
));
},
[
searchValue
,
projectData
]);
},
[
searchValue
,
projectData
]);
useEffect
(()
=>
{
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryProject
,
payload
:
selectCatalogueSortTypeData
});
},
[
selectCatalogueSortTypeData
]);
function
renameTrees
(
trees
:
TreeVo
[]):
ItemType
[]
{
const
menuItems
:
ItemType
[]
=
[];
for
(
let
tree
of
trees
)
{
let
menuItem
=
{
key
:
tree
[
'value'
],
label
:
tree
[
'name'
]
};
if
(
tree
[
'children'
])
{
const
subTrees
=
renameTrees
(
tree
[
'children'
]);
menuItem
[
'children'
]
=
subTrees
;
}
menuItems
.
push
(
menuItem
);
}
return
menuItems
;
}
// set sort default value
useEffect
(()
=>
{
if
(
selectCatalogueSortTypeData
&&
selectCatalogueSortTypeData
.
sortValue
!=
''
&&
selectCatalogueSortTypeData
.
sortType
!=
''
)
{
const
initialSortValue
=
selectCatalogueSortTypeData
.
sortValue
+
'_'
+
selectCatalogueSortTypeData
.
sortType
;
setSelectedSortValue
([
initialSortValue
]);
}
},
[]);
// when sorted, change the icon display
useEffect
(()
=>
{
if
(
selectCatalogueSortTypeData
.
sortValue
&&
selectCatalogueSortTypeData
.
sortType
)
{
setSortIconType
(
'link'
);
}
else
{
setSortIconType
(
'text'
);
}
},
[
selectCatalogueSortTypeData
]);
const
[
autoExpandParent
,
setAutoExpandParent
]
=
useState
(
true
);
const
[
autoExpandParent
,
setAutoExpandParent
]
=
useState
(
true
);
const
onChangeSearch
=
(
e
:
any
)
=>
{
const
onChangeSearch
=
(
e
:
any
)
=>
{
let
{
value
}
=
e
.
target
;
let
{
value
}
=
e
.
target
;
...
@@ -139,14 +194,56 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
...
@@ -139,14 +194,56 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
payload
:
btnEvent
payload
:
btnEvent
});
});
const
onClick
:
MenuProps
[
'onClick'
]
=
(
e
)
=>
{
const
selectSortValue
=
e
.
key
;
const
sortField
:
string
=
selectSortValue
.
substring
(
0
,
selectSortValue
.
lastIndexOf
(
'_'
));
const
sortType
:
string
=
selectSortValue
.
substring
(
selectSortValue
.
lastIndexOf
(
'_'
)
+
1
);
if
(
sortField
==
selectCatalogueSortTypeData
.
sortValue
&&
sortType
==
selectCatalogueSortTypeData
.
sortType
)
{
setSelectedSortValue
([]);
dispatch
({
type
:
STUDIO_MODEL
.
saveTaskSortTypeData
,
payload
:
{
sortValue
:
''
,
sortType
:
''
}
});
}
else
{
setSelectedSortValue
([
selectSortValue
]);
dispatch
({
type
:
STUDIO_MODEL
.
saveTaskSortTypeData
,
payload
:
{
sortValue
:
sortField
,
sortType
:
sortType
}
});
}
};
return
(
return
(
<>
<>
<
Space
direction=
'horizontal'
>
<
Search
<
Search
style=
{
{
margin
:
'8px 0px'
}
}
style=
{
{
margin
:
'8px 0px'
}
}
placeholder=
{
l
(
'global.search.text'
)
}
placeholder=
{
l
(
'global.search.text'
)
}
onChange=
{
onChangeSearch
}
onChange=
{
onChangeSearch
}
allowClear=
{
true
}
allowClear=
{
true
}
/>
/>
<
Dropdown
menu=
{
{
items
:
renameTrees
(
catalogueSortTypeData
),
mode
:
'horizontal'
,
selectable
:
true
,
onClick
:
onClick
,
selectedKeys
:
selectedSortValue
}
}
placement=
'bottomLeft'
>
<
Button
icon=
{
<
SortAscendingOutlined
/>
}
type=
{
sortIconType
}
></
Button
>
</
Dropdown
>
</
Space
>
{
data
.
length
?
(
{
data
.
length
?
(
<
DirectoryTree
<
DirectoryTree
...
@@ -173,5 +270,7 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
...
@@ -173,5 +270,7 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
height
:
Studio
.
toolContentHeight
,
height
:
Studio
.
toolContentHeight
,
project
:
Studio
.
project
project
:
Studio
.
project
,
catalogueSortType
:
Studio
.
catalogueSortType
,
selectCatalogueSortTypeData
:
Studio
.
selectCatalogueSortTypeData
}))(
JobTree
);
}))(
JobTree
);
dinky-web/src/pages/DataStudio/LeftContainer/Project/ProjectTitle/index.tsx
View file @
3c07d9ba
...
@@ -32,6 +32,7 @@ import React, { useState } from 'react';
...
@@ -32,6 +32,7 @@ import React, { useState } from 'react';
const
ProjectTitle
:
React
.
FC
<
StateType
&
connect
>
=
(
props
)
=>
{
const
ProjectTitle
:
React
.
FC
<
StateType
&
connect
>
=
(
props
)
=>
{
const
{
const
{
leftContainer
:
{
selectKey
},
leftContainer
:
{
selectKey
},
selectCatalogueSortTypeData
:
{
data
:
selectCatalogueSortTypeData
},
dispatch
dispatch
}
=
props
;
}
=
props
;
...
@@ -62,7 +63,7 @@ const ProjectTitle: React.FC<StateType & connect> = (props) => {
...
@@ -62,7 +63,7 @@ const ProjectTitle: React.FC<StateType & connect> = (props) => {
()
=>
{},
()
=>
{},
()
=>
{
()
=>
{
handleCancelCreate
();
handleCancelCreate
();
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryProject
});
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryProject
,
payload
:
selectCatalogueSortTypeData
});
}
}
);
);
};
};
...
@@ -103,5 +104,6 @@ const ProjectTitle: React.FC<StateType & connect> = (props) => {
...
@@ -103,5 +104,6 @@ const ProjectTitle: React.FC<StateType & connect> = (props) => {
};
};
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
leftContainer
:
Studio
.
leftContainer
leftContainer
:
Studio
.
leftContainer
,
selectCatalogueSortTypeData
:
Studio
.
selectCatalogueSortTypeData
}))(
ProjectTitle
);
}))(
ProjectTitle
);
dinky-web/src/pages/DataStudio/LeftContainer/Project/index.tsx
View file @
3c07d9ba
...
@@ -59,6 +59,7 @@ const Project: React.FC = (props: connect) => {
...
@@ -59,6 +59,7 @@ const Project: React.FC = (props: connect) => {
dispatch
,
dispatch
,
project
:
{
expandKeys
,
selectKey
},
project
:
{
expandKeys
,
selectKey
},
tabs
:
{
panes
,
activeKey
},
tabs
:
{
panes
,
activeKey
},
selectCatalogueSortTypeData
:
{
data
:
selectCatalogueSortTypeData
},
tabs
tabs
}
=
props
;
}
=
props
;
...
@@ -210,7 +211,7 @@ const Project: React.FC = (props: connect) => {
...
@@ -210,7 +211,7 @@ const Project: React.FC = (props: connect) => {
},
},
()
=>
{},
()
=>
{},
()
=>
{
()
=>
{
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryProject
});
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryProject
,
payload
:
selectCatalogueSortTypeData
});
if
(
values
.
type
&&
values
.
type
.
toLowerCase
()
===
DIALECT
.
FLINKSQLENV
)
{
if
(
values
.
type
&&
values
.
type
.
toLowerCase
()
===
DIALECT
.
FLINKSQLENV
)
{
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryEnv
});
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryEnv
});
}
}
...
@@ -255,7 +256,7 @@ const Project: React.FC = (props: connect) => {
...
@@ -255,7 +256,7 @@ const Project: React.FC = (props: connect) => {
handleContextCancel
();
handleContextCancel
();
if
(
!
isLeaf
)
{
if
(
!
isLeaf
)
{
await
handleRemoveById
(
API_CONSTANTS
.
DELETE_CATALOGUE_BY_ID_URL
,
key
,
()
=>
{
await
handleRemoveById
(
API_CONSTANTS
.
DELETE_CATALOGUE_BY_ID_URL
,
key
,
()
=>
{
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryProject
});
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryProject
,
payload
:
selectCatalogueSortTypeData
});
});
});
return
;
return
;
}
}
...
@@ -284,7 +285,7 @@ const Project: React.FC = (props: connect) => {
...
@@ -284,7 +285,7 @@ const Project: React.FC = (props: connect) => {
dispatch
({
type
:
STUDIO_MODEL
.
updateActiveBreadcrumbTitle
,
payload
:
''
});
dispatch
({
type
:
STUDIO_MODEL
.
updateActiveBreadcrumbTitle
,
payload
:
''
});
}
}
});
});
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryProject
});
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryProject
,
payload
:
selectCatalogueSortTypeData
});
}
}
});
});
};
};
...
@@ -321,7 +322,8 @@ const Project: React.FC = (props: connect) => {
...
@@ -321,7 +322,8 @@ const Project: React.FC = (props: connect) => {
API_CONSTANTS
.
COPY_TASK_URL
,
API_CONSTANTS
.
COPY_TASK_URL
,
l
(
'right.menu.copy'
),
l
(
'right.menu.copy'
),
{
...
projectState
.
value
},
{
...
projectState
.
value
},
()
=>
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryProject
})
()
=>
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryProject
,
payload
:
selectCatalogueSortTypeData
})
);
);
handleContextCancel
();
handleContextCancel
();
};
};
...
@@ -358,7 +360,7 @@ const Project: React.FC = (props: connect) => {
...
@@ -358,7 +360,7 @@ const Project: React.FC = (props: connect) => {
}));
}));
}
}
);
);
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryProject
});
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryProject
,
payload
:
selectCatalogueSortTypeData
});
handleContextCancel
();
handleContextCancel
();
};
};
...
@@ -487,5 +489,6 @@ const Project: React.FC = (props: connect) => {
...
@@ -487,5 +489,6 @@ const Project: React.FC = (props: connect) => {
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
tabs
:
Studio
.
tabs
,
tabs
:
Studio
.
tabs
,
project
:
Studio
.
project
project
:
Studio
.
project
,
selectCatalogueSortTypeData
:
Studio
.
selectCatalogueSortTypeData
}))(
Project
);
}))(
Project
);
dinky-web/src/pages/DataStudio/LeftContainer/Project/service.tsx
View file @
3c07d9ba
...
@@ -22,8 +22,11 @@ import { postAll, putDataJson } from '@/services/api';
...
@@ -22,8 +22,11 @@ import { postAll, putDataJson } from '@/services/api';
import
{
queryDataByParams
}
from
'@/services/BusinessCrud'
;
import
{
queryDataByParams
}
from
'@/services/BusinessCrud'
;
import
{
API_CONSTANTS
}
from
'@/services/endpoints'
;
import
{
API_CONSTANTS
}
from
'@/services/endpoints'
;
export
async
function
getTaskData
()
{
export
async
function
getTaskData
(
params
:
any
)
{
return
(
await
postAll
(
API_CONSTANTS
.
CATALOGUE_GET_CATALOGUE_TREE_DATA
)).
data
;
return
(
await
postAll
(
API_CONSTANTS
.
CATALOGUE_GET_CATALOGUE_TREE_DATA
,
params
)).
data
;
}
export
async
function
getTaskSortTypeData
()
{
return
(
await
postAll
(
API_CONSTANTS
.
CATALOGUE_GET_CATALOGUE_SORT_TYPE_DATA
)).
data
;
}
}
export
function
getTaskDetails
(
id
:
number
):
Promise
<
TaskDataType
|
undefined
>
{
export
function
getTaskDetails
(
id
:
number
):
Promise
<
TaskDataType
|
undefined
>
{
return
queryDataByParams
(
API_CONSTANTS
.
TASK
,
{
id
:
id
});
return
queryDataByParams
(
API_CONSTANTS
.
TASK
,
{
id
:
id
});
...
...
dinky-web/src/pages/DataStudio/function.ts
View file @
3c07d9ba
...
@@ -89,9 +89,15 @@ export const mapDispatchToProps = (dispatch: Dispatch) => ({
...
@@ -89,9 +89,15 @@ export const mapDispatchToProps = (dispatch: Dispatch) => ({
dispatch
({
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryDatabaseList
type
:
STUDIO_MODEL_ASYNC
.
queryDatabaseList
}),
}),
queryTaskData
:
()
=>
{
queryTaskData
:
(
payload
:
any
)
=>
{
dispatch
({
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryTaskData
type
:
STUDIO_MODEL_ASYNC
.
queryTaskData
,
...
payload
});
},
queryTaskSortTypeData
:
()
=>
{
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryTaskSortTypeData
});
});
},
},
querySessionData
:
()
=>
{
querySessionData
:
()
=>
{
...
...
dinky-web/src/pages/DataStudio/index.tsx
View file @
3c07d9ba
...
@@ -55,6 +55,7 @@ const DataStudio: React.FC<connect> = (props: any) => {
...
@@ -55,6 +55,7 @@ const DataStudio: React.FC<connect> = (props: any) => {
rightContainer
,
rightContainer
,
queryDatabaseList
,
queryDatabaseList
,
queryTaskData
,
queryTaskData
,
queryTaskSortTypeData
,
updateToolContentHeight
,
updateToolContentHeight
,
updateBottomHeight
,
updateBottomHeight
,
querySessionData
,
querySessionData
,
...
@@ -66,7 +67,8 @@ const DataStudio: React.FC<connect> = (props: any) => {
...
@@ -66,7 +67,8 @@ const DataStudio: React.FC<connect> = (props: any) => {
queryClusterConfigurationData
,
queryClusterConfigurationData
,
activeBreadcrumbTitle
,
activeBreadcrumbTitle
,
updateSelectBottomSubKey
,
updateSelectBottomSubKey
,
tabs
:
{
panes
,
activeKey
}
tabs
:
{
panes
,
activeKey
},
selectCatalogueSortTypeData
:
{
data
:
selectCatalogueSortTypeData
}
}
=
props
;
}
=
props
;
const
isProject
=
isProjectTabs
(
panes
,
activeKey
);
const
isProject
=
isProjectTabs
(
panes
,
activeKey
);
const
{
token
}
=
useToken
();
const
{
token
}
=
useToken
();
...
@@ -108,7 +110,8 @@ const DataStudio: React.FC<connect> = (props: any) => {
...
@@ -108,7 +110,8 @@ const DataStudio: React.FC<connect> = (props: any) => {
const
loadData
=
()
=>
{
const
loadData
=
()
=>
{
queryDatabaseList
();
queryDatabaseList
();
queryTaskData
();
queryTaskSortTypeData
();
queryTaskData
({
payload
:
selectCatalogueSortTypeData
});
querySessionData
();
querySessionData
();
queryEnv
();
queryEnv
();
queryClusterConfigurationData
();
queryClusterConfigurationData
();
...
@@ -301,7 +304,8 @@ export default connect(
...
@@ -301,7 +304,8 @@ export default connect(
rightContainer
:
Studio
.
rightContainer
,
rightContainer
:
Studio
.
rightContainer
,
bottomContainer
:
Studio
.
bottomContainer
,
bottomContainer
:
Studio
.
bottomContainer
,
activeBreadcrumbTitle
:
Studio
.
tabs
.
activeBreadcrumbTitle
,
activeBreadcrumbTitle
:
Studio
.
tabs
.
activeBreadcrumbTitle
,
tabs
:
Studio
.
tabs
tabs
:
Studio
.
tabs
,
selectCatalogueSortTypeData
:
Studio
.
selectCatalogueSortTypeData
}),
}),
mapDispatchToProps
mapDispatchToProps
)(
DataStudio
);
)(
DataStudio
);
dinky-web/src/pages/DataStudio/model.ts
View file @
3c07d9ba
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
import
{
LeftBottomKey
,
LeftMenuKey
}
from
'@/pages/DataStudio/data.d'
;
import
{
LeftBottomKey
,
LeftMenuKey
}
from
'@/pages/DataStudio/data.d'
;
import
{
getFooterValue
,
isDataStudioTabsItemType
}
from
'@/pages/DataStudio/function'
;
import
{
getFooterValue
,
isDataStudioTabsItemType
}
from
'@/pages/DataStudio/function'
;
import
{
getDataSourceList
}
from
'@/pages/DataStudio/LeftContainer/DataSource/service'
;
import
{
getDataSourceList
}
from
'@/pages/DataStudio/LeftContainer/DataSource/service'
;
import
{
getTaskData
}
from
'@/pages/DataStudio/LeftContainer/Project/service'
;
import
{
getTaskData
,
getTaskSortTypeData
}
from
'@/pages/DataStudio/LeftContainer/Project/service'
;
import
{
import
{
getClusterConfigurationData
,
getClusterConfigurationData
,
getEnvData
,
getEnvData
,
...
@@ -80,6 +80,12 @@ export type EnvType = {
...
@@ -80,6 +80,12 @@ export type EnvType = {
fragment
?:
boolean
;
fragment
?:
boolean
;
};
};
export
type
TreeVo
=
{
name
?:
string
;
value
?:
string
;
children
?:
TreeVo
[];
};
export
type
TaskType
=
{
export
type
TaskType
=
{
id
?:
number
;
id
?:
number
;
catalogueId
?:
number
;
catalogueId
?:
number
;
...
@@ -278,6 +284,15 @@ export type StateType = {
...
@@ -278,6 +284,15 @@ export type StateType = {
expandKeys
:
[];
expandKeys
:
[];
selectKey
:
[];
selectKey
:
[];
};
};
catalogueSortType
:
{
data
:
TreeVo
[];
};
selectCatalogueSortTypeData
:
{
data
:
{
sortValue
:
string
;
sortType
:
string
;
};
};
sessionCluster
:
Cluster
.
Instance
[];
sessionCluster
:
Cluster
.
Instance
[];
clusterConfiguration
:
Cluster
.
Config
[];
clusterConfiguration
:
Cluster
.
Config
[];
flinkConfigOptions
:
DefaultOptionType
[];
flinkConfigOptions
:
DefaultOptionType
[];
...
@@ -298,6 +313,7 @@ export type ModelType = {
...
@@ -298,6 +313,7 @@ export type ModelType = {
queryEnv
:
Effect
;
queryEnv
:
Effect
;
queryDatabaseList
:
Effect
;
queryDatabaseList
:
Effect
;
queryTaskData
:
Effect
;
queryTaskData
:
Effect
;
queryTaskSortTypeData
:
Effect
;
querySessionData
:
Effect
;
querySessionData
:
Effect
;
queryClusterConfigurationData
:
Effect
;
queryClusterConfigurationData
:
Effect
;
};
};
...
@@ -313,6 +329,7 @@ export type ModelType = {
...
@@ -313,6 +329,7 @@ export type ModelType = {
updateBottomHeight
:
Reducer
<
StateType
>
;
updateBottomHeight
:
Reducer
<
StateType
>
;
saveDataBase
:
Reducer
<
StateType
>
;
saveDataBase
:
Reducer
<
StateType
>
;
saveProject
:
Reducer
<
StateType
>
;
saveProject
:
Reducer
<
StateType
>
;
saveCatalogueSortType
:
Reducer
<
StateType
>
;
updateProjectExpandKey
:
Reducer
<
StateType
>
;
updateProjectExpandKey
:
Reducer
<
StateType
>
;
updateProjectSelectKey
:
Reducer
<
StateType
>
;
updateProjectSelectKey
:
Reducer
<
StateType
>
;
updateTabsActiveKey
:
Reducer
<
StateType
>
;
updateTabsActiveKey
:
Reducer
<
StateType
>
;
...
@@ -334,6 +351,7 @@ export type ModelType = {
...
@@ -334,6 +351,7 @@ export type ModelType = {
updateJobRunningMsg
:
Reducer
<
StateType
>
;
updateJobRunningMsg
:
Reducer
<
StateType
>
;
saveFlinkConfigOptions
:
Reducer
<
StateType
>
;
saveFlinkConfigOptions
:
Reducer
<
StateType
>
;
updateSuggestions
:
Reducer
<
StateType
>
;
updateSuggestions
:
Reducer
<
StateType
>
;
saveTaskSortTypeData
:
Reducer
<
StateType
>
;
};
};
};
};
...
@@ -372,6 +390,15 @@ const Model: ModelType = {
...
@@ -372,6 +390,15 @@ const Model: ModelType = {
expandKeys
:
[],
expandKeys
:
[],
selectKey
:
[]
selectKey
:
[]
},
},
catalogueSortType
:
{
data
:
[]
},
selectCatalogueSortTypeData
:
{
data
:
{
sortValue
:
''
,
sortType
:
''
}
},
tabs
:
{
tabs
:
{
activeBreadcrumbTitle
:
''
,
activeBreadcrumbTitle
:
''
,
activeKey
:
'0'
,
activeKey
:
'0'
,
...
@@ -443,6 +470,13 @@ const Model: ModelType = {
...
@@ -443,6 +470,13 @@ const Model: ModelType = {
payload
:
response
payload
:
response
});
});
},
},
*
queryTaskSortTypeData
({
payload
},
{
call
,
put
})
{
const
response
:
TreeVo
[]
=
yield
call
(
getTaskSortTypeData
,
payload
);
yield
put
({
type
:
'saveCatalogueSortType'
,
payload
:
response
});
},
*
querySessionData
({
payload
},
{
call
,
put
})
{
*
querySessionData
({
payload
},
{
call
,
put
})
{
const
response
:
Cluster
.
Instance
[]
=
yield
call
(
getSessionData
,
payload
);
const
response
:
Cluster
.
Instance
[]
=
yield
call
(
getSessionData
,
payload
);
yield
put
({
yield
put
({
...
@@ -601,6 +635,18 @@ const Model: ModelType = {
...
@@ -601,6 +635,18 @@ const Model: ModelType = {
project
:
{
...
state
.
project
,
data
:
payload
}
project
:
{
...
state
.
project
,
data
:
payload
}
};
};
},
},
saveCatalogueSortType
(
state
,
{
payload
})
{
return
{
...
state
,
catalogueSortType
:
{
data
:
payload
}
};
},
saveTaskSortTypeData
(
state
,
{
payload
})
{
return
{
...
state
,
selectCatalogueSortTypeData
:
{
data
:
payload
}
};
},
updateProjectExpandKey
(
state
,
{
payload
})
{
updateProjectExpandKey
(
state
,
{
payload
})
{
return
{
return
{
...
...
dinky-web/src/pages/DevOps/JobList/index.tsx
View file @
3c07d9ba
...
@@ -134,7 +134,7 @@ const JobList = () => {
...
@@ -134,7 +134,7 @@ const JobList = () => {
* 获取任务数据 | query task data
* 获取任务数据 | query task data
*/
*/
useEffect
(()
=>
{
useEffect
(()
=>
{
getTaskData
().
then
((
res
)
=>
{
getTaskData
(
{}
).
then
((
res
)
=>
{
if
(
res
)
{
if
(
res
)
{
setData
(
buildProjectTree
(
res
,
searchValue
,
[]));
setData
(
buildProjectTree
(
res
,
searchValue
,
[]));
}
}
...
...
dinky-web/src/services/endpoints.tsx
View file @
3c07d9ba
...
@@ -266,6 +266,7 @@ export enum API_CONSTANTS {
...
@@ -266,6 +266,7 @@ export enum API_CONSTANTS {
SUBMIT_TASK
=
'/api/task/submitTask'
,
SUBMIT_TASK
=
'/api/task/submitTask'
,
CHANGE_TASK_LIFE
=
'/api/task/changeTaskLife'
,
CHANGE_TASK_LIFE
=
'/api/task/changeTaskLife'
,
CATALOGUE_GET_CATALOGUE_TREE_DATA
=
'/api/catalogue/getCatalogueTreeData'
,
CATALOGUE_GET_CATALOGUE_TREE_DATA
=
'/api/catalogue/getCatalogueTreeData'
,
CATALOGUE_GET_CATALOGUE_SORT_TYPE_DATA
=
'/api/catalogue/getCatalogueSortType'
,
GET_JOB_VERSION
=
'/api/task/version'
,
GET_JOB_VERSION
=
'/api/task/version'
,
RESTART_TASK
=
'/api/task/restartTask'
,
RESTART_TASK
=
'/api/task/restartTask'
,
SAVEPOINT
=
'/api/task/savepoint'
,
SAVEPOINT
=
'/api/task/savepoint'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment