Name
sn_cmp.CmpCommonsUtil
Description
Holds the common methods to perform basic validation
Script
var CmpCommonsUtil = Class.create();
CmpCommonsUtil.prototype = {
initialize: function () { },
optFieldFromArray: function (objectArray, index, fieldName, defaultValue) {
var value;
if (objectArray && this._isNonEmptyArray(objectArray) && this._isFieldExists(objectArray[index], fieldName))
value = this._getField(objectArray[index], fieldName);
else
value = defaultValue;
return value;
},
optField: function (testObject, fieldName, defaultValue) {
var value;
if (testObject && this._isFieldExists(testObject, fieldName))
value = this._getField(testObject, fieldName);
else
value = defaultValue;
return value;
},
_isNonEmptyArray: function (testObject) {
return !(testObject.propertyIsEnumerable('length')) &&
typeof testObject === 'object' && typeof testObject.length === 'number' && testObject.length > 0;
},
_isFieldExists: function (testObject, fieldName) {
return testObject.hasOwnProperty(fieldName);
},
_getField: function (testObject, fieldName) {
return testObject[fieldName];
},
type: 'CmpCommonsUtil'
};
CmpCommonsUtil.useNewHardwareTable = function() {
if(gs.getProperty('sn_itom_pattern.use a single hardware type for cloud data centers') == 'true')
return true;
return false;
};
Sys ID
73f37d9753573300d53bddeeff7b1219