Search in sources :

Example 51 with ModelMapper

use of org.modelmapper.ModelMapper in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class ScanResults method mergeWith.

public void mergeWith(ScanResults scanResultsToMerge) {
    if (scanResultsToMerge != null) {
        ModelMapper modelMapper = new ModelMapper();
        modelMapper.getConfiguration().setPropertyCondition(Conditions.isNotNull());
        modelMapper.map(scanResultsToMerge, this);
    }
}
Also used : ModelMapper(org.modelmapper.ModelMapper)

Example 52 with ModelMapper

use of org.modelmapper.ModelMapper in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class ScaClientHelper method getScanResults.

private SCAResults getScanResults() {
    SCAResults result;
    log.debug("Getting results for scan ID {}", scanId);
    try {
        result = new SCAResults();
        result.setScanId(this.scanId);
        ScaSummaryBaseFormat summaryBaseFormat = getSummaryReport(scanId);
        printSummary(summaryBaseFormat, this.scanId);
        ModelMapper mapper = new ModelMapper();
        Summary summary = mapper.map(summaryBaseFormat, Summary.class);
        Map<Filter.Severity, Integer> findingCountsPerSeverity = getFindingCountMap(summaryBaseFormat);
        summary.setFindingCounts(findingCountsPerSeverity);
        result.setSummary(summary);
        List<Finding> findings = getFindings(scanId);
        result.setFindings(findings);
        List<Package> packages = getPackages(scanId);
        result.setPackages(packages);
        String reportLink = getWebReportLink(config.getScaConfig().getWebAppUrl());
        result.setWebReportLink(reportLink);
        printWebReportLink(result);
        result.setScaResultReady(true);
        String riskReportId = getRiskReportByProjectId(this.projectId);
        List<PolicyEvaluation> policyEvaluationsByReportId = getPolicyEvaluationByReportId(riskReportId);
        List<String> scanViolatedPolicies = getScanViolatedPolicies(policyEvaluationsByReportId);
        result.setPolicyViolated(!scanViolatedPolicies.isEmpty());
        result.setViolatedPolicies(scanViolatedPolicies);
        if (scaProperties.isPreserveXml()) {
            String path = String.format(REPORT_IN_XML_WITH_SCANID, URLEncoder.encode(scanId, ENCODING));
            String xml = httpClient.getRequest(path, ContentType.CONTENT_TYPE_APPLICATION_JSON, String.class, HttpStatus.SC_OK, "CxSCA findings", false);
            xml = xml.trim().replaceFirst("^([\\W]+)<", "<");
            String xml2 = ScanUtils.cleanStringUTF8_2(xml);
            result.setOutput(xml2);
        }
        log.info("Retrieved SCA results successfully.");
    } catch (IOException e) {
        throw new ScannerRuntimeException("Error retrieving CxSCA scan results.", e);
    }
    return result;
}
Also used : Severity(com.checkmarx.sdk.dto.scansummary.Severity) IOException(java.io.IOException) ScannerRuntimeException(com.checkmarx.sdk.exception.ScannerRuntimeException) ModelMapper(org.modelmapper.ModelMapper) Package(com.checkmarx.sdk.dto.sca.report.Package)

Example 53 with ModelMapper

use of org.modelmapper.ModelMapper in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class ScaClientHelper method getScaResults.

private SCAResults getScaResults(RiskReportSummaryType riskReportSummaryType, PackagesType packagesType, VulnerabilitiesType vulnerabilitiesType, LicensesType licensesType, PoliciesType policiesType) {
    SCAResults result;
    ScaSummaryBaseFormat summaryBaseFormat = new ScaSummaryBaseFormat();
    List<Package> packages = null;
    log.debug("Getting results for scan ID {}", scanId);
    try {
        result = new SCAResults();
        result.setScanId(this.scanId);
        summaryBaseFormat = getScaSummaryReport(riskReportSummaryType, summaryBaseFormat);
        printSummary(summaryBaseFormat, this.scanId);
        ModelMapper mapper = new ModelMapper();
        Summary summary = mapper.map(summaryBaseFormat, Summary.class);
        Map<Filter.Severity, Integer> findingCountsPerSeverity = getFindingCountMap(summaryBaseFormat);
        summary.setFindingCounts(findingCountsPerSeverity);
        result.setSummary(summary);
        List<Finding> findings = getScaFindings(vulnerabilitiesType);
        result.setFindings(findings);
        packages = getScaPackages(packagesType, packages);
        result.setPackages(packages);
        String reportLink = getWebReportLink(config.getScaConfig().getWebAppUrl());
        result.setWebReportLink(reportLink);
        printWebReportLink(result);
        result.setScaResultReady(true);
        List<PolicyEvaluation> policyEvaluationsByReport = getScaPolicyEvaluationByReport(policiesType);
        List<String> scanViolatedPolicies = getScanViolatedPolicies(policyEvaluationsByReport);
        result.setPolicyViolated(!scanViolatedPolicies.isEmpty());
        result.setViolatedPolicies(scanViolatedPolicies);
        log.info("Retrieved SCA results successfully.");
    } catch (Exception e) {
        throw new ScannerRuntimeException("Error retrieving CxSCA scan results.", e);
    }
    return result;
}
Also used : Severity(com.checkmarx.sdk.dto.scansummary.Severity) ScannerRuntimeException(com.checkmarx.sdk.exception.ScannerRuntimeException) CheckmarxException(com.checkmarx.sdk.exception.CheckmarxException) ScannerRuntimeException(com.checkmarx.sdk.exception.ScannerRuntimeException) JAXBException(javax.xml.bind.JAXBException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) CxHTTPClientException(com.checkmarx.sdk.exception.CxHTTPClientException) IOException(java.io.IOException) ModelMapper(org.modelmapper.ModelMapper) Package(com.checkmarx.sdk.dto.sca.report.Package)

Example 54 with ModelMapper

use of org.modelmapper.ModelMapper in project springboot-learning by lyb-geek.

the class ModelMapperConfig method modelMapper.

@Bean
public ModelMapper modelMapper() {
    ModelMapper modelMapper = new ModelMapper();
    PropertyMap<User, UserDTO> propertyUser2UserDTOMap = new PropertyMap<User, UserDTO>() {

        @Override
        protected void configure() {
            skip(source.getGender(), destination.getGender());
        }
    };
    modelMapper.addMappings(propertyUser2UserDTOMap);
    return modelMapper;
}
Also used : User(com.github.lybgeek.mongodb.model.User) PropertyMap(org.modelmapper.PropertyMap) UserDTO(com.github.lybgeek.mongodb.dto.UserDTO) ModelMapper(org.modelmapper.ModelMapper) Bean(org.springframework.context.annotation.Bean)

Example 55 with ModelMapper

use of org.modelmapper.ModelMapper in project pagopa-api-config by pagopa.

the class MappingsConfiguration method modelMapper.

@Bean
public ModelMapper modelMapper() {
    ModelMapper mapper = new ModelMapper();
    mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
    Converter<Pa, CreditorInstitutionDetails> convertPaToCreditorInstitutionDetails = new ConvertPaToCreditorInstitutionDetails();
    Converter<Pa, CreditorInstitution> convertPaToCreditorInstitution = new ConvertPaToCreditorInstitution();
    Converter<Stazioni, Station> convertStazioniToStation = new ConvertStazioniToStation();
    Converter<Stazioni, StationDetails> convertStazioniToStationDetails = new ConvertStazioniToStationDetails();
    Converter<PaStazionePa, CreditorInstitutionStation> convertPaStazionePaToCreditorInstitutionStation = new ConvertPaStazionePaToCreditorInstitutionStation();
    Converter<PaStazionePa, StationCreditorInstitution> convertPaStazionePaToStationCreditorInstitution = new ConvertPaStazionePaToStationCreditorInstitution();
    Converter<CodifichePa, Encoding> convertCodifichePaToEncoding = new ConvertCodifichePaToEncoding();
    Converter<IntermediariPa, Broker> convertIntermediariPaToBroker = new ConvertIntermediariPaToBroker();
    Converter<IbanValidiPerPa, Iban> convertIbanValidiPerPaToIban = new ConvertIbanValidiPerPaToIban();
    Converter<IntermediariPa, BrokerDetails> convertIntermediariPaToBrokerDetails = new ConvertIntermediariPaToBrokerDetails();
    Converter<InformativeContoAccreditoMaster, Ica> convertInformativeContoAccreditoMasterRepositoryToIca = new ConvertInformativeContoAccreditoMasterRepositoryToIca();
    Converter<InformativePaMaster, CounterpartTable> convertInformativePaMasterToCounterpartTable = new ConvertInformativePaMasterToCounterpartTable();
    Converter<CreditorInstitutionDetails, Pa> convertCreditorInstitutionDetailsToPa = new ConvertCreditorInstitutionDetailsToPa();
    Converter<BrokerDetails, IntermediariPa> convertBrokerDetailsToIntermediariPa = new ConvertBrokerDetailsToIntermediariPa();
    Converter<StationDetails, Stazioni> convertStationDetailsToStazioni = new ConvertStationDetailsToStazioni();
    Converter<Encoding, CodifichePa> convertEncodingToCodifichePa = new ConvertEncodingToCodifichePa();
    Converter<Psp, PaymentServiceProvider> convertPspToPaymentServiceProvider = new ConvertPspToPaymentServiceProvider();
    Converter<Psp, PaymentServiceProviderDetails> convertPspToPaymentServiceProviderDetails = new ConvertPspToPaymentServiceProviderDetails();
    Converter<CreditorInstitutionStationEdit, PaStazionePa> convertCreditorInstitutionStationPostToPaStazionePa = new ConvertCreditorInstitutionStationPostToPaStazionePa();
    Converter<IntermediariPsp, BrokerPsp> convertIntermediariPspToBrokerPsp = new ConvertIntermediariPspToBrokerPsp();
    Converter<IntermediariPsp, BrokerPspDetails> convertIntermediariPspToBrokerPspDetails = new ConvertIntermediariPspToBrokerPspDetails();
    Converter<Canali, Channel> convertCanaliToChannel = new ConvertCanaliToChannel();
    Converter<Canali, ChannelDetails> convertCanaliToChannelDetails = new ConvertCanaliToChannelDetails();
    Converter<ElencoServizi, Service> convertElencoServiziToService = new ConvertElencoServiziToService();
    Converter<CdiMaster, Cdi> convertCdiMasterToCdi = new ConvertCdiMasterToCdi();
    Converter<PspCanaleTipoVersamento, PspChannel> convertPspCanaleTipoVersamentoToPspChannel = new ConvertPspCanaleTipoVersamentoToPspChannel();
    Converter<BrokerPspDetails, IntermediariPsp> convertBrokerPspDetailsToIntermediariPsp = new ConvertBrokerPspDetailsToIntermediariPsp();
    Converter<PaymentServiceProviderDetails, Psp> convertPaymentServiceProviderDetailsToPsp = new ConvertPaymentServiceProviderDetailsToPsp();
    Converter<ChannelDetails, Canali> convertChannelDetailsToCanali = new ConvertChannelDetailsToCanali();
    Converter<ConfigurationKeys, ConfigurationKey> convertConfigurationKeysConfigurationKey = new ConvertConfigurationKeysToConfigurationKey();
    Converter<CanaleTipoVersamento, PaymentType> convertCanaleTipoVersamentoToPaymentType = new ConvertCanaleTipoVersamentoToPaymentType();
    Converter<WfespPluginConf, it.pagopa.pagopa.apiconfig.model.configuration.WfespPluginConf> convertConfWfespPluginConf = new ConvertWfespPluginConfToWfespPluginConf();
    Converter<Pdd, it.pagopa.pagopa.apiconfig.model.configuration.Pdd> convertPddEToPddM = new ConvertPddEToPddM();
    Converter<it.pagopa.pagopa.apiconfig.model.configuration.Pdd, Pdd> convertPddMToPddE = new ConvertPddMToPddE();
    Converter<FtpServers, FtpServer> convertFtpServersFtpServer = new ConvertFtpServersToFtpServer();
    Converter<TipiVersamento, PaymentType> convertTipiVersamentoPaymentType = new ConvertTipiVersamentoToPaymentType();
    Converter<PaymentType, String> convertPaymentTypeString = new ConvertPaymentTypeToString();
    Converter<PaymentType, TipiVersamento> convertPaymentTypeTipiVersamento = new ConvertPaymentTypeToTipiVersamento();
    mapper.createTypeMap(Pa.class, CreditorInstitutionDetails.class).setConverter(convertPaToCreditorInstitutionDetails);
    mapper.createTypeMap(Pa.class, CreditorInstitution.class).setConverter(convertPaToCreditorInstitution);
    mapper.createTypeMap(Stazioni.class, Station.class).setConverter(convertStazioniToStation);
    mapper.createTypeMap(Stazioni.class, StationDetails.class).setConverter(convertStazioniToStationDetails);
    mapper.createTypeMap(PaStazionePa.class, CreditorInstitutionStation.class).setConverter(convertPaStazionePaToCreditorInstitutionStation);
    mapper.createTypeMap(PaStazionePa.class, StationCreditorInstitution.class).setConverter(convertPaStazionePaToStationCreditorInstitution);
    mapper.createTypeMap(CodifichePa.class, Encoding.class).setConverter(convertCodifichePaToEncoding);
    mapper.createTypeMap(IntermediariPa.class, Broker.class).setConverter(convertIntermediariPaToBroker);
    mapper.createTypeMap(IbanValidiPerPa.class, Iban.class).setConverter(convertIbanValidiPerPaToIban);
    mapper.createTypeMap(IntermediariPa.class, BrokerDetails.class).setConverter(convertIntermediariPaToBrokerDetails);
    mapper.createTypeMap(InformativeContoAccreditoMaster.class, Ica.class).setConverter(convertInformativeContoAccreditoMasterRepositoryToIca);
    mapper.createTypeMap(InformativePaMaster.class, CounterpartTable.class).setConverter(convertInformativePaMasterToCounterpartTable);
    mapper.createTypeMap(CreditorInstitutionDetails.class, Pa.class).setConverter(convertCreditorInstitutionDetailsToPa);
    mapper.createTypeMap(BrokerDetails.class, IntermediariPa.class).setConverter(convertBrokerDetailsToIntermediariPa);
    mapper.createTypeMap(StationDetails.class, Stazioni.class).setConverter(convertStationDetailsToStazioni);
    mapper.createTypeMap(Encoding.class, CodifichePa.class).setConverter(convertEncodingToCodifichePa);
    mapper.createTypeMap(Psp.class, PaymentServiceProvider.class).setConverter(convertPspToPaymentServiceProvider);
    mapper.createTypeMap(Psp.class, PaymentServiceProviderDetails.class).setConverter(convertPspToPaymentServiceProviderDetails);
    mapper.createTypeMap(CreditorInstitutionStationEdit.class, PaStazionePa.class).setConverter(convertCreditorInstitutionStationPostToPaStazionePa);
    mapper.createTypeMap(IntermediariPsp.class, BrokerPsp.class).setConverter(convertIntermediariPspToBrokerPsp);
    mapper.createTypeMap(IntermediariPsp.class, BrokerPspDetails.class).setConverter(convertIntermediariPspToBrokerPspDetails);
    mapper.createTypeMap(Canali.class, Channel.class).setConverter(convertCanaliToChannel);
    mapper.createTypeMap(Canali.class, ChannelDetails.class).setConverter(convertCanaliToChannelDetails);
    mapper.createTypeMap(ElencoServizi.class, Service.class).setConverter(convertElencoServiziToService);
    mapper.createTypeMap(CdiMaster.class, Cdi.class).setConverter(convertCdiMasterToCdi);
    mapper.createTypeMap(PspCanaleTipoVersamento.class, PspChannel.class).setConverter(convertPspCanaleTipoVersamentoToPspChannel);
    mapper.createTypeMap(BrokerPspDetails.class, IntermediariPsp.class).setConverter(convertBrokerPspDetailsToIntermediariPsp);
    mapper.createTypeMap(PaymentServiceProviderDetails.class, Psp.class).setConverter(convertPaymentServiceProviderDetailsToPsp);
    mapper.createTypeMap(ChannelDetails.class, Canali.class).setConverter(convertChannelDetailsToCanali);
    mapper.createTypeMap(ConfigurationKeys.class, ConfigurationKey.class).setConverter(convertConfigurationKeysConfigurationKey);
    mapper.createTypeMap(CanaleTipoVersamento.class, PaymentType.class).setConverter(convertCanaleTipoVersamentoToPaymentType);
    mapper.createTypeMap(WfespPluginConf.class, it.pagopa.pagopa.apiconfig.model.configuration.WfespPluginConf.class).setConverter(convertConfWfespPluginConf);
    mapper.createTypeMap(Pdd.class, it.pagopa.pagopa.apiconfig.model.configuration.Pdd.class).setConverter(convertPddEToPddM);
    mapper.createTypeMap(it.pagopa.pagopa.apiconfig.model.configuration.Pdd.class, Pdd.class).setConverter(convertPddMToPddE);
    mapper.createTypeMap(FtpServers.class, FtpServer.class).setConverter(convertFtpServersFtpServer);
    mapper.createTypeMap(TipiVersamento.class, PaymentType.class).setConverter(convertTipiVersamentoPaymentType);
    mapper.createTypeMap(PaymentType.class, String.class).setConverter(convertPaymentTypeString);
    mapper.createTypeMap(PaymentType.class, TipiVersamento.class).setConverter(convertPaymentTypeTipiVersamento);
    return mapper;
}
Also used : Cdi(it.pagopa.pagopa.apiconfig.model.psp.Cdi) BrokerPsp(it.pagopa.pagopa.apiconfig.model.psp.BrokerPsp) PaymentServiceProviderDetails(it.pagopa.pagopa.apiconfig.model.psp.PaymentServiceProviderDetails) ConfigurationKey(it.pagopa.pagopa.apiconfig.model.configuration.ConfigurationKey) PaymentServiceProvider(it.pagopa.pagopa.apiconfig.model.psp.PaymentServiceProvider) ChannelDetails(it.pagopa.pagopa.apiconfig.model.psp.ChannelDetails) PspChannel(it.pagopa.pagopa.apiconfig.model.psp.PspChannel) Channel(it.pagopa.pagopa.apiconfig.model.psp.Channel) BrokerPsp(it.pagopa.pagopa.apiconfig.model.psp.BrokerPsp) PaymentType(it.pagopa.pagopa.apiconfig.model.configuration.PaymentType) Service(it.pagopa.pagopa.apiconfig.model.psp.Service) PspChannel(it.pagopa.pagopa.apiconfig.model.psp.PspChannel) ModelMapper(org.modelmapper.ModelMapper) FtpServer(it.pagopa.pagopa.apiconfig.model.configuration.FtpServer) BrokerPspDetails(it.pagopa.pagopa.apiconfig.model.psp.BrokerPspDetails) Bean(org.springframework.context.annotation.Bean)

Aggregations

ModelMapper (org.modelmapper.ModelMapper)185 Bean (org.springframework.context.annotation.Bean)35 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