1 /* 2 * SIMPLICITE - runtime & framework 3 * http://www.simplicite.fr 4 * Copyright (c)2006-2013 Simplicite Software. All rights reserved. 5 */ 6 7 /** 8 * Get a new business process. 9 * <br/>Sample usage: 10 * <pre> 11 * // app is a Simplicite.Ajax instance 12 * var pcs = app.getBusinessProcess("MyProcess"); 13 * </pre> 14 * @param name Business process name 15 * @function 16 */ 17 Simplicite.Ajax.prototype.getBusinessProcess = function(name) { 18 return new Simplicite.Ajax.BusinessProcess(this, name); 19 }; 20 21 /** 22 * Simplicité® business process. 23 * <br/>Getting a new business process should use the <code>Simplicite.Ajax.getBusinessProcess()</code> function instead of this constructor 24 * @param app Application Simplicite.Ajax instance 25 * @param name Business process name 26 * @class 27 */ 28 Simplicite.Ajax.BusinessProcess = function(app, name) { 29 /** @ignore */ 30 this._app = app; 31 32 /** 33 * Current meta data. 34 * <ul> 35 * <li>name: object name</li> 36 * <li>TO BE COMPLETED...</li> 37 * </ul> 38 * @field 39 */ 40 this.metadata = { 41 name : name 42 }; 43 }; 44 45 /** 46 * Loads meta data. 47 * @param callback Callback function called when loading is completed 48 * @param params Optional parameters - async Asynchronous call (use default if absent) ? - error Custom error handler (use default error handler if absent) ? 49 * @function 50 */ 51 Simplicite.Ajax.BusinessProcess.prototype.getMetaData = function(callback, params) { 52 //var s = this._app; 53 //var url = s._pcsURL + "?action=metadata&process=" + this.metadata.name; 54 if (params === undefined) 55 params = new Object(); 56 // TODO : temporaire 57 /* 58 return s._call(params.async, url, undefined, function(r) { 59 if (r.type == "error") { 60 this.metadata = { name: this.name, instance: this.instance }; 61 if (params.error !== undefined) 62 params.error.call(this, r.response); 63 else 64 s.error(r.response); 65 } else { 66 */ 67 this.metadata.label = this.metadata.name;//this.metadata = r.response; 68 if (callback !== undefined) 69 callback.call(this); 70 /* 71 } 72 }, this); 73 */ 74 }; 75 76 /** 77 * Gets name from meta data. 78 * @function 79 */ 80 Simplicite.Ajax.BusinessProcess.prototype.getName = function() { 81 return this.metadata.name; 82 }; 83 84 /** 85 * Gets label name from meta data. 86 * @function 87 */ 88 Simplicite.Ajax.BusinessProcess.prototype.getLabel = function() { 89 return this.metadata.label; 90 }; 91 92 // TODO : to be completed 93 94