-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove corresponding issues on branch delete #1224
base: 9.x
Are you sure you want to change the base?
Changes from 10 commits
e8d187c
0100342
54788d6
ddb1859
487b222
e3ed550
eff0ef2
204b04f
7f56487
8500f18
f16b635
0e9f56b
c96bc96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.b2international.snowowl.core.branch; | ||
cmark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.eclipse.core.runtime.jobs.ISchedulingRule; | ||
|
||
import com.b2international.commons.CompareUtils; | ||
import com.b2international.snowowl.core.ServiceProvider; | ||
import com.b2international.snowowl.core.events.AsyncRequest; | ||
import com.b2international.snowowl.core.identity.User; | ||
import com.b2international.snowowl.core.jobs.JobRequests; | ||
import com.b2international.snowowl.core.jobs.SerializableSchedulingRule; | ||
import com.b2international.snowowl.core.validation.ValidationRequests; | ||
import com.google.common.base.Joiner; | ||
|
||
public class ValidationCleanupService { | ||
|
||
public static final SerializableSchedulingRule VALIDATION_ISSUE_CLEANUP_RULE = new SerializableSchedulingRule() { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public boolean isConflicting(ISchedulingRule rule) { | ||
return rule == this; | ||
} | ||
|
||
@Override | ||
public boolean contains(ISchedulingRule rule) { | ||
return rule == this; | ||
} | ||
}; | ||
|
||
public ValidationCleanupService() { | ||
} | ||
|
||
public void scheduleStaleIssueRemoval(ServiceProvider context, String resourceURI) { | ||
scheduleStaleIssueRemoval(context, List.of(resourceURI), Collections.emptyList()); | ||
} | ||
|
||
public void scheduleStaleIssueRemoval(ServiceProvider context, List<String> resourceURIs) { | ||
scheduleStaleIssueRemoval(context, resourceURIs, Collections.emptyList()); | ||
} | ||
Check warning on line 43 in core/com.b2international.snowowl.core/src/com/b2international/snowowl/core/branch/ValidationCleanupService.java Codecov / codecov/patchcore/com.b2international.snowowl.core/src/com/b2international/snowowl/core/branch/ValidationCleanupService.java#L42-L43
|
||
|
||
public void scheduleStaleIssueRemoval(ServiceProvider context, String resourceURI, List<String> resultIds) { | ||
scheduleStaleIssueRemoval(context, List.of(resourceURI), resultIds); | ||
} | ||
Check warning on line 47 in core/com.b2international.snowowl.core/src/com/b2international/snowowl/core/branch/ValidationCleanupService.java Codecov / codecov/patchcore/com.b2international.snowowl.core/src/com/b2international/snowowl/core/branch/ValidationCleanupService.java#L46-L47
|
||
|
||
public void scheduleStaleIssueRemoval(ServiceProvider context, List<String> resourceURIs, List<String> resultIds) { | ||
AsyncRequest<Boolean> request; | ||
|
||
if (!CompareUtils.isEmpty(resultIds)) { | ||
request = ValidationRequests.issues() | ||
.prepareDelete() | ||
.setResultIds(resultIds) | ||
.buildAsync(); | ||
} else { | ||
Check warning on line 57 in core/com.b2international.snowowl.core/src/com/b2international/snowowl/core/branch/ValidationCleanupService.java Codecov / codecov/patchcore/com.b2international.snowowl.core/src/com/b2international/snowowl/core/branch/ValidationCleanupService.java#L53-L57
|
||
if (CompareUtils.isEmpty(resourceURIs)) { | ||
return; | ||
Check warning on line 59 in core/com.b2international.snowowl.core/src/com/b2international/snowowl/core/branch/ValidationCleanupService.java Codecov / codecov/patchcore/com.b2international.snowowl.core/src/com/b2international/snowowl/core/branch/ValidationCleanupService.java#L59
|
||
} | ||
|
||
request = ValidationRequests.issues() | ||
.prepareDelete() | ||
.setCodeSystemURIs(resourceURIs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing good, we shouldn't delete without resource uri filters. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, but that's a flaw in the API. If the caller should only use one input parameter, then we should split this method into two separate implementations instead of merging them into one with if else blocks. |
||
.buildAsync(); | ||
} | ||
|
||
final String description = String.format("Remove validation issues on stale/removed branch(es) of %s", Joiner.on(", ").join(resourceURIs)); | ||
|
||
JobRequests.prepareSchedule() | ||
.setRequest(request) | ||
.setDescription(description) | ||
.setAutoClean(true) | ||
.setSchedulingRule(VALIDATION_ISSUE_CLEANUP_RULE) | ||
.build() | ||
.execute(context); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we have to treat the new tilde path variants (
XZX~branch
) as well here. Could you please add support for that?