Author: ygrego Date: 2015-05-06 14:17:10 +0000 (Wed, 06 May 2015) New Revision: 1323 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1323 Log: Addition of new class giving access to severals globals objects or permit to obtain new object like an instance of Recording, MetadataManager, ... Added: oipf/js/impl/model/ModelFactory.js Added: oipf/js/impl/model/ModelFactory.js =================================================================== --- oipf/js/impl/model/ModelFactory.js (rev 0) +++ oipf/js/impl/model/ModelFactory.js 2015-05-06 14:17:10 UTC (rev 1323) @@ -0,0 +1,65 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +var ModelFactory = Class.extend({ + + init: function(metadataObject) { + this.metadataObject = metadataObject; + this.metadaManager = null; + this.xmlTvData = null; + this.createXmlTvData(); + }, + + createXmlTvData: function() { + + return this.return("xmlTvData") || + this.setProperty("xmlTvData", + new XmlTvData(this.metadataObject)); + + }, + + getXmlTvData: function() { + return this.xmlTvData; + }, + + + /* + * FIXME: Yannis - 06/05/2015 - Get a method to find an available number for + * randomIndex. + */ + getAProgrammeFromXmlTvData: function() { + + var randomIndex = 150; + + if (this.xmlTvData && this.xmlTvData.programmes[randomIndex]) { + return this.xmlTvData.programmes[15]; + } + + }, + + createScheduledRecording: function() { + return new ScheduledRecording(this.getAPrgrammeFromXmlTvData()); + }, + + createRecording: function() { + return new Recording(this.createScheduledRecording()); + }, + + createMetadataManager: function() { + return this.return("metadaManager") || + this.setProperty("metadaManager", + new MetadataManager()); + }, + + getProperty: function(propertyName) { + return this[propertyName]; + }, + + setProperty: function(propertyName, value) { + this[propertyName] = value; + } + +});
participants (1)
-
ygregoï¼ users.nuiton.org