This is an automated email from the ASF dual-hosted git repository. pinal pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/branch-2.0 by this push: new 9a5ad2d47 ATLAS-4822: Relationship Search feature should be configurable 9a5ad2d47 is described below commit 9a5ad2d4736577eaabe73887afc65f7b15634907 Author: vinayak.marraiya <vinayak.marra...@cloudera.com> AuthorDate: Thu Mar 14 21:34:13 2024 +0530 ATLAS-4822: Relationship Search feature should be configurable Signed-off-by: Pinal Shah <pinal.s...@freestoneinfotech.com> --- dashboardv2/public/css/scss/override.scss | 6 +++++ dashboardv2/public/js/main.js | 29 ++++++++++++++-------- .../js/templates/search/SearchLayoutView_tmpl.html | 4 +-- dashboardv2/public/js/utils/Globals.js | 1 + .../public/js/views/search/SearchLayoutView.js | 8 +++++- dashboardv3/public/js/main.js | 19 ++++++++++++++ dashboardv3/public/js/utils/Globals.js | 1 + .../views/search/SearchFilterBrowseLayoutView.js | 4 ++- .../search/tree/CustomFilterTreeLayoutView.js | 19 ++++++++------ .../java/org/apache/atlas/AtlasConfiguration.java | 3 ++- .../patches/RelationshipTypeNamePatch.java | 6 +++++ .../apache/atlas/web/resources/AdminResource.java | 4 +++ .../org/apache/atlas/web/rest/DiscoveryREST.java | 8 ++++++ 13 files changed, 89 insertions(+), 23 deletions(-) diff --git a/dashboardv2/public/css/scss/override.scss b/dashboardv2/public/css/scss/override.scss index 0c5f8bc0d..26b706547 100644 --- a/dashboardv2/public/css/scss/override.scss +++ b/dashboardv2/public/css/scss/override.scss @@ -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; } \ No newline at end of file diff --git a/dashboardv2/public/js/main.js b/dashboardv2/public/js/main.js index f0cea7999..9c864cf8f 100644 --- a/dashboardv2/public/js/main.js +++ b/dashboardv2/public/js/main.js @@ -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, diff --git a/dashboardv2/public/js/templates/search/SearchLayoutView_tmpl.html b/dashboardv2/public/js/templates/search/SearchLayoutView_tmpl.html index f049fa420..3d4e15036 100644 --- a/dashboardv2/public/js/templates/search/SearchLayoutView_tmpl.html +++ b/dashboardv2/public/js/templates/search/SearchLayoutView_tmpl.html @@ -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;"> diff --git a/dashboardv2/public/js/utils/Globals.js b/dashboardv2/public/js/utils/Globals.js index 431a24b38..8ea4aafe7 100644 --- a/dashboardv2/public/js/utils/Globals.js +++ b/dashboardv2/public/js/utils/Globals.js @@ -60,6 +60,7 @@ define(["require", "underscore"], function(require, _) { Globals.lineageNodeCount = 3; Globals.lineageDepth = 3; Globals.fromRelationshipSearch = false; + Globals.isRelationshipSearchEnabled = false; return Globals; }); \ No newline at end of file diff --git a/dashboardv2/public/js/views/search/SearchLayoutView.js b/dashboardv2/public/js/views/search/SearchLayoutView.js index c59a5d83e..8173f70ff 100644 --- a/dashboardv2/public/js/views/search/SearchLayoutView.js +++ b/dashboardv2/public/js/views/search/SearchLayoutView.js @@ -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) { diff --git a/dashboardv3/public/js/main.js b/dashboardv3/public/js/main.js index 7423c88c3..69ffed9ae 100644 --- a/dashboardv3/public/js/main.js +++ b/dashboardv3/public/js/main.js @@ -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 diff --git a/dashboardv3/public/js/utils/Globals.js b/dashboardv3/public/js/utils/Globals.js index 410d82881..056ac640e 100644 --- a/dashboardv3/public/js/utils/Globals.js +++ b/dashboardv3/public/js/utils/Globals.js @@ -61,6 +61,7 @@ define(["require", "underscore"], function(require, _) { Globals.lineageNodeCount = 3; Globals.lineageDepth = 3; Globals.fromRelationshipSearch = false; + Globals.isRelationshipSearchEnabled = false; return Globals; }); \ No newline at end of file diff --git a/dashboardv3/public/js/views/search/SearchFilterBrowseLayoutView.js b/dashboardv3/public/js/views/search/SearchFilterBrowseLayoutView.js index c81a74fd8..1c160016e 100644 --- a/dashboardv3/public/js/views/search/SearchFilterBrowseLayoutView.js +++ b/dashboardv3/public/js/views/search/SearchFilterBrowseLayoutView.js @@ -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(); }, diff --git a/dashboardv3/public/js/views/search/tree/CustomFilterTreeLayoutView.js b/dashboardv3/public/js/views/search/tree/CustomFilterTreeLayoutView.js index ea7185b35..b49541d3a 100644 --- a/dashboardv3/public/js/views/search/tree/CustomFilterTreeLayoutView.js +++ b/dashboardv3/public/js/views/search/tree/CustomFilterTreeLayoutView.js @@ -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; }, diff --git a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java index 090889e1c..0868f8b6e 100644 --- a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java +++ b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java @@ -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; diff --git a/repository/src/main/java/org/apache/atlas/repository/patches/RelationshipTypeNamePatch.java b/repository/src/main/java/org/apache/atlas/repository/patches/RelationshipTypeNamePatch.java index c3a9106fa..52adcd4d7 100644 --- a/repository/src/main/java/org/apache/atlas/repository/patches/RelationshipTypeNamePatch.java +++ b/repository/src/main/java/org/apache/atlas/repository/patches/RelationshipTypeNamePatch.java @@ -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(); diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java index 27ec59d37..0025276bb 100755 --- a/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java +++ b/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java @@ -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()); diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java index d1d19075f..b15f662d0 100644 --- a/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java +++ b/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java @@ -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);