Name
sn_grc.IGItemToEntityActionHandler
Description
No description available
Script
var IGItemToEntityActionHandler = Class.create();
IGItemToEntityActionHandler.prototype = {
initialize: function(action, strategy) {
this.actionType = action.action + '';
this.source = action.source;
this.sourceTable = action.table;
this.entityId = action.entity_id + '';
this.itemId = action.item_id + '';
this.strategy = strategy;
this.RELIANT_ENTITY_TO_ITEM_EXT_POINT = "sn_grc.ReliantEntityToItemAssociationExtPoint";
},
execute: function() {
if (gs.nil(this.entityId) || gs.nil(this.itemId)) {
return;
}
if (gs.nil(this.strategy.getItemToEntityTable())) return;
if (gs.nil(this.strategy.itemTable)) return;
switch (this.actionType) {
case 'add_entity_to_item':
this._addEntityToItem();
break;
case 'activate_entity_to_item':
this._activateEntityToItem();
break;
case 'remove_entity_from_item':
this._removeEntityFromItem();
break;
case 'deactivate_entity_to_item':
this._deactivateEntityToItem();
break;
}
},
_addEntityToItem: function() {
try {
var extensionPoints = new GlideScriptedExtensionPoint().getExtensions(this.RELIANT_ENTITY_TO_ITEM_EXT_POINT);
for (var i = 0; i < extensionPoints.length; i++) {
var extensionPoint = extensionPoints[i];
if (extensionPoint.handles(this.strategy.itemTable)) {
extensionPoint.addReliantEntityToItem(this.entityId, this.itemId);
}
}
} catch (e) {
gs.error("Unable to run addReliantEntityToItem method on the extension point " + this.RELIANT_ENTITY_TO_ITEM_EXT_POINT);
}
},
_activateEntityToItem: function() {
try {
var extensionPoints = new GlideScriptedExtensionPoint().getExtensions(this.RELIANT_ENTITY_TO_ITEM_EXT_POINT);
for (var i = 0; i < extensionPoints.length; i++) {
var extensionPoint = extensionPoints[i];
if (extensionPoint.handles(this.strategy.itemTable)) {
extensionPoint.activateReliantEntityToItemAssociation(this.entityId, this.itemId);
}
}
} catch (e) {
gs.error("Unable to run activateReliantEntityToItemAssociation method on the extension point " + this.RELIANT_ENTITY_TO_ITEM_EXT_POINT);
}
},
_removeEntityFromItem: function() {
try {
var extensionPoints = new GlideScriptedExtensionPoint().getExtensions(this.RELIANT_ENTITY_TO_ITEM_EXT_POINT);
for (var i = 0; i < extensionPoints.length; i++) {
var extensionPoint = extensionPoints[i];
if (extensionPoint.handles(this.strategy.itemTable)) {
extensionPoint.removeReliantEntityFromItem(this.entityId, this.itemId);
}
}
} catch (e) {
gs.error("Unable to run removeReliantEntityFromItem method on the extension point " + this.RELIANT_ENTITY_TO_ITEM_EXT_POINT);
}
},
_deactivateEntityToItem: function() {
try {
var extensionPoints = new GlideScriptedExtensionPoint().getExtensions(this.RELIANT_ENTITY_TO_ITEM_EXT_POINT);
for (var i = 0; i < extensionPoints.length; i++) {
var extensionPoint = extensionPoints[i];
if (extensionPoint.handles(this.strategy.itemTable)) {
extensionPoint.deactivateReliantEntityToItemAssociation(this.entityId, this.itemId);
}
}
} catch (e) {
gs.error("Unable to run deactivateReliantEntityToItemAssociation method on the extension point " + this.RELIANT_ENTITY_TO_ITEM_EXT_POINT);
}
},
type: 'IGItemToEntityActionHandler'
};
Sys ID
68e7f2327756111063533b53fe5a995b