-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b680ddc
commit 59274ec
Showing
4 changed files
with
360 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...endencytrack/persistence/jdbi/mapping/NotificationSubjectProjectAuditChangeRowMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.dependencytrack.persistence.jdbi.mapping; | ||
|
||
import org.dependencytrack.proto.notification.v1.Component; | ||
import org.dependencytrack.proto.notification.v1.Project; | ||
import org.dependencytrack.proto.notification.v1.Vulnerability; | ||
import org.dependencytrack.proto.notification.v1.VulnerabilityAnalysis; | ||
import org.dependencytrack.proto.notification.v1.VulnerabilityAnalysisDecisionChangeSubject; | ||
import org.jdbi.v3.core.mapper.RowMapper; | ||
import org.jdbi.v3.core.statement.StatementContext; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
|
||
import static org.dependencytrack.persistence.jdbi.mapping.RowMapperUtil.maybeSet; | ||
|
||
public class NotificationSubjectProjectAuditChangeRowMapper implements RowMapper<VulnerabilityAnalysisDecisionChangeSubject> { | ||
|
||
@Override | ||
public VulnerabilityAnalysisDecisionChangeSubject map(final ResultSet rs, final StatementContext ctx) throws SQLException { | ||
final RowMapper<Component> componentRowMapper = ctx.findRowMapperFor(Component.class).orElseThrow(); | ||
final RowMapper<Project> projectRowMapper = ctx.findRowMapperFor(Project.class).orElseThrow(); | ||
final RowMapper<Vulnerability> vulnRowMapper = ctx.findRowMapperFor(Vulnerability.class).orElseThrow(); | ||
final VulnerabilityAnalysis.Builder vulnAnalysisBuilder = VulnerabilityAnalysis.newBuilder() | ||
.setComponent(componentRowMapper.map(rs, ctx)) | ||
.setProject(projectRowMapper.map(rs, ctx)) | ||
.setVulnerability(vulnRowMapper.map(rs, ctx)); | ||
maybeSet(rs, "vulnAnalysisState", ResultSet::getString, vulnAnalysisBuilder::setState); | ||
maybeSet(rs, "isVulnAnalysisSuppressed", ResultSet::getBoolean, vulnAnalysisBuilder::setSuppressed); | ||
final VulnerabilityAnalysisDecisionChangeSubject.Builder builder = VulnerabilityAnalysisDecisionChangeSubject.newBuilder() | ||
.setComponent(componentRowMapper.map(rs, ctx)) | ||
.setProject(projectRowMapper.map(rs, ctx)) | ||
.setVulnerability(vulnRowMapper.map(rs, ctx)) | ||
.setAnalysis(vulnAnalysisBuilder); | ||
return builder.build(); | ||
} | ||
|
||
} |
Oops, something went wrong.