in dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js [142:388]
bindEvents: function() {
var that = this;
this.listenTo(this.collection, 'reset', function() {
this.entityObject = this.collection.first().toJSON();
var collectionJSON = this.entityObject.entity;
this.activeEntityDef = this.entityDefCollection.fullCollection.find({ name: collectionJSON.typeName });
if (!this.activeEntityDef) {
Utils.backButtonClick();
Utils.notifyError({
content: "Unknown Entity-Type"
});
return true;
}
if (collectionJSON && _.startsWith(collectionJSON.typeName, "AtlasGlossary")) {
this.$(".termBox").hide();
}
// MergerRefEntity.
Utils.findAndMergeRefEntity({
attributeObject: collectionJSON.attributes,
referredEntities: this.entityObject.referredEntities
});
Utils.findAndMergeRefEntity({
attributeObject: collectionJSON.relationshipAttributes,
referredEntities: this.entityObject.referredEntities
});
Utils.findAndMergeRelationShipEntity({
attributeObject: collectionJSON.attributes,
relationshipAttributes: collectionJSON.relationshipAttributes
});
// check if entity is process
var isProcess = false,
typeName = Utils.getName(collectionJSON, 'typeName'),
superTypes = Utils.getNestedSuperTypes({ data: this.activeEntityDef.toJSON(), collection: this.entityDefCollection }),
isLineageRender = _.find(superTypes, function(type) {
if (type === "DataSet" || type === "Process") {
if (type === "Process") {
isProcess = true;
}
return true;
}
});
if (!isLineageRender) {
isLineageRender = (typeName === "DataSet" || typeName === "Process") ? true : null;
}
if (collectionJSON && collectionJSON.guid) {
var tagGuid = collectionJSON.guid;
this.readOnly = Enums.entityStateReadOnly[collectionJSON.status];
} else {
var tagGuid = this.id;
}
if (this.readOnly) {
this.$el.addClass('readOnly');
} else {
this.$el.removeClass('readOnly');
}
if (collectionJSON) {
this.name = Utils.getName(collectionJSON);
if (collectionJSON.attributes) {
if (collectionJSON.typeName) {
collectionJSON.attributes.typeName = _.escape(collectionJSON.typeName);
}
if (this.name && collectionJSON.typeName) {
this.name = this.name + ' (' + _.escape(collectionJSON.typeName) + ')';
}
if (!this.name && collectionJSON.typeName) {
this.name = _.escape(collectionJSON.typeName);
}
this.description = collectionJSON.attributes.description;
if (this.name) {
this.ui.title.show();
var titleName = '<span>' + this.name + '</span>';
if (this.readOnly) {
titleName += '<button title="Deleted" class="btn btn-action btn-md deleteBtn"><i class="fa fa-trash"></i> Deleted</button>';
}
this.ui.title.html(titleName);
if (collectionJSON.attributes.serviceType === undefined) {
if (Globals.serviceTypeMap[collectionJSON.typeName] === undefined && this.activeEntityDef) {
Globals.serviceTypeMap[collectionJSON.typeName] = this.activeEntityDef.get('serviceType');
}
} else if (Globals.serviceTypeMap[collectionJSON.typeName] === undefined) {
Globals.serviceTypeMap[collectionJSON.typeName] = collectionJSON.attributes.serviceType;
}
var entityData = _.extend({ "serviceType": Globals.serviceTypeMap[collectionJSON.typeName], "isProcess": isProcess }, collectionJSON);
if (this.readOnly) {
this.ui.entityIcon.addClass('disabled');
} else {
this.ui.entityIcon.removeClass('disabled');
}
this.ui.entityIcon.attr('title', _.escape(collectionJSON.typeName)).html('<img src="' + Utils.getEntityIconPath({ entityData: entityData }) + '"/>').find("img").on('error', function() {
this.src = Utils.getEntityIconPath({ entityData: entityData, errorUrl: this.src });
});
} else {
this.ui.title.hide();
}
if (this.description) {
this.ui.description.show();
this.ui.description.html('<span>' + _.escape(this.description) + '</span>');
} else {
this.ui.description.hide();
}
}
var tags = {
'self': [],
'propagated': [],
'propagatedMap': {},
'combineMap': {}
};
if (collectionJSON.classifications) {
var tagObject = collectionJSON.classifications;
_.each(tagObject, function(val) {
var typeName = val.typeName;
if (val.entityGuid === that.id) {
tags['self'].push(val)
} else {
tags['propagated'].push(val);
if (tags.propagatedMap[typeName]) {
tags.propagatedMap[typeName]["count"]++;
} else {
tags.propagatedMap[typeName] = val;
tags.propagatedMap[typeName]["count"] = 1;
}
}
if (tags.combineMap[typeName] === undefined) {
tags.combineMap[typeName] = val;
}
});
tags.self = _.sortBy(tags.self, "typeName");
tags.propagated = _.sortBy(tags.propagated, "typeName");
this.generateTag(tags);
} else {
this.generateTag([]);
}
if (collectionJSON.relationshipAttributes && collectionJSON.relationshipAttributes.meanings) {
this.generateTerm(collectionJSON.relationshipAttributes.meanings);
}
if (Globals.entityTypeConfList && _.isEmptyArray(Globals.entityTypeConfList)) {
this.editEntity = true;
} else {
if (_.contains(Globals.entityTypeConfList, collectionJSON.typeName)) {
this.editEntity = true;
}
}
if (collectionJSON.attributes && collectionJSON.attributes.columns) {
var valueSorted = _.sortBy(collectionJSON.attributes.columns, function(val) {
return val.attributes && val.attributes.position
});
collectionJSON.attributes.columns = valueSorted;
}
}
this.hideLoader();
var obj = {
entity: collectionJSON,
guid: this.id,
entityName: this.name,
typeHeaders: this.typeHeaders,
tags: tags,
entityDefCollection: this.entityDefCollection,
fetchCollection: this.fetchCollection.bind(that),
enumDefCollection: this.enumDefCollection,
classificationDefCollection: this.classificationDefCollection,
glossaryCollection: this.glossaryCollection,
businessMetadataCollection: this.activeEntityDef.get('businessAttributeDefs'),
searchVent: this.searchVent,
attributeDefs: (function() {
return that.getEntityDef(collectionJSON);
})(),
editEntity: this.editEntity || false
}
obj["renderAuditTableLayoutView"] = function() {
that.renderAuditTableLayoutView(obj);
};
this.renderEntityDetailTableLayoutView(obj);
this.renderEntityUserDefineView(obj);
this.renderEntityLabelDefineView(obj);
if (obj.businessMetadataCollection) {
this.renderEntityBusinessMetadataView(obj);
}
this.renderRelationshipLayoutView(obj);
this.renderAuditTableLayoutView(obj);
this.renderTagTableLayoutView(obj);
if (Globals.isTasksEnabled && Globals.isUiTasksTabEnabled) { this.renderPendingTaskTableLayoutView(); }
// To render profile tab check for attribute "profileData" or typeName = "hive_db","hbase_namespace"
if (collectionJSON && (!_.isUndefined(collectionJSON.attributes['profileData']) || collectionJSON.typeName === "hive_db" || collectionJSON.typeName === "hbase_namespace")) {
if (collectionJSON.typeName === "hive_db" || collectionJSON.typeName === "hbase_namespace") {
this.$('.profileTab a').text("Tables")
}
this.$('.profileTab').show();
this.renderProfileLayoutView(_.extend({}, obj, {
entityDetail: collectionJSON.attributes,
profileData: collectionJSON.attributes.profileData,
typeName: collectionJSON.typeName,
value: that.value
}));
} else {
this.$('.profileTab').hide();
this.redirectToDefaultTab("profile");
}
if (this.activeEntityDef) {
//to display ReplicationAudit tab
if (collectionJSON && collectionJSON.typeName === "AtlasServer") {
this.$('.replicationTab').show();
this.renderReplicationAuditTableLayoutView(obj);
} else {
this.$('.replicationTab').hide();
this.redirectToDefaultTab("raudits");
}
// To render Schema check attribute "schemaElementsAttribute"
var schemaOptions = this.activeEntityDef.get('options');
var schemaElementsAttribute = schemaOptions && schemaOptions.schemaElementsAttribute;
if (!_.isEmpty(schemaElementsAttribute)) {
this.$('.schemaTable').show();
this.renderSchemaLayoutView(_.extend({}, obj, {
attribute: collectionJSON.relationshipAttributes[schemaElementsAttribute] || collectionJSON.attributes[schemaElementsAttribute]
}));
} else {
this.$('.schemaTable').hide();
this.redirectToDefaultTab("schema");
}
if (isLineageRender) {
this.$('.lineageGraph').show();
this.renderLineageLayoutView(_.extend(obj, {
processCheck: isProcess,
fetchCollection: this.fetchCollection.bind(this),
}));
} else {
this.$('.lineageGraph').hide();
this.redirectToDefaultTab("lineage");
}
}
}, this);
this.listenTo(this.collection, 'error', function(model, response) {
this.$('.fontLoader-relative').removeClass('show');
if (response.responseJSON) {
Utils.notifyError({
content: response.responseJSON.errorMessage || response.responseJSON.error
});
}
}, this);
},