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);
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations