use of org.molgenis.data.support.AggregateQueryImpl in project molgenis by molgenis.
the class PlatformIT method runAggregateQuery.
private AggregateResult runAggregateQuery(String attrX, String attrY, String attrDistinct, Query<Entity> query) {
requireNonNull(attrX);
requireNonNull(query);
Attribute x = entityTypeDynamic.getAttribute(attrX);
Attribute y = attrY != null ? entityTypeDynamic.getAttribute(attrY) : null;
Attribute distinct = attrDistinct != null ? entityTypeDynamic.getAttribute(attrDistinct) : null;
AggregateQuery aggregateQuery = new AggregateQueryImpl(x, y, distinct, query);
return runAsSystem(() -> dataService.aggregate(entityTypeDynamic.getId(), aggregateQuery));
}
use of org.molgenis.data.support.AggregateQueryImpl in project molgenis by molgenis.
the class DataServiceIT method testAggregateTwoDimensionalDistinct.
@WithMockUser(username = USERNAME_READ)
@Test(groups = "readtest")
public void testAggregateTwoDimensionalDistinct() {
AggregateQuery aggregateQuery = new AggregateQueryImpl().query(new QueryImpl<>()).attrX(entityType.getAttribute(ATTR_BOOL)).attrY(entityType.getAttribute(ATTR_BOOL)).attrDistinct(entityType.getAttribute(ATTR_ENUM));
AggregateResult result = dataService.aggregate(entityType.getId(), aggregateQuery);
AggregateResult expectedResult = new AggregateResult(asList(asList(1L, 0L), asList(0L, 1L)), asList(0L, 1L), asList(0L, 1L));
assertEquals(result, expectedResult);
}
use of org.molgenis.data.support.AggregateQueryImpl in project molgenis by molgenis.
the class DataServiceIT method testAggregateTwoDimensionalQuery.
@WithMockUser(username = USERNAME_READ)
@Test(groups = "readtest")
public void testAggregateTwoDimensionalQuery() {
AggregateQuery aggregateQuery = new AggregateQueryImpl().query(new QueryImpl<>()).attrX(entityType.getAttribute(ATTR_BOOL)).attrY(entityType.getAttribute(ATTR_BOOL)).query(new QueryImpl<>().gt(ATTR_INT, 10));
AggregateResult result = dataService.aggregate(entityType.getId(), aggregateQuery);
AggregateResult expectedResult = new AggregateResult(asList(asList(1L, 0L), asList(0L, 1L)), asList(0L, 1L), asList(0L, 1L));
assertEquals(result, expectedResult);
}
use of org.molgenis.data.support.AggregateQueryImpl in project molgenis by molgenis.
the class DataServiceIT method testAggregateTwoDimensionalQueryDistinct.
@WithMockUser(username = USERNAME_READ)
@Test(groups = "readtest")
public void testAggregateTwoDimensionalQueryDistinct() {
AggregateQuery aggregateQuery = new AggregateQueryImpl().query(new QueryImpl<>()).attrX(entityType.getAttribute(ATTR_BOOL)).attrY(entityType.getAttribute(ATTR_ENUM)).attrDistinct(entityType.getAttribute(ATTR_ENUM)).query(new QueryImpl<>().gt(ATTR_INT, 1));
AggregateResult result = dataService.aggregate(entityType.getId(), aggregateQuery);
AggregateResult expectedResult = new AggregateResult(asList(asList(0L, 1L), asList(1L, 0L)), asList(0L, 1L), asList("option1", "option2"));
assertEquals(result, expectedResult);
}
use of org.molgenis.data.support.AggregateQueryImpl in project molgenis by molgenis.
the class DataServiceIT method testAggregateOneDimensionalDistinct.
@WithMockUser(username = USERNAME_READ)
@Test(groups = "readtest")
public void testAggregateOneDimensionalDistinct() {
AggregateQuery aggregateQuery = new AggregateQueryImpl().query(new QueryImpl<>()).attrX(entityType.getAttribute(ATTR_BOOL)).attrDistinct(entityType.getAttribute(ATTR_ENUM));
AggregateResult result = dataService.aggregate(entityType.getId(), aggregateQuery);
AggregateResult expectedResult = new AggregateResult(asList(singletonList(1L), singletonList(1L)), asList(0L, 1L), emptyList());
assertEquals(result, expectedResult);
}
Aggregations