use of org.apache.nifi.web.api.dto.provenance.lineage.LineageResultsDTO in project nifi by apache.
the class ProvenanceResource method populateRemainingLineageContent.
/**
* Populates the uri for the specified lineage.
*/
private LineageDTO populateRemainingLineageContent(LineageDTO lineage, String clusterNodeId) {
lineage.setUri(generateResourceUri("provenance", "lineage", lineage.getId()));
// set the cluster node id
lineage.getRequest().setClusterNodeId(clusterNodeId);
final LineageResultsDTO results = lineage.getResults();
if (results != null && results.getNodes() != null) {
results.getNodes().forEach(node -> node.setClusterNodeIdentifier(clusterNodeId));
}
return lineage;
}
use of org.apache.nifi.web.api.dto.provenance.lineage.LineageResultsDTO in project nifi by apache.
the class DtoFactory method createLineageDto.
/**
* Creates a LineageDTO for the specified Lineage.
*
* @param computeLineageSubmission submission
* @return dto
*/
public LineageDTO createLineageDto(final ComputeLineageSubmission computeLineageSubmission) {
// build the lineage dto
final LineageDTO dto = new LineageDTO();
final LineageRequestDTO requestDto = new LineageRequestDTO();
final LineageResultsDTO resultsDto = new LineageResultsDTO();
// include the original request and results
dto.setRequest(requestDto);
dto.setResults(resultsDto);
// rebuild the request from the submission object
switch(computeLineageSubmission.getLineageComputationType()) {
case EXPAND_CHILDREN:
requestDto.setEventId(computeLineageSubmission.getExpandedEventId());
requestDto.setLineageRequestType(LineageRequestType.CHILDREN);
break;
case EXPAND_PARENTS:
requestDto.setEventId(computeLineageSubmission.getExpandedEventId());
requestDto.setLineageRequestType(LineageRequestType.PARENTS);
break;
case FLOWFILE_LINEAGE:
final Collection<String> uuids = computeLineageSubmission.getLineageFlowFileUuids();
if (uuids.size() == 1) {
requestDto.setUuid(uuids.iterator().next());
}
requestDto.setEventId(computeLineageSubmission.getExpandedEventId());
requestDto.setLineageRequestType(LineageRequestType.FLOWFILE);
break;
}
// include lineage details
dto.setId(computeLineageSubmission.getLineageIdentifier());
dto.setSubmissionTime(computeLineageSubmission.getSubmissionTime());
// create the results dto
final ComputeLineageResult results = computeLineageSubmission.getResult();
dto.setFinished(results.isFinished());
dto.setPercentCompleted(results.getPercentComplete());
dto.setExpiration(results.getExpiration());
final List<LineageNode> nodes = results.getNodes();
final List<LineageEdge> edges = results.getEdges();
final List<ProvenanceNodeDTO> nodeDtos = new ArrayList<>();
if (results.isFinished()) {
// create the node dto's
for (final LineageNode node : nodes) {
switch(node.getNodeType()) {
case FLOWFILE_NODE:
nodeDtos.add(createFlowFileNodeDTO(node));
break;
case PROVENANCE_EVENT_NODE:
nodeDtos.add(createProvenanceEventNodeDTO((ProvenanceEventLineageNode) node));
break;
}
}
}
resultsDto.setNodes(nodeDtos);
// include any errors
if (results.getError() != null) {
final Set<String> errors = new HashSet<>();
errors.add(results.getError());
resultsDto.setErrors(errors);
}
// create the link dto's
final List<ProvenanceLinkDTO> linkDtos = new ArrayList<>();
for (final LineageEdge edge : edges) {
linkDtos.add(createProvenanceLinkDTO(edge));
}
resultsDto.setLinks(linkDtos);
return dto;
}
Aggregations