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

View File

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

View File

@ -13,8 +13,8 @@
</nav> </nav>
<div *ngIf="conf" style="margin-top: 2em;"> <div *ngIf="conf" style="margin-top: 2em;">
<button mat-stroked-button color="primary" (click)="launchWf()"> <button mat-stroked-button color="primary" (click)="launchWfConf()">
<mat-icon fontIcon="add"></mat-icon> <mat-icon fontIcon="play_circle"></mat-icon>
launch launch
</button> </button>
<button mat-stroked-button color="primary" (click)="editConf()"> <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 { MatSelectChange } from '@angular/material/select';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute, Router } from '@angular/router'; 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 { ISService } from '../common/is.service';
import { ResMetadataDialog } from '../resources/resources.component'; import { ResMetadataDialog } from '../resources/resources.component';
@ -74,14 +74,10 @@ export class WfConfsComponent implements OnInit {
}); });
} }
launchWfConf() {
launchWf() { if (this.conf?.id && this.conf?.workflow) {
if (this.conf?.workflow) this.service.startWfConfiguration(this.conf?.id, (data: WfProcessStatus) => this.snackBar.open('Workflow launched !!!', 'INFO', { duration: 5000 }));
this._launchWf(this.conf.workflow);
} }
_launchWf(wfId: string) {
} }
editConf() { editConf() {
@ -93,8 +89,9 @@ export class WfConfsComponent implements OnInit {
deleteConf() { deleteConf() {
if (this.conf?.destroyWf) { if (this.conf?.destroyWf) {
this._launchWf(this.conf.destroyWf); if (this.conf?.id && this.conf?.workflow) {
this.snackBar.open('Destroy Workflow launched, PLEASE WAIT !!!', 'INFO', { duration: 5000 }); this.service.startDestroyWfConfiguration(this.conf?.id, (data: WfProcessStatus) => this.snackBar.open('Destroy Workflow launched, PLEASE WAIT !!!', 'INFO', { duration: 5000 }));
}
} else if (this.conf?.id) { } else if (this.conf?.id) {
this.service.deleteWfConfiguration(this.conf?.id, (data: void) => { this.service.deleteWfConfiguration(this.conf?.id, (data: void) => {
this.snackBar.open('Configuration deleted !!!', 'INFO', { duration: 5000 }); 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, public ExecutionStatus startRepoHiWorkflow(final String wfId,
final String dsId, final String dsId,
final String apiId, final String apiId,
final ExecutionCallback<WorkflowProcess> callback) final ExecutionCallback<WorkflowProcess> callback) throws WorkflowManagerException {
throws WorkflowManagerException {
if (isPaused()) { if (isPaused()) {
log.warn("Wf " + wfId + " not launched, because WorkflowExecutor is preparing for shutdown"); 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.setSystemParams(new HashMap<>());
conf.setUserParams(new HashMap<>()); conf.setUserParams(new HashMap<>());
return startWorkflowConfiguration(conf, callback); return startWorkflow(wfId, conf, callback);
} catch (final DsmException e) { } catch (final DsmException e) {
throw new WorkflowManagerException("Invalid datasource: " + dsId, e); throw new WorkflowManagerException("Invalid datasource: " + dsId, e);
} }
} }
public ExecutionStatus startWorkflowConfiguration(final String wfConfId, public ExecutionStatus startWorkflowConfiguration(final String wfConfId) throws WorkflowManagerException {
final String parent, return startWorkflowConfiguration(findWorkflowConfiguration(wfConfId));
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");
} }
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); final WorkflowConfiguration conf = findWorkflowConfiguration(wfConfId);
return startWorkflow(conf.getDestroyWf(), conf, null);
return startWorkflowConfiguration(conf, callback);
} }
public ExecutionStatus startWorkflowConfiguration(final WorkflowConfiguration conf, public ExecutionStatus startWorkflow(final String wfId,
final WorkflowConfiguration conf,
final ExecutionCallback<WorkflowProcess> callback) final ExecutionCallback<WorkflowProcess> callback)
throws WorkflowManagerException { throws WorkflowManagerException {
@ -144,11 +143,11 @@ public class WorkflowManagerService implements Stoppable {
} }
final SimpleResource wfMetadata = simpleResourceRepository final SimpleResource wfMetadata = simpleResourceRepository
.findById(conf.getWorkflow()) .findById(wfId)
.filter(r -> r.getType().equals("workflows")) .filter(r -> r.getType().equals("wf_template"))
.orElseThrow(() -> new WorkflowManagerException("WF not found: " + conf.getWorkflow())); .orElseThrow(() -> new WorkflowManagerException("WF not found: " + conf.getWorkflow()));
final WorkflowTemplate wfTmpl = simpleResourceRepository.findContentById(wfMetadata.getId()) final WorkflowTemplate wfTmpl = simpleResourceRepository.findContentById(wfId)
.map(s -> { .map(s -> {
try { try {
return new ObjectMapper().readValue(s, WorkflowTemplate.class); return new ObjectMapper().readValue(s, WorkflowTemplate.class);
@ -157,7 +156,7 @@ public class WorkflowManagerService implements Stoppable {
} }
}) })
.filter(Objects::nonNull) .filter(Objects::nonNull)
.orElseThrow(() -> new WorkflowManagerException("Invalid wf: " + wfMetadata.getId())); .orElseThrow(() -> new WorkflowManagerException("Invalid wf: " + wfId));
final WorkflowProcess process = final WorkflowProcess process =
processFactory.newProcess(wfMetadata, wfTmpl, conf, callback); processFactory.newProcess(wfMetadata, wfTmpl, conf, callback);
@ -199,7 +198,7 @@ public class WorkflowManagerService implements Stoppable {
this.paused = paused; this.paused = paused;
} }
public List<WorkflowSection> listSsections() { public List<WorkflowSection> listSections() {
return workflowSectionRepository.findAll(); return workflowSectionRepository.findAll();
} }

View File

@ -51,7 +51,7 @@ public class ScheduledWorkflowLauncher {
.filter(this::isReady) .filter(this::isReady)
.forEach(conf -> { .forEach(conf -> {
try { try {
wfManagerService.startWorkflowConfiguration(conf, null); wfManagerService.startWorkflowConfiguration(conf);
} catch (final Exception e) { } catch (final Exception e) {
log.error("Error launching scheduled wf conf: " + conf.getId(), 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.setSystemParams(process.getGlobalParams());
conf.setUserParams(new HashMap<>()); conf.setUserParams(new HashMap<>());
final ExecutionStatus info = wfManagerService.startWorkflowConfiguration(conf, new ExecutionCallback<WorkflowProcess>() { final ExecutionStatus info = wfManagerService.startWorkflow(wfId, conf, new ExecutionCallback<WorkflowProcess>() {
@Override @Override
public void onSuccess(final WorkflowProcess t) { public void onSuccess(final WorkflowProcess t) {