diff --git a/frontend/app/components/api/api-v3/hal-resource-types-storage/hal-resource-types-storage.service.ts b/frontend/app/components/api/api-v3/hal-resource-factory/hal-resource-factory.service.ts similarity index 95% rename from frontend/app/components/api/api-v3/hal-resource-types-storage/hal-resource-types-storage.service.ts rename to frontend/app/components/api/api-v3/hal-resource-factory/hal-resource-factory.service.ts index be7881ba11..5e03dfaf58 100644 --- a/frontend/app/components/api/api-v3/hal-resource-types-storage/hal-resource-types-storage.service.ts +++ b/frontend/app/components/api/api-v3/hal-resource-factory/hal-resource-factory.service.ts @@ -30,7 +30,7 @@ import {opApiModule} from '../../../../angular-modules'; import {HalResource} from '../hal-resources/hal-resource.service'; -export class HalResourceTypesStorageService { +export class HalResourceFactoryService { private config:any = {}; public get defaultClass() { @@ -80,4 +80,4 @@ export class HalResourceTypesStorageService { } } -opApiModule.service('halResourceTypesStorage', HalResourceTypesStorageService); +opApiModule.service('halResourceFactory', HalResourceFactoryService); diff --git a/frontend/app/components/api/api-v3/hal-resource-types/hal-resource-types.service.test.ts b/frontend/app/components/api/api-v3/hal-resource-types/hal-resource-types.service.test.ts index 767634f0a6..73e8c3babb 100644 --- a/frontend/app/components/api/api-v3/hal-resource-types/hal-resource-types.service.test.ts +++ b/frontend/app/components/api/api-v3/hal-resource-types/hal-resource-types.service.test.ts @@ -28,11 +28,11 @@ import {opApiModule} from '../../../../angular-modules'; import {HalResourceTypesService} from './hal-resource-types.service'; -import {HalResourceTypesStorageService} from '../hal-resource-types-storage/hal-resource-types-storage.service'; +import {HalResourceFactoryService} from '../hal-resource-factory/hal-resource-factory.service'; describe('halResourceTypes service', () => { var halResourceTypes:HalResourceTypesService; - var halResourceTypesStorage:HalResourceTypesStorageService; + var halResourceFactory:HalResourceFactoryService; var config:any; var compareCls:typeof HalResource; @@ -49,20 +49,20 @@ describe('halResourceTypes service', () => { $provide.value('FooResource', FooResource); })); - beforeEach(angular.mock.inject(function (_halResourceTypes_, _halResourceTypesStorage_) { - [halResourceTypes, halResourceTypesStorage] = _.toArray(arguments); + beforeEach(angular.mock.inject(function (_halResourceTypes_, _halResourceFactory_) { + [halResourceTypes, halResourceFactory] = _.toArray(arguments); })); const expectResourceClassAdded = () => { it('should add the respective class object to the storage', () => { - const cls = halResourceTypesStorage.getResourceClassOfType('Other'); + const cls = halResourceFactory.getResourceClassOfType('Other'); expect(cls).to.equal(compareCls); }); }; const expectAttributeClassAdded = () => { it('should add the attribute type config to the storage', () => { - const cls = halResourceTypesStorage.getResourceClassOfAttribute('Other', 'attr'); + const cls = halResourceFactory.getResourceClassOfAttribute('Other', 'attr'); expect(cls).to.equal(compareCls); }); }; @@ -72,7 +72,7 @@ describe('halResourceTypes service', () => { }); it('should have added HalResource as the default type', () => { - expect(halResourceTypesStorage.defaultClass).to.equal(HalResource); + expect(halResourceFactory.defaultClass).to.equal(HalResource); }); describe('when configuring the type with class and attributes', () => { @@ -107,7 +107,7 @@ describe('halResourceTypes service', () => { describe('when configuring the type with only the attribute types', () => { beforeEach(() => { - compareCls = halResourceTypesStorage.defaultClass; + compareCls = halResourceFactory.defaultClass; config = { Other: { attr: 'Other' diff --git a/frontend/app/components/api/api-v3/hal-resource-types/hal-resource-types.service.ts b/frontend/app/components/api/api-v3/hal-resource-types/hal-resource-types.service.ts index 9a91c444cc..9423f814ba 100644 --- a/frontend/app/components/api/api-v3/hal-resource-types/hal-resource-types.service.ts +++ b/frontend/app/components/api/api-v3/hal-resource-types/hal-resource-types.service.ts @@ -27,13 +27,13 @@ // ++ import {opApiModule} from '../../../../angular-modules'; -import {HalResourceTypesStorageService} from '../hal-resource-types-storage/hal-resource-types-storage.service'; +import {HalResourceFactoryService} from '../hal-resource-factory/hal-resource-factory.service'; export class HalResourceTypesService { constructor(protected $injector, - protected halResourceTypesStorage:HalResourceTypesStorageService, + protected halResourceFactory:HalResourceFactoryService, HalResource) { - halResourceTypesStorage.defaultClass = HalResource; + halResourceFactory.defaultClass = HalResource; } public setResourceTypeConfig(config) { @@ -41,7 +41,7 @@ export class HalResourceTypesService { const value = config[typeName]; const result = { typeName: typeName, - className: value.className || this.getClassName(this.halResourceTypesStorage.defaultClass), + className: value.className || this.getClassName(this.halResourceFactory.defaultClass), attrTypes: value.attrTypes || {} }; @@ -57,13 +57,13 @@ export class HalResourceTypesService { }); types.forEach(typeConfig => { - this.halResourceTypesStorage + this.halResourceFactory .setResourceType(typeConfig.typeName, this.$injector.get(typeConfig.className)); }); types .forEach(typeConfig => { - this.halResourceTypesStorage.setResourceTypeAttributes(typeConfig.typeName, typeConfig.attrTypes); + this.halResourceFactory.setResourceTypeAttributes(typeConfig.typeName, typeConfig.attrTypes); }); } diff --git a/frontend/app/components/api/api-v3/hal-resources/hal-resource.service.test.ts b/frontend/app/components/api/api-v3/hal-resources/hal-resource.service.test.ts index 3df3397240..651339658b 100644 --- a/frontend/app/components/api/api-v3/hal-resources/hal-resource.service.test.ts +++ b/frontend/app/components/api/api-v3/hal-resources/hal-resource.service.test.ts @@ -28,11 +28,11 @@ import {opApiModule, opServicesModule} from '../../../../angular-modules'; import {HalResource} from './hal-resource.service'; -import {HalResourceTypesStorageService} from '../hal-resource-types-storage/hal-resource-types-storage.service'; +import {HalResourceFactoryService} from '../hal-resource-factory/hal-resource-factory.service'; describe('HalResource service', () => { var $httpBackend:ng.IHttpBackendService; - var halResourceTypesStorage:HalResourceTypesStorageService; + var halResourceFactory:HalResourceFactoryService; var resource; var source; @@ -43,9 +43,9 @@ describe('HalResource service', () => { $provide.value('OtherResource', OtherResource); })); beforeEach(angular.mock.inject(function (_$httpBackend_, - _halResourceTypesStorage_, + _halResourceFactory_, apiV3) { - [$httpBackend, halResourceTypesStorage] = _.toArray(arguments); + [$httpBackend, halResourceFactory] = _.toArray(arguments); apiV3.setDefaultHttpFields({cache: false}); })); @@ -54,7 +54,7 @@ describe('HalResource service', () => { }); it('should be instantiable using a default object', () => { - expect(new HalResource().href).to.equal(null); + expect(new HalResource().$href).to.equal(null); }); it('should set its source to _plain if _plain is a property of the source', () => { @@ -87,8 +87,8 @@ describe('HalResource service', () => { } }; - halResourceTypesStorage.setResourceType('Other', OtherResource); - halResourceTypesStorage.setResourceTypeAttributes('Other', { + halResourceFactory.setResourceType('Other', OtherResource); + halResourceFactory.setResourceTypeAttributes('Other', { someResource: 'Other' }); diff --git a/frontend/app/components/api/api-v3/hal-resources/hal-resource.service.ts b/frontend/app/components/api/api-v3/hal-resources/hal-resource.service.ts index a3d40a4ca4..9640340b88 100644 --- a/frontend/app/components/api/api-v3/hal-resources/hal-resource.service.ts +++ b/frontend/app/components/api/api-v3/hal-resources/hal-resource.service.ts @@ -28,20 +28,20 @@ import {opApiModule} from '../../../../angular-modules'; import {HalLinkInterface} from '../hal-link/hal-link.service'; -import {HalResourceTypesStorageService} from '../hal-resource-types-storage/hal-resource-types-storage.service'; +import {HalResourceFactoryService} from '../hal-resource-factory/hal-resource-factory.service'; const ObservableArray:any = require('observable-array'); var $q:ng.IQService; var lazy; var HalLink; -var halResourceTypesStorage:HalResourceTypesStorageService; +var halResourceFactory:HalResourceFactoryService; export class HalResource { public static _type:string; public static init(source:any) { - const resourceClass = halResourceTypesStorage.getResourceClassOfType(source._type); + const resourceClass = halResourceFactory.getResourceClassOfType(source._type); return new resourceClass(source); } @@ -50,7 +50,7 @@ export class HalResource { return element; } - const resourceClass = halResourceTypesStorage.getResourceClassOfType(element._type); + const resourceClass = halResourceFactory.getResourceClassOfType(element._type); return new resourceClass(element); } @@ -274,7 +274,7 @@ function initializeResource(halResource:HalResource) { var resource = HalResource.getEmptyResource(); resource._links.self = link; - const resourceClass = halResourceTypesStorage + const resourceClass = halResourceFactory .getResourceClassOfAttribute(halResource.constructor._type, linkName); return new resourceClass(resource, false); @@ -297,7 +297,7 @@ function initializeResource(halResource:HalResource) { } function halResourceService(...args) { - [$q, lazy, HalLink, halResourceTypesStorage] = args; + [$q, lazy, HalLink, halResourceFactory] = args; return HalResource; } @@ -305,7 +305,7 @@ halResourceService.$inject = [ '$q', 'lazy', 'HalLink', - 'halResourceTypesStorage' + 'halResourceFactory' ]; opApiModule.factory('HalResource', halResourceService);