Skip to content
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

Closes #372 - Add Distribution for tasks #373

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jannikFuellgrafEnvite
Copy link
Contributor

@jannikFuellgrafEnvite jannikFuellgrafEnvite commented Jan 7, 2025

Thanks for your PR! Please fill out the following list :)



@jannikFuellgrafEnvite jannikFuellgrafEnvite force-pushed the kad/distribute-tasks-no-transfer-flag-change branch 10 times, most recently from da4edc2 to 36d24f4 Compare January 22, 2025 07:14
@@ -52,6 +56,16 @@ public static WorkbasketBuilder defaultTestWorkbasket() {
.orgLevel1("company");
}

public static TaskBuilder defaultTask(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's talk about this

// Distribute tasks based on the provided parameters
BulkOperationResults<String, KadaiException> result;

if (destinationWorkbasketIds != null && distributionStrategyName != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can refactor this in a separate method, let's discuss :)

@jannikFuellgrafEnvite jannikFuellgrafEnvite force-pushed the kad/distribute-tasks-no-transfer-flag-change branch 6 times, most recently from 10ded54 to 8316c7e Compare January 28, 2025 11:00
@jannikFuellgrafEnvite jannikFuellgrafEnvite linked an issue Jan 29, 2025 that may be closed by this pull request

if (taskDistributionProviderList.isEmpty()) {
LOGGER.info(
"No Custom TaskDistribution Provider found. Running wit DefaultTaskDistributionProvider");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"No Custom TaskDistribution Provider found. Running wit DefaultTaskDistributionProvider");
"No Custom TaskDistribution Provider found. Running with DefaultTaskDistributionProvider");

* <li>{@code sourceWorkbasketId} ({@code String}): The ID of the source workbasket. Must be
* set if {@code taskIds} is null.
* <li>{@code taskIds} ({@code List<String>}): A list of task IDs to be distributed. Must be
* set if {@code sourceWorkbasketId} is null. The other parameter must be null to ensure
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this description still correct considering the sourceWorkasbasketId must now always be provided? Refers to complete description, e.g. line 1079,1112 as well etc.

@PostMapping(path = RestEndpoints.URL_DISTRIBUTE)
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<BulkOperationResultsRepresentationModel> distributeTasks(
@Valid @RequestBody DistributionTasksRepresentationModel distributionTasksRepresentationModel,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the @Valid here? I don't see the Model expressing any constraints. Would it even work?

if (taskIds.isEmpty()) {
return operationResults;
} else {
checkIfTasksInSameWorkbasket(taskIds);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two checks will also be performed, if no taskIds are provided and retrieved via the sourceWorkbasket, but we don't need it in this case, right?

@jannikFuellgrafEnvite jannikFuellgrafEnvite force-pushed the kad/distribute-tasks-no-transfer-flag-change branch 3 times, most recently from 86a9be0 to 9a24ce9 Compare February 3, 2025 15:02
@jannikFuellgrafEnvite jannikFuellgrafEnvite force-pushed the kad/distribute-tasks-no-transfer-flag-change branch from 9a24ce9 to 77441b0 Compare February 12, 2025 16:09
@jannikFuellgrafEnvite jannikFuellgrafEnvite force-pushed the kad/distribute-tasks-no-transfer-flag-change branch from 77441b0 to 1df144f Compare February 13, 2025 13:45
} else {
LOGGER.info("No distribution strategy specified. Using default distribution.");
newTaskDistribution =
new DefaultTaskDistributionProvider()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't you add the default provider to the list of provider? In that case you don't even need a if-then-else block?

* workbasket.
* @param destinationWorkbasketIds A list of {@linkplain Workbasket#getId() Ids} of the
* destination workbaskets where tasks will be distributed.
* @param distributionStrategyName The name of the custom distribution strategy to be applied. The
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The strategy name is always the full qualified class name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the class, the simple name is sufficient. I have adjusted and specified the description accordingly.

@jannikFuellgrafEnvite jannikFuellgrafEnvite force-pushed the kad/distribute-tasks-no-transfer-flag-change branch from 1df144f to e6d9315 Compare February 13, 2025 16:37
Comment on lines 434 to 465
if (taskIds == null) {
if (destinationWorkbasketIds != null && distributionStrategyName != null) {
result =
taskService.distribute(
workbasketId,
destinationWorkbasketIds,
distributionStrategyName,
additionalInformation);
} else if (destinationWorkbasketIds != null) {
result = taskService.distributeWithDestinations(workbasketId, destinationWorkbasketIds);
} else if (distributionStrategyName != null) {
result =
taskService.distributeWithStrategy(
workbasketId, distributionStrategyName, additionalInformation);
} else {
result = taskService.distribute(workbasketId);
}
} else {
if (destinationWorkbasketIds != null && distributionStrategyName != null) {
result =
taskService.distribute(
workbasketId,
taskIds,
destinationWorkbasketIds,
distributionStrategyName,
additionalInformation);
} else if (destinationWorkbasketIds != null) {
result =
taskService.distributeWithDestinations(workbasketId, taskIds, destinationWorkbasketIds);
} else if (distributionStrategyName != null) {
result =
taskService.distributeWithStrategy(
workbasketId, taskIds, distributionStrategyName, additionalInformation);
} else {
result = taskService.distribute(workbasketId, taskIds);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to extract this in a private method and simplify the if else chain, so that all possibilities are more clearly expressed in code.

@jannikFuellgrafEnvite jannikFuellgrafEnvite force-pushed the kad/distribute-tasks-no-transfer-flag-change branch from e6d9315 to 87ed38a Compare February 24, 2025 10:27
@jannikFuellgrafEnvite jannikFuellgrafEnvite force-pushed the kad/distribute-tasks-no-transfer-flag-change branch from 87ed38a to a7f9c9f Compare February 24, 2025 10:30
Copy link
Contributor

@CRoberto1926 CRoberto1926 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sieht gut aus 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Distribution for Tasks
4 participants