Page MenuHomec4science

query.service.ts
No OneTemporary

File Metadata

Created
Thu, May 30, 01:43

query.service.ts

import { Injectable } from '@angular/core';
import { DataService } from './resources.service';
@Injectable()
export class QueryService {
query: string;
select = 'SELECT ?p ?o '
whereSubject: string;
whereObject: string;
wherePredicate: string;
Optional = '';
queryLimit = ' LIMIT 200';
constructor(private dataService: DataService ) {
}
public assemble_resource_data(resourceValue: string, resourceOwlClass?: string) {
switch (resourceOwlClass) {
case 'subject': {
this.whereSubject = ' <' + decodeURI(resourceValue) + '> ';
this.wherePredicate = ' ?p ';
this.whereObject = ' ?o ';
break;
}
case 'object': {
this.whereObject = ' <' + decodeURI(resourceValue) + '> ';
this.wherePredicate = ' ?p ';
this.whereSubject = ' ?s ';
break;
}
case 'predicate': {
this.wherePredicate = ' <' + decodeURI(resourceValue) + '> ';
this.whereObject = ' ?o ';
this.whereSubject = ' ?s ';
break;
}
}
this.query = this.select + 'WHERE { ' + this.whereSubject + this.wherePredicate + this.whereObject + this.Optional + ' } ' + this.queryLimit;
return this.query;
}
}

Event Timeline