repo hi api
This commit is contained in:
parent
8d00b6dfbd
commit
809309c427
|
@ -32,9 +32,9 @@ public class ApiController extends DnetRestController {
|
|||
@Autowired
|
||||
private SimpleResourceService service;
|
||||
|
||||
@GetMapping("/resources/byType/{typeId}")
|
||||
public List<SimpleResource> listResources(@PathVariable final String typeId) {
|
||||
return service.listResources(typeId);
|
||||
@GetMapping("/resources/byType/{type}")
|
||||
public List<SimpleResource> listResources(@PathVariable final String type, @RequestParam(required = false) final String subtype) {
|
||||
return service.listResources(type, subtype);
|
||||
}
|
||||
|
||||
@GetMapping("/resources/{resId}/metadata")
|
||||
|
|
|
@ -23,6 +23,8 @@ public interface SimpleResourceRepository extends JpaRepository<SimpleResource,
|
|||
|
||||
List<SimpleResource> findByType(String type);
|
||||
|
||||
List<SimpleResource> findByTypeAndSubtype(String type, String subtype);
|
||||
|
||||
@Query(value = "select t.content_type from resources r join resource_types t on (r.type = t.id) where r.id = ?1", nativeQuery = true)
|
||||
Optional<String> findContentTypeById(String id);
|
||||
|
||||
|
|
|
@ -50,9 +50,12 @@ public class SimpleResourceService {
|
|||
return simpleResourceRepository.findContentTypeById(id).orElseThrow(() -> new InformationServiceException("Id not found"));
|
||||
}
|
||||
|
||||
public List<SimpleResource> listResources(final String type) {
|
||||
return simpleResourceRepository.findByType(type)
|
||||
.stream()
|
||||
public List<SimpleResource> listResources(final String type, final String subType) {
|
||||
|
||||
final List<SimpleResource> list = ((StringUtils.isNotBlank(subType)) ? simpleResourceRepository.findByTypeAndSubtype(type, subType)
|
||||
: simpleResourceRepository.findByType(type));
|
||||
|
||||
return list.stream()
|
||||
.sorted((r1, r2) -> StringUtils.compareIgnoreCase(r1.getName(), r2.getName()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
|
|
@ -17,8 +17,10 @@ import eu.dnetlib.common.controller.DnetRestController;
|
|||
import eu.dnetlib.domain.common.KeyValue;
|
||||
import eu.dnetlib.domain.wfs.WfConfiguration;
|
||||
import eu.dnetlib.domain.wfs.WfJournalEntry;
|
||||
import eu.dnetlib.domain.wfs.WfRepoHiDesc;
|
||||
import eu.dnetlib.domain.wfs.WfSection;
|
||||
import eu.dnetlib.domain.wfs.WfSubscription;
|
||||
import eu.dnetlib.domain.wfs.WfTemplate;
|
||||
import eu.dnetlib.wfs.manager.service.WorkflowManagerService;
|
||||
|
||||
@RestController
|
||||
|
@ -101,4 +103,13 @@ public class ApiController extends DnetRestController {
|
|||
wfManagerService.saveSubscriptions(id, subscriptions);
|
||||
}
|
||||
|
||||
@GetMapping("/repo-his")
|
||||
public List<WfRepoHiDesc> listRepoHIs() {
|
||||
return wfManagerService.listRepoHis();
|
||||
}
|
||||
|
||||
@GetMapping("/template/{id}")
|
||||
public WfTemplate findWfTemplate(@PathVariable final String id) {
|
||||
return wfManagerService.findWfTemplate(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package eu.dnetlib.wfs.manager.service;
|
|||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
@ -19,10 +20,12 @@ import eu.dnetlib.common.clients.SimpleResourceClient;
|
|||
import eu.dnetlib.domain.wfs.JobStatus;
|
||||
import eu.dnetlib.domain.wfs.WfConfiguration;
|
||||
import eu.dnetlib.domain.wfs.WfJournalEntry;
|
||||
import eu.dnetlib.domain.wfs.WfRepoHiDesc;
|
||||
import eu.dnetlib.domain.wfs.WfSection;
|
||||
import eu.dnetlib.domain.wfs.WfSubscription;
|
||||
import eu.dnetlib.domain.wfs.WfTemplate;
|
||||
import eu.dnetlib.domain.wfs.WfTemplate.WfParam;
|
||||
import eu.dnetlib.domain.wfs.WorkflowsConstants;
|
||||
import eu.dnetlib.errors.WorkflowManagerException;
|
||||
import eu.dnetlib.wfs.repository.WfConfigurationRepository;
|
||||
import eu.dnetlib.wfs.repository.WfJournalEntryRepository;
|
||||
|
@ -68,9 +71,7 @@ public class WorkflowManagerService {
|
|||
conf.setId("wfconf-" + UUID.randomUUID());
|
||||
}
|
||||
|
||||
final List<WfParam> wfParams = clientFactory.getClient(SimpleResourceClient.class)
|
||||
.findResourceContent(conf.getWorkflow(), WfTemplate.class)
|
||||
.getParameters();
|
||||
final List<WfParam> wfParams = findWfTemplate(conf.getWorkflow()).getParameters();
|
||||
|
||||
conf.setConfigured(WfConfigurationUtils.isConfigured(wfParams, conf));
|
||||
|
||||
|
@ -79,6 +80,10 @@ public class WorkflowManagerService {
|
|||
return conf;
|
||||
}
|
||||
|
||||
public WfTemplate findWfTemplate(final String id) {
|
||||
return clientFactory.getClient(SimpleResourceClient.class).findResourceContent(id, WfTemplate.class);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteWfConfiguration(final String id) {
|
||||
wfSubscriptionRepository.deleteByWfConfigurationId(id);
|
||||
|
@ -148,4 +153,19 @@ public class WorkflowManagerService {
|
|||
return wfJournalEntryRepository.findById(processId).get();
|
||||
}
|
||||
|
||||
public List<WfRepoHiDesc> listRepoHis() {
|
||||
return clientFactory.getClient(SimpleResourceClient.class)
|
||||
.findResources(WorkflowsConstants.WF_TEMPLATE, WorkflowsConstants.REPO_HI_JOB)
|
||||
.stream()
|
||||
.map(r -> {
|
||||
final WfRepoHiDesc repohi = new WfRepoHiDesc();
|
||||
repohi.setId(r.getId());
|
||||
repohi.setName(r.getName());
|
||||
repohi.setDescription(r.getDescription());
|
||||
return repohi;
|
||||
})
|
||||
.sorted(Comparator.comparing(WfRepoHiDesc::getName))
|
||||
.toList();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import { ResourcesComponent, ResContentDialog, ResCreateNewDialog, ResMetadataDi
|
|||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { ContextsComponent, ContextViewerComponent, ContextParamsDialog } from './contexts/contexts.component';
|
||||
import { VocabulariesComponent, VocabularyEditorComponent, VocDialog, VocTermDialog } from './vocabularies/vocabularies.component';
|
||||
import { DsmSearchComponent, DsmResultsComponent, DsmApiComponent, DsmAddApiDialog, DsmBrowseDialog } from './dsm/dsm.component';
|
||||
import { DsmSearchComponent, DsmResultsComponent, DsmApiComponent, DsmAddApiDialog, DsmBrowseDialog, DsmAddWorkflowDialog } from './dsm/dsm.component';
|
||||
import { MatPaginatorModule } from '@angular/material/paginator';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { SpinnerHttpInterceptor } from './common/spinner.service';
|
||||
|
@ -71,6 +71,7 @@ import { SwaggerUiComponent } from './swagger/swagger-ui.component';
|
|||
DsmApiComponent,
|
||||
DsmAddApiDialog,
|
||||
DsmBrowseDialog,
|
||||
DsmAddWorkflowDialog,
|
||||
MdstoresComponent,
|
||||
MdstoreInspectorComponent,
|
||||
MDStoreVersionsDialog,
|
||||
|
|
|
@ -255,3 +255,9 @@ export interface WfSubscription {
|
|||
export interface WfProcessStatus {
|
||||
// TODO
|
||||
}
|
||||
|
||||
export interface WfRepoHi {
|
||||
id: string,
|
||||
name: string,
|
||||
description?: string
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<h1 mat-dialog-title>Available RepoHI Workflows</h1>
|
||||
|
||||
<div mat-dialog-content>
|
||||
<mat-card *ngFor="let wf of repohis">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{wf.name}}</mat-card-title>
|
||||
<mat-card-subtitle>{{wf.description}}</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
...
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-stroked-button color="primary" mat-dialog-close (click)="startRepoHiWf(wf.id)">
|
||||
<mat-icon fontIcon="build"></mat-icon> generate workflow
|
||||
</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</div>
|
||||
|
||||
<div mat-dialog-actions>
|
||||
<button mat-stroked-button color="primary" mat-dialog-close>Close</button>
|
||||
</div>
|
|
@ -10,8 +10,8 @@
|
|||
add workflow
|
||||
</button>
|
||||
<button mat-stroked-button color="warn" (click)="deleteApi()" [disabled]="!api.removable || api.active">
|
||||
<mat-icon fontIcon="delete api"></mat-icon>
|
||||
delete
|
||||
<mat-icon fontIcon="delete"></mat-icon>
|
||||
delete api
|
||||
</button>
|
||||
</p>
|
||||
|
||||
|
@ -110,7 +110,7 @@
|
|||
<span *ngIf="api.compatibilityOverrided">{{api.compatibilityOverride}}</span>
|
||||
<span *ngIf="!api.compatibilityOverrided">{{api.compatibility}}</span>
|
||||
|
||||
<span style="float: right;">OVERRIDE</span>
|
||||
<span style="float: right;">OVERRIDE (TODO)</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr *ngIf="api.lastColletionMdid">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Page, DsmConf, KeyValue, BrowseTerm, SimpleDatasource } from '../common/is.model';
|
||||
import { Page, DsmConf, KeyValue, BrowseTerm, SimpleDatasource, WfRepoHi } from '../common/is.model';
|
||||
import { ISClient } from '../common/is.client';
|
||||
|
||||
@Injectable({
|
||||
|
@ -41,8 +41,8 @@ export class DsmClient extends ISClient {
|
|||
alert('TODO');
|
||||
}
|
||||
|
||||
dsmListRepoHiWfs(apiId: string, onSuccess: Function) {
|
||||
alert('TODO');
|
||||
dsmListRepoHiWfs(onSuccess: Function) {
|
||||
this.httpGet<WfRepoHi>('/proxy/byType/wf_manager/api/repo-his', onSuccess);
|
||||
}
|
||||
|
||||
dsmRepoHiWf(wfId: string, onSuccess: Function) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, Inject, Injectable, OnInit, ViewChild } from '@angular/core';
|
||||
import { Page, BrowseTerm, SimpleDatasource, KeyValue, DsmConf, ProtocolParam, Api, ApiInsert } from '../common/is.model';
|
||||
import { Page, BrowseTerm, SimpleDatasource, KeyValue, DsmConf, ProtocolParam, Api, ApiInsert, WfRepoHi } from '../common/is.model';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
|
@ -152,15 +152,28 @@ export class DsmApiComponent implements OnInit {
|
|||
}
|
||||
|
||||
deleteApi() {
|
||||
alert('TODO');
|
||||
alert('TODO DELETE API');
|
||||
}
|
||||
|
||||
newAddWorkflowDialog() {
|
||||
alert('TODO');
|
||||
this.client.dsmListRepoHiWfs((data: WfRepoHi[]) => {
|
||||
const dialogRef = this.dialog.open(DsmAddWorkflowDialog, {
|
||||
data: {
|
||||
'ds': this.ds,
|
||||
'api': this.api,
|
||||
'repohis': data
|
||||
},
|
||||
width: '80%'
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
if (result) this.reload();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
newEditApiDialog() {
|
||||
alert('TODO');
|
||||
alert('TODO EDIT WF DIALOG');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -321,3 +334,29 @@ export class DsmConfService {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'dsm-add-wf-dialog',
|
||||
templateUrl: 'add-wf-dialog.html',
|
||||
styleUrls: ['./dsm.component.css']
|
||||
})
|
||||
export class DsmAddWorkflowDialog {
|
||||
|
||||
api: any = {};
|
||||
ds: any = {};
|
||||
repohis: WfRepoHi[] = [];
|
||||
|
||||
constructor(public dialogRef: MatDialogRef<DsmAddWorkflowDialog>, @Inject(MAT_DIALOG_DATA) public data: any, public client: DsmClient) {
|
||||
this.api = data.api;
|
||||
this.ds = data.ds;
|
||||
this.repohis = data.repohis;
|
||||
}
|
||||
|
||||
startRepoHiWf(wfId: string): void {
|
||||
alert('TODO REPO HI');
|
||||
}
|
||||
|
||||
onNoClick(): void {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.dnetlib.common.clients;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
@ -7,6 +8,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import eu.dnetlib.domain.resource.SimpleResource;
|
||||
|
||||
public class SimpleResourceClient extends DnetServiceClient {
|
||||
|
@ -54,4 +57,17 @@ public class SimpleResourceClient extends DnetServiceClient {
|
|||
return httpPostParams("/api/resources/", params, SimpleResource.class);
|
||||
}
|
||||
|
||||
public List<SimpleResource> findResources(final String type, final String subType) {
|
||||
|
||||
final StringWriter url = new StringWriter();
|
||||
url.append("/api/resources/byType/");
|
||||
url.append(URLEncoder.encode(type, StandardCharsets.UTF_8));
|
||||
if (StringUtils.isNotBlank(subType)) {
|
||||
url.append("?subtype=");
|
||||
url.append(URLEncoder.encode(subType, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
return Arrays.asList(httpGet(url.toString(), SimpleResource[].class));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package eu.dnetlib.domain.wfs;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class WfRepoHiDesc implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5192964707849869720L;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.wfs.utils;
|
||||
package eu.dnetlib.domain.wfs;
|
||||
|
||||
public class WorkflowsConstants {
|
||||
|
||||
|
@ -38,12 +38,17 @@ public class WorkflowsConstants {
|
|||
|
||||
public static final String MAIN_LOG_PREFIX = "mainlog:";
|
||||
|
||||
public static final String WF_TEMPLATE = "wf_template";
|
||||
|
||||
public static final String REPO_HI_JOB = "REPO-HI";
|
||||
public static final String REPO_BYE_JOB = "REPO-BYE";
|
||||
|
||||
public enum WorkflowStatus {
|
||||
|
||||
EXECUTABLE("Executable", "icon-ok"), WAIT_USER_SETTINGS("Waiting user settings", "icon-edit"), WAIT_SYS_SETTINGS("Waiting system settings",
|
||||
EXECUTABLE("Executable", "icon-ok"),
|
||||
WAIT_USER_SETTINGS("Waiting user settings", "icon-edit"),
|
||||
WAIT_SYS_SETTINGS(
|
||||
"Waiting system settings",
|
||||
"icon-refresh");
|
||||
|
||||
public String displayName;
|
|
@ -13,10 +13,10 @@ import eu.dnetlib.domain.resource.SimpleResource;
|
|||
import eu.dnetlib.domain.wfs.JobStatus;
|
||||
import eu.dnetlib.domain.wfs.WfConfiguration;
|
||||
import eu.dnetlib.domain.wfs.WfJournalEntry;
|
||||
import eu.dnetlib.domain.wfs.WorkflowsConstants;
|
||||
import eu.dnetlib.wfs.env.Env;
|
||||
import eu.dnetlib.wfs.graph.Graph;
|
||||
import eu.dnetlib.wfs.utils.ProcessCallback;
|
||||
import eu.dnetlib.wfs.utils.WorkflowsConstants;
|
||||
|
||||
/**
|
||||
* Created by michele on 19/11/15.
|
||||
|
|
|
@ -21,6 +21,7 @@ import eu.dnetlib.domain.wfs.JobStatus;
|
|||
import eu.dnetlib.domain.wfs.WfConfiguration;
|
||||
import eu.dnetlib.domain.wfs.WfJournalEntry;
|
||||
import eu.dnetlib.domain.wfs.WfTemplate;
|
||||
import eu.dnetlib.domain.wfs.WorkflowsConstants;
|
||||
import eu.dnetlib.errors.WorkflowManagerException;
|
||||
import eu.dnetlib.utils.Stoppable;
|
||||
import eu.dnetlib.utils.StoppableDetails;
|
||||
|
@ -132,7 +133,7 @@ public class WfExecutorService implements Stoppable {
|
|||
final SimpleResourceClient simpleResourceClient = clientFactory.getClient(SimpleResourceClient.class);
|
||||
|
||||
final SimpleResource wfMetadata = simpleResourceClient.findResource(wfId);
|
||||
if (!"wf_template".equals(wfMetadata.getType())) { throw new WorkflowManagerException("WF not found: " + conf.getWorkflow()); }
|
||||
if (!WorkflowsConstants.WF_TEMPLATE.equals(wfMetadata.getType())) { throw new WorkflowManagerException("WF not found: " + conf.getWorkflow()); }
|
||||
|
||||
final WfTemplate wfTmpl = simpleResourceClient.findResourceContent(wfId, WfTemplate.class);
|
||||
|
||||
|
|
Loading…
Reference in New Issue