Skip to content

Commit

Permalink
Back port of Task Thin Execution List and List By Name
Browse files Browse the repository at this point in the history
Updates api docs for tasks/thinexecutions/name and all HATEOAS links. Updates related tests for links.
Update find by name to return 404 when task definition doesn't exist.
Update version checking in TaskTemplate.

Fixes #5995
  • Loading branch information
corneil committed Nov 12, 2024
1 parent 6e87904 commit afad738
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class TaskTemplate implements TaskOperations {
private static final String VALIDATION_THIN_TASK_VERSION = "2.11.3";

private static final String VALIDATION_TASK_LAUNCH_VERSION = "2.11.0";
private static final String VALIDATION_TASK_THIN_BY_NAME = "2.11.6";

private static final String EXECUTIONS_RELATION = "tasks/executions";

Expand Down Expand Up @@ -145,14 +146,43 @@ public class TaskTemplate implements TaskOperations {

this.restTemplate = restTemplate;
this.dataFlowServerVersion = dataFlowServerVersion;
String version = VersionUtils.getThreePartVersion(dataFlowServerVersion);
if (VersionUtils.isDataFlowServerVersionGreaterThanOrEqualToRequiredVersion(version, EXECUTIONS_CURRENT_RELATION_VERSION)) {
Assert.isTrue(resources.getLink(EXECUTIONS_CURRENT_RELATION).isPresent(), ()-> EXECUTIONS_CURRENT_RELATION + " relation is required");
this.executionsCurrentLink = resources.getLink(EXECUTIONS_CURRENT_RELATION).get();
} else {
this.executionsCurrentLink = null;
}
if (VersionUtils.isDataFlowServerVersionGreaterThanOrEqualToRequiredVersion(version, VALIDATION_RELATION_VERSION)) {
Assert.isTrue(resources.getLink(VALIDATION_REL).isPresent(), ()->VALIDATION_REL + " relation is required");
this.validationLink = resources.getLink(VALIDATION_REL).get();
} else {
this.validationLink = null;
}

this.validationLink = resources.getLink(VALIDATION_REL).get();
this.aboutLink = resources.getLink("about").get();

this.thinExecutionsLink = resources.getLink(THIN_EXECUTIONS_RELATION).orElse(null);
this.thinExecutionsByNameLink = resources.getLink(THIN_EXECUTIONS_BY_NAME_RELATION).orElse(null);
this.executionLaunchLink = resources.getLink(EXECUTION_LAUNCH_RELATION).orElse(null);
this.executionsCurrentLink = resources.getLink(EXECUTIONS_CURRENT_RELATION).orElse(null);
if(VersionUtils.isDataFlowServerVersionGreaterThanOrEqualToRequiredVersion(version, VALIDATION_THIN_TASK_VERSION) && resources.getLink(THIN_EXECUTIONS_RELATION).isPresent()) {
Assert.isTrue(resources.getLink(THIN_EXECUTIONS_RELATION).isPresent(), () -> THIN_EXECUTIONS_RELATION + " relation is required");
this.thinExecutionsLink = resources.getLink(THIN_EXECUTIONS_RELATION).get();
} else {
this.thinExecutionsLink = null;
}
if(VersionUtils.isDataFlowServerVersionGreaterThanOrEqualToRequiredVersion(version, VALIDATION_TASK_THIN_BY_NAME)) {
Assert.isTrue(resources.getLink(THIN_EXECUTIONS_BY_NAME_RELATION).isPresent(), () -> THIN_EXECUTIONS_BY_NAME_RELATION + " relation is required");
this.thinExecutionsByNameLink = resources.getLink(THIN_EXECUTIONS_BY_NAME_RELATION).get();
} else {
this.thinExecutionsByNameLink = null;
}

if (VersionUtils.isDataFlowServerVersionGreaterThanOrEqualToRequiredVersion(version, VALIDATION_TASK_LAUNCH_VERSION)) {
Assert.isTrue(resources.getLink(EXECUTION_LAUNCH_RELATION).isPresent(), () -> EXECUTION_LAUNCH_RELATION + " relation is required");
this.executionLaunchLink = resources.getLink(EXECUTION_LAUNCH_RELATION).get();
} else {
this.executionLaunchLink = null;
}


this.aboutLink = resources.getLink("about").get();

this.definitionsLink = resources.getLink(DEFINITIONS_RELATION).get();
this.definitionLink = resources.getLink(DEFINITION_RELATION).get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ public void testOldDataFlow() {

@Test
public void testMinDataFlow() {
validateExecutionLinkPresent("1.7.0");
validateExecutionLinkPresent("2.10.0");
}

@Test
public void testFutureDataFlow() {
validateExecutionLinkPresent("1.8.0");
validateExecutionLinkPresent("1.9.0");
validateExecutionLinkPresent("2.0.0");
validateExecutionLinkPresent("2.11.6");
}


Expand Down

0 comments on commit afad738

Please sign in to comment.