Project

General

Profile

« Previous | Next » 

Revision 43956

Search Dataproviders completed | bug fixed in search Publications (title)

View differences:

modules/uoa-services-portal/trunk/portal-2/src/app/utils/entities/searchResult.ts
11 11
    //datasets:
12 12
    publisher: string;
13 13
    //dataproviders & projects:
14
    organizations: { "name": string, "url": string};
14
    organizations: { "name": string, "url": string }[];
15 15
    //projects:
16 16
    funders: string;
17 17
    //organizations:
modules/uoa-services-portal/trunk/portal-2/src/app/services/searchDataproviders.service.ts
1
import {Injectable} from '@angular/core';
2
import {Http, Response} from '@angular/http';
3
import {Observable}     from 'rxjs/Observable';
4
import {OpenaireProperties} from '../utils/properties/openaireProperties';
5
import {SearchResult}     from '../utils/entities/searchResult';
6

  
7
@Injectable()
8
export class SearchDataprovidersService {
9
    constructor(private http: Http) {}
10

  
11
    searchDataproviders (params: string, page: number, size: number):any {
12

  
13
        console.info("In searchDataproviders");
14

  
15
        let link = OpenaireProperties.getSearchAPIURL()+"datasources";
16

  
17
        let url = link+"?";
18
        if(params != '') {
19
            url += "q="+params+"&page="+page+"&size="+size;
20
        } else {
21
            url += "page="+page+"&size="+size;
22
        }
23

  
24
        return this.http.get(url)
25
                    .map(res => <any> res.json())
26
                    .do(res => console.info(res))
27
                    //.map(res => []);
28
                    .map(res => [res['meta'].total, this.parseResults(res['results'])])
29
                    ;
30
    }
31

  
32

  
33
    parseResults(data: any): SearchResult[] {
34
        let results: SearchResult[] = [];
35

  
36
        let length = Array.isArray(data) ? data.length : 1;
37

  
38
        for(let i=0; i<length; i++) {
39
            let resData = length > 1 ? data[i]['result']['metadata']['oaf:entity']['oaf:datasource'] : data['result']['metadata']['oaf:entity']['oaf:datasource'];
40

  
41
            var result: SearchResult = new SearchResult();
42

  
43
            result['title'] = {"name": '', "url": '', "accessMode": ''};
44

  
45
            result['title'].name = resData.officialname;
46

  
47
            result['title'].url = OpenaireProperties.getsearchLinkToDataProvider();
48
            result['title'].url += length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
49

  
50
            if(resData['datasourcetype'].hasOwnProperty("classname")) {
51
                result['type'] = resData['datasourcetype'].classname;
52
            }
53

  
54
            if(resData['accessinfopackage'] != '') {
55
                if(Array.isArray(resData['accessinfopackage'])) {
56
                    result['OAIPMHURL'] = resData['accessinfopackage'][0];
57
                } else {
58
                    result['OAIPMHURL'] = resData['accessinfopackage'];
59
                }
60
            }
61

  
62
            result['websiteURL'] = resData.websiteurl;
63

  
64
            if(resData['rels'].hasOwnProperty("rel")) {
65
                let counter = 0;
66
                let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
67

  
68
                for(let i=0; i<relLength; i++) {
69
                    let relation = relLength > 1 ? resData['rels']['rel'][i] : resData['rels']['rel'];
70

  
71
                    if(relation.hasOwnProperty("to")) {
72
                        if(relation['to'].class == "provides" && relation['to'].type == "organization") {
73
                            if(result['organizations'] == undefined) {
74
                                result['organizations'] = new Array<{"name": string, "url": string}>();
75
                            }
76

  
77
                            result['organizations'][counter] = {"name": "", "url": ""};
78
                            result['organizations'][counter]['name'] = relation.legalname;
79
                            result['organizations'][counter]['url'] = OpenaireProperties.getsearchLinkToOrganization()+relation['to'].content;
80

  
81
                            counter++;
82
                        }
83
                    }
84
                }
85
            }
86

  
87
            results.push(result);
88

  
89
        }
90

  
91
        return results;
92
    }
93
}
modules/uoa-services-portal/trunk/portal-2/src/app/services/searchPublications.service.ts
42 42
            var result: SearchResult = new SearchResult();
43 43

  
44 44
            result['title'] = {"name": '', "url": '', "accessMode": ''};
45
            if(resData['title'].hasOwnProperty("content")) {
46
                result['title'].name = resData['title'].content;
45

  
46
            if(Array.isArray(resData['title'])) {
47
                resData['title'][0].hasOwnProperty("content") {
48
                    result['title'].name = resData['title'][0].content;
49
                }
50
            } else {
51
                resData['title'].hasOwnProperty("content") {
52
                    result['title'].name = resData['title'].content;
53
                }
47 54
            }
55

  
48 56
            result['title'].url = OpenaireProperties.getsearchLinkToPublication();
49 57
            result['title'].url += length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
50 58
            if(resData['bestlicense'].hasOwnProperty("classid")) {
modules/uoa-services-portal/trunk/portal-2/src/app/services/dataProvider.service.ts
93 93

  
94 94
                        this.dataProviderInfo.organizations[counter] = {"name": "", "url": ""};
95 95
                        this.dataProviderInfo.organizations[counter]['name'] = mydata.legalname;
96
                        this.dataProviderInfo.organizations[counter]['url'] = mydata.websiteUrl;
96
                        this.dataProviderInfo.organizations[counter]['url'] = OpenaireProperties.getsearchLinkToOrganization()+mydata['to'].content;
97 97

  
98 98
                        counter++;
99 99
                    }
modules/uoa-services-portal/trunk/portal-2/src/app/services/organization.service.ts
14 14
    getOrganizationInfo (id: string):any {
15 15
        console.info("getOrganizationInfo in service");
16 16

  
17
        let url = OpenaireProperties.getSearchAPIURL()+'organisations/'+id;
17
        let url = OpenaireProperties.getSearchAPIURL()+'organizations/'+id;
18 18

  
19 19
        return this.http.get(url)
20 20
                    .map(res => <any> res.json())
modules/uoa-services-portal/trunk/portal-2/src/app/services/services.module.ts
16 16
import { SearchOrcidService } from './searchOrcid.service';
17 17
import {SearchPublicationsService} from './searchPublications.service';
18 18
import {DataProviderService} from './dataProvider.service';
19
import {SearchDataprovidersService} from './searchDataproviders.service';
19 20

  
20 21

  
21 22

  
22

  
23 23
@NgModule({
24 24
  imports: [
25
    CommonModule, FormsModule,
25
    CommonModule, FormsModule
26 26
  ],
27 27
  declarations: [
28 28
  ],
......
30 30
    ContextsService, DatasetService, OpenaireProjectsService,OrganizationService,
31 31
    PersonService, ProjectService, PublicationService, SearchCrossrefService,
32 32
    SearchCrossrefService, SearchDataciteService, SearchOrcidService,
33
    SearchPublicationsService, DataProviderService
33
    SearchPublicationsService, SearchDataprovidersService, DataProviderService
34 34

  
35 35
  ],
36 36
  exports: [
modules/uoa-services-portal/trunk/portal-2/src/app/searchPages/searchDataproviders.component.ts
1
import {Component, Input, ViewChild} from '@angular/core';
2
import { ActivatedRoute} from '@angular/router';
3

  
4
import { Filter, Value} from './searchUtils/searchHelperClasses.class';
5

  
6
import {SearchDataprovidersService} from '../services/searchDataproviders.service';
7
import {SearchResult}     from '../utils/entities/searchResult';
8
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
9

  
10
@Component({
11
    selector: 'search-dataproviders',
12
    template: `
13

  
14
    <search-page pageTitle="Search Dataproviders" type="datasource" [(filters)] = "filters"
15
                 [(results)] = "results" [(totalResults)] = "totalResults" [(keyword)] = "keyword"
16
                 [(page)] = "page" [(size)] = "size" [(status)] = "status" [baseUrl] = "baseUrl" (queryChange)="queryChanged($event)"  >
17
    </search-page>
18

  
19
    `
20

  
21
})
22
export class SearchDataprovidersComponent {
23
  public results =[];
24
  private filters =[];
25
  public totalResults:number  = 0 ;
26
  private baseUrl:string;
27
  public status:number;
28
  private keyword = '';
29
  private page :number = 1;
30
  private size :number = 10;
31
  private sub: any;
32

  
33
  constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) {
34
    //this.results =[];
35
    //this.filters =[];
36
    var errorCodes:ErrorCodes = new ErrorCodes();
37
    this.status =errorCodes.LOADING;
38
    this.baseUrl = OpenaireProperties.getLinkToSearchPublications();
39
  }
40

  
41
  private ngOnInit() {
42
    this.sub =  this.route.queryParams.subscribe(params => {
43
    this.keyword = (params['keyword']?params['keyword']:'');
44
    this.page = (params['page']=== undefined)?1:+params['page'];
45
    for(var i=0; i<5 ; i++){
46
           var  values = [];
47
           for(var j=0; j<10 ; j++){
48
             var value:Value = {name: "name"+j, id: "filter_"+i+ "_id_"+j, number:j, selected:false}
49
             values.push(value);
50
           }
51
           values.sort((n2,n1) => {
52
              if (n1.number > n2.number) {
53
                  return 1;
54
              }
55

  
56
              if (n1.number < n2.number) {
57
                  return -1;
58
              }
59

  
60
              return 0;
61
          });
62
          var filter:Filter = {title: "title"+i, filterId: "filter_"+i, originalFilterId: "filter_"+i, values : values, countSelectedValues:0, "filterOperator": 'and'}
63
          if(i==0) {
64
              var  values = [];
65
              for(var j=0; j<10 ; j++){
66
                var value:Value = {name: "MYname"+j, id: "MYfilter_"+i+ "_id_"+j, number:j, selected:false}
67
                values.push(value);
68
              }
69
              values.sort((n2,n1) => {
70
                 if (n1.number > n2.number) {
71
                     return 1;
72
                 }
73

  
74
                 if (n1.number < n2.number) {
75
                     return -1;
76
                 }
77

  
78
                 return 0;
79
              });
80
              var filter1:Filter = {title: "MYtitle"+i, filterId: "MYfilter_"+i, originalFilterId: "MYfilter_"+i, values : values, countSelectedValues:0, "filterOperator": 'or'}
81
              this.filters.push(filter1);
82
              this.getResults(this.keyword, this.page, this.size);
83

  
84
          }
85

  
86

  
87

  
88
           console.info(params);
89
          if(params[filter.filterId] != undefined) {
90
              let values = params[filter.filterId].split(",");
91
              for(let value of values) {
92
                  for(let filterValue of filter.values) {
93
                      if(filterValue.id == value) {
94
                          filterValue.selected = true;
95
                          filter.countSelectedValues++;
96
                      }
97
                  }
98
              }
99
          }
100
      }
101

  
102
    });
103
  }
104

  
105
  private ngOnDestroy() {
106
    this.sub.unsubscribe();
107
  }
108

  
109
  public getResults(parameters:string, page: number, size: number){
110
    console.info("getResults: Execute search query "+parameters);
111

  
112
    this._searchDataprovidersService.searchDataproviders(parameters, page, size).subscribe(
113
        data => {
114
            this.totalResults = data[0];
115
            console.info("searchPubl total="+this.totalResults);
116
            this.results = data[1];
117
            var errorCodes:ErrorCodes = new ErrorCodes();
118
             this.status = errorCodes.DONE;
119
            if(this.totalResults == 0 ){
120
              this.status = errorCodes.NONE;
121
            }
122
        },
123
        err => {
124
            console.error(err);
125
            console.info("error");
126
            //TODO check erros (service not available, bad request)
127
            // if( ){
128
            //   this.status = ErrorCodes.ERROR;
129
            // }
130
            var errorCodes:ErrorCodes = new ErrorCodes();
131
            this.status = errorCodes.NOT_AVAILABLE;
132
        }
133
    );
134
  }
135

  
136
  private setFilters(){
137
    //TODO set filters from
138
  }
139

  
140
  private queryChanged($event) {
141
    var parameters = $event.value;
142
    console.info("queryChanged: Execute search query "+parameters);
143
    this.getResults(parameters, this.page, this.size);
144
  }
145

  
146

  
147
}
modules/uoa-services-portal/trunk/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts
62 62
  @Input() size: number = 10;
63 63
  @Input() status: number;
64 64
  @Input() totalResults: number = 0;
65
  @Input() keyword:string = '';
65
  @Input() keyword: string = '';
66
  @Output() queryChange  = new EventEmitter();
66 67
  @Input() baseUrl:string = '';
67 68

  
68
  test= { value: 0};
69

  
70
  @Output() queryChange  = new EventEmitter();
71 69
  constructor (private location: Location) {
72 70

  
73 71
  }
......
77 75
    console.log("  search page st: "+this.status);
78 76
    //this.totalResults = this.totalResults;
79 77
    console.info("searchPage total="+this.totalResults);
78
    console.info("searchPage: results.length = "+this.results.length);
80 79
  }
81 80

  
82 81
  changekeyword(){
......
162 161
    this.page = page;
163 162
    var urlParameters = this.createUrlParameters();
164 163
    var queryParameters = this.createQueryParameters();
164
    console.info(location.pathname);
165 165
    this.location.go(location.pathname,urlParameters);
166 166
    this.queryChange.emit({
167 167
        value: queryParameters
modules/uoa-services-portal/trunk/portal-2/src/app/searchPages/searchUtils/searchResult.component.ts
13 13

  
14 14
        <li *ngFor="let result of results">
15 15
            <h4>
16
                <a class="custom-external" href="{{result['title'].url}}" target="_blank">
16
                <a href="{{result['title'].url}}">
17 17
                    <p *ngIf="result['title'].name != undefined && result['title'].name != ''">
18 18
                        {{result['title'].name}}
19 19
                    </p>
......
26 26
            <div>
27 27
                <span *ngIf="result['authors'] != undefined">
28 28
                    <span *ngFor="let author of result['authors'].slice(0,15)">
29
                        <a class="custom-external" href="{{author['url']}}" target="_blank">
29
                        <a href="{{author['url']}}">
30 30
                            {{author['name']}};
31 31
                        </a>
32 32
                    </span>
33 33
                    <span *ngIf="result['authors'].length > 15">...</span>
34 34
                </span>
35
                <span *ngIf="result.year != ''">
35
                <span *ngIf="result.year != undefined && result.year != ''">
36 36
                    ({{result.year}})
37 37
                </span>
38 38
            </div>
......
40 40
            <div *ngIf="result['projects'] != undefined">
41 41
                <span> Projects: </span>
42 42
                <span *ngFor="let project of result['projects'] let i=index">
43
                    <a *ngIf="project.url != undefined"
44
                        class="custom-external" href="{{project.url}}" target="_blank">
43
                    <a *ngIf="project.url != undefined" href="{{project.url}}">
45 44
                            {{project['funderShortname']?project['funderShortname']:project['funderName']}}
46 45
                            | {{ project['acronym']?project['acronym']:project['title']}} ({{project.code}})
47 46
                    </a>
......
57 56
                <div class="text-justify" [innerHTML]="result.description"></div>
58 57
            </blockquote>
59 58

  
60
            <mark *ngIf="result.embargoEndDate != ''">Embargo End Date: {{result.embargoEndDate}}</mark>
59
            <mark *ngIf="result.embargoEndDate != undefined && result.embargoEndDate != ''">Embargo End Date: {{result.embargoEndDate}}</mark>
61 60

  
61

  
62
            <div *ngIf="result['organizations'] != undefined">
63
                <span> Organizations: </span>
64
                <span *ngFor="let organization of result['organizations'] let i=index">
65
                    <a *ngIf="organization.url != undefined" href="{{organization.url}}">
66
                            {{organization.name}}
67
                    </a>
68
                    <span *ngIf="organization.url == undefined">
69
                        {{organization.name}}
70
                    </span>
71
                    <span *ngIf="i < result['organizations'].length-1"> ,</span>
72
                </span>
73
            </div>
74

  
75
            <div *ngIf="result['type'] != undefined && result['type'] != ''">Type: {{result['type']}}</div>
76
            <div *ngIf="result['websiteURL'] != undefined && result['websiteURL'] != ''">
77
                <span>Website URL: </span>
78
                <span>
79
                    <a class="custom-external" href="{{result['websiteURL']}}" target="_blank">
80
                        {{result['websiteURL']}}
81
                    </a>
82
                </span>
83
            </div>
84
            <div *ngIf="result['OAIPMHURL'] != undefined && result['OAIPMHURL'] != ''">
85
                <span>OAI-PMH URL: </span>
86
                <span>
87
                    <a class="custom-external" href="{{result['OAIPMHURL']}}" target="_blank">
88
                        {{result['OAIPMHURL']}}
89
                    </a>
90
                </span>
91
            </div>
92

  
62 93
            <hr>
63 94
        </li>
64 95
    </ul>
......
72 103
    @Input() status: number;
73 104
    errorCodes:ErrorCodes = new ErrorCodes();
74 105

  
75
    private errorMessage: string = "";
106
    private errorMessage: string = "No results found";
76 107
/*
77 108
    @Input() title;
78 109
    @Input() id;
modules/uoa-services-portal/trunk/portal-2/src/app/searchPages/searchPublications.component.ts
31 31
  private sub: any;
32 32

  
33 33
  constructor (private route: ActivatedRoute, private _searchPublicationsService: SearchPublicationsService ) {
34
    this.results =[];
35
    this.filters =[];
34
    //this.results =[];
35
    //this.filters =[];
36 36
    var errorCodes:ErrorCodes = new ErrorCodes();
37 37
    this.status =errorCodes.LOADING;
38 38
    this.baseUrl = OpenaireProperties.getLinkToSearchPublications();
39
  }
39 40

  
40

  
41

  
42
  }
43 41
  private ngOnInit() {
44 42
    this.sub =  this.route.queryParams.subscribe(params => {
45 43
    this.keyword = (params['keyword']?params['keyword']:'');
modules/uoa-services-portal/trunk/portal-2/src/app/searchPages/search.module.ts
20 20
import {AdvancedSearchFormComponent} from './searchUtils/advancedSearchForm.component';
21 21
import { SearchPublicationsComponent } from './searchPublications.component';
22 22
import { AdvancedSearchPublicationsComponent } from './advancedSearchPublications.component';
23
import { SearchDataprovidersComponent } from './searchDataproviders.component';
23 24

  
24 25
import {SearchComponent} from './find/search.component';
25 26

  
27

  
26 28
@NgModule({
27 29
  imports: [
28 30
    CommonModule, FormsModule,
29 31
    UtilsModule,
30
    ServicesModule,
32
    ServicesModule
31 33

  
32 34
  ],
33 35
  declarations: [
......
41 43
    AdvancedSearchFormComponent,
42 44
    SearchPublicationsComponent,
43 45
    AdvancedSearchPublicationsComponent,
46
    SearchDataprovidersComponent,
44 47
    SearchComponent
45 48

  
46

  
47 49
  ],
48 50
  providers:[
49 51
    // SearchPublicationsService
......
52 54
      SearchAllComponent,
53 55
      AdvancedSearchPublicationsComponent,
54 56
      SearchPublicationsComponent,
57
      SearchDataprovidersComponent,
55 58
      SearchComponent
56 59
    ]
57 60
})
modules/uoa-services-portal/trunk/portal-2/src/app/app.routing.ts
15 15
import { SearchComponent } from './searchPages/find/search.component';
16 16
import { SearchPublicationsComponent } from './searchPages/searchPublications.component';
17 17
import { AdvancedSearchPublicationsComponent } from './searchPages/advancedSearchPublications.component';
18
import { SearchDataprovidersComponent } from './searchPages/searchDataproviders.component';
18 19
import { DepositComponent } from './deposit/deposit.component';
19 20
import { DepositResultComponent } from './deposit/depositResult.component';
20 21
import { ErrorPageComponent } from './error/errorPage.component';
......
24 25

  
25 26
const appRoutes: Routes = [
26 27
	{ path: '', component: SearchComponent, pathMatch: 'full' },
27
  { path: 'claims', component: ClaimsAdminComponent },
28
  { path: 'home', component: HomeComponent },
29
  { path: 'claim', component: ClaimComponent },
30
  { path: 'myclaims', component: MyClaimsComponent },
28
	{ path: 'claims', component: ClaimsAdminComponent },
29
  	{ path: 'home', component: HomeComponent },
30
  	{ path: 'claim', component: ClaimComponent },
31
  	{ path: 'myclaims', component: MyClaimsComponent },
31 32
	{ path: 'search/person', component: PersonComponent },
32 33
	{ path: 'search/project', component: ProjectComponent },
33 34
	{ path: 'search/organization', component: OrganizationComponent },
......
38 39
	{ path: 'linking', component: LinkingComponent },
39 40
	{ path: 'bulk-linking', component: BulkLinkingComponent},
40 41
	{ path: 'search/find/publications', component: SearchPublicationsComponent },
41
  { path: 'search/advanced/publications', component: AdvancedSearchPublicationsComponent },
42
  	{ path: 'search/advanced/publications', component: AdvancedSearchPublicationsComponent },
43
	{ path: 'search/find/dataproviders', component: SearchDataprovidersComponent },
42 44
	{ path: 'deposit', component: DepositComponent},
43
  { path: 'deposit-results', component: DepositResultComponent},
45
  	{ path: 'deposit-results', component: DepositResultComponent},
44 46
	{ path: 'test', component: TestComponent},
45 47
	{ path: 'search', component: SearchAllComponent },
46
  { path: 'error', component: ErrorPageComponent},
48
  	{ path: 'error', component: ErrorPageComponent},
47 49

  
48
  { path: '**', component: ErrorPageComponent } // it has to be the last one - otherwise the next declaration are ignored
50
  	{ path: '**', component: ErrorPageComponent } // it has to be the last one - otherwise the next declaration are ignored
49 51

  
50 52
];
51 53

  
modules/uoa-services-portal/trunk/portal-2/src/server.ts
68 68
app.get('/search', ngApp);
69 69
app.get('/search/find/publications', ngApp);
70 70
app.get('/search/advanced/publications', ngApp);
71
app.get('/search/find/dataproviders', ngApp);
71 72
app.get('/deposit', ngApp);
72 73
app.get('/deposit-result', ngApp);
73 74
app.get('/error', ngApp);

Also available in: Unified diff