Search in sources :

Example 1 with NsiliDataModel

use of org.codice.alliance.nsili.common.datamodel.NsiliDataModel in project alliance by codice.

the class SubmitQueryRequestImpl method complete_DAG_results.

@Override
public State complete_DAG_results(DAGListHolder results) throws ProcessingFault, SystemFault {
    DAG[] noResults = new DAG[0];
    results.value = noResults;
    List<DAG> dags = new ArrayList<>();
    int totalHits = 0;
    List<Result> queryResults = getResults(query, totalHitsReturned);
    LOGGER.debug("Query: {} return NSILI results: {}", query.bqs_query, queryResults.size());
    Map<String, List<String>> mandatoryAttributes = new HashMap<>();
    if (outgoingValidationEnabled) {
        NsiliDataModel nsiliDataModel = new NsiliDataModel();
        mandatoryAttributes = nsiliDataModel.getRequiredAttrsForView(NsiliConstants.NSIL_ALL_VIEW);
    }
    for (Result result : queryResults) {
        try {
            DAG dag = ResultDAGConverter.convertResult(result, _orb(), _poa(), resultAttributes, mandatoryAttributes);
            if (dag != null) {
                dags.add(dag);
                totalHits++;
                totalHitsReturned++;
            }
        } catch (DagParsingException dpe) {
            LOGGER.debug("DAG could not be parsed and will not be returned to caller:", dpe);
        }
        if (totalHits >= maxNumReturnedHits) {
            break;
        }
    }
    if (!dags.isEmpty()) {
        results.value = dags.toArray(new DAG[0]);
        LOGGER.debug("Number of results being returned: {}, requested: {}", results.value.length, maxNumReturnedHits);
    } else {
        LOGGER.debug("No results will be returned");
        results.value = noResults;
    }
    return State.COMPLETED;
}
Also used : DagParsingException(org.codice.alliance.nsili.common.DagParsingException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DAG(org.codice.alliance.nsili.common.UCO.DAG) NsiliEndpoint(org.codice.alliance.nsili.endpoint.NsiliEndpoint) NsiliDataModel(org.codice.alliance.nsili.common.datamodel.NsiliDataModel) Result(ddf.catalog.data.Result) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with NsiliDataModel

use of org.codice.alliance.nsili.common.datamodel.NsiliDataModel in project alliance by codice.

the class GetParametersRequestImpl method complete.

@Override
public State complete(DAGHolder parameters) throws ProcessingFault, SystemFault {
    Filter filter = filterBuilder.attribute(Metacard.ID).is().equalTo().text(productIdStr);
    Query query = new QueryImpl(filter);
    Result result = getResult(query);
    if (result == null) {
        return State.COMPLETED;
    }
    Map<String, List<String>> mandatoryAttributes = new HashMap<>();
    if (outgoingValidationEnabled) {
        NsiliDataModel nsiliDataModel = new NsiliDataModel();
        mandatoryAttributes = nsiliDataModel.getRequiredAttrsForView(NsiliConstants.NSIL_ALL_VIEW);
    }
    try {
        if (desiredParameters != null) {
            if (isParamContained(desiredParameters, "ALL")) {
                parameters.value = ResultDAGConverter.convertResult(result, _orb(), _poa(), new ArrayList<>(), mandatoryAttributes);
            } else if (isParamContained(desiredParameters, "CORE")) {
                throw new NO_IMPLEMENT("CORE desired_parameter not supported");
            } else if (isParamContained(desiredParameters, "ORDER")) {
                throw new NO_IMPLEMENT("ORDER desired_parameter not supported");
            } else {
                parameters.value = ResultDAGConverter.convertResult(result, _orb(), _poa(), Arrays.asList(desiredParameters), mandatoryAttributes);
            }
        } else {
            if (result != null) {
                parameters.value = ResultDAGConverter.convertResult(result, _orb(), _poa(), new ArrayList<>(), mandatoryAttributes);
            }
        }
    } catch (DagParsingException dpe) {
        LOGGER.debug("DAG could not be parsed and will not be returned to caller:", dpe);
    }
    return State.COMPLETED;
}
Also used : NO_IMPLEMENT(org.omg.CORBA.NO_IMPLEMENT) DagParsingException(org.codice.alliance.nsili.common.DagParsingException) QueryImpl(ddf.catalog.operation.impl.QueryImpl) Query(ddf.catalog.operation.Query) Filter(org.opengis.filter.Filter) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) NsiliDataModel(org.codice.alliance.nsili.common.datamodel.NsiliDataModel) Result(ddf.catalog.data.Result)

Aggregations

Result (ddf.catalog.data.Result)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 DagParsingException (org.codice.alliance.nsili.common.DagParsingException)2 NsiliDataModel (org.codice.alliance.nsili.common.datamodel.NsiliDataModel)2 Query (ddf.catalog.operation.Query)1 QueryImpl (ddf.catalog.operation.impl.QueryImpl)1 DAG (org.codice.alliance.nsili.common.UCO.DAG)1 NsiliEndpoint (org.codice.alliance.nsili.endpoint.NsiliEndpoint)1 NO_IMPLEMENT (org.omg.CORBA.NO_IMPLEMENT)1 Filter (org.opengis.filter.Filter)1