use of org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceNodeDTO in project nifi by apache.
the class DtoFactory method createProvenanceEventNodeDTO.
/**
* Creates a ProvenanceEventNodeDTO for the specified ProvenanceEventLineageNode.
*
* @param node node
* @return dto
*/
public ProvenanceNodeDTO createProvenanceEventNodeDTO(final ProvenanceEventLineageNode node) {
final ProvenanceNodeDTO dto = new ProvenanceNodeDTO();
dto.setId(node.getIdentifier());
dto.setType("EVENT");
dto.setEventType(node.getEventType().toString());
dto.setTimestamp(new Date(node.getTimestamp()));
dto.setMillis(node.getTimestamp());
dto.setFlowFileUuid(node.getFlowFileUuid());
dto.setParentUuids(node.getParentUuids());
dto.setChildUuids(node.getChildUuids());
return dto;
}
use of org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceNodeDTO in project nifi by apache.
the class DtoFactory method createFlowFileNodeDTO.
/**
* Creates a FlowFileNodeDTO for the specified LineageNode.
*
* @param node node
* @return dto
*/
public ProvenanceNodeDTO createFlowFileNodeDTO(final LineageNode node) {
final ProvenanceNodeDTO dto = new ProvenanceNodeDTO();
dto.setId(node.getIdentifier());
dto.setType("FLOWFILE");
dto.setTimestamp(new Date(node.getTimestamp()));
dto.setMillis(node.getTimestamp());
dto.setFlowFileUuid(node.getFlowFileUuid());
return dto;
}
use of org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceNodeDTO 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