2 * Copyright (c) 2017 ZTE Corporation.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and the Apache License 2.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * ZTE - initial API and implementation and/or initial documentation
12 import { Component, Input, OnInit } from '@angular/core';
13 import { ServiceTask } from '../../../model/workflow/service-task';
14 import { NodeTypeService } from '../../../services/node-type.service';
15 import { Parameter } from '../../../model/workflow/parameter';
16 import { ValueSource } from '../../../model/value-source.enum';
19 selector: 'wfm-service-task',
20 templateUrl: './service-task.component.html',
21 styleUrls: ['./service-task.component.css']
23 export class ServiceTaskComponent implements OnInit {
24 @Input() public node: ServiceTask;
25 public canEdit = true;
26 public inputValueSource = [ValueSource.Variable];
27 public outputValueSource = [];
28 constructor(private nodeTypeService: NodeTypeService) { }
31 const nodeDataType = this.nodeTypeService.getNodeDataTypeById(this.node.typeId);
32 if (nodeDataType.content && nodeDataType.content.class && '' != nodeDataType.content.class) {
35 if (!this.node.className) {
36 this.node.className = '';
37 if (nodeDataType.content.class) {
38 this.node.className = nodeDataType.content.class;
42 let inputs = nodeDataType.content.inputs;
43 if (!this.node.inputs) {
45 this.node.inputs = [];
47 for (const key in inputs) {
48 if (inputs.hasOwnProperty(key)) {
49 const element = inputs[key];
50 this.node.inputs.push(new Parameter(key, element.default, ValueSource[ValueSource.string],
51 element.type, element.required, element.show));
56 // Load parameter value
60 let outputs = nodeDataType.content.outputs;
61 if (!this.node.outputs) {
63 this.node.outputs = [];
65 for (const key in outputs) {
66 if (outputs.hasOwnProperty(key)) {
67 const element = outputs[key];
68 this.node.outputs.push(new Parameter(key, element.default, ValueSource[ValueSource.string],
69 element.type, element.required));
74 // Load parameter value
79 public createInput(): void {
80 this.node.inputs.push(new Parameter('', '', ValueSource[ValueSource.string]));
83 public deleteInput(index: number): void {
84 this.node.inputs.splice(index, 1);
86 public createOutput(): void {
87 this.node.outputs.push(new Parameter('', '', ValueSource[ValueSource.string]));
90 public deleteOutput(index: number): void {
91 this.node.outputs.splice(index, 1);
94 private getParameters() {