Project

General

Profile

1
import {Component, ViewChild} from '@angular/core';
2
import {Observable} from 'rxjs/Observable';
3
import {PublicationService} from '../../services/publication.service';
4
import {PublicationInfo} from '../../utils/entities/publicationInfo';
5
import {ActivatedRoute} from '@angular/router';
6
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
7
import {InlineClaimContextComponent} from '../../claimPages/inlineClaims/inlineClaimContext.component';
8
import {InlineClaimProjectComponent} from '../../claimPages/inlineClaims/inlineClaimProject.component';
9
import {InlineClaimResultComponent} from '../../claimPages/inlineClaims/inlineClaimResult.component';
10

    
11
@Component({
12
    selector: 'publication',
13
    templateUrl: 'publication.component.html',
14

    
15
})
16

    
17
export class PublicationComponent {
18
  public showAllCollectedFrom: boolean = false;
19
  public showAllDownloadFrom: boolean = false;
20
  public showAllFundedBy: boolean = false;
21
  public showAllPublishedIn: boolean = false;
22

    
23
  public start ;public end ;
24
  constructor (private _publicationService: PublicationService, private route: ActivatedRoute) {
25
    this.start = new Date().getTime();
26
  }
27
  ngOnInit() {
28
    this.sub =  this.route.queryParams.subscribe(data => {
29
      this.articleId = data['articleId'];
30
      console.info("Article id is :"+this.articleId);
31
       if(this.articleId){
32
        this.getPublicationInfo(this.articleId);
33
      }else{
34
        console.info("Article id not found");
35
      }
36
      this.end = new Date().getTime();
37
      var time = this.end - this.start;
38
      console.log('ngOnInit:Execution time: ' + time);
39

    
40
  });
41

    
42

    
43
}
44
ngAfterContentInit() {
45
  this.end = new Date().getTime();
46
  var time = this.end - this.start;
47
  console.log('ngAfterContentInit:Execution time: ' + time);
48
 }
49

    
50
ngAfterViewChecked() {
51
  // console.info("indentifiers:"+(this.publicationInfo != undefined&& this.publicationInfo.identifiers!= undefined)?this.publicationInfo.identifiers.size:"-");
52

    
53
  this.end = new Date().getTime();
54
  var time = this.end - this.start;
55
  console.log('ngAfterViewChecked: Execution time: ' + time);
56
 }
57

    
58
  ngOnDestroy() {
59
    this.sub.unsubscribe();
60
  }
61
  sub: any;
62
  articleId: string;
63
  private publicationInfo: PublicationInfo;
64

    
65
  public showAllReferences: boolean = false;
66
  public showAllRelResData: boolean = false;
67
  public showAllSimilPubl: boolean = false;
68
  public showAllBioentities: boolean = false;
69
  public showFundingDetails: boolean = false;
70

    
71
  public bioentitiesNum: number = 0;
72

    
73
  public result ;
74

    
75
  @ViewChild (InlineClaimProjectComponent) inlineClaimProject : InlineClaimProjectComponent ;
76
  @ViewChild (InlineClaimContextComponent) inlineClaimContext : InlineClaimContextComponent ;
77
  @ViewChild (InlineClaimResultComponent) inlineClaimResult : InlineClaimResultComponent ;
78

    
79
  public warningMessage = "";
80
  public errorMessage = "";
81

    
82
  public activeTab: string = '';
83

    
84
  public myfunct(tab: string) {
85
     this.activeTab = tab;
86
  }
87

    
88
  getPublicationInfo(id:string) {
89
    this.warningMessage = '';
90
    this.errorMessage=""
91
    if(this.articleId==null || this.articleId==''){
92
      this.warningMessage="No valid publication id";
93
     }else{
94
       this._publicationService.getPublicationInfo(this.articleId).subscribe(
95
        data => {
96
            this.publicationInfo = data;
97
            // this.result = []
98
            // this.result = {id: id, type :"dataset", source : "openaire", title: this.publicationInfo.title,url: '', result: '', accessRights: this.publicationInfo.bestlicense, embargoEndDate: ''};
99

    
100
                    let bioentitiesNum = 0;
101
                    if(this.publicationInfo.bioentities != undefined) {
102
                        this.publicationInfo.bioentities.forEach(function (value, key, map) {
103
                            bioentitiesNum += value.size;
104
                        });
105
                    }
106
                    this.bioentitiesNum = bioentitiesNum;
107

    
108
                    this.result = {id: this.articleId, type :"publication", source : "openaire", title: this.publicationInfo.title,url: '', result: '', accessRights: this.publicationInfo.bestlicense, embargoEndDate: ''};
109
                    // this.result.push(result_);
110
        },
111
        err => {
112
          console.error(err);
113
          console.info("error");
114

    
115
          this.errorMessage = 'No publication found';
116
        }
117
      );
118
    }
119
   }
120

    
121
   /*
122
   ********* Methods for Inline Claim  of project / publication *****
123
     */
124
   toggleClaimProject(){
125
      this.inlineClaimProject.toggle();
126
   }
127
   projectAdded($event){
128
     var projects =$event.value;
129
     if(projects){
130
        for(var i=0; i < projects.length; i++){
131

    
132
                if(this.publicationInfo.fundedByProjects == undefined) {
133
                    this.publicationInfo.fundedByProjects = new Array<
134
                        { "url": string, "acronym": string, "title": string,
135
                          "funderShortname": string, "funderName": string,
136
                          "funding": string, "code": string, "inline": boolean
137
                        }>();
138
                }
139
                var project =projects[i];
140

    
141
                let counter = this.publicationInfo.fundedByProjects.length;
142
                this.publicationInfo.fundedByProjects[counter] = {
143
                    "url": "", "acronym": "", "title": "",
144
                    "funderShortname": "", "funderName": "",
145
                    "funding": "", "code": "", "inline": true
146
                }
147
                this.publicationInfo.fundedByProjects[counter]['url'] =
148
                    OpenaireProperties.getsearchLinkToProject() + project.projectId;
149
                this.publicationInfo.fundedByProjects[counter]['acronym'] = project.projectAcronym;
150
                // TODO ARGIRO : code is undefined? this field was missing before
151
                this.publicationInfo.fundedByProjects[counter]['code'] = "-";
152
                this.publicationInfo.fundedByProjects[counter]['title'] = project.projectName;
153
                this.publicationInfo.fundedByProjects[counter]['funderShortname'] = project.funderName;
154
        }
155
      }
156
    }
157
    toggleClaimContext(){
158
       this.inlineClaimContext.toggle();
159
    }
160
    contextAdded($event){
161
      var contexts =$event.value;
162
      if(contexts){
163
         for(var i=0; i < contexts.length; i++){
164
           var context = contexts[i];
165
           if(!this.publicationInfo.contexts){
166
             this.publicationInfo.contexts =  new Array<
167
                 { "labelContext": string, "labelCategory": string, "labelConcept": string, "inline": boolean}>();
168

    
169
           }
170
           var position:number = this.publicationInfo.contexts.length;
171

    
172
           this.publicationInfo.contexts[ position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: true };
173
           this.publicationInfo.contexts[position]['labelContext'] = context.community;
174
           this.publicationInfo.contexts[position]['labelCategory'] = context.category;
175
           this.publicationInfo.contexts[position]['labelConcept'] = context.concept.label;
176

    
177

    
178
         }
179
       }
180
     }
181
     toggleClaimResult(){
182
        this.inlineClaimResult.toggle();
183
     }
184
     resultsAdded($event, isPublication:boolean){
185
       var results =$event.value;
186

    
187
      //TODO
188
      }
189

    
190
    showChange($event) {
191
        this.showAllReferences=$event.value;
192
    }
193

    
194

    
195
}
(2-2/2)