This commit is contained in:
parent
bc9fe2c716
commit
b7e7612a12
|
@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.DeleteMapping;
|
|||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
@ -17,7 +18,6 @@ import eu.dnetlib.manager.wf.model.WorkflowConfiguration;
|
|||
import eu.dnetlib.manager.wf.model.WorkflowSection;
|
||||
import eu.dnetlib.manager.wf.model.WorkflowSubscription;
|
||||
import eu.dnetlib.manager.wf.workflows.procs.ExecutionStatus;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/ajax/wfs")
|
||||
|
@ -45,8 +45,8 @@ public class WfConfigurationsController extends AbstractDnetController {
|
|||
}
|
||||
|
||||
@PostMapping("/conf")
|
||||
public void saveWfConfiguration(@RequestBody final WorkflowConfiguration conf) throws Exception {
|
||||
wfManagerService.saveWfConfiguration(conf);
|
||||
public WorkflowConfiguration saveWfConfiguration(@RequestBody final WorkflowConfiguration conf) throws Exception {
|
||||
return wfManagerService.saveWfConfiguration(conf);
|
||||
}
|
||||
|
||||
@DeleteMapping("/conf/{id}")
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<h2>{{section?.name}}: Configured Workflows</h2>
|
||||
{{confs}}
|
||||
|
||||
<button mat-stroked-button color="primary" (click)="openAddWfConfDialog()">
|
||||
<mat-icon fontIcon="add"></mat-icon>
|
||||
configure a new workflow
|
||||
</button>
|
||||
|
||||
<nav mat-tab-nav-bar *ngIf="confs.length > 0">
|
||||
<a mat-tab-link *ngFor="let c of confs" [routerLink]="['/wfs/conf', c.k]" routerLinkActive #rla="routerLinkActive"
|
||||
[active]="rla.isActive">
|
||||
|
@ -7,13 +12,8 @@
|
|||
</a>
|
||||
</nav>
|
||||
|
||||
<button mat-stroked-button color="primary" (click)="openAddWfConfDialog()">
|
||||
<mat-icon fontIcon="add"></mat-icon>
|
||||
configure a new workflow
|
||||
</button>
|
||||
|
||||
<div *ngIf="conf">
|
||||
{{conf}}
|
||||
<div *ngIf="conf" style="margin-top: 2em;">
|
||||
{{conf | json}}
|
||||
</div>
|
||||
|
||||
<div *ngIf="!conf" style="margin-top: 2em;">
|
||||
|
|
|
@ -117,10 +117,8 @@ export class WfConfDialog implements OnInit {
|
|||
this.wfConfFormStep2.get('enabled')?.setValue(data.enabled);
|
||||
this.wfConfFormStep2.get('priority')?.setValue(data.priority);
|
||||
//details
|
||||
|
||||
//systemParams,
|
||||
//userParams
|
||||
|
||||
this.wfConfFormStep4.get('schedulingEnabled')?.setValue(data.schedulingEnabled);
|
||||
this.wfConfFormStep4.get('cronExpression')?.setValue(data.cronExpression);
|
||||
this.wfConfFormStep4.get('cronMinInterval')?.setValue(data.cronMinInterval);
|
||||
|
@ -138,9 +136,6 @@ export class WfConfDialog implements OnInit {
|
|||
this.wfParameters = JSON.parse(data).parameters;
|
||||
}
|
||||
|
||||
|
||||
console.log(this.wfParameters);
|
||||
|
||||
this.wfConfFormStep3.controls = {};
|
||||
|
||||
this.wfParameters.forEach(p => {
|
||||
|
@ -153,8 +148,12 @@ export class WfConfDialog implements OnInit {
|
|||
}
|
||||
|
||||
onSubmit(): void {
|
||||
const conf = Object.assign({}, this.data, this.wfConfFormStep1.value, this.wfConfFormStep2.value, this.wfConfFormStep3.value, this.wfConfFormStep4.value);
|
||||
this.service.saveWfConfiguration(conf, (data: void) => this.dialogRef.close(1), this.wfConfFormFinal);
|
||||
const conf = Object.assign({}, this.data, this.wfConfFormStep1.value, this.wfConfFormStep2.value, this.wfConfFormStep4.value);
|
||||
conf.details = {};
|
||||
conf.systemParams = {};
|
||||
conf.userParams = this.wfConfFormStep3.value;
|
||||
|
||||
this.service.saveWfConfiguration(conf, (data: void) => this.dialogRef.close(data), this.wfConfFormFinal);
|
||||
}
|
||||
|
||||
onNoClick(): void {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package eu.dnetlib.manager.wf.model;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
class WorkflowConfigurationTest {
|
||||
|
||||
private final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@BeforeEach
|
||||
private void setUp() throws Exception {}
|
||||
|
||||
@Test
|
||||
final void test() throws IOException {
|
||||
final WorkflowConfiguration conf =
|
||||
mapper.readValue(IOUtils.toString(getClass().getResourceAsStream("test-conf.json"), "UTF-8"), WorkflowConfiguration.class);
|
||||
|
||||
System.out.println(conf.getName());
|
||||
assertNotNull(conf.getName());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"id": "",
|
||||
"name": "fffff",
|
||||
"section": "GC",
|
||||
"enabled": true,
|
||||
"priority": 75,
|
||||
"workflow": "09991db4-79e6-4e7c-a388-5063955bf9d8",
|
||||
"schedulingEnabled": true,
|
||||
"cronExpression": "0 30 12 1/1 * ?",
|
||||
"cronMinInterval": 9600,
|
||||
"details": {
|
||||
|
||||
},
|
||||
"configured": true,
|
||||
"systemParams": {
|
||||
|
||||
},
|
||||
"userParams": {
|
||||
"Name": "xxx",
|
||||
"Age": "xxx",
|
||||
"Birthday": "xxxx"
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import javax.annotation.PostConstruct;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -206,8 +207,19 @@ public class WorkflowManagerService implements Stoppable {
|
|||
return workflowConfigurationRepository.findBySection(section);
|
||||
}
|
||||
|
||||
public void saveWfConfiguration(final WorkflowConfiguration conf) {
|
||||
public WorkflowConfiguration saveWfConfiguration(final WorkflowConfiguration conf) {
|
||||
if (StringUtils.isBlank(conf.getId())) {
|
||||
conf.setId("wfconf-" + UUID.randomUUID());
|
||||
}
|
||||
checkConfiguration(conf);
|
||||
|
||||
workflowConfigurationRepository.save(conf);
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
||||
private void checkConfiguration(final WorkflowConfiguration conf) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
Loading…
Reference in New Issue