149 lines
4.9 KiB
TypeScript
149 lines
4.9 KiB
TypeScript
import {Injectable, ReflectiveInjector, Injector} from '@angular/core';
|
|
import { HttpClient , HttpHeaders, HttpParams} from '@angular/common/http';
|
|
import {FieldBase} from '../../app/form/fields/field-base';
|
|
import {JsonObjest} from '../../app/entities/JsonObject.class';
|
|
import {dataModelBuilder} from '../../app/services/dataModelBuilder.service';
|
|
import { DatasetProfile } from '../entities/datasetprofile';
|
|
import {DataModel} from '../entities/DataModel';
|
|
import {Project} from '../entities/model/project';
|
|
import {LoginComponent} from '../../app/login/login-page';
|
|
import { TokenService, TokenProvider } from './token.service';
|
|
import {RestBase} from './rest-base';
|
|
import 'rxjs/Rx';
|
|
|
|
import './../../assets/xml2json.min.js';
|
|
declare var X2JS: any;
|
|
|
|
@Injectable()
|
|
export class ServerService {
|
|
|
|
|
|
xml2jsonOBJ: any;
|
|
//fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/a868dbbb-ee37-4ce6-81c8-27048e0599a9';
|
|
//fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/a71a6a92-5c23-40d7-ab87-e30bc860f5a4';//include rules!
|
|
//fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/d597c26e-3d8b-416a-bc07-1734d68c79c9';//include sections! + 3groupfields
|
|
//fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/dmps/9a4a4a57-4d01-465e-9887-254534f31600'; με το security
|
|
fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend-no-sec/rest/dmps/9a4a4a57-4d01-465e-9887-254534f31600';
|
|
//fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/6c845c42-dc09-42ed-9959-cceb3b616364';
|
|
|
|
/*
|
|
//fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/a868dbbb-ee37-4ce6-81c8-27048e0599a9';
|
|
fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/a71a6a92-5c23-40d7-ab87-e30bc860f5a4';
|
|
//fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/6c845c42-dc09-42ed-9959-cceb3b616364';
|
|
*/
|
|
|
|
//data: any;
|
|
|
|
constructor(private httpClient: HttpClient, private tokenService: TokenService, private restBase: RestBase) { //private http: Http
|
|
this.xml2jsonOBJ = new X2JS();
|
|
}
|
|
|
|
|
|
|
|
listDatasetIDs(){
|
|
return this.restBase.get("dataset");
|
|
}
|
|
|
|
getAllDatasets(){
|
|
return this.restBase.get("getAllDatasets");
|
|
}
|
|
|
|
getAllDatasetIDs(datasetId: string){
|
|
return this.restBase.get("dataset/"+datasetId);
|
|
}
|
|
|
|
|
|
getAllDmps(){
|
|
return this.restBase.get("dmp/getAll");
|
|
}
|
|
|
|
listDmpsLabelID(){
|
|
return this.restBase.get("dmp/listDMPLabelID");
|
|
}
|
|
|
|
getDmp(dmpid : string){
|
|
return this.restBase.get("dmps/"+dmpid);
|
|
}
|
|
|
|
listDmpIDs(){
|
|
return this.restBase.get("dmps");
|
|
}
|
|
|
|
|
|
listProjectIDs(){
|
|
return this.restBase.get("projects");
|
|
}
|
|
|
|
getAllProjects(){
|
|
return this.restBase.get("project/getAll");
|
|
}
|
|
|
|
getProject(projectID : string){
|
|
return this.restBase.get("projects/"+projectID);
|
|
}
|
|
|
|
listProjectsLabelID(){
|
|
return this.restBase.get("project/listAllLabelIDs");
|
|
}
|
|
|
|
|
|
|
|
|
|
getData() {
|
|
|
|
//let headers = new HttpHeaders();
|
|
let headers = new HttpHeaders().set("google-token", this.tokenService.getToken());
|
|
|
|
console.log("google-token: "+ this.tokenService.getToken());
|
|
|
|
return this.httpClient.get<any>(this.fetchURL);
|
|
|
|
|
|
/*
|
|
return this.http.get(this.fetchURL)
|
|
.map(
|
|
(response: Response) => {
|
|
console.log("response");
|
|
console.log(response);
|
|
const data = response.json();
|
|
|
|
//replace the xmls {model,view,rule} definitions with json -- https://github.com/abdmob/x2js library
|
|
data.dataset.profile.definition = this.xml2jsonOBJ.xml_str2json(data.dataset.profile.definition);
|
|
data.dataset.profile.ruleset.definition = this.xml2jsonOBJ.xml_str2json(data.dataset.profile.ruleset.definition);
|
|
data.dataset.profile.viewstyle.definition = this.xml2jsonOBJ.xml_str2json(data.dataset.profile.viewstyle.definition);
|
|
//can be converted back to xml (which shouldn't be needed) with this.xml2jsonOBJ.json2xml_str
|
|
|
|
this.data = data; //cache it for subsequent calls
|
|
return data;
|
|
}
|
|
);
|
|
*/
|
|
|
|
}
|
|
|
|
getProjects(){
|
|
|
|
let headers = new HttpHeaders().set("google-token", this.tokenService.getToken());
|
|
|
|
console.log("google-token: "+ this.tokenService.getToken());
|
|
|
|
return this.httpClient.get<any>("http://dl010.madgik.di.uoa.gr:8080/dmp-backend-no-sec/rest/project/getAll");
|
|
|
|
// let projects :Project[] =[];
|
|
|
|
// let project = new Project;
|
|
// project.name = "Project1";
|
|
// project.id = "Project1Id";
|
|
|
|
// projects.push(project);
|
|
|
|
// let project2 = new Project;
|
|
// project2.name = "Project2";
|
|
// project2.id = "Project2Id";
|
|
|
|
// projects.push(project2);
|
|
|
|
// return projects;
|
|
}
|
|
|
|
} |