use of org.modelmapper.TypeToken in project agile-service by open-hand.
the class StateMachineNodeServiceImpl method queryByStateMachineId.
@Override
public List<StatusMachineNodeVO> queryByStateMachineId(Long organizationId, Long stateMachineId, Boolean isDraft) {
List<StatusMachineNodeVO> nodeVOS;
if (Boolean.TRUE.equals(isDraft)) {
// 获取节点
List<StateMachineNodeDraftDTO> nodes = nodeDraftMapper.selectByStateMachineId(stateMachineId);
Map<Long, StatusDTO> map = nodes.stream().filter(x -> x.getStatus() != null).collect(Collectors.toMap(StateMachineNodeDraftDTO::getId, StateMachineNodeDraftDTO::getStatus));
nodeVOS = modelMapper.map(nodes, new TypeToken<List<StatusMachineNodeVO>>() {
}.getType());
for (StatusMachineNodeVO nodeVO : nodeVOS) {
StatusDTO status = map.get(nodeVO.getId());
if (status != null) {
nodeVO.setStatusVO(modelMapper.map(status, StatusVO.class));
}
}
} else {
List<StatusMachineNodeDTO> nodes = nodeDeployMapper.selectByStateMachineId(stateMachineId);
Map<Long, StatusDTO> map = nodes.stream().filter(x -> x.getStatus() != null).collect(Collectors.toMap(StatusMachineNodeDTO::getId, StatusMachineNodeDTO::getStatus));
nodeVOS = modelMapper.map(nodes, new TypeToken<List<StatusMachineNodeVO>>() {
}.getType());
for (StatusMachineNodeVO nodeVO : nodeVOS) {
StatusDTO status = map.get(nodeVO.getId());
if (status != null) {
nodeVO.setStatusVO(modelMapper.map(status, StatusVO.class));
}
}
}
return nodeVOS;
}
use of org.modelmapper.TypeToken in project agile-service by open-hand.
the class PriorityServiceImpl method queryByOrganizationId.
@Override
public Map<Long, PriorityVO> queryByOrganizationId(Long organizationId) {
PriorityDTO priority = new PriorityDTO();
priority.setOrganizationId(organizationId);
List<PriorityDTO> priorities = priorityMapper.select(priority);
if (CollectionUtils.isEmpty(priorities)) {
return new HashMap<>();
}
Map<Long, PriorityVO> result = new HashMap<>();
List<PriorityVO> priorityVOS = modelMapper.map(priorities, new TypeToken<List<PriorityVO>>() {
}.getType());
result.putAll(priorityVOS.stream().collect(Collectors.toMap(PriorityVO::getId, Function.identity())));
return result;
}
use of org.modelmapper.TypeToken in project agile-service by open-hand.
the class PriorityServiceImpl method queryDefaultByOrganizationId.
@Override
public PriorityVO queryDefaultByOrganizationId(Long organizationId) {
PriorityDTO priority = new PriorityDTO();
priority.setOrganizationId(organizationId);
priority.setDefault(true);
PriorityDTO result = priorityMapper.selectOne(priority);
if (result == null) {
throw new CommonException(NOT_FOUND);
}
return modelMapper.map(result, new TypeToken<PriorityVO>() {
}.getType());
}
use of org.modelmapper.TypeToken in project agile-service by open-hand.
the class QuickFilterServiceImpl method listByProjectId.
@Override
public Page<QuickFilterVO> listByProjectId(Long projectId, QuickFilterSearchVO quickFilterSearchVO, PageRequest pageRequest) {
boolean isFirstPage = (pageRequest.getPage() == 0);
List<Long> topIds = quickFilterSearchVO.getQuickFilterIds();
List<QuickFilterDTO> list = new ArrayList<>();
if (isFirstPage && !ObjectUtils.isEmpty(topIds)) {
QuickFilterSearchVO search = new QuickFilterSearchVO();
search.setQuickFilterIds(topIds);
list.addAll(quickFilterMapper.queryFiltersByProjectId(projectId, search));
}
quickFilterSearchVO.setQuickFilterIds(null);
quickFilterSearchVO.setIgnoredQuickFilterIds(topIds);
Page<QuickFilterDTO> page = PageHelper.doPageAndSort(pageRequest, () -> quickFilterMapper.queryFiltersByProjectId(projectId, quickFilterSearchVO));
list.addAll(page.getContent());
list.forEach(v -> v.setDescription(handlerFilterDescription(v.getDescription(), true)));
if (list.isEmpty()) {
return PageUtil.emptyPage(pageRequest.getPage(), pageRequest.getSize());
}
List<QuickFilterVO> result = modelMapper.map(list, new TypeToken<List<QuickFilterVO>>() {
}.getType());
return PageUtil.buildPageInfoWithPageInfoList(page, result);
}
use of org.modelmapper.TypeToken in project agile-service by open-hand.
the class IssuePredecessorServiceImpl method queryByIssueId.
@Override
public List<IssuePredecessorVO> queryByIssueId(Long projectId, Long currentIssueId, boolean withInfo) {
IssuePredecessorDTO dto = new IssuePredecessorDTO();
dto.setOrganizationId(ConvertUtil.getOrganizationId(projectId));
dto.setProjectId(projectId);
dto.setIssueId(currentIssueId);
List<IssuePredecessorDTO> dtoList = issuePredecessorMapper.select(dto);
ModelMapper modelMapper = new ModelMapper();
List<IssuePredecessorVO> result = modelMapper.map(dtoList, new TypeToken<List<IssuePredecessorVO>>() {
}.getType());
if (Boolean.TRUE.equals(withInfo) && !CollectionUtils.isEmpty(result)) {
Long organizationId = ConvertUtil.getOrganizationId(projectId);
List<Long> issueIds = result.stream().map(IssuePredecessorVO::getPredecessorId).collect(Collectors.toList());
// 类型、概要、编号、优先级、状态、经办人
List<IssueDTO> issueDTOList = issueMapper.queryIssueListWithSubByIssueIds(issueIds, null, false, false);
Map<Long, PriorityVO> priorityMap = priorityService.queryByOrganizationId(organizationId);
Map<Long, StatusVO> statusMapDTOMap = statusService.queryAllStatusMap(organizationId);
Map<Long, IssueTypeVO> issueTypeDTOMap = issueTypeService.listIssueTypeMap(organizationId, projectId);
List<IssueListVO> issueList = issueAssembler.issueDoToIssueListDto(issueDTOList, priorityMap, statusMapDTOMap, issueTypeDTOMap);
Map<Long, IssueListVO> issueMap = issueList.stream().collect(Collectors.toMap(IssueListVO::getIssueId, Function.identity()));
result.forEach(vo -> vo.setPredecessorIssueVO(issueMap.get(vo.getPredecessorId())));
}
return result;
}
Aggregations