Name

sn_itom_licensing.ITOMVisibilityLicenseCounterFactoryStore

Description

No description available

Script

var ITOMVisibilityLicenseCounterFactoryStore = Class.create();
ITOMVisibilityLicenseCounterFactoryStore.prototype = {
  initialize: function() {},
  getCounter: function() {
      var smPluginActive = new GlidePluginManager().isActive('com.snc.service-mapping');
      var svcLicensingUtil = new global.SMLicensingUtilWrapper();
      var licenseUtil = new ITOMLicensingUtilsStore();

      if (smPluginActive && svcLicensingUtil && this._countLicensableServices()) {
          try {
              return new ITOMVisibilityLicenseCounterWithServicesStore();
          } catch (e) {
              gs.warn('Failed to initialize ITOMVisibilityLicenseCounterWithServices Script Include: ' + e);
          }
      }

      return new ITOMVisibilityLicenseCounterStore();

  },

  _countLicensableServices: function() {
      var licensableServiceTypes = gs.getProperty('itom.visibility.licensable_service_types', '');
      var ga = new GlideAggregate('cmdb_ci_service_discovered');
      var services = 0;
      if (ga.isValid()) {
          ga.addAggregate('COUNT');
          ga.addQuery('type', 'IN', licensableServiceTypes);
          ga.query();
          ga.next();
          services = parseInt(ga.getAggregate('COUNT'));
      }

      return services;
  },


  type: 'ITOMVisibilityLicenseCounterFactoryStore'
};

Sys ID

004c88c0b7c6301046df8985de11a991

Offical Documentation

Official Docs: