use of org.modelmapper.ModelMapper in project agile-service by open-hand.
the class BeanConfiguration method modelMapper.
@Bean
public ModelMapper modelMapper() {
ModelMapper modelMapper = new ModelMapper();
modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
return modelMapper;
}
use of org.modelmapper.ModelMapper 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;
}
use of org.modelmapper.ModelMapper in project DataspaceConnector by International-Data-Spaces-Association.
the class RepresentationViewAssembler method toModel.
/**
* Construct the RepresentationView from a Representation.
*
* @param representation The representation.
* @return The new view.
*/
@Override
public RepresentationView toModel(final Representation representation) {
final var modelMapper = new ModelMapper();
final var view = modelMapper.map(representation, RepresentationView.class);
view.add(getSelfLink(representation.getId()));
final var artifactsLink = linkTo(methodOn(RepresentationsToArtifactsController.class).getResource(representation.getId(), null, null)).withRel(BaseType.ARTIFACTS);
view.add(artifactsLink);
final var resourceType = representation.getResources();
Link resourceLinker;
if (resourceType.isEmpty()) {
// No elements found, default to offered resources
resourceLinker = linkTo(methodOn(RepresentationsToOfferedResourcesController.class).getResource(representation.getId(), null, null)).withRel(BaseType.OFFERS);
} else {
// Construct the link for the right resource type.
if (resourceType.get(0) instanceof OfferedResource) {
resourceLinker = linkTo(methodOn(RepresentationsToOfferedResourcesController.class).getResource(representation.getId(), null, null)).withRel(BaseType.OFFERS);
} else if (resourceType.get(0) instanceof RequestedResource) {
resourceLinker = linkTo(methodOn(RepresentationsToRequestsController.class).getResource(representation.getId(), null, null)).withRel(BaseType.REQUESTS);
} else {
throw new UnreachableLineException(ErrorMessage.UNKNOWN_TYPE);
}
}
view.add(resourceLinker);
final var subscriptionLink = linkTo(methodOn(RepresentationsToSubscriptionsController.class).getResource(representation.getId(), null, null)).withRel(BaseType.SUBSCRIPTIONS);
view.add(subscriptionLink);
return view;
}
use of org.modelmapper.ModelMapper in project DataspaceConnector by International-Data-Spaces-Association.
the class ContractViewAssembler method toModel.
/**
* Construct the ContractView from a Contract.
*
* @param contract The contract.
* @return The new view.
*/
@Override
public ContractView toModel(final Contract contract) {
final var modelMapper = new ModelMapper();
final var view = modelMapper.map(contract, ContractView.class);
view.add(getSelfLink(contract.getId()));
final var rulesLink = linkTo(methodOn(ContractsToRulesController.class).getResource(contract.getId(), null, null)).withRel(BaseType.RULES);
view.add(rulesLink);
final var resourceType = contract.getResources();
Link resourceLinker;
if (resourceType.isEmpty()) {
// No elements found, default to offered resources
resourceLinker = linkTo(methodOn(ContractsToOfferedResourcesController.class).getResource(contract.getId(), null, null)).withRel(BaseType.OFFERS);
} else {
// Construct the link for the right resource type.
if (resourceType.get(0) instanceof OfferedResource) {
resourceLinker = linkTo(methodOn(ContractsToOfferedResourcesController.class).getResource(contract.getId(), null, null)).withRel(BaseType.OFFERS);
} else if (resourceType.get(0) instanceof RequestedResource) {
resourceLinker = linkTo(methodOn(ContractsToRequestedResourcesController.class).getResource(contract.getId(), null, null)).withRel(BaseType.REQUESTS);
} else {
throw new UnreachableLineException(ErrorMessage.UNKNOWN_TYPE);
}
}
view.add(resourceLinker);
return view;
}
use of org.modelmapper.ModelMapper in project selenium_java by sergueik.
the class ExcelReportWriter method write.
@Override
public void write(ExceptionRecord record) {
NormalRecord normalRecord = record.getNormalRecord();
ModelMapper mapper = new ModelMapper();
ExcelReport excelReport = mapper.map(normalRecord, ExcelReport.class);
excelReport.setDetail(record.getStackTraceText());
fillReport(normalRecord, ReportStatus.EXCEPTION, excelReport);
utils.export(excelReport);
}
Aggregations