fixing oai explorer
This commit is contained in:
parent
c0e3456887
commit
47e0fa2c8d
|
@ -108,7 +108,11 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th align="left" width="20%">Protocol</th>
|
||||
<td width="80%">{{api.protocol}}</td>
|
||||
<td width="80%">
|
||||
{{api.protocol}}
|
||||
<button routerLink="/oai-explorer" [queryParams]="{ baseUrl: api.baseurl}" mat-raised-button color="primary"
|
||||
*ngIf="api.protocol.toLowerCase() == 'oai'" style="float: right; height: 2em">test</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left" width="20%">Compliance</th>
|
||||
|
|
|
@ -3,23 +3,20 @@
|
|||
<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)="gotoPage(1, null, null, null, null)"
|
||||
[disabled]="!oaiBaseUrl">
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="pageInfo()" [disabled]="!oaiBaseUrl">
|
||||
Info
|
||||
</button>
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="gotoPage(2, null, null, null, null)"
|
||||
[disabled]="!oaiBaseUrl">
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="pageSets()" [disabled]="!oaiBaseUrl">
|
||||
Sets
|
||||
</button>
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="gotoPage(3, null, null, null, null)"
|
||||
[disabled]="!oaiBaseUrl">
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="pageFormats()" [disabled]="!oaiBaseUrl">
|
||||
MD Formats
|
||||
</button>
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="gotoPage(4, null, null, null, null)"
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="pageRecords(undefined, undefined, undefined)"
|
||||
[disabled]="!oaiBaseUrl">
|
||||
Records
|
||||
</button>
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="gotoPage(5, null, null, null, null)"
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="pageIdentifiers(undefined, undefined, undefined)"
|
||||
[disabled]="!oaiBaseUrl" style="margin-right: 0.5em;">
|
||||
Identifiers
|
||||
</button>
|
||||
|
@ -36,12 +33,34 @@
|
|||
<span *ngIf="oaiResponse.time"><b>Response Time: </b> {{oaiResponse.time}} ms<br /></span>
|
||||
</p>
|
||||
|
||||
<mat-card *ngIf="!oaiResponse.valid">
|
||||
<p>
|
||||
<span *ngIf="oaiResponse.size > 0 || oaiResponse.total > 0 || oaiResponse.cursor > 0">
|
||||
<b>Cursor: </b>{{oaiResponse.cursor}}<br />
|
||||
</span>
|
||||
<span *ngIf="oaiResponse.size > 0"><b>Size: </b> {{oaiResponse.size}}<br /></span>
|
||||
<span *ngIf="oaiResponse.total > 0"><b>Total: </b> {{oaiResponse.total}}<br /></span>
|
||||
<span *ngIf="oaiResponse.resumptionToken && page == 2">
|
||||
<b>Next Page: </b>
|
||||
<a (click)="pageSets(oaiResponse.resumptionToken)">{{oaiResponse.resumptionToken}}</a>
|
||||
</span>
|
||||
<span *ngIf="oaiResponse.resumptionToken && page == 4">
|
||||
<b>Next Page: </b>
|
||||
<a (click)="pageRecords(undefined, undefined, oaiResponse.resumptionToken)">{{oaiResponse.resumptionToken}}</a>
|
||||
</span>
|
||||
<span *ngIf="oaiResponse.resumptionToken && page == 5">
|
||||
<b>Next Page: </b>
|
||||
<a (click)="pageIdentifiers(undefined, undefined, oaiResponse.resumptionToken)">{{oaiResponse.resumptionToken}}</a>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
|
||||
<mat-card *ngIf="!oaiResponse.valid" style="margin-top: 2em;">
|
||||
<mat-card-content>
|
||||
<pre>{{oaiResponse.error}}</pre>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
|
||||
<!-- INFO -->
|
||||
<mat-card *ngIf="oaiResponse.valid && page == 1" style="margin-top: 2em;">
|
||||
<mat-card-content>
|
||||
|
@ -106,17 +125,17 @@
|
|||
</table>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="gotoPage(4, s.setSpec, null, null, null)">
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="pageRecords(s.setSpec, undefined, undefined)">
|
||||
Records
|
||||
</button>
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="gotoPage(5, s.setSpec, null, null, null)">
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="pageIdentifiers(s.setSpec, undefined, undefined)">
|
||||
Identifiers
|
||||
</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</ng-container>
|
||||
|
||||
<!-- SETS -->
|
||||
<!-- FORMATS -->
|
||||
<ng-container *ngIf="oaiResponse.valid && page == 3 && oaiResponse.body && oaiResponse.body.length">
|
||||
<mat-card *ngFor=" let f of oaiResponse.body" style="margin-top: 2em;">
|
||||
<mat-card-content>
|
||||
|
@ -136,10 +155,12 @@
|
|||
</table>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="gotoPage(4, null, f.metadataPrefix, null, null)">
|
||||
<button mat-stroked-button matSuffix color="primary"
|
||||
(click)="pageRecords(undefined, f.metadataPrefix, undefined)">
|
||||
Records
|
||||
</button>
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="gotoPage(5, null, f.metadataPrefix, null, null)">
|
||||
<button mat-stroked-button matSuffix color="primary"
|
||||
(click)="pageIdentifiers(undefined, f.metadataPrefix, undefined)">
|
||||
Identifiers
|
||||
</button>
|
||||
</mat-card-actions>
|
||||
|
@ -153,7 +174,7 @@
|
|||
<table>
|
||||
<tr>
|
||||
<th align="left" width="20%">ID</th>
|
||||
<td>{{r.id}}</td>
|
||||
<td>{{r.id}} <span class="badge-label badge-failure" *ngIf="r.deleted == true">deleted</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left" width="20%">Date</th>
|
||||
|
@ -178,7 +199,7 @@
|
|||
<table>
|
||||
<tr>
|
||||
<th align="left" width="20%">ID</th>
|
||||
<td>{{r.id}}</td>
|
||||
<td>{{r.id}} <span class="badge-label badge-failure" *ngIf="r.deleted == true">deleted</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left" width="20%">Date</th>
|
||||
|
@ -191,8 +212,8 @@
|
|||
</table>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="gotoPage(4, null, null, null, r.id)">
|
||||
Get Record (TODO)
|
||||
<button mat-stroked-button matSuffix color="primary" (click)="pageSingleRecord(r.id, currFormat)">
|
||||
Get Record
|
||||
</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
|
@ -204,7 +225,10 @@
|
|||
<table>
|
||||
<tr>
|
||||
<th align="left" width="20%">ID</th>
|
||||
<td>{{oaiResponse.body.id}}</td>
|
||||
<td>
|
||||
{{oaiResponse.body.id}} <span class="badge-label badge-failure"
|
||||
*ngIf="oaiResponse.body.deleted == true">deleted</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left" width="20%">Date</th>
|
||||
|
@ -217,6 +241,6 @@
|
|||
</table>
|
||||
</mat-card-content>
|
||||
<mat-card-content>
|
||||
<pre>{{oaiResponse.body.body}}</pre>
|
||||
<pre>{{oaiResponse.body.body | xml}}</pre>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
|
|
@ -16,6 +16,7 @@ export class OaiExplorerComponent implements OnInit {
|
|||
oaiBaseUrl: string = ""
|
||||
page: number = 0;
|
||||
oaiResponse: any = {};
|
||||
currFormat?: string;
|
||||
|
||||
constructor(public client: OaiExplorerClient, public router: Router, public route: ActivatedRoute, public dialog: MatDialog) { }
|
||||
|
||||
|
@ -24,26 +25,41 @@ export class OaiExplorerComponent implements OnInit {
|
|||
(params: Params, queryParams: Params) => ({ params, queryParams })
|
||||
).subscribe((res: { params: Params; queryParams: Params }) => {
|
||||
this.oaiBaseUrl = res.queryParams['baseUrl'];
|
||||
this.gotoPage(1, null, null, null, null);
|
||||
this.pageInfo();
|
||||
});
|
||||
}
|
||||
|
||||
gotoPage(page: number, set: string | null, format: string | null, token: string | null, id: string | null) {
|
||||
this.page = page;
|
||||
pageInfo() {
|
||||
this.page = 1;
|
||||
this.client.callIdentifyVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
||||
}
|
||||
|
||||
if (this.oaiBaseUrl) {
|
||||
if (this.page == 1) {
|
||||
this.client.callIdentifyVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
||||
} else if (this.page == 2) {
|
||||
this.client.callListSetsVerb(this.oaiBaseUrl, token, (res: any) => this.oaiResponse = res);
|
||||
} else if (this.page == 3) {
|
||||
this.client.callListMdFormatsVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
||||
} else if (this.page == 4) {
|
||||
this.client.callListRecordsVerb(this.oaiBaseUrl, set, format, token, (res: any) => this.oaiResponse = res);
|
||||
} else if (this.page == 5) {
|
||||
this.client.callListIdentifiersVerb(this.oaiBaseUrl, set, format, token, (res: any) => this.oaiResponse = res);
|
||||
}
|
||||
}
|
||||
pageSets(token?: string) {
|
||||
this.page = 2;
|
||||
this.client.callListSetsVerb(this.oaiBaseUrl, token, (res: any) => this.oaiResponse = res);
|
||||
}
|
||||
|
||||
pageFormats() {
|
||||
this.page = 3;
|
||||
this.client.callListMdFormatsVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
||||
}
|
||||
|
||||
pageRecords(set: string | undefined, format: string | undefined, token: string | undefined) {
|
||||
this.page = 4;
|
||||
this.currFormat = format;
|
||||
this.client.callListRecordsVerb(this.oaiBaseUrl, set, format, token, (res: any) => this.oaiResponse = res);
|
||||
}
|
||||
|
||||
pageIdentifiers(set: string | undefined, format: string | undefined, token: string | undefined) {
|
||||
this.page = 5;
|
||||
this.currFormat = format;
|
||||
this.client.callListIdentifiersVerb(this.oaiBaseUrl, set, format, token, (res: any) => this.oaiResponse = res);
|
||||
}
|
||||
|
||||
pageSingleRecord(id: string, format?: string) {
|
||||
this.page = 6;
|
||||
this.currFormat = format;
|
||||
this.client.callGetRecordVerb(this.oaiBaseUrl, id, format, (res: any) => this.oaiResponse = res);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +73,7 @@ export class OaiExplorerClient extends ISClient {
|
|||
this.httpGet(this.baseUrl + '/oai-explorer/info?baseUrl=' + encodeURIComponent(oaiBaseUrl), onSuccess);
|
||||
}
|
||||
|
||||
callListSetsVerb(oaiBaseUrl: string, token: string | null, onSuccess: Function) {
|
||||
callListSetsVerb(oaiBaseUrl: string, token: string | undefined, onSuccess: Function) {
|
||||
let url = this.baseUrl + '/oai-explorer/sets?baseUrl=' + encodeURIComponent(oaiBaseUrl);
|
||||
if (token) { url += "&token=" + encodeURIComponent(token); }
|
||||
this.httpGet(url, onSuccess);
|
||||
|
@ -67,7 +83,7 @@ export class OaiExplorerClient extends ISClient {
|
|||
this.httpGet(this.baseUrl + '/oai-explorer/mdformats?baseUrl=' + encodeURIComponent(oaiBaseUrl), onSuccess);
|
||||
}
|
||||
|
||||
callListRecordsVerb(oaiBaseUrl: string, set: string | null, format: string | null, token: string | null, onSuccess: Function) {
|
||||
callListRecordsVerb(oaiBaseUrl: string, set: string | undefined, format: string | undefined, token: string | undefined, onSuccess: Function) {
|
||||
let url = this.baseUrl + '/oai-explorer/records?baseUrl=' + encodeURIComponent(oaiBaseUrl);
|
||||
if (token) {
|
||||
url += "&token=" + encodeURIComponent(token);
|
||||
|
@ -78,7 +94,7 @@ export class OaiExplorerClient extends ISClient {
|
|||
this.httpGet(url, onSuccess);
|
||||
}
|
||||
|
||||
callListIdentifiersVerb(oaiBaseUrl: string, set: string | null, format: string | null, token: string | null, onSuccess: Function) {
|
||||
callListIdentifiersVerb(oaiBaseUrl: string, set: string | undefined, format: string | undefined, token: string | undefined, onSuccess: Function) {
|
||||
let url = this.baseUrl + '/oai-explorer/identifiers?baseUrl=' + encodeURIComponent(oaiBaseUrl);
|
||||
if (token) {
|
||||
url += "&token=" + encodeURIComponent(token);
|
||||
|
@ -89,4 +105,12 @@ export class OaiExplorerClient extends ISClient {
|
|||
this.httpGet(url, onSuccess);
|
||||
}
|
||||
|
||||
callGetRecordVerb(oaiBaseUrl: string, id: string, format: string | undefined, onSuccess: Function) {
|
||||
let url = this.baseUrl + '/oai-explorer/record?baseUrl=' + encodeURIComponent(oaiBaseUrl) + '&id=' + encodeURIComponent(id);
|
||||
|
||||
if (format) {
|
||||
url += "&format=" + encodeURIComponent(format);
|
||||
}
|
||||
this.httpGet(url, onSuccess);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,4 +68,9 @@ public class ExportedOaiRecord implements OaiRecord<LocalDateTime, String> {
|
|||
return Arrays.asList(this.oaiSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,4 +11,6 @@ public interface OaiIdentifier<T> extends Serializable {
|
|||
|
||||
List<String> getSets();
|
||||
|
||||
boolean isDeleted();
|
||||
|
||||
}
|
||||
|
|
|
@ -15,11 +15,15 @@ public class OaiIdentifierImpl implements OaiIdentifier<String> {
|
|||
|
||||
private String date;
|
||||
|
||||
private boolean deleted;
|
||||
|
||||
private List<String> sets = new ArrayList<>();
|
||||
|
||||
public OaiIdentifierImpl(final Element node) {
|
||||
this.id = node.valueOf("./*[local-name() = 'identifier']");
|
||||
this.date = node.valueOf("./*[local-name() = 'datestamp']");
|
||||
this.deleted = "deleted".equalsIgnoreCase(node.valueOf("@status"));
|
||||
|
||||
node.selectNodes("./*[local-name() = 'setSpec']").forEach(s -> this.sets.add(s.getText()));
|
||||
}
|
||||
|
||||
|
@ -49,4 +53,13 @@ public class OaiIdentifierImpl implements OaiIdentifier<String> {
|
|||
public void setSets(final List<String> sets) {
|
||||
this.sets = sets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return this.deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(final boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Node;
|
||||
|
||||
import eu.dnetlib.domain.oai.OaiRecord;
|
||||
|
||||
|
@ -19,11 +20,20 @@ public class OaiRecordImpl implements OaiRecord<String, String> {
|
|||
|
||||
private List<String> sets = new ArrayList<>();
|
||||
|
||||
private boolean deleted;
|
||||
|
||||
public OaiRecordImpl(final Element node) {
|
||||
|
||||
this.id = node.valueOf("./*[local-name() = 'header']/*[local-name() = 'identifier']");
|
||||
this.date = node.valueOf("./*[local-name() = 'header']/*[local-name() = 'datestamp']");
|
||||
this.body = node.selectSingleNode("./*[local-name() = 'metadata']/*").asXML();
|
||||
this.deleted = "deleted".equalsIgnoreCase(node.valueOf("./*[local-name() = 'header']/@status"));
|
||||
|
||||
node.selectNodes("./*[local-name() = 'header']/*[local-name() = 'setSpec']").forEach(s -> this.sets.add(s.getText()));
|
||||
|
||||
final Node mdNode = node.selectSingleNode("./*[local-name() = 'metadata']/*");
|
||||
if (mdNode != null) {
|
||||
this.body = mdNode.asXML();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,4 +71,13 @@ public class OaiRecordImpl implements OaiRecord<String, String> {
|
|||
public void setSets(final List<String> sets) {
|
||||
this.sets = sets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return this.deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(final boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public class OaiSetImpl implements OaiSet {
|
|||
public OaiSetImpl(final Element node) {
|
||||
this.setSpec = node.valueOf("./*[local-name()='setSpec']");
|
||||
this.setName = node.valueOf("./*[local-name()='setName']");
|
||||
this.description = node.valueOf("./*[local-name()='description']");
|
||||
this.description = node.valueOf("./*[local-name()='setDescription']");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue