Name

sn_cmp.CloudPatternBase

Description

No description available

Script

var CloudPatternBase = Class.create();
CloudPatternBase.prototype = {
  initialize: function() {},

  _getPatternForResource: function(resourceType) {
      var patternId = '';
      var resourceTypeGr = this._getResourceTypeGr(resourceType);
      if (!resourceTypeGr || !resourceTypeGr.get('name', resourceType))
          return null;
      patternId = resourceTypeGr.getValue('pattern');

      return patternId;
  },

  getPatternRecordForResource: function(resourceType) {
      var patternId = this._getPatternForResource(resourceType);
      if (gs.nil(patternId))
          return null;

      return this.getPatternRecord(patternId);
  },

  _getPatternId: function(resourceType) {
      var patternId = this._getPatternForResource(resourceType);
      /**
       * Adding this check for compatibility, where CPG(v. Paris and later) is installed and system has older version of patterns app
       * As few of the patterns mapping record in table 'sn_capi_resource_type'
       * are seeded as part of Cloud API.
       **/
      if (gs.nil(patternId) || !this._isPatternExists(patternId))
          patternId = '';

      return (gs.nil(patternId)) ? null : patternId;
  },

  _isPatternExists: function(patternId) {
      return !gs.nil(this.getPatternRecord(patternId));
  },

  getPatternRecord: function(patternId) {
      if (gs.tableExists('sa_pattern')) {
          var patternGr = new GlideRecord('sa_pattern');
          return (patternGr.get('sys_id', patternId)) ? patternGr : '';
      }
      return '';
  },

  _getResourceTypeGr: function(resourceType) {
      var resourceTypeGr = new GlideRecord('sn_capi_resource_type');
      if (resourceTypeGr.get('name', resourceType))
          return resourceTypeGr;
      return null;
  },

  type: 'CloudPatternBase'
};

Sys ID

6749e04f53b13010e79cddeeff7b12df

Offical Documentation

Official Docs: