ui to start wfs

This commit is contained in:
Michele Artini 2023-03-30 14:59:57 +02:00
parent cdb3381d3e
commit 94a78beb16
7 changed files with 43 additions and 41 deletions

View File

@ -28,7 +28,7 @@ public class WfConfigurationsController extends AbstractDnetController {
@GetMapping("/sections")
public List<WorkflowSection> listWfSections() throws Exception {
return wfManagerService.listSsections();
return wfManagerService.listSections();
}
@GetMapping("/sections/{section}")
@ -56,7 +56,12 @@ public class WfConfigurationsController extends AbstractDnetController {
@GetMapping("/conf/{id}/start")
public ExecutionStatus startWorkflowConfiguration(@PathVariable final String id) throws Exception {
return wfManagerService.startWorkflowConfiguration(id, null, null);
return wfManagerService.startWorkflowConfiguration(id);
}
@GetMapping("/conf/{id}/destroy")
public ExecutionStatus destroyWorkflowConfiguration(@PathVariable final String id) throws Exception {
return wfManagerService.destroyWorkflowConfiguration(id);
}
@GetMapping("/process/{id}")

View File

@ -10,16 +10,13 @@ import { firstValueFrom, Observable } from 'rxjs';
})
export class ISService {
constructor(public client: HttpClient, public snackBar: MatSnackBar) {
}
loadResourceTypes(onSuccess: Function) {
this.httpGet<ResourceType[]>("/ajax/resourceTypes", onSuccess)
}
loadResourceType(id: string, onSuccess: Function) {
this.httpGet<ResourceType>("/ajax/resourceTypes/" + encodeURIComponent(id), onSuccess);
}
@ -248,6 +245,10 @@ export class ISService {
this.httpGet<WfProcessStatus>('./ajax/wfs/conf/' + encodeURIComponent(id) + '/start', onSuccess);
}
startDestroyWfConfiguration(id: string, onSuccess: Function): void {
this.httpGet<WfProcessStatus>('./ajax/wfs/conf/' + encodeURIComponent(id) + '/destroy', onSuccess);
}
findProcess(id: string, onSuccess: Function): void {
this.httpGet<WfProcessStatus>('./ajax/wfs/process/' + encodeURIComponent(id), onSuccess);
}

View File

@ -13,8 +13,8 @@
</nav>
<div *ngIf="conf" style="margin-top: 2em;">
<button mat-stroked-button color="primary" (click)="launchWf()">
<mat-icon fontIcon="add"></mat-icon>
<button mat-stroked-button color="primary" (click)="launchWfConf()">
<mat-icon fontIcon="play_circle"></mat-icon>
launch
</button>
<button mat-stroked-button color="primary" (click)="editConf()">

View File

@ -5,7 +5,7 @@ import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dial
import { MatSelectChange } from '@angular/material/select';
import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute, Router } from '@angular/router';
import { KeyValue, SimpleResource, WfConf, WfParam, WfSection } from '../common/is.model';
import { KeyValue, SimpleResource, WfConf, WfParam, WfProcessStatus, WfSection } from '../common/is.model';
import { ISService } from '../common/is.service';
import { ResMetadataDialog } from '../resources/resources.component';
@ -74,14 +74,10 @@ export class WfConfsComponent implements OnInit {
});
}
launchWf() {
if (this.conf?.workflow)
this._launchWf(this.conf.workflow);
}
_launchWf(wfId: string) {
launchWfConf() {
if (this.conf?.id && this.conf?.workflow) {
this.service.startWfConfiguration(this.conf?.id, (data: WfProcessStatus) => this.snackBar.open('Workflow launched !!!', 'INFO', { duration: 5000 }));
}
}
editConf() {
@ -93,8 +89,9 @@ export class WfConfsComponent implements OnInit {
deleteConf() {
if (this.conf?.destroyWf) {
this._launchWf(this.conf.destroyWf);
this.snackBar.open('Destroy Workflow launched, PLEASE WAIT !!!', 'INFO', { duration: 5000 });
if (this.conf?.id && this.conf?.workflow) {
this.service.startDestroyWfConfiguration(this.conf?.id, (data: WfProcessStatus) => this.snackBar.open('Destroy Workflow launched, PLEASE WAIT !!!', 'INFO', { duration: 5000 }));
}
} else if (this.conf?.id) {
this.service.deleteWfConfiguration(this.conf?.id, (data: void) => {
this.snackBar.open('Configuration deleted !!!', 'INFO', { duration: 5000 });

View File

@ -86,8 +86,7 @@ public class WorkflowManagerService implements Stoppable {
public ExecutionStatus startRepoHiWorkflow(final String wfId,
final String dsId,
final String apiId,
final ExecutionCallback<WorkflowProcess> callback)
throws WorkflowManagerException {
final ExecutionCallback<WorkflowProcess> callback) throws WorkflowManagerException {
if (isPaused()) {
log.warn("Wf " + wfId + " not launched, because WorkflowExecutor is preparing for shutdown");
@ -114,27 +113,27 @@ public class WorkflowManagerService implements Stoppable {
conf.setSystemParams(new HashMap<>());
conf.setUserParams(new HashMap<>());
return startWorkflowConfiguration(conf, callback);
return startWorkflow(wfId, conf, callback);
} catch (final DsmException e) {
throw new WorkflowManagerException("Invalid datasource: " + dsId, e);
}
}
public ExecutionStatus startWorkflowConfiguration(final String wfConfId,
final String parent,
final ExecutionCallback<WorkflowProcess> callback) throws Exception {
if (isPaused()) {
log.warn("Wf configuration " + wfConfId + " not launched, because WorkflowExecutor is preparing for shutdown");
throw new WorkflowManagerException("WorkflowExecutor is preparing for shutdown");
}
final WorkflowConfiguration conf = findWorkflowConfiguration(wfConfId);
return startWorkflowConfiguration(conf, callback);
public ExecutionStatus startWorkflowConfiguration(final String wfConfId) throws WorkflowManagerException {
return startWorkflowConfiguration(findWorkflowConfiguration(wfConfId));
}
public ExecutionStatus startWorkflowConfiguration(final WorkflowConfiguration conf,
public ExecutionStatus startWorkflowConfiguration(final WorkflowConfiguration conf) throws WorkflowManagerException {
return startWorkflow(conf.getWorkflow(), conf, null);
}
public ExecutionStatus destroyWorkflowConfiguration(final String wfConfId) throws WorkflowManagerException {
final WorkflowConfiguration conf = findWorkflowConfiguration(wfConfId);
return startWorkflow(conf.getDestroyWf(), conf, null);
}
public ExecutionStatus startWorkflow(final String wfId,
final WorkflowConfiguration conf,
final ExecutionCallback<WorkflowProcess> callback)
throws WorkflowManagerException {
@ -144,11 +143,11 @@ public class WorkflowManagerService implements Stoppable {
}
final SimpleResource wfMetadata = simpleResourceRepository
.findById(conf.getWorkflow())
.filter(r -> r.getType().equals("workflows"))
.findById(wfId)
.filter(r -> r.getType().equals("wf_template"))
.orElseThrow(() -> new WorkflowManagerException("WF not found: " + conf.getWorkflow()));
final WorkflowTemplate wfTmpl = simpleResourceRepository.findContentById(wfMetadata.getId())
final WorkflowTemplate wfTmpl = simpleResourceRepository.findContentById(wfId)
.map(s -> {
try {
return new ObjectMapper().readValue(s, WorkflowTemplate.class);
@ -157,7 +156,7 @@ public class WorkflowManagerService implements Stoppable {
}
})
.filter(Objects::nonNull)
.orElseThrow(() -> new WorkflowManagerException("Invalid wf: " + wfMetadata.getId()));
.orElseThrow(() -> new WorkflowManagerException("Invalid wf: " + wfId));
final WorkflowProcess process =
processFactory.newProcess(wfMetadata, wfTmpl, conf, callback);
@ -199,7 +198,7 @@ public class WorkflowManagerService implements Stoppable {
this.paused = paused;
}
public List<WorkflowSection> listSsections() {
public List<WorkflowSection> listSections() {
return workflowSectionRepository.findAll();
}

View File

@ -51,7 +51,7 @@ public class ScheduledWorkflowLauncher {
.filter(this::isReady)
.forEach(conf -> {
try {
wfManagerService.startWorkflowConfiguration(conf, null);
wfManagerService.startWorkflowConfiguration(conf);
} catch (final Exception e) {
log.error("Error launching scheduled wf conf: " + conf.getId(), e);
}

View File

@ -51,7 +51,7 @@ public class LaunchWorkflowJobNode extends ProcessNode implements ProcessAware {
conf.setSystemParams(process.getGlobalParams());
conf.setUserParams(new HashMap<>());
final ExecutionStatus info = wfManagerService.startWorkflowConfiguration(conf, new ExecutionCallback<WorkflowProcess>() {
final ExecutionStatus info = wfManagerService.startWorkflow(wfId, conf, new ExecutionCallback<WorkflowProcess>() {
@Override
public void onSuccess(final WorkflowProcess t) {