Skip to content

Commit

Permalink
Add contact filter from OrgForResource
Browse files Browse the repository at this point in the history
  • Loading branch information
Angi-Kinas committed Dec 5, 2023
1 parent 912f2cb commit 6302fe0
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 116 deletions.
136 changes: 136 additions & 0 deletions libs/data-access/gn4/src/custom-api/thesaurus.api.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import { Inject, Injectable, Optional } from '@angular/core'
import {
HttpClient,
HttpHeaders,
HttpParameterCodec,
} from '@angular/common/http'
import { Observable } from 'rxjs'
import { CustomHttpParameterCodec } from '../openapi/encoder'
import { Configuration } from '../openapi/configuration'

import { BASE_PATH, COLLECTION_FORMATS } from '../openapi/variables'

export interface thesaurusResponse {
values: { [key: string]: string }
definitions: { [key: string]: string }
coordEast?: string
coordWest?: string
coordSouth?: string
coordNorth?: string
thesaurusKey: string
value: string
uri: string
definition?: string
}

@Injectable({
providedIn: 'root',
})
export class ThesaurusApiService {
protected basePath = 'https://apps.titellus.net/geonetwork/srv/api'
public defaultHeaders = new HttpHeaders()
public configuration = new Configuration()
public encoder: HttpParameterCodec

constructor(
protected httpClient: HttpClient,
@Optional() @Inject(BASE_PATH) basePath: string,
@Optional() configuration: Configuration
) {
if (configuration) {
this.configuration = configuration
}
if (typeof this.configuration.basePath !== 'string') {
if (typeof basePath !== 'string') {
basePath = this.basePath
}
this.configuration.basePath = basePath
}
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec()
}

/**
* List database translations (used to overrides client application translations).
* @param esFieldName set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param iso3 set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getTranslationsFromThesaurus(
thesaurusName: string,
langIso3: string,
observe?: 'body',
reportProgress?: boolean,
options?: { httpHeaderAccept?: 'application/json' }
): Observable<any>
public getTranslationsFromThesaurus(
thesaurusName: string,
langIso3: string,
observe?: 'response',
reportProgress?: boolean,
options?: { httpHeaderAccept?: 'application/json' }
): Observable<thesaurusResponse[]>
public getTranslationsFromThesaurus(
thesaurusName: string,
langIso3: string,
observe?: 'events',
reportProgress?: boolean,
options?: { httpHeaderAccept?: 'application/json' }
): Observable<thesaurusResponse[]>
public getTranslationsFromThesaurus(
thesaurusName: string,
langIso3: string,
observe: any = 'body',
reportProgress: boolean = false,
options?: { httpHeaderAccept?: 'application/json' }
): Observable<any> {
if (
thesaurusName === null ||
thesaurusName === undefined ||
langIso3 === null ||
langIso3 === undefined
) {
throw new Error(
'Required parameter pack was null or undefined when calling getTranslationsFromThesaurus.'
)
}

console.log('here')
let headers = this.defaultHeaders

let httpHeaderAcceptSelected: string | undefined =
options && options.httpHeaderAccept
if (httpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = ['application/json']
httpHeaderAcceptSelected =
this.configuration.selectHeaderAccept(httpHeaderAccepts)
}
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected)
}

let responseType_: 'text' | 'json' = 'json'
if (
httpHeaderAcceptSelected &&
httpHeaderAcceptSelected.startsWith('text')
) {
responseType_ = 'text'
}

return this.httpClient.get<thesaurusResponse[]>(
`${
this.configuration.basePath
}/registries/vocabularies/search?rows=1000&type=CONTAINS&sort=DESC&thesaurus=${encodeURIComponent(
String(thesaurusName)
)}&lang=${encodeURIComponent(langIso3)}`,
{
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress,
}
)
}
}
23 changes: 9 additions & 14 deletions libs/data-access/gn4/src/openapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
### Building

To install the required dependencies and to build the typescript sources run:

```
npm install
npm run build
```

### publishing

First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!)

### consuming

Expand All @@ -34,25 +33,25 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_

In PATH_TO_GENERATED_PACKAGE/dist:

```
npm link
```

In your project:

```
npm link
npm link
```

**Note for Windows users:** The Angular CLI has troubles to use linked npm packages.
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages.
Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround.
Published packages are not effected by this issue.


#### General usage

In your Angular project:


```
// without configuring providers
import { ApiModule } from '';
Expand Down Expand Up @@ -129,11 +128,9 @@ Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons.

#### Using multiple OpenAPI files / APIs / ApiModules

In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules
in order to avoid naming conflicts:

```
import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path';
Expand All @@ -153,9 +150,9 @@ export class AppModule {
}
```

### Set service base path

If different than the generated base path, during app bootstrap, you can provide the base path to your service.
### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service.

```
import { BASE_PATH } from '';
Expand All @@ -164,7 +161,6 @@ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]);
```

or

```
Expand All @@ -179,8 +175,8 @@ import { BASE_PATH } from '';
export class AppModule {}
```

#### Using @angular/cli

#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path:

```
Expand All @@ -191,7 +187,6 @@ export const environment = {
```

In the src/app/app.module.ts:

```
import { BASE_PATH } from '';
import { environment } from '../environments/environment';
Expand All @@ -205,4 +200,4 @@ import { environment } from '../environments/environment';
bootstrap: [ AppComponent ]
})
export class AppModule { }
```
```
97 changes: 0 additions & 97 deletions libs/data-access/gn4/src/openapi/api/tools.api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ import { Observable } from 'rxjs'
import { BASE_PATH } from '../variables'
import { Configuration } from '../configuration'

interface thesaurusResponse {
values: string[]
definitions: string[]
coordEast: string
coordWest: string
coordSouth: string
coordNorth: string
thesaurusKey: string
value: string
uri: string
definition: string
}

@Injectable({
providedIn: 'root',
})
Expand Down Expand Up @@ -926,88 +913,4 @@ export class ToolsApiService {
}
)
}

/**
* List database translations (used to overrides client application translations).
* @param esFieldName set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param iso3 set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getTranslationsFromThesaurus(
thesaurusName: string,
langIso3: string,
observe?: 'body',
reportProgress?: boolean,
options?: { httpHeaderAccept?: 'application/json' }
): Observable<any>
public getTranslationsFromThesaurus(
thesaurusName: string,
langIso3: string,
observe?: 'response',
reportProgress?: boolean,
options?: { httpHeaderAccept?: 'application/json' }
): Observable<thesaurusResponse[]>
public getTranslationsFromThesaurus(
thesaurusName: string,
langIso3: string,
observe?: 'events',
reportProgress?: boolean,
options?: { httpHeaderAccept?: 'application/json' }
): Observable<thesaurusResponse[]>
public getTranslationsFromThesaurus(
thesaurusName: string,
langIso3: string,
observe: any = 'body',
reportProgress: boolean = false,
options?: { httpHeaderAccept?: 'application/json' }
): Observable<any> {
if (
thesaurusName === null ||
thesaurusName === undefined ||
langIso3 === null ||
langIso3 === undefined
) {
throw new Error(
'Required parameter pack was null or undefined when calling getTranslationsFromThesaurus.'
)
}

let headers = this.defaultHeaders

let httpHeaderAcceptSelected: string | undefined =
options && options.httpHeaderAccept
if (httpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = ['application/json']
httpHeaderAcceptSelected =
this.configuration.selectHeaderAccept(httpHeaderAccepts)
}
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected)
}

let responseType_: 'text' | 'json' = 'json'
if (
httpHeaderAcceptSelected &&
httpHeaderAcceptSelected.startsWith('text')
) {
responseType_ = 'text'
}

return this.httpClient.get<thesaurusResponse[]>(
`${
this.configuration.basePath
}/registries/vocabularies/search?rows=1000&type=CONTAINS&sort=DESC&thesaurus=${encodeURIComponent(
String(thesaurusName)
)}&lang=${encodeURIComponent(langIso3)}`,
{
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress,
}
)
}
}
1 change: 1 addition & 0 deletions libs/data-access/gn4/src/openapi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './model/models'
export * from './variables'
export * from './configuration'
export * from './api.module'
export * from '../custom-api/thesaurus.api.service'
Loading

0 comments on commit 6302fe0

Please sign in to comment.