Class for parsing functions created | Parsing for rels/rel/funding in publication/dataset landings & fundingTree in project landing moved to parseFundingTrees functions of parsingFunctions.class | In filters of search pages 'Show More' renamed to 'View more' with an icon and modal for filters became wider

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@48177 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2017-06-30 09:56:56 +00:00
parent a75ca69828
commit 629c38512b
6 changed files with 133 additions and 37 deletions

View File

@ -188,7 +188,7 @@ export class DatasetComponent {
}
if(item.code || item.funderName || item.funderShortname || item.funding) {
tooltipContent += "<p>";
tooltipContent += "</p>";
}
if(item.provenanceAction == 'Repository') {

View File

@ -7,12 +7,16 @@ import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import { CacheService } from '../../shared/cache.service';
import { ParsingFunctions } from '../landing-utils/parsingFunctions.class';
@Injectable()
export class DatasetService {
constructor(private http: Http, public _cache: CacheService) {}
constructor(private http: Http, public _cache: CacheService) {
this.parsingFunctions = new ParsingFunctions();
}
public parsingFunctions: ParsingFunctions;
datasetInfo: DatasetInfo;
getDatasetInfo (id: string):any {
@ -141,7 +145,7 @@ export class DatasetService {
this.datasetInfo.fundedByProjects[counter]['provenanceAction'] = "";
}
/*
if(mydata.hasOwnProperty("funding")) {
let length1 = Array.isArray(mydata['funding']) ? mydata['funding'].length : 1;
@ -176,6 +180,21 @@ export class DatasetService {
}
}
}
*/
if(mydata.hasOwnProperty("funding")) {
let funding: {"funderName": string, "funderShortname": string, "stream": string};
funding = this.parsingFunctions.parseFundingTrees(mydata.funding);
if(funding.funderName) {
this.datasetInfo.fundedByProjects[counter]['funderName'] = funding.funderName;
}
if(funding.funderShortname) {
this.datasetInfo.fundedByProjects[counter]['funderShortname'] = funding.funderShortname;
}
if(funding.stream) {
this.datasetInfo.fundedByProjects[counter]['funding'] = funding.stream;
}
}
} else if(mydata['to'].class == "isRelatedTo") {
let provenanceAction: string;
if(mydata.provenanceaction in this.datasetInfo.provenanceVocabulary) {

View File

@ -0,0 +1,69 @@
export class ParsingFunctions {
constructor () {}
public ngOnDestroy() {}
public parseFundingTrees(fundingTree: any): {"funderName": string, "funderShortname": string, "stream": string} {
let funding: {"funderName": string, "funderShortname": string, "stream": string} = {"funderName": "", "funderShortname": "", "stream": ""};
let length = Array.isArray(fundingTree) ? fundingTree.length : 1;
for(let i=0; i<length; i++) {
let fundingData = Array.isArray(fundingTree) ? fundingTree[i] : fundingTree;
if(fundingData.hasOwnProperty("funder")) {
funding.funderShortname = fundingData['funder'].shortname;
funding.funderName = fundingData['funder'].name;
}
funding.stream = this.addFundingLevel0(fundingData, funding.stream);
funding.stream = this.addFundingLevel1(fundingData, funding.stream);
funding.stream = this.addFundingLevel2(fundingData, funding.stream);
}
return funding;
}
addFundingLevel0(parent: string, fundingStream: string) : string {
if(parent.hasOwnProperty("funding_level_0")) {
let level0 = parent['funding_level_0'];
fundingStream += (fundingStream) ? " ; " : "";
fundingStream += level0.name;
}
return fundingStream;
}
addFundingLevel1(parent: string, fundingStream: string): string {
if(parent.hasOwnProperty("funding_level_1")) {
let level1 = parent['funding_level_1'];
// For projects' parsing
if(level1.hasOwnProperty("parent")) {
fundingStream = this.addFundingLevel0(level1.parent, fundingStream);
}
fundingStream += (fundingStream) ? " | " : "";
fundingStream += level1.name;
}
return fundingStream;
}
addFundingLevel2(parent: string, fundingStream: string): string {
if(parent.hasOwnProperty("funding_level_2")) {
let level2 = parent['funding_level_2'];
// For projects' parsing
if(level2.hasOwnProperty("parent")) {
fundingStream = this.addFundingLevel1(level2.parent, fundingStream);
}
fundingStream += (fundingStream) ? " | " : "";
fundingStream += level2.name;
}
return fundingStream;
}
}

View File

@ -7,11 +7,16 @@ import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import { CacheService } from '../../shared/cache.service';
import { ParsingFunctions } from '../landing-utils/parsingFunctions.class';
@Injectable()
export class ProjectService {
constructor(private http: Http, public _cache: CacheService) {}
constructor(private http: Http, public _cache: CacheService) {
this.parsingFunctions = new ParsingFunctions();
}
public parsingFunctions: ParsingFunctions;
projectInfo: ProjectInfo;
getProjectInfo (id: string):any {
@ -113,6 +118,7 @@ export class ProjectService {
this.projectInfo.specialClause39 = data[0].ecsc39;
}
if(data[1] != null) {
/*
if(data[1]['funder'] != null) {
this.projectInfo.funder = data[1]['funder'].shortname;
}
@ -137,6 +143,22 @@ export class ProjectService {
this.projectInfo.funding += funding[i];
}
}
*/
let funding: {"funderName": string, "funderShortname": string, "stream": string};
funding = this.parsingFunctions.parseFundingTrees(data[1]);
// if(funding.funderName) {
// this.publicationInfo.fundedByProjects[counter]['funderName'] = funding.funderName;
// }
if(funding.funderShortname) {
this.projectInfo.funder = funding.funderShortname;
}
if(funding.stream) {
this.projectInfo['funding'] = funding.stream;
}
console.info("funder="+this.projectInfo.funder);
console.info("stream="+this.projectInfo.funding);
}
if(data[2] != null) {

View File

@ -7,11 +7,17 @@ import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import { CacheService } from '../../shared/cache.service';
import { ParsingFunctions } from '../landing-utils/parsingFunctions.class';
@Injectable()
export class PublicationService {
constructor(private http: Http, public _cache: CacheService) {}
constructor(private http: Http, public _cache: CacheService) {
this.parsingFunctions = new ParsingFunctions();
}
public parsingFunctions: ParsingFunctions;
publicationInfo: PublicationInfo;
getPublicationInfo (id: string):any {
@ -143,37 +149,17 @@ export class PublicationService {
}
if(relation.hasOwnProperty("funding")) {
let length1 = Array.isArray(relation['funding']) ? relation['funding'].length : 1;
let funding: {"funderName": string, "funderShortname": string, "stream": string};
funding = this.parsingFunctions.parseFundingTrees(relation.funding);
for(let j=0; j<length1; j++) {
let funding;
let fundingData = Array.isArray(relation['funding']) ? relation['funding'][j] : relation['funding'];
if(fundingData.hasOwnProperty("funder")) {
this.publicationInfo.fundedByProjects[counter]['funderShortname'] = fundingData['funder'].shortname;
this.publicationInfo.fundedByProjects[counter]['funderName'] = fundingData['funder'].name;
}
if(fundingData.hasOwnProperty("funding_level_2")) {
funding = fundingData['funding_level_2'].name;//.content;
} else if(fundingData.hasOwnProperty("funding_level_1")) {
funding = fundingData['funding_level_1'].name;//.content;
} else if(fundingData.hasOwnProperty("funding_level_0")) {
funding = fundingData['funding_level_0'].name;//.content;
}
if(funding != undefined) {
// funding = funding.split("::");
if(this.publicationInfo.fundedByProjects[counter]['funding'] != "") {
this.publicationInfo.fundedByProjects[counter]['funding'] += ", "+funding;//[1];
} else {
this.publicationInfo.fundedByProjects[counter]['funding'] = funding;//[1];
}
// for(let i=2; i<funding.length; i++) {
// this.publicationInfo.fundedByProjects[counter]['funding'] += " | " + funding[i];
// }
}
if(funding.funderName) {
this.publicationInfo.fundedByProjects[counter]['funderName'] = funding.funderName;
}
if(funding.funderShortname) {
this.publicationInfo.fundedByProjects[counter]['funderShortname'] = funding.funderShortname;
}
if(funding.stream) {
this.publicationInfo.fundedByProjects[counter]['funding'] = funding.stream;
}
}
} else if(relation['to'].class == "isRelatedTo") {

View File

@ -36,11 +36,11 @@ import {Open} from '../../utils/modal/open.component';
Show More
</button-->
<a *ngIf="(getSelectedValues(filter).length + getNotSelectedValues(filter).length) > 5" (click)="open()" [class]="(isDisabled)?'uk-disabled uk-link-muted':''">Show More</a>
<a *ngIf="(getSelectedValues(filter).length + getNotSelectedValues(filter).length) > 5" (click)="open()" [class]="(isDisabled)?'uk-disabled uk-link-muted':''">View more<span uk-icon="icon: triangle-right"></span></a>
<div [class]="(!isOpen)?'uk-modal ':'uk-modal uk-open uk-animation-fade'" uk-modal [open]="!isOpen" id="modal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" bg-close="true">
<div class="uk-modal-dialog uk-width-1-4 uk-padding-small uk-padding-remove-top uk-padding-remove-horizontal">
<div class="uk-modal-dialog uk-width-1-3 uk-padding-small uk-padding-remove-top uk-padding-remove-horizontal">
<button type="button" class="uk-modal-close-default" uk-close (click)="close()"></button>
<h3 class="uk-margin-remove uk-padding uk-padding-remove-bottom">
{{filter.title}}