Skip to content

Commit

Permalink
Use exposure: node selection
Browse files Browse the repository at this point in the history
  • Loading branch information
jtcohen6 committed Sep 22, 2020
1 parent 8bdbf1a commit 9bb68eb
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/app/components/graph/graph-launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ angular

if (node && node.resource_type == 'source') {
var nodes = graph.showFullGraph('source:' + node.source_name + "." + node.name);
} else if (node && node.resource_type == 'exposure') {
var nodes = graph.showFullGraph('exposure:' + node.name);
} else {
var nodes = graph.showFullGraph(node_name);
}
Expand All @@ -149,6 +151,8 @@ angular
var node = selectorService.getViewNode();
if (node && node.resource_type == 'source') {
var nodes = graph.showVerticalGraph('source:' + node.source_name + "." + node.name, true);
} else if (node && node.resource_type == 'exposure') {
var nodes = graph.showVerticalGraph('exposure:' + node.name, true);
} else {
var nodes = graph.showVerticalGraph(node.name, true);
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/graph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ angular
function getNodeSelector(node) {
if (node && node.resource_type == 'source') {
return 'source:' + node.source_name + "." + node.name;
} else if (node && node.resource_type == 'exposure') {
return 'exposure:' + node.name;
} else if (node.name) {
return node.name;
} else {
Expand Down
7 changes: 6 additions & 1 deletion src/app/services/node_selection_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ angular

service.resetSelection = function(node) {
var include_selection;
if (node && _.includes(['model', 'seed', 'snapshot', 'exposure'], node.resource_type)) {
if (node && _.includes(['model', 'seed', 'snapshot'], node.resource_type)) {
include_selection = '+' + node.name + '+';
} else if (node && node.resource_type == 'source') {
include_selection = '+source:' + node.source_name + "." + node.name + '+';
} else if (node && node.resource_type == 'exposure') {
include_selection = '+exposure:' + node.name;
} else if (node && _.includes(['analysis', 'test'], node.resource_type)) {
include_selection = '+' + node.name;
} else {
Expand Down Expand Up @@ -87,6 +89,9 @@ angular
if (node.resource_type == 'source') {
pre += "source:"
node_name = node.source_name + "." + node.name;
} else if (node.resource_type == 'exposure') {
pre += "exposure:"
node_name = node.name;
} else {
node_name = node.name;
}
Expand Down
25 changes: 24 additions & 1 deletion src/app/services/selector_matcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var SELECTOR_TYPE = {
FQN: 'fqn',
TAG: 'tag',
SOURCE: 'source',
EXPOSURE: 'exposure',
PATH: 'path',
PACKAGE: 'package',
CONFIG: 'config',
Expand All @@ -20,6 +21,7 @@ NODE_MATCHERS[SELECTOR_TYPE.IMPLICIT] = getNodesByImplicitSelection;
NODE_MATCHERS[SELECTOR_TYPE.FQN] = getNodesByFQN;
NODE_MATCHERS[SELECTOR_TYPE.TAG] = getNodesByTag;
NODE_MATCHERS[SELECTOR_TYPE.SOURCE] = getNodesBySource;
NODE_MATCHERS[SELECTOR_TYPE.EXPOSURE] = getNodesByExposure;
NODE_MATCHERS[SELECTOR_TYPE.PATH] = getNodesByPath;
NODE_MATCHERS[SELECTOR_TYPE.PACKAGE] = getNodesByPackage;
NODE_MATCHERS[SELECTOR_TYPE.CONFIG] = getNodesByConfig;
Expand Down Expand Up @@ -57,7 +59,7 @@ function getNodesByFQN(elements, qualified_name) {
var node = el.data;
var fqn = node.fqn;

if (!fqn || node.resource_type == 'source') {
if (!fqn || node.resource_type == 'source' || node.resource_type == 'exposure') {
return;
}

Expand Down Expand Up @@ -212,6 +214,27 @@ function getNodesBySource(elements, source) {
return nodes;
}

function getNodesByExposure(elements, exposure) {
var nodes = [];
_.each(elements, function(node_obj) {
var node = node_obj.data;

if (node.resource_type != 'exposure') {
return;
}

var exposure_name = node.name;
var selected_exposure_name = exposure;

if (selected_exposure_name == '*') {
nodes.push(node_obj.data);
} else if (selected_exposure_name == exposure_name) {
nodes.push(node_obj.data);
}
})
return nodes;
}

function getNodesFromSpec(dag, pristine_nodes, maxHops, selector) {
const matcher = NODE_MATCHERS[selector.selector_type];
if (!matcher) {
Expand Down
15 changes: 15 additions & 0 deletions src/app/services/selector_methods.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,21 @@ test("Test parsing specs (explicit source.table)", () => {
});
})

test("Test parsing specs (explicit exposure)", () => {
expect(
selectors.parseSpec('+exposure:a')
).toStrictEqual({
select_at: false,
select_children: false,
select_parents: true,
parents_depth: null,
children_depth: null,
selector_type: 'exposure',
selector_value: 'a',
raw: '+exposure:a',
});
})

test("Test parsing specs (scoped fqn)", () => {
expect(
selectors.parseSpec('a.b.c+')
Expand Down

0 comments on commit 9bb68eb

Please sign in to comment.