@@ -251,50 +251,6 @@ function getParamTypes(id, methodName) {
251251 return result ;
252252}
253253
254- /**
255- * @method checkResult
256- * @param {Object } params
257- * @returns {Boolean } true if conditions on ouput are compliant with the metamodel
258- * @private
259- * @description Check if conditions on output are compliant with the metamodel
260- */
261- function checkResult ( params ) {
262- params = params || { } ;
263-
264- var component = params . component || null ;
265- var methodName = params . methodName || '' ;
266- var methodResult = null ;
267- var componentClassName = '' ;
268- var returnType = null ;
269- var result = true ;
270-
271- if ( typeof params . methodResult !== 'undefined' ) {
272- methodResult = params . methodResult ;
273- } else {
274- methodResult = undefined ;
275- }
276-
277- if ( component . constructor . name === 'Function' ) {
278- componentClassName = component . name ;
279- } else {
280- componentClassName = component . constructor . name ;
281- }
282-
283- returnType = getReturnType ( componentClassName , methodName ) ;
284- if ( ! $metamodel . isValidType ( methodResult , returnType ) ) {
285- result = false ;
286- $log . invalidResultType (
287- component . id ( ) ,
288- component . constructor . name ,
289- methodName ,
290- JSON . stringify ( returnType ) ,
291- Array . isArray ( methodResult ) ? 'array' : typeof methodResult
292- ) ;
293- }
294-
295- return result ;
296- }
297-
298254/**
299255 * @method getActions
300256 * @param {Object } component a System Runtime component
@@ -464,14 +420,14 @@ function action(component, state, action, params, isEvent) {
464420/* Public methods */
465421
466422/**
467- * @method validParamNumbers
423+ * @method checkInputNumbers
468424 * @param {String } className name the class
469425 * @param {String } state state on which the action applied
470426 * @param {Function } action action
471427 * @returns {Boolean } true if the action is the valid number of parameters
472428 * @description Check if an action has the valid number of parameter
473429 */
474- exports . validParamNumbers = function validParamNumbers (
430+ exports . checkInputNumbers = function checkInputNumbers (
475431 className ,
476432 state ,
477433 action
@@ -545,12 +501,12 @@ exports.validParamNumbers = function validParamNumbers(
545501} ;
546502
547503/**
548- * @method checkParams
504+ * @method checkInput
549505 * @param {Object } params
550506 * @returns {Boolean } true if condition on input are compliant with the model
551507 * @description Check if conditions on input are compliant with the model before calling the action
552508 */
553- exports . checkParams = function checkParams ( params ) {
509+ exports . checkInput = function checkInput ( params ) {
554510 params = params || { } ;
555511
556512 var component = params . component || null ;
@@ -668,6 +624,49 @@ exports.checkParams = function checkParams(params) {
668624 return result ;
669625} ;
670626
627+ /**
628+ * @method checkOutput
629+ * @param {Object } params
630+ * @returns {Boolean } true if conditions on ouput are compliant with the metamodel
631+ * @description Check if conditions on output are compliant with the metamodel
632+ */
633+ exports . checkOutput = function checkOutput ( params ) {
634+ params = params || { } ;
635+
636+ var component = params . component || null ;
637+ var methodName = params . methodName || '' ;
638+ var methodResult = null ;
639+ var componentClassName = '' ;
640+ var returnType = null ;
641+ var result = true ;
642+
643+ if ( typeof params . methodResult !== 'undefined' ) {
644+ methodResult = params . methodResult ;
645+ } else {
646+ methodResult = undefined ;
647+ }
648+
649+ if ( component . constructor . name === 'Function' ) {
650+ componentClassName = component . name ;
651+ } else {
652+ componentClassName = component . constructor . name ;
653+ }
654+
655+ returnType = getReturnType ( componentClassName , methodName ) ;
656+ if ( ! $metamodel . isValidType ( methodResult , returnType ) ) {
657+ result = false ;
658+ $log . invalidResultType (
659+ component . id ( ) ,
660+ component . constructor . name ,
661+ methodName ,
662+ JSON . stringify ( returnType ) ,
663+ Array . isArray ( methodResult ) ? 'array' : typeof methodResult
664+ ) ;
665+ }
666+
667+ return result ;
668+ } ;
669+
671670/**
672671 * @method process
673672 * @param {Object } params params to process
@@ -768,7 +767,7 @@ exports.process = function process(params) {
768767
769768 if ( actions . length ) {
770769 if (
771- exports . checkParams ( {
770+ exports . checkInput ( {
772771 component : component ,
773772 methodName : params . state ,
774773 args : params . data
@@ -783,7 +782,7 @@ exports.process = function process(params) {
783782 false
784783 ) ;
785784
786- checkResult ( {
785+ exports . checkOutput ( {
787786 component : component ,
788787 methodName : params . state ,
789788 methodResult : result
0 commit comments