1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\r
3 # Licensed under the Apache License, Version 2.0 (the "License"); #
\r
4 # you may not use this file except in compliance with the License. #
\r
5 # You may obtain a copy of the License at #
\r
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\r
9 # Unless required by applicable law or agreed to in writing, software #
\r
10 # distributed under the License is distributed on an "AS IS" BASIS, #
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
\r
12 # See the License for the specific language governing permissions and #
\r
13 # limitations under the License. #
\r
14 ##############################################################################*/
\r
17 import { Injectable } from '@angular/core';
\r
18 import { HttpClient } from '@angular/common/http';
\r
19 import { AppGlobals } from '../../app.global';
\r
20 import { Observable } from 'rxjs';
\r
21 import { ParamsService } from './params.service';
\r
22 import { CookieService } from 'ngx-cookie-service';
\r
23 import { ModelService } from './model.service';
\r
24 import { FeathersService } from './feathers.service';
\r
25 import { GroupService } from './group.service';
\r
33 export class TestDefinitionService extends ModelService {
\r
35 constructor(http: HttpClient, Params: ParamsService, cookie: CookieService, feathers: FeathersService, private _groups: GroupService) {
\r
36 super('test-definitions', http, Params, cookie, feathers);
\r
40 create(data, params?): Observable<Object>{
\r
41 this.setGroup(data);
\r
42 return super.create(data, params);
\r
45 validate(testDefinition): Observable<Object> {
\r
46 return this.call('create', {data: { testDefinition: testDefinition } }, AppGlobals.baseAPIUrl + 'bpmn-validate')
\r
47 //return this.http.post(AppGlobals.baseAPIUrl + 'bpmn-validate', {testDefinition: testDefinition}, this.getHttpOptions());
\r
50 validateSave(testDefinition): Observable<Object> {
\r
51 return this.call('update', { data: {_id: null, testDefinition: testDefinition } }, AppGlobals.baseAPIUrl + 'bpmn-validate')
\r
52 //return this.http.put(AppGlobals.baseAPIUrl + 'bpmn-validate', {testDefinition: testDefinition}, this.getHttpOptions());
\r
55 check(processDefinitionKey): Observable<Object>{
\r
56 return this.call('get', {data: processDefinitionKey} , AppGlobals.baseAPIUrl + 'bpmn-validate')
\r
57 //return this.http.get(AppGlobals.baseAPIUrl + 'bpmn-validate/' + processDefinitionKey, this.getHttpOptions());
\r
60 deploy(testDefinition, versionName?): Observable<Object> {
\r
61 let data = {testDefinition: testDefinition};
\r
63 if(versionName != null && versionName != undefined){
\r
64 data['version'] = versionName;
\r
66 return this.call('create', {data: data }, AppGlobals.baseAPIUrl + 'bpmn-upload')
\r
67 //return this.http.post(AppGlobals.baseAPIUrl + 'bpmn-upload', {testDefinition: testDefinition}, this.getHttpOptions());
\r
71 // this.find({$limit: -1}).subscribe(definitions => {
\r
72 // //definitions = definitions['data'];
\r
73 // (definitions as Array<Object>).forEach((elem, val) => {
\r
74 // elem['bpmnInstances'].forEach((e , v) => {
\r
76 // this.deploy(elem, el.version).subscribe(res => {
\r
77 // console.log(res);
\r
84 private setGroup(data){
\r
85 if(!data['groupId']){
\r
86 data['groupId'] = this._groups.getGroup()['_id'];
\r