ATLAS-4822: Relationship Search feature should be configurable

Signed-off-by: Pinal Shah <pinal.shah@freestoneinfotech.com>
This commit is contained in:
vinayak.marraiya 2024-03-14 21:34:13 +05:30 committed by Pinal Shah
parent a7d7398679
commit b4745dcfe1
13 changed files with 89 additions and 23 deletions

View File

@ -659,4 +659,10 @@ div.columnmanager-dropdown-container {
background-color: #323544 !important;
}
}
}
.disable-relationship-search{
display:none !important;
}
.search-tab-body{
padding: 0px 18px 18px 18px !important;
}

View File

@ -257,6 +257,19 @@ require(['App',
App.start();
}
};
var relationshipSearch= function(){
var that=this;
this.relationshipDefCollection.fetch({
async: true,
complete: function() {
that.relationshipDefCollection.fullCollection.comparator = function(model) {
return model.get('name').toLowerCase();
};
that.relationshipDefCollection.fullCollection.sort({ silent: true });
that.relationshipEventAgg.trigger("Relationship:Update");
}
});
};
CommonViewFunction.userDataFetch({
url: UrlLinks.sessionApiUrl(),
callback: function(response) {
@ -308,6 +321,12 @@ require(['App',
if (response['atlas.lineage.on.demand.default.node.count'] !== undefined) {
Globals.lineageNodeCount = response['atlas.lineage.on.demand.default.node.count'];
}
if (response['atlas.relationship.search.enabled'] !== undefined) {
Globals.isRelationshipSearchEnabled = response['atlas.relationship.search.enabled'];
}
if(Globals.isRelationshipSearchEnabled){
relationshipSearch();
}
/* Atlas idealTimeout
redirectUrl: url to redirect after timeout
idealTimeLimit: timeout in seconds
@ -391,16 +410,6 @@ require(['App',
startApp();
}
});
this.relationshipDefCollection.fetch({
async: true,
complete: function() {
that.relationshipDefCollection.fullCollection.comparator = function(model) {
return model.get('name').toLowerCase();
};
that.relationshipDefCollection.fullCollection.sort({ silent: true });
that.relationshipEventAgg.trigger("Relationship:Update");
}
});
CommonViewFunction.fetchRootEntityAttributes({
url: UrlLinks.rootEntityDefUrl(Enums.addOnEntities[0]),
entity: Enums.addOnEntities,

View File

@ -16,7 +16,7 @@
-->
<div class="row row-margin-bottom">
<div class="col-sm-12" style="margin-top: 10px;">
<div class="row">
<div class="row" data-id="searchTabs">
<div>
<ul class="nav nav-tabs" data-id="tab-searchlist">
<li role="basic-search" class="tab basicSearch active"><a href="#tab-basicSearch" aria-controls="tab-basicSearch" role="tab" data-toggle="tab" aria-expanded="true">ENTITIES</a></li>
@ -25,7 +25,7 @@
</div>
</div>
<div class="tab-content">
<div id="tab-basicSearch" role="basic-search" class="tab-pane active animated fadeIn row">
<div id="tab-basicSearch" data-id="searchTabBody" role="basic-search" class="tab-pane active animated fadeIn row">
<div class="searchToggleBtn-container" style="margin:15px 0px; font-size: 14px;">
<div class="row">
<div class="col-sm-9" style="margin-top: 5px;">

View File

@ -60,6 +60,7 @@ define(["require", "underscore"], function(require, _) {
Globals.lineageNodeCount = 3;
Globals.lineageDepth = 3;
Globals.fromRelationshipSearch = false;
Globals.isRelationshipSearchEnabled = false;
return Globals;
});

View File

@ -55,7 +55,9 @@ define(['require',
advancedInfoBtn: '[data-id="advancedInfo"]',
typeAttrFilter: '[data-id="typeAttrFilter"]',
tagAttrFilter: '[data-id="tagAttrFilter"]',
tablist: '[data-id="tab-searchlist"] li'
tablist: '[data-id="tab-searchlist"] li',
searchTabs:'[data-id="searchTabs"]',
searchTabBody:'[data-id="searchTabBody"]',
},
/** ui events hash */
@ -385,6 +387,10 @@ define(['require',
// array of tags which is coming from url
this.initializeValues();
this.updateTabState();
if(!Globals.isRelationshipSearchEnabled){ // hide relationship search
this.ui.searchTabs.addClass("disable-relationship-search");
this.ui.searchTabBody.addClass("search-tab-body");
}
},
updateTabState: function() {
if ((Utils.getUrlState.isRelationTab() || Utils.getUrlState.isRelationshipDetailPage()) && !this.isRelationSearch) {

View File

@ -284,6 +284,19 @@ require(['App',
App.start();
}
};
var relationshipSearch= function(){
var that=this;
this.relationshipDefCollection.fetch({
async: true,
complete: function() {
that.relationshipDefCollection.fullCollection.comparator = function(model) {
return model.get('name').toLowerCase();
};
that.relationshipDefCollection.fullCollection.sort({ silent: true });
startApp();
}
});
};
CommonViewFunction.userDataFetch({
url: UrlLinks.sessionApiUrl(),
callback: function(response) {
@ -335,6 +348,12 @@ require(['App',
if (response['atlas.lineage.on.demand.default.node.count'] !== undefined) {
Globals.lineageNodeCount = response['atlas.lineage.on.demand.default.node.count'];
}
if (response['atlas.relationship.search.enabled'] !== undefined) {
Globals.isRelationshipSearchEnabled = response['atlas.relationship.search.enabled'];
}
if(Globals.isRelationshipSearchEnabled){
relationshipSearch();
}
/* Atlas idealTimeout
redirectUrl: url to redirect after timeout
idealTimeLimit: timeout in seconds

View File

@ -61,6 +61,7 @@ define(["require", "underscore"], function(require, _) {
Globals.lineageNodeCount = 3;
Globals.lineageDepth = 3;
Globals.fromRelationshipSearch = false;
Globals.isRelationshipSearchEnabled = false;
return Globals;
});

View File

@ -124,7 +124,9 @@ define([
this.renderGlossaryTree(opt);
this.renderCustomFilterTree();
this.renderBusinessMetadataTree();
this.renderRelationshipTree();
if(Globals.isRelationshipSearchEnabled){ // show, hide relationship search
this.renderRelationshipTree();
}
this.showHideGlobalFilter();
this.showDefaultPage();
},

View File

@ -385,15 +385,18 @@ define([
text: "Advanced Search",
name: "Advanced Search",
state: { opened: true }
}, {
icon: "fa fa-folder-o",
gType: "customFilter",
type: "customFilterFolder",
children: customFilterRelationshipList,
text: "Relationship Search",
name: "Relationship Search",
state: { opened: true }
}];
if(Globals.isRelationshipSearchEnabled){
treeView.push({
icon: "fa fa-folder-o",
gType: "customFilter",
type: "customFilterFolder",
children: customFilterRelationshipList,
text: "Relationship Search",
name: "Relationship Search",
state: { opened: true }
});
}
var customFilterList = that.isGroupView ? treeView : allCustomFilter;
return customFilterList;
},

View File

@ -109,7 +109,8 @@ public enum AtlasConfiguration {
MIN_AUDIT_COUNT_TO_MAINTAIN("atlas.audit.min.count.to.maintain", 50),
ATLAS_AUDIT_AGING_SEARCH_MAX_LIMIT("atlas.audit.aging.search.maxlimit", 10000),
ATLAS_AUDIT_DEFAULT_AGEOUT_IGNORE_TTL("atlas.audit.default.ageout.ignore.ttl", false),
ATLAS_AUDIT_AGING_TTL_TEST_AUTOMATION("atlas.audit.aging.ttl.test.automation", false); //Only for test automation
ATLAS_AUDIT_AGING_TTL_TEST_AUTOMATION("atlas.audit.aging.ttl.test.automation", false),//Only for test automation
RELATIONSHIP_SEARCH_ENABLED("atlas.relationship.search.enabled" ,false);
private static final Configuration APPLICATION_PROPERTIES;

View File

@ -17,6 +17,7 @@
*/
package org.apache.atlas.repository.patches;
import org.apache.atlas.AtlasConfiguration;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.pc.WorkItemManager;
import org.apache.atlas.repository.Constants;
@ -52,6 +53,11 @@ public class RelationshipTypeNamePatch extends AtlasPatchHandler {
@Override
public void apply() throws AtlasBaseException {
if (AtlasConfiguration.RELATIONSHIP_SEARCH_ENABLED.getBoolean() == false) {
LOG.info("RelationshipTypeNamePatch: Skipped, since not enabled!");
return;
}
LOG.info("RelationshipTypeNamePatch: Starting...");
EdgePatchProcessor patchProcessor = new RelationshipTypeNamePatchProcessor(context);
patchProcessor.apply();

View File

@ -190,6 +190,7 @@ public class AdminResource {
private final boolean isTasksEnabled;
private final boolean isOnDemandLineageEnabled;
private final int defaultLineageNodeCount;
private final boolean isRelationshipSearchEnabled;
private final AtlasMetricsUtil atlasMetricsUtil;
private AtlasAuditReductionService auditReductionService;
@ -237,6 +238,7 @@ public class AdminResource {
this.isTasksEnabled = AtlasConfiguration.TASKS_USE_ENABLED.getBoolean();
this.isOnDemandLineageEnabled = AtlasConfiguration.LINEAGE_ON_DEMAND_ENABLED.getBoolean();
this.defaultLineageNodeCount = AtlasConfiguration.LINEAGE_ON_DEMAND_DEFAULT_NODE_COUNT.getInt();
this.isRelationshipSearchEnabled = AtlasConfiguration.RELATIONSHIP_SEARCH_ENABLED.getBoolean();
} else {
this.defaultUIVersion = UI_VERSION_V2;
this.isTimezoneFormatEnabled = true;
@ -245,6 +247,7 @@ public class AdminResource {
this.isTasksEnabled = false;
this.isOnDemandLineageEnabled = false;
this.defaultLineageNodeCount = 3;
this.isRelationshipSearchEnabled = false;
}
}
@ -396,6 +399,7 @@ public class AdminResource {
responseData.put(AtlasConfiguration.TASKS_USE_ENABLED.getPropertyName(), isTasksEnabled);
responseData.put(AtlasConfiguration.LINEAGE_ON_DEMAND_ENABLED.getPropertyName(), isOnDemandLineageEnabled);
responseData.put(AtlasConfiguration.LINEAGE_ON_DEMAND_DEFAULT_NODE_COUNT.getPropertyName(), defaultLineageNodeCount);
responseData.put( AtlasConfiguration.RELATIONSHIP_SEARCH_ENABLED.getPropertyName(),isRelationshipSearchEnabled);
if (AtlasConfiguration.SESSION_TIMEOUT_SECS.getInt() != -1) {
responseData.put(AtlasConfiguration.SESSION_TIMEOUT_SECS.getPropertyName(), AtlasConfiguration.SESSION_TIMEOUT_SECS.getInt());

View File

@ -21,6 +21,7 @@ import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.RequestContext;
import org.apache.atlas.SortOrder;
import org.apache.atlas.AtlasConfiguration;
import org.apache.atlas.annotation.Timed;
import org.apache.atlas.authorize.AtlasAuthorizationUtils;
import org.apache.atlas.discovery.AtlasDiscoveryService;
@ -449,6 +450,10 @@ public class DiscoveryREST {
throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "RelationshipFilters specified without Type name");
}
if (AtlasConfiguration.RELATIONSHIP_SEARCH_ENABLED.getBoolean() == false) {
throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Relationship search is currently disabled, set property " + AtlasConfiguration.RELATIONSHIP_SEARCH_ENABLED.getPropertyName() + " = true to enable");
}
return discoveryService.searchRelationsWithParameters(parameters);
} finally {
AtlasPerfTracer.log(perf);
@ -485,6 +490,9 @@ public class DiscoveryREST {
", " + sortByAttribute + ", " + sortOrder + ", " + limit + ", " + offset + ", " + marker + ")");
}
if (AtlasConfiguration.RELATIONSHIP_SEARCH_ENABLED.getBoolean() == false) {
throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Relationship search is currently disabled, set property " + AtlasConfiguration.RELATIONSHIP_SEARCH_ENABLED.getPropertyName() + " = true to enable");
}
RelationshipSearchParameters parameters = new RelationshipSearchParameters();
parameters.setRelationshipName(relationshipName);
parameters.setSortBy(sortByAttribute);