ajax methods for wfs
This commit is contained in:
parent
28598ddfea
commit
806f8e9227
|
@ -40,9 +40,9 @@ public class DsmAjaxController extends AbstractDnetController {
|
|||
private ProtocolService protocolService;
|
||||
|
||||
@GetMapping("/browsableFields")
|
||||
public List<KeyValue> browsableFields() {
|
||||
public List<KeyValue<String>> browsableFields() {
|
||||
return Arrays.stream(DsmBrowsableFields.values())
|
||||
.map(f -> new KeyValue(f.name(), f.desc))
|
||||
.map(f -> new KeyValue<>(f.name(), f.desc))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
@ -56,30 +56,30 @@ public class InfoAjaxController extends AbstractDnetController {
|
|||
return res;
|
||||
}
|
||||
|
||||
private InfoSection<KeyValue> jvm() {
|
||||
final InfoSection<KeyValue> jvm = new InfoSection<>("JVM");
|
||||
jvm.getData().add(new KeyValue("JVM Name", mxbean.getVmName()));
|
||||
jvm.getData().add(new KeyValue("JVM Vendor", mxbean.getVmVendor()));
|
||||
jvm.getData().add(new KeyValue("JVM Version", mxbean.getVmVersion()));
|
||||
jvm.getData().add(new KeyValue("JVM Spec Name", mxbean.getSpecName()));
|
||||
jvm.getData().add(new KeyValue("JVM Spec Vendor", mxbean.getSpecVendor()));
|
||||
jvm.getData().add(new KeyValue("JVM Spec Version", mxbean.getSpecVersion()));
|
||||
jvm.getData().add(new KeyValue("Running JVM Name", mxbean.getName()));
|
||||
jvm.getData().add(new KeyValue("Management Spec Version", mxbean.getManagementSpecVersion()));
|
||||
private InfoSection<KeyValue<String>> jvm() {
|
||||
final InfoSection<KeyValue<String>> jvm = new InfoSection<>("JVM");
|
||||
jvm.getData().add(new KeyValue<>("JVM Name", mxbean.getVmName()));
|
||||
jvm.getData().add(new KeyValue<>("JVM Vendor", mxbean.getVmVendor()));
|
||||
jvm.getData().add(new KeyValue<>("JVM Version", mxbean.getVmVersion()));
|
||||
jvm.getData().add(new KeyValue<>("JVM Spec Name", mxbean.getSpecName()));
|
||||
jvm.getData().add(new KeyValue<>("JVM Spec Vendor", mxbean.getSpecVendor()));
|
||||
jvm.getData().add(new KeyValue<>("JVM Spec Version", mxbean.getSpecVersion()));
|
||||
jvm.getData().add(new KeyValue<>("Running JVM Name", mxbean.getName()));
|
||||
jvm.getData().add(new KeyValue<>("Management Spec Version", mxbean.getManagementSpecVersion()));
|
||||
return jvm;
|
||||
}
|
||||
|
||||
private InfoSection<KeyValue> args() {
|
||||
final InfoSection<KeyValue> libs = new InfoSection<>("Arguments");
|
||||
libs.getData().add(new KeyValue("Input arguments", StringUtils.join(mxbean.getInputArguments(), " ")));
|
||||
private InfoSection<KeyValue<String>> args() {
|
||||
final InfoSection<KeyValue<String>> libs = new InfoSection<>("Arguments");
|
||||
libs.getData().add(new KeyValue<>("Input arguments", StringUtils.join(mxbean.getInputArguments(), " ")));
|
||||
return libs;
|
||||
}
|
||||
|
||||
private List<InfoSection<KeyValue>> props() {
|
||||
final List<InfoSection<KeyValue>> res = new ArrayList<>();
|
||||
private List<InfoSection<KeyValue<?>>> props() {
|
||||
final List<InfoSection<KeyValue<?>>> res = new ArrayList<>();
|
||||
|
||||
configurableEnvironment.getPropertySources().forEach(ps -> {
|
||||
final InfoSection<KeyValue> section = new InfoSection<>("Properties: " + ps.getName());
|
||||
final InfoSection<KeyValue<?>> section = new InfoSection<>("Properties: " + ps.getName());
|
||||
addAllProperties(section, ps);
|
||||
res.add(section);
|
||||
});
|
||||
|
@ -87,13 +87,13 @@ public class InfoAjaxController extends AbstractDnetController {
|
|||
return res;
|
||||
}
|
||||
|
||||
private void addAllProperties(final InfoSection<KeyValue> res, final PropertySource<?> ps) {
|
||||
private void addAllProperties(final InfoSection<KeyValue<?>> res, final PropertySource<?> ps) {
|
||||
if (ps instanceof CompositePropertySource) {
|
||||
final CompositePropertySource cps = (CompositePropertySource) ps;
|
||||
cps.getPropertySources().forEach(x -> addAllProperties(res, x));
|
||||
} else if (ps instanceof EnumerablePropertySource<?>) {
|
||||
final EnumerablePropertySource<?> eps = (EnumerablePropertySource<?>) ps;
|
||||
Arrays.asList(eps.getPropertyNames()).forEach(k -> res.getData().add(new KeyValue(k, eps.getProperty(k))));
|
||||
Arrays.asList(eps.getPropertyNames()).forEach(k -> res.getData().add(new KeyValue<>(k, eps.getProperty(k))));
|
||||
} else {}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package eu.dnetlib.is.info;
|
||||
|
||||
public class KeyValue {
|
||||
public class KeyValue<T> {
|
||||
|
||||
private final String k;
|
||||
private final Object v;
|
||||
private final T v;
|
||||
|
||||
public KeyValue(final String k, final Object v) {
|
||||
public KeyValue(final String k, final T v) {
|
||||
this.k = k;
|
||||
this.v = v;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class KeyValue {
|
|||
return k;
|
||||
}
|
||||
|
||||
public Object getV() {
|
||||
public T getV() {
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
package eu.dnetlib.manager.wf;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import eu.dnetlib.is.info.KeyValue;
|
||||
import eu.dnetlib.manager.wf.model.WorkflowInstance;
|
||||
import eu.dnetlib.utils.CountedValue;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/ajax/wf_instances")
|
||||
|
@ -22,9 +24,18 @@ public class WfInstancesController extends AbstractDnetController {
|
|||
return wfManagerService.findWorkflowInstance(id);
|
||||
}
|
||||
|
||||
@GetMapping("/families")
|
||||
public List<CountedValue> listWfFamilies() throws Exception {
|
||||
return wfManagerService.families();
|
||||
@GetMapping("/search")
|
||||
public List<KeyValue<String>> listWfInstances(@RequestParam final String section) throws Exception {
|
||||
return wfManagerService.streamWfInstancesBySection(section)
|
||||
.map(x -> new KeyValue<>(x.getId(), x.getName()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@GetMapping("/sections")
|
||||
public List<KeyValue<Long>> listWfFamilies() throws Exception {
|
||||
return wfManagerService.streamSections()
|
||||
.map(x -> new KeyValue<>(x.getValue(), x.getCount()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import { MdstoresComponent, MdstoreInspectorComponent, MDStoreVersionsDialog, Ad
|
|||
import { CleanerTesterComponent } from './cleaner-tester/cleaner-tester.component';
|
||||
import { EmailDialog, EmailsComponent } from './emails/emails.component';
|
||||
import { WfInstancesComponent } from './wf-instances/wf-instances.component';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
@ -100,7 +101,8 @@ import { WfInstancesComponent } from './wf-instances/wf-instances.component';
|
|||
ReactiveFormsModule,
|
||||
MatSnackBarModule,
|
||||
MatPaginatorModule,
|
||||
MatProgressSpinnerModule
|
||||
MatProgressSpinnerModule,
|
||||
MatTabsModule
|
||||
],
|
||||
providers: [{
|
||||
provide: HTTP_INTERCEPTORS,
|
||||
|
|
|
@ -350,6 +350,27 @@ export class ISService {
|
|||
});
|
||||
}
|
||||
|
||||
loadWfIntancesSections(onSuccess: Function): void {
|
||||
this.client.get<void>('./ajax/wf_instances/sections').subscribe({
|
||||
next: data => onSuccess(data),
|
||||
error: error => this.showError(error)
|
||||
});
|
||||
}
|
||||
|
||||
loadWfIntances(section: string, onSuccess: Function): void {
|
||||
this.client.get<void>('./ajax/wf_instances/search?section=' + encodeURIComponent(section)).subscribe({
|
||||
next: data => onSuccess(data),
|
||||
error: error => this.showError(error)
|
||||
});
|
||||
}
|
||||
|
||||
loadWfIntance(id: string, onSuccess: Function): void {
|
||||
this.client.get<void>('./ajax/wf_instances/instance/' + encodeURIComponent(id)).subscribe({
|
||||
next: data => onSuccess(data),
|
||||
error: error => this.showError(error)
|
||||
});
|
||||
}
|
||||
|
||||
private showError(error: any, form?: FormGroup) {
|
||||
|
||||
console.log(error);
|
||||
|
|
|
@ -1 +1,7 @@
|
|||
<p>wfs works!</p>
|
||||
<h2>Workflow Instances</h2>
|
||||
|
||||
<mat-tab-group animationDuration="0ms">
|
||||
<mat-tab label="First">Content 1</mat-tab>
|
||||
<mat-tab label="Second">Content 2</mat-tab>
|
||||
<mat-tab label="Third">Content 3</mat-tab>
|
||||
</mat-tab-group>
|
||||
|
|
|
@ -31,6 +31,12 @@ public class WorkflowInstance implements Serializable {
|
|||
@Column(name = "id")
|
||||
private String id;
|
||||
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "section")
|
||||
private String section;
|
||||
|
||||
@Type(type = "jsonb")
|
||||
@Column(name = "details", columnDefinition = "jsonb")
|
||||
private Map<String, String> details = new LinkedHashMap<>();
|
||||
|
@ -87,6 +93,22 @@ public class WorkflowInstance implements Serializable {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSection() {
|
||||
return section;
|
||||
}
|
||||
|
||||
public void setSection(final String section) {
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
public Map<String, String> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
|
|
@ -264,6 +264,8 @@ CREATE TABLE emails (
|
|||
|
||||
CREATE TABLE workflow_instances (
|
||||
id text PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
section text,
|
||||
details jsonb NOT NULL DEFAULT '{}',
|
||||
priority int,
|
||||
dsid text,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.dnetlib.manager.wf.repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
@ -10,10 +10,12 @@ import eu.dnetlib.utils.CountedValue;
|
|||
|
||||
public interface WorkflowInstanceRepository extends JpaRepository<WorkflowInstance, String> {
|
||||
|
||||
@Query(value = "select r.subtype as value, count(*) as count "
|
||||
+ "from workflow_instances i join resources r on (i.workflow = r.id) "
|
||||
+ "group by r.subtype "
|
||||
@Query(value = "select section as value, count(*) as count "
|
||||
+ "from workflow_instances "
|
||||
+ "group by section "
|
||||
+ "order by count desc;", nativeQuery = true)
|
||||
List<CountedValue> families();
|
||||
Stream<CountedValue> streamSections();
|
||||
|
||||
Stream<WorkflowInstance> findBySection(String section);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package eu.dnetlib.manager.wf;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
|
@ -187,8 +187,12 @@ public class WorkflowManagerService implements Stoppable {
|
|||
this.paused = paused;
|
||||
}
|
||||
|
||||
public List<CountedValue> families() {
|
||||
return workflowInstanceRepository.families();
|
||||
public Stream<CountedValue> streamSections() {
|
||||
return workflowInstanceRepository.streamSections();
|
||||
}
|
||||
|
||||
public Stream<WorkflowInstance> streamWfInstancesBySection(final String section) {
|
||||
return workflowInstanceRepository.findBySection(section);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class WorkflowProcess implements Comparable<WorkflowProcess> {
|
|||
}
|
||||
|
||||
public String getName() {
|
||||
return wfMetadata.getName();
|
||||
return wfInstance.getName();
|
||||
}
|
||||
|
||||
public String getFamily() {
|
||||
|
|
Loading…
Reference in New Issue