services, repos, registries added to dataset creation

This commit is contained in:
Diamantis Tziotzios 2017-12-08 11:51:39 +02:00
parent 65831fff1f
commit 028410c128
4 changed files with 206 additions and 152 deletions

View File

@ -98,6 +98,7 @@ import {ProgressBarModule} from 'primeng/primeng';
import {StepsModule,MenuItem} from 'primeng/primeng'; import {StepsModule,MenuItem} from 'primeng/primeng';
import {CheckboxModule} from 'primeng/primeng'; import {CheckboxModule} from 'primeng/primeng';
import {RadioButtonModule} from 'primeng/primeng'; import {RadioButtonModule} from 'primeng/primeng';
import {AutoCompleteModule} from 'primeng/primeng';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -157,7 +158,8 @@ import {RadioButtonModule} from 'primeng/primeng';
SidebarModule.forRoot(), SidebarModule.forRoot(),
StepsModule, StepsModule,
CheckboxModule, CheckboxModule,
RadioButtonModule RadioButtonModule,
AutoCompleteModule
], ],
providers: [{ providers: [{
provide: HTTP_INTERCEPTORS, provide: HTTP_INTERCEPTORS,

View File

@ -5,7 +5,7 @@ import { ServerService } from '../../app/services/server.service';
import { Project } from '../entities/model/project'; import { Project } from '../entities/model/project';
import { Dataset } from '../entities/model/dataset'; import { Dataset } from '../entities/model/dataset';
import { Dmp } from '../entities/model/dmp'; import { Dmp } from '../entities/model/dmp';
import {DataTable} from 'angular2-datatable'; import { DataTable } from 'angular2-datatable';
import { DropdownField } from '../../app/form/fields/dropdown/field-dropdown'; import { DropdownField } from '../../app/form/fields/dropdown/field-dropdown';
import { Param } from '../entities/model/param'; import { Param } from '../entities/model/param';
import { StatusToString } from '../pipes/various/status-to-string'; import { StatusToString } from '../pipes/various/status-to-string';
@ -16,7 +16,7 @@ declare var $: any;
import '../../assets/custom.js'; import '../../assets/custom.js';
declare function simple_notifier(type: string, title: string, message:string): any; declare function simple_notifier(type: string, title: string, message: string): any;
@Component({ @Component({
selector: 'datasets-table', selector: 'datasets-table',
@ -29,11 +29,11 @@ export class DatasetsComponent implements OnInit {
// Start ALTERNATIVE // Start ALTERNATIVE
//whole dmp data model //whole dmp data model
tableData : any[] = new Array(); tableData: any[] = new Array();
//organisation editor data model //organisation editor data model
editingOrganisation: any = {}; editingOrganisation: any = {};
organisationEditorForm : any; organisationEditorForm: any;
//required by the table //required by the table
public filterQuery = ""; public filterQuery = "";
@ -46,8 +46,8 @@ export class DatasetsComponent implements OnInit {
// for tableIds // for tableIds
showIDs : boolean = false; showIDs: boolean = false;
// END ALTERNATIVE // END ALTERNATIVE
returnUrl: string; returnUrl: string;
@Input() datasets: Dataset[]; @Input() datasets: Dataset[];
@ -57,12 +57,15 @@ export class DatasetsComponent implements OnInit {
@Input() dmpLabelforDatasets: string; @Input() dmpLabelforDatasets: string;
@Input() statusDropDown: DropdownField; @Input() statusDropDown: DropdownField;
dataset: any; dataset: any;
saveAndDescribe:boolean; saveAndDescribe: boolean;
dataSetValue: boolean = true; dataSetValue: boolean = true;
uriRegex = "/^([a-z0-9+.-]+):(?://(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?|(/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?$/i"; uriRegex = "/^([a-z0-9+.-]+):(?://(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?|(/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?$/i";
filteredServices: any[];
filteredRepositories: any[];
filteredRegistries: any[];
constructor( constructor(
@ -78,7 +81,7 @@ export class DatasetsComponent implements OnInit {
this.datasetProfileDropDown.options = []; this.datasetProfileDropDown.options = [];
this.saveAndDescribe = false; this.saveAndDescribe = false;
this.statusDropDown = new DropdownField(); this.statusDropDown = new DropdownField();
this.statusDropDown.options= [{key:'', value:null},{key:'0', value:"Active"},{key:'1', value:"Inactive"}] this.statusDropDown.options = [{ key: '', value: null }, { key: '0', value: "Active" }, { key: '1', value: "Inactive" }]
} }
@ -101,26 +104,26 @@ export class DatasetsComponent implements OnInit {
params.value = datasetprofile.label; params.value = datasetprofile.label;
this.datasetProfileDropDown.options.push(params); this.datasetProfileDropDown.options.push(params);
}, },
error => { error => {
simple_notifier("danger",null,"Could not load User's Dataset Profiles"); simple_notifier("danger", null, "Could not load User's Dataset Profiles");
} }
); );
} }
) )
} }
ngAfterViewInit(){ ngAfterViewInit() {
$( function() { $(function () {
$('#status-filter').append("<option value='' style='text-color: #cccccc' selected disabled hidden>Filter by status</option>"); $('#status-filter').append("<option value='' style='text-color: #cccccc' selected disabled hidden>Filter by status</option>");
//$('#status-filter').value=; //$('#status-filter').value=;
}) })
} }
createEmptyDataset(){ createEmptyDataset() {
return { return {
id: null, id: null,
label: '', label: '',
@ -129,43 +132,46 @@ export class DatasetsComponent implements OnInit {
status: 0, status: 0,
properties: '', properties: '',
profile: { "id": '' }, profile: { "id": '' },
dmp: { "id": '' } dmp: { "id": '' },
services:[],
registries:[],
repositories:[]
} }
} }
SaveDataset(){ SaveDataset() {
if(this.dataset.id ==null){ if (this.dataset.id == null) {
this.dataset.dmp = { "id": this.dmpIdforDatasets } this.dataset.dmp = { "id": this.dmpIdforDatasets }
this.dataset.profile = { "id": this.dataset.profile } this.dataset.profile = { "id": this.dataset.profile }
this.serverService.createDatasetForDmp(this.dataset).subscribe( this.serverService.createDatasetForDmp(this.dataset).subscribe(
response => { response => {
simple_notifier("success",null,"Created dataset"); simple_notifier("success", null, "Created dataset");
this.getDatasets(); this.getDatasets();
if (this.saveAndDescribe == true) if (this.saveAndDescribe == true)
this.describeDataset(response); this.describeDataset(response);
}, },
error=>{ error => {
simple_notifier("danger",null,"Could not create Dataset"); simple_notifier("danger", null, "Could not create Dataset");
} }
) )
$("#newDatasetModal").modal("hide"); $("#newDatasetModal").modal("hide");
} }
else{ else {
this.dataset.dmp = { "id": this.dmpIdforDatasets }; this.dataset.dmp = { "id": this.dmpIdforDatasets };
this.dataset.profile = { "id": this.dataset.profile }; this.dataset.profile = { "id": this.dataset.profile };
this.dataset.creator = {"id" : this.dataset.creator }; this.dataset.creator = { "id": this.dataset.creator };
this.serverService.updateDatsetsProfile(this.dataset).subscribe( this.serverService.updateDatsetsProfile(this.dataset).subscribe(
response => { response => {
simple_notifier("success",null,"Dataset edited"); simple_notifier("success", null, "Dataset edited");
this.getDatasets(); this.getDatasets();
if (this.saveAndDescribe == true) if (this.saveAndDescribe == true)
this.describeDataset(response); this.describeDataset(response);
}, },
error => { error => {
simple_notifier("danger",null,"Could not edit dataset"); simple_notifier("danger", null, "Could not edit dataset");
} }
) )
$("#newDatasetModal").modal("hide"); $("#newDatasetModal").modal("hide");
@ -173,18 +179,18 @@ export class DatasetsComponent implements OnInit {
} }
getDatasets(muted?: boolean){ getDatasets(muted?: boolean) {
this.spinnerService.show(); this.spinnerService.show();
this.serverService.getDatasetForDmp({ "id": this.dmpIdforDatasets }).subscribe( this.serverService.getDatasetForDmp({ "id": this.dmpIdforDatasets }).subscribe(
response => { response => {
this.tableData = response; this.tableData = response;
if(muted && muted!=true) if (muted && muted != true)
simple_notifier("success",null,"Updated datasets table"); simple_notifier("success", null, "Updated datasets table");
}, },
error => { error => {
simple_notifier("danger",null,"Could not update datasets table"); simple_notifier("danger", null, "Could not update datasets table");
}, },
() =>{ () => {
this.spinnerService.hide(); this.spinnerService.hide();
} }
); );
@ -199,16 +205,16 @@ export class DatasetsComponent implements OnInit {
}, },
error => { error => {
console.log("could not retrieve dataset for dpm: "+dmpid); console.log("could not retrieve dataset for dpm: " + dmpid);
}, },
() =>{ () => {
this.spinnerService.hide(); this.spinnerService.hide();
} }
); );
} }
editRow(item, event) { editRow(item, event) {
if (event.toElement.id == "editDataset"){ if (event.toElement.id == "editDataset") {
//this.dataset = item; //this.dataset = item;
this.dataset.label = item.label; this.dataset.label = item.label;
this.dataset.uri = item.uri; this.dataset.uri = item.uri;
@ -216,12 +222,12 @@ export class DatasetsComponent implements OnInit {
this.dataset.status = item.status; this.dataset.status = item.status;
this.dataset.description = item.description; this.dataset.description = item.description;
//this.dataset.dmp = item.dmp; //this.dataset.dmp = item.dmp;
this.dataset.profile = item.profile==null ? null : item.profile.id; this.dataset.profile = item.profile == null ? null : item.profile.id;
this.dataset.id = item.id; this.dataset.id = item.id;
this.dataset.creator = item.creator; this.dataset.creator = item.creator;
$("#newDatasetModal").modal("show"); $("#newDatasetModal").modal("show");
} }
else if(event.toElement.id == "describeDataset"){ else if (event.toElement.id == "describeDataset") {
this.describeDataset(item); this.describeDataset(item);
} }
@ -229,49 +235,67 @@ export class DatasetsComponent implements OnInit {
newDataset() { newDataset() {
this.dataset = this.createEmptyDataset(); this.dataset = this.createEmptyDataset();
this.dataset.dmp =this.dmpLabelforDatasets; this.dataset.dmp = this.dmpLabelforDatasets;
this.dataset.status = 0; this.dataset.status = 0;
$("#newDatasetModal").modal("show"); $("#newDatasetModal").modal("show");
} }
SaveDescribeDataset(){ SaveDescribeDataset() {
this.saveAndDescribe = true; this.saveAndDescribe = true;
this.SaveDataset(); this.SaveDataset();
} }
describeDataset(item) { describeDataset(item) {
this.router.navigate(['/dynamic-form/'+item.id]); this.router.navigate(['/dynamic-form/' + item.id]);
//this.ngZone.run(() => this.router.navigate(['dynamic-form', {id: item.profile.id, datasetId:item.id, label: item.label}])); //this.ngZone.run(() => this.router.navigate(['dynamic-form', {id: item.profile.id, datasetId:item.id, label: item.label}]));
} }
markDatasetForDelete(dataset){ markDatasetForDelete(dataset) {
this.dataset = dataset; this.dataset = dataset;
} }
deleteDataset(confirmation){ deleteDataset(confirmation) {
if(confirmation==true) if (confirmation == true)
this.deleteRow(this.dataset); this.deleteRow(this.dataset);
} }
deleteRow(dataset){ deleteRow(dataset) {
this.serverService.deleteDataset(dataset).subscribe( this.serverService.deleteDataset(dataset).subscribe(
response => { response => {
simple_notifier("success",null,"Deleted dataset"); simple_notifier("success", null, "Deleted dataset");
this.getDatasets(); this.getDatasets();
}, },
err => { err => {
if(err.status>=200 && err.status<300) if (err.status >= 200 && err.status < 300)
simple_notifier("success",null,"Deleted dataset"); simple_notifier("success", null, "Deleted dataset");
else else
simple_notifier("danger",null,"Could not delete the dataset"); simple_notifier("danger", null, "Could not delete the dataset");
this.getDatasets(); this.getDatasets();
} }
); );
} }
searchServices(event) {
let query = event.query;
this.serverService.searchDatasetService(query).subscribe(services => {
this.filteredServices = services;
});
}
searchRegistries(event) {
let query = event.query;
this.serverService.searchDatasetRegistry(query).subscribe(registries => {
this.filteredRegistries = registries;
});
}
searchRepositories(event) {
let query = event.query;
this.serverService.searchDatasetRepository(query).subscribe(repos => {
this.filteredRepositories = repos;
});
}
} }

View File

@ -1,7 +1,6 @@
<app-spinner> </app-spinner> <app-spinner> </app-spinner>
<table class="table table-striped" [mfData]="tableData | datasetTableFilter : filterQuery | datasetstatusFilter: statusFilter" #mf="mfDataTable" [mfRowsOnPage]="rowsOnPage" <table class="table table-striped" [mfData]="tableData | datasetTableFilter : filterQuery | datasetstatusFilter: statusFilter"
[(mfSortBy)]="sortBy" [(mfSortOrder)]="sortOrder"> #mf="mfDataTable" [mfRowsOnPage]="rowsOnPage" [(mfSortBy)]="sortBy" [(mfSortOrder)]="sortOrder">
<thead> <thead>
<tr> <tr>
@ -11,19 +10,20 @@
<th colspan="1"> <th colspan="1">
<!-- <input class="form-control" [(ngModel)]="versionFilter" placeholder='Filter' /> --> <!-- <input class="form-control" [(ngModel)]="versionFilter" placeholder='Filter' /> -->
<select [ngClass]="{'semi-visible': statusFilter==''}" class="form-control" id="status-filter" [(ngModel)]="statusFilter" [name]="statusDropDown" #datasetfield>
<select [ngClass]="{'semi-visible': statusFilter==''}" class="form-control" id="status-filter" [(ngModel)]="statusFilter"
[name]="statusDropDown" #datasetfield>
<option *ngFor="let opt of statusDropDown.options" [value]="opt.key">{{opt.value}}</option> <option *ngFor="let opt of statusDropDown.options" [value]="opt.key">{{opt.value}}</option>
</select> </select>
</th> </th>
<th> <th>
<button class="btn btn-default" (click)="getDatasets('false')"> <button class="btn btn-default" (click)="getDatasets('false')">
<span class="glyphicon glyphicon-refresh"></span> <span class="glyphicon glyphicon-refresh"></span>
</button> </button>
</th> </th>
</tr> </tr>
<tr> <tr>
@ -32,7 +32,7 @@
</th> </th>
<th> <th>
<mfDefaultSorter by="label">Label</mfDefaultSorter> <mfDefaultSorter by="label">Label</mfDefaultSorter>
</th> </th>
<th> <th>
<mfDefaultSorter by="uri">Uri</mfDefaultSorter> <mfDefaultSorter by="uri">Uri</mfDefaultSorter>
</th> </th>
@ -63,17 +63,24 @@
<td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{dataset.id}}</td> <td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{dataset.id}}</td>
<td>{{(dataset?.label?.length > 80) ? (dataset?.label | slice:0:80)+'...':(dataset?.label) }}</td> <td>{{(dataset?.label?.length > 80) ? (dataset?.label | slice:0:80)+'...':(dataset?.label) }}</td>
<td>{{(dataset?.uri?.length > 40) ? (dataset?.uri | slice:0:40)+'...':(dataset?.uri) }}</td> <td>{{(dataset?.uri?.length > 40) ? (dataset?.uri | slice:0:40)+'...':(dataset?.uri) }}</td>
<td>{{(dataset?.profile?.label?.length > 40) ? (dataset?.profile?.label | slice:0:40)+'...':(dataset?.profile?.label) }}</td> <td>{{(dataset?.profile?.label?.length > 40) ? (dataset?.profile?.label | slice:0:40)+'...':(dataset?.profile?.label)
}}
</td>
<td>{{(dataset?.description?.length > 40) ? (dataset?.description | slice:0:40)+'...':(dataset?.description) }}</td> <td>{{(dataset?.description?.length > 40) ? (dataset?.description | slice:0:40)+'...':(dataset?.description) }}</td>
<td>{{dataset?.created | date:'yyyy-MM-dd HH:mm:ss Z'}}</td> <td>{{dataset?.created | date:'yyyy-MM-dd HH:mm:ss Z'}}</td>
<td>{{dataset?.status | statusToString }}</td> <td>{{dataset?.status | statusToString }}</td>
<td> <td>
<a [ngClass]="{'hidden-keepspace': dataset.status==2 }" class="editGridColumn cursor-hand disabled" (click)="editRow(dataset, $event)"> <a [ngClass]="{'hidden-keepspace': dataset.status==2 }" class="editGridColumn cursor-hand disabled" (click)="editRow(dataset, $event)">
<i class="fa fa-pencil fa-fw" data-toggle="tooltip" title="edit Properties" id="editDataset"></i></a> <i class="fa fa-pencil fa-fw" data-toggle="tooltip" title="edit Properties" id="editDataset"></i>
</a>
<a class="editGridColumn cursor-hand" (click)="editRow(dataset, $event)"> <a class="editGridColumn cursor-hand" (click)="editRow(dataset, $event)">
<i class="fa fa-eraser fa-fw" data-toggle="modal" data-target="#delete-dataset-confirm" (click)="markDatasetForDelete(dataset)" title="delete Dataset"></i></a> <i class="fa fa-eraser fa-fw" data-toggle="modal" data-target="#delete-dataset-confirm" (click)="markDatasetForDelete(dataset)"
title="delete Dataset"></i>
</a>
<a class="editGridColumn cursor-hand" (click)="editRow(dataset, $event)"> <a class="editGridColumn cursor-hand" (click)="editRow(dataset, $event)">
<i class="fa fa-list-alt fa-fw" data-toggle="tooltip" title="describe dataset" id="describeDataset"></i></a></td> <i class="fa fa-list-alt fa-fw" data-toggle="tooltip" title="describe dataset" id="describeDataset"></i>
</a>
</td>
</tr> </tr>
</tbody> </tbody>
@ -93,9 +100,11 @@
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title" id="modalLabel"><b>{{ dataset?.id ? "Edit Dataset" : "New Dataset" }}</b></h4> <h4 class="modal-title" id="modalLabel">
<b>{{ dataset?.id ? "Edit Dataset" : "New Dataset" }}</b>
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
@ -115,23 +124,33 @@
<input class="form-control" id="uri-text" [(ngModel)]="dataset.uri" name="uri" pattern="^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?"> <input class="form-control" id="uri-text" [(ngModel)]="dataset.uri" name="uri" pattern="^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="status-name" class="col-form-label">Status:</label> <label for="status-name" class="col-form-label">Status:</label>
<select class="form-control" id="statusid" [(ngModel)]="dataset.status" name="statusDropDown" #datasetfield> <select class="form-control" id="statusid" [(ngModel)]="dataset.status" name="statusDropDown" #datasetfield>
<option *ngFor="let opt of statusDropDown.options" [value]="opt.key">{{opt.value}}</option> <option *ngFor="let opt of statusDropDown.options" [value]="opt.key">{{opt.value}}</option>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="abbreviation-text" class="form-control-label">Description:</label> <label for="abbreviation-text" class="form-control-label">Description:</label>
<textarea rows="3" class="form-control" id="abbreviation-text" [(ngModel)]="dataset.description" name="description"></textarea> <textarea rows="3" class="form-control" id="abbreviation-text" [(ngModel)]="dataset.description" name="description"></textarea>
</div> </div>
<!-- <div class="form-group"> <div class="form-group">
<label for="start-date" class="form-control-label">Properties:</label> <label for="services-dropdown" class="form-control-label">Services:</label>
<input class="form-control" id="startDate-date" [(ngModel)]= "dataset.properties" name = "properties"> <p-autoComplete id="services-dropdown" [(ngModel)]="dataset.services" [suggestions]="filteredServices" (completeMethod)="searchServices($event)"
</div> --> styleClass="wid100" [minLength]="1" name="services" [multiple]="true" [emptyMessage]="true" field="name">
<!-- <div class="form-group"> </p-autoComplete>
<label for="end-date" class="form-control-label">End Date:</label> </div>
<input class="form-control" id="endDate-date" [(ngModel)]= "dataset.endDate" name = "endDate"> <div class="form-group">
</div> --> <label for="registries-dropdown" class="form-control-label">Registries:</label>
<p-autoComplete id="registries-dropdown" [(ngModel)]="dataset.registries" [suggestions]="filteredRegistries" (completeMethod)="searchRegistries($event)"
styleClass="wid100" [minLength]="1" name="registries" [multiple]="true" [emptyMessage]="true" field="name">
</p-autoComplete>
</div>
<div class="form-group">
<label for="repositories-dropdown" class="form-control-label">Repositories:</label>
<p-autoComplete id="repositories-dropdown" [(ngModel)]="dataset.repositories" [suggestions]="filteredRepositories" (completeMethod)="searchRepositories($event)"
styleClass="wid100" [minLength]="1" name="repositories" [multiple]="true" [emptyMessage]="true" field="name">
</p-autoComplete>
</div>
</form> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
@ -143,5 +162,6 @@
</div> </div>
</div> </div>
<!-- Confirmation module- do not delete --> <!-- Confirmation module- do not delete -->
<confirmation [confirmationID]="'delete-dataset-confirm'" [confirmationTitle]="'Caution'" [confirmationDescr]="'This action will delete this dataset. Are you sure you want to delete this dataset ? This is not revertable !'" (responseSender)="deleteDataset($event)"></confirmation> <confirmation [confirmationID]="'delete-dataset-confirm'" [confirmationTitle]="'Caution'" [confirmationDescr]="'This action will delete this dataset. Are you sure you want to delete this dataset ? This is not revertable !'"
(responseSender)="deleteDataset($event)"></confirmation>

View File

@ -1,8 +1,8 @@
import {Injectable, ReflectiveInjector, Injector} from '@angular/core'; import { Injectable, ReflectiveInjector, Injector } from '@angular/core';
import {JsonObjest} from '../../app/entities/JsonObject.class'; import { JsonObjest } from '../../app/entities/JsonObject.class';
import { DatasetProfile } from '../entities/datasetprofile'; import { DatasetProfile } from '../entities/datasetprofile';
import {Project} from '../entities/model/project'; import { Project } from '../entities/model/project';
import {RestBase} from './rest-base'; import { RestBase } from './rest-base';
import 'rxjs/Rx'; import 'rxjs/Rx';
import './../../assets/xml2json.min.js'; import './../../assets/xml2json.min.js';
@ -12,168 +12,176 @@ declare var X2JS: any;
export class ServerService { export class ServerService {
xml2jsonOBJ: any; xml2jsonOBJ: any;
constructor(private restBase: RestBase) { constructor(private restBase: RestBase) {
this.xml2jsonOBJ = new X2JS(); this.xml2jsonOBJ = new X2JS();
} }
public listDatasetIDs(){ public listDatasetIDs() {
return this.restBase.get("dataset"); return this.restBase.get("dataset");
} }
public getAllDatasets(){ public getAllDatasets() {
return this.restBase.get("getAllDatasets"); return this.restBase.get("getAllDatasets");
} }
public getAllDatasetIDs(datasetId: string){ public getAllDatasetIDs(datasetId: string) {
return this.restBase.get("dataset/"+datasetId); return this.restBase.get("dataset/" + datasetId);
} }
public getDatasetByID(datasetId: string){ public getDatasetByID(datasetId: string) {
return this.restBase.get("datasets/"+datasetId); return this.restBase.get("datasets/" + datasetId);
} }
public setDataset(dataset){ public setDataset(dataset) {
return this.restBase.post("dataset/update", dataset); return this.restBase.post("dataset/update", dataset);
} }
public getAllDmps(){ public getAllDmps() {
return this.restBase.get("dmp/getAll"); return this.restBase.get("dmp/getAll");
} }
public listDmpsLabelID(){ public listDmpsLabelID() {
return this.restBase.get("dmp/listDMPLabelID"); return this.restBase.get("dmp/listDMPLabelID");
} }
public getDmp(dmpid : string, eager? : boolean){ public getDmp(dmpid: string, eager?: boolean) {
if(eager) if (eager)
return this.restBase.get("dmps/"+dmpid, {"eager": true}); return this.restBase.get("dmps/" + dmpid, { "eager": true });
else else
return this.restBase.get("dmps/"+dmpid, {"eager": true}); return this.restBase.get("dmps/" + dmpid, { "eager": true });
} }
public getDmpHistory(dmpid: string){ public getDmpHistory(dmpid: string) {
return this.restBase.get("dmp/history/"+dmpid); return this.restBase.get("dmp/history/" + dmpid);
} }
public listDmpIDs(){ public listDmpIDs() {
return this.restBase.get("dmps"); return this.restBase.get("dmps");
} }
public listProjectIDs(){ public listProjectIDs() {
return this.restBase.get("projects"); return this.restBase.get("projects");
} }
public getAllProjects(){ public getAllProjects() {
return this.restBase.get("project/getAll"); return this.restBase.get("project/getAll");
} }
public getProject(projectID : string, eager? : boolean){ public getProject(projectID: string, eager?: boolean) {
if(eager) if (eager)
return this.restBase.get("projects/"+projectID, {"eager": true}); return this.restBase.get("projects/" + projectID, { "eager": true });
else else
return this.restBase.get("projects/"+projectID, {"eager": false}); return this.restBase.get("projects/" + projectID, { "eager": false });
} }
public listProjectsLabelID(){ public listProjectsLabelID() {
return this.restBase.get("project/listAllLabelIDs"); return this.restBase.get("project/listAllLabelIDs");
} }
public listDmpsUser(){ public listDmpsUser() {
return this.restBase.get("dmp/listDMPLabelID"); return this.restBase.get("dmp/listDMPLabelID");
} }
public getProjectsOfUser(){ public getProjectsOfUser() {
return this.restBase.get("project/getofuser"); return this.restBase.get("project/getofuser");
} }
public createProject(data:any){ public createProject(data: any) {
return this.restBase.post("project/createofuser", data); return this.restBase.post("project/createofuser", data);
} }
public updateProject(data:any){ public updateProject(data: any) {
return this.restBase.post("project/update", data); return this.restBase.post("project/update", data);
} }
public getDmpsOfProject(projectID: string){ public getDmpsOfProject(projectID: string) {
return this.restBase.get("project/dmps", {"id":projectID}); return this.restBase.get("project/dmps", { "id": projectID });
} }
public getAllDataSet(){ public getAllDataSet() {
return this.restBase.get("dataset/getAll"); return this.restBase.get("dataset/getAll");
} }
public getDmpOfUser(){ public getDmpOfUser() {
return this.restBase.get("dmp/getofuser"); return this.restBase.get("dmp/getofuser");
} }
public createDmpForCurrentUser(data:any){ public createDmpForCurrentUser(data: any) {
return this.restBase.post("dmp/createofuser", data); return this.restBase.post("dmp/createofuser", data);
} }
public updateDmp(data:any){ public updateDmp(data: any) {
return this.restBase.post("dmp/update", data); return this.restBase.post("dmp/update", data);
} }
public cloneDmp(data: any){ public cloneDmp(data: any) {
return this.restBase.post("dmp/cloneforuser", data); return this.restBase.post("dmp/cloneforuser", data);
} }
public deleteDmp(dmp: any){ public deleteDmp(dmp: any) {
return this.restBase.post("dmp/softdelete", dmp); return this.restBase.post("dmp/softdelete", dmp);
} }
public getDatasetForDmp(data:any){ public getDatasetForDmp(data: any) {
return this.restBase.post("dmp/getdatasets", data); return this.restBase.post("dmp/getdatasets", data);
} }
public createDatasetForDmp(data:any){ public createDatasetForDmp(data: any) {
return this.restBase.post("dataset/create", data); return this.restBase.post("dataset/create", data);
} }
public getAllDatsetsProfile(){ public getAllDatsetsProfile() {
return this.restBase.get("datasetprofile/getAll"); return this.restBase.get("datasetprofile/getAll");
} }
public getDatasetProfileByID(id){ public getDatasetProfileByID(id) {
return this.restBase.get("datasetprofiles/"+id); return this.restBase.get("datasetprofiles/" + id);
} }
public updateDatsetsProfile(data:any){ public updateDatsetsProfile(data: any) {
return this.restBase.post("dataset/update", data); return this.restBase.post("dataset/update", data);
} }
public deleteDataset(dataset: any){ public deleteDataset(dataset: any) {
return this.restBase.post("dataset/softdelete", dataset); return this.restBase.post("dataset/softdelete", dataset);
} }
public getUserByID(id : string){ public getUserByID(id: string) {
return this.restBase.get("users/"+id); return this.restBase.get("users/" + id);
} }
public whoami(){ public whoami() {
return this.restBase.get("user/whoami"); return this.restBase.get("user/whoami");
} }
public updateDataset(id:string,properties:any){ public updateDataset(id: string, properties: any) {
return this.restBase.post("datasetprofile/save/"+id,properties); return this.restBase.post("datasetprofile/save/" + id, properties);
} }
public getSingleDataset(id){ public getSingleDataset(id) {
return this.restBase.get("datasetprofile/get/"+id); return this.restBase.get("datasetprofile/get/" + id);
} }
getThroughProxy(url : string, query: string){ getThroughProxy(url: string, query: string) {
return this.restBase.proxy_get_wQuery(url, query); return this.restBase.proxy_get_wQuery(url, query);
} }
public searchDatasetRegistry(like: string) {
return this.restBase.get("external/registries" + "?query=" + like);
}
public searchDatasetRepository(like: string) {
return this.restBase.get("external/datarepos" + "?query=" + like);
}
public searchDatasetService(like: string) {
return this.restBase.get("external/services" + "?query=" + like);
}
} }