答案 0 :(得分:1)
为什么不使用本体文件? 与.nt和.owl中的每个版本一起发布
2016-10:
然后只查询http://dbpedia.org/ontology/Galaxy
某事like:
import { AppSandbox } from '../../shared/sandbox/app-sandbox';
import { Observable } from 'rxjs/Observable';
import { Action } from '@ngrx/store/store';
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import { ProvidersListService } from '../../shared/services/provider-list.service';
import {
SetServiceProvidersAction,
SetSelectedServiceProviderId,
SetDeviceListAction
} from '../../shared/state-management/actions/serviceprovider.actions';
import * as fromRoot from '../../shared/reducers/index';
import { AppStateManager } from '../../shared/state-management/app-state-manager';
import { ServiceAction, ServiceActionTypes } from '../../shared/models/service-action';
import { Device } from '../../shared/models/device';
import { ServiceProviderResult } from '../../shared/models/service-provider';
@Injectable()
export class NavbarSandbox extends AppSandbox {
constructor(private providersListService: ProvidersListService, private appStateManager: AppStateManager) {
super();
}
// TODO: create action using ActionFactory
// To get data from service
public getServiceProviderListAPI(payload: any): Observable<Array<ServiceProviderResult>> {
const data$ = super.invokeService(new ServiceAction(ServiceActionTypes.GET_SERVICE_PROVIDERS, payload), this.providersListService)
.subscribe((res: Array<ServiceProviderResult>) => {
this.setListOfServiceProviders(new SetServiceProvidersAction(res));
});
return this.getListOfServiceProviders();
}
getDeviceListByIdAPI(): void {
let selectedId: number;
this.getSelectedServiceProvider().subscribe((data) => { selectedId = data.id; });
const data$ = super.invokeService(new ServiceAction(ServiceActionTypes.GET_DEVICE_LIST, selectedId), this.providersListService)
.subscribe((res: Array<Device>) => {
this.setDeviceDatabyId(new SetDeviceListAction(res));
});
}
// To save data in store
private setListOfServiceProviders(action: Action): void {
this.appStateManager.saveToStore(action);
}
// To set the device data based on selected value
private setDeviceDatabyId(payload: any): void {
this.appStateManager.saveToStore(new SetDeviceListAction(payload));
}
// To set the selected ID from dropdown
public setSelectedServiceProvider(payload: any): void {
this.appStateManager.saveToStore(new SetSelectedServiceProviderId(payload));
// To call and store device data into store.
this.getDeviceListByIdAPI();
this.getDeviceListbySelectedId().subscribe((data) => {console.log(data); });
}
// To get data from store
public getListOfServiceProviders(): Observable<Array<ServiceProviderResult>> {
return this.appStateManager.getFromStore<Array<ServiceProviderResult>>(state => state.providerState.listOfServiceProviders);
}
public getSelectedServiceProvider(): Observable<ServiceProviderResult> {
return this.appStateManager.getFromStore<ServiceProviderResult>(state => state.providerState.selectedServiceProvider);
}
public getDeviceListbySelectedId(): Observable<Array<Device>> {
return this.appStateManager.getFromStore<Array<Device>>(state => state.providerState.listOfDevices);
}
}
更新
对于json输出附加&amp; format = json或&amp; format = json-ld:click。