231 lines
9.9 KiB
JavaScript
231 lines
9.9 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Value object for system entity.
|
|
*
|
|
* @author Igor Samulenko
|
|
* @constructor
|
|
*/
|
|
function EntityVO() {
|
|
this.entityId = '';
|
|
this.type = '';
|
|
this.displayValue = '';
|
|
this.classId = null;
|
|
//derived fields
|
|
this.entityLink = '';
|
|
}
|
|
/**
|
|
* Setup inheritance chain.
|
|
*/
|
|
EntityVO.prototype = Object.create(BaseVO.prototype);
|
|
EntityVO.prototype.constructor = EntityVO;
|
|
/**
|
|
* Constants section.
|
|
* Read-only state will be enforced later.
|
|
*/
|
|
EntityVO.TYPE_ASSET = 'asset';
|
|
EntityVO.TYPE_TICKET = 'ticket';
|
|
EntityVO.TYPE_INCIDENT = 'incident';
|
|
EntityVO.TYPE_SERVICEREQUEST = 'request';
|
|
EntityVO.TYPE_SBEREQUEST = 'sberequest';
|
|
EntityVO.TYPE_SLM = 'slm';
|
|
EntityVO.TYPE_WORKORDER = 'workorder';
|
|
EntityVO.TYPE_TASK = 'task';
|
|
EntityVO.TYPE_KNOWLEDGE = 'knowledge';
|
|
EntityVO.TYPE_PERSON = 'person';
|
|
EntityVO.TYPE_SMARTRECORDER = 'smartRecorder';
|
|
EntityVO.TYPE_ORGANIZATION = 'organization';
|
|
EntityVO.TYPE_DEPARTMENT = 'department';
|
|
EntityVO.TYPE_REGION = 'region';
|
|
EntityVO.TYPE_SITE_GROUP = 'sitegroup';
|
|
EntityVO.TYPE_SITE = 'site';
|
|
EntityVO.TYPE_SUPPORTGROUP = 'supportgroup';
|
|
EntityVO.TYPE_COMPANY = 'company';
|
|
EntityVO.TYPE_BROADCAST = 'broadcast';
|
|
EntityVO.TYPE_OUTAGE = 'outage';
|
|
EntityVO.TYPE_CONTRACT = 'contract';
|
|
EntityVO.TYPE_PRIORITY = 'priority';
|
|
EntityVO.TYPE_CALCULATED_PRIORITY = 'calculatedPriority';
|
|
EntityVO.TYPE_SELECTED_URGENCY = 'selectedUrgency';
|
|
EntityVO.TYPE_SELECTED_IMPACT = 'selectedImpact';
|
|
EntityVO.TYPE_SELECTED_STATUS = 'selectedStatus';
|
|
EntityVO.TYPE_STATUS = 'status';
|
|
EntityVO.TYPE_STATUS_REASON = 'statusReason';
|
|
EntityVO.TYPE_MILESTONE = 'milestone';
|
|
EntityVO.TYPE_IMPACT = 'impact';
|
|
EntityVO.TYPE_URGENCY = 'urgency';
|
|
EntityVO.TYPE_TEXT = 'text';
|
|
EntityVO.TYPE_TIME = 'time';
|
|
EntityVO.TYPE_TIMESTAMP = 'timestamp';
|
|
EntityVO.TYPE_CHANGE = 'change';
|
|
EntityVO.TYPE_KNOWNERROR = 'knownerror';
|
|
EntityVO.TYPE_PROBLEM = 'problem';
|
|
EntityVO.TYPE_PEOPLE = 'people';
|
|
EntityVO.TYPE_EMAIL_LINK = 'email';
|
|
EntityVO.TYPE_INTEGER = 'integer';
|
|
EntityVO.TYPE_RISKQUESTION = 'riskquestion';
|
|
EntityVO.TYPE_REPORTS = 'reports';
|
|
EntityVO.TYPE_HELIX_DASHBOARD = 'helixdashboard';
|
|
EntityVO.TYPE_GLOBAL = 'global';
|
|
EntityVO.TYPE_SMART_RECORDER = 'smartrecorder';
|
|
EntityVO.TYPE_BUSINESS_EVENT = 'businessevent';
|
|
EntityVO.TYPE_DLP = 'dlp';
|
|
EntityVO.TYPE_RELEASE = 'release';
|
|
EntityVO.TYPE_ACTIVITY = 'activity';
|
|
EntityVO.TYPE_URL = 'url';
|
|
EntityVO.TYPE_CALL_LOG = 'callLog';
|
|
EntityVO.TYPE_LIVE_CHAT = 'eschat';
|
|
EntityVO.TYPE_ITSM_INSIGHTS = 'itsminsights';
|
|
EntityVO.TYPE_OUTAGE_TYPE = 'outage-type';
|
|
EntityVO.TICKET_TYPES = [EntityVO.TYPE_INCIDENT, EntityVO.TYPE_WORKORDER, EntityVO.TYPE_TASK, EntityVO.TYPE_SERVICEREQUEST, EntityVO.TYPE_CHANGE, EntityVO.TYPE_PROBLEM, EntityVO.TYPE_KNOWNERROR, EntityVO.TYPE_RELEASE];
|
|
EntityVO.ALL_TYPES = [EntityVO.TYPE_INCIDENT, EntityVO.TYPE_WORKORDER, EntityVO.TYPE_TASK, EntityVO.TYPE_SERVICEREQUEST, EntityVO.TYPE_CHANGE, EntityVO.TYPE_ASSET, EntityVO.TYPE_OUTAGE, EntityVO.TYPE_PROBLEM, EntityVO.TYPE_KNOWNERROR, EntityVO.TYPE_DLP, EntityVO.TYPE_RELEASE, EntityVO.TYPE_ACTIVITY];
|
|
EntityVO.ENTITIES_WITH_APPROVALS = [EntityVO.TYPE_CHANGE, EntityVO.TYPE_RELEASE];
|
|
EntityVO.ENTITIES_HAVE = {
|
|
approvals: [EntityVO.TYPE_CHANGE, EntityVO.TYPE_RELEASE],
|
|
attachments: [EntityVO.TYPE_INCIDENT, EntityVO.TYPE_WORKORDER, EntityVO.TYPE_TASK, EntityVO.TYPE_CHANGE, EntityVO.TYPE_PROBLEM, EntityVO.TYPE_RELEASE],
|
|
metadata: [EntityVO.TYPE_ASSET, EntityVO.TYPE_INCIDENT, EntityVO.TYPE_WORKORDER, EntityVO.TYPE_TASK, EntityVO.TYPE_SERVICEREQUEST, EntityVO.TYPE_OUTAGE, EntityVO.TYPE_BROADCAST, EntityVO.TYPE_CHANGE, EntityVO.TYPE_PROBLEM, EntityVO.TYPE_RELEASE]
|
|
};
|
|
EntityVO.ENTITIES_WITH_NEW_CUSTOMIZATION = [EntityVO.TYPE_INCIDENT, EntityVO.TYPE_CHANGE, EntityVO.TYPE_WORKORDER, EntityVO.TYPE_TASK];
|
|
//todo: move this out of entity VO, it is rather RelationVO
|
|
EntityVO.TYPE_RESOURCE = 'resource';
|
|
EntityVO.TYPE_LINKEDITEM = 'linkeditem';
|
|
EntityVO.TYPE_RELATEDTO = 'relatedto';
|
|
EntityVO.TYPE_DUPLICATEOF = 'duplicateof';
|
|
EntityVO.TYPE_ORIGINALOF = 'originalof';
|
|
EntityVO.TYPE_CAUSED = 'caused';
|
|
EntityVO.TYPE_CAUSEDBY = 'causedby';
|
|
EntityVO.TYPE_CHANGEDBY = 'changedby';
|
|
EntityVO.TYPE_INSTALLEDBY = 'installedby';
|
|
EntityVO.TYPE_MOVEDBY = 'movedby';
|
|
EntityVO.TYPE_REMOVEDBY = 'removedby';
|
|
EntityVO.TYPE_REPAIREDBY = 'repairedby';
|
|
EntityVO.TYPE_UPGRADEDBY = 'upgradedby';
|
|
EntityVO.TYPE_RESOLVED = 'resolved';
|
|
EntityVO.TYPE_RESOLVEDBY = 'resolvedby';
|
|
EntityVO.TYPE_IMPACTS = 'impacts';
|
|
EntityVO.TYPE_IMPACTEDBY = 'impactedby';
|
|
EntityVO.TYPE_RESTORES = 'restores';
|
|
EntityVO.TYPE_RESTOREDBY = 'restoredby';
|
|
EntityVO.TYPE_REOPENEDFROM = 'reopenedfrom';
|
|
EntityVO.TYPE_REOPENEDBY = 'reopenedby';
|
|
EntityVO.TYPE_USEDBY = 'usedby';
|
|
EntityVO.TYPE_CORRECTEDBY = 'correctedby';
|
|
EntityVO.TYPE_CREATED = 'created';
|
|
EntityVO.TYPE_INVESTIGATEDBY = 'investigatedby';
|
|
EntityVO.TYPE_COMPONENT = 'component';
|
|
EntityVO.TYPE_DEPENDENCY = 'dependency';
|
|
EntityVO.TYPE_IMPACT = 'impact';
|
|
EntityVO.TYPE_MEMBEROFCOLLECTION = 'memberofcollection';
|
|
EntityVO.TYPE_HOSTEDSYSTEMCOMPONENTS = 'hostedsystemcomponents';
|
|
EntityVO.TYPE_HOSTEDACCESSPOINT = 'hostedaccesspoint';
|
|
EntityVO.TYPE_HOSTEDSERVICE = 'hostedservice';
|
|
EntityVO.TYPE_ACCOUNTONSYSTEM = 'accountonsystem';
|
|
EntityVO.TYPE_ELEMENTLOCATION = 'elementlocation';
|
|
EntityVO.TYPE_SETTINGSOF = 'settingsof';
|
|
EntityVO.TYPE_ALLRELATED = 'allrelated';
|
|
EntityVO.TYPE_PEOPLETYPE = 'peopleType';
|
|
EntityVO.TYPE_SOFTWARE = 'Software';
|
|
EntityVO.TYPE_HARDWARE = 'Hardware';
|
|
EntityVO.TYPE_BUSINESSSERVICE = 'Business Service';
|
|
EntityVO.TYPE_NETWORK = 'Network';
|
|
EntityVO.TYPE_OTHER = 'OTHER';
|
|
EntityVO.FIELD_CHANGE_RISK = 'changeRisk';
|
|
EntityVO.FIELD_CHANGE_PRIORITY = 'priority';
|
|
EntityVO.FIELD_RISK_LEVEL = 'riskLevel';
|
|
EntityVO.WIDGET_IMPACTED_AREAS = 'impactedAreas';
|
|
EntityVO.FIELD_REQUESTED_BY_COMPANY = 'requestedByCompany';
|
|
EntityVO.ACTION_REOPEN = 'reopen';
|
|
EntityVO.ACTION_REQUESTAGAIN = 'requestagain';
|
|
EntityVO.ACTION_CANCEL = 'cancel';
|
|
EntityVO.ACTION_DUPLICATE = 'duplicate';
|
|
/*SocialProfileVO profile types*/
|
|
EntityVO.SOCIAL_PROFILE_USER = 'user';
|
|
EntityVO.SOCIAL_PROFILE_ASSET = 'asset';
|
|
EntityVO.SOCIAL_PROFILE_LOCATION = 'location';
|
|
EntityVO.SOCIAL_PROFILE_SERVICE = 'service';
|
|
EntityVO.SOCIAL_PROFILE_GROUP = 'group';
|
|
EntityVO.SOCIAL_PROFILE_APP = 'application';
|
|
EntityVO.CATEGORY_OPERATIONAL = 'operational';
|
|
EntityVO.CATEGORY_PRODUCT = 'product';
|
|
EntityVO.CATEGORY_RESOLUTION = 'resolution';
|
|
EntityVO.CATEGORY_RESOLUTION_PRODUCT = 'resolutionProduct';
|
|
//ChatOps
|
|
EntityVO.CHATOPS_DETAILS = '/details';
|
|
EntityVO.CHATOPS_KNOWLEDGE = '/knowledge';
|
|
EntityVO.CHATOPS_SIMILARINCIDENTS = '/similarincidents';
|
|
EntityVO.CHATOPS_TOOLS = '/?';
|
|
EntityVO.CHATOPS_INCIDENT = '/incident';
|
|
EntityVO.CHATOPS_INCIDENTDETAILS = "/incidentDetails";
|
|
EntityVO.CHATOPS_LINKKNOWLEDGE = "/linkKnowledge";
|
|
EntityVO.CHATOPS_ERROR = "/error";
|
|
EntityVO.CHATOPS_SWARM = "/swarm";
|
|
//Status
|
|
EntityVO.STATUS_CLOSED = 'closed';
|
|
EntityVO.STATUS_RESOLVED = 'resolved';
|
|
EntityVO.STATUS_IN_PROGRESS = 'Work In Progress';
|
|
EntityVO.STATUS_DRAFT = 'Draft';
|
|
EntityVO.STATUS_CONTENT_REVIEW = 'Optional Review 1';
|
|
EntityVO.STATUS_SME_REVIEW = 'SME Review';
|
|
EntityVO.STATUS_IN_INVENTORY = 'In Inventory';
|
|
EntityVO.CHAT_STATUS_ONLINE = 'online';
|
|
EntityVO.CHAT_STATUS_AWAY = 'away';
|
|
EntityVO.CHAT_STATUS_OFFLINE = 'offline';
|
|
EntityVO.APPROVAL_STATUS_REJECTED = 'Rejected';
|
|
EntityVO.APPROVAL_STATUS_APPROVED = 'Approved';
|
|
EntityVO.APPROVAL_STATUS_HOLD = 'Hold';
|
|
EntityVO.APPROVAL_STATUS_PENDING = 'Pending';
|
|
EntityVO.APPROVAL_STATUS_MORE_INFO = 'More Information';
|
|
EntityVO.PENDING_APPROVAL_STATUSES_LIST = [EntityVO.APPROVAL_STATUS_HOLD, EntityVO.APPROVAL_STATUS_PENDING, EntityVO.APPROVAL_STATUS_MORE_INFO];
|
|
EntityVO.APPROVAL_ACTIONS = [{ name: 'approve', statusLabel: EntityVO.APPROVAL_STATUS_APPROVED }, { name: 'reject', statusLabel: EntityVO.APPROVAL_STATUS_REJECTED }, { name: 'hold', statusLabel: EntityVO.APPROVAL_STATUS_HOLD }];
|
|
EntityVO.FILTER_TYPE_TICKETS = 'tickets';
|
|
EntityVO.FILTER_TYPE_PERSON = 'person';
|
|
EntityVO.FILTER_TYPE_ASSET = 'asset';
|
|
EntityVO.FILTER_TYPE_KNOWLEDGE = 'knowledge';
|
|
EntityVO.COGNITIVE_SG_APPLY_AUTO = 'Apply Automatically';
|
|
EntityVO.COGNITIVE_SG_SHOW_RECOMMENDATION = 'Show Recommendation';
|
|
EntityVO.COGNITIVE_SG_NO = 'No';
|
|
/**
|
|
* @override
|
|
* @return {Array}
|
|
*/
|
|
EntityVO.prototype.getProps = function () {
|
|
return ['entityId', 'type', 'displayValue', 'classId'];
|
|
};
|
|
/**
|
|
* @override
|
|
*/
|
|
EntityVO.prototype.postBuild = function () {
|
|
if (this.type === EntityVO.TYPE_EMAIL_LINK) {
|
|
this.entityLink = 'mailto:' + this.displayValue;
|
|
}
|
|
else if (this.type === EntityVO.TYPE_INTEGER) {
|
|
this.entityLink = 'javascript:void(0)'; //jshint ignore:line
|
|
}
|
|
else if (this.type === EntityVO.TYPE_ASSET) {
|
|
this.entityLink = '#/' + this.type + '/' + encodeURIComponent(this.entityId) + '/' + this.classId;
|
|
}
|
|
else if (this.type === EntityVO.TYPE_URL) {
|
|
this.entityLink = decodeURIComponent(this.entityId);
|
|
}
|
|
else {
|
|
this.entityLink = '#/' + this.type + '/' + encodeURIComponent(this.entityId);
|
|
}
|
|
};
|
|
//TODO: Create generic method which will be handling "instance has" flags
|
|
EntityVO.entityHas = function (featureName, type) {
|
|
if (featureName) {
|
|
var entitiesHaveFeature = this.ENTITIES_HAVE[featureName];
|
|
}
|
|
return _.includes(entitiesHaveFeature || [], type);
|
|
};
|
|
EntityVO.hasApprovalsFlow = function (type) {
|
|
return this.entityHas('approvals', type);
|
|
};
|
|
EntityVO.hasMetadata = function (type) {
|
|
var entitiesWithMetadata = [this.TYPE_ASSET, this.TYPE_INCIDENT, this.TYPE_WORKORDER, this.TYPE_TASK, this.TYPE_SERVICEREQUEST, this.TYPE_OUTAGE, this.TYPE_KNOWLEDGE, EntityVO.TYPE_BROADCAST, EntityVO.TYPE_CHANGE, EntityVO.TYPE_PROBLEM, EntityVO.TYPE_KNOWNERROR, EntityVO.TYPE_RELEASE, EntityVO.TYPE_ACTIVITY];
|
|
return _.includes(entitiesWithMetadata, type);
|
|
};
|
|
EntityVO.hasAttachments = function (type) {
|
|
var entitiesWithAttachments = [this.TYPE_INCIDENT, this.TYPE_WORKORDER, this.TYPE_TASK, this.TYPE_RELEASE, this.TYPE_CHANGE, this.TYPE_PROBLEM, this.TYPE_KNOWNERROR];
|
|
return _.includes(entitiesWithAttachments, type);
|
|
};
|