Name

global.DiscoverySensorJob

Description

A Discovery - Sensor async job that calls the SensorProcessor.

Script

var DiscoverySensorJob = Class.create();
DiscoverySensorJob.prototype = {
  initialize: function() {
  },
  
  process: function() {
  	
  	// when TransactionCancelledException is thrown the global.current variable is set to undefined depending on where
  	// (horizontal discovery sensor, pre sensor script) the exception is thrown. The reason is unknown and to avoid issues
  	// with updating discovery completed count, we are passing current as a local variable when calling runSensor().
  	this.runSensor(current);
  
  },
  
  runSensor: function(current) {
  	var completed;
  	var duplicate;
  	try {
  		gs.getSession().putProperty("disable.labels", true);

  		var sp = new SncSensorProcessor(current);
  		completed = sp.process();

  		// Check whether DiscoveryPageManager is available to the plugin, if it's not then we don't need to handle it
  		var pageManagerAvailable = (typeof DiscoveryPageManager !== 'undefined');

  		if (pageManagerAvailable && completed) {
  			/*
  			* In case SensorProcessor have processed an input, we let DiscoveryPageManager decide whether the entire
  			* pagination was done.
  			* A single input can be a part of a larger discovery containing multipages or a paginated pattern and
  			* SensorProcessor has a view of the multipage proces, but not on a paginated discovery
  			*/
  			var isPaginationOver = DiscoveryPageManager.isPaginationFinished(current.response_to + '', current.getValue('sys_id'));

  			if (isPaginationOver)
  				DiscoveryPatternOrchestratorEventHandler.onPatternExecutionCompleted(current.agent_correlator + '', current.response_to + '');

  			/*
  			* The 'completed' variable is one of the keys for increasing the 'Completed' count on a status
  			* We need to increase the discovert status's 'Completed' count when we are done with ALL pages
  			* of a single execution [multipages or pages coming as part of a paginated pattern]
  			*/
  			completed = isPaginationOver;
  		}

  		duplicate = sp.isDuplicate();

  	} catch(e) {
  		gs.logError("SensorProcessor failed for ECC queue record "+current.sys_id+" - "+e);
  		// Don't want this record to sit in ready state:
  		if (current.state != "processed") {
  			current.state = "error";
  			current.error_string = "Exception during sensor processing: "+e;
  			current.setWorkflow(false);
  			current.update(); 
  			current.setWorkflow(true);
  		}
  		completed = true;
  	}
  	finally {
  		// Update "completed" count for discovery status

  		/*
  		* PRB945908: do not updated completed count if this
  		* input record was a duplicate of one already processed
  		*/
  		if (completed && !duplicate) {
  			DiscoveryStatus.updateStatusCompletedCount(current.agent_correlator);
  		}
  	}

  	// Let the LabelEngine do it's job
  	gs.getSession().clearProperty("disable.labels");
  },

  type: 'DiscoverySensorJob'
};

Sys ID

78dfb2dd536002001f175f43911c087d

Offical Documentation

Official Docs: