Search in sources :

Example 1 with SourceProcessingDetails

use of ddf.catalog.operation.SourceProcessingDetails in project ddf by codice.

the class MigrateCommand method query.

@Override
protected SourceResponse query(CatalogFacade framework, Filter filter, int startIndex, long querySize) {
    QueryImpl query = new QueryImpl(filter);
    query.setRequestsTotalResultsCount(true);
    query.setPageSize((int) querySize);
    query.setSortBy(new SortByImpl(Metacard.MODIFIED, SortOrder.DESCENDING));
    QueryRequest queryRequest = new QueryRequestImpl(query);
    query.setStartIndex(startIndex);
    SourceResponse response;
    try {
        LOGGER.debug("Querying with startIndex: {}", startIndex);
        response = framework.query(queryRequest);
    } catch (UnsupportedQueryException | SourceUnavailableException | FederationException e) {
        printErrorMessage(String.format("Received error from Frameworks: %s%n", e.getMessage()));
        return null;
    }
    if (response.getProcessingDetails() != null && !response.getProcessingDetails().isEmpty()) {
        for (SourceProcessingDetails details : response.getProcessingDetails()) {
            LOGGER.debug("Got Issues: {}", details.getWarnings());
        }
        return null;
    }
    return response;
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponse(ddf.catalog.operation.SourceResponse) SortByImpl(ddf.catalog.filter.impl.SortByImpl) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FederationException(ddf.catalog.federation.FederationException) SourceProcessingDetails(ddf.catalog.operation.SourceProcessingDetails)

Example 2 with SourceProcessingDetails

use of ddf.catalog.operation.SourceProcessingDetails in project ddf by codice.

the class ReplicateCommand method query.

@Override
protected SourceResponse query(CatalogFacade framework, Filter filter, int startIndex, long querySize) {
    QueryImpl query = new QueryImpl(filter);
    query.setRequestsTotalResultsCount(true);
    query.setPageSize((int) querySize);
    query.setSortBy(new SortByImpl(Metacard.EFFECTIVE, SortOrder.DESCENDING));
    QueryRequest queryRequest = new QueryRequestImpl(query, Arrays.asList(sourceId));
    query.setStartIndex(startIndex);
    SourceResponse response;
    try {
        LOGGER.debug("Querying with startIndex: {}", startIndex);
        response = framework.query(queryRequest);
    } catch (UnsupportedQueryException | SourceUnavailableException | FederationException e) {
        printErrorMessage(String.format("Received error from %s: %s%n", sourceId, e.getMessage()));
        return null;
    }
    if (response.getProcessingDetails() != null && !response.getProcessingDetails().isEmpty()) {
        for (SourceProcessingDetails details : response.getProcessingDetails()) {
            LOGGER.debug("Got Issues: {}", details.getWarnings());
        }
        return null;
    }
    final long totalHits = response.getHits();
    if (totalHits == 0) {
        console.println("No records were found to replicate.");
        return null;
    }
    return response;
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponse(ddf.catalog.operation.SourceResponse) SortByImpl(ddf.catalog.filter.impl.SortByImpl) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FederationException(ddf.catalog.federation.FederationException) SourceProcessingDetails(ddf.catalog.operation.SourceProcessingDetails)

Example 3 with SourceProcessingDetails

use of ddf.catalog.operation.SourceProcessingDetails in project ddf by codice.

the class SortedQueryMonitor method executePostFederationQueryPlugins.

private SourceResponse executePostFederationQueryPlugins(SourceResponse sourceResponse, QueryRequest queryRequest, String sourceId, Set<ProcessingDetails> processingDetails) {
    final HashSet<ProcessingDetails> newProcessingDetails = new HashSet<>(processingDetails);
    newProcessingDetails.addAll(sourceProcessingDetailsToProcessingDetails(sourceId, sourceResponse));
    QueryResponse queryResponse = new QueryResponseImpl(queryRequest, sourceResponse.getResults(), true, sourceResponse.getHits(), sourceResponse.getProperties(), newProcessingDetails);
    try {
        for (PostFederatedQueryPlugin service : postQuery) {
            try {
                queryResponse = service.process(queryResponse);
            } catch (PluginExecutionException e) {
                LOGGER.info("Error executing PostFederatedQueryPlugin", e);
            }
        }
    } catch (StopProcessingException e) {
        LOGGER.info("Plugin stopped processing", e);
    }
    Set<SourceProcessingDetails> detailsOfResponseAfterPlugins = new HashSet<>(queryResponse.getProcessingDetails());
    return new SourceResponseImpl(queryRequest, sourceResponse.getProperties(), queryResponse.getResults(), queryResponse.getHits(), detailsOfResponseAfterPlugins);
}
Also used : SourceProcessingDetails(ddf.catalog.operation.SourceProcessingDetails) ProcessingDetails(ddf.catalog.operation.ProcessingDetails) QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) QueryResponse(ddf.catalog.operation.QueryResponse) StopProcessingException(ddf.catalog.plugin.StopProcessingException) PostFederatedQueryPlugin(ddf.catalog.plugin.PostFederatedQueryPlugin) PluginExecutionException(ddf.catalog.plugin.PluginExecutionException) HashSet(java.util.HashSet) SourceProcessingDetails(ddf.catalog.operation.SourceProcessingDetails)

Aggregations

SourceProcessingDetails (ddf.catalog.operation.SourceProcessingDetails)3 FederationException (ddf.catalog.federation.FederationException)2 SortByImpl (ddf.catalog.filter.impl.SortByImpl)2 QueryRequest (ddf.catalog.operation.QueryRequest)2 SourceResponse (ddf.catalog.operation.SourceResponse)2 QueryImpl (ddf.catalog.operation.impl.QueryImpl)2 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)2 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)2 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)2 ProcessingDetails (ddf.catalog.operation.ProcessingDetails)1 QueryResponse (ddf.catalog.operation.QueryResponse)1 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)1 SourceResponseImpl (ddf.catalog.operation.impl.SourceResponseImpl)1 PluginExecutionException (ddf.catalog.plugin.PluginExecutionException)1 PostFederatedQueryPlugin (ddf.catalog.plugin.PostFederatedQueryPlugin)1 StopProcessingException (ddf.catalog.plugin.StopProcessingException)1 HashSet (java.util.HashSet)1