[new-search-json | WIP | CHANGED]: Updated parsing according to new json schema.
1. dataProviderInfo.ts: Updated field "contentpolicy: string;" to "contentpolicies: string[];". 2. dataProvider.service.ts: Parse contentPolicies field as array. 3. dataProvider.component.html: Display contentpolicies array. 4. searchResearchResults.service.ts: Parse field "entityType" from header.recordType instead of result.resulttype. 5. resultLanding.service.ts: Parse field "entityType" from header.recordType instead of result.resulttype | Parse header.status (not yet available field) for under curation records | [BUG] Parse field externalReference instead of externalreference. 6. searchOrganizations.service.ts: [BUG] Get "pid" field from correct path. 7. parsingFunctions.class.ts: [BUG] Fix parsing of measures - unit is an array.
This commit is contained in:
parent
61c60eff60
commit
01ccbb9d68
|
@ -617,9 +617,9 @@
|
||||||
{{dataProviderInfo.jurisdiction}}
|
{{dataProviderInfo.jurisdiction}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="dataProviderInfo.contentpolicy" class="uk-margin-medium-bottom">
|
<div *ngIf="dataProviderInfo.contentpolicies?.length > 0" class="uk-margin-medium-bottom">
|
||||||
<div class="uk-text-meta uk-margin-small-bottom">Content policy</div>
|
<div class="uk-text-meta uk-margin-small-bottom">Content policy</div>
|
||||||
{{dataProviderInfo.contentpolicy}}
|
{{dataProviderInfo.contentpolicies.join(", ")}}
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
|
|
@ -198,9 +198,13 @@ export class DataProviderService {
|
||||||
this.dataProviderInfo.jurisdiction = datasource.jurisdiction.label;
|
this.dataProviderInfo.jurisdiction = datasource.jurisdiction.label;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add check for array
|
|
||||||
if(datasource.contentpolicies) {
|
if(datasource.contentpolicies) {
|
||||||
this.dataProviderInfo.contentpolicy = datasource.contentpolicies[0].label;
|
this.dataProviderInfo.contentpolicies = [];
|
||||||
|
datasource.contentpolicies.forEach(contentpolicy => {
|
||||||
|
if(contentpolicy.label) {
|
||||||
|
this.dataProviderInfo.contentpolicies.push(contentpolicy.label);
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if(datasource['datasourcetype']) {
|
if(datasource['datasourcetype']) {
|
||||||
|
|
|
@ -974,41 +974,46 @@ export class ParsingFunctions {
|
||||||
let downloads: number = 0;
|
let downloads: number = 0;
|
||||||
elements.forEach(element => {
|
elements.forEach(element => {
|
||||||
if (element.id == 'views') {
|
if (element.id == 'views') {
|
||||||
let viewsNum = parseInt(element.unit.label);
|
element.unit.forEach(unit => {
|
||||||
views += viewsNum;
|
let viewsNum = parseInt(unit.label);
|
||||||
let datasourceId = element.unit.code;
|
views += viewsNum;
|
||||||
if(datasourceId) {
|
let datasourceId = unit.code;
|
||||||
if(datasourcePosition.has(datasourceId)) {
|
if(datasourceId) {
|
||||||
countsPerDatasource[datasourcePosition.get(datasourceId)].views = viewsNum;
|
if(datasourcePosition.has(datasourceId)) {
|
||||||
} else {
|
countsPerDatasource[datasourcePosition.get(datasourceId)].views = viewsNum;
|
||||||
datasourcePosition.set(datasourceId, countsPerDatasource.length);
|
} else {
|
||||||
countsPerDatasource.push({"datasourceId": datasourceId.split("||")[0], "datasourceName": datasourceId.split("||")[1], "views": viewsNum, "downloads": 0})
|
datasourcePosition.set(datasourceId, countsPerDatasource.length);
|
||||||
|
countsPerDatasource.push({"datasourceId": datasourceId.split("||")[0], "datasourceName": datasourceId.split("||")[1], "views": viewsNum, "downloads": 0})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
// measure.views = element.count;
|
} else if (element.id == 'downloads') {
|
||||||
}
|
element.unit.forEach(unit => {
|
||||||
if (element.id == 'downloads') {
|
let downloadsNum = parseInt(unit.label);
|
||||||
let downloadsNum = parseInt(element.unit.label);
|
downloads += downloadsNum;
|
||||||
downloads += downloadsNum;
|
let datasourceId = unit.code;
|
||||||
let datasourceId = element.unit.code;
|
if (datasourceId) {
|
||||||
if(datasourceId) {
|
if (datasourcePosition.has(datasourceId)) {
|
||||||
if(datasourcePosition.has(datasourceId)) {
|
countsPerDatasource[datasourcePosition.get(datasourceId)].downloads = downloadsNum;
|
||||||
countsPerDatasource[datasourcePosition.get(datasourceId)].downloads = downloadsNum;
|
} else {
|
||||||
} else {
|
datasourcePosition.set(datasourceId, countsPerDatasource.length);
|
||||||
datasourcePosition.set(datasourceId, countsPerDatasource.length);
|
countsPerDatasource.push({
|
||||||
countsPerDatasource.push({"datasourceId": datasourceId.split("||")[0], "datasourceName": datasourceId.split("||")[1], "views": 0, "downloads": downloadsNum})
|
"datasourceId": datasourceId.split("||")[0],
|
||||||
|
"datasourceName": datasourceId.split("||")[1],
|
||||||
|
"views": 0,
|
||||||
|
"downloads": downloadsNum
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
// measure.downloads = element.count;
|
// measure.downloads = element.count;
|
||||||
}
|
} else if (element.id == 'influence_alt' || element.id == 'citation_count') {
|
||||||
if (element.id == 'influence_alt' || element.id == 'citation_count') {
|
|
||||||
for(let unit of element.unit) {
|
for(let unit of element.unit) {
|
||||||
if(unit.code == "score") {
|
if(unit.code == "score") {
|
||||||
bip.push({name: 'citations', icon: 'cite', value: parseInt(element.unit.label), order: 2});
|
bip.push({name: 'citations', icon: 'cite', value: parseInt(unit.label), order: 2});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (element.id == 'popularity' || element.id == 'influence' || element.id == 'impulse') {
|
||||||
if (element.id == 'popularity' || element.id == 'influence' || element.id == 'impulse') {
|
|
||||||
let value = "";
|
let value = "";
|
||||||
for(let unit of element.unit) {
|
for(let unit of element.unit) {
|
||||||
if (unit.code == "class") {
|
if (unit.code == "class") {
|
||||||
|
@ -1029,12 +1034,10 @@ export class ParsingFunctions {
|
||||||
if (element.id == 'popularity') {
|
if (element.id == 'popularity') {
|
||||||
let metric: Metric = {name: 'popularity', icon: 'fire', value: value, order: 3};
|
let metric: Metric = {name: 'popularity', icon: 'fire', value: value, order: 3};
|
||||||
bip.push(metric);
|
bip.push(metric);
|
||||||
}
|
} else if (element.id == 'influence') {
|
||||||
if (element.id == 'influence') {
|
|
||||||
let metric: Metric = {name: 'influence', icon: 'landmark', value: value, order: 4};
|
let metric: Metric = {name: 'influence', icon: 'landmark', value: value, order: 4};
|
||||||
bip.push(metric);
|
bip.push(metric);
|
||||||
}
|
} else if (element.id == 'impulse') {
|
||||||
if (element.id == 'impulse') {
|
|
||||||
let metric: Metric = {name: 'impulse', icon: 'rocket', value: value, order: 5};
|
let metric: Metric = {name: 'impulse', icon: 'rocket', value: value, order: 5};
|
||||||
bip.push(metric);
|
bip.push(metric);
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,14 +138,14 @@ export class ResultLandingService {
|
||||||
if(data["header"]) {
|
if(data["header"]) {
|
||||||
this.resultLandingInfo.objIdentifier = data["header"]["id"];
|
this.resultLandingInfo.objIdentifier = data["header"]["id"];
|
||||||
this.resultLandingInfo.relcanId = ParsingFunctions.parseRelCanonicalId(this.resultLandingInfo.record, "result");
|
this.resultLandingInfo.relcanId = ParsingFunctions.parseRelCanonicalId(this.resultLandingInfo.record, "result");
|
||||||
//this.resultLandingInfo.resultType = data['header']['recordType'];
|
this.resultLandingInfo.resultType = data['header']['recordType'];
|
||||||
|
|
||||||
|
this.resultLandingInfo.underCurationMessage = data["header"]['status'] == "UNDER_CURATION";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data["result"]) {
|
if(data["result"]) {
|
||||||
let result = data["result"];
|
let result = data["result"];
|
||||||
|
|
||||||
this.resultLandingInfo.resultType = result.resulttype;
|
|
||||||
|
|
||||||
let date: string = (result['publicationdate'] ? result['publicationdate'] : '') + ''; // transform to string in case it is an integer
|
let date: string = (result['publicationdate'] ? result['publicationdate'] : '') + ''; // transform to string in case it is an integer
|
||||||
this.resultLandingInfo.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
|
this.resultLandingInfo.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
|
||||||
this.resultLandingInfo.dateofacceptance = result['publicationdate'] ? Dates.getDate(result['publicationdate']) : null;
|
this.resultLandingInfo.dateofacceptance = result['publicationdate'] ? Dates.getDate(result['publicationdate']) : null;
|
||||||
|
@ -342,8 +342,8 @@ export class ResultLandingService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: example?
|
// TODO: example?
|
||||||
if (result["externalreference"]) {
|
if (result["externalReference"]) {
|
||||||
let externalResults: Map<string, Map<string, string>> = this.parseBioentitiesAndSoftware(result["externalreference"]);
|
let externalResults: Map<string, Map<string, string>> = this.parseBioentitiesAndSoftware(result["externalReference"]);
|
||||||
this.resultLandingInfo.bioentities = externalResults;
|
this.resultLandingInfo.bioentities = externalResults;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,12 +421,6 @@ export class ResultLandingService {
|
||||||
// this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[13]);
|
// this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[13]);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// // res['result']['header']['dri:status']
|
|
||||||
// if (data[14] != null && data[14] == "under curation") {
|
|
||||||
// this.resultLandingInfo.underCurationMessage = true;
|
|
||||||
// } else {
|
|
||||||
// this.resultLandingInfo.underCurationMessage = false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
return this.resultLandingInfo;
|
return this.resultLandingInfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,8 +186,8 @@ export class SearchOrganizationsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result['pid']) {
|
if(resBody['pid']) {
|
||||||
result.identifiers = this.parsingFunctions.parseIdentifiers(result['pid']);
|
result.identifiers = this.parsingFunctions.parseIdentifiers(resBody['pid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
results.push(result);
|
results.push(result);
|
||||||
|
|
|
@ -194,11 +194,12 @@ export class SearchResearchResultsService {
|
||||||
let resData = Array.isArray(data) ? data[i]: data;
|
let resData = Array.isArray(data) ? data[i]: data;
|
||||||
var result: SearchResult = new SearchResult();
|
var result: SearchResult = new SearchResult();
|
||||||
try {
|
try {
|
||||||
if (resData.result['resulttype']) {
|
if (resData.header['recordType']) {
|
||||||
result.entityType = resData.result['resulttype'];
|
result.entityType = resData.header['recordType'];
|
||||||
} else {
|
} else {
|
||||||
result.entityType = resultType;
|
result.entityType = resultType;
|
||||||
}
|
}
|
||||||
|
|
||||||
result['title'] = {"name": '', "accessMode": ''};
|
result['title'] = {"name": '', "accessMode": ''};
|
||||||
result['title'].name = (resData.result['maintitle']) ? StringUtils.HTMLToString(resData.result['maintitle']) : "";
|
result['title'].name = (resData.result['maintitle']) ? StringUtils.HTMLToString(resData.result['maintitle']) : "";
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,6 @@ convertDatasource(datasource: any, URL, otherUrl): Organization {
|
||||||
return [item as String];
|
return [item as String];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: schemeid field is missing
|
|
||||||
private getLicense(result: any): License[] {
|
private getLicense(result: any): License[] {
|
||||||
const item = _.get(result, "result.bestaccessright", null);
|
const item = _.get(result, "result.bestaccessright", null);
|
||||||
if (!item) return null;
|
if (!item) return null;
|
||||||
|
@ -390,7 +389,7 @@ convertDatasource(datasource: any, URL, otherUrl): Organization {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: extraInfo missing
|
// TODO: extraInfo missing - should be references, not citations
|
||||||
private getCitation(result: any): Citation[] {
|
private getCitation(result: any): Citation[] {
|
||||||
const item = _.get(result, "result.metadata.oaf:entity.extraInfo.citations.citation", null);
|
const item = _.get(result, "result.metadata.oaf:entity.extraInfo.citations.citation", null);
|
||||||
if (!item) return null;
|
if (!item) return null;
|
||||||
|
|
|
@ -35,7 +35,7 @@ export class DataProviderInfo {
|
||||||
subjects: string[];
|
subjects: string[];
|
||||||
jurisdiction: string;
|
jurisdiction: string;
|
||||||
thematic: boolean;
|
thematic: boolean;
|
||||||
contentpolicy: string;
|
contentpolicies: string[];
|
||||||
identifiers: Map<string, string[]>; //key is the classname
|
identifiers: Map<string, string[]>; //key is the classname
|
||||||
|
|
||||||
fundedContent: string; // search query
|
fundedContent: string; // search query
|
||||||
|
|
Loading…
Reference in New Issue