Project

General

Profile

« Previous | Next » 

Revision 56883

Creating a branch 'mergeResultLandingPages' for merging landing pages of publications, datasets, software and other research products by using same components and services.

View differences:

modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/webpack.server.config.js
1
// Work around for https://github.com/angular/angular-cli/issues/7200
2

  
3
const path = require('path');
4
const webpack = require('webpack');
5

  
6
module.exports = {
7
  entry: {
8
    // This is our Express server for Dynamic universal
9
    server: './server.ts',
10
    // This is an example of Static prerendering (generative)
11
    prerender: './prerender.ts'
12
  },
13
  target: 'node',
14
  resolve: { extensions: ['.ts', '.js'] },
15
  // Make sure we include all node_modules etc
16
  externals: [/(node_modules|main\..*\.js)/,],
17
  optimization: {
18
    minimize: false
19
  },
20
  output: {
21
    // Puts the output at the root of the dist folder
22
    path: path.join(__dirname, 'dist'),
23
    filename: '[name].js'
24
  },
25
  module: {
26
    rules: [
27
      { test: /\.ts$/, loader: 'ts-loader' }
28
      ,{
29
        // Mark files inside `@angular/core` as using SystemJS style dynamic imports.
30
        // Removing this will cause deprecation warnings to appear.
31
        test: /(\\|\/)@angular(\\|\/)core(\\|\/).+\.js$/,
32
        parser: { system: true },
33
      },
34
    ]
35
  },
36
  plugins: [
37
    new webpack.ContextReplacementPlugin(
38
      // fixes WARNING Critical dependency: the request of a dependency is an expression
39
      /(.+)?angular(\\|\/)core(.+)?/,
40
      path.join(__dirname, 'src'), // location of your src
41
      {} // a map of your routes
42
    ),
43
    new webpack.ContextReplacementPlugin(
44
      // fixes WARNING Critical dependency: the request of a dependency is an expression
45
      /(.+)?express(\\|\/)(.+)?/,
46
      path.join(__dirname, 'src'),
47
      {}
48
    )
49
  ]
50
}
51
  
modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/angular.json
1
{
2
  "$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
3
  "version": 1,
4
  "newProjectRoot": "projects",
5
  "projects": {
6
    "ng-openaire-library": {
7
      "root": "",
8
      "projectType": "application",
9
      "architect": {
10
        "build": {
11
          "builder": "@angular-devkit/build-angular:browser",
12
          "options": {
13
            "outputPath": "dist/browser",
14
            "index": "src/index.html",
15
            "main": "src/main.ts",
16
            "tsConfig": "src/tsconfig.app.json",
17
            "polyfills": "src/polyfills.ts",
18
            "assets": [
19
              {
20
                "glob": "**/*",
21
                "input": "src/assets",
22
                "output": "/assets"
23
              },
24
              {
25
                "glob": "favicon.ico",
26
                "input": "src",
27
                "output": "/"
28
              }
29
            ],
30
            "styles": [
31
              "src/styles.css",
32
              "node_modules/datatables.net-dt/css/jquery.dataTables.css"
33
            ],
34
            "scripts": [
35
              "node_modules/jquery/dist/jquery.js",
36
              "node_modules/datatables.net/js/jquery.dataTables.js"
37
            ]
38
          },
39
          "configurations": {
40
            "production": {
41
              "optimization": true,
42
              "outputHashing": "all",
43
              "sourceMap": false,
44
              "extractCss": true,
45
              "namedChunks": false,
46
              "aot": true,
47
              "extractLicenses": true,
48
              "vendorChunk": false,
49
              "buildOptimizer": true,
50
              "fileReplacements": [
51
                {
52
                  "replace": "src/environments/environment.ts",
53
                  "with": "src/environments/environment.prod.ts"
54
                }
55
              ]
56
            }
57
          }
58
        },
59
        "serve": {
60
          "builder": "@angular-devkit/build-angular:dev-server",
61
          "options": {
62
            "browserTarget": "ng-openaire-library:build"
63
          },
64
          "configurations": {
65
            "production": {
66
              "browserTarget": "ng-openaire-library:build:production"
67
            }
68
          }
69
        },
70
        "extract-i18n": {
71
          "builder": "@angular-devkit/build-angular:extract-i18n",
72
          "options": {
73
            "browserTarget": "ng-openaire-library:build"
74
          }
75
        },
76
        "test": {
77
          "builder": "@angular-devkit/build-angular:karma",
78
          "options": {
79
            "main": "src/test.ts",
80
            "karmaConfig": "./karma.conf.js",
81
            "polyfills": "src/polyfills.ts",
82
            "tsConfig": "src/tsconfig.spec.json",
83
            "scripts": [],
84
            "styles": [
85
              "src/styles.css"
86
            ],
87
            "assets": [
88
              {
89
                "glob": "**/*",
90
                "input": "src/assets",
91
                "output": "/assets"
92
              },
93
              {
94
                "glob": "favicon.ico",
95
                "input": "src",
96
                "output": "/"
97
              }
98
            ]
99
          }
100
        },
101
        "lint": {
102
          "builder": "@angular-devkit/build-angular:tslint",
103
          "options": {            
104
            "tsConfig": [
105
              "src/tsconfig.app.json"
106
            ],
107
            "exclude": [
108
              "**/node_modules/**"
109
            ]
110
          }
111
        },
112
        "server": {
113
          "builder": "@angular-devkit/build-angular:server",
114
          "options": {
115
            "outputPath": "dist/server",
116
            "main": "src/main.server.ts",
117
            "tsConfig": "src/tsconfig.server.json"
118
          },
119
          "configurations": {
120
            "production": {
121
              "fileReplacements": [
122
                {
123
                  "replace": "src/environments/environment.ts",
124
                  "with": "src/environments/environment.prod.ts"
125
                }
126
              ]
127
            }
128
          }
129
        }
130
      }
131
    },
132
    "ng-openaire-library-e2e": {
133
      "root": "",
134
      "projectType": "application",
135
      "cli": {},
136
      "schematics": {},
137
      "architect": {
138
        "e2e": {
139
          "builder": "@angular-devkit/build-angular:protractor",
140
          "options": {
141
            "protractorConfig": "./protractor.conf.js",
142
            "devServerTarget": "ng-openaire-library:serve"
143
          }
144
        },
145
        "lint": {
146
          "builder": "@angular-devkit/build-angular:tslint",
147
          "options": {
148
            "tsConfig": [],
149
            "exclude": [
150
              "**/node_modules/**"
151
            ]
152
          }
153
        }
154
      }
155
    }
156
  },
157
  "cli": {},
158
  "schematics": {
159
    "@schematics/angular:class": {
160
      "spec": false
161
    },
162
    "@schematics/angular:component": {
163
      "spec": false,
164
      "inlineStyle": true,
165
      "inlineTemplate": true,
166
      "prefix": "app",
167
      "styleext": "css"
168
    },
169
    "@schematics/angular:directive": {
170
      "spec": false,
171
      "prefix": "app"
172
    },
173
    "@schematics/angular:guard": {
174
      "spec": false
175
    },
176
    "@schematics/angular:module": {
177
      "spec": false
178
    },
179
    "@schematics/angular:pipe": {
180
      "spec": false
181
    },
182
    "@schematics/angular:service": {
183
      "spec": false
184
    }
185
  }
186
}
modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/createLibrary.sh
1
rm -rf dist;
2
npm run packagr;
3
cd dist;
4
npm pack;
5
cd ..;
0 6

  
modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/package.json
1
{
2
  "name": "ng-openaire-library",
3
  "version": "1.0.0",
4
  "license": "Openaire",
5
  "contributors": [
6
    "Argiro Kokogiannaki <argirok@di.uoa.gr>",
7
    "Konstantina Galouni <kgalouni@di.uoa.gr>"
8
  ],
9
  "scripts": {
10
    "ng": "ng",
11
    "start": "ng serve --disable-host-check --host 0.0.0.0",
12
    "build": "ng build",
13
    "lint": "ng lint ng-openaire-library",
14
    "build:client-and-server-bundles": "ng build --prod && ng run ng-openaire-library:server:production",
15
    "build:prerender": "npm run build:client-and-server-bundles && npm run webpack:server && npm run generate:prerender",
16
    "build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
17
    "generate:prerender": "cd dist && node prerender",
18
    "webpack:server": "webpack --config webpack.server.config.js --progress --colors",
19
    "serve:prerender": "cd dist/browser && http-server",
20
    "serve:ssr": "node dist/server",
21
    "packagr": "ng-packagr -p ng-package.json"
22
  },
23
  "pre-commit": [],
24
  "private": true,
25
  "dependencies": {
26
    "@angular/animations": "7.2.14",
27
    "@angular/cdk": "^7.3.7",
28
    "@angular/common": "7.2.14",
29
    "@angular/compiler": "7.2.14",
30
    "@angular/core": "7.2.14",
31
    "@angular/forms": "7.2.14",
32
    "@angular/http": "7.2.14",
33
    "@angular/material": "^7.3.7",
34
    "@angular/platform-browser": "7.2.14",
35
    "@angular/platform-browser-dynamic": "7.2.14",
36
    "@angular/platform-server": "7.2.14",
37
    "@angular/router": "7.2.14",
38
    "@nguniversal/express-engine": "^6.0.0",
39
    "@nguniversal/module-map-ngfactory-loader": "^6.0.0",
40
    "@types/express": "^4.16.1",
41
    "angular-datatables": "^4.4.1",
42
    "citation-js": "^0.3.4",
43
    "clipboard": "^1.5.16",
44
    "core-js": "^2.4.1",
45
    "datatables.net": "^1.10.19",
46
    "datatables.net-dt": "^1.10.19",
47
    "jquery": "^3.4.1",
48
    "ngx-json-ld": "0.1.6",
49
    "ts-md5": "^1.2.0",
50
    "wikidata-sdk": "^5.2.9",
51
    "zone.js": "^0.8.26"
52
  },
53
  "devDependencies": {
54
    "@angular-devkit/build-angular": "0.11.4",
55
    "@angular/cli": "7.3.9",
56
    "@angular/compiler-cli": "7.2.14",
57
    "@angular/language-service": "7.2.14",
58
    "@types/datatables.net": "^1.10.17",
59
    "@types/jquery": "^3.3.29",
60
    "@types/node": "^8.0.30",
61
    "codelyzer": "^4.0.2",
62
    "cpy-cli": "^1.0.1",
63
    "http-server": "^0.10.0",
64
    "ng-packagr": "^1.6.0",
65
    "pre-commit": "^1.2.2",
66
    "reflect-metadata": "^0.1.10",
67
    "rxjs": "6.5.1",
68
    "rxjs-compat": "^6.5.1",
69
    "rxjs-tslint": "^0.1.7",
70
    "ts-loader": "^4.2.0",
71
    "tslint": "^5.7.0",
72
    "typescript": "3.2.4",
73
    "webpack-cli": "^3.3.2"
74
  }
75
}
modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/tsconfig.json
1
{
2
  "compileOnSave": false,
3
  "compilerOptions": {
4
    "outDir": "./dist/out-tsc",
5
    "sourceMap": true,
6
    "declaration": false,
7
    "moduleResolution": "node",
8
    "emitDecoratorMetadata": true,
9
    "experimentalDecorators": true,
10
    "target": "es5",
11
    "typeRoots": [
12
      "node_modules/@types"
13
    ],
14
    "lib": [
15
      "es2017",
16
      "dom"
17
    ]
18
  }
19
}
modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/ng-package.json
1
{
2
  "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
3
  "lib": {
4
    "entryFile": "public_api.ts"
5
  }
6
}
modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/tslint.json
1
{
2
  "rulesDirectory": [
3
    "node_modules/codelyzer"
4
  ],
5
  "rules": {
6
    "arrow-return-shorthand": true,
7
    "callable-types": true,
8
    "class-name": true,
9
    "comment-format": [
10
      true,
11
      "check-space"
12
    ],
13
    "curly": true,
14
    "deprecation": {
15
      "severity": "warn"
16
    },
17
    "eofline": true,
18
    "forin": true,
19
    "import-blacklist": [
20
      true,
21
      "rxjs/Rx",
22
      "rxjs/operators"
23
    ],
24
    "import-spacing": true,
25
    "indent": [
26
      true,
27
      "spaces"
28
    ],
29
    "interface-over-type-literal": true,
30
    "label-position": true,
31
    "max-line-length": [
32
      true,
33
      140
34
    ],
35
    "member-access": false,
36
    "member-ordering": [
37
      true,
38
      {
39
        "order": [
40
          "static-field",
41
          "instance-field",
42
          "static-method",
43
          "instance-method"
44
        ]
45
      }
46
    ],
47
    "no-arg": true,
48
    "no-bitwise": true,
49
    "no-console": [
50
      true,
51
      "debug",
52
      "info",
53
      "time",
54
      "timeEnd",
55
      "trace"
56
    ],
57
    "no-construct": true,
58
    "no-debugger": true,
59
    "no-duplicate-super": true,
60
    "no-empty": false,
61
    "no-empty-interface": true,
62
    "no-eval": true,
63
    "no-inferrable-types": [
64
      true,
65
      "ignore-params"
66
    ],
67
    "no-misused-new": true,
68
    "no-non-null-assertion": true,
69
    "no-shadowed-variable": true,
70
    "no-string-literal": false,
71
    "no-string-throw": true,
72
    "no-switch-case-fall-through": true,
73
    "no-trailing-whitespace": true,
74
    "no-unnecessary-initializer": true,
75
    "no-unused-expression": true,
76
    "no-use-before-declare": true,
77
    "no-var-keyword": true,
78
    "object-literal-sort-keys": false,
79
    "one-line": [
80
      true,
81
      "check-open-brace",
82
      "check-catch",
83
      "check-else",
84
      "check-whitespace"
85
    ],
86
    "prefer-const": true,
87
    "quotemark": [
88
      true,
89
      "single"
90
    ],
91
    "radix": true,
92
    "semicolon": [
93
      true,
94
      "always"
95
    ],
96
    "triple-equals": [
97
      true,
98
      "allow-null-check"
99
    ],
100
    "typedef-whitespace": [
101
      true,
102
      {
103
        "call-signature": "nospace",
104
        "index-signature": "nospace",
105
        "parameter": "nospace",
106
        "property-declaration": "nospace",
107
        "variable-declaration": "nospace"
108
      }
109
    ],
110
    "typeof-compare": true,
111
    "unified-signatures": true,
112
    "variable-name": false,
113
    "whitespace": [
114
      true,
115
      "check-branch",
116
      "check-decl",
117
      "check-operator",
118
      "check-separator",
119
      "check-type"
120
    ],
121
    "directive-selector": [
122
      true,
123
      "attribute",
124
      "app",
125
      "camelCase"
126
    ],
127
    "component-selector": [
128
      true,
129
      "element",
130
      "app",
131
      "kebab-case"
132
    ],
133
    "no-output-on-prefix": true,
134
    "use-input-property-decorator": true,
135
    "use-output-property-decorator": true,
136
    "use-host-property-decorator": true,
137
    "no-input-rename": true,
138
    "no-output-rename": true,
139
    "use-life-cycle-interface": true,
140
    "use-pipe-transform-interface": true,
141
    "component-class-suffix": true,
142
    "directive-class-suffix": true
143
  }
144
}
modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/src/app/test/test.component.ts
1
import {Component, ElementRef} from '@angular/core';
2
import { Subject , Observable} from 'rxjs';
3

  
4
import {SearchFields, FieldDetails} from '../utils/properties/searchFields';
5

  
6
@Component({
7
    selector: 'test',
8
    template: `
9

  
10

  
11

  
12
`
13

  
14
})
15
export class TestComponent {
16

  
17
  constructor() {
18

  
19
   }
20

  
21

  
22
  ngOnInit() {
23

  
24
    }
25

  
26

  
27
  test(){
28
    var  sf:SearchFields  = new SearchFields();
29
    console.info("~~~RESULT");
30

  
31
    this.checktables(sf.RESULT_REFINE_FIELDS,sf.RESULT_FIELDS,sf.RESULT_FIELDS);
32
    this.checktables(sf.RESULT_ADVANCED_FIELDS,sf.RESULT_FIELDS,sf.RESULT_FIELDS);
33
    console.info("~~~PR");
34

  
35
    this.checktables(sf.PROJECT_REFINE_FIELDS,sf.PROJECT_FIELDS,sf.PROJECT_FIELDS);
36
    this.checktables(sf.PROJECT_ADVANCED_FIELDS,sf.PROJECT_FIELDS,sf.PROJECT_FIELDS);
37
    console.info("~~~DATAPR");
38

  
39
    this.checktables(sf.DATASOURCE_REFINE_FIELDS,sf.DATASOURCE_FIELDS,sf.DATASOURCE_FIELDS);
40
    this.checktables(sf.DATASOURCE_ADVANCED_FIELDS,sf.DATASOURCE_FIELDS,sf.DATASOURCE_FIELDS);
41

  
42
    console.info("~~~ORG");
43
    this.checktables(sf.ORGANIZATION_REFINE_FIELDS,sf.ORGANIZATION_FIELDS,sf.ORGANIZATION_FIELDS);
44
    this.checktables(sf.ORGANIZATION_ADVANCED_FIELDS,sf.ORGANIZATION_FIELDS,sf.ORGANIZATION_FIELDS);
45
    console.info("~~~PERSON");
46
   
47
 }
48
  checktables(fields,fieldsDetails,fieldsParam){
49
 for(var i =0; i < fields.length; i++){
50
   if(!fieldsDetails[fields[i]]){
51
     console.info("!!!!"+fields[i]+ "field has to details");
52
   }
53
   }
54

  
55
 }
56

  
57

  
58

  
59

  
60
}
modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/src/app/test/test.module.ts
1
import { NgModule } from '@angular/core';
2

  
3
import { SharedModule } from '../shared/shared.module';
4
import { TestComponent } from './test.component';
5
import { TestRoutingModule } from './test-routing.module';
6

  
7

  
8
 
9
@NgModule({
10
  imports: [
11
    SharedModule,
12
    TestRoutingModule,
13

  
14
  ],
15
  declarations: [
16
    TestComponent
17
  ]
18
})
19
export class TestModule { }
modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/src/app/test/test-routing.module.ts
1
import { NgModule } from '@angular/core';
2
import { RouterModule } from '@angular/router';
3

  
4
import { TestComponent } from './test.component';
5

  
6
@NgModule({
7
  imports: [
8
    RouterModule.forChild([
9
      { path: '', component: TestComponent},
10

  
11
    ])
12
  ]
13
})
14
export class TestRoutingModule { }
modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/src/app/services/searchDataproviders.service.ts
1
import {Injectable} from '@angular/core';
2
import {Http, Response} from '@angular/http';
3
import {HttpClient} from "@angular/common/http";
4
import {Observable}     from 'rxjs';
5
import {SearchResult}     from '../utils/entities/searchResult';
6
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
7

  
8

  
9

  
10
import {StringUtils} from '../utils/string-utils.class';
11
import{EnvProperties} from '../utils/properties/env-properties';
12
import {map} from "rxjs/operators";
13

  
14
@Injectable()
15
export class SearchDataprovidersService {
16
    constructor(private http: HttpClient ) {}
17

  
18
    searchDataproviders (params: string, refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties, usedBy: string="search" ):any {
19
        let link = properties.searchAPIURLLAst+"datasources";
20

  
21
        let url = link+"?";
22
        if(params!= null && params != ''  ) {
23
            url += params;
24
        }
25
        if(refineParams!= null && refineParams != ''  ) {
26
            url += refineParams;
27
        }
28
        url += "&page="+(page-1)+"&size="+size+"&format=json";
29

  
30

  
31
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
32
                    //.map(res => <any> res.json())
33
                    //.do(res => console.info(res))
34
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource", usedBy)]));
35
    }
36
    //((oaftype exact datasource) and(collectedfromdatasourceid exact "openaire____::47ce9e9f4fad46e732cff06419ecaabb"))
37
    advancedSearchDataproviders (params: string, page: number, size: number, properties: EnvProperties ):any {
38
      let url =  properties.searchResourcesAPIURL;
39
      var basicQuery = "(oaftype exact datasource) " +
40
      'and (datasourcecompatibilityid <> "UNKNOWN")';
41
      url += "?query=";
42
      if(params!= null && params != ''  ) {
43
        url +=" ( "+basicQuery+ " ) " +" and (" + params + ")";
44
      }else{
45
        url +=" ( "+basicQuery+ " ) ";
46
      }
47

  
48
      url += "&page="+(page-1)+"&size="+size+"&format=json";
49

  
50
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
51
      //.map(res => <any> res.json())
52
      //.do(res => console.info(res))
53
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]))
54
    }
55

  
56
    searchCompatibleDataprovidersTable ( properties:EnvProperties):any {
57
      let size: number = 0;
58
      let url: string= properties.searchResourcesAPIURL;
59
      url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other) not(datasourcetypeuiid exact "pubsrepository::journal") not(datasourcetypeuiid exact "aggregator::pubsrepository::journals"))';
60
      url += "&page=0&size=0&format=json";
61

  
62

  
63

  
64
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
65
                      //.map(res => <any> res.json())
66
                      .pipe(map(res => res['meta'].total));
67
    }
68

  
69
    searchCompatibleDataproviders (params: string,refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
70
      let url: string = properties.searchResourcesAPIURL;
71
      url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other) not(datasourcetypeuiid exact "pubsrepository::journal") not(datasourcetypeuiid exact "aggregator::pubsrepository::journals"))';
72
      if(params!= null && params != ''  ) {
73
        url += params;
74
      }
75
      if(refineParams!= null && refineParams != ''  ) {
76
        url += refineParams;
77
      }
78
      url += "&page="+(page-1)+"&size="+size+"&format=json";
79

  
80
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
81
      //.map(res => <any> res.json())
82
      //.do(res => console.info(res))
83
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
84
    }
85

  
86
    searchEntityRegistriesTable (properties:EnvProperties):any {
87
      let size: number = 0;
88
      let url: string= properties.searchResourcesAPIURL;
89
      url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))";
90
      url += "&page=0&size=0&format=json";
91

  
92

  
93

  
94
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
95
                      //.map(res => <any> res.json())
96
                      .pipe(map(res => res['meta'].total));
97
    }
98

  
99
    searchEntityRegistries (params: string,refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
100
      let url = properties.searchResourcesAPIURL;
101
      url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))";
102
      if(params!= null && params != ''  ) {
103
        url += params;
104
      }
105
      if(refineParams!= null && refineParams != ''  ) {
106
        url += refineParams;
107
      }
108
      url += "&page="+(page-1)+"&size="+size+"&format=json";
109

  
110
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
111
      //.map(res => <any> res.json())
112
      //.do(res => console.info(res))
113
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
114
    }
115

  
116
    searchJournalsTable ( properties:EnvProperties):any {
117
      let size: number = 0;
118
      let url: string= properties.searchResourcesAPIURL;
119
      url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))';
120
      url += "&page=0&size=0&format=json";
121

  
122
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)//.map(res => <any> res.json())
123
                        .pipe(map(res => res['meta'].total));
124
    }
125

  
126
    searchJournals (params: string,refineParams:string, page: number, size: number, refineFields:string[] , properties:EnvProperties):any {
127
      let url: string = properties.searchResourcesAPIURL;
128
      //url += "?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))"
129
      url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))';
130

  
131
      if(params!= null && params != ''  ) {
132
        url += params;
133
      }
134
      if(refineParams!= null && refineParams != ''  ) {
135
        url += refineParams;
136
      }
137
      url += "&page="+(page-1)+"&size="+size+"&format=json";
138

  
139
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
140
      //.map(res => <any> res.json())
141
      //.do(res => console.info(res))
142
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
143
    }
144

  
145
    searchDataprovidersForDeposit (id: string,type:string, page: number, size: number, properties:EnvProperties):any {
146
        let link = properties.searchResourcesAPIURL;
147
        var compatibilities = "";
148
        if(type == "Research Data"){
149
          //compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid = openaire2.0_data)"
150
          compatibilities = " and (datasourcecompatibilityid = openaire2.0_data)";
151
        }else if(type == "Publications"){
152
          //compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid <> openaire2.0_data)"
153
          compatibilities = " and (datasourcecompatibilityid <> openaire2.0_data)";
154
        }
155
        let url = link+"?query=(((deletedbyinference = false) AND (oaftype exact datasource)) "+((compatibilities && compatibilities.length > 0)?" "+compatibilities+" ":"")+") and (relorganizationid exact \""+id+"\")";
156
        url += "&page="+(page-1)+"&size="+size+"&format=json";
157

  
158

  
159
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
160
                    //.map(res => <any> res.json())
161
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
162
    }
163

  
164
    searchDataprovidersForDepositSearch(params: string, refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties, usedBy: string="search" ):any {
165
    let link = properties.searchResourcesAPIURL;
166
      let url = link+"?query=((deletedbyinference = false) AND (oaftype exact datasource)) "+params;
167
      if(refineParams!= null && refineParams != ''  ) {
168
        url += refineParams;
169
      }
170
      url += "&page="+(page-1)+"&size="+size+"&format=json";
171

  
172
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
173
                      .pipe(map(res => [res['meta'].total, this.parseResults(res['results']), RefineResultsUtils.parse(res['refineResults'],
174
                                              refineFields, "datasource", usedBy)]));
175
  }
176

  
177
    searchDataProvidersBySubjects(keyword:string, type:string, page: number, size: number, properties:EnvProperties):any {
178
      let link = properties.searchResourcesAPIURL;
179
      var compatibilities = "";
180
      if(type == "Research Data"){
181
        compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid = openaire2.0_data)"
182
      }else if(type == "Publications"){
183
        compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid <> openaire2.0_data)"
184
      }
185
      let url = link+"?query=(((deletedbyinference = false) AND (oaftype exact datasource)) "+((compatibilities && compatibilities.length > 0)?" "+
186
      compatibilities+" ":"")+") "+
187
      " and (datasourcesubject all "+'"'+keyword+'"'+") " ;
188
      url += "&page="+(page-1)+"&size="+size+"&format=json";
189

  
190

  
191
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
192
                  //.map(res => <any> res.json())
193
                  .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
194

  
195
    }
196

  
197
    getDataProvidersforEntityRegistry(datasourceId: string, page: number, size: number , properties:EnvProperties):any {
198
      let url = properties.searchResourcesAPIURL;
199
      var basicQuery = "(oaftype exact datasource) "
200
      url += "?query=";
201
      if(datasourceId!= null && datasourceId != ''  ) {
202
        url +=" ( "+basicQuery+ " ) " +" and (collectedfromdatasourceid exact \"" + datasourceId + "\")";
203
      }else{
204
        url +=" ( "+basicQuery+ " ) ";
205
      }
206

  
207
      url += "&page="+(page-1)+"&size="+size+"&format=json";
208

  
209
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
210
      //.map(res => <any> res.json())
211
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
212
    }
213
    searchDataprovidersForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
214
        let link = properties.searchAPIURLLAst;
215
        let url = link+params+"/datasources?format=json";
216

  
217
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
218
                    //.map(res => <any> res.json())
219
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
220
    }
221
/*
222
    searchDataprovidersCSV (params: string, refineParams:string, page: number, size: number):any {
223

  
224
        let link = OpenaireProperties. getSearchAPIURLLast()+"datasources";
225

  
226
        let url = link+"?";
227
        if(params!= null && params != ''  ) {
228
            url += params;
229
        }
230
        if(refineParams!= null && refineParams != ''  ) {
231
            url += refineParams;
232
        }
233
        url += "&page="+(page-1)+"&size="+size+"&format=json";
234

  
235
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
236
                    .map(res => <any> res.json())
237
                    //.do(res => console.info(res))
238

  
239
                    .map(res => this.parseResultsCSV(res['results']));
240
    }
241
*/
242
/*
243
    searchEntityRegistriesCSV (params: string,refineParams:string, page: number, size: number):any {
244
      let url = properties.searchAPIURLLAst;
245
      url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))"
246
      if(params!= null && params != ''  ) {
247
        url += params;
248
      }
249
      if(refineParams!= null && refineParams != ''  ) {
250
        url += refineParams;
251
      }
252
      url += "&page="+(page - 1)+"&size="+size+"&format=json";
253

  
254
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
255
      .map(res => <any> res.json())
256
      //.do(res => console.info(res))
257

  
258
      .map(res => this.parseResultsCSV(res['results']));
259
    }
260
*/
261
/*
262
    searchCompatibleDataprovidersCSV (params: string,refineParams:string, page: number, size: number):any {
263
      let url = properties.searchAPIURLLAst;
264
      url += "?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))"
265
      if(params!= null && params != ''  ) {
266
        url += params;
267
      }
268
      if(refineParams!= null && refineParams != ''  ) {
269
        url += refineParams;
270
      }
271
      url += "&page="+(page - 1)+"&size="+size+"&format=json";
272

  
273
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
274
      .map(res => <any> res.json())
275
      //.do(res => console.info(res))
276

  
277
      .map(res => this.parseResultsCSV(res['results']));
278
    }
279
*/
280

  
281

  
282
    parseResults(data: any): SearchResult[] {
283
        let results: SearchResult[] = [];
284

  
285
        let length = Array.isArray(data) ? data.length : 1;
286

  
287
        for(let i=0; i<length; i++) {
288
            let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:datasource'] : data['result']['metadata']['oaf:entity']['oaf:datasource'];
289

  
290
            var result: SearchResult = new SearchResult();
291

  
292
            result['title'] = {"name": '', "accessMode": '', "sc39": ''};
293

  
294
            result['title'].name = resData.officialname;
295
            result['englishname'] = resData.englishname;
296

  
297
            //result['title'].url = OpenaireProperties.getsearchLinkToDataProvider();
298
            //result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
299
            result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
300

  
301
            result['type'] = this.getDataproviderType(resData);
302

  
303
            let typeid: string = resData['datasourcetype'].classid;
304
            //console.info(typeid);
305
            if(typeid != "entityregistry" && typeid != "entityregistry::projects" && typeid != "entityregistry::repositories") {
306

  
307
                if(resData.hasOwnProperty('accessinfopackage')) {
308
                    let OAIPMHURL: string;
309
                    if(Array.isArray(resData['accessinfopackage'])) {
310
                        OAIPMHURL = resData['accessinfopackage'][0];
311
                    } else {
312
                        OAIPMHURL = resData['accessinfopackage'];
313
                    }
314

  
315
                    if(OAIPMHURL != '' && OAIPMHURL != 'unknown') {
316
                        result['OAIPMHURL'] = OAIPMHURL;
317
                    }
318
                }
319
                let compatibility = this.getDataproviderCompatibility(resData);
320
                result['compatibility'] = compatibility.classname;
321
                if(compatibility.classid == "UNKNOWN") {
322
                  result['compatibilityUNKNOWN'] = true;
323
                }
324
            } else {
325
              result['compatibility'] = "";
326
            }
327

  
328
            result['websiteURL'] = resData.websiteurl;
329

  
330
            let res:[string[], {"name":string, "id":string}[]] = this.getDataproviderCountriesOrganizations(resData, true, true);
331
            result['organizations'] = res[1];
332
            result['countries'] = res[0];
333
            result['subjects'] = this.getDataproviderSubjects(resData);
334
            //console.log(result['subjects']);
335
            results.push(result);
336
        }
337

  
338
        return results;
339
    }
340
    getDataproviderSubjects(resData: any): string [] {
341
      var subjects:string [] = [];
342

  
343
      let length = Array.isArray(resData['subjects']) ? resData['subjects'].length : 1;
344
      for(let i=0; i<length; i++) {
345
          let subject = Array.isArray(resData['subjects']) ? resData['subjects'][i] :resData['subjects'];
346
          subjects.push(subject.content);
347
      }
348
      return subjects;
349
    }
350
    getDataproviderType(resData: any): string {
351
        if(resData['datasourcetype'].hasOwnProperty("classname")) {
352
            return resData['datasourcetype'].classname;
353
        } else {
354
            return '';
355
        }
356
    }
357

  
358
    getDataproviderCompatibility(resData: any): {"classid": string, "classname": string} {
359
        if(resData.hasOwnProperty('openairecompatibility')) {
360
            return {"classid": resData['openairecompatibility'].classid, "classname": resData['openairecompatibility'].classname};
361
        } else {
362
            return {"classid": "", "classname": ""};
363
        }
364
    }
365

  
366
    getDataproviderCountriesOrganizations(resData: any, getCountries: boolean, getOrganizations: boolean): [string[], {"name": string, "id": string}[]] {
367
        let countries: string[] = [];
368
        let organizations: {"name": string, "id": string}[] = [];
369

  
370
        if(resData['rels'].hasOwnProperty("rel")) {
371
            let countriesSet: Set<string> = new Set<string>();
372

  
373
            let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
374

  
375
            for(let i=0; i<relLength; i++) {
376
                let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][i] : resData['rels']['rel'];
377

  
378
                if(relation.hasOwnProperty("to")) {
379
                    if(relation['to'].class == "provides" && relation['to'].type == "organization") {
380
                        if(getOrganizations) {
381
                            let item: {"name":string, "id":string} = {"name": "", "id": ""};
382
                            //item['name'] = relation.legalname;
383
                            if(relation.legalshortname) {
384
                              item['name'] = relation.legalshortname;
385
                            } else {
386
                              item['name'] = relation.legalname;
387
                            }
388
                            item['id'] = /*OpenaireProperties.getsearchLinkToOrganization()+*/relation['to'].content;
389
                            organizations.push(item);
390
                        }
391

  
392
                        if(getCountries) {
393
                            if(relation.hasOwnProperty('country') &&
394
                               relation.country.hasOwnProperty('classname')) {
395
                                if(!countriesSet.has(relation.country.classname)) {
396
                                    countriesSet.add(relation.country.classname);
397
                                    countries.push(relation.country.classname);
398
                                }
399
                            }
400
                        }
401
                    }
402
                }
403
            }
404
        }
405
        return [countries, organizations];
406
    }
407
/*
408
    parseResultsCSV(data: any): any {
409
        let results: any = [];
410
        let length = Array.isArray(data) ? data.length : 1;
411

  
412
        for(let i=0; i<length; i++) {
413
            let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:datasource'] : data['result']['metadata']['oaf:entity']['oaf:datasource'];
414

  
415
            var result: any = [];
416

  
417
            result.push(this.quote(resData.officialname));
418
            result.push(this.quote(this.getDataproviderType(resData)));
419
            result.push(this.quote(this.getDataproviderCountriesOrganizations(resData, true, false)[0]));
420
            result.push(this.quote(this.getDataproviderCompatibility(resData)));
421
            results.push(result);
422
        }
423
        return results;
424
    }
425
*/
426
    numOfDataproviders(url: string, properties:EnvProperties):any {
427
        //let url = OpenaireProperties. getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
428

  
429
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
430
                    //.map(res => <any> res.json())
431
                    .pipe(map(res => res['total']));
432
    }
433

  
434
    numOfEntityDataproviders(id: string, entity: string, properties:EnvProperties):any {
435
        var parameters = "";
436
        if(entity == "organization") {
437
          parameters = "organizations/"+id+"/datasources/count";
438
        }
439

  
440
        let url = properties.searchAPIURLLAst+parameters+"?format=json";
441
        return this.numOfDataproviders(url, properties);
442
    }
443

  
444
    numOfSearchDataproviders(params: string, properties:EnvProperties, refineQuery:string=null):any {
445
        let url: string = properties.searchAPIURLLAst+"datasources/count?format=json";
446
        if(params != "") {
447
          url += "&q=" + StringUtils.URIEncode(params);
448
        }
449
      if(refineQuery!= null && refineQuery != ''  ) {
450
        url += refineQuery;
451
      }
452

  
453
        return this.numOfDataproviders(url, properties);
454
    }
455
/*
456
    private quote(word: any): string {
457
        return '"'+word+'"';
458
    }
459
*/
460
getDataprovidersTableResults (queryType:string, properties:EnvProperties):any {
461
  let size: number = 0;
462
  let url: string= properties.searchAPIURLLAst;
463
  if(queryType == "compatible"){
464
      url += '?query=((oaftype exact datasource) not (datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other) not(datasourcetypeuiid exact "pubsrepository::journal") not(datasourcetypeuiid exact "aggregator::pubsrepository::journals"))';
465
  }else if(queryType=="registries"){
466
    url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))";
467
  }else if(queryType=="journals"){
468
    url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))';
469

  
470
  }
471

  
472
  url += "&page=0&size=0&format=json";
473

  
474

  
475

  
476
  return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
477
                  //.map(res => <any> res.json())
478
                  .pipe(map(res => res['meta'].total));
479
}
480
}
modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/src/app/services/organizationsService.module.ts
1
import { NgModule}            from '@angular/core';
2
import { CommonModule }        from '@angular/common';
3
import { FormsModule }         from '@angular/forms';
4

  
5
import {SearchOrganizationsService} from './searchOrganizations.service';
6

  
7

  
8
@NgModule({
9
  imports: [
10
    CommonModule, FormsModule
11
  ],
12
  declarations: [
13
  ],
14
  providers:[
15
  SearchOrganizationsService
16
],
17
  exports: [
18
    ]
19
})
20
export class OrganizationsServiceModule { }
modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/src/app/services/reports.service.ts
1
import {Injectable} from '@angular/core';
2
import {Http, Response, Headers} from '@angular/http';
3
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
4
import {Observable, throwError} from 'rxjs';
5

  
6

  
7

  
8
import {map, tap} from "rxjs/operators";
9

  
10
@Injectable()
11
export class ReportsService {
12
    // url:string = "http://beta.services.openaire.eu:8480/search/rest/v2/api/publications?format=csv&page=0&size=3&q=(%22test%22)&fq=instancetypename%20exact%20%22Dataset%22";
13
    constructor(private http: HttpClient) {}
14

  
15
    //On the service:
16
   downloadCSVFile(url: string){
17
     //var headers = new Headers();
18
     //headers.append('responseType', 'arraybuffer');
19
     return this.http.get(url, {responseType: 'text'})
20
                .pipe(map(res => new Blob([res], { type: 'text/csv' })));
21
   }
22
   getCSVResponse(url: string){
23
     //var headers = new Headers();
24
     //headers.append('responseType', 'arraybuffer');
25
     return this.http.get(url, {responseType: 'text'});
26
                //.pipe(map(res => res));
27
   }
28

  
29
  /**
30
   * @deprecated not used
31
   */
32
   downloadHTMLFile(url: string, info: string){
33
     //var headers = new Headers();
34
     //headers.append('responseType', 'arraybuffer');
35
     return this.http.get(url)
36
                .pipe(map(res => this.addInfo(res, info)))
37
                .pipe(map(res => new Blob([res['_body']], { type: 'text/html' })))
38
                .pipe(tap(res => console.log(res)))
39
   }
40

  
41
  /**
42
   * @deprecated not used
43
   */
44
   addInfo(res:any, info:string) {
45
       /*
46
       var para = res.document.createElement("P");                       // Create a <p> element
47
       var t = res.document.createTextNode("This is a paragraph");       // Create a text node
48
       para.appendChild(t);                                          // Append the text to <p>
49
       res.document.body.appendChild(para);
50
       */
51
       res['_body'] = info+res['_body'];
52
       return res;
53
   }
54

  
55
    private handleError (error: HttpErrorResponse) {
56
    // in a real world app, we may send the error to some remote logging infrastructure
57
    // instead of just logging it to the console
58
        console.log(error);
59
        return throwError(error  || 'Server error');
60
    }
61

  
62

  
63
}
modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/src/app/services/refineFieldResults.service.ts
1
import {Injectable} from '@angular/core';
2
import {Http, Response} from '@angular/http';
3
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
4
import {Observable, throwError} from 'rxjs';
5
import {AutoCompleteValue} from '../searchPages/searchUtils/searchHelperClasses.class';
6

  
7

  
8

  
9
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
10
import{EnvProperties} from '../utils/properties/env-properties';
11
import {map} from "rxjs/operators";
12

  
13
@Injectable()
14
export class RefineFieldResultsService {
15
     constructor(private http: HttpClient ) {}
16
     getRefineFieldsResultsByEntityName(fields:string[], entityName:string, properties:EnvProperties, communityQuery=null):any{
17
        let url = properties.searchAPIURLLAst + this.getSearchAPIURLForEntity(entityName)+"?format=json&refine=true&page=1&size=0";
18
        for(var i=0; i < fields.length; i++){
19
            url += "&fields="+fields[i];
20
        }
21
        if(communityQuery!= null && communityQuery != ''  ) {
22
            url += communityQuery;
23
        }
24
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
25
                    //.map(res => <any> res.json())
26

  
27
                    .pipe(map(res =>   [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],fields, entityName)]));
28

  
29
     }
30
    getRefineFieldResultsByFieldName(fieldName:string, entityName:string, properties:EnvProperties):any{
31
       let link = properties.searchAPIURLLAst +this.getSearchAPIURLForEntity(entityName)+"?fields="+fieldName + "&format=json";
32
        return  this.getField(link,fieldName, properties);
33

  
34
    }
35

  
36
    getField (link:string,fieldName:string, properties:EnvProperties):any{
37
      let url = link+"&refine=true&page=1&size=0";
38

  
39
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
40
                  //.map(res => <any> res.json())
41
                  .pipe(map(res => res['refineResults']))
42
                  .pipe(map(res =>  this.parse(res,fieldName)));
43

  
44
    }
45
    parse(data: any,fieldName:string):any {
46
      var values:AutoCompleteValue[] = [];
47
      if(data){
48
          let field = data[fieldName];
49
          for(let i=0; i<field.length; i++) {
50
            var value:AutoCompleteValue = new AutoCompleteValue();
51
            value.label = field[i].name;
52
            value.label = RefineResultsUtils.inParenthesisThePartAfterCharacters(field[i],"||");
53
            value.id = field[i].id;
54
            values.push(value);
55

  
56
        }
57
    }
58

  
59
    return values;
60
    }
61
    getSearchAPIURLForEntity(entityType:string):string{
62
      var suffix = "";
63
      if(entityType == "project"){
64
        suffix="projects/";
65
      }else if(entityType == "publication"){
66
        suffix="publications/";
67
      }else if(entityType == "dataset"){
68
        suffix="datasets/";
69
      } else if(entityType == "software"){
70
        suffix="software/";
71
      } else if(entityType == "other"){
72
        suffix="other/";
73
      }else if(entityType == "organization"){
74
        suffix="organizations/";
75
      }else if(entityType == "dataprovider"){
76
        suffix="datasources/";
77
      }else if(entityType == "person"){
78
        suffix="people/";
79
      }
80
      return  suffix;
81
    }
82
    private handleError (error: HttpErrorResponse) {
83
      // in a real world app, we may send the error to some remote logging infrastructure
84
      // instead of just logging it to the console
85
      console.log(error);
86
      return throwError(error  || 'Server error');
87
    }
88
}
modules/uoa-services-library/branches/mergeResultLandingPages/ng-openaire-library/src/app/services/searchDatasets.service.ts
1
import {Injectable} from '@angular/core';
2
import {HttpClient} from "@angular/common/http";
3
import {SearchResult} from '../utils/entities/searchResult';
4
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
5

  
6

  
7
import {DOI, StringUtils} from '../utils/string-utils.class';
8
import {ParsingFunctions} from '../landingPages/landing-utils/parsingFunctions.class';
9
import {EnvProperties} from '../utils/properties/env-properties';
10
import {map} from "rxjs/operators";
11

  
12
@Injectable()
13
export class SearchDatasetsService {
14
    private sizeOfDescription: number = 270;
15
    public parsingFunctions: ParsingFunctions = new ParsingFunctions();
16

  
17
    constructor(private http: HttpClient ) {}
18

  
19
    searchDatasets (params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[], properties:EnvProperties ):any {
20

  
21
        let link = properties.searchAPIURLLAst+"datasets";
22

  
23
        let url = link+"?";
24
        if(params!= null && params != ''  ) {
25
            url += params;
26
        }
27
        if(refineParams!= null && refineParams != ''  ) {
28
            url += refineParams;
29
        }
30
        if(sortBy) {
31
          url += "&sortBy=" + sortBy;
32
        }
33
        url += "&page="+ (page-1) +"&size="+size+"&format=json";
34

  
35

  
36
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
37
                    //.map(res => <any> res.json())
38
                    //.do(res => console.info(res))
39
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]));
40

  
41
    }
42
    searchDatasetById (id: string , properties:EnvProperties):any {
43

  
44
        let url = properties.searchAPIURLLAst+"datasets/"+id+"?format=json";
45
         return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
46
                    //.map(res => <any> res.json())
47
                    .pipe(map(res => this.parseResults(res, properties)));
48
    }
49

  
50
    searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any {
51

  
52
        let link = properties.searchAPIURLLAst+"datasets";
53

  
54
        let url = link+"?"+"&format=json";
55
        if(params!= null && params != ''  ) {
56
            url += params;
57
        }
58
        if(refineParams!= null && refineParams != ''  ) {
59
            url += refineParams;
60
        }
61
        url += "&page="+(page-1)+"&size="+size;
62

  
63

  
64

  
65
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
66
                    //.map(res => <any> res.json())
67
                    .pipe(map(res => this.parseRefineResults(id, res['refineResults'])))
68
    }
69

  
70
    searchDatasetsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
71
        let link = properties.searchAPIURLLAst+"datasets";
72
        let url = link+"?";
73
        var doisParams = "";
74

  
75
        for(var i =0 ;i < DOIs.length; i++){
76
          doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
77
        }
78
        if(doisParams.length > 0){
79
          url += "&"+doisParams;
80

  
81
        }
82
        if(refineParams!= null && refineParams != ''  ) {
83
            url += refineParams;
84
        }
85
        url += "&page="+ (page-1) +"&size="+size+"&format=json";
86

  
87

  
88
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
89
                    //.map(res => <any> res.json())
90
                    //.do(res => console.info(res))
91
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]));
92

  
93
    }
94
    advancedSearchDatasets (params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any {
95
      let url = properties.searchResourcesAPIURL;
96
      var basicQuery = "(oaftype exact result) and (resulttypeid exact dataset)  "
97
      url += "?query=";
98
      if(params!= null && params != ''  ) {
99
        url +=" ( "+basicQuery+ " ) " +" and (" + params + ")";
100
      }else{
101
        url +=" ( "+basicQuery+ " ) ";
102
      }
103

  
104
      if(sortBy) {
105
        let sortOptions = sortBy.split(",");
106
        url += "sortBy "+sortOptions[0]+"/sort."+sortOptions[1]+" ";
107
      }
108

  
109
      url += "&page="+(page-1)+"&size="+size;
110
      url += "&format=json";
111

  
112
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
113
      //.map(res => <any> res.json())
114
      //.do(res => console.info(res))
115
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
116
    }
117
    searchDatasetsForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
118
        let link = properties.searchAPIURLLAst;
119
        let url = link+params+"/datasets"+"?format=json";
120

  
121
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
122
                    //.map(res => <any> res.json())
123
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
124

  
125
    }
126

  
127
    searchDatasetsForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any {
128
        let link = properties.searchAPIURLLAst;
129
        let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
130
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
131
                    //.map(res => <any> res.json())
132
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
133

  
134
    }
135

  
136
    parseResults(data: any, properties: EnvProperties): SearchResult[] {
137
        let results: SearchResult[] = [];
138

  
139
        let length = Array.isArray(data) ? data.length : 1;
140

  
141
        for(let i=0; i<length; i++) {
142
            let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result'];
143

  
144
            var result: SearchResult = new SearchResult();
145
            result.entityType = "dataset";
146

  
147
            result.types = new Array<string>();
148
            let types = new Set<string>();
149
            let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1;
150

  
151
            let instance;
152
            for(let i=0; i<length; i++) {
153
              instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance'];
154
              this.parsingFunctions.parseTypes(result.types, types, instance);
155
            }
156

  
157
            if(resData['language'] && resData['language'] != null) {
158
              result.languages = new Array<string>();
159

  
160
              if(!Array.isArray(resData['language'])) {
161
                if(resData['language'].classname != "Undetermined" && resData['language'].classname) {
162
                  result.languages.push(resData['language'].classname);
163
                }
164
              } else {
165
                for(let i=0; i<resData['language'].length; i++) {
166
                  if(resData['language'][i].classname != "Undetermined" && resData['language'][i].classname) {
167
                    result.languages.push(resData['language'][i].classname);
168
                  }
169
                }
170
              }
171
            }
172
            if(resData['country'] && resData['country'] != null) {
173
              result.countriesForResults = new Array<string>();
174

  
175
              if(!Array.isArray(resData['country'])) {
176
                if(resData['country'].classname != "Undetermined" && resData['country'].classname) {
177
                  result.countriesForResults.push(resData['country'].classname);
178
                }
179
              } else {
180
                for(let i=0; i<resData['country'].length; i++) {
181
                  if(resData['country'][i].classname != "Undetermined" && resData['country'][i].classname) {
182
                    result.countriesForResults.push(resData['country'][i].classname);
183
                  }
184
                }
185
              }
186
            }
187

  
188
            result['title'] = {"name": '', "accessMode": '', "sc39": ''};
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff