[CORD-1927] Fixing generate url for service models

Change-Id: I08d0d853ba2ab041626e133d079ab4562d73171e
(cherry picked from commit 6349847ecd1040111de5e7def26304e9e093cb92)
diff --git a/src/app/datasources/helpers/store.helpers.ts b/src/app/datasources/helpers/store.helpers.ts
index 83c3b9a..0df37c7 100644
--- a/src/app/datasources/helpers/store.helpers.ts
+++ b/src/app/datasources/helpers/store.helpers.ts
@@ -18,27 +18,26 @@
 
 import {BehaviorSubject} from 'rxjs';
 import * as _ from 'lodash';
-import * as pluralize from 'pluralize';
 import {IWSEvent} from '../websocket/global';
 import {IXosResourceService} from '../rest/model.rest';
+import {IXosModeldefsCache} from './modeldefs.service';
 
 export interface IStoreHelpersService {
-  urlFromCoreModel(name: string): string;
   updateCollection(event: IWSEvent, subject: BehaviorSubject<any>): BehaviorSubject<any>;
 }
 
 export class StoreHelpers implements IStoreHelpersService {
-  static $inject = ['ModelRest'];
+  static $inject = [
+    'ModelRest',
+    'XosModeldefsCache'
+  ];
 
   constructor (
-    private modelRest: IXosResourceService
+    private modelRest: IXosResourceService,
+    private XosModeldefsCache: IXosModeldefsCache
   ) {
   }
 
-  public urlFromCoreModel(name: string): string {
-    return `/core/${pluralize(name.toLowerCase())}`;
-  }
-
   public updateCollection(event: IWSEvent, subject: BehaviorSubject<any>): BehaviorSubject<any> {
     const collection: any[] = subject.value;
     const index: number = _.findIndex(collection, (i) => {
@@ -49,7 +48,8 @@
     const isDeleted: boolean = _.includes(event.msg.changed_fields, 'deleted');
 
     // generate a resource for the model
-    const endpoint = this.urlFromCoreModel(event.model);
+    const modelDef = this.XosModeldefsCache.get(event.model); // get the model definition
+    const endpoint = this.XosModeldefsCache.getApiUrlFromModel(modelDef);
     const resource = this.modelRest.getResource(endpoint);
     const model = new resource(event.msg.object);