Skip to content

Commit

Permalink
Use projections / result class to determine ProjectVersions
Browse files Browse the repository at this point in the history
Co-authored-by: Niklas <[email protected]>
Signed-off-by: Walter de Boer <[email protected]>
  • Loading branch information
Walter de Boer and nscuro committed Jun 27, 2023
1 parent c02fe38 commit 32284b4
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.github.packageurl.PackageURL;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.datanucleus.api.jdo.JDOQuery;
import org.dependencytrack.auth.Permissions;
import org.dependencytrack.event.IndexEvent;
import org.dependencytrack.model.Analysis;
Expand Down Expand Up @@ -1122,9 +1121,10 @@ private static boolean hasActiveChild(Project project) {
}

private List<ProjectVersion> getProjectVersions(Project project) {
final Query<Object[]> query = pm.newQuery(JDOQuery.SQL, "SELECT UUID, VERSION FROM PROJECT WHERE NAME = ?");
final Query<Project> query = pm.newQuery(Project.class);
query.setFilter("name == :name");
query.setParameters(project.getName());
final var stream = query.executeList().stream();
return stream.map(i -> new ProjectVersion(i[0].toString(), i[1].toString())).toList();
query.setResult("uuid, version");
return query.executeList(ProjectVersion.class);
}
}

0 comments on commit 32284b4

Please sign in to comment.