use of com.thinkbiganalytics.nifi.rest.model.visitor.NifiFlowBuilder in project kylo by Teradata.
the class DefaultNiFiFlowVisitorClient method getTemplateFeedFlow.
public NifiFlowProcessGroup getTemplateFeedFlow(TemplateDTO template) {
ProcessGroupDTO parentProcessGroup = new ProcessGroupDTO();
parentProcessGroup.setId(UUID.randomUUID().toString());
parentProcessGroup.setParentGroupId(UUID.randomUUID().toString());
parentProcessGroup.setName(template.getName());
parentProcessGroup.setContents(template.getSnippet());
NifiConnectionOrderVisitorCache cache = new NifiConnectionOrderVisitorCache();
Collection<ProcessGroupDTO> groups = NifiProcessUtil.getProcessGroups(parentProcessGroup);
cache.add(parentProcessGroup);
// add the snippet as its own process group
if (template.getSnippet().getProcessors() != null) {
// find the first processor and get its parent group id
Optional<ProcessorDTO> firstProcessor = template.getSnippet().getProcessors().stream().findFirst();
if (firstProcessor.isPresent()) {
String groupId = firstProcessor.get().getParentGroupId();
ProcessGroupDTO snippetGroup = new ProcessGroupDTO();
snippetGroup.setId(groupId);
snippetGroup.setParentGroupId(template.getGroupId());
snippetGroup.setContents(template.getSnippet());
cache.add(snippetGroup);
}
}
if (groups != null) {
groups.stream().forEach(group -> cache.add(group));
}
// add any remote ProcessGroups
if (template.getSnippet().getRemoteProcessGroups() != null) {
template.getSnippet().getRemoteProcessGroups().stream().forEach(remoteProcessGroupDTO -> cache.add(remoteProcessGroupDTO));
}
NifiVisitableProcessGroup visitableGroup = getFlowOrder(parentProcessGroup, cache, false);
NifiFlowProcessGroup flow = new NifiFlowBuilder().build(visitableGroup);
return flow;
}
use of com.thinkbiganalytics.nifi.rest.model.visitor.NifiFlowBuilder in project kylo by Teradata.
the class DefaultNiFiFlowVisitorClient method getFeedFlow.
public NifiFlowProcessGroup getFeedFlow(String processGroupId, NifiConnectionOrderVisitorCache cache) {
NifiVisitableProcessGroup visitableGroup = getFlowOrder(processGroupId, cache);
NifiFlowProcessGroup flow = new NifiFlowBuilder().build(visitableGroup);
String categoryName = flow.getParentGroupName();
String feedName = flow.getName();
feedName = FeedNameUtil.fullName(categoryName, feedName);
// if it is a versioned feed then strip the version to get the correct feed name
feedName = TemplateCreationHelper.parseVersionedProcessGroupName(feedName);
flow.setFeedName(feedName);
return flow;
}
use of com.thinkbiganalytics.nifi.rest.model.visitor.NifiFlowBuilder in project kylo by Teradata.
the class NifiRestTest method testOrder.
// @Test
public void testOrder() throws Exception {
NifiVisitableProcessGroup g = restClient.getFlowOrder("63de0732-015e-1000-f198-dcd76ac2942e", null);
NifiFlowProcessGroup flow = new NifiFlowBuilder().build(g);
// NifiFlowProcessGroup flow2 = restClient.getFeedFlow("27ab143a-0159-1000-4f6a-30f3746a341e");
// List<String> feeds = Lists.newArrayList();
// feeds.add("sample.new_feed_three");
// List<NifiFlowProcessGroup> flows3 = restClient.getNiFiRestClient().flows().getFeedFlows(feeds);
// List<NifiFlowProcessGroup> feedFlows = restClient.getFeedFlows();
int i = 0;
}
Aggregations