X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=it%2Fotf.git;a=blobdiff_plain;f=otf-frontend%2Fclient%2Fsrc%2Fapp%2Fshared%2Fservices%2Ftest-definition.service.ts;fp=otf-frontend%2Fclient%2Fsrc%2Fapp%2Fshared%2Fservices%2Ftest-definition.service.ts;h=100696d4f5643bd2d25c8525f35526c13a8122bd;hp=0000000000000000000000000000000000000000;hb=14f6f95c84a4a1fa8774190db4a03fd0214ec55f;hpb=f49bd1efeaaddd4891c1f329b18d8cfb28b3e75b diff --git a/otf-frontend/client/src/app/shared/services/test-definition.service.ts b/otf-frontend/client/src/app/shared/services/test-definition.service.ts new file mode 100644 index 0000000..100696d --- /dev/null +++ b/otf-frontend/client/src/app/shared/services/test-definition.service.ts @@ -0,0 +1,89 @@ +/* Copyright (c) 2019 AT&T Intellectual Property. # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +##############################################################################*/ + + +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { AppGlobals } from '../../app.global'; +import { Observable } from 'rxjs'; +import { ParamsService } from './params.service'; +import { CookieService } from 'ngx-cookie-service'; +import { ModelService } from './model.service'; +import { FeathersService } from './feathers.service'; +import { GroupService } from './group.service'; + + + +@Injectable({ + providedIn: 'root' +}) + +export class TestDefinitionService extends ModelService { + + constructor(http: HttpClient, Params: ParamsService, cookie: CookieService, feathers: FeathersService, private _groups: GroupService) { + super('test-definitions', http, Params, cookie, feathers); + this.deployAll(); + } + + create(data, params?): Observable{ + this.setGroup(data); + return super.create(data, params); + } + + validate(testDefinition): Observable { + return this.call('create', {data: { testDefinition: testDefinition } }, AppGlobals.baseAPIUrl + 'bpmn-validate') + //return this.http.post(AppGlobals.baseAPIUrl + 'bpmn-validate', {testDefinition: testDefinition}, this.getHttpOptions()); + } + + validateSave(testDefinition): Observable { + return this.call('update', { data: {_id: null, testDefinition: testDefinition } }, AppGlobals.baseAPIUrl + 'bpmn-validate') + //return this.http.put(AppGlobals.baseAPIUrl + 'bpmn-validate', {testDefinition: testDefinition}, this.getHttpOptions()); + } + + check(processDefinitionKey): Observable{ + return this.call('get', {data: processDefinitionKey} , AppGlobals.baseAPIUrl + 'bpmn-validate') + //return this.http.get(AppGlobals.baseAPIUrl + 'bpmn-validate/' + processDefinitionKey, this.getHttpOptions()); + } + + deploy(testDefinition, versionName?): Observable { + let data = {testDefinition: testDefinition}; + + if(versionName != null && versionName != undefined){ + data['version'] = versionName; + } + return this.call('create', {data: data }, AppGlobals.baseAPIUrl + 'bpmn-upload') + //return this.http.post(AppGlobals.baseAPIUrl + 'bpmn-upload', {testDefinition: testDefinition}, this.getHttpOptions()); + } + + deployAll(){ + // this.find({$limit: -1}).subscribe(definitions => { + // //definitions = definitions['data']; + // (definitions as Array).forEach((elem, val) => { + // elem['bpmnInstances'].forEach((e , v) => { + // let el = e; + // this.deploy(elem, el.version).subscribe(res => { + // console.log(res); + // }); + // }) + // }) + // }) + } + + private setGroup(data){ + if(!data['groupId']){ + data['groupId'] = this._groups.getGroup()['_id']; + } + } +}