aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-ui/src/app/services
diff options
context:
space:
mode:
Diffstat (limited to 'sdc-workflow-designer-ui/src/app/services')
-rw-r--r--sdc-workflow-designer-ui/src/app/services/auth.service.spec.ts26
-rw-r--r--sdc-workflow-designer-ui/src/app/services/auth.service.ts65
-rw-r--r--sdc-workflow-designer-ui/src/app/services/broadcast.service.ts52
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data/backend.service.ts100
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data/data.service.ts79
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data/in-memory-data.service.ts71
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data/mockdata.ts4
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data/sdc.service.ts86
-rw-r--r--sdc-workflow-designer-ui/src/app/services/display-info.service.ts27
-rw-r--r--sdc-workflow-designer-ui/src/app/services/interface.service.spec.ts26
-rw-r--r--sdc-workflow-designer-ui/src/app/services/interface.service.ts47
-rw-r--r--sdc-workflow-designer-ui/src/app/services/jsplumb.service.ts66
-rw-r--r--sdc-workflow-designer-ui/src/app/services/model.service.ts246
-rw-r--r--sdc-workflow-designer-ui/src/app/services/node-type.service.ts68
-rw-r--r--sdc-workflow-designer-ui/src/app/services/rest.service.ts341
-rw-r--r--sdc-workflow-designer-ui/src/app/services/setting.service.spec.ts11
-rw-r--r--sdc-workflow-designer-ui/src/app/services/setting.service.ts16
-rw-r--r--sdc-workflow-designer-ui/src/app/services/swagger-tree-converter.service.ts39
-rw-r--r--sdc-workflow-designer-ui/src/app/services/tosca.service.spec.ts26
-rw-r--r--sdc-workflow-designer-ui/src/app/services/tosca.service.ts153
-rw-r--r--sdc-workflow-designer-ui/src/app/services/workflow.service.ts79
21 files changed, 878 insertions, 750 deletions
diff --git a/sdc-workflow-designer-ui/src/app/services/auth.service.spec.ts b/sdc-workflow-designer-ui/src/app/services/auth.service.spec.ts
new file mode 100644
index 00000000..9bd500ef
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/services/auth.service.spec.ts
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+import { TestBed, inject } from '@angular/core/testing';
+
+import { AuthService } from './auth.service';
+
+describe('AuthService', () => {
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [AuthService]
+ });
+ });
+
+ it('should be created', inject([AuthService], (service: AuthService) => {
+ expect(service).toBeTruthy();
+ }));
+});
diff --git a/sdc-workflow-designer-ui/src/app/services/auth.service.ts b/sdc-workflow-designer-ui/src/app/services/auth.service.ts
new file mode 100644
index 00000000..a8e60753
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/services/auth.service.ts
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+import { Injectable } from '@angular/core';
+import { Http } from '@angular/http';
+import { BroadcastService } from './broadcast.service';
+
+@Injectable()
+export class AuthService {
+ private static AuthUrl = "/api/oauth2/v1/perms/user/operations";
+ private static AllOperations = ["operation.apds.create", "operation.apds.delete", "operation.apds.modify",
+ "operation.apds.view", "operation.apds.import", "operation.apds.export", "operation.apds.deploy",
+ "operation.apds.test"];
+ private static ModifyOperation = 'operation.apds.modify';
+
+ constructor(private http: Http, private broadcastService: BroadcastService) {
+ this.checkRights();
+ // keep alive
+ // setInterval(() => {
+ // console.log(`Keep session alive. Request per 3 minutes. ${new Date()}`);
+ // this.checkRights();
+ // }, 180000);
+ }
+ public checkRights() {
+ // let data = { operations: AuthService.AllOperations };
+ // this.http.post(AuthService.AuthUrl, data).subscribe(res => {
+ // let hasRightOP = res.json().operations;
+ // if (hasRightOP.length > 0) {
+ // this.broadcastService.broadcast(this.broadcastService.openRight, true);
+ // if (hasRightOP.indexOf(AuthService.ModifyOperation) > -1) {
+ // this.broadcastService.broadcast(this.broadcastService.saveRight, true);
+ // } else {
+ // this.broadcastService.broadcast(this.broadcastService.saveRight, false);
+ // }
+ // } else {
+ // this.broadcastService.broadcast(this.broadcastService.openRight, false);
+ // this.broadcastService.broadcast(this.broadcastService.saveRight, false);
+ // }
+ // }, error => {
+ // switch (error.status) {
+ // // Incase oauth service not exists or operation set not exists
+ // case 404:
+ // case 501:
+ // case 502:
+ // this.broadcastService.broadcast(this.broadcastService.openRight, true);
+ // this.broadcastService.broadcast(this.broadcastService.saveRight, true);
+ // break;
+ // default:
+ // this.broadcastService.broadcast(this.broadcastService.openRight, false);
+ // this.broadcastService.broadcast(this.broadcastService.saveRight, false);
+ // break;
+ // }
+ // });
+ this.broadcastService.broadcast(this.broadcastService.openRight, true);
+ this.broadcastService.broadcast(this.broadcastService.saveRight, true);
+ }
+}
diff --git a/sdc-workflow-designer-ui/src/app/services/broadcast.service.ts b/sdc-workflow-designer-ui/src/app/services/broadcast.service.ts
index 6d80e91e..410ae9b0 100644
--- a/sdc-workflow-designer-ui/src/app/services/broadcast.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/broadcast.service.ts
@@ -26,56 +26,38 @@ import { WorkflowElement } from '../model/workflow/workflow-element';
*/
@Injectable()
export class BroadcastService {
+ public openRight = new Subject<boolean>();
+ public openRight$ = this.openRight.asObservable();
- public showProperty = new Subject<WorkflowElement>();
- public showProperty$ = this.showProperty.asObservable();
+ public saveRight = new Subject<boolean>();
+ public saveRight$ = this.saveRight.asObservable();
- public workflows = new Subject<Map<string, any>>();
- public workflows$ = this.workflows.asObservable();
+ public initModel = new Subject<PlanModel>();
+ public initModel$ = this.initModel.asObservable();
- public planId = new Subject<string>();
- public planId$ = this.planId.asObservable();
+ public showProperty = new Subject<WorkflowElement>();
+ public showProperty$ = this.showProperty.asObservable();
public planModel = new Subject<PlanModel>();
public planModel$ = this.planModel.asObservable();
+ public updateModelToscaConfig = new Subject<any[]>();
+ public updateModelToscaConfig$ = this.updateModelToscaConfig.asObservable();
+
public updateModelRestConfig = new Subject<RestConfig[]>();
public updateModelRestConfig$ = this.updateModelRestConfig.asObservable();
- public saveEvent = new Subject<any>();
+ public updateNodeTypeConfig = new Subject<any[]>();
+ public updateNodeTypeConfig$ = this.updateNodeTypeConfig.asObservable();
+
+ public saveEvent = new Subject<PlanModel>();
public saveEvent$ = this.saveEvent.asObservable();
public selectedElement = new Subject<WorkflowElement[]>();
public selectedElement$ = this.selectedElement.asObservable();
- // public elementClick = new Subject<WorkflowElement>();
- // public elementClick$ = this.elementClick.asObservable();
- /**
- * this should be used while the source of rest interfaces changed.
- * @type {Subject<>}
- */
- public backendServiceReady = new Subject<any>();
- public backendServiceReady$ = this.backendServiceReady.asObservable();
-
-
- public nodeProperty = new Subject<WorkflowNode>();
- public nodeProperty$ = this.nodeProperty.asObservable();
-
- public nodeTaskChange = new Subject<WorkflowNode>();
- public nodeTaskChange$ = this.nodeTaskChange.asObservable();
-
- public showSequenceFlow = new Subject<boolean>();
- public showSequenceFlow$ = this.showSequenceFlow.asObservable();
-
- public sequenceFlow = new Subject<SequenceFlow>();
- public sequenceFlow$ = this.sequenceFlow.asObservable();
-
- public currentSequenceFlow = new Subject<SequenceFlow>();
- public currentSequenceFlow$ = this.currentSequenceFlow.asObservable();
- public currentWorkflowNode = new Subject<WorkflowNode>();
- public currentWorkflowNode$ = this.currentWorkflowNode.asObservable();
- public currentType = new Subject<string>();
- public currentType$ = this.currentType.asObservable();
+ public swagger = new Subject<any>();
+ public swagger$ = this.swagger.asObservable();
/**
* broadcast datas
diff --git a/sdc-workflow-designer-ui/src/app/services/data/backend.service.ts b/sdc-workflow-designer-ui/src/app/services/data/backend.service.ts
deleted file mode 100644
index 41f6fccd..00000000
--- a/sdc-workflow-designer-ui/src/app/services/data/backend.service.ts
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * Copyright (c) 2017 ZTE Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * ZTE - initial API and implementation and/or initial documentation
- */
-
-import { Injectable } from '@angular/core';
-import { Observable } from 'rxjs/Observable';
-import { TranslateService } from '@ngx-translate/core';
-
-import { PlanModel } from '../../model/plan-model';
-import { NodeTemplate } from '../../model/topology/node-template';
-import { HttpService } from '../../util/http.service';
-import { BroadcastService } from '../broadcast.service';
-import { NoticeService } from '../notice.service';
-
-/**
- * BackendService
- * provides backend data accessor to load and save data.
- */
-@Injectable()
-export abstract class BackendService {
- private topologyProperties: { name: string, value: string }[] = [];
-
- constructor(protected broadcastService: BroadcastService, protected noticeService: NoticeService,
- protected httpService: HttpService, private translate: TranslateService) {
- this.broadcastService.saveEvent$.subscribe(data => {
- this.save(data).subscribe(response => {
- this.translate.get('WORKFLOW.MSG.SAVE_SUCCESS').subscribe((res: string) => {
- this.noticeService.success(res);
- });
- }, error => {
- this.noticeService.error(error);
- });
- });
- }
-
- public abstract loadPlans(): Observable<Map<number, any>>;
-
- public abstract getBackendType(): string;
-
- public abstract setParameters(params: any);
-
- public abstract loadNodeTemplates(): Observable<NodeTemplate[]>;
-
- public abstract loadTopologyProperties(nodeTemplate: NodeTemplate): Observable<string[]>;
-
- public abstract loadNodeTemplateInterfaces(nodeTemplate: NodeTemplate): Observable<string[]>;
-
- public abstract loadNodeTemplateOperations(nodeTemplate: NodeTemplate,
- interfaceName: string): Observable<string[]>;
-
- public abstract loadNodeTemplateOperationParameter(nodeTemplate: NodeTemplate,
- interfaceName: string,
- operation: string): Observable<any>;
-
- public abstract save(data: any): Observable<any>;
-
- public abstract loadPlan(): Observable<PlanModel>;
-
- public getTopologyProperties(): { name: string, value: string }[] {
- return this.topologyProperties;
- }
-
- public canEdit(): boolean {
- return true;
- }
-
- protected refreshTopologyProperties(): void {
- this.loadNodeTemplates().subscribe(nodes => {
- if (0 === nodes.length) {
- return;
- }
-
- const subscribes = nodes.map(node => this.loadTopologyProperties(node));
- Observable.forkJoin(subscribes).map(nodesProperties => {
- const allProperties: { name: string, value: string }[] = [];
- nodesProperties.forEach((properties, index) => {
- properties.forEach(property => {
- // allProperties.push(nodes[index].name + '.' + property);
- const propertyOption = {
- name: `${nodes[index].name}.${property}`,
- value: `[${nodes[index].name}].[${property}]`
- };
- allProperties.push(propertyOption);
- });
- });
- return allProperties;
- }).subscribe(allProperties => {
- this.topologyProperties = allProperties;
- });
- });
- }
-}
diff --git a/sdc-workflow-designer-ui/src/app/services/data/data.service.ts b/sdc-workflow-designer-ui/src/app/services/data/data.service.ts
deleted file mode 100644
index 73be01b7..00000000
--- a/sdc-workflow-designer-ui/src/app/services/data/data.service.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Copyright (c) 2017 ZTE Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * ZTE - initial API and implementation and/or initial documentation
- */
-
-import { Injectable } from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
-import { Observable } from 'rxjs/Observable';
-import { TranslateService } from '@ngx-translate/core';
-
-import { PlanModel } from '../../model/plan-model';
-import { NodeTemplate } from '../../model/topology/node-template';
-import { HttpService } from '../../util/http.service';
-import { BroadcastService } from '../broadcast.service';
-import { SettingService } from "../setting.service";
-import { NoticeService } from '../notice.service';
-import { BackendService } from './backend.service';
-import { SdcService } from './sdc.service';
-
-/**
- * DataService
- * BackendService factory, provide backend service by running environment.
- */
-@Injectable()
-export class DataService {
- private service: BackendService;
-
- constructor(private broadcastService: BroadcastService, private noticeService: NoticeService,
- protected httpService: HttpService, private translate: TranslateService,
- private settingService: SettingService, private activatedRoute: ActivatedRoute) {
- this.createBackendService();
- }
-
- public initData(): void {
- this.activatedRoute.queryParams.subscribe(queryParams => {
- this.service.setParameters(queryParams);
- });
- }
-
- public getTopologyProperties(): { name: string, value: string }[] {
- return this.service.getTopologyProperties();
- }
-
- public loadNodeTemplates(): Observable<NodeTemplate[]> {
- return this.service.loadNodeTemplates();
- }
-
- public loadNodeTemplateInterfaces(nodeTemplate: NodeTemplate): Observable<string[]> {
- return this.service.loadNodeTemplateInterfaces(nodeTemplate);
- }
-
- public loadNodeTemplateOperations(nodeTemplate: NodeTemplate, interfaceName: string): Observable<string[]> {
- return this.service.loadNodeTemplateOperations(nodeTemplate, interfaceName);
- }
-
- public loadNodeTemplateOperationParameter(nodeTemplate: NodeTemplate, interfaceName: string,
- operation: string): Observable<any> {
- return this.service.loadNodeTemplateOperationParameter(nodeTemplate, interfaceName, operation);
- }
-
- public getBackendType(): string {
- return this.service.getBackendType();
- }
-
- private createBackendService() {
- this.settingService.getSetting().subscribe(response => {
- let serviceType = response.BackendType;
- this.service = new SdcService(this.broadcastService, this.noticeService, this.httpService, this.translate);
- this.broadcastService.broadcast(this.broadcastService.backendServiceReady, null);
- })
- }
-}
diff --git a/sdc-workflow-designer-ui/src/app/services/data/in-memory-data.service.ts b/sdc-workflow-designer-ui/src/app/services/data/in-memory-data.service.ts
deleted file mode 100644
index a7449185..00000000
--- a/sdc-workflow-designer-ui/src/app/services/data/in-memory-data.service.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Copyright (c) 2017 ZTE Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * ZTE - initial API and implementation and/or initial documentation
- */
-
-import { Injectable } from '@angular/core';
-import { InMemoryDbService } from 'angular-in-memory-web-api';
-import { workflowFJH } from "./mockdata";
-import { PlanModel } from '../../model/plan-model';
-/**
- * InMemeoryDataService
- * Mock backend data
- */
-export class InMemoryDataService implements InMemoryDbService {
- createDb() {
-
- const swagger = {"swagger":"2.0","info":{"version":"1.0.0","title":"MicroService Bus rest API"},"basePath":"/api/microservices/v1","tags":[{"name":"metrics"},{"name":"iuiRoute"},{"name":"ServiceAccess"},{"name":"ApiRoute"},{"name":"MSB-Service Resource"},{"name":"CustomRoute"}],"paths":{"/apiRoute":{"get":{"tags":["ApiRoute"],"summary":"get all ApiRoute ","description":"","operationId":"getApiRoutes","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"array","items":{"$ref":"#/definitions/ApiRouteInfo"}}},"500":{"description":"get ApiRouteInfo List fail","schema":{"type":"string"}}}},"post":{"tags":["ApiRoute"],"summary":"add one ApiRoute ","description":"","operationId":"addApiRoute","produces":["application/json"],"parameters":[{"in":"body","name":"body","description":"ApiRoute Instance Info","required":true,"schema":{"$ref":"#/definitions/ApiRouteInfo"}}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/ApiRouteInfo"}},"400":{"description":"Unprocessable ApiRouteInfo JSON REQUEST","schema":{"type":"string"}},"500":{"description":"add ApiRouteInfo fail","schema":{"type":"string"}},"415":{"description":"Unprocessable ApiRouteInfo Entity ","schema":{"type":"string"}}}}},"/apiRoute/apiDocs":{"get":{"tags":["ApiRoute"],"summary":"get all Local apiDoc ","description":"","operationId":"getApiDocs","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"array","items":{"type":"string"}}},"500":{"description":"get apiDoc List fail","schema":{"type":"string"}}}}},"/apiRoute/apiGatewayPort":{"get":{"tags":["ApiRoute"],"summary":"get apiGateway Port ","description":"","operationId":"getApiGatewayPort","produces":["text/plain"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"string"}},"500":{"description":"get apiGateway Port fail","schema":{"type":"string"}}}}},"/apiRoute/discoverInfo":{"get":{"tags":["ApiRoute"],"summary":"get discover Info ","description":"","operationId":"getServiceDiscoverInfo","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/DiscoverInfo"}},"500":{"description":"get discover Info fail","schema":{"type":"string"}}}}},"/apiRoute/export":{"get":{"tags":["ApiRoute"],"summary":"export all route service Info by json-file","description":"","operationId":"exportService","produces":["text/plain"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"string"}},"500":{"description":"export fail","schema":{"type":"string"}},"406":{"description":" not Acceptable client-side","schema":{"type":"string"}}}}},"/apiRoute/{serviceName}/version/{version}":{"get":{"tags":["ApiRoute"],"summary":"get one ApiRoute ","description":"","operationId":"getApiRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"ApiRoute serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"ApiRoute version,if the version is empty, please enter \"null\"","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/ApiRouteInfo"}},"500":{"description":"get ApiRouteInfo fail","schema":{"type":"string"}},"404":{"description":"ApiRouteInfo not found","schema":{"type":"string"}},"415":{"description":"Unprocessable ApiRouteInfo Entity ","schema":{"type":"string"}}}},"put":{"tags":["ApiRoute"],"summary":"update one ApiRoute by serviceName and version","description":"","operationId":"updateApiRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"ApiRoute serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"ApiRoute version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"in":"body","name":"body","description":"ApiRoute Instance Info","required":true,"schema":{"$ref":"#/definitions/ApiRouteInfo"}}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/ApiRouteInfo"}},"400":{"description":"Unprocessable ApiRouteInfo JSON REQUEST","schema":{"type":"string"}},"500":{"description":"update ApiRouteInfo fail","schema":{"type":"string"}},"415":{"description":"Unprocessable ApiRouteInfo Entity ","schema":{"type":"string"}}}},"delete":{"tags":["ApiRoute"],"summary":"delete one ApiRoute by serviceName and version","description":"","operationId":"deleteApiRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"ApiRoute serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"ApiRoute version,if the version is empty, please enter \"null\"","required":true,"type":"string"}],"responses":{"500":{"description":"delete ApiRouteInfo fail","schema":{"type":"string"}},"204":{"description":"delete ApiRouteInfo succeed "},"404":{"description":"ApiRouteInfo not found","schema":{"type":"string"}}}}},"/apiRoute/{serviceName}/version/{version}/status/{status}":{"put":{"tags":["ApiRoute"],"summary":"update one ApiRoute status by serviceName and version","description":"","operationId":"updateApiRouteStatus","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"ApiRoute serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"ApiRoute version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"name":"status","in":"path","description":"ApiRoute status,1:abled 0:disabled","required":true,"type":"string"}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/ApiRouteInfo"}},"500":{"description":"update status fail","schema":{"type":"string"}},"415":{"description":"Unprocessable ApiRouteInfo Entity ","schema":{"type":"string"}},"404":{"description":"ApiRouteInfo not found","schema":{"type":"string"}}}}},"/customRoute/all":{"get":{"tags":["CustomRoute"],"summary":"get all CustomRoute ","description":"","operationId":"getCustomRoutes","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"array","items":{"$ref":"#/definitions/CustomRouteInfo"}}},"500":{"description":"get CustomRouteInfo List fail","schema":{"type":"string"}}}}},"/customRoute/instance":{"get":{"tags":["CustomRoute"],"summary":"get one CustomRoute ","description":"","operationId":"getCustomRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"query","description":"CustomRoute serviceName","required":false,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/CustomRouteInfo"}},"500":{"description":"get CustomRoute fail","schema":{"type":"string"}},"404":{"description":"CustomRoute not found","schema":{"type":"string"}},"415":{"description":"Unprocessable CustomRoute Entity ","schema":{"type":"string"}}}},"post":{"tags":["CustomRoute"],"summary":"add one CustomRoute ","description":"","operationId":"addCustomRoute","produces":["application/json"],"parameters":[{"in":"body","name":"body","description":"CustomRoute Instance Info","required":true,"schema":{"$ref":"#/definitions/CustomRouteInfo"}}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/CustomRouteInfo"}},"400":{"description":"Unprocessable CustomRouteInfo JSON REQUEST","schema":{"type":"string"}},"500":{"description":"add CustomRouteInfo fail","schema":{"type":"string"}},"415":{"description":"Unprocessable CustomRouteInfo Entity ","schema":{"type":"string"}}}},"put":{"tags":["CustomRoute"],"summary":"update one CustomRoute by serviceName","description":"","operationId":"updateCustomRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"query","description":"CustomRoute serviceName","required":true,"type":"string"},{"in":"body","name":"body","description":"CustomRoute Instance Info","required":true,"schema":{"$ref":"#/definitions/CustomRouteInfo"}}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/CustomRouteInfo"}},"400":{"description":"Unprocessable CustomRoute JSON REQUEST","schema":{"type":"string"}},"500":{"description":"update CustomRoute fail","schema":{"type":"string"}},"415":{"description":"Unprocessable CustomRoute Entity ","schema":{"type":"string"}}}},"delete":{"tags":["CustomRoute"],"summary":"delete one CustomRoute by serviceName","description":"","operationId":"deleteCustomRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"query","description":"CustomRoute serviceName","required":true,"type":"string"}],"responses":{"500":{"description":"delete customRoute fail","schema":{"type":"string"}},"204":{"description":"delete customRoute succeed "},"404":{"description":"customRoute not found","schema":{"type":"string"}}}}},"/customRoute/status":{"put":{"tags":["CustomRoute"],"summary":"update one CustomRoute status by serviceName ","description":"","operationId":"updateCustomRouteStatus","produces":["application/json"],"parameters":[{"name":"serviceName","in":"query","description":"CustomRoute serviceName","required":true,"type":"string"},{"name":"status","in":"query","description":"CustomRoute status,1:abled 0:disabled","required":true,"type":"string"}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/CustomRouteInfo"}},"500":{"description":"update status fail","schema":{"type":"string"}},"415":{"description":"Unprocessable customRoute Entity ","schema":{"type":"string"}},"404":{"description":"customRoute not found","schema":{"type":"string"}}}}},"/iuiRoute":{"get":{"tags":["iuiRoute"],"summary":"get all iuiRoute ","description":"","operationId":"getIuiRoutes","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"array","items":{"$ref":"#/definitions/IuiRouteInfo"}}},"500":{"description":"get iuiRouteInfo List fail","schema":{"type":"string"}}}},"post":{"tags":["iuiRoute"],"summary":"add one iuiRoute ","description":"","operationId":"addIuiRoute","produces":["application/json"],"parameters":[{"in":"body","name":"body","description":"iuiRoute Instance Info","required":true,"schema":{"$ref":"#/definitions/IuiRouteInfo"}}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/IuiRouteInfo"}},"400":{"description":"Unprocessable iuiRouteInfo JSON REQUEST","schema":{"type":"string"}},"500":{"description":"add iuiRouteInfo fail","schema":{"type":"string"}},"415":{"description":"Unprocessable iuiRouteInfo Entity ","schema":{"type":"string"}}}}},"/iuiRoute/{serviceName}":{"get":{"tags":["iuiRoute"],"summary":"get one iuiRoute ","description":"","operationId":"getIuiRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"iuiRoute serviceName","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/IuiRouteInfo"}},"500":{"description":"get IuiRouteInfo fail","schema":{"type":"string"}},"404":{"description":"IuiRouteInfo not found","schema":{"type":"string"}},"415":{"description":"Unprocessable IuiRouteInfo Entity ","schema":{"type":"string"}}}},"put":{"tags":["iuiRoute"],"summary":"update one iuiRoute by serviceName","description":"","operationId":"updateIuiRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"iuiRoute serviceName","required":true,"type":"string"},{"in":"body","name":"body","description":"iuiRoute Instance Info","required":true,"schema":{"$ref":"#/definitions/IuiRouteInfo"}}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/IuiRouteInfo"}},"400":{"description":"Unprocessable IuiRouteInfo JSON REQUEST","schema":{"type":"string"}},"500":{"description":"update IuiRouteInfo fail","schema":{"type":"string"}},"415":{"description":"Unprocessable IuiRouteInfo Entity ","schema":{"type":"string"}}}},"delete":{"tags":["iuiRoute"],"summary":"delete one iuiRoute by serviceName","description":"","operationId":"deleteIuiRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"iuiRoute serviceName","required":true,"type":"string"}],"responses":{"500":{"description":"delete IuiRouteInfo fail","schema":{"type":"string"}},"204":{"description":"delete IuiRouteInfo succeed "},"404":{"description":"IuiRouteInfo not found","schema":{"type":"string"}}}}},"/iuiRoute/{serviceName}/status/{status}":{"put":{"tags":["iuiRoute"],"summary":"update one iuiRoute status by serviceName ","description":"","operationId":"updateIuiRouteStatus","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"iuiRoute serviceName","required":true,"type":"string"},{"name":"status","in":"path","description":"iuiRoute status,1:abled 0:disabled","required":true,"type":"string"}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/IuiRouteInfo"}},"500":{"description":"update IuiRouteInfo status fail","schema":{"type":"string"}},"415":{"description":"Unprocessable IuiRouteInfo Entity ","schema":{"type":"string"}},"404":{"description":"IuiRouteInfo not found","schema":{"type":"string"}}}}},"/metrics":{"get":{"tags":["metrics"],"summary":"get Metrics Info ","description":"","operationId":"getMetricsInfo","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/MetricsInfo"}}}}},"/serviceaccess/{serviceName}":{"get":{"tags":["ServiceAccess"],"summary":"get the msb access address of the service ","description":"","operationId":"getApiRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"serviceName","required":true,"type":"string"},{"name":"type","in":"query","description":"service type","required":false,"type":"string","enum":["api","iui","custom","p2p"]},{"name":"version","in":"query","description":"version","required":false,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/ServiceAccessInfo"}},"500":{"description":"get access address error "}}}},"/services":{"get":{"tags":["MSB-Service Resource"],"summary":"get all microservices ","description":"","operationId":"getMicroService","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"array","items":{"$ref":"#/definitions/MicroServiceFullInfo"}}},"500":{"description":"get microservice List fail","schema":{"type":"string"}}}},"post":{"tags":["MSB-Service Resource"],"summary":"add one microservice ","description":"","operationId":"addMicroService","produces":["application/json"],"parameters":[{"in":"body","name":"body","description":"MicroServiceInfo Instance Info","required":true,"schema":{"$ref":"#/definitions/MicroServiceInfo"}},{"name":"createOrUpdate","in":"query","description":"createOrUpdate","required":false,"type":"boolean","default":"true"},{"name":"port","in":"query","description":"port","required":false,"type":"string"}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/MicroServiceFullInfo"}},"400":{"description":"Unprocessable MicroServiceInfo JSON REQUEST","schema":{"type":"string"}},"500":{"description":"add microservice fail","schema":{"type":"string"}},"415":{"description":"Unprocessable MicroServiceInfo Entity ","schema":{"type":"string"}}}}},"/services/{serviceName}/version/{version}":{"get":{"tags":["MSB-Service Resource"],"summary":"get one microservice ","description":"","operationId":"getMicroService","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"microservice serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"microservice version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"name":"port","in":"query","description":"port","required":false,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/MicroServiceFullInfo"}},"500":{"description":"get microservice fail","schema":{"type":"string"}},"404":{"description":"microservice not found","schema":{"type":"string"}},"415":{"description":"Unprocessable MicroServiceInfo Entity ","schema":{"type":"string"}}}},"put":{"tags":["MSB-Service Resource"],"summary":"update one microservice by serviceName and version","description":"","operationId":"updateMicroService","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"microservice serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"microservice version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"in":"body","name":"body","description":"microservice Instance Info","required":true,"schema":{"$ref":"#/definitions/MicroServiceInfo"}}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/MicroServiceFullInfo"}},"400":{"description":"Unprocessable MicroServiceInfo JSON REQUEST","schema":{"type":"string"}},"500":{"description":"update microservice fail","schema":{"type":"string"}},"415":{"description":"Unprocessable MicroServiceInfo Entity ","schema":{"type":"string"}}}},"delete":{"tags":["MSB-Service Resource"],"summary":"delete one full microservice by serviceName and version","description":"","operationId":"deleteMicroService","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"microservice serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"microservice version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"name":"port","in":"query","description":"port","required":false,"type":"string"}],"responses":{"500":{"description":"delete microservice fail","schema":{"type":"string"}},"204":{"description":"delete microservice succeed "},"404":{"description":"microservice not found","schema":{"type":"string"}},"415":{"description":"Unprocessable MicroServiceInfo Entity ","schema":{"type":"string"}}}}},"/services/{serviceName}/version/{version}/nodes/{ip}/{port}":{"put":{"tags":["MSB-Service Resource"],"summary":"update single node by serviceName and version and node","description":"","operationId":"updateNode","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"microservice serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"microservice version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"name":"ip","in":"path","description":"ip","required":true,"type":"string"},{"name":"port","in":"path","description":"port","required":true,"type":"string"},{"name":"ttl","in":"query","description":"ttl","required":false,"type":"integer","format":"int32"}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/MicroServiceFullInfo"}},"500":{"description":"update node fail","schema":{"type":"string"}},"415":{"description":"Unprocessable MicroServiceInfo Entity ","schema":{"type":"string"}},"404":{"description":"microservice not found","schema":{"type":"string"}}}},"delete":{"tags":["MSB-Service Resource"],"summary":"delete single node by serviceName and version and node","description":"","operationId":"deleteNode","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"microservice serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"microservice version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"name":"ip","in":"path","description":"ip","required":true,"type":"string"},{"name":"port","in":"path","description":"port","required":true,"type":"string"}],"responses":{"500":{"description":"delete node fail","schema":{"type":"string"}},"204":{"description":"delete node succeed "},"404":{"description":"node not found","schema":{"type":"string"}},"415":{"description":"Unprocessable MicroServiceInfo Entity ","schema":{"type":"string"}}}}},"/services/{serviceName}/version/{version}/status/{status}":{"put":{"tags":["MSB-Service Resource"],"summary":"update microservice status by serviceName and version","description":"","operationId":"updateServiceStatus","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"microservice serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"microservice version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"name":"status","in":"path","description":"status,1:abled 0:disabled","required":true,"type":"string"}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/MicroServiceFullInfo"}},"500":{"description":"update status fail","schema":{"type":"string"}},"415":{"description":"Unprocessable MicroServiceInfo Entity ","schema":{"type":"string"}},"404":{"description":"microservice not found","schema":{"type":"string"}}}}}},"definitions":{"JVMMetrics":{"type":"object","properties":{"value":{"type":"number","format":"double"}}},"DiscoverInfo":{"type":"object","properties":{"ip":{"type":"string"},"port":{"type":"integer","format":"int32"},"enabled":{"type":"boolean","default":false}}},"IuiRouteInfo":{"type":"object","required":["servers","serviceName","url"],"properties":{"serviceName":{"type":"string"},"url":{"type":"string","example":"/test","description":"Target Service URL,start with /"},"control":{"type":"string","example":"0","description":"[control Range] 0:default 1:readonly 2:hidden ","enum":["0","1","2"]},"status":{"type":"string","example":"1","description":"[status] 1:abled 0:disabled ","enum":["0","1"]},"visualRange":{"type":"string","example":"1","description":"[visual Range]interSystem:0,inSystem:1","enum":["0","1"]},"useOwnUpstream":{"type":"string","example":"0","description":"[LB Policy]non_ip_hash:0,ip_hash:1","enum":["0","1"]},"servers":{"type":"array","items":{"$ref":"#/definitions/RouteServer"}}}},"Node":{"type":"object","required":["ip","port"],"properties":{"ip":{"type":"string"},"port":{"type":"string"},"ttl":{"type":"integer","format":"int32"}}},"RouteServer":{"type":"object","required":["ip","port"],"properties":{"ip":{"type":"string"},"port":{"type":"string"},"weight":{"type":"integer","format":"int32"}}},"MicroServiceInfo":{"type":"object","required":["protocol","serviceName","url"],"properties":{"serviceName":{"type":"string"},"version":{"type":"string","example":"v1"},"url":{"type":"string","example":"/api/serviceName/v1","description":"Target Service URL,start with /"},"protocol":{"type":"string","example":"REST","description":"Service Protocol","enum":["REST","UI","MQ","FTP","SNMP","TCP","UDP"]},"visualRange":{"type":"string","example":"1","description":"[visual Range]interSystem:0,inSystem:1","enum":["0","1"]},"lb_policy":{"type":"string","example":"hash","description":"lb policy","enum":["round-robin","hash","least_conn"]},"namespace":{"type":"string"},"nodes":{"type":"array","uniqueItems":true,"items":{"$ref":"#/definitions/Node"}}}},"HttpMetrics":{"type":"object","properties":{"count":{"type":"integer","format":"int32"},"max":{"type":"number","format":"double"},"mean":{"type":"number","format":"double"},"min":{"type":"number","format":"double"},"p50":{"type":"number","format":"double"},"p75":{"type":"number","format":"double"},"p95":{"type":"number","format":"double"},"p98":{"type":"number","format":"double"},"p99":{"type":"number","format":"double"},"p999":{"type":"number","format":"double"},"stddev":{"type":"number","format":"double"},"m15_rate":{"type":"number","format":"double"},"m1_rate":{"type":"number","format":"double"},"m5_rate":{"type":"number","format":"double"},"mean_rate":{"type":"number","format":"double"},"duration_units":{"type":"string"},"rate_units":{"type":"string"}}},"ApiRouteInfo":{"type":"object","required":["servers","serviceName","url","version"],"properties":{"serviceName":{"type":"string"},"version":{"type":"string","example":"v1"},"url":{"type":"string","example":"/test","description":"Target Service URL,start with /"},"apiJson":{"type":"string"},"apiJsonType":{"type":"string","example":"1","description":"[apiJson Type] 0:local file 1: remote file","enum":["0","1"]},"metricsUrl":{"type":"string"},"control":{"type":"string","example":"0","description":"[control Range] 0:default 1:readonly 2:hidden ","enum":["0","1","2"]},"status":{"type":"string","example":"1","description":"[status] 1:abled 0:disabled ","enum":["0","1"]},"visualRange":{"type":"string","example":"1","description":"[visual Range]interSystem:0,inSystem:1","enum":["0","1"]},"useOwnUpstream":{"type":"string","example":"0","description":"[LB Policy]non_ip_hash:0,ip_hash:1","enum":["0","1"]},"servers":{"type":"array","items":{"$ref":"#/definitions/RouteServer"}}}},"Gauges":{"type":"object","properties":{"jvm.attribute.uptime":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.Eden-Space.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.PS-Eden-Space.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.Perm-Gen.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.PS-Perm-Gen.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.Survivor-Space.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.PS-Survivor-Space.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.Tenured-Gen.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.PS-Old-Gen.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.Code-Cache.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.heap.init":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.non-heap.init":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.heap.used":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.non-heap.used":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.heap.max":{"$ref":"#/definitions/JVMMetrics"},"jvm.threads.runnable.count":{"$ref":"#/definitions/JVMMetrics"},"jvm.threads.timed_waiting.count":{"$ref":"#/definitions/JVMMetrics"},"jvm.threads.waiting.count":{"$ref":"#/definitions/JVMMetrics"},"jvm.threads.blocked.count":{"$ref":"#/definitions/JVMMetrics"},"jvm.threads.count":{"$ref":"#/definitions/JVMMetrics"}}},"MetricsInfo":{"type":"object","properties":{"gauges":{"$ref":"#/definitions/Gauges"},"timers":{"$ref":"#/definitions/Timers"}}},"ServiceAccessInfo":{"type":"object","properties":{"serviceType":{"type":"string"},"serviceName":{"type":"string"},"version":{"type":"string"},"accessAddr":{"type":"string"}}},"MicroServiceFullInfo":{"type":"object","required":["protocol","serviceName","url"],"properties":{"serviceName":{"type":"string"},"version":{"type":"string","example":"v1"},"url":{"type":"string","example":"/api/serviceName/v1","description":"Target Service URL,start with /"},"protocol":{"type":"string","example":"REST","description":"Service Protocol","enum":["REST","UI","MQ","FTP","SNMP","TCP","UDP"]},"visualRange":{"type":"string","example":"1","description":"[visual Range]interSystem:0,inSystem:1","enum":["0","1"]},"lb_policy":{"type":"string","example":"hash","description":"lb policy","enum":["round-robin","hash","least_conn"]},"namespace":{"type":"string"},"nodes":{"type":"array","uniqueItems":true,"items":{"$ref":"#/definitions/NodeInfo"}},"status":{"type":"string"}}},"NodeInfo":{"type":"object","required":["ip","port"],"properties":{"ip":{"type":"string"},"port":{"type":"string"},"ttl":{"type":"integer","format":"int32"},"nodeId":{"type":"string"},"expiration":{"type":"string","format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"CustomRouteInfo":{"type":"object","required":["servers","serviceName","url"],"properties":{"serviceName":{"type":"string"},"url":{"type":"string","example":"/test","description":"Target Service URL,start with /"},"control":{"type":"string","example":"0","description":"[control Range] 0:default 1:readonly 2:hidden ","enum":["0","1","2"]},"status":{"type":"string","example":"1","description":"[status] 1:abled 0:disabled ","enum":["0","1"]},"visualRange":{"type":"string","example":"1","description":"[visual Range]interSystem:0,inSystem:1","enum":["0","1"]},"useOwnUpstream":{"type":"string","example":"0","description":"[LB Policy]non_ip_hash:0,ip_hash:1","enum":["0","1"]},"servers":{"type":"array","items":{"$ref":"#/definitions/RouteServer"}}}},"Timers":{"type":"object","properties":{"org.openo.msb.resources.ApiRouteResource.addApiRoute":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.ApiRouteResource.deleteApiRoute":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.ApiRouteResource.getApiDocs":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.ApiRouteResource.getApiRoute":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.ApiRouteResource.getApiRoutes":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.ApiRouteResource.getServerIP":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.ApiRouteResource.updateApiRoute":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.IuiRouteResource.addIuiRoute":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.IuiRouteResource.deleteIuiRoute":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.IuiRouteResource.getIuiRoute":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.IuiRouteResource.getIuiRoutes":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.IuiRouteResource.updateIuiRoute":{"$ref":"#/definitions/HttpMetrics"},"io.dropwizard.jetty.MutableServletContextHandler.get-requests":{"$ref":"#/definitions/HttpMetrics"},"io.dropwizard.jetty.MutableServletContextHandler.post-requests":{"$ref":"#/definitions/HttpMetrics"},"io.dropwizard.jetty.MutableServletContextHandler.put-requests":{"$ref":"#/definitions/HttpMetrics"},"io.dropwizard.jetty.MutableServletContextHandler.delete-requests":{"$ref":"#/definitions/HttpMetrics"},"io.dropwizard.jetty.MutableServletContextHandler.other-requests":{"$ref":"#/definitions/HttpMetrics"}}}}};
-
- const workflows = {
- "1": {
- planName: "plan1",
- plan: {
- id: 'workflow1',
- name: 'workflow1',
- nodes: [],
- configs: {
- restConfigs: [{
- definition: "/s/swagger",
- name: "test",
- swaggerJson: JSON.stringify(swagger),
- version: "v2"
- }]
- }
- },
- },
- "2": {
- planName: "plan2",
- plan: {
- id: 'workflow2',
- name: 'workflow2',
- nodes: [],
- configs: {
- restConfigs: []
- }
- },
- },
- "3": {
- planName: "plan3",
- plan: workflowFJH,
- } ,
- };
-
- const mockarray = [];
- const mockobject = {};
-
- const setting = {
- "BackendType":"SDC",
- };
-
- const tenant = {tenant: "tenant1"};
-
- return { workflows, swagger, mockarray,mockobject, setting, tenant};
- }
-}
diff --git a/sdc-workflow-designer-ui/src/app/services/data/mockdata.ts b/sdc-workflow-designer-ui/src/app/services/data/mockdata.ts
deleted file mode 100644
index ad89e475..00000000
--- a/sdc-workflow-designer-ui/src/app/services/data/mockdata.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-
-export const swaggerFjh = {"info":{"version":"1.0.0","contact":{"url":"https://gerrit.onap.org/r/#/admin/projects/vfc/nfvo/lcm","name":"ONAP VFC team","email":"onap-discuss@lists.onap.org"},"description":"VFC Network Service Lifecycle Management Rest API.","title":"ONAP VFC Network Service Lifecycle Management API"},"paths":{"/ns/sfcs/{sfcInstId}":{"delete":{"responses":{"204":{"description":"successful operation","schema":{"$ref":"#/definitions/DeleteResponse"}},"404":{"description":"the sfc instance id is wrong"},"500":{"description":"the url is invalid"}},"description":"","parameters":[{"required":true,"type":"string","description":"","in":"path","name":"sfcInstId"}],"produces":["application/json"],"tags":["sfc"],"summary":"delete sfc","consumes":["application/json"],"operationId":"delete_sfc"},"get":{"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/SfcInfo"}},"404":{"description":"the sfc instance id is wrong"},"500":{"description":"the url is invalid"}},"description":"","parameters":[{"description":"sfc instance id","required":true,"type":"string","name":"sfcInstId","in":"path"}],"produces":["application/json"],"tags":["sfc"],"summary":"query the specified sfc info","consumes":["application/json"],"operationId":"query_sfc"}},"/ns/{nsInstanceId}/postdeal":{"post":{"responses":{"202":{"description":""}},"description":"","parameters":[{"required":true,"type":"string","description":"","in":"path","name":"nsInstanceId"},{"schema":{"$ref":"#/definitions/NSInstPostDetailRequest"},"description":"request param","required":true,"name":"body","in":"body"}],"produces":["application/json"],"tags":["postdeal"],"summary":"ns postdeal","consumes":["application/json"],"operationId":"ns_postdeal"}},"/ns/vnfs":{"post":{"responses":{"201":{"description":"","schema":{"$ref":"#/definitions/VnfPostResponse"}}},"description":"","parameters":[{"schema":{"$ref":"#/definitions/VnfPostRequest"},"description":"instantiate request param","required":true,"name":"body","in":"body"}],"produces":["application/json"],"tags":["vnf"],"summary":"vnf create","consumes":["application/json"],"operationId":"create_vnf"}},"/ns/{ns_instance_id}/heal":{"post":{"responses":{"202":{"description":"","schema":{"$ref":"#/definitions/JobInfo"}},"500":{"description":"the url is invalid"}},"parameters":[{"required":true,"type":"string","description":"Identifier of the NS instance.","in":"path","name":"ns_instance_id"},{"schema":{"$ref":"#/definitions/NsHealRequest"},"description":"healVnfData","required":true,"name":"healVnfData","in":"body"}],"tags":["ns"],"description":"ns heal","summary":"ns heal","operationId":"ns_heal"}},"/jobs/{jobId}":{"post":{"responses":{"202":{"description":""}},"parameters":[{"required":true,"type":"string","description":"","in":"path","name":"jobId"},{"schema":{"$ref":"#/definitions/JobProgressRequest"},"description":"request param","required":true,"name":"body","in":"body"}],"tags":["job"],"description":"","summary":"jobstatus","operationId":"post_jobprogress"},"get":{"responses":{"202":{"description":"","schema":{"$ref":"#/definitions/JobDetailInfo"}}},"parameters":[{"required":true,"type":"string","description":"job Id","in":"path","name":"jobId"},{"required":true,"type":"string","description":"job response message id","in":"query","name":"responseId"}],"tags":["job"],"description":"","summary":"jobstatus","operationId":"get_jobstatus"}},"/ns/vls/{vlId}":{"delete":{"responses":{"204":{"description":"successful operation","schema":{"$ref":"#/definitions/DeleteVlResponse"}},"404":{"description":"the vl instance id is wrong"},"500":{"description":"the url is invalid"}},"description":"","parameters":[{"required":true,"type":"string","description":"","in":"path","name":"vlId"}],"produces":["application/json"],"tags":["vl"],"summary":"delete vl","consumes":["application/json"],"operationId":"delete_vl"},"get":{"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/VlInfo"}},"404":{"description":"the vl instance id is wrong"},"500":{"description":"the url is invalid"}},"description":"","parameters":[{"description":"vl instance id","required":true,"type":"string","name":"vlId","in":"path"}],"produces":["application/json"],"tags":["vl"],"summary":"query the specified vl info","consumes":["application/json"],"operationId":"query_vl"}},"/ns/vls":{"post":{"responses":{"201":{"description":"","schema":{"$ref":"#/definitions/VlPostResponse"}}},"description":"","parameters":[{"schema":{"$ref":"#/definitions/VlPostRequest"},"description":"instantiate request param","required":true,"name":"body","in":"body"}],"produces":["application/json"],"tags":["vl"],"summary":"vl create","consumes":["application/json"],"operationId":"create_vl"}},"/ns/sfcs":{"post":{"responses":{"201":{"description":"","schema":{"$ref":"#/definitions/SfcPostResponse"}}},"description":"","parameters":[{"schema":{"$ref":"#/definitions/SfcPostRequest"},"description":"request param","required":true,"name":"body","in":"body"}],"produces":["application/json"],"tags":["sfc"],"summary":"sfc create","consumes":["application/json"],"operationId":"create_sfc"}},"/ns/{ns_instance_id}":{"delete":{"responses":{"204":{"description":"The NS instance resource and the associated NS identifier were deleted successfully."}},"parameters":[{"required":true,"type":"string","description":"Identifier of the NS instance.","in":"path","name":"ns_instance_id"}],"tags":["ns"],"description":"ns delete","summary":"ns delete","operationId":"ns_delete"},"get":{"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/NsInstanceInfo"}}},"parameters":[],"tags":["ns"],"description":"ns get","summary":"ns get","operationId":"ns_instance_get"}},"/ns/vnfs/{vnfInstId}":{"delete":{"responses":{"204":{"description":"successful operation","schema":{"$ref":"#/definitions/DeleteResponse"}},"404":{"description":"the vl instance id is wrong"},"500":{"description":"the url is invalid"}},"description":"","parameters":[{"required":true,"type":"string","description":"","in":"path","name":"vnfInstId"}],"produces":["application/json"],"tags":["vnf"],"summary":"delete vnf","consumes":["application/json"],"operationId":"delete_vnf"},"get":{"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/VnfInfo"}},"404":{"description":"the vnf instance id is wrong"},"500":{"description":"the url is invalid"}},"description":"","parameters":[{"description":"vnf instance id","required":true,"type":"string","name":"vnfInstId","in":"path"}],"produces":["application/json"],"tags":["vnf"],"summary":"query the specified vnf info","consumes":["application/json"],"operationId":"query_vnf"}},"/ns":{"post":{"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/NsCreateResponse"}}},"parameters":[{"schema":{"$ref":"#/definitions/NsCreateRequest"},"description":"NS Instance Create Request","required":true,"name":"NSCreateRequest","in":"body"}],"tags":["ns"],"description":"ns create","summary":"ns create","operationId":"ns_create"},"get":{"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/NsInstancesInfo"}}},"parameters":[{"required":true,"type":"string","description":"job response message id","in":"query","name":"csarId"}],"tags":["ns"],"description":"ns get","summary":"ns get","operationId":"ns_instantces_get"}},"/ns/{ns_instance_id}/terminate":{"post":{"responses":{"202":{"description":"","schema":{"$ref":"#/definitions/JobInfo"}},"500":{"description":"the url is invalid"}},"parameters":[{"required":true,"type":"string","description":"Identifier of the NS instance.","in":"path","name":"ns_instance_id"},{"schema":{"$ref":"#/definitions/NsTerminateRequest"},"description":"NsTerminateRequest","required":true,"name":"NsTerminateRequest","in":"body"}],"tags":["ns"],"description":"ns terminate","summary":"ns terminate","operationId":"ns_terminate"}},"/ns/{nsInstanceId}/scale":{"post":{"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/JobInfo"}},"201":{"description":"Invalid Request"}},"parameters":[{"required":true,"type":"string","description":"","in":"path","name":"nsInstanceId"},{"schema":{"$ref":"#/definitions/NsScaleRequest"},"description":"Scale NS Request Body","required":true,"name":"ScaleNSRequest","in":"body"}],"tags":["ns"],"description":"ns scale","summary":"ns scale","operationId":"ns_scale"}},"/mandb/{modelName}":{"delete":{"responses":{"204":{"description":"The tables were deleted successfully."}},"description":"ns table delete","parameters":[{"required":true,"type":"string","description":"model Name.","in":"path","name":"modelName"}],"produces":["application/json"],"tags":["db"],"summary":"ns table delete","consumes":["application/json"],"operationId":"ns_table_delete"},"get":{"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/TableInfo"}},"500":{"description":"the url is invalid"}},"description":"query ns table info","parameters":[{"required":true,"type":"string","description":"model Name.","in":"path","name":"modelName"}],"produces":["application/json"],"tags":["db"],"summary":"query ns table info","consumes":["application/json"],"operationId":"query_ns_table"}},"/ns/{nsInstanceId}/Instantiate":{"post":{"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/JobInfo"}},"201":{"description":"Invalid Request"}},"parameters":[{"required":true,"type":"string","description":"","in":"path","name":"nsInstanceId"},{"schema":{"$ref":"#/definitions/NsInstantiateRequest"},"description":"NS Instantiate Request Body","required":true,"name":"NSInstantiateRequest","in":"body"}],"tags":["ns"],"description":"ns Instantiate","summary":"ns Instantiate","operationId":"ns_Instantiate"}}},"schemes":["http","https"],"produces":["application/json"],"basePath":"/api/nslcm/v1","definitions":{"NsInstanceInfo":{"type":"object","properties":{"nsState":{"type":"string"},"vnfInfo":{"items":{"$ref":"#/definitions/vnfInfo"},"type":"array"},"nsInstanceId":{"type":"string"},"nsdId":{"type":"string"},"vlInfo":{"items":{"$ref":"#/definitions/vlInfo"},"type":"array"},"nsName":{"type":"string"},"vnffgInfo":{"items":{"$ref":"#/definitions/vnffgInfo"},"type":"array"},"description":{"type":"string"}}},"JobDetailInfo":{"type":"object","properties":{"responseDescriptor":{"type":"object","properties":{"status":{"type":"string"},"responseHistoryList":{"items":{"$ref":"#/definitions/jobResponseInfo"},"type":"array"},"responseId":{"type":"string"},"errorCode":{"type":"string"},"progress":{"type":"string"},"statusDescription":{"type":"string"}}},"jobId":{"type":"string"}}},"VnfInfo":{"type":"object","properties":{"vnfInstId":{"type":"string"},"vnfName":{"type":"string"},"vnfStatus":{"type":"string"}}},"DeleteResponse":{"type":"object","properties":{"result":{"enum":[0,1],"type":"integer"},"detail":{"type":"string"}}},"NsHealRequest":{"type":"object","properties":{"vnfInstanceId":{"type":"string"},"cause":{"type":"string"},"additionalParams":{"type":"object","properties":{"action":{"type":"string"},"actionvminfo":{"type":"object","properties":{"vmname":{"type":"string"},"vmid":{"type":"string"}}}}}}},"NsScaleRequest":{"type":"object","properties":{"scaleNsByStepsData":{"$ref":"#/definitions/NsScaleByStepsData"},"scaleType":{"type":"string"}}},"jobResponseInfo":{"type":"object","properties":{"status":{"type":"string"},"progress":{"type":"string"},"responseId":{"type":"string"},"statusDescription":{"type":"string"},"errorCode":{"type":"string"}}},"NSInstPostDetailRequest":{"type":"object","properties":{"status":{"type":"string"}}},"VlInfo":{"type":"object","properties":{"vlId":{"type":"string"},"vlStatus":{"type":"string"},"vlName":{"type":"string"}}},"VnfPostResponse":{"type":"object","properties":{"vnfInstId":{"type":"string"},"jobId":{"type":"string"}}},"NsCreateRequest":{"type":"object","properties":{"nsName":{"type":"string"},"csarId":{"type":"string","description":"the NS package ID"},"description":{"type":"string"}}},"VlPostResponse":{"type":"object","properties":{"vlId":{"type":"string"},"result":{"enum":[0,1],"type":"integer"},"detail":{"type":"string"}}},"SfcPostRequest":{"type":"object","properties":{"sdnControllerId":{"type":"string"},"vnfInstanceData":{"items":{"type":"object"},"type":"array"},"additionalParamForVnf":{"items":{"type":"object"},"type":"array"},"nsInstanceId":{"type":"string"},"jobId":{"type":"string"},"additionalParamForNs":{"items":{"type":"object"},"type":"array"},"context":{"type":"string"},"sapData":{"items":{"type":"object"},"type":"array"},"fpindex":{"type":"string"}}},"NsTerminateRequest":{"type":"object","properties":{"gracefulTerminationTimeout":{"type":"string"},"terminationType":{"type":"string"}}},"JobProgressRequest":{"type":"object","properties":{"progress":{"type":"string"},"errcode":{"type":"string"},"desc":{"type":"string"}}},"SfcInfo":{"type":"object","properties":{"sfcName":{"type":"string"},"sfcInstId":{"type":"string"},"sfcStatus":{"type":"string"}}},"vnfInfo":{"type":"object","properties":{"vnfInstanceId":{"type":"string"},"vnfdId":{"type":"string"},"vnfInstanceName":{"type":"string"}}},"LocationConstraint":{"type":"object","properties":{"locationConstraints":{"type":"object","properties":{"vimid":{"type":"string"}}},"vnfProfileId":{"type":"string"}}},"NsCreateResponse":{"type":"object","properties":{"nsInstanceId":{"type":"string"}}},"VlPostRequest":{"type":"object","properties":{"vnfInstanceData":{"items":{"type":"object"},"type":"array"},"additionalParamForVnf":{"items":{"type":"object"},"type":"array"},"nsInstanceId":{"type":"string"},"flavourId":{"type":"string"},"pnfInfo":{"items":{"type":"object"},"type":"array"},"extNSVirtualLink":{"items":{"type":"object"},"type":"array"},"additionalParamForNs":{"items":{"type":"object"},"type":"array"},"context":{"type":"string"},"sapData":{"items":{"type":"object"},"type":"array"},"nestedNsInstanceId":{"items":{"type":"object"},"type":"array"},"jobId":{"type":"string"},"locationConstraints":{"items":{"type":"object"},"type":"array"},"vlIndex":{"type":"string"}}},"VnfPostRequest":{"type":"object","properties":{"vnfInstanceData":{"items":{"type":"object"},"type":"array"},"vnfIndex":{"type":"string"},"additionalParamForVnf":{"items":{"type":"object"},"type":"array"},"nsInstanceId":{"type":"string"},"flavourId":{"type":"string"},"pnfInfo":{"items":{"type":"object"},"type":"array"},"extNSVirtualLink":{"items":{"type":"object"},"type":"array"},"additionalParamForNs":{"items":{"type":"object"},"type":"array"},"context":{"type":"string"},"sapData":{"items":{"type":"object"},"type":"array"},"nestedNsInstanceId":{"items":{"type":"object"},"type":"array"},"jobId":{"type":"string"},"locationConstraints":{"items":{"type":"object"},"type":"array"}}},"DeleteVlResponse":{"type":"object","properties":{"result":{"enum":[0,1],"type":"integer"},"detail":{"type":"string"}}},"vlInfo":{"type":"object","properties":{"vldId":{"type":"string"},"vlInstanceName":{"type":"string"},"vlInstanceId":{"type":"string"},"relatedCpInstanceId":{"items":{"$ref":"#/definitions/cpInfo"},"type":"array"}}},"cpInfo":{"type":"object","properties":{"cpInstanceId":{"type":"string"},"cpdId":{"type":"string"},"cpInstanceName":{"type":"string"}}},"SfcPostResponse":{"type":"object","properties":{"sfcInstId":{"type":"string"},"jobId":{"type":"string"}}},"NsInstantiateRequest":{"type":"object","properties":{"additionalParamForNs":{"type":"string"},"LocationConstraints":{"items":{"$ref":"#/definitions/LocationConstraint"},"type":"array"}}},"JobInfo":{"type":"object","properties":{"jobId":{"type":"string"}}},"NsInstancesInfo":{"items":{"$ref":"#/definitions/NsInstanceInfo"},"type":"array"},"NsScaleByStepsData":{"type":"object","properties":{"numberOfSteps":{"type":"integer"},"scalingDirection":{"type":"string"},"aspectId":{"type":"string"}}},"vnffgInfo":{"type":"object","properties":{"cpId":{"type":"string"},"virtualLinkId":{"type":"string"},"vnfId":{"type":"string"},"pnfId":{"type":"string"},"nfp":{"type":"string"},"vnffgInstanceId":{"type":"string"}}},"TableInfo":{"type":"object","properties":{"count":{"type":"string"}}}},"swagger":"2.0","consumes":["application/json"]};
-
-export const workflowFJH = {"id":"fjh","name":"fjh","nodes":[{"id":"node0","name":"startEvent","type":"startEvent","position":{"top":31,"left":31,"width":200,"height":100},"connection":[{"sourceRef":"node0","targetRef":"node23"}],"parameters":[{"name":"vlCount","value":"","valueSource":"String","type":"String"},{"name":"vnfCount","value":"","valueSource":"String","type":"String"},{"name":"sfcCount","value":"","valueSource":"String","type":"String"},{"name":"object_context","value":"","valueSource":"String","type":"String"},{"name":"nsInstanceId","value":"","valueSource":"String","type":"String"},{"name":"object_additionalParamForNs","value":"","valueSource":"String","type":"String"},{"name":"object_additionalParamForVnf","value":"","valueSource":"String","type":"String"},{"name":"jobId","value":"","valueSource":"String","type":"String"},{"name":"sdnControllerId","value":"","valueSource":"String","type":"String"},{"name":"templateid","value":"","valueSource":"String","type":"String"},{"name":"instanceid","value":"","valueSource":"String","type":"String"},{"name":"sdnolcmurl","value":"","valueSource":"String","type":"String"},{"name":"statusurl","value":"","valueSource":"String","type":"String"}]},{"id":"node1","name":"endEvent","type":"endEvent","position":{"top":668,"left":955,"width":200,"height":100},"connection":[]},{"id":"node2","name":"exclusiveGateway","type":"exclusiveGateway","position":{"top":120,"left":169,"width":200,"height":100},"connection":[{"sourceRef":"node2","targetRef":"node3","condition":"${ vl_index <= vlCount and vl_status='active' }","name":"未完成"},{"sourceRef":"node2","targetRef":"node4","condition":"!( vl_index <= vlCount and vl_status='active' )","name":"创建完成"}]},{"id":"node3","name":"createVL","type":"restTask","position":{"top":213,"left":142,"width":200,"height":100},"connection":[{"sourceRef":"node3","targetRef":"node11"}],"produces":["application/json"],"consumes":["application/json"],"parameters":[{"name":"body","valueSource":"String","type":"String","position":"body","schema":{"$ref":"#/definitions/VlPostRequest"}}],"responses":[{"description":"","schema":{"$ref":"#/definitions/VlPostResponse"}}],"restConfigId":"nslcm","path":"/ns/vls","method":"post"},{"id":"node4","name":"restTask","type":"restTask","position":{"top":115,"left":358,"width":200,"height":100},"connection":[{"sourceRef":"node4","targetRef":"node5"}],"produces":[],"consumes":[],"parameters":[],"responses":[],"restConfigId":"nslcm","path":"","method":""},{"id":"node5","name":"exclusiveGateway","type":"exclusiveGateway","position":{"top":212,"left":383,"width":200,"height":100},"connection":[{"sourceRef":"node5","targetRef":"node6","condition":"未完成"},{"sourceRef":"node5","targetRef":"node12","condition":"创建完成"}]},{"id":"node6","name":"createVNF","type":"restTask","position":{"top":306,"left":352,"width":200,"height":100},"connection":[{"sourceRef":"node6","targetRef":"node7"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node7","name":"intermediateCatchEvent","type":"intermediateCatchEvent","position":{"top":558,"left":443,"width":200,"height":100},"connection":[{"sourceRef":"node7","targetRef":"node8"}],"timerEventDefinition":{"type":"timeDuration"}},{"id":"node8","name":"query_vnf nslcm","type":"restTask","position":{"top":639,"left":216,"width":200,"height":100},"connection":[{"sourceRef":"node8","targetRef":"node9"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node9","name":"exclusiveGateway","type":"exclusiveGateway","position":{"top":539,"left":264,"width":200,"height":100},"connection":[{"sourceRef":"node9","targetRef":"node7","condition":"未完成"},{"sourceRef":"node9","targetRef":"node10","condition":"已完成"}]},{"id":"node10","name":"scriptTask","type":"scriptTask","position":{"top":303,"left":239,"width":200,"height":100},"connection":[{"sourceRef":"node10","targetRef":"node5"}]},{"id":"node11","name":"scriptTask","type":"scriptTask","position":{"top":207,"left":34,"width":200,"height":100},"connection":[{"sourceRef":"node11","targetRef":"node2"}]},{"id":"node12","name":"restTask","type":"restTask","position":{"top":205,"left":732,"width":200,"height":100},"connection":[{"sourceRef":"node12","targetRef":"node13"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node13","name":"exclusiveGateway","type":"exclusiveGateway","position":{"top":287,"left":757,"width":200,"height":100},"connection":[{"sourceRef":"node13","targetRef":"node14","condition":"未结束"},{"sourceRef":"node13","targetRef":"node18","condition":"已结束"}]},{"id":"node14","name":"createSfc","type":"restTask","position":{"top":440,"left":726,"width":200,"height":100},"connection":[{"sourceRef":"node14","targetRef":"node15"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node15","name":"intermediateCatchEvent","type":"intermediateCatchEvent","position":{"top":551,"left":754,"width":200,"height":100},"connection":[{"sourceRef":"node15","targetRef":"node16"}],"timerEventDefinition":{"type":"timeDuration"}},{"id":"node16","name":"restTask","type":"restTask","position":{"top":642,"left":589,"width":200,"height":100},"connection":[{"sourceRef":"node16","targetRef":"node17"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node17","name":"exclusiveGateway","type":"exclusiveGateway","position":{"top":551,"left":614,"width":200,"height":100},"connection":[{"sourceRef":"node17","targetRef":"node15","condition":"未结束"},{"sourceRef":"node17","targetRef":"node19","condition":"已结束"}]},{"id":"node18","name":"restTask","type":"restTask","position":{"top":282,"left":927,"width":200,"height":100},"connection":[{"sourceRef":"node18","targetRef":"node20"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node19","name":"scriptTask","type":"scriptTask","position":{"top":275,"left":588,"width":200,"height":100},"connection":[{"sourceRef":"node19","targetRef":"node13"}]},{"id":"node20","name":"Assign_all_status","type":"scriptTask","position":{"top":380,"left":928,"width":200,"height":100},"connection":[{"sourceRef":"node20","targetRef":"node21"}]},{"id":"node21","name":"post_do","type":"restTask","position":{"top":497,"left":929,"width":200,"height":100},"connection":[{"sourceRef":"node21","targetRef":"node22"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node22","name":"jobstatus","type":"restTask","position":{"top":586,"left":927,"width":200,"height":100},"connection":[{"sourceRef":"node22","targetRef":"node1"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node23","name":"scriptTask","type":"scriptTask","position":{"top":16,"left":143,"width":200,"height":100},"connection":[{"sourceRef":"node23","targetRef":"node2"}],"scriptFormate":"javascript","script":"execution.setVariable(\"vl_index\", 1);\nexecution.setVariable(\"vl_status\", \"active\");"}],"configs":{"restConfigs":[{"id": "nslcm", "name":"nslcm","version":"v1","swagger":swaggerFjh,"definition":""}]}};
diff --git a/sdc-workflow-designer-ui/src/app/services/data/sdc.service.ts b/sdc-workflow-designer-ui/src/app/services/data/sdc.service.ts
deleted file mode 100644
index 0e2f1118..00000000
--- a/sdc-workflow-designer-ui/src/app/services/data/sdc.service.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Copyright (c) 2017 ZTE Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * ZTE - initial API and implementation and/or initial documentation
- */
-
-import { Injectable } from '@angular/core';
-import { Observable } from "rxjs/Observable";
-import { WorkflowNode } from "../../model/workflow/workflow-node";
-import { HttpService } from "../../util/http.service";
-import { PlanModel } from "../../model/plan-model";
-import { BackendService } from './backend.service';
-import { NodeTemplate } from '../../model/topology/node-template';
-
-/**
- * SdcService
- * provides data access from sdc
- */
-@Injectable()
-export class SdcService extends BackendService {
- private workflowId: string;
-
- public getBackendType(): string {
- return "SDC";
- }
- public setParameters(params: any) {
- this.workflowId = params;
- this.loadPlans().subscribe(plans => {
- const map = new Map<string, any>();
- for(let id of Object.keys(plans)) {
- map.set(id, plans[id]);
- }
- this.broadcastService.broadcast(this.broadcastService.workflows, map);
- });
- }
- public loadNodeTemplates(): Observable<NodeTemplate[]> {
- // TODO load data from sdc
- const url = 'api/mockarray';
- return this.httpService.get(url).map(response => response.data);
- }
- public loadTopologyProperties(nodeTemplate: NodeTemplate): Observable<string[]> {
- // TODO load data from sdc
- const url = 'api/mockarray';
- return this.httpService.get(url).map(response => response.data);
- }
- public loadNodeTemplateInterfaces(nodeTemplate: NodeTemplate): Observable<string[]> {
- // TODO load data from sdc
- const url = 'api/mockarray';
- return this.httpService.get(url).map(response => response.data);
- }
- public loadNodeTemplateOperations(nodeTemplate: NodeTemplate, interfaceName: string): Observable<string[]> {
- // TODO load data from sdc
- const url = 'api/mockarray';
- return this.httpService.get(url).map(response => response.data);
- }
- public loadNodeTemplateOperationParameter(nodeTemplate: NodeTemplate, interfaceName: string, operation: string): Observable<any> {
- // TODO load data from sdc
- const url = 'api/mockobject';
- return this.httpService.get(url).map(response => response.data);
- }
-
- public loadPlans(): Observable<any> {
- // TODO load data from sdc
- const url = 'api/workflows';
- return this.httpService.get(url).map(response => response.data);
- }
-
- public loadPlan(): Observable<PlanModel> {
- // TODO load data from sdc
- const url = `api/workflows/${this.workflowId}`;
- return this.httpService.get(url).map(response => response.data as PlanModel);
- }
-
- public save(data: any): Observable<boolean> {
- // TODO save workflow design to sdc
- const url = `api/workflows/${data.name}`;
- return this.httpService.put(url, JSON.stringify(data.planModel)).map(() => true);
- }
-
-}
diff --git a/sdc-workflow-designer-ui/src/app/services/display-info.service.ts b/sdc-workflow-designer-ui/src/app/services/display-info.service.ts
new file mode 100644
index 00000000..a3a57686
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/services/display-info.service.ts
@@ -0,0 +1,27 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+import { Injectable } from "@angular/core";
+import { HttpService } from "../util/http.service";
+import { Observable } from "rxjs";
+import { ModelService } from "./model.service";
+
+@Injectable()
+export class DisplayInfoService {
+ private displayInfoUrl = '/api/workflow-modeler/v1/ext-activities/displayInfo?scene=';
+
+ constructor(private modelService: ModelService, private httpService: HttpService) {
+ }
+
+ public getDisplayInfo(): Observable<any> {
+ return this.httpService.get(this.displayInfoUrl + this.modelService.getPlanModel().scene);
+ }
+} \ No newline at end of file
diff --git a/sdc-workflow-designer-ui/src/app/services/interface.service.spec.ts b/sdc-workflow-designer-ui/src/app/services/interface.service.spec.ts
new file mode 100644
index 00000000..0aeb3f52
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/services/interface.service.spec.ts
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+import { TestBed, inject } from '@angular/core/testing';
+
+import { InterfaceService } from './interface.service';
+
+describe('PersistenceService', () => {
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [InterfaceService]
+ });
+ });
+
+ it('should be created', inject([InterfaceService], (service: InterfaceService) => {
+ expect(service).toBeTruthy();
+ }));
+});
diff --git a/sdc-workflow-designer-ui/src/app/services/interface.service.ts b/sdc-workflow-designer-ui/src/app/services/interface.service.ts
new file mode 100644
index 00000000..c9ef87d8
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/services/interface.service.ts
@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+import { Injectable } from '@angular/core';
+import { ActivatedRoute } from '@angular/router/';
+
+import { Observable } from 'rxjs/Observable';
+import { TranslateService } from '@ngx-translate/core';
+
+import { HttpService } from '../util/http.service';
+import { BroadcastService } from './broadcast.service';
+import { NoticeService } from './notice.service';
+import { PlanModel } from '../model/plan-model';
+
+@Injectable()
+export class InterfaceService {
+ private static ModelUrl = '/api/workflow-modeler/v1/models/';
+ constructor(private activatedRoute: ActivatedRoute, private http: HttpService,
+ private broadcast: BroadcastService, private notice: NoticeService, private translate: TranslateService) {
+ this.getModelData();
+ }
+
+ public getModelData() {
+ this.activatedRoute.queryParams.subscribe(queryParams => {
+ let modelId = queryParams.id;
+ this.http.get(InterfaceService.ModelUrl + modelId).subscribe(data => {
+ this.broadcast.broadcast(this.broadcast.initModel, data);
+ }, error => {
+ this.translate.get('WORKFLOW.MSG.LOAD_FAIL').subscribe((res: string) => {
+ this.notice.error(res);
+ });
+ });
+ });
+ }
+
+ public saveModelData(planModel: PlanModel): Observable<PlanModel> {
+ return this.http.put(InterfaceService.ModelUrl + planModel.id, planModel);
+ }
+}
diff --git a/sdc-workflow-designer-ui/src/app/services/jsplumb.service.ts b/sdc-workflow-designer-ui/src/app/services/jsplumb.service.ts
index e90efa7e..0cf93efe 100644
--- a/sdc-workflow-designer-ui/src/app/services/jsplumb.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/jsplumb.service.ts
@@ -10,15 +10,15 @@
* ZTE - initial API and implementation and/or initial documentation
*/
-import { Injectable } from '@angular/core';
+import {Injectable} from '@angular/core';
import * as jsp from 'jsplumb';
-import { Subscription } from 'rxjs/Subscription';
-import { WorkflowNode } from '../model/workflow/workflow-node';
-import { BroadcastService } from './broadcast.service';
-import { ModelService } from './model.service';
-import { SequenceFlow } from '../model/workflow/sequence-flow';
-import { Position } from '../model/workflow/position';
+import {Subscription} from 'rxjs/Subscription';
+import {WorkflowNode} from '../model/workflow/workflow-node';
+import {BroadcastService} from './broadcast.service';
+import {ModelService} from './model.service';
+import {SequenceFlow} from '../model/workflow/sequence-flow';
+import {Position} from '../model/workflow/position';
/**
* JsPlumbService
@@ -46,17 +46,6 @@ export class JsPlumbService {
}
}
});
-
- this.broadcastService.planModel$.subscribe(Workflow => {
- this.jsplumbInstanceMap.get(this.modelService.rootNodeId).reset();
- this.unsubscriptionAll();
- this.buttonDraggable();
- this.buttonDroppable();
- });
- }
-
- private unsubscriptionAll() {
- this.subscriptionMap.forEach(subscription => subscription.unsubscribe());
}
public connectChildrenNodes(parentNodeId: string) {
@@ -121,7 +110,7 @@ export class JsPlumbService {
width: 11,
length: 12
}],
- ['Label', { label: '', id: 'label' }]
+ ['Label', {label: '', id: 'label'}]
]
});
@@ -206,7 +195,7 @@ export class JsPlumbService {
public deleteConnect(sourceId: string, targetId: string) {
const sourceNode = this.modelService.getNodeMap().get(sourceId);
const jsplumbInstance = this.jsplumbInstanceMap.get(sourceNode.parentId);
- const connectionSelection = jsplumbInstance.select({ source: sourceId, target: targetId });
+ const connectionSelection = jsplumbInstance.select({source: sourceId, target: targetId});
this.unsubscription4Connection(connectionSelection);
connectionSelection.delete();
}
@@ -214,7 +203,7 @@ export class JsPlumbService {
public setLabel(sourceId: string, targetId: string, label: string) {
const sourceNode = this.modelService.getNodeMap().get(sourceId);
const jsplumbInstance = this.jsplumbInstanceMap.get(sourceNode.parentId);
- const connections = jsplumbInstance.select({ source: sourceId, target: targetId });
+ const connections = jsplumbInstance.select({source: sourceId, target: targetId});
connections.setLabel(label);
}
@@ -279,7 +268,7 @@ export class JsPlumbService {
if (sourceId === targetId) {
return false;
}
- const sameConnections = this.instance.getConnections({ source: sourceId, target: targetId });
+ const sameConnections = this.instance.getConnections({source: sourceId, target: targetId});
if (sameConnections && 0 < sameConnections.length) {
return false;
}
@@ -332,6 +321,8 @@ export class JsPlumbService {
private drop(event) {
const dragEl = event.drag.el;
const dropEl = event.drop.el;
+ console.log(this.modelService.getNodes());
+
this.resizeParent(dragEl, dropEl);
@@ -345,7 +336,8 @@ export class JsPlumbService {
dragEl.style.left = left + 'px';
// 12 is title height
- this.modelService.updatePosition(dragEl.id, left, top, dragEl.getBoundingClientRect().width, dragEl.getBoundingClientRect().height - 12);
+ const nameHeight = this.getNodeNameHeight(dragEl);
+ this.modelService.updatePosition(dragEl.id, left, top, dragEl.getBoundingClientRect().width, dragEl.getBoundingClientRect().height - nameHeight);
const originalParentNode = this.getParentNodeEl(dragEl);
const originalParentNodeId = originalParentNode ? originalParentNode.id : this.modelService.rootNodeId;
@@ -354,6 +346,17 @@ export class JsPlumbService {
this.changeParent(dragEl.id, originalParentNodeId, targetParentNodeId);
}
+ private getNodeNameHeight(element: any): number {
+ const children = element.children;
+ if (children && children.length) {
+ const nameElement = children[0];
+ if (nameElement && nameElement.className === 'name') {
+ return nameElement.getBoundingClientRect().height;
+ }
+ }
+ return 0;
+ }
+
private changeParent(id: string, originalParentNodeId: string, targetParentNodeId: string) {
if (originalParentNodeId !== targetParentNodeId) {
this.jsplumbInstanceMap.get(originalParentNodeId).removeAllEndpoints(id);
@@ -402,6 +405,10 @@ export class JsPlumbService {
drop: event => {
const el = jsplumbInstance.getSelector(event.drag.el);
const type = el.attributes.nodeType.value;
+ let typeId = null;
+ if (el.attributes.nodeTypeId && el.attributes.nodeTypeId.value) {
+ typeId = el.attributes.nodeTypeId.value;
+ }
// Mouse position minus drop canvas start position plus scroll position.
let left = event.e.x - event.drop.pagePosition[0] + event.drop.el.scrollLeft;
let top = event.e.y - event.drop.pagePosition[1] + event.drop.el.scrollTop;
@@ -411,8 +418,8 @@ export class JsPlumbService {
if (0 > top) {
top = 0;
}
- const name = event.drag.el.children[1].innerText;
- this.modelService.addNode(name, type, left, top);
+ const name = el.attributes.name.value;
+ this.modelService.addNode(type, typeId, name, left, top);
},
});
}
@@ -421,9 +428,9 @@ export class JsPlumbService {
const jsplumbInstance = this.jsplumbInstanceMap.get(node.parentId);
// unsubscription4Connection
- const connectionsAsSource = jsplumbInstance.select({ source: node.id });
+ const connectionsAsSource = jsplumbInstance.select({source: node.id});
this.unsubscription4Connection(connectionsAsSource);
- const connectionsAsTarget = jsplumbInstance.select({ target: node.id });
+ const connectionsAsTarget = jsplumbInstance.select({target: node.id});
this.unsubscription4Connection(connectionsAsTarget);
jsplumbInstance.remove(node.id);
@@ -447,11 +454,12 @@ export class JsPlumbService {
if (leftResized || rightResized || topResized || bottomResized) {
if (parentElement.classList.contains('node')) {
const rect = parentElement.getBoundingClientRect();
+ const nameHeight = this.getNodeNameHeight(parentElement);
this.modelService.updatePosition(parentElement.id,
parentElement.offsetLeft,
parentElement.offsetTop,
// title height
- rect.width, rect.height - 12);
+ rect.width, rect.height - nameHeight);
}
this.resizeParent(parentElement, parentElement.parentNode);
}
@@ -547,7 +555,7 @@ export class JsPlumbService {
const len = parentElment.children.length;
for (let i = 0; i < len; i++) {
const childElment = parentElment.children[i];
- if (childElment.localName === 'b4t-node') {
+ if (childElment.localName === 'wfm-node') {
this.translateElement(childElment.children[0], left, top, 0, 0);
}
}
diff --git a/sdc-workflow-designer-ui/src/app/services/model.service.ts b/sdc-workflow-designer-ui/src/app/services/model.service.ts
index b0ce69f3..8cb7b86a 100644
--- a/sdc-workflow-designer-ui/src/app/services/model.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/model.service.ts
@@ -15,7 +15,13 @@ import { isNullOrUndefined } from 'util';
import { PlanModel } from '../model/plan-model';
import { PlanTreeviewItem } from '../model/plan-treeview-item';
import { RestConfig } from '../model/rest-config';
-import { Swagger, SwaggerModel, SwaggerModelSimple, SwaggerPrimitiveObject, SwaggerReferenceObject } from '../model/swagger';
+import {
+ Swagger,
+ SwaggerModel,
+ SwaggerModelSimple,
+ SwaggerPrimitiveObject,
+ SwaggerReferenceObject
+} from '../model/swagger';
import { ErrorEvent } from '../model/workflow/error-event';
import { IntermediateCatchEvent } from '../model/workflow/intermediate-catch-event';
import { NodeType } from '../model/workflow/node-type.enum';
@@ -32,8 +38,13 @@ import { ValueSource } from '../model/value-source.enum';
import { BroadcastService } from './broadcast.service';
import { RestService } from './rest.service';
import { SwaggerTreeConverterService } from './swagger-tree-converter.service';
-import { ScriptTask } from "../model/workflow/script-task";
import { TimerEventDefinition, TimerEventDefinitionType } from "../model/workflow/timer-event-definition";
+import { InterfaceService } from './interface.service';
+import { ServiceTask } from '../model/workflow/service-task';
+import { NodeTypeService } from './node-type.service';
+import { WorkflowUtil } from '../util/workflow-util';
+import { TranslateService } from '@ngx-translate/core';
+import { NoticeService } from './notice.service';
/**
* ModelService
@@ -44,10 +55,13 @@ export class ModelService {
public rootNodeId = 'root';
private planModel: PlanModel = new PlanModel();
+ private tempPlanModel: PlanModel = new PlanModel();
- constructor(private broadcastService: BroadcastService, private restService: RestService) {
- this.broadcastService.planModel$.subscribe(plan => {
- plan.nodes.forEach(node => {
+ constructor(private interfaceService: InterfaceService, private broadcastService: BroadcastService,
+ private restService: RestService, private nodeTypeService: NodeTypeService,
+ private translate: TranslateService, private notice: NoticeService) {
+ this.broadcastService.initModel$.subscribe(planModel => {
+ planModel.data.nodes.forEach(node => {
switch (node.type) {
case NodeType[NodeType.startEvent]:
node.position.width = 56;
@@ -93,16 +107,22 @@ export class ModelService {
break;
}
});
- this.planModel = plan;
- });
- this.broadcastService.updateModelRestConfig$.subscribe(restConfigs => {
- this.updateRestConfig(restConfigs);
+ this.planModel = planModel;
+ this.tempPlanModel = WorkflowUtil.deepClone(this.planModel);
});
+ // Do not use restConfig property.
+ // this.broadcastService.updateModelRestConfig$.subscribe(restConfigs => {
+ // this.updateRestConfig(restConfigs);
+ // });
+ }
+
+ public getPlanModel(): PlanModel {
+ return this.planModel;
}
public getChildrenNodes(parentId: string): WorkflowNode[] {
if (!parentId || parentId === this.rootNodeId) {
- return this.planModel.nodes;
+ return this.planModel.data.nodes;
} else {
const node = this.getNodeMap().get(parentId);
if (node.type === 'subProcess') {
@@ -114,7 +134,7 @@ export class ModelService {
}
public getNodes(): WorkflowNode[] {
- return this.planModel.nodes;
+ return this.planModel.data.nodes;
}
public getSequenceFlow(sourceRef: string, targetRef: string): SequenceFlow {
@@ -127,11 +147,76 @@ export class ModelService {
}
}
- public addNode(name: string, type: string, left: number, top: number) {
- const id = this.createId();
+ public addNode(type: string, typeId: string, name: string, left: number, top: number) {
+ const id = this.generateNodeProperty('id', type);
+ const nodeName = this.generateNodeProperty('name', name);
const workflowPos = new Position(left, top);
- const node = this.createNodeByType(id, name, type, workflowPos);
- this.planModel.nodes.push(node);
+ let node;
+ if ('serviceTask' === type || 'scriptTask' === type || 'restTask' === type) {
+ node = this.createNodeByTypeId(id, nodeName, type, typeId, workflowPos);
+ } else {
+ node = this.createNodeByType(id, nodeName, type, workflowPos);
+ }
+ this.planModel.data.nodes.push(node);
+ }
+
+ private generateNodeProperty(key: string, type: string): string {
+ let nodeProperty = type;
+ const nodes = this.getNodes();
+ console.log(nodes);
+ const existNode = nodes.find(node => node[key] === nodeProperty);
+ if (existNode) {
+ let count = 2;
+ do {
+ nodeProperty = type + '_' + count;
+ count++;
+ } while (nodes.find(node => node[key] === nodeProperty))
+ }
+ return nodeProperty;
+ }
+
+ private generateNodeName(typeId: string): string {
+ const language = this.translate.currentLang.indexOf('en') > -1 ? 'en_US' : 'zh_CN';
+ const nodeType = this.nodeTypeService.getNodeDataTypeById(typeId);
+ let displayName;
+ if (nodeType.displayName && nodeType.displayName[language]) {
+ displayName = nodeType.displayName[language];
+ } else {
+ displayName = nodeType.type;
+ }
+ return this.generateNodeProperty('name', displayName);
+ }
+
+ public createNodeByTypeId(id: string, name: string, type: string, typeId: string, position: Position): WorkflowNode {
+ const nodeDataType = this.nodeTypeService.getNodeDataTypeById(typeId);
+ const initPosition = new Position(position.left, position.top, nodeDataType.icon.width, nodeDataType.icon.height);
+ // switch (type) {
+ // case NodeType[NodeType.serviceTask]:
+ // let serviceTask: ServiceTask = {
+ // id: id, type: type, name: name, parentId: this.rootNodeId,
+ // position: initPosition, connection: [], class: nodeDataType.activity.class,
+ // input: nodeDataType.activity.input, output: nodeDataType.activity.output
+ // };
+ // return serviceTask;
+ // case NodeType[NodeType.scriptTask]:
+ // let scriptTask: ScriptTask = {
+ // id: id, type: type, name: name, parentId: this.rootNodeId,
+ // position: initPosition, connection: [], scriptFormat: nodeDataType.activity.scriptFormat,
+ // script: nodeDataType.activity.script
+ // };
+ // return scriptTask;
+ // case NodeType[NodeType.restTask]:
+ // let restTaskNode: RestTask = {
+ // id: id, type: type, name: name, parentId: this.rootNodeId,
+ // position: initPosition, connection: [], produces: [], consumes: [], parameters: [], responses: []
+ // };
+ // return restTaskNode;
+ // default:
+ let node: WorkflowNode = {
+ id: id, type: type, typeId: nodeDataType.id, icon: nodeDataType.icon.name, name: name,
+ parentId: this.rootNodeId, position: initPosition, connection: []
+ };
+ return node;
}
private createNodeByType(id: string, name: string, type: string, position: Position): WorkflowNode {
@@ -150,17 +235,16 @@ export class ModelService {
position: bigPosition, connection: []
};
return endEventNode;
- case NodeType[NodeType.restTask]:
- let restTaskNode: RestTask = {
- id: id, type: type, name: name, parentId: this.rootNodeId,
- position: bigPosition, connection: [], produces: [], consumes: [], parameters: [], responses: []
- };
- return restTaskNode;
case NodeType[NodeType.errorStartEvent]:
case NodeType[NodeType.errorEndEvent]:
let errorEventNode: ErrorEvent = {
- id: id, type: type, name: '', parentId: this.rootNodeId,
- position: smallPosition, connection: [], parameter: new Parameter('errorRef', '', ValueSource[ValueSource.String])
+ id: id,
+ type: type,
+ name: '',
+ parentId: this.rootNodeId,
+ position: smallPosition,
+ connection: [],
+ parameter: new Parameter('errorRef', '', ValueSource[ValueSource.string])
};
return errorEventNode;
case NodeType[NodeType.toscaNodeManagementTask]:
@@ -177,16 +261,15 @@ export class ModelService {
return subProcess;
case NodeType[NodeType.intermediateCatchEvent]:
let intermediateCatchEvent: IntermediateCatchEvent = {
- id: id, type: type, name: name, parentId: this.rootNodeId,
- position: bigPosition, connection: [], timerEventDefinition: <TimerEventDefinition>{ type: TimerEventDefinitionType[TimerEventDefinitionType.timeDuration] }
+ id: id,
+ type: type,
+ name: name,
+ parentId: this.rootNodeId,
+ position: bigPosition,
+ connection: [],
+ timerEventDefinition: <TimerEventDefinition>{ type: TimerEventDefinitionType[TimerEventDefinitionType.timeDuration] }
};
return intermediateCatchEvent;
- case NodeType[NodeType.scriptTask]:
- let scriptTask: ScriptTask = {
- id: id, type: type, name: name, parentId: this.rootNodeId,
- position: bigPosition, connection: [], scriptFormat: 'JavaScript'
- };
- return scriptTask;
case NodeType[NodeType.exclusiveGateway]:
case NodeType[NodeType.parallelGateway]:
let getway: WorkflowNode = {
@@ -207,34 +290,6 @@ export class ModelService {
return undefined !== object.type;
}
- // public createNodeByJson(obj: any): WorkflowNode {
- // let node;
- // switch (obj.type) {
- // case NodeType[NodeType.startEvent]:
- // node = new StartEvent(obj.name, obj.id, obj.type, this.rootNodeId, obj.position);
- // node.parameters = obj.parameters;
- // return node;
- // case NodeType[NodeType.restTask]:
- // node = new RestTask(obj.name, obj.id, obj.type, this.rootNodeId, obj.position);
- // node.
- // case NodeType[NodeType.errorStartEvent]:
- // return new ErrorEvent(type, id, type, this.rootNodeId, position);
- // case NodeType[NodeType.errorEndEvent]:
- // return new ErrorEvent(type, id, type, this.rootNodeId, position);
- // case NodeType[NodeType.toscaNodeManagementTask]:
- // return new ToscaNodeTask(type, id, type, this.rootNodeId, position);
- // case NodeType[NodeType.subProcess]:
- // return new SubProcess(type, id, type, this.rootNodeId, position);
- // case NodeType[NodeType.intermediateCatchEvent]:
- // return new IntermediateCatchEvent(type, id, type, this.rootNodeId, position);
- // case NodeType[NodeType.scriptTask]:
- // return new ScriptTask(type, id, type, this.rootNodeId, position);
- // default:
- // return new WorkflowNode(type, id, type, this.rootNodeId, position);
- // }
- // return node;
- // }
-
public changeParent(id: string, originalParentId: string, targetParentId: string) {
if (originalParentId === targetParentId) {
return;
@@ -246,7 +301,7 @@ export class ModelService {
if (targetParentId) {
this.addChild(targetParentId, node);
} else {
- this.planModel.nodes.push(node);
+ this.planModel.data.nodes.push(node);
}
}
@@ -259,13 +314,13 @@ export class ModelService {
}
public updateRestConfig(restConfigs: RestConfig[]): void {
- this.planModel.configs = { restConfigs: restConfigs };
+ this.planModel.data.configs = { restConfigs: restConfigs };
// console.log(this.planModel.configs);
}
public getNodeMap(): Map<string, WorkflowNode> {
const map = new Map<string, WorkflowNode>();
- this.toNodeMap(this.planModel.nodes, map);
+ this.toNodeMap(this.planModel.data.nodes, map);
return map;
}
@@ -423,7 +478,7 @@ export class ModelService {
const item = new PlanTreeviewItem(node.name, `[${node.id}]`, [], false);
item.children.push(this.createStatusCodeTreeViewItem(node.id));
- if (node.responses.length !== 0) { // load rest responses
+ if (node.responses && node.responses.length !== 0) { // load rest responses
const responseItem = this.createResponseTreeViewItem(node.id);
item.children.push(responseItem);
// todo: should list all available response or only the first one?
@@ -491,11 +546,28 @@ export class ModelService {
return targetNode !== undefined;
}
- public save() {
+ public save(callback?: Function) {
console.log('****************** save data *********************');
- console.log(this.planModel);
-
- this.broadcastService.broadcast(this.broadcastService.saveEvent, this.planModel);
+ console.log(JSON.stringify(this.planModel));
+ // Check data
+ if(!this.checkData()){
+ return;
+ }
+ this.interfaceService.saveModelData(this.planModel).subscribe(response => {
+ this.translate.get('WORKFLOW.MSG.SAVE_SUCCESS').subscribe((res: string) => {
+ this.notice.success(res);
+ // Update the cache.
+ this.tempPlanModel = WorkflowUtil.deepClone(this.planModel);
+ if (callback) {
+ callback();
+ }
+ });
+ }, error => {
+ this.translate.get('WORKFLOW.MSG.SAVE_FAIL').subscribe((res: string) => {
+ this.notice.error(res);
+ });
+ });
+ ;
}
private createId() {
@@ -510,4 +582,44 @@ export class ModelService {
return 'node' + nodeMap.size;
}
+
+ public isModify(): boolean {
+ // Compare the cache.
+ return JSON.stringify(this.planModel) != JSON.stringify(this.tempPlanModel);
+ }
+
+ private checkData(): boolean {
+ if (this.planModel && this.planModel.data && this.planModel.data.nodes) {
+ let nodes = this.planModel.data.nodes;
+ for (let index = 0; index < nodes.length; index++) {
+ const node = nodes[index];
+ if (NodeType[NodeType.startEvent] === node.type) {
+ let startEvent = node as StartEvent;
+ if (startEvent.parameters) {
+ for (let i = 0; i < startEvent.parameters.length; i++) {
+ const parameter = startEvent.parameters[i];
+ if (!parameter.name) {
+ this.translate.get('WORKFLOW.MSG.PROCESS_VARIABLE_EMPTY').subscribe((res: string) => {
+ this.notice.error(res);
+ });
+ return false;
+ }
+ if(i + 1 < startEvent.parameters.length){
+ for (let j = i + 1; j < startEvent.parameters.length; j++) {
+ const param = startEvent.parameters[j];
+ if(parameter.name === param.name){
+ this.translate.get('WORKFLOW.MSG.PROCESS_VARIABLE_SAME').subscribe((res: string) => {
+ this.notice.error(res);
+ });
+ return false;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
}
diff --git a/sdc-workflow-designer-ui/src/app/services/node-type.service.ts b/sdc-workflow-designer-ui/src/app/services/node-type.service.ts
new file mode 100644
index 00000000..a40ad50f
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/services/node-type.service.ts
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+import { Injectable } from "@angular/core";
+import { HttpService } from "../util/http.service";
+import { BroadcastService } from "./broadcast.service";
+import { NodeDataType } from "../model/node-data-type/node-data-type";
+import { Parameter } from "../model/workflow/parameter";
+import { TranslateService } from "@ngx-translate/core";
+
+@Injectable()
+export class NodeTypeService {
+ private nodeDataTypes: NodeDataType[] = [];
+ private nodeDataTypeUrl = '/api/workflow-modeler/v1/ext-activities?sence=test';
+
+ constructor(private httpService: HttpService, private translateService: TranslateService,
+ private broadcastService: BroadcastService) {
+ this.initNodeDataTypes();
+ }
+
+ private initNodeDataTypes(): void {
+ this.httpService.get(this.nodeDataTypeUrl)
+ .toPromise()
+ .then(resp => {
+ if (resp && 0 < resp.length) {
+ this.nodeDataTypes = resp;
+ }
+ this.broadcastService.broadcast(this.broadcastService.updateNodeTypeConfig, null);
+ });
+ }
+
+ public getAllNodeDataTypes(): NodeDataType[] {
+ return this.nodeDataTypes;
+ }
+
+ public getNodeDataTypeById(id: string): NodeDataType | null {
+ return this.nodeDataTypes.find(nodeDataType => nodeDataType.id === id);
+ }
+
+ public GetI18nName(key: string, displayName: any): string {
+ //todo: add logic
+ let name = key;
+ if (displayName) {
+ let language = 'zh_CN';
+ if (this.translateService.currentLang.indexOf('en') > -1) {
+ language = 'en_US';
+ }
+ if (displayName.language && '' != displayName.language) {
+ name = displayName.language;
+ }
+ }
+ return name;
+ }
+
+ public static GetParameterByDataType(nodeDataType: any): Parameter {
+ //todo: add logic
+ let param = new Parameter('', '', '');
+ return param;
+ }
+} \ No newline at end of file
diff --git a/sdc-workflow-designer-ui/src/app/services/rest.service.ts b/sdc-workflow-designer-ui/src/app/services/rest.service.ts
index 1db51471..e3bde51b 100644
--- a/sdc-workflow-designer-ui/src/app/services/rest.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/rest.service.ts
@@ -1,190 +1,151 @@
-/*******************************************************************************
- * Copyright (c) 2017 ZTE Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * ZTE - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-import { Injectable } from '@angular/core';
-import { Http, RequestOptionsArgs } from '@angular/http';
-import { Observable } from 'rxjs/Rx';
-import { isNullOrUndefined } from 'util';
-
-import { SwaggerMethod } from '../model/swagger';
-import { SwaggerResponse } from '../model/swagger';
-import { Swagger, SwaggerSchemaObject } from '../model/swagger';
-import { RestConfig } from '../model/rest-config';
-import { HttpService } from '../util/http.service';
-import { BroadcastService } from './broadcast.service';
-import { NoticeService } from './notice.service';
-
-@Injectable()
-export class RestService {
-
- private restConfigs: RestConfig[] = [];
- // private runtimeURL = '/openoapi/catalog/v1/sys/config';
- private runtimeURL = '/api/tenant';
- // private msbPublishServiceURL = '/api/msdiscover/v1/publishservicelist';
- private msbPublishServiceURL = '/api/mockarray';
-
- constructor(private broadcastService: BroadcastService, private http: Http, private noticeService: NoticeService) {
- this.broadcastService.planModel$.subscribe(planModel => {
- planModel.configs.restConfigs.forEach(element => {
- this.addRestConfig(element);
- });
- });
- this.initSwaggerInfoByMSB();
- }
-
- public addRestConfig(config: RestConfig) {
- const idSet = new Set<string>();
- this.restConfigs.forEach(rc => {
- idSet.add(rc.id);
- });
-
- if(idSet.has(config.id)) {
- return false;
- } else {
- this.restConfigs.push(config);
- return true;
- }
- }
-
- public newRestConfig(): RestConfig {
- const idSet = new Set<string>();
- this.restConfigs.forEach(rc => {
- idSet.add(rc.id);
- });
-
- let index = 0;
- for(; index <= idSet.size; index++) {
- if(!idSet.has(index + '')) {
- break;
- }
- }
-
- const restConfig = new RestConfig(index.toString(), 'new Config', '', '', '');
- return restConfig;
- }
-
- // public initSwaggerInfo(restConfig: RestConfig) {
- // if (restConfig.dynamic && restConfig.definition) {
- // this.getDynamicSwaggerInfo(restConfig.definition).subscribe(response => restConfig.swagger = new Swagger(response));
- // } else {
- // restConfig.swagger = new Swagger(restConfig.swagger);
- // }
- // }
-
- public getRestConfigs() {
- return this.restConfigs;
- }
-
- public getDynamicSwaggerInfo(url: string): Observable<any> {
- const options: any = {
- headers: {
- Accept: 'application/json',
- },
- };
- return this.http.get(url, options);
- }
-
- public getSwaggerInfo(id: string): Swagger {
- const restConfig = this.restConfigs.find(tmp => tmp.id === id);
- return restConfig === undefined ? undefined : restConfig.swagger;
- }
-
- public getResponseParameters(swagger: Swagger, interfaceUrl: string, operation: string): SwaggerResponse[] {
- const path = swagger.paths[interfaceUrl];
- const method: SwaggerMethod = path[operation];
- let responses: SwaggerResponse[] = [];
-
- for (const key of Object.keys(method.responses)) {
- if (key.startsWith('20') && method.responses[key].schema && method.responses[key].schema.$ref) {
- let response: SwaggerResponse = method.responses[key];
- responses.push(response);
- }
- }
-
- return responses;
- }
-
- public getDefinition(swagger: Swagger, position: string): SwaggerSchemaObject {
- const definitionName = position.substring('#/definitions/'.length);
-
- return swagger.definitions[definitionName];
- }
-
- private initSwaggerInfoByMSB(): void {
- const options: any = {
- headers: {
- Accept: 'application/json',
- }
- };
- let restConfigs = this.restConfigs;
- this.http.get(this.runtimeURL).subscribe(runtimeResponse => {
- const tenant = runtimeResponse.json().tenant;
- console.log('Current namespace is:' + tenant);
- this.http.get(this.msbPublishServiceURL, { params: { namespace: tenant } }).subscribe(serviceResponse => {
- if (!Array.isArray(serviceResponse.json())) {
- return;
- }
- const services = serviceResponse.json();
- const protocel = location.protocol.slice(0, location.protocol.length - 1);
- const swaggerObservableArray: Observable<any>[] = [];
- services.forEach(serviceInfo => {
- if ('REST' === serviceInfo.protocol && protocel === serviceInfo.publish_protocol) {
- // this service don't have sawgger file.
- if ('/activiti-rest' !== serviceInfo.publish_url) {
- const id = serviceInfo.serviceName + '.' + serviceInfo.version;
- this.addRestConfig(new RestConfig(id, serviceInfo.serviceName, serviceInfo.version, serviceInfo.publish_url, ''));
- let swaggerUrl = '';
- if (undefined !== serviceInfo.swagger_url && '' !== serviceInfo.swagger_url) {
- swaggerUrl = serviceInfo.publish_url + '/' + serviceInfo.swagger_url;
- } else {
- // default swagger url is: '/swagger.json'
- swaggerUrl = serviceInfo.publish_url + '/swagger.json';
- }
- swaggerObservableArray.push(this.http.get(swaggerUrl, options).timeout(5000).catch((error): Observable<any> => {
- console.log('Request swagger from:"' + swaggerUrl + '" faild!');
- return Observable.of(null);
- }));
- }
- }
- });
- Observable.forkJoin(swaggerObservableArray).subscribe(
- responses => {
- let deleteArray: number[] = [];
- responses.forEach((response, index) => {
- // mark http get failed request index or set the swagger into restConfigs
- if (null === response) {
- deleteArray.push(index);
- } else {
- try {
- const swagger = response.json();
- restConfigs[index].swagger = new Swagger(swagger);
- } catch (e) {
- deleteArray.push(index);
- console.warn('Do not support this sawgger file format:' + response.text());
- }
- }
- });
- console.log('Get all swagger file finish.');
- // delete failed request from all restConfigs array
- deleteArray.reverse();
- deleteArray.forEach(deleteIndex => {
- restConfigs.splice(deleteIndex, 1);
- });
- this.broadcastService.broadcast(this.broadcastService.updateModelRestConfig, restConfigs);
- console.log('Load all swagger finished.');
- }
- );
- });
- });
- }
-}
-
+/*******************************************************************************
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+import { Injectable } from '@angular/core';
+import { Http, RequestOptionsArgs } from '@angular/http';
+import { Observable } from 'rxjs/Rx';
+import { isNullOrUndefined } from 'util';
+
+import { SwaggerMethod } from '../model/swagger';
+import { SwaggerResponseClass } from '../model/swagger';
+import { Swagger, SwaggerSchemaObject } from '../model/swagger';
+import { RestConfig } from '../model/rest-config';
+import { BroadcastService } from './broadcast.service';
+import { NoticeService } from './notice.service';
+import { SettingService } from './setting.service';
+
+@Injectable()
+export class RestService {
+ private restConfigs: RestConfig[] = [];
+ private runtimeURL = '/openoapi/catalog/v1/sys/config';
+ private msbPublishServiceURL = '/api/msdiscover/v1/publishservicelist';
+
+ constructor(private broadcastService: BroadcastService, private http: Http,
+ private noticeService: NoticeService, private settgingService: SettingService) {
+ this.settgingService.getSetting().subscribe(setting => {
+ if (true === setting.supportRestNode) {
+ this.initSwaggerInfo();
+ } else {
+ this.broadcastService.broadcast(this.broadcastService.updateModelRestConfig, null);
+ }
+ });
+ }
+
+ public getRestConfigs(): RestConfig[] {
+ return this.restConfigs;
+ }
+
+ public getRestConfig(id: string): RestConfig {
+ return this.restConfigs.find(tmp => tmp.id === id);
+ }
+
+ public getSwaggerInfo(id: string): Swagger {
+ const restConfig = this.restConfigs.find(tmp => tmp.id === id);
+ return restConfig === undefined ? undefined : restConfig.swagger;
+ }
+
+ public getResponseParameters(swagger: Swagger, interfaceUrl: string, operation: string): SwaggerResponseClass[] {
+ const path = swagger.paths[interfaceUrl];
+ const method: SwaggerMethod = path[operation];
+ let responses: SwaggerResponseClass[] = [];
+
+ for (const key of Object.keys(method.responses)) {
+ if (key.startsWith('20') && method.responses[key].schema && method.responses[key].schema.$ref) {
+ let response: SwaggerResponseClass = method.responses[key];
+ responses.push(response);
+ }
+ }
+
+ return responses;
+ }
+
+ public getDefinition(swagger: Swagger, position: string): SwaggerSchemaObject {
+ const definitionName = position.substring('#/definitions/'.length);
+ return swagger.definitions[definitionName];
+ }
+
+ private initSwaggerInfo(): void {
+ this.http.get(this.runtimeURL).subscribe(runtimeResponse => {
+ const tenant = runtimeResponse.json().tenant;
+ console.log('Current namespace is:' + tenant);
+ this.initSwaggerInfoByTenant(tenant);
+ }, error => {
+ console.warn('No tenant interface!');
+ this.initSwaggerInfoByTenant('');
+ });
+ }
+
+ private initSwaggerInfoByTenant(tenant: string): void {
+ this.http.get(this.msbPublishServiceURL, { params: { namespace: tenant } }).subscribe(serviceResponse => {
+ if (!Array.isArray(serviceResponse.json())) {
+ return;
+ }
+ const services = serviceResponse.json();
+ const protocel = location.protocol.slice(0, location.protocol.length - 1);
+ const swaggerObservableArray: Observable<any>[] = [];
+ services.forEach(serviceInfo => {
+ if ('REST' === serviceInfo.protocol && protocel === serviceInfo.publish_protocol) {
+ // this service don't have sawgger file.
+ if ('/activiti-rest' !== serviceInfo.publish_url) {
+ const id = serviceInfo.serviceName + '.' + serviceInfo.version;
+ this.restConfigs.push(new RestConfig(id, serviceInfo.serviceName, serviceInfo.version, serviceInfo.publish_url));
+ let swaggerUrl = '';
+ if (undefined !== serviceInfo.swagger_url && '' !== serviceInfo.swagger_url) {
+ swaggerUrl = serviceInfo.publish_url + '/' + serviceInfo.swagger_url;
+ } else {
+ // default swagger url is: '/swagger.json'
+ swaggerUrl = serviceInfo.publish_url + '/swagger.json';
+ }
+ const options: any = {
+ headers: {
+ Accept: 'application/json',
+ }
+ };
+ swaggerObservableArray.push(this.http.get(swaggerUrl, options).timeout(5000).catch((error): Observable<any> => {
+ console.log('Request swagger from:"' + swaggerUrl + '" faild!');
+ return Observable.of(null);
+ }));
+ }
+ }
+ });
+ Observable.forkJoin(swaggerObservableArray).subscribe(
+ responses => {
+ let deleteArray: number[] = [];
+ responses.forEach((response, index) => {
+ // mark http get failed request index or set the swagger into restConfigs
+ if (null === response) {
+ deleteArray.push(index);
+ } else {
+ try {
+ const swagger = response.json();
+ this.restConfigs[index].swagger = new Swagger(swagger);
+ } catch (e) {
+ deleteArray.push(index);
+ console.warn('Do not support this sawgger file format:' + response.text());
+ }
+ }
+ });
+ console.log('Get all swagger file finish.');
+ // delete failed request from all restConfigs array
+ deleteArray.reverse();
+ deleteArray.forEach(deleteIndex => {
+ this.restConfigs.splice(deleteIndex, 1);
+ });
+ this.broadcastService.broadcast(this.broadcastService.updateModelRestConfig, this.restConfigs);
+ console.log('Load all swagger finished.');
+ }
+ );
+ });
+
+ }
+}
+
diff --git a/sdc-workflow-designer-ui/src/app/services/setting.service.spec.ts b/sdc-workflow-designer-ui/src/app/services/setting.service.spec.ts
index 0fe25d0b..a85d2c27 100644
--- a/sdc-workflow-designer-ui/src/app/services/setting.service.spec.ts
+++ b/sdc-workflow-designer-ui/src/app/services/setting.service.spec.ts
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ *******************************************************************************/
import { TestBed, inject } from '@angular/core/testing';
import { SettingService } from './setting.service';
diff --git a/sdc-workflow-designer-ui/src/app/services/setting.service.ts b/sdc-workflow-designer-ui/src/app/services/setting.service.ts
index 558620fc..266c5533 100644
--- a/sdc-workflow-designer-ui/src/app/services/setting.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/setting.service.ts
@@ -1,5 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ *******************************************************************************/
import { Injectable } from '@angular/core';
-import { Observable } from "rxjs";
+import { Observable } from "rxjs/Rx";
import { HttpService } from '../util/http.service';
@@ -14,8 +25,7 @@ export class SettingService {
Accept: 'application/json',
}
};
- // return this.http.get('assets/global-setting.json', options);
- return this.http.get('/api/setting', options);
+ return this.http.get('assets/global-setting.json', options);
}
}
diff --git a/sdc-workflow-designer-ui/src/app/services/swagger-tree-converter.service.ts b/sdc-workflow-designer-ui/src/app/services/swagger-tree-converter.service.ts
index 24fad5ce..8128b44c 100644
--- a/sdc-workflow-designer-ui/src/app/services/swagger-tree-converter.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/swagger-tree-converter.service.ts
@@ -17,15 +17,15 @@ import { ValueSource } from '../model/value-source.enum';
import { WorkflowUtil } from '../util/workflow-util';
import { RestService } from './rest.service';
import { Swagger } from "../model/swagger";
+import { ValueObject } from '../model/value-object';
+import { ValueType } from '../model/value-type.enum';
@Injectable()
export class SwaggerTreeConverterService {
private swagger: Swagger;
- constructor(private restService: RestService) {
-
- }
+ constructor(private restService: RestService) { }
public schema2TreeNode(swagger: Swagger, key: string | number, schema: any, value?: any): any {
this.swagger = swagger;
@@ -52,12 +52,37 @@ export class SwaggerTreeConverterService {
if (definition.$ref) {
definition = this.restService.getDefinition(this.swagger, definition.$ref);
}
+ let valueObject: ValueObject = { valueSource: ValueSource[ValueSource.string] };
+ if (undefined == value) {
+ valueObject.value = definition.default;
+ if (ValueType[ValueType.array] === definition.type || ValueType[ValueType.object] === definition.type) {
+ valueObject.valueSource = ValueSource[ValueSource.Definition];
+ } else {
+ valueObject.valueSource = definition.type;
+ }
+ } else {
+ valueObject.valueSource = value.valueSource;
+ valueObject.value = undefined === value.value ? definition.default : value.value;
+ }
if (definition.type === 'object') {
- return this.getInitValue4Object(value);
+ // if (undefined == value) {
+ // valueObject.value = definition.default;
+ // if (ValueType[ValueType.array] === definition.type || ValueType[ValueType.object] === definition.type) {
+ // valueObject.valueSource = ValueSource[ValueSource.Definition];
+ // } else {
+ // valueObject.valueSource = definition.type;
+ // }
+ // } else {
+ // valueObject.valueSource = value.valueSource;
+ // valueObject.value = undefined === value.value ? definition.default : value.value;
+ // }
+ return this.getInitValue4Object(valueObject);
} else if (definition.type === 'array') {
- return this.getInitValue4Array(value);
+ return this.getInitValue4Array(valueObject);
} else { // primary type
- return this.getInitValue4Primary(value);
+ // valueObject.value = undefined === value ? definition.default : value;
+ // valueObject.valueSource = definition.type;
+ return this.getInitValue4Primary(valueObject);
}
}
@@ -104,7 +129,7 @@ export class SwaggerTreeConverterService {
private getInitValue4Primary(value: any) {
const newValue = {
value: '',
- valueSource: ValueSource[ValueSource.String]
+ valueSource: ValueSource[ValueSource.string]
};
if (!value) {
diff --git a/sdc-workflow-designer-ui/src/app/services/tosca.service.spec.ts b/sdc-workflow-designer-ui/src/app/services/tosca.service.spec.ts
new file mode 100644
index 00000000..a54fba63
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/services/tosca.service.spec.ts
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+import { TestBed, inject } from '@angular/core/testing';
+
+import { ToscaService } from './tosca.service';
+
+describe('ToscaService', () => {
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [ToscaService]
+ });
+ });
+
+ it('should be created', inject([ToscaService], (service: ToscaService) => {
+ expect(service).toBeTruthy();
+ }));
+});
diff --git a/sdc-workflow-designer-ui/src/app/services/tosca.service.ts b/sdc-workflow-designer-ui/src/app/services/tosca.service.ts
new file mode 100644
index 00000000..dd62a717
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/services/tosca.service.ts
@@ -0,0 +1,153 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+import { Injectable } from '@angular/core';
+import { Observable } from "rxjs/Rx";
+
+import { NodeTemplate } from '../model/topology/node-template';
+import { SettingService } from './setting.service';
+import { HttpService } from '../util/http.service';
+import { BroadcastService } from './broadcast.service';
+
+@Injectable()
+export class ToscaService {
+ private nodeTemplate: NodeTemplate[] = [];
+ private topologyProperties: {
+ name: string;
+ value: string;
+ }[] = [];
+ private namespace;
+ private serviceTemplateId;
+ private repositoryURL;
+ constructor(private settingService: SettingService, private httpService: HttpService,
+ private broadcastService: BroadcastService) {
+ this.settingService.getSetting().subscribe(setting => {
+ if (true === setting.supportToscaNode) {
+ // todo: need to load tosca interface and tosca properties
+ this.initTOSCAInfo();
+ } else {
+ this.broadcastService.broadcast(this.broadcastService.updateModelToscaConfig, null);
+ }
+ });
+ }
+
+ public getNodeTemplate(): NodeTemplate[] {
+ return this.nodeTemplate;
+ }
+
+ public getTopologyProperties() {
+ return this.topologyProperties;
+ }
+
+ public initTOSCAInfo() {
+ this.getNodeTemplates().subscribe(nodes => {
+ if (0 === nodes.length) {
+ return;
+ }
+
+ const subscribes = nodes.map(node => this.loadTopologyProperties(node));
+ Observable.forkJoin(subscribes).map(nodesProperties => {
+ const allProperties: { name: string, value: string }[] = [];
+ nodesProperties.forEach((properties, index) => {
+ properties.forEach(property => {
+ // allProperties.push(nodes[index].name + '.' + property);
+ const propertyOption = {
+ name: `${nodes[index].name}.${property}`,
+ value: `[${nodes[index].name}].[${property}]`
+ };
+ allProperties.push(propertyOption);
+ });
+ });
+ return allProperties;
+ }).subscribe(allProperties => {
+ this.topologyProperties = allProperties;
+ this.broadcastService.broadcast(this.broadcastService.updateModelToscaConfig, this.topologyProperties);
+ });
+ });
+ }
+
+ public getNodeTemplates(): Observable<NodeTemplate[]> {
+ const url = 'servicetemplates/' + this.encode(this.namespace)
+ + '/' + this.encode(this.serviceTemplateId) + '/topologytemplate/';
+
+ return this.httpService.get(this.getFullUrl(url)).map(response => {
+ const nodeTemplates = [];
+ for (const key in response.nodeTemplates) {
+ if (response.nodeTemplates.hasOwnProperty(key)) {
+ const nodeTemplate = response.nodeTemplates[key];
+ nodeTemplates.push({
+ id: nodeTemplate.id,
+ type: nodeTemplate.type.replace(/^\{(.+)\}(.+)/, '$2'),
+ name: nodeTemplate.name,
+ namespace: nodeTemplate.type.replace(/^\{(.+)\}(.+)/, '$1'),
+ });
+ }
+ }
+ return nodeTemplates;
+ });
+ }
+
+ public loadTopologyProperties(nodeTemplate: NodeTemplate): Observable<string[]> {
+ const url = 'nodetypes/' + this.encode(nodeTemplate.namespace)
+ + '/' + this.encode(nodeTemplate.type) + '/propertiesdefinition/winery/list/';
+
+ return this.httpService.get(this.getFullUrl(url)).map(properties =>
+ properties.map(property => property.key));
+ }
+
+ public loadNodeTemplateInterfaces(nodeTemplate: NodeTemplate): Observable<string[]> {
+ const url = 'nodetypes/' + this.encode(nodeTemplate.namespace)
+ + '/' + this.encode(nodeTemplate.type) + '/interfaces/';
+
+ return this.httpService.get(this.getFullUrl(url));
+ }
+ public loadNodeTemplateOperations(nodeTemplate: NodeTemplate,
+ interfaceName: string): Observable<string[]> {
+ const url = 'nodetypes/' + this.encode(nodeTemplate.namespace)
+ + '/' + this.encode(nodeTemplate.type) + '/interfaces/' + this.encode(interfaceName) + '/operations/';
+
+ return this.httpService.get(this.getFullUrl(url));
+ }
+
+ public loadNodeTemplateOperationParameter(nodeTemplate: NodeTemplate,
+ interfaceName: string,
+ operation: string): Observable<any> {
+ const relativePath = 'nodetypes/' + this.encode(nodeTemplate.namespace) + '/' + this.encode(nodeTemplate.type)
+ + '/interfaces/' + this.encode(interfaceName) + '/operations/' + this.encode(operation) + '/';
+
+ // input parameters
+ const inputObservable = this.httpService
+ .get(this.getFullUrl(relativePath + 'inputparameters'));
+
+ // output parameters
+ const outputObservable = this.httpService
+ .get(this.getFullUrl(relativePath + 'outputparameters'));
+
+ return Observable.forkJoin([inputObservable, outputObservable]).map(params => {
+ return {
+ input: params[0],
+ output: params[1],
+ };
+ });
+ }
+
+ private decode(param: string): string {
+ return decodeURIComponent(decodeURIComponent(param));
+ }
+
+ private encode(param: string): string {
+ return encodeURIComponent(encodeURIComponent(param));
+ }
+
+ private getFullUrl(relativePath: string) {
+ return this.repositoryURL + relativePath;
+ }
+}
diff --git a/sdc-workflow-designer-ui/src/app/services/workflow.service.ts b/sdc-workflow-designer-ui/src/app/services/workflow.service.ts
deleted file mode 100644
index 127629c9..00000000
--- a/sdc-workflow-designer-ui/src/app/services/workflow.service.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Copyright (c) 2017 ZTE Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * ZTE - initial API and implementation and/or initial documentation
- */
-
-import { Injectable } from '@angular/core';
-import { DataService } from "./data/data.service";
-import { Observable } from "rxjs/Observable";
-import { PlanModel } from "../model/plan-model";
-import { BroadcastService } from "./broadcast.service";
-
-/**
- * ModelService
- * provides all operations about plan model.
- */
-@Injectable()
-export class WorkflowService {
-
- public workflows = new Map<string, any>();
- public planModel: PlanModel;
- private planName : string;
-
- constructor(private broadcastService: BroadcastService, private dataAccessService: DataService) {
- this.broadcastService.workflows$.subscribe(workflows => this.workflows = workflows);
- this.broadcastService.planModel$.subscribe(workflow => this.planModel = workflow);
- }
-
- public save() {
- console.log(this.planModel);
- console.log(JSON.stringify(this.planModel));
- this.broadcastService.broadcast(this.broadcastService.saveEvent, {"name": this.planName, "planModel": this.planModel});
- }
-
- public getPlanName(planId: string): string {
- const planInfo = this.workflows.get(planId);
- return planInfo ? planInfo.planName: null;
- }
-
- public getPlanModel(planId: string): PlanModel {
- const planInfo = this.workflows.get(planId);
- return planInfo ? planInfo.plan: null;
- }
-
- public getWorkflows(): Map<string, any> {
-
- return this.workflows;
- }
-
- public addWorkflow() {
- this.workflows.set(this.getPlanId(), {"planName": "newPlan", "plan": new PlanModel()});
- this.broadcastWorkflows();
- }
-
- public deleteWorkflow(planId: string): PlanModel {
- this.workflows.delete(planId);
- this.broadcastWorkflows();
-
- return undefined;
- }
-
- public broadcastWorkflows() {
- this.broadcastService.broadcast(this.broadcastService.workflows, this.workflows);
- }
-
- private getPlanId(): string {
- for(let index=0; index <= this.workflows.size; index++) {
- if(!this.workflows.has(index + "")) {
- return index + "";
- }
- }
- }
-}