Skip to content

Commit

Permalink
inject urls from config
Browse files Browse the repository at this point in the history
  • Loading branch information
Vijeinath committed Apr 23, 2024
1 parent 9323ead commit 5d43161
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/app/app-init.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ export class AppInitService {

this._gsBuilder.apiURL = AppInitService.settings.apiURL;

this._knoraService.projectIRI = AppInitService.settings.projectIRI;

this._knoraService.knoraApiConnection = AppInitService.settings.apiURL;

this._knoraService.appLogin('app@wordweb.ch', '2bon2btitq')
this._knoraService.appLogin(AppInitService.settings.email, AppInitService.settings.pwd)
.pipe(
mergeMap(() => this._knoraService.getAllLists('http://rdfh.ch/projects/qhOve-cKTmSkiIU81W0lDQ')),
mergeMap(() => this._knoraService.getAllLists(AppInitService.settings.projectIRI)),
mergeMap((lists: ListNodeInfo[]) => forkJoin<Observable<List>>(lists.map((list: ListNodeInfo) => this._knoraService.getList(list.id))))
)
.subscribe((fullList: List[]) => {
Expand Down
20 changes: 12 additions & 8 deletions src/app/services/knora.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export interface ResourceData {
providedIn: 'root'
})
export class KnoraService {
static readonly PROJECT_IRI = 'http://rdfh.ch/projects/qhOve-cKTmSkiIU81W0lDQ';
private _projectIRI = '';
public _knoraApiConnection: KnoraApiConnection;
wwOntology: string;
loggedin: boolean;
Expand Down Expand Up @@ -321,6 +321,10 @@ export class KnoraService {
constructor(private _gsBuilder: GravsearchBuilderService) {
}

set projectIRI(projectIRI: string) {
this._projectIRI = projectIRI;
}

set knoraApiConnection(url: string) {
const settings = url.split('://');
if (settings[0] !== 'http' && settings[0] !== 'https') {
Expand Down Expand Up @@ -662,7 +666,7 @@ export class KnoraService {
// EDITING BY LUKAS //----------------------------------------------------------------------------------------------

getAllLists2(): Observable<Array<ListData>> {
return this._knoraApiConnection.admin.listsEndpoint.getListsInProject(KnoraService.PROJECT_IRI).pipe(
return this._knoraApiConnection.admin.listsEndpoint.getListsInProject(this._projectIRI).pipe(
map((res: ApiResponseData<ListsResponse>) => {
const result: Array<ListData> = [];
for (const list of res.body.lists) {
Expand Down Expand Up @@ -894,7 +898,7 @@ export class KnoraService {
const createResource = new CreateResource();
createResource.label = data.label;
createResource.type = this.wwOntology + 'company';
createResource.attachedToProject = KnoraService.PROJECT_IRI;
createResource.attachedToProject = this._projectIRI;

const props = {};

Expand Down Expand Up @@ -963,7 +967,7 @@ export class KnoraService {
const createResource = new CreateResource();
createResource.label = data.label;
createResource.type = this.wwOntology + 'person';
createResource.attachedToProject = KnoraService.PROJECT_IRI;
createResource.attachedToProject = this._projectIRI;

const props = {};
createResource.properties = props;
Expand Down Expand Up @@ -1169,7 +1173,7 @@ export class KnoraService {
const createResource = new CreateResource();
createResource.label = data.label;
createResource.type = this.wwOntology + 'lexia';
createResource.attachedToProject = KnoraService.PROJECT_IRI;
createResource.attachedToProject = this._projectIRI;

const props = {};

Expand Down Expand Up @@ -1245,7 +1249,7 @@ export class KnoraService {
const createResource = new CreateResource();
createResource.label = data.label;
createResource.type = this.wwOntology + 'passage';
createResource.attachedToProject = KnoraService.PROJECT_IRI;
createResource.attachedToProject = this._projectIRI;

const props = {};

Expand Down Expand Up @@ -1432,7 +1436,7 @@ export class KnoraService {
const createResource = new CreateResource();
createResource.label = data.label;
createResource.type = this.wwOntology + 'book';
createResource.attachedToProject = KnoraService.PROJECT_IRI;
createResource.attachedToProject = this._projectIRI;

const props = {};

Expand Down Expand Up @@ -1754,7 +1758,7 @@ export class KnoraService {
const createResource = new CreateResource();
createResource.label = data.label;
createResource.type = this.wwOntology + 'venue';
createResource.attachedToProject = KnoraService.PROJECT_IRI;
createResource.attachedToProject = this._projectIRI;

const props = {};

Expand Down

0 comments on commit 5d43161

Please sign in to comment.