use of com.thinkbiganalytics.nifi.rest.visitor.NifiConnectionOrderVisitor in project kylo by Teradata.
the class DefaultNiFiFlowVisitorClient method getFlowOrder.
/**
* @param processGroupEntity
* @param cache
* @param logRestAccessErrors
* @return
* @throws NifiComponentNotFoundException
*/
public NifiVisitableProcessGroup getFlowOrder(ProcessGroupDTO processGroupEntity, NifiConnectionOrderVisitorCache cache, boolean logRestAccessErrors) throws NifiComponentNotFoundException {
if (cache == null) {
cache = new NifiConnectionOrderVisitorCache();
}
final NifiConnectionOrderVisitorCache finalCache = cache;
Optional<ProcessGroupDTO> cachedProcessGroup = cache.getProcessGroup(processGroupEntity.getId());
if (!cachedProcessGroup.isPresent() && processGroupEntity.getContents() != null) {
NifiProcessUtil.getProcessGroups(processGroupEntity).stream().forEach(processGroupDTO -> finalCache.add(processGroupDTO));
}
NifiVisitableProcessGroup group = null;
if (processGroupEntity != null) {
group = new NifiVisitableProcessGroup(processGroupEntity);
NifiConnectionOrderVisitor orderVisitor = new NifiConnectionOrderVisitor(restClient, group, finalCache);
try {
Optional<ProcessGroupDTO> parent = cache.getProcessGroup(processGroupEntity.getParentGroupId());
if (!parent.isPresent()) {
parent = restClient.processGroups().findById(processGroupEntity.getParentGroupId(), false, false, logRestAccessErrors);
}
if (parent.isPresent()) {
group.setParentProcessGroup(parent.get());
}
} catch (NifiComponentNotFoundException e) {
// cant find the parent
}
group.accept(orderVisitor);
finalCache.add(orderVisitor.toCachedItem());
}
return group;
}
Aggregations