Commit c305c41f authored by Jérémy Destin's avatar Jérémy Destin
Browse files

fix: Factorize duplicate code that map the source name with there uri. Add the...

fix: Factorize duplicate code that map the source name with there uri. Add the link to the germplasm card on the name of the germplasm in the germplasm-result-page table.GNP-4309
parent 0c08d877
......@@ -59,7 +59,13 @@
<tbody>
<ng-container *ngFor="let germplasm of germplasms">
<tr>
<td>{{ germplasm.germplasmName }}</td>
<td>
<a [routerLink]="['/germplasm']"
[queryParams]="{id: germplasm.germplasmDbId}"
target="_blank">
{{ germplasm.germplasmName }}
</a>
</td>
<td>{{ germplasm.accessionNumber }}</td>
<td>{{ germplasm.genusSpecies }}</td>
<td>{{ germplasm.instituteName }}</td>
......@@ -109,7 +115,7 @@
</ng-container>
<div *ngIf="germplasms.length == 0"
<div *ngIf="germplasms && germplasms.length == 0"
id="no-results" class="text-center">
<div class="no-result-icon">
<span class="fa fa-meh-o"></span>
......
......@@ -72,12 +72,17 @@ export class GnpisService {
search(
criteria: DataDiscoveryCriteria
): Observable<DataDiscoveryResults> {
return zip(
return this.mapSources( zip(
// Get source by URI
this.sourceByURI$,
// Get documents by criteria
this.http.post<any>(`${BASE_URL}/datadiscovery/search`, criteria)
).pipe(map(([sourceByURI, response]) => {
));
}
mapSources(httpResponse: Observable<any>) {
return httpResponse.pipe(map(([sourceByURI, response]) => {
// Extract BrAPI documents from result
const documents = response.result.data;
......@@ -92,8 +97,12 @@ export class GnpisService {
}
return response;
}));
}
/**
* Get germplasm by ID or PUI with data source (present in JSON-LD response)
* @param params containing Id or PUI
......@@ -110,28 +119,13 @@ export class GnpisService {
germplasmSearch(criteria: GermplasmCriteria): Observable<GermplasmResults<Germplasm>> {
return zip(
return this.mapSources(zip(
// Get source by URI
this.sourceByURI$,
// Get documents by criteria
this.http.post<GermplasmResults<Germplasm>>(`${BASE_URL}/germplasm/search`,
criteria,
{ headers: { 'Accept': 'application/ld+json,application/json' } }))
.pipe(map(([sourceByURI, response]) => {
// Extract BrAPI documents from result
const germplasm = response.result.data;
// Transform document to have the source details in place of the source URI
response.result.data = germplasm.map(data => {
const sourceURI = data['schema:includedInDataCatalog'];
data['schema:includedInDataCatalog'] = sourceByURI[sourceURI];
return data;
});
if (response.facets) {
this.getSourcesName(sourceByURI, response);
}
return response;
}));
{ headers: { 'Accept': 'application/ld+json,application/json' } })));
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment