Search in sources :

Example 1 with ScanMappingConfiguration

use of com.mercedesbenz.sechub.domain.scan.config.ScanMappingConfiguration in project sechub by mercedes-benz.

the class ScanMappingConfigurationTestJSONasNamePatternDialogAction method execute.

@Override
protected void execute(ActionEvent e) throws Exception {
    /* convert to rows */
    String json = getMappingUI().getJSON();
    MappingIdentifier identifier = resolveMappingIdentifier();
    ScanMappingConfiguration config = createScanConfig(json, identifier);
    DeveloperToolsScanMappingConfigurationService scanMappingConfigurationService = new DeveloperToolsScanMappingConfigurationService();
    scanMappingConfigurationService.switchConfigurationIfChanged(config);
    NamePatternIdProvider provider = scanMappingConfigurationService.getNamePatternIdProvider(identifier);
    boolean ongoing = true;
    while (ongoing) {
        /* ui */
        Optional<String> value = getDialogUI().getContext().getDialogUI().getUserInput("Enter a name to check", "pattern");
        if (!value.isPresent()) {
            return;
        }
        String pattern = value.get();
        String id = provider.getIdForName(pattern);
        ongoing = getDialogUI().getContext().getDialogUI().confirm("Pattern '" + pattern + "' results in '" + id + "'\n\nDo you want to test another value?");
    }
}
Also used : MappingIdentifier(com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier) DeveloperToolsScanMappingConfigurationService(com.mercedesbenz.sechub.domain.scan.config.DeveloperToolsScanMappingConfigurationService) NamePatternIdProvider(com.mercedesbenz.sechub.domain.scan.config.NamePatternIdProvider) ScanMappingConfiguration(com.mercedesbenz.sechub.domain.scan.config.ScanMappingConfiguration)

Example 2 with ScanMappingConfiguration

use of com.mercedesbenz.sechub.domain.scan.config.ScanMappingConfiguration in project sechub by mercedes-benz.

the class ScanMappingConfigurationTestJSONasNamePatternDialogAction method createScanConfig.

private ScanMappingConfiguration createScanConfig(String json, MappingIdentifier identifier) {
    MappingData mappingData = MappingData.fromString(json);
    ScanMapping mapping = new ScanMapping(identifier.getId());
    mapping.setData(mappingData.toJSON());
    ScanMappingConfiguration config = new ScanMappingToScanMappingConfigurationTransformer().transform(Collections.singletonList(mapping));
    return config;
}
Also used : ScanMapping(com.mercedesbenz.sechub.domain.scan.config.ScanMapping) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) ScanMappingConfiguration(com.mercedesbenz.sechub.domain.scan.config.ScanMappingConfiguration) ScanMappingToScanMappingConfigurationTransformer(com.mercedesbenz.sechub.domain.scan.config.ScanMappingToScanMappingConfigurationTransformer)

Aggregations

ScanMappingConfiguration (com.mercedesbenz.sechub.domain.scan.config.ScanMappingConfiguration)2 DeveloperToolsScanMappingConfigurationService (com.mercedesbenz.sechub.domain.scan.config.DeveloperToolsScanMappingConfigurationService)1 NamePatternIdProvider (com.mercedesbenz.sechub.domain.scan.config.NamePatternIdProvider)1 ScanMapping (com.mercedesbenz.sechub.domain.scan.config.ScanMapping)1 ScanMappingToScanMappingConfigurationTransformer (com.mercedesbenz.sechub.domain.scan.config.ScanMappingToScanMappingConfigurationTransformer)1 MappingData (com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)1 MappingIdentifier (com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier)1