[CORD-879] Using ServiceDependency to draw the Coarse Graph

Change-Id: I33ea9ae78e041d329e99b8ae34c10ea335d217a9
diff --git a/src/app/core/services/helpers/config.helpers.ts b/src/app/core/services/helpers/config.helpers.ts
index 2ac9394..0ec20cd 100644
--- a/src/app/core/services/helpers/config.helpers.ts
+++ b/src/app/core/services/helpers/config.helpers.ts
@@ -76,7 +76,7 @@
     pluralize.addPluralRule(/library$/i, 'librarys');
     pluralize.addPluralRule(/imagedeployments/i, 'imagedeploymentses');
     pluralize.addPluralRule(/controllerimages/i, 'controllerimageses');
-
+    pluralize.addPluralRule(/servicedependency/i, 'servicedependencys');
   }
 
   public pluralize(string: string, quantity?: number, count?: boolean): string {
diff --git a/src/app/service-graph/interfaces.ts b/src/app/service-graph/interfaces.ts
index 3dba9d3..b484534 100644
--- a/src/app/service-graph/interfaces.ts
+++ b/src/app/service-graph/interfaces.ts
@@ -41,12 +41,13 @@
 
 export interface IXosCoarseGraphData {
   services: IXosServiceModel[];
-  tenants: IXosTenantModel[];
+  servicedependencys: any[];
 }
 
 export interface IXosFineGrainedGraphData extends IXosCoarseGraphData {
-  subscribers: IXosServiceModel[];
-  networks: IXosTenantModel[];
+  tenants: IXosTenantModel[];
+  subscribers: any[];
+  networks: any[];
 }
 
 export interface IXosServiceGraphNodeBadge {
diff --git a/src/app/service-graph/services/graph.store.spec.ts b/src/app/service-graph/services/graph.store.spec.ts
index 9073d58..27c6ccd 100644
--- a/src/app/service-graph/services/graph.store.spec.ts
+++ b/src/app/service-graph/services/graph.store.spec.ts
@@ -14,6 +14,7 @@
   tenant: new Subject<any>(),
   subscriber: new Subject<any>(),
   network: new Subject<any>(),
+  servicedependency: new Subject<any>()
 };
 
 // COARSE data
@@ -69,7 +70,7 @@
   describe('when subscribing for the COARSE service graph', () => {
     beforeEach((done) => {
       subjects.service.next(coarseServices);
-      subjects.tenant.next(coarseTenants);
+      subjects.servicedependency.next(coarseTenants);
       setTimeout(done, 500);
     });
 
diff --git a/src/app/service-graph/services/graph.store.ts b/src/app/service-graph/services/graph.store.ts
index 2266329..08ec52b 100644
--- a/src/app/service-graph/services/graph.store.ts
+++ b/src/app/service-graph/services/graph.store.ts
@@ -25,7 +25,8 @@
     services: [],
     tenants: [],
     networks: [],
-    subscribers: []
+    subscribers: [],
+    servicedependencys: []
   });
 
   private emptyGraph: IXosServiceGraph = {
@@ -42,6 +43,7 @@
   private tenants;
   private subscribers;
   private networks;
+  private servicedependencys;
 
   // debounced functions
   private handleData;
@@ -51,6 +53,7 @@
   private TenantSubscription: Subscription;
   private SubscriberSubscription: Subscription;
   private NetworkSubscription: Subscription;
+  private ServiceDependencySubscription: Subscription;
 
   constructor (
     private $log: ng.ILogService,
@@ -65,8 +68,6 @@
     this.handleData = this.XosDebouncer.debounce(this._handleData, 500, this, false);
 
     // observe models and populate graphData
-    // TODO get Nodes (model that represent compute nodes in a pod)
-    // TODO get Instances (model that represent deployed VMs)
     this.ServiceSubscription = this.XosModelStore.query('Service', '/core/services')
       .subscribe(
         (res) => {
@@ -77,6 +78,16 @@
         }
       );
 
+    this.ServiceDependencySubscription = this.XosModelStore.query('ServiceDependency', '/core/servicedependencys')
+      .subscribe(
+        (res) => {
+          this.combineData(res, 'servicedependencys');
+        },
+        (err) => {
+          this.$log.error(`[XosServiceGraphStore] Service Observable: `, err);
+        }
+      );
+
     this.TenantSubscription = this.XosModelStore.query('Tenant', '/core/tenants')
       .subscribe(
         (res) => {
@@ -129,7 +140,7 @@
     return this.d3CoarseGraph.asObservable();
   }
 
-  private combineData(data: any, type: 'services'|'tenants'|'subscribers'|'networks') {
+  private combineData(data: any, type: 'services'|'tenants'|'subscribers'|'networks'|'servicedependencys') {
     switch (type) {
       case 'services':
         this.services = data;
@@ -143,6 +154,9 @@
       case 'networks':
         this.networks = data;
         break;
+      case 'servicedependencys':
+        this.servicedependencys = data;
+        break;
     }
     this.handleData(this.services, this.tenants);
   }
@@ -152,7 +166,8 @@
       services: this.services,
       tenants: this.tenants,
       subscribers: this.subscribers,
-      networks: this.networks
+      networks: this.networks,
+      servicedependencys: this.servicedependencys
     });
   }
 
@@ -209,8 +224,7 @@
   private graphDataToCoarseGraph(data: IXosCoarseGraphData) {
 
     try {
-      const links: IXosServiceGraphLink[] = _.chain(data.tenants)
-        .filter((t: IXosTenantModel) => t.kind === 'coarse')
+      const links: IXosServiceGraphLink[] = _.chain(data.servicedependencys)
         .map((t: IXosTenantModel) => {
           return {
             id: t.id,