Search in sources :

Example 81 with ModelMapper

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;
}
Also used : ModelMapper(org.modelmapper.ModelMapper) Bean(org.springframework.context.annotation.Bean)

Example 82 with 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;
}
Also used : ModelMapper(org.modelmapper.ModelMapper) IssueListVO(io.choerodon.agile.api.vo.business.IssueListVO) IssuePredecessorDTO(io.choerodon.agile.infra.dto.IssuePredecessorDTO) TypeToken(org.modelmapper.TypeToken) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO)

Example 83 with ModelMapper

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;
}
Also used : RepresentationsToRequestsController(io.dataspaceconnector.controller.resource.relation.RepresentationsToRequestsController) RepresentationsToSubscriptionsController(io.dataspaceconnector.controller.resource.relation.RepresentationsToSubscriptionsController) OfferedResource(io.dataspaceconnector.model.resource.OfferedResource) RequestedResource(io.dataspaceconnector.model.resource.RequestedResource) UnreachableLineException(io.dataspaceconnector.common.exception.UnreachableLineException) RepresentationsToArtifactsController(io.dataspaceconnector.controller.resource.relation.RepresentationsToArtifactsController) Link(org.springframework.hateoas.Link) ModelMapper(org.modelmapper.ModelMapper)

Example 84 with ModelMapper

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;
}
Also used : ContractsToRulesController(io.dataspaceconnector.controller.resource.relation.ContractsToRulesController) OfferedResource(io.dataspaceconnector.model.resource.OfferedResource) ContractsToRequestedResourcesController(io.dataspaceconnector.controller.resource.relation.ContractsToRequestedResourcesController) RequestedResource(io.dataspaceconnector.model.resource.RequestedResource) UnreachableLineException(io.dataspaceconnector.common.exception.UnreachableLineException) Link(org.springframework.hateoas.Link) ModelMapper(org.modelmapper.ModelMapper)

Example 85 with ModelMapper

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);
}
Also used : NormalRecord(com.surenpi.autotest.report.record.NormalRecord) ExcelReport(com.surenpi.autotest.report.excel.model.ExcelReport) ModelMapper(org.modelmapper.ModelMapper)

Aggregations

ModelMapper (org.modelmapper.ModelMapper)187 Bean (org.springframework.context.annotation.Bean)37 ArrayList (java.util.ArrayList)18 Date (java.util.Date)6 LocalDate (java.time.LocalDate)5 List (java.util.List)5 Map (java.util.Map)5 Optional (java.util.Optional)5 Actor (com.management.entities.Actor)4 CinemaTheatre (com.management.entities.CinemaTheatre)4 Event (com.management.entities.Event)4 Performance (com.management.entities.Performance)4 Props (com.management.entities.Props)4 User (com.management.entities.User)4 Collectors (java.util.stream.Collectors)4 PutMessageRequestType (no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Actorperformances (com.management.entities.Actorperformances)3 FanZone (com.management.entities.FanZone)3