use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeListCriteriaPair in project UVMS-ExchangeModule-APP by UnionVMS.
the class SearchFieldMapper method getSearchValueForMessageDirection.
private static SearchValue getSearchValueForMessageDirection(ExchangeListCriteriaPair criteria) {
if (!SearchField.MESSAGE_DIRECTION.equals(criteria.getKey()) || criteria.getValue() == null) {
return null;
}
MessageDirection messageDirection = MessageDirection.valueOf(criteria.getValue());
SearchValue searchValue = null;
switch(messageDirection) {
case ALL:
searchValue = null;
break;
case INCOMING:
searchValue = new SearchValue(ExchangeSearchField.TRANSFER_INCOMING, "true");
break;
case OUTGOING:
searchValue = new SearchValue(ExchangeSearchField.TRANSFER_INCOMING, "false");
break;
default:
searchValue = null;
}
return searchValue;
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeListCriteriaPair in project UVMS-Docker by UnionVMS.
the class ExchangeLogRestIT method getLogListByCriteriaTest.
/**
* Gets the log list by criteria test.
*
* @return the log list by criteria test
* @throws Exception the exception
*/
@Test
public void getLogListByCriteriaTest() throws Exception {
ExchangeListQuery exchangeListQuery = new ExchangeListQuery();
ExchangeListCriteria exchangeListCriteria = new ExchangeListCriteria();
exchangeListCriteria.setIsDynamic(true);
ExchangeListCriteriaPair exchangeListCriteriaPair = new ExchangeListCriteriaPair();
exchangeListCriteriaPair.setKey(SearchField.STATUS);
exchangeListCriteriaPair.setValue("SUCCESSFUL");
exchangeListCriteria.getCriterias().add(exchangeListCriteriaPair);
exchangeListQuery.setExchangeSearchCriteria(exchangeListCriteria);
ExchangeListPagination exchangeListPagination = new ExchangeListPagination();
exchangeListPagination.setPage(1);
exchangeListPagination.setListSize(100);
exchangeListQuery.setPagination(exchangeListPagination);
final HttpResponse response = Request.Post(getBaseUrl() + "exchange/rest/exchange/list").bodyByteArray(writeValueAsString(exchangeListQuery).getBytes()).setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).execute().returnResponse();
Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
List<List> logList = (List) dataMap.get("logList");
assertFalse(logList.isEmpty());
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeListCriteriaPair in project UVMS-ExchangeModule-APP by UnionVMS.
the class SearchFieldMapper method mapSearchField.
/**
* Converts List<ListCriteria> to List<SearchValue> so that a JPQL query can
* be built based on the criterias
*
* @param listCriterias
* @return
* @throws ExchangeSearchMapperException
*/
public static List<SearchValue> mapSearchField(List<ExchangeListCriteriaPair> listCriterias) throws ExchangeSearchMapperException {
if (CollectionUtils.isEmpty(listCriterias)) {
LOG.debug(" Non valid search criteria when mapping ListCriterias to SearchValue, List is null or empty");
return new ArrayList<>();
}
List<SearchValue> searchFields = new ArrayList<>();
for (ExchangeListCriteriaPair criteria : listCriterias) {
try {
if (SearchField.MESSAGE_DIRECTION.equals(criteria.getKey())) {
SearchValue searchValue = getSearchValueForMessageDirection(criteria);
if (searchValue == null) {
continue;
}
searchFields.add(searchValue);
} else {
ExchangeSearchField field = mapCriteria(criteria.getKey());
searchFields.add(new SearchValue(field, criteria.getValue()));
}
} catch (ExchangeSearchMapperException ex) {
LOG.debug("[ Error when mapping to search field.. continuing with other criterias ]");
}
}
return searchFields;
}
Aggregations