Search in sources :

Example 1 with CatalogToolDTO

use of it.istat.mec.catalog.dto.CatalogToolDTO in project catalogo-strumenti by istat-methodology.

the class Translators method translate.

public static CatalogToolDTO translate(CatalogTool x) {
    final ModelMapper modelMapper = new ModelMapper();
    TypeMap<CatalogTool, CatalogToolDTO> typeMap = modelMapper.createTypeMap(CatalogTool.class, CatalogToolDTO.class);
    typeMap.include(DesktopApplication.class, CatalogToolDTO.class).include(StatisticalService.class, CatalogToolDTO.class).include(SoftwareProcedure.class, CatalogToolDTO.class);
    modelMapper.typeMap(DesktopApplication.class, CatalogToolDTO.class).setProvider(new Provider<CatalogToolDTO>() {

        public CatalogToolDTO get(ProvisionRequest<CatalogToolDTO> request) {
            return new DesktopApplicationDto();
        }
    });
    modelMapper.typeMap(StatisticalService.class, CatalogToolDTO.class).setProvider(new Provider<CatalogToolDTO>() {

        public CatalogToolDTO get(ProvisionRequest<CatalogToolDTO> request) {
            return new StatisticalServiceDto();
        }
    });
    modelMapper.typeMap(SoftwareProcedure.class, CatalogToolDTO.class).setProvider(new Provider<CatalogToolDTO>() {

        public CatalogToolDTO get(ProvisionRequest<CatalogToolDTO> request) {
            return new SoftwareProcedureDto();
        }
    });
    CatalogToolDTO dTO = null;
    if (x instanceof StatisticalService)
        dTO = modelMapper.map(x, StatisticalServiceDto.class);
    if (x instanceof DesktopApplication)
        dTO = modelMapper.map(x, DesktopApplicationDto.class);
    if (x instanceof SoftwareProcedure)
        dTO = modelMapper.map(x, SoftwareProcedureDto.class);
    return dTO;
}
Also used : CatalogTool(it.istat.mec.catalog.domain.CatalogTool) DesktopApplication(it.istat.mec.catalog.domain.DesktopApplication) CatalogToolDTO(it.istat.mec.catalog.dto.CatalogToolDTO) StatisticalServiceDto(it.istat.mec.catalog.dto.StatisticalServiceDto) SoftwareProcedureDto(it.istat.mec.catalog.dto.SoftwareProcedureDto) DesktopApplicationDto(it.istat.mec.catalog.dto.DesktopApplicationDto) StatisticalService(it.istat.mec.catalog.domain.StatisticalService) SoftwareProcedure(it.istat.mec.catalog.domain.SoftwareProcedure) ModelMapper(org.modelmapper.ModelMapper)

Example 2 with CatalogToolDTO

use of it.istat.mec.catalog.dto.CatalogToolDTO in project catalogo-strumenti by istat-methodology.

the class Translators method translate.

public static List<CatalogToolDTO> translate(List<CatalogTool> list) {
    final ModelMapper modelMapper = new ModelMapper();
    TypeMap<CatalogTool, CatalogToolDTO> typeMap = modelMapper.createTypeMap(CatalogTool.class, CatalogToolDTO.class);
    typeMap.include(DesktopApplication.class, DesktopApplicationDto.class).include(StatisticalService.class, StatisticalServiceDto.class).include(SoftwareProcedure.class, SoftwareProcedureDto.class);
    typeMap.include(DesktopApplication.class, CatalogToolDTO.class).include(StatisticalService.class, CatalogToolDTO.class).include(SoftwareProcedure.class, CatalogToolDTO.class);
    modelMapper.typeMap(DesktopApplication.class, CatalogToolDTO.class).setProvider(new Provider<CatalogToolDTO>() {

        public CatalogToolDTO get(ProvisionRequest<CatalogToolDTO> request) {
            return new DesktopApplicationDto();
        }
    });
    modelMapper.typeMap(StatisticalService.class, CatalogToolDTO.class).setProvider(new Provider<CatalogToolDTO>() {

        public CatalogToolDTO get(ProvisionRequest<CatalogToolDTO> request) {
            return new StatisticalServiceDto();
        }
    });
    modelMapper.typeMap(SoftwareProcedure.class, CatalogToolDTO.class).setProvider(new Provider<CatalogToolDTO>() {

        public CatalogToolDTO get(ProvisionRequest<CatalogToolDTO> request) {
            return new SoftwareProcedureDto();
        }
    });
    return mapList(list, CatalogToolDTO.class, modelMapper);
}
Also used : CatalogTool(it.istat.mec.catalog.domain.CatalogTool) DesktopApplication(it.istat.mec.catalog.domain.DesktopApplication) CatalogToolDTO(it.istat.mec.catalog.dto.CatalogToolDTO) StatisticalServiceDto(it.istat.mec.catalog.dto.StatisticalServiceDto) SoftwareProcedureDto(it.istat.mec.catalog.dto.SoftwareProcedureDto) DesktopApplicationDto(it.istat.mec.catalog.dto.DesktopApplicationDto) StatisticalService(it.istat.mec.catalog.domain.StatisticalService) SoftwareProcedure(it.istat.mec.catalog.domain.SoftwareProcedure) ModelMapper(org.modelmapper.ModelMapper)

Aggregations

CatalogTool (it.istat.mec.catalog.domain.CatalogTool)2 DesktopApplication (it.istat.mec.catalog.domain.DesktopApplication)2 SoftwareProcedure (it.istat.mec.catalog.domain.SoftwareProcedure)2 StatisticalService (it.istat.mec.catalog.domain.StatisticalService)2 CatalogToolDTO (it.istat.mec.catalog.dto.CatalogToolDTO)2 DesktopApplicationDto (it.istat.mec.catalog.dto.DesktopApplicationDto)2 SoftwareProcedureDto (it.istat.mec.catalog.dto.SoftwareProcedureDto)2 StatisticalServiceDto (it.istat.mec.catalog.dto.StatisticalServiceDto)2 ModelMapper (org.modelmapper.ModelMapper)2