2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 import { Injectable, Inject } from "@angular/core";
22 import { Observable } from "rxjs/Observable";
23 import { HttpService } from "./http.service";
24 import { SdcConfigToken, ISdcConfig } from "../config/sdc-config.config";
25 import { Component } from "../../models";
26 import { ComponentFactory } from 'app/utils/component-factory';
30 export class ArchiveService {
33 constructor(private http: HttpService, @Inject(SdcConfigToken) sdcConfig:ISdcConfig, private componentFactory:ComponentFactory/*, @Inject(ComponentFactory) componentFactory */) {
34 this.baseUrl = sdcConfig.api.root ;
37 public getArchiveCatalog() {
38 let archiveCatalogItems:Component[] = [];
39 let archiveCatalogResourceItems:Component[] = [];
40 let archiveCatalogServiceItems:Component[] = [];
42 return this.http.get(this.baseUrl + '/v1/catalog/archive/', {}).map(res => {
43 let archiveCatalogObject = res.json();
44 if (archiveCatalogObject.resources) archiveCatalogResourceItems = this.getResourceItems(archiveCatalogObject.resources);
45 if (archiveCatalogObject.services) archiveCatalogServiceItems = this.getServiceItems(archiveCatalogObject.services);
46 archiveCatalogItems = [].concat(archiveCatalogResourceItems, archiveCatalogServiceItems);
48 return archiveCatalogItems;
53 private getResourceItems(resources){
54 let resourceItems = resources.map((resource)=>{
55 return this.componentFactory.createResource(resource)
60 private getServiceItems(services){
61 let serviceItems = services.map((service)=>{
62 return this.componentFactory.createService(service)