support set parameter for workflow
[sdc/sdc-workflow-designer.git] / sdc-workflow-designer-ui / src / app / services / data-access / sdc.service.ts
1 /**\r
2  * Copyright (c) 2017 ZTE Corporation.\r
3  * All rights reserved. This program and the accompanying materials\r
4  * are made available under the terms of the Eclipse Public License v1.0\r
5  * and the Apache License 2.0 which both accompany this distribution,\r
6  * and are available at http://www.eclipse.org/legal/epl-v10.html\r
7  * and http://www.apache.org/licenses/LICENSE-2.0\r
8  *\r
9  * Contributors:\r
10  *     ZTE - initial API and implementation and/or initial documentation\r
11  */\r
12 \r
13 import { Injectable } from '@angular/core';\r
14 import { CatalogService } from "./catalog.service";\r
15 import { Observable } from "rxjs/Observable";\r
16 import { WorkflowNode } from "../../model/workflow/workflow-node";\r
17 import { HttpService } from "../../util/http.service";\r
18 import { Workflow } from "../../model/workflow/workflow";\r
19 \r
20 /**\r
21  * SdcService\r
22  * provides data access from sdc\r
23  */\r
24 @Injectable()\r
25 export class SdcService extends CatalogService {\r
26 \r
27     constructor(protected httpService: HttpService) {\r
28         super(httpService);\r
29     }\r
30 \r
31     public loadWorkflows(): Observable<WorkflowNode[]> {\r
32         // TODO load data from sdc\r
33         const url = 'api/workflows';\r
34         return this.httpService.get(url);\r
35     }\r
36 \r
37     public loadWorkflow(workflowId: string): Observable<Workflow> {\r
38         // TODO load data from sdc\r
39         const url = `api/workflows/${workflowId}`;\r
40         return this.httpService.get(url).map(response => response.data);\r
41     }\r
42 \r
43     public saveWorkflow(workflow: Workflow): Observable<boolean> {\r
44         // TODO save workflow design to sdc\r
45         const url = `api/workflows/${workflow.id}`;\r
46         return this.httpService.put(url, JSON.stringify(workflow)).map(() => true);\r
47     }\r
48 \r
49 }\r