mirror of
https://github.com/DependencyTrack/dependency-track.git
synced 2025-10-19 16:03:19 +00:00
Replace manual transaction commits with callInTransaction
This is to properly support nested transactions as introduced in https://github.com/stevespringett/Alpine/pull/552. Signed-off-by: nscuro <nscuro@protonmail.com>
This commit is contained in:
parent
31b676f0c4
commit
d82d32a06c
6 changed files with 62 additions and 78 deletions
|
@ -816,25 +816,26 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
* @param project a Project object
|
||||
* @param tags a List of Tag objects
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void bind(Project project, List<Tag> tags) {
|
||||
final Query<Tag> query = pm.newQuery(Tag.class, "projects.contains(:project)");
|
||||
final List<Tag> currentProjectTags = (List<Tag>)query.execute(project);
|
||||
pm.currentTransaction().begin();
|
||||
for (final Tag tag: currentProjectTags) {
|
||||
if (!tags.contains(tag)) {
|
||||
tag.getProjects().remove(project);
|
||||
runInTransaction(() -> {
|
||||
final Query<Tag> query = pm.newQuery(Tag.class, "projects.contains(:project)");
|
||||
query.setParameters(project);
|
||||
final List<Tag> currentProjectTags = executeAndCloseList(query);
|
||||
|
||||
for (final Tag tag : currentProjectTags) {
|
||||
if (!tags.contains(tag)) {
|
||||
tag.getProjects().remove(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
project.setTags(tags);
|
||||
for (final Tag tag: tags) {
|
||||
final List<Project> projects = tag.getProjects();
|
||||
if (!projects.contains(project)) {
|
||||
projects.add(project);
|
||||
project.setTags(tags);
|
||||
for (final Tag tag : tags) {
|
||||
final List<Project> projects = tag.getProjects();
|
||||
if (!projects.contains(project)) {
|
||||
projects.add(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
pm.currentTransaction().commit();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue