use of org.codice.alliance.nsili.common.DagParsingException 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;
}
use of org.codice.alliance.nsili.common.DagParsingException 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;
}
Aggregations