Search in sources :

Example 1 with ProvenanceOptionsDTO

use of org.apache.nifi.web.api.dto.provenance.ProvenanceOptionsDTO in project nifi by apache.

the class ControllerFacade method getProvenanceSearchOptions.

/**
 * Gets the available options for searching provenance.
 *
 * @return the available options for searching provenance
 */
public ProvenanceOptionsDTO getProvenanceSearchOptions() {
    final ProvenanceRepository provenanceRepository = flowController.getProvenanceRepository();
    // create the search options dto
    final ProvenanceOptionsDTO searchOptions = new ProvenanceOptionsDTO();
    final List<ProvenanceSearchableFieldDTO> searchableFieldNames = new ArrayList<>();
    final List<SearchableField> fields = provenanceRepository.getSearchableFields();
    for (final SearchableField field : fields) {
        // we prefer the user queries using startDate and endDate
        if (SearchableFields.EventTime.equals(field)) {
            continue;
        }
        final ProvenanceSearchableFieldDTO searchableField = new ProvenanceSearchableFieldDTO();
        searchableField.setId(field.getIdentifier());
        searchableField.setField(field.getSearchableFieldName());
        searchableField.setLabel(field.getFriendlyName());
        searchableField.setType(field.getFieldType().name());
        searchableFieldNames.add(searchableField);
    }
    final List<SearchableField> searchableAttributes = provenanceRepository.getSearchableAttributes();
    for (final SearchableField searchableAttr : searchableAttributes) {
        final ProvenanceSearchableFieldDTO searchableAttribute = new ProvenanceSearchableFieldDTO();
        searchableAttribute.setId(searchableAttr.getIdentifier());
        searchableAttribute.setField(searchableAttr.getSearchableFieldName());
        searchableAttribute.setLabel(searchableAttr.getFriendlyName());
        searchableAttribute.setType(searchableAttr.getFieldType().name());
        searchableFieldNames.add(searchableAttribute);
    }
    searchOptions.setSearchableFields(searchableFieldNames);
    return searchOptions;
}
Also used : ProvenanceSearchableFieldDTO(org.apache.nifi.web.api.dto.provenance.ProvenanceSearchableFieldDTO) ProvenanceOptionsDTO(org.apache.nifi.web.api.dto.provenance.ProvenanceOptionsDTO) ArrayList(java.util.ArrayList) ProvenanceRepository(org.apache.nifi.provenance.ProvenanceRepository) SearchableField(org.apache.nifi.provenance.search.SearchableField)

Example 2 with ProvenanceOptionsDTO

use of org.apache.nifi.web.api.dto.provenance.ProvenanceOptionsDTO in project nifi by apache.

the class ProvenanceResource method getSearchOptions.

/**
 * Gets the provenance search options for this NiFi.
 *
 * @return A provenanceOptionsEntity
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("search-options")
@ApiOperation(value = "Gets the searchable attributes for provenance events", response = ProvenanceOptionsEntity.class, authorizations = { @Authorization(value = "Read - /provenance") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response getSearchOptions() {
    authorizeProvenanceRequest();
    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }
    // get provenance search options
    final ProvenanceOptionsDTO searchOptions = serviceFacade.getProvenanceSearchOptions();
    // create the response entity
    final ProvenanceOptionsEntity entity = new ProvenanceOptionsEntity();
    entity.setProvenanceOptions(searchOptions);
    // generate the response
    return noCache(Response.ok(entity)).build();
}
Also used : ProvenanceOptionsDTO(org.apache.nifi.web.api.dto.provenance.ProvenanceOptionsDTO) ProvenanceOptionsEntity(org.apache.nifi.web.api.entity.ProvenanceOptionsEntity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ProvenanceOptionsDTO (org.apache.nifi.web.api.dto.provenance.ProvenanceOptionsDTO)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 ArrayList (java.util.ArrayList)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 ProvenanceRepository (org.apache.nifi.provenance.ProvenanceRepository)1 SearchableField (org.apache.nifi.provenance.search.SearchableField)1 ProvenanceSearchableFieldDTO (org.apache.nifi.web.api.dto.provenance.ProvenanceSearchableFieldDTO)1 ProvenanceOptionsEntity (org.apache.nifi.web.api.entity.ProvenanceOptionsEntity)1