use of org.hypertrace.core.documentstore.Filter in project entity-service by hypertrace.
the class DocStoreConverter method transformToOrFilterChainForStrArray.
private static Filter transformToOrFilterChainForStrArray(AttributeFilter attributeFilter) {
String fieldName = attributeFilter.getName() + VALUE_LIST_VALUES_CONST;
Filter f = new Filter();
f.setFieldName("");
f.setOp(Op.OR);
f.setChildFilters(attributeFilter.getAttributeValue().getValueList().getValuesList().stream().map(rhsAttributeValue -> createEqFilterForAttributeValue(fieldName, rhsAttributeValue)).collect(Collectors.toList()).toArray(new Filter[] {}));
return f;
}
use of org.hypertrace.core.documentstore.Filter in project entity-service by hypertrace.
the class DocStoreConverter method transform.
public static org.hypertrace.core.documentstore.Query transform(@Nonnull String tenantId, @Nonnull Query query, List<String> selections) {
org.hypertrace.core.documentstore.Query docStoreQuery = new org.hypertrace.core.documentstore.Query();
List<Filter> filters = new ArrayList<>();
filters.add(getTenantIdEqFilter(tenantId));
if (!query.getEntityIdList().isEmpty()) {
filters.add(new Filter(Filter.Op.IN, EntityServiceConstants.ENTITY_ID, query.getEntityIdList()));
}
if (StringUtils.isNotEmpty(query.getEntityType())) {
filters.add(new Filter(Filter.Op.EQ, EntityServiceConstants.ENTITY_TYPE, query.getEntityType()));
}
if (StringUtils.isNotEmpty(query.getEntityName())) {
filters.add(new Filter(Filter.Op.EQ, EntityServiceConstants.ENTITY_NAME, query.getEntityName()));
}
if (query.hasFilter()) {
filters.add(transform(query.getFilter()));
}
if (!filters.isEmpty()) {
if (filters.size() == 1) {
docStoreQuery.setFilter(filters.get(0));
} else {
Filter f = new Filter();
f.setOp(Filter.Op.AND);
f.setChildFilters(filters.toArray(new Filter[] {}));
docStoreQuery.setFilter(f);
}
}
if (!selections.isEmpty()) {
docStoreQuery.addAllSelections(selections);
}
if (query.getOrderByCount() > 0) {
docStoreQuery.addAllOrderBys(transformOrderBy(query.getOrderByList()));
}
if (query.getLimit() > 0) {
docStoreQuery.setLimit(query.getLimit());
}
if (query.getOffset() > 0) {
docStoreQuery.setOffset(query.getOffset());
}
return docStoreQuery;
}
use of org.hypertrace.core.documentstore.Filter in project entity-service by hypertrace.
the class DocStoreConverter method transformToNeqFilterWithValueListRhs.
private static Filter transformToNeqFilterWithValueListRhs(AttributeFilter attributeFilter) {
String fieldName = attributeFilter.getName() + VALUE_LIST_VALUES_CONST;
Filter f = new Filter();
f.setFieldName(fieldName);
f.setOp(Op.NEQ);
f.setValue(prepareRhsValueForSpecialValueListCase(attributeFilter.getAttributeValue()));
// Set child filters to empty array
f.setChildFilters(new Filter[] {});
return f;
}
use of org.hypertrace.core.documentstore.Filter in project entity-service by hypertrace.
the class DocStoreConverter method transformToAndFilterChainForStrArray.
private static Filter transformToAndFilterChainForStrArray(AttributeFilter attributeFilter) {
String fieldName = attributeFilter.getName() + VALUE_LIST_VALUES_CONST;
Filter f = new Filter();
f.setFieldName("");
f.setOp(Op.AND);
List<Filter> filters = attributeFilter.getAttributeValue().getValueList().getValuesList().stream().map(rhsAttributeValue -> createNeqFilterForAttributeValue(fieldName, rhsAttributeValue)).collect(Collectors.toList());
f.setChildFilters(filters.toArray(new Filter[] {}));
return f;
}
use of org.hypertrace.core.documentstore.Filter in project entity-service by hypertrace.
the class DocStoreConverter method createNeqFilterForAttributeValue.
private static Filter createNeqFilterForAttributeValue(String fieldName, AttributeValue attributeValue) {
Filter f = new Filter();
f.setFieldName(fieldName);
f.setOp(Op.NEQ);
f.setValue(prepareRhsValueForSpecialValueListCase(attributeValue));
// Set child filters to empty array
f.setChildFilters(new Filter[] {});
return f;
}
Aggregations