argos/dmp-frontend/src/app/services/server.service.ts

160 lines
3.6 KiB
TypeScript
Raw Normal View History

import {Injectable, ReflectiveInjector, Injector} from '@angular/core';
import {JsonObjest} from '../../app/entities/JsonObject.class';
import { DatasetProfile } from '../entities/datasetprofile';
import {Project} from '../entities/model/project';
2017-10-18 18:08:21 +02:00
import {RestBase} from './rest-base';
2017-10-17 11:13:10 +02:00
import 'rxjs/Rx';
import './../../assets/xml2json.min.js';
declare var X2JS: any;
@Injectable()
export class ServerService {
xml2jsonOBJ: any;
2017-11-08 11:35:56 +01:00
constructor(private restBase: RestBase) {
this.xml2jsonOBJ = new X2JS();
}
2017-10-18 18:08:21 +02:00
public listDatasetIDs(){
2017-10-18 18:08:21 +02:00
return this.restBase.get("dataset");
}
public getAllDatasets(){
return this.restBase.get("getAllDatasets");
2017-10-18 18:08:21 +02:00
}
public getAllDatasetIDs(datasetId: string){
2017-10-18 18:08:21 +02:00
return this.restBase.get("dataset/"+datasetId);
}
2017-11-01 11:27:05 +01:00
public getDatasetByID(datasetId: string){
return this.restBase.get("datasets/"+datasetId);
}
public setDataset(dataset){
return this.restBase.post("dataset/update", dataset);
}
2017-10-18 18:08:21 +02:00
public getAllDmps(){
2017-10-18 18:08:21 +02:00
return this.restBase.get("dmp/getAll");
}
public listDmpsLabelID(){
2017-10-18 18:08:21 +02:00
return this.restBase.get("dmp/listDMPLabelID");
2017-10-23 18:16:04 +02:00
}
2017-10-18 18:08:21 +02:00
2017-11-22 18:33:29 +01:00
public getDmp(dmpid : string, eager? : boolean){
if(eager)
return this.restBase.get("dmps/"+dmpid, {"eager": true});
else
return this.restBase.get("dmps/"+dmpid, {"eager": true});
2017-10-18 18:08:21 +02:00
}
public listDmpIDs(){
2017-10-18 18:08:21 +02:00
return this.restBase.get("dmps");
}
public listProjectIDs(){
2017-10-18 18:08:21 +02:00
return this.restBase.get("projects");
}
public getAllProjects(){
2017-10-18 18:08:21 +02:00
return this.restBase.get("project/getAll");
}
public getProject(projectID : string){
2017-10-18 18:08:21 +02:00
return this.restBase.get("projects/"+projectID);
}
public listProjectsLabelID(){
2017-10-18 18:08:21 +02:00
return this.restBase.get("project/listAllLabelIDs");
}
2017-10-23 18:16:04 +02:00
public listDmpsUser(){
return this.restBase.get("dmp/listDMPLabelID");
}
2017-11-06 17:25:23 +01:00
public getProjectsOfUser(){
2017-10-23 18:16:04 +02:00
return this.restBase.get("project/getofuser");
}
public createProject(data:any){
return this.restBase.post("project/createofuser", data);
}
2017-11-06 17:25:23 +01:00
public updateProject(data:any){
return this.restBase.post("project/update", data);
}
public getAllDataSet(){
return this.restBase.get("dataset/getAll");
}
public getDmpOfUser(){
return this.restBase.get("dmp/getofuser");
}
2017-10-27 11:52:27 +02:00
public createDmpForCurrentUser(data:any){
2017-10-27 16:08:10 +02:00
return this.restBase.post("dmp/createofuser", data);
2017-10-27 09:48:53 +02:00
}
2017-11-01 12:30:39 +01:00
public updateDmp(data:any){
return this.restBase.post("dmp/update", data);
}
2017-11-07 10:45:19 +01:00
public cloneDmp(data: any){
return this.restBase.post("dmp/cloneforuser", data);
}
2017-11-06 14:11:03 +01:00
public deleteDmp(dmp: any){
return this.restBase.post("dmp/softdelete", dmp);
}
2017-10-27 16:08:10 +02:00
public getDatasetForDmp(data:any){
return this.restBase.post("dmp/getdatasets", data);
2017-10-27 16:08:10 +02:00
}
2017-10-27 18:38:31 +02:00
public createDatasetForDmp(data:any){
2017-10-27 16:08:10 +02:00
return this.restBase.post("dataset/create", data);
}
public getAllDatsetsProfile(){
return this.restBase.get("datasetprofile/getAll");
}
2017-10-30 15:56:50 +01:00
2017-11-01 11:27:05 +01:00
public getDatasetProfileByID(id){
2017-10-30 15:56:50 +01:00
return this.restBase.get("datasetprofiles/"+id);
}
2017-10-30 17:37:17 +01:00
public updateDatsetsProfile(data:any){
return this.restBase.post("dataset/update", data);
}
2017-10-27 16:08:10 +02:00
2017-11-06 14:11:03 +01:00
public deleteDataset(dataset: any){
return this.restBase.post("dataset/softdelete", dataset);
}
public whoami(){
return this.restBase.get("user/whoami");
}
2017-11-06 14:11:03 +01:00
2017-11-08 11:35:56 +01:00
/*
logOut() {
2017-11-01 18:18:27 +01:00
this.tokenService.logout();
}
2017-10-17 11:13:10 +02:00
*/
2017-11-08 11:35:56 +01:00
2017-11-08 14:33:14 +01:00
getThroughProxy(url : string, query: string){
return this.restBase.proxy_get_wQuery(url, query);
}
2017-11-08 11:35:56 +01:00
}