oai explorer page
This commit is contained in:
parent
54cbe69dd3
commit
196b89358e
|
@ -13,6 +13,7 @@ import { WfConfsComponent } from './wf-confs/wf-confs.component';
|
||||||
import { IndexComponent } from './index/index.component';
|
import { IndexComponent } from './index/index.component';
|
||||||
import { OaiComponent } from './oai/oai.component';
|
import { OaiComponent } from './oai/oai.component';
|
||||||
import { SwaggerUiComponent } from './swagger/swagger-ui.component';
|
import { SwaggerUiComponent } from './swagger/swagger-ui.component';
|
||||||
|
import { OaiExplorerComponent } from './oai-explorer/oai-explorer.component';
|
||||||
|
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
|
@ -35,6 +36,7 @@ const routes: Routes = [
|
||||||
{ path: "cleaner", component: CleanerTesterComponent },
|
{ path: "cleaner", component: CleanerTesterComponent },
|
||||||
{ path: "index", component: IndexComponent },
|
{ path: "index", component: IndexComponent },
|
||||||
{ path: "oai", component: OaiComponent },
|
{ path: "oai", component: OaiComponent },
|
||||||
|
{ path: "oai-explorer", component: OaiExplorerComponent },
|
||||||
{ path: "swagger-ui/:id", component: SwaggerUiComponent }
|
{ path: "swagger-ui/:id", component: SwaggerUiComponent }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ import { WfTemplateDialog, WfConfDialog, WfConfLauncherDialog } from './wf-confs
|
||||||
import { MatMenuModule } from '@angular/material/menu';
|
import { MatMenuModule } from '@angular/material/menu';
|
||||||
import { MatDatepickerModule } from '@angular/material/datepicker';
|
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||||
import { MatNativeDateModule } from '@angular/material/core';
|
import { MatNativeDateModule } from '@angular/material/core';
|
||||||
|
import { OaiExplorerComponent } from './oai-explorer/oai-explorer.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
|
@ -90,6 +91,7 @@ import { MatNativeDateModule } from '@angular/material/core';
|
||||||
WfConfLauncherDialog,
|
WfConfLauncherDialog,
|
||||||
IndexComponent,
|
IndexComponent,
|
||||||
OaiComponent,
|
OaiComponent,
|
||||||
|
OaiExplorerComponent,
|
||||||
SwaggerUiComponent
|
SwaggerUiComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
<div>
|
<div>
|
||||||
<a class="menu-item" routerLink="dsm/search">Search</a>
|
<a class="menu-item" routerLink="dsm/search">Search</a>
|
||||||
|
<a class="menu-item" routerLink="oai-explorer">Oai Explorer</a>
|
||||||
</div>
|
</div>
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
<h2>Oai Explorer</h2>
|
||||||
|
|
||||||
|
<mat-form-field appearance="fill" floatLabel="always" style="width: 100%;">
|
||||||
|
<mat-label>OAI BaseUrl</mat-label>
|
||||||
|
<input matInput [(ngModel)]="oaiBaseUrl" />
|
||||||
|
<button mat-stroked-button matSuffix color="primary" (click)="changeUrl(oaiBaseUrl, 1)">
|
||||||
|
Info
|
||||||
|
</button>
|
||||||
|
<button mat-stroked-button matSuffix color="primary" (click)="changeUrl(oaiBaseUrl, 2)">
|
||||||
|
Sets
|
||||||
|
</button>
|
||||||
|
<button mat-stroked-button matSuffix color="primary" (click)="changeUrl(oaiBaseUrl, 3)">
|
||||||
|
MD Formats
|
||||||
|
</button>
|
||||||
|
<button mat-stroked-button matSuffix color="primary" (click)="changeUrl(oaiBaseUrl, 4)">
|
||||||
|
Records
|
||||||
|
</button>
|
||||||
|
<button mat-stroked-button matSuffix color="primary" (click)="changeUrl(oaiBaseUrl, 5)" style="margin-right: 0.5em;">
|
||||||
|
Identifiers
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
{{oaiResponse | json}}
|
||||||
|
</pre>
|
|
@ -0,0 +1,77 @@
|
||||||
|
import { Component, Inject, Injectable, OnInit } from '@angular/core';
|
||||||
|
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||||
|
import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
|
import { MDStore, MDStoreRecord, MDStoreVersion } from '../common/is.model';
|
||||||
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
|
import { ISClient } from '../common/is.client';
|
||||||
|
import { combineLatest } from 'rxjs';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'oai-explorer',
|
||||||
|
templateUrl: './oai-explorer.component.html',
|
||||||
|
styleUrls: []
|
||||||
|
})
|
||||||
|
export class OaiExplorerComponent implements OnInit {
|
||||||
|
|
||||||
|
oaiBaseUrl: string = ""
|
||||||
|
page: number = 1;
|
||||||
|
oaiResponse = {};
|
||||||
|
|
||||||
|
constructor(public client: OaiExplorerClient, public router: Router, public route: ActivatedRoute, public dialog: MatDialog) { }
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
combineLatest([this.route.params, this.route.queryParams],
|
||||||
|
(params: Params, queryParams: Params) => ({ params, queryParams })
|
||||||
|
).subscribe((res: { params: Params; queryParams: Params }) => {
|
||||||
|
this.oaiBaseUrl = res.queryParams['baseUrl'];
|
||||||
|
|
||||||
|
if (this.oaiBaseUrl) {
|
||||||
|
if (res.queryParams['page'] == 1) {
|
||||||
|
this.client.callIdentifyVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
||||||
|
} else if (res.queryParams['page'] == 2) {
|
||||||
|
this.client.callListSetsVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
||||||
|
} else if (res.queryParams['page'] == 3) {
|
||||||
|
this.client.callListMdFormatsVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
||||||
|
} else if (res.queryParams['page'] == 4) {
|
||||||
|
this.client.callListRecordsVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
||||||
|
} else if (res.queryParams['page'] == 5) {
|
||||||
|
this.client.callListIdentifiersVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
||||||
|
} else {
|
||||||
|
this.client.callIdentifyVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
changeUrl(baseUrl: string, page: number) {
|
||||||
|
this.router.navigate(['/oai-explorer'], { queryParams: { baseUrl: baseUrl, page: page } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class OaiExplorerClient extends ISClient {
|
||||||
|
baseUrl = '/proxy/byType/datasource_manager/api';
|
||||||
|
|
||||||
|
callIdentifyVerb(oaiBaseUrl: string, onSuccess: Function) {
|
||||||
|
this.httpGet(this.baseUrl + '/oai-explorer/info?baseUrl=' + encodeURIComponent(oaiBaseUrl), onSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
callListSetsVerb(oaiBaseUrl: string, onSuccess: Function) {
|
||||||
|
this.httpGet(this.baseUrl + '/oai-explorer/sets?baseUrl=' + encodeURIComponent(oaiBaseUrl), onSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
callListMdFormatsVerb(oaiBaseUrl: string, onSuccess: Function) {
|
||||||
|
this.httpGet(this.baseUrl + '/oai-explorer/mdformats?baseUrl=' + encodeURIComponent(oaiBaseUrl), onSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
callListRecordsVerb(oaiBaseUrl: string, onSuccess: Function) {
|
||||||
|
this.httpGet(this.baseUrl + '/oai-explorer/records?baseUrl=' + encodeURIComponent(oaiBaseUrl), onSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
callListIdentifiersVerb(oaiBaseUrl: string, onSuccess: Function) {
|
||||||
|
this.httpGet(this.baseUrl + '/oai-explorer/identifiers?baseUrl=' + encodeURIComponent(oaiBaseUrl), onSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.dnetlib.common.oai;
|
package eu.dnetlib.common.oai;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -10,10 +9,6 @@ import org.dom4j.Document;
|
||||||
import org.dom4j.DocumentHelper;
|
import org.dom4j.DocumentHelper;
|
||||||
import org.dom4j.Element;
|
import org.dom4j.Element;
|
||||||
import org.dom4j.Node;
|
import org.dom4j.Node;
|
||||||
import org.springframework.http.HttpEntity;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
@ -134,21 +129,18 @@ public class OaiClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void callOaiVerb(final OaiRequest req, final OaiResponse<T> res, final Function<Document, T> processBody) {
|
private <T> void callOaiVerb(final OaiRequest req, final OaiResponse<T> res, final Function<Document, T> processBody) {
|
||||||
|
|
||||||
res.setVerb(req.getVerb());
|
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final HttpHeaders headers = new HttpHeaders();
|
res.setVerb(req.getVerb());
|
||||||
headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML_VALUE);
|
|
||||||
|
|
||||||
final Map<String, Object> params = req.toQueryParams();
|
|
||||||
|
|
||||||
final UriComponentsBuilder urlBuilder = UriComponentsBuilder.fromHttpUrl(req.getBaseUrl());
|
final UriComponentsBuilder urlBuilder = UriComponentsBuilder.fromHttpUrl(req.getBaseUrl());
|
||||||
params.keySet().forEach(k -> urlBuilder.queryParam(k, "{" + k + "}"));
|
req.toQueryParams().forEach((k, v) -> urlBuilder.queryParam(k, v));
|
||||||
|
|
||||||
final ResponseEntity<String> httpResponse =
|
final String url = urlBuilder.encode().toUriString();
|
||||||
new RestTemplate().exchange(urlBuilder.encode().toUriString(), HttpMethod.GET, new HttpEntity<>(headers), String.class, params);
|
res.setUrl(url);
|
||||||
|
|
||||||
|
final ResponseEntity<String> httpResponse = new RestTemplate().getForEntity(url, String.class);
|
||||||
|
|
||||||
res.setHttpCode(httpResponse.getStatusCode().value());
|
res.setHttpCode(httpResponse.getStatusCode().value());
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.io.Serializable;
|
||||||
public class OaiResponse<T> implements Serializable {
|
public class OaiResponse<T> implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -7841519266909952558L;
|
private static final long serialVersionUID = -7841519266909952558L;
|
||||||
|
private String url;
|
||||||
private String verb;
|
private String verb;
|
||||||
private long time;
|
private long time;
|
||||||
private int httpCode;
|
private int httpCode;
|
||||||
|
@ -16,6 +17,14 @@ public class OaiResponse<T> implements Serializable {
|
||||||
private T body;
|
private T body;
|
||||||
private String resumptionToken;
|
private String resumptionToken;
|
||||||
|
|
||||||
|
public void setUrl(final String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return this.url;
|
||||||
|
}
|
||||||
|
|
||||||
public String getVerb() {
|
public String getVerb() {
|
||||||
return this.verb;
|
return this.verb;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue