Search in sources :

Example 1 with ProvenanceNodeDTO

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;
}
Also used : ProvenanceNodeDTO(org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceNodeDTO) Date(java.util.Date)

Example 2 with ProvenanceNodeDTO

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;
}
Also used : ProvenanceNodeDTO(org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceNodeDTO) Date(java.util.Date)

Example 3 with ProvenanceNodeDTO

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;
}
Also used : ComputeLineageResult(org.apache.nifi.provenance.lineage.ComputeLineageResult) LineageDTO(org.apache.nifi.web.api.dto.provenance.lineage.LineageDTO) ArrayList(java.util.ArrayList) ProvenanceNodeDTO(org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceNodeDTO) LineageRequestDTO(org.apache.nifi.web.api.dto.provenance.lineage.LineageRequestDTO) ProvenanceEventLineageNode(org.apache.nifi.provenance.lineage.ProvenanceEventLineageNode) LineageResultsDTO(org.apache.nifi.web.api.dto.provenance.lineage.LineageResultsDTO) LineageEdge(org.apache.nifi.provenance.lineage.LineageEdge) ProvenanceEventLineageNode(org.apache.nifi.provenance.lineage.ProvenanceEventLineageNode) LineageNode(org.apache.nifi.provenance.lineage.LineageNode) ProvenanceLinkDTO(org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceLinkDTO) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

ProvenanceNodeDTO (org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceNodeDTO)3 Date (java.util.Date)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 ComputeLineageResult (org.apache.nifi.provenance.lineage.ComputeLineageResult)1 LineageEdge (org.apache.nifi.provenance.lineage.LineageEdge)1 LineageNode (org.apache.nifi.provenance.lineage.LineageNode)1 ProvenanceEventLineageNode (org.apache.nifi.provenance.lineage.ProvenanceEventLineageNode)1 LineageDTO (org.apache.nifi.web.api.dto.provenance.lineage.LineageDTO)1 LineageRequestDTO (org.apache.nifi.web.api.dto.provenance.lineage.LineageRequestDTO)1 LineageResultsDTO (org.apache.nifi.web.api.dto.provenance.lineage.LineageResultsDTO)1 ProvenanceLinkDTO (org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceLinkDTO)1