mirror of https://github.com/apache/nifi.git
NIFI-6381 - Make Parameters and Parameter Contexts searchable in UI
NIFI-6381 - remove wildcard imports This closes #3728
This commit is contained in:
parent
8a8852e73d
commit
5ca3655dbf
|
@ -35,6 +35,8 @@ public class SearchResultsDTO {
|
||||||
private List<ComponentSearchResultDTO> outputPortResults = new ArrayList<>();
|
private List<ComponentSearchResultDTO> outputPortResults = new ArrayList<>();
|
||||||
private List<ComponentSearchResultDTO> remoteProcessGroupResults = new ArrayList<>();
|
private List<ComponentSearchResultDTO> remoteProcessGroupResults = new ArrayList<>();
|
||||||
private List<ComponentSearchResultDTO> funnelResults = new ArrayList<>();
|
private List<ComponentSearchResultDTO> funnelResults = new ArrayList<>();
|
||||||
|
private List<ComponentSearchResultDTO> parameterContextResults = new ArrayList<>();
|
||||||
|
private List<ComponentSearchResultDTO> parameterResults = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The processors that matched the search
|
* @return The processors that matched the search
|
||||||
|
@ -134,4 +136,31 @@ public class SearchResultsDTO {
|
||||||
this.funnelResults = funnelResults;
|
this.funnelResults = funnelResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return parameter contexts that matched the search.
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "The parameter contexts that matched the search."
|
||||||
|
)
|
||||||
|
public List<ComponentSearchResultDTO> getParameterContextResults() {
|
||||||
|
return parameterContextResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParameterContextResults(List<ComponentSearchResultDTO> parameterContextResults) {
|
||||||
|
this.parameterContextResults = parameterContextResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return parameters that matched the search.
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "The parameters that matched the search."
|
||||||
|
)
|
||||||
|
public List<ComponentSearchResultDTO> getParameterResults() {
|
||||||
|
return parameterResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParameterResults(List<ComponentSearchResultDTO> parameterResults) {
|
||||||
|
this.parameterResults = parameterResults;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1619,6 +1619,7 @@ public class ControllerFacade implements Authorizable {
|
||||||
final SearchResultsDTO results = new SearchResultsDTO();
|
final SearchResultsDTO results = new SearchResultsDTO();
|
||||||
|
|
||||||
controllerSearchService.search(results, search, rootGroup);
|
controllerSearchService.search(results, search, rootGroup);
|
||||||
|
controllerSearchService.searchParameters(results, search);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,9 @@ import org.apache.nifi.flowfile.FlowFilePrioritizer;
|
||||||
import org.apache.nifi.groups.ProcessGroup;
|
import org.apache.nifi.groups.ProcessGroup;
|
||||||
import org.apache.nifi.groups.RemoteProcessGroup;
|
import org.apache.nifi.groups.RemoteProcessGroup;
|
||||||
import org.apache.nifi.nar.NarCloseable;
|
import org.apache.nifi.nar.NarCloseable;
|
||||||
|
import org.apache.nifi.parameter.Parameter;
|
||||||
|
import org.apache.nifi.parameter.ParameterContext;
|
||||||
|
import org.apache.nifi.parameter.ParameterContextManager;
|
||||||
import org.apache.nifi.processor.DataUnit;
|
import org.apache.nifi.processor.DataUnit;
|
||||||
import org.apache.nifi.processor.Processor;
|
import org.apache.nifi.processor.Processor;
|
||||||
import org.apache.nifi.processor.Relationship;
|
import org.apache.nifi.processor.Relationship;
|
||||||
|
@ -56,6 +59,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -163,6 +167,39 @@ public class ControllerSearchService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches all parameter contexts and parameters
|
||||||
|
* @param results Search results
|
||||||
|
* @param search The search term
|
||||||
|
*/
|
||||||
|
public void searchParameters(final SearchResultsDTO results, final String search) {
|
||||||
|
final NiFiUser user = NiFiUserUtils.getNiFiUser();
|
||||||
|
ParameterContextManager parameterContextManager = flowController.getFlowManager().getParameterContextManager();
|
||||||
|
|
||||||
|
final Set<ParameterContext> parameterContexts = parameterContextManager.getParameterContexts();
|
||||||
|
for (final ParameterContext parameterContext : parameterContexts) {
|
||||||
|
if (parameterContext.isAuthorized(authorizer, RequestAction.READ, user)) {
|
||||||
|
ComponentSearchResultDTO parameterContextMatch = search(search, parameterContext);
|
||||||
|
if (parameterContextMatch != null) {
|
||||||
|
results.getParameterContextResults().add(parameterContextMatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
// search each parameter within the context as well
|
||||||
|
for (Parameter parameter : parameterContext.getParameters().values()) {
|
||||||
|
ComponentSearchResultDTO parameterMatch = search(search, parameter);
|
||||||
|
if (parameterMatch != null) {
|
||||||
|
final SearchResultGroupDTO paramContextGroup = new SearchResultGroupDTO();
|
||||||
|
paramContextGroup.setId(parameterContext.getIdentifier());
|
||||||
|
paramContextGroup.setName(parameterContext.getName());
|
||||||
|
parameterMatch.setParentGroup(paramContextGroup);
|
||||||
|
|
||||||
|
results.getParameterResults().add(parameterMatch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private ComponentSearchResultDTO search(final String searchStr, final Port port) {
|
private ComponentSearchResultDTO search(final String searchStr, final Port port) {
|
||||||
final List<String> matches = new ArrayList<>();
|
final List<String> matches = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -474,6 +511,42 @@ public class ControllerSearchService {
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ComponentSearchResultDTO search(final String searchString, final ParameterContext parameterContext) {
|
||||||
|
final List<String> matches = new ArrayList<>();
|
||||||
|
addIfAppropriate(searchString, parameterContext.getIdentifier(), "Id", matches);
|
||||||
|
addIfAppropriate(searchString, parameterContext.getName(), "Name", matches);
|
||||||
|
addIfAppropriate(searchString, parameterContext.getDescription(), "Description", matches);
|
||||||
|
|
||||||
|
if (matches.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ComponentSearchResultDTO dto = new ComponentSearchResultDTO();
|
||||||
|
dto.setId(parameterContext.getIdentifier());
|
||||||
|
dto.setName(parameterContext.getName());
|
||||||
|
dto.setMatches(matches);
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ComponentSearchResultDTO search(final String searchString, final Parameter parameter) {
|
||||||
|
final List<String> matches = new ArrayList<>();
|
||||||
|
addIfAppropriate(searchString, parameter.getDescriptor().getName(), "Name", matches);
|
||||||
|
addIfAppropriate(searchString, parameter.getDescriptor().getDescription(), "Description", matches);
|
||||||
|
if (!parameter.getDescriptor().isSensitive()) {
|
||||||
|
addIfAppropriate(searchString, parameter.getValue(), "Value", matches);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matches.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ComponentSearchResultDTO dto = new ComponentSearchResultDTO();
|
||||||
|
dto.setId(parameter.getDescriptor().getName());
|
||||||
|
dto.setName(parameter.getDescriptor().getName());
|
||||||
|
dto.setMatches(matches);
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the nearest versioned parent result group for a given user.
|
* Builds the nearest versioned parent result group for a given user.
|
||||||
*
|
*
|
||||||
|
|
|
@ -19,9 +19,15 @@ package org.apache.nifi.web.controller;
|
||||||
import org.apache.nifi.authorization.Authorizer;
|
import org.apache.nifi.authorization.Authorizer;
|
||||||
import org.apache.nifi.authorization.RequestAction;
|
import org.apache.nifi.authorization.RequestAction;
|
||||||
import org.apache.nifi.authorization.user.NiFiUser;
|
import org.apache.nifi.authorization.user.NiFiUser;
|
||||||
|
import org.apache.nifi.controller.FlowController;
|
||||||
import org.apache.nifi.controller.ProcessorNode;
|
import org.apache.nifi.controller.ProcessorNode;
|
||||||
import org.apache.nifi.controller.StandardProcessorNode;
|
import org.apache.nifi.controller.StandardProcessorNode;
|
||||||
|
import org.apache.nifi.controller.flow.FlowManager;
|
||||||
import org.apache.nifi.groups.ProcessGroup;
|
import org.apache.nifi.groups.ProcessGroup;
|
||||||
|
import org.apache.nifi.parameter.Parameter;
|
||||||
|
import org.apache.nifi.parameter.ParameterContext;
|
||||||
|
import org.apache.nifi.parameter.ParameterContextManager;
|
||||||
|
import org.apache.nifi.parameter.ParameterDescriptor;
|
||||||
import org.apache.nifi.processor.Processor;
|
import org.apache.nifi.processor.Processor;
|
||||||
import org.apache.nifi.registry.VariableRegistry;
|
import org.apache.nifi.registry.VariableRegistry;
|
||||||
import org.apache.nifi.registry.flow.StandardVersionControlInformation;
|
import org.apache.nifi.registry.flow.StandardVersionControlInformation;
|
||||||
|
@ -33,25 +39,39 @@ import org.junit.Test;
|
||||||
import org.mockito.AdditionalMatchers;
|
import org.mockito.AdditionalMatchers;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.isNull;
|
import static org.mockito.ArgumentMatchers.isNull;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
public class ControllerSearchServiceTest {
|
public class ControllerSearchServiceTest {
|
||||||
private MutableVariableRegistry variableRegistry;
|
private MutableVariableRegistry variableRegistry;
|
||||||
private ControllerSearchService service;
|
private ControllerSearchService service;
|
||||||
private SearchResultsDTO searchResultsDTO;
|
private SearchResultsDTO searchResultsDTO;
|
||||||
|
private FlowController flowController;
|
||||||
|
private ParameterContextManager parameterContextManager;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
variableRegistry = mock(MutableVariableRegistry.class);
|
variableRegistry = mock(MutableVariableRegistry.class);
|
||||||
service = new ControllerSearchService();
|
service = new ControllerSearchService();
|
||||||
searchResultsDTO = new SearchResultsDTO();
|
searchResultsDTO = new SearchResultsDTO();
|
||||||
|
flowController = mock(FlowController.class);
|
||||||
|
|
||||||
|
FlowManager mockFlowManager = mock(FlowManager.class);
|
||||||
|
parameterContextManager = mock(ParameterContextManager.class);
|
||||||
|
|
||||||
|
doReturn(mockFlowManager).when(flowController).getFlowManager();
|
||||||
|
doReturn(parameterContextManager).when(mockFlowManager).getParameterContextManager();
|
||||||
|
service.setFlowController(flowController);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -339,6 +359,83 @@ public class ControllerSearchServiceTest {
|
||||||
assertTrue(searchResultsDTO.getProcessorResults().get(0).getVersionedGroup().getName() == null);
|
assertTrue(searchResultsDTO.getProcessorResults().get(0).getVersionedGroup().getName() == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchParameterContext() {
|
||||||
|
final ParameterContext paramContext1 = setupMockedParameterContext("foo", "description for parameter context foo", 1, "foo_param", true);
|
||||||
|
final ParameterContext paramContext2 = setupMockedParameterContext("bar", "description for parameter context bar", 2, "bar_param", true);
|
||||||
|
final Set<ParameterContext> mockedParameterContexts = new HashSet<ParameterContext>();
|
||||||
|
mockedParameterContexts.add(paramContext1);
|
||||||
|
mockedParameterContexts.add(paramContext2);
|
||||||
|
|
||||||
|
Mockito.doReturn(mockedParameterContexts).when(parameterContextManager).getParameterContexts();
|
||||||
|
|
||||||
|
service.searchParameters(searchResultsDTO, "foo");
|
||||||
|
|
||||||
|
assertTrue(searchResultsDTO.getParameterContextResults().size() == 1);
|
||||||
|
assertTrue(searchResultsDTO.getParameterContextResults().get(0).getId().equals("fooId"));
|
||||||
|
assertTrue(searchResultsDTO.getParameterContextResults().get(0).getName().equals("foo"));
|
||||||
|
// should have a match for the name, id, description
|
||||||
|
assertTrue(searchResultsDTO.getParameterContextResults().get(0).getMatches().size() == 3);
|
||||||
|
|
||||||
|
assertTrue(searchResultsDTO.getParameterResults().size() == 1);
|
||||||
|
|
||||||
|
assertTrue(searchResultsDTO.getParameterResults().get(0).getParentGroup().getId().equals("fooId"));
|
||||||
|
assertTrue(searchResultsDTO.getParameterResults().get(0).getName().equals("foo_param_0"));
|
||||||
|
// and the parameter name, parameter description, and the parameter value
|
||||||
|
assertTrue(searchResultsDTO.getParameterResults().get(0).getMatches().size() == 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchParameterContextNotAuthorized() {
|
||||||
|
final ParameterContext paramContext1 = setupMockedParameterContext("foo", "description for parameter context foo", 1, "foo_param", false);
|
||||||
|
final ParameterContext paramContext2 = setupMockedParameterContext("bar", "description for parameter context bar", 2, "bar_param", true);
|
||||||
|
final Set<ParameterContext> mockedParameterContexts = new HashSet<ParameterContext>();
|
||||||
|
mockedParameterContexts.add(paramContext1);
|
||||||
|
mockedParameterContexts.add(paramContext2);
|
||||||
|
|
||||||
|
Mockito.doReturn(mockedParameterContexts).when(parameterContextManager).getParameterContexts();
|
||||||
|
|
||||||
|
service.searchParameters(searchResultsDTO, "foo");
|
||||||
|
|
||||||
|
// the matching parameter context is not readable by the user, so there should not be any results
|
||||||
|
assertTrue(searchResultsDTO.getParameterContextResults().size() == 0);
|
||||||
|
assertTrue(searchResultsDTO.getParameterResults().size() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up a mock Parameter Context including isAuthorized()
|
||||||
|
* @param name name of the parameter context
|
||||||
|
* @param description description of the parameter context
|
||||||
|
* @param numberOfParams number of parameters to include as part of this context
|
||||||
|
* @param parameterNamePrefix a prefix for the parameter names
|
||||||
|
* @param authorizedToRead whether or not the user can read the parameter context
|
||||||
|
* @return ParameterContext
|
||||||
|
*/
|
||||||
|
private ParameterContext setupMockedParameterContext(String name, String description, int numberOfParams, String parameterNamePrefix, boolean authorizedToRead) {
|
||||||
|
final ParameterContext parameterContext = mock(ParameterContext.class);
|
||||||
|
Mockito.doReturn(name + "Id").when(parameterContext).getIdentifier();
|
||||||
|
Mockito.doReturn(name).when(parameterContext).getName();
|
||||||
|
Mockito.doReturn(description).when(parameterContext).getDescription();
|
||||||
|
Mockito.doReturn(authorizedToRead).when(parameterContext).isAuthorized(any(Authorizer.class), eq(RequestAction.READ), any(NiFiUser.class));
|
||||||
|
Mockito.doReturn(authorizedToRead).when(parameterContext).isAuthorized(eq(null), eq(RequestAction.READ), eq(null));
|
||||||
|
|
||||||
|
Map<ParameterDescriptor, Parameter> parameters = new HashMap<>();
|
||||||
|
for (int i = 0; i < numberOfParams; i++) {
|
||||||
|
final ParameterDescriptor descriptor = new ParameterDescriptor.Builder()
|
||||||
|
.name(parameterNamePrefix + "_" + i)
|
||||||
|
.description("Description for " + parameterNamePrefix + "_" + i)
|
||||||
|
.sensitive(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final Parameter param = new Parameter(descriptor, parameterNamePrefix + "_" + i + " value");
|
||||||
|
parameters.put(descriptor, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
Mockito.doReturn(parameters).when(parameterContext).getParameters();
|
||||||
|
|
||||||
|
return parameterContext;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mocks Processor including isAuthorized() and its name & id.
|
* Mocks Processor including isAuthorized() and its name & id.
|
||||||
*
|
*
|
||||||
|
|
|
@ -26,9 +26,10 @@
|
||||||
'nf.ContextMenu',
|
'nf.ContextMenu',
|
||||||
'nf.ClusterSummary',
|
'nf.ClusterSummary',
|
||||||
'nf.ErrorHandler',
|
'nf.ErrorHandler',
|
||||||
'nf.Settings'],
|
'nf.Settings',
|
||||||
function ($, nfCommon, nfDialog, nfCanvasUtils, nfContextMenu, nfClusterSummary, nfErrorHandler, nfSettings) {
|
'nf.ParameterContexts'],
|
||||||
return (nf.ng.Canvas.FlowStatusCtrl = factory($, nfCommon, nfDialog, nfCanvasUtils, nfContextMenu, nfClusterSummary, nfErrorHandler, nfSettings));
|
function ($, nfCommon, nfDialog, nfCanvasUtils, nfContextMenu, nfClusterSummary, nfErrorHandler, nfSettings, nfParameterContexts) {
|
||||||
|
return (nf.ng.Canvas.FlowStatusCtrl = factory($, nfCommon, nfDialog, nfCanvasUtils, nfContextMenu, nfClusterSummary, nfErrorHandler, nfSettings, nfParameterContexts));
|
||||||
});
|
});
|
||||||
} else if (typeof exports === 'object' && typeof module === 'object') {
|
} else if (typeof exports === 'object' && typeof module === 'object') {
|
||||||
module.exports = (nf.ng.Canvas.FlowStatusCtrl =
|
module.exports = (nf.ng.Canvas.FlowStatusCtrl =
|
||||||
|
@ -39,7 +40,8 @@
|
||||||
require('nf.ContextMenu'),
|
require('nf.ContextMenu'),
|
||||||
require('nf.ClusterSummary'),
|
require('nf.ClusterSummary'),
|
||||||
require('nf.ErrorHandler'),
|
require('nf.ErrorHandler'),
|
||||||
require('nf.Settings')));
|
require('nf.Settings'),
|
||||||
|
require('nf.ParameterContexts')));
|
||||||
} else {
|
} else {
|
||||||
nf.ng.Canvas.FlowStatusCtrl = factory(root.$,
|
nf.ng.Canvas.FlowStatusCtrl = factory(root.$,
|
||||||
root.nf.Common,
|
root.nf.Common,
|
||||||
|
@ -48,9 +50,10 @@
|
||||||
root.nf.ContextMenu,
|
root.nf.ContextMenu,
|
||||||
root.nf.ClusterSummary,
|
root.nf.ClusterSummary,
|
||||||
root.nf.ErrorHandler,
|
root.nf.ErrorHandler,
|
||||||
root.nf.Settings);
|
root.nf.Settings,
|
||||||
|
root.nf.ParameterContexts);
|
||||||
}
|
}
|
||||||
}(this, function ($, nfCommon, nfDialog, nfCanvasUtils, nfContextMenu, nfClusterSummary, nfErrorHandler, nfSettings) {
|
}(this, function ($, nfCommon, nfDialog, nfCanvasUtils, nfContextMenu, nfClusterSummary, nfErrorHandler, nfSettings, nfParameterContexts) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
return function (serviceProvider) {
|
return function (serviceProvider) {
|
||||||
|
@ -145,7 +148,7 @@
|
||||||
if (!nfCommon.isEmpty(searchResults.processorResults)) {
|
if (!nfCommon.isEmpty(searchResults.processorResults)) {
|
||||||
ul.append('<li class="search-header"><div class="search-result-icon icon icon-processor"></div>Processors</li>');
|
ul.append('<li class="search-header"><div class="search-result-icon icon icon-processor"></div>Processors</li>');
|
||||||
$.each(searchResults.processorResults, function (i, processorMatch) {
|
$.each(searchResults.processorResults, function (i, processorMatch) {
|
||||||
nfSearchAutocomplete._renderItem(ul, processorMatch);
|
nfSearchAutocomplete._renderItem(ul, $.extend({}, processorMatch, { type: 'processor' }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +156,7 @@
|
||||||
if (!nfCommon.isEmpty(searchResults.processGroupResults)) {
|
if (!nfCommon.isEmpty(searchResults.processGroupResults)) {
|
||||||
ul.append('<li class="search-header"><div class="search-result-icon icon icon-group"></div>Process Groups</li>');
|
ul.append('<li class="search-header"><div class="search-result-icon icon icon-group"></div>Process Groups</li>');
|
||||||
$.each(searchResults.processGroupResults, function (i, processGroupMatch) {
|
$.each(searchResults.processGroupResults, function (i, processGroupMatch) {
|
||||||
nfSearchAutocomplete._renderItem(ul, processGroupMatch);
|
nfSearchAutocomplete._renderItem(ul, $.extend({}, processGroupMatch, { type: 'process group' }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +164,7 @@
|
||||||
if (!nfCommon.isEmpty(searchResults.remoteProcessGroupResults)) {
|
if (!nfCommon.isEmpty(searchResults.remoteProcessGroupResults)) {
|
||||||
ul.append('<li class="search-header"><div class="search-result-icon icon icon-group-remote"></div>Remote Process Groups</li>');
|
ul.append('<li class="search-header"><div class="search-result-icon icon icon-group-remote"></div>Remote Process Groups</li>');
|
||||||
$.each(searchResults.remoteProcessGroupResults, function (i, remoteProcessGroupMatch) {
|
$.each(searchResults.remoteProcessGroupResults, function (i, remoteProcessGroupMatch) {
|
||||||
nfSearchAutocomplete._renderItem(ul, remoteProcessGroupMatch);
|
nfSearchAutocomplete._renderItem(ul, $.extend({}, remoteProcessGroupMatch, { type: 'remote process group' }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +172,7 @@
|
||||||
if (!nfCommon.isEmpty(searchResults.connectionResults)) {
|
if (!nfCommon.isEmpty(searchResults.connectionResults)) {
|
||||||
ul.append('<li class="search-header"><div class="search-result-icon icon icon-connect"></div>Connections</li>');
|
ul.append('<li class="search-header"><div class="search-result-icon icon icon-connect"></div>Connections</li>');
|
||||||
$.each(searchResults.connectionResults, function (i, connectionMatch) {
|
$.each(searchResults.connectionResults, function (i, connectionMatch) {
|
||||||
nfSearchAutocomplete._renderItem(ul, connectionMatch);
|
nfSearchAutocomplete._renderItem(ul, $.extend({}, connectionMatch, { type: 'connection' }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +180,7 @@
|
||||||
if (!nfCommon.isEmpty(searchResults.inputPortResults)) {
|
if (!nfCommon.isEmpty(searchResults.inputPortResults)) {
|
||||||
ul.append('<li class="search-header"><div class="search-result-icon icon icon-port-in"></div>Input Ports</li>');
|
ul.append('<li class="search-header"><div class="search-result-icon icon icon-port-in"></div>Input Ports</li>');
|
||||||
$.each(searchResults.inputPortResults, function (i, inputPortMatch) {
|
$.each(searchResults.inputPortResults, function (i, inputPortMatch) {
|
||||||
nfSearchAutocomplete._renderItem(ul, inputPortMatch);
|
nfSearchAutocomplete._renderItem(ul, $.extend({}, inputPortMatch, { type: 'input port' }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +188,7 @@
|
||||||
if (!nfCommon.isEmpty(searchResults.outputPortResults)) {
|
if (!nfCommon.isEmpty(searchResults.outputPortResults)) {
|
||||||
ul.append('<li class="search-header"><div class="search-result-icon icon icon-port-out"></div>Output Ports</li>');
|
ul.append('<li class="search-header"><div class="search-result-icon icon icon-port-out"></div>Output Ports</li>');
|
||||||
$.each(searchResults.outputPortResults, function (i, outputPortMatch) {
|
$.each(searchResults.outputPortResults, function (i, outputPortMatch) {
|
||||||
nfSearchAutocomplete._renderItem(ul, outputPortMatch);
|
nfSearchAutocomplete._renderItem(ul, $.extend({}, outputPortMatch, { type: 'output port' }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +196,23 @@
|
||||||
if (!nfCommon.isEmpty(searchResults.funnelResults)) {
|
if (!nfCommon.isEmpty(searchResults.funnelResults)) {
|
||||||
ul.append('<li class="search-header"><div class="search-result-icon icon icon-funnel"></div>Funnels</li>');
|
ul.append('<li class="search-header"><div class="search-result-icon icon icon-funnel"></div>Funnels</li>');
|
||||||
$.each(searchResults.funnelResults, function (i, funnelMatch) {
|
$.each(searchResults.funnelResults, function (i, funnelMatch) {
|
||||||
nfSearchAutocomplete._renderItem(ul, funnelMatch);
|
nfSearchAutocomplete._renderItem(ul, $.extend({}, funnelMatch, { type: 'funnel' }));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// show all parameter contexts and parameters
|
||||||
|
if (!nfCommon.isEmpty(searchResults.parameterContextResults)) {
|
||||||
|
ul.append('<li class="search-header"><div class="search-result-icon icon"></div>Parameter Contexts</li>');
|
||||||
|
$.each(searchResults.parameterContextResults, function (i, parameterContextMatch) {
|
||||||
|
nfSearchAutocomplete._renderItem(ul, $.extend({}, parameterContextMatch, { type: 'parameter context' }));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// show all parameters
|
||||||
|
if (!nfCommon.isEmpty(searchResults.parameterResults)) {
|
||||||
|
ul.append('<li class="search-header"><div class="search-result-icon icon"></div>Parameters</li>');
|
||||||
|
$.each(searchResults.parameterResults, function (i, parameterMatch) {
|
||||||
|
nfSearchAutocomplete._renderItem(ul, $.extend({}, parameterMatch, { type: 'parameter' }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,9 +223,14 @@
|
||||||
},
|
},
|
||||||
_renderItem: function (ul, match) {
|
_renderItem: function (ul, match) {
|
||||||
var itemHeader = $('<div class="search-match-header"></div>').text(match.name);
|
var itemHeader = $('<div class="search-match-header"></div>').text(match.name);
|
||||||
|
var itemContent = $('<a></a>').append(itemHeader);
|
||||||
|
|
||||||
|
if (match.type !== 'parameter context' && match.type !== 'parameter') {
|
||||||
var parentGroupHeader = $('<div class="search-match-header"></div>').append(document.createTextNode('Parent: '));
|
var parentGroupHeader = $('<div class="search-match-header"></div>').append(document.createTextNode('Parent: '));
|
||||||
var parentGroup = match.parentGroup.name ? match.parentGroup.name : match.parentGroup.id;
|
var parentGroup = '-';
|
||||||
|
if (nfCommon.isDefinedAndNotNull(match.parentGroup)) {
|
||||||
|
parentGroup = match.parentGroup.name ? match.parentGroup.name : match.parentGroup.id;
|
||||||
|
}
|
||||||
parentGroupHeader = parentGroupHeader.append($('<span></span>').text(parentGroup));
|
parentGroupHeader = parentGroupHeader.append($('<span></span>').text(parentGroup));
|
||||||
|
|
||||||
var versionedGroupHeader = $('<div class="search-match-header"></div>').append(document.createTextNode('Versioned: '));
|
var versionedGroupHeader = $('<div class="search-match-header"></div>').append(document.createTextNode('Versioned: '));
|
||||||
|
@ -218,7 +242,17 @@
|
||||||
|
|
||||||
versionedGroupHeader = versionedGroupHeader.append($('<span></span>').text(versionedGroup));
|
versionedGroupHeader = versionedGroupHeader.append($('<span></span>').text(versionedGroup));
|
||||||
// create a search item wrapper
|
// create a search item wrapper
|
||||||
var itemContent = $('<a></a>').append(itemHeader).append(parentGroupHeader).append(versionedGroupHeader);
|
itemContent.append(parentGroupHeader).append(versionedGroupHeader);
|
||||||
|
} else if (match.type === 'parameter') {
|
||||||
|
var paramContextHeader = $('<div class="search-match-header"></div>').append(document.createTextNode('Parameter Context: '));
|
||||||
|
var paramContext = '-';
|
||||||
|
if (nfCommon.isDefinedAndNotNull(match.parentGroup)) {
|
||||||
|
paramContext = match.parentGroup.name ? match.parentGroup.name : match.parentGroup.id;
|
||||||
|
}
|
||||||
|
paramContextHeader = paramContextHeader.append($('<span></span>').text(paramContext));
|
||||||
|
itemContent.append(paramContextHeader);
|
||||||
|
}
|
||||||
|
|
||||||
// append all matches
|
// append all matches
|
||||||
$.each(match.matches, function (i, match) {
|
$.each(match.matches, function (i, match) {
|
||||||
itemContent.append($('<div class="search-match"></div>').text(match));
|
itemContent.append($('<div class="search-match"></div>').text(match));
|
||||||
|
@ -251,10 +285,22 @@
|
||||||
},
|
},
|
||||||
select: function (event, ui) {
|
select: function (event, ui) {
|
||||||
var item = ui.item;
|
var item = ui.item;
|
||||||
|
|
||||||
|
switch (item.type) {
|
||||||
|
case 'parameter context':
|
||||||
|
nfParameterContexts.showParameterContexts(item.id);
|
||||||
|
break;
|
||||||
|
case 'parameter':
|
||||||
|
var paramContext = item.parentGroup;
|
||||||
|
nfParameterContexts.showParameterContext(paramContext.id, null, item.name);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
var group = item.parentGroup;
|
var group = item.parentGroup;
|
||||||
|
|
||||||
// show the selected component
|
// show the selected component
|
||||||
nfCanvasUtils.showComponent(group.id, item.id);
|
nfCanvasUtils.showComponent(group.id, item.id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
searchCtrl.getInputElement().val('').blur();
|
searchCtrl.getInputElement().val('').blur();
|
||||||
|
|
||||||
|
|
|
@ -1995,8 +1995,10 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the parameter contexts.
|
* Loads the parameter contexts.
|
||||||
|
*
|
||||||
|
* @param parameterContextToSelect id of the parameter context to select in the grid
|
||||||
*/
|
*/
|
||||||
var loadParameterContexts = function () {
|
var loadParameterContexts = function (parameterContextToSelect) {
|
||||||
var parameterContexts = $.Deferred(function (deferred) {
|
var parameterContexts = $.Deferred(function (deferred) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
|
@ -2026,6 +2028,21 @@
|
||||||
parameterContextsData.setItems(contexts);
|
parameterContextsData.setItems(contexts);
|
||||||
parameterContextsData.reSort();
|
parameterContextsData.reSort();
|
||||||
parameterContextsGrid.invalidate();
|
parameterContextsGrid.invalidate();
|
||||||
|
|
||||||
|
// if we are pre-selecting a specific parameter context, get the row to select
|
||||||
|
if (nfCommon.isDefinedAndNotNull(parameterContextToSelect)) {
|
||||||
|
var parameterContextRow = null;
|
||||||
|
$.each(contexts, function (i, contextEntity) {
|
||||||
|
if (contextEntity.id === parameterContextToSelect) {
|
||||||
|
parameterContextRow = parameterContextsData.getRowById(parameterContextToSelect);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (parameterContextRow !== null) {
|
||||||
|
// select the desired row
|
||||||
|
parameterContextsGrid.setSelectedRows([parameterContextRow]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}).fail(nfErrorHandler.handleAjaxError);
|
}).fail(nfErrorHandler.handleAjaxError);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2360,13 +2377,15 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the parameter context dialog.
|
* Shows the parameter context dialog.
|
||||||
|
*
|
||||||
|
* @param id The parameter context id to select
|
||||||
*/
|
*/
|
||||||
showParameterContexts: function () {
|
showParameterContexts: function (id) {
|
||||||
// conditionally allow creation of new parameter contexts
|
// conditionally allow creation of new parameter contexts
|
||||||
$('#new-parameter-context').prop('disabled', !nfCommon.canModifyParameterContexts());
|
$('#new-parameter-context').prop('disabled', !nfCommon.canModifyParameterContexts());
|
||||||
|
|
||||||
// load the parameter contexts
|
// load the parameter contexts
|
||||||
return loadParameterContexts().done(showParameterContexts);
|
return loadParameterContexts(id).done(showParameterContexts);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue