static ScannerContextImpl from(CloseableIterator<ScannerReport.ContextProperty> it) { try { ImmutableMap.Builder<String, String> mapBuilder = ImmutableMap.builder(); while (it.hasNext()) { ScannerReport.ContextProperty prop = it.next(); mapBuilder.put(prop.getKey(), prop.getValue()); } return new ScannerContextImpl(mapBuilder.build()); } finally { it.close(); } } }
@Override public void execute(ComputationStep.Context context) { List<AnalysisPropertyDto> analysisPropertyDtos = new ArrayList<>(); try (CloseableIterator<ScannerReport.ContextProperty> it = reportReader.readContextProperties()) { it.forEachRemaining( contextProperty -> { String propertyKey = contextProperty.getKey(); if (propertyKey.startsWith(SONAR_ANALYSIS) || propertyKey.startsWith(SONAR_PULL_REQUEST)) { analysisPropertyDtos.add(new AnalysisPropertyDto() .setUuid(uuidFactory.create()) .setKey(propertyKey) .setValue(contextProperty.getValue()) .setSnapshotUuid(analysisMetadataHolder.getUuid())); } }); } analysisMetadataHolder.getScmRevisionId().ifPresent(scmRevisionId -> analysisPropertyDtos.add(new AnalysisPropertyDto() .setUuid(uuidFactory.create()) .setKey(SCM_REVISION_ID) .setValue(scmRevisionId) .setSnapshotUuid(analysisMetadataHolder.getUuid()))); if (analysisPropertyDtos.isEmpty()) { return; } try (DbSession dbSession = dbClient.openSession(false)) { dbClient.analysisPropertiesDao().insert(dbSession, analysisPropertyDtos); dbSession.commit(); } }
static ScannerContextImpl from(CloseableIterator<ScannerReport.ContextProperty> it) { try { ImmutableMap.Builder<String, String> mapBuilder = ImmutableMap.builder(); while (it.hasNext()) { ScannerReport.ContextProperty prop = it.next(); mapBuilder.put(prop.getKey(), prop.getValue()); } return new ScannerContextImpl(mapBuilder.build()); } finally { it.close(); } } }
@Override public void execute() { final List<AnalysisPropertyDto> analysisPropertyDtos = new ArrayList<>(); reportReader.readContextProperties().forEachRemaining( contextProperty -> { String propertyKey = contextProperty.getKey(); if (propertyKey.startsWith(SONAR_ANALYSIS) || propertyKey.startsWith(SONAR_PULL_REQUEST)) { analysisPropertyDtos.add(new AnalysisPropertyDto() .setUuid(uuidFactory.create()) .setKey(propertyKey) .setValue(contextProperty.getValue()) .setSnapshotUuid(analysisMetadataHolder.getUuid())); } }); if (analysisPropertyDtos.isEmpty()) { return; } try (DbSession dbSession = dbClient.openSession(false)) { dbClient.analysisPropertiesDao().insert(dbSession, analysisPropertyDtos); dbSession.commit(); } }