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
10 * ZTE - initial API and implementation and/or initial documentation
\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-node";
\r
17 import { HttpService } from "../../util/http.service";
\r
18 import { Workflow } from "../../model/workflow";
\r
22 * provides data access from sdc
\r
25 export class SdcService extends CatalogService {
\r
27 constructor(protected httpService: HttpService) {
\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
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
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