in dashboardv3/public/js/views/search/SearchResultLayoutView.js [768:1060]
getFixedDslColumn: function() {
var that = this,
nameCheck = 0,
columnToShow = null,
col = {};
this.value = Utils.getUrlState.getQueryParams() || this.value;
if (this.value && this.value.searchType === "basic" && this.searchTableColumns && (this.searchTableColumns[this.value.type || this.value.tag] !== undefined)) {
columnToShow = this.searchTableColumns[this.value.type || this.value.tag] == null ? [] : this.searchTableColumns[this.value.type || this.value.tag];
}
col['Check'] = {
name: "selected",
label: "Select",
cell: "select-row",
resizeable: false,
orderable: false,
alwaysVisible: true, //Backgrid.ColumnManager.js -> render() to hide the name in dropdownlist
renderable: (columnToShow ? _.contains(columnToShow, 'selected') : true),
headerCell: "select-all"
};
col['name'] = {
label: this.value && this.profileDBView ? "Table Name" : "Name",
cell: "html",
editable: false,
resizeable: true,
orderable: false,
renderable: true,
sortable: true,
className: "searchTableName",
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON(),
nameHtml = "",
name = Utils.getName(obj);
if (!obj.attributes || obj.attributes.serviceType === undefined) {
if (Globals.serviceTypeMap[obj.typeName] === undefined && that.entityDefCollection) {
var defObj = that.entityDefCollection.fullCollection.find({ name: obj.typeName });
if (defObj) {
Globals.serviceTypeMap[obj.typeName] = defObj.get('serviceType');
}
}
} else if (Globals.serviceTypeMap[obj.typeName] === undefined) {
Globals.serviceTypeMap[obj.typeName] = obj.attributes ? obj.attributes.serviceType : null;
}
obj.serviceType = Globals.serviceTypeMap[obj.typeName];
if (obj.guid) {
if (obj.guid == "-1") {
nameHtml = '<span title="' + name + '">' + name + '</span>';
} else {
nameHtml = '<a title="' + name + '" href="#!/detailPage/' + obj.guid + (that.fromView ? "?from=" + that.fromView : "") + '">' + name + '</a>';
}
} else {
nameHtml = '<span title="' + name + '">' + name + '</span>';
}
if (obj.status && Enums.entityStateReadOnly[obj.status]) {
nameHtml += '<button type="button" title="Deleted" class="btn btn-action btn-md deleteBtn"><i class="fa fa-trash"></i></button>';
nameHtml = '<div class="readOnly readOnlyLink">' + nameHtml + '</div>';
}
var getImageData = function(options) {
var imagePath = options.imagePath,
returnImgUrl = null;
that.checkEntityImage[model.get('guid')] = false;
$.ajax({
"url": imagePath,
"method": "get",
"cache": true
})
.always(function(data, status, xhr) {
if (data.status == 404) {
returnImgUrl = getImageData({
"imagePath": Utils.getEntityIconPath({ entityData: obj, errorUrl: imagePath })
});
} else if (data) {
that.checkEntityImage[model.get('guid')] = imagePath;
returnImgUrl = imagePath;
that.$("img[data-imgGuid='" + obj.guid + "']").removeClass("searchTableLogoLoader").attr("src", imagePath);
}
});
}
var img = "";
img = "<div><img data-imgGuid='" + obj.guid + "' class='searchTableLogoLoader'></div>";
if (that.checkEntityImage[model.get('guid')] == undefined) {
getImageData({ imagePath: Utils.getEntityIconPath({ entityData: obj }) });
} else {
if (that.checkEntityImage[model.get('guid')] != false) {
img = "<div><img data-imgGuid='" + obj.guid + "' src='" + that.checkEntityImage[model.get('guid')] + "'></div>";
}
}
return (img + nameHtml);
}
})
};
col['owner'] = {
label: "Owner",
cell: "String",
editable: false,
resizeable: true,
orderable: true,
renderable: true,
sortable: true,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON();
if (obj && obj.attributes && obj.attributes.owner) {
return obj.attributes.owner;
}
}
})
};
if (this.value && this.profileDBView) {
col['createTime'] = {
label: "Date Created",
cell: "Html",
editable: false,
sortable: true,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON();
if (obj && obj.attributes && obj.attributes.createTime) {
return Utils.formatDate({ date: obj.attributes.createTime });
} else {
return '-'
}
}
})
}
}
if (this.value && !this.profileDBView) {
col['description'] = {
label: "Description",
cell: "String",
editable: false,
resizeable: true,
orderable: true,
renderable: true,
sortable: true,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON();
if (obj && obj.attributes && obj.attributes.description) {
return obj.attributes.description;
}
}
})
};
col['typeName'] = {
label: "Type",
cell: "Html",
editable: false,
resizeable: true,
orderable: true,
sortable: true,
renderable: (columnToShow ? _.contains(columnToShow, 'typeName') : true),
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON();
if (obj && obj.typeName) {
return '<a title="Search ' + obj.typeName + '" href="#!/search/searchResult?type=' + obj.typeName + '&searchType=basic">' + obj.typeName + '</a>';
}
}
})
};
this.getTagCol({ 'col': col, 'columnToShow': columnToShow });
if ((!_.contains(["glossary"], this.fromView))) {
this.getTermCol({ 'col': col, 'columnToShow': columnToShow });
}
if (this.value && this.value.searchType === "basic") {
var def = this.entityDefCollection.fullCollection.find({ name: this.value.type }),
systemAttr = [],
businessMetadataAttr = [],
businessAttributes = {};
if (this.value.type == "_ALL_ENTITY_TYPES") {
this.businessMetadataDefCollection.each(function(model) {
var sortedAttributes = model.get('attributeDefs') || null,
name = model.get('name');
if (sortedAttributes) {
sortedAttributes = _.sortBy(sortedAttributes, function(obj) {
return obj.name;
});
businessAttributes[name] = $.extend(true, {}, sortedAttributes);
}
})
} else {
businessAttributes = def ? ($.extend(true, {}, def.get('businessAttributeDefs')) || null) : null;
}
if (def || Globals[this.value.type] || (
this.value.tag ?
Globals[this.value.tag] ?
Globals[this.value.tag] :
Globals[Enums.addOnClassification[0]] :
undefined)) {
var attrObj = def ? Utils.getNestedSuperTypeObj({ data: def.toJSON(), collection: this.entityDefCollection, attrMerge: true }) : [];
if (this.value.type && (Globals[this.value.type] || Globals[Enums.addOnEntities[0]])) {
systemAttr = (Globals[this.value.type] || Globals[Enums.addOnEntities[0]]).attributeDefs;
}
if (this.value.tag && (Globals[this.value.tag] || Globals[Enums.addOnClassification[0]])) {
systemAttr = (Globals[this.value.tag] || Globals[Enums.addOnClassification[0]]).attributeDefs;
}
attrObj = attrObj.concat(systemAttr);
if (businessAttributes) {
_.each(businessAttributes, function(businessMetadata, businessMetadataName) {
_.each(businessMetadata, function(attr, index) {
var attribute = attr;
attribute.isBusinessAttributes = true;
attribute.name = businessMetadataName + '.' + attribute.name;
businessMetadataAttr.push(attribute);
})
})
}
attrObj = attrObj.concat(businessMetadataAttr);
_.each(attrObj, function(obj, key) {
var key = obj.name,
isRenderable = _.contains(columnToShow, key),
// isSortable = obj.typeName.search(/(array|map)/i) == -1, // commented : as sorting is required for all the columns except classifications and terms
isSortable = obj.typeName.search(/(string|date|boolean|int|number|byte|float|long|double|short)/i) == 0, // commented : as sorting is required for all the columns except non-primitive types
columnLabel;
if (key == "name" || key == "description" || key == "owner") {
if (columnToShow) {
col[key].renderable = isRenderable;
}
return;
}
if (key == "__historicalGuids" || key == "__classificationsText" || key == "__classificationNames" || key == "__propagatedClassificationNames") {
return;
}
columnLabel = Enums.systemAttributes[obj.name] ? Enums.systemAttributes[obj.name] : (_.escape(obj.isBusinessAttributes ? obj.name : obj.name.capitalize()));
that.tableColumnsLabelMap[columnLabel] = obj.name;
col[obj.name] = {
label: columnLabel,
cell: "Html",
// headerCell: Backgrid.HeaderHTMLDecodeCell,
editable: false,
resizeable: true,
orderable: true,
sortable: isSortable,
renderable: isRenderable,
headerClassName: obj.isBusinessAttributes ? "no-capitalize" : "",
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var modelObj = model.toJSON();
if (modelObj && modelObj.attributes && !_.isUndefined(modelObj.attributes[key])) {
var tempObj = {
'scope': that,
'attributeDefs': [obj],
'valueObject': {},
'isTable': false
};
if (key == "__labels") {
var values = modelObj.attributes[key] ? modelObj.attributes[key].split("|") : null,
valueOfArray = [];
if (values) {
if (values[values.length - 1] === "") { values.pop(); }
if (values[0] === "") { values.shift(); }
_.each(values, function(names) {
valueOfArray.push('<span class="json-string"><a class="btn btn-action btn-sm btn-blue btn-icon" ><span>' + _.escape(names) + '</span></a></span>');
});
return valueOfArray.join(' ');
}
}
if (key == "__customAttributes") {
var customAttributes = modelObj.attributes[key] ? JSON.parse(modelObj.attributes[key]) : null,
valueOfArray = [];
if (customAttributes) {
_.each(Object.keys(customAttributes), function(value, index) {
valueOfArray.push('<span class="json-string"><a class="btn btn-action btn-sm btn-blue btn-icon" ><span><span>' + _.escape(value) + '</span> : <span>' + _.escape(Object.values(customAttributes)[index]) + '</span></span></a></span>');
});
return valueOfArray.join(' ');
}
}
tempObj.valueObject[key] = modelObj.attributes[key];
tempObj['isEditorValue'] = that.checkIsEditorValue(key);
var tablecolumn = CommonViewFunction.propertyTable(tempObj);
if (_.isArray(modelObj.attributes[key])) {
var column = $("<div>" + tablecolumn + "</div>")
if (tempObj.valueObject[key].length > 2) {
column.addClass("toggleList semi-collapsed").append("<span><a data-id='load-more-columns'>Show More</a></span>");
}
return column;
}
return tablecolumn;
}
}
})
};
});
}
}
}
return this.searchCollection.constructor.getTableCols(col, this.searchCollection);
},