use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class HibernateEventVisualizationStore method getEventVisualizationsLikeName.
private List<EventVisualization> getEventVisualizationsLikeName(final Set<String> words, final int first, final int max, final EventVisualizationSet eventVisualizationSet) {
final CriteriaBuilder builder = getCriteriaBuilder();
final JpaQueryParameters<EventVisualization> params = new JpaQueryParameters<EventVisualization>().addPredicates(getSharingPredicates(builder)).addOrder(root -> builder.asc(root.get("name"))).setFirstResult(first).setMaxResults(max);
if (words.isEmpty()) {
return getList(builder, params);
}
final List<Function<Root<EventVisualization>, Predicate>> conjunction = new ArrayList<>(1);
for (final String word : words) {
conjunction.add(root -> builder.like(builder.lower(root.get("name")), "%" + word.toLowerCase() + "%"));
}
params.addPredicate(root -> builder.and(conjunction.stream().map(p -> p.apply(root)).collect(Collectors.toList()).toArray(new Predicate[0])));
setCorrectPredicates(eventVisualizationSet, builder, params);
return getList(builder, params);
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class HibernateEventVisualizationStore method getEventVisualizations.
private List<EventVisualization> getEventVisualizations(final int first, final int max, final EventVisualizationSet eventVisualizationSet) {
final CriteriaBuilder builder = getCriteriaBuilder();
final JpaQueryParameters<EventVisualization> params = new JpaQueryParameters<EventVisualization>().addPredicates(getSharingPredicates(builder)).addOrder(root -> builder.asc(root.get("name"))).setFirstResult(first).setMaxResults(max);
setCorrectPredicates(eventVisualizationSet, builder, params);
return getList(builder, params);
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class DimensionServiceTest method testMergeAnalyticalEventObjectDataElementGroupSet.
@Test
void testMergeAnalyticalEventObjectDataElementGroupSet() {
// Given
EventVisualization eventVisualization = new EventVisualization("any");
eventVisualization.getColumns().add(new BaseDimensionalObject(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X, Lists.newArrayList(deA, deB)));
eventVisualization.getRows().add(deGroupSetA);
eventVisualization.getFilters().add(new BaseDimensionalObject(DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList(peA, peB)));
// When
dimensionService.mergeAnalyticalObject(eventVisualization);
// Then
assertEquals(2, eventVisualization.getDataDimensionItems().size());
assertEquals(2, eventVisualization.getPeriods().size());
assertEquals(1, eventVisualization.getDataElementGroupSetDimensions().size());
assertEquals(3, eventVisualization.getDataElementGroupSetDimensions().get(0).getItems().size());
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class DimensionServiceTest method testMergeAnalyticalEventObjectUserOrgUnit.
@Test
void testMergeAnalyticalEventObjectUserOrgUnit() {
// Given
EventVisualization eventVisualization = new EventVisualization("any");
eventVisualization.getColumns().add(new BaseDimensionalObject(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X, Lists.newArrayList(deA, deB)));
eventVisualization.getRows().add(new BaseDimensionalObject(DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATION_UNIT, Lists.newArrayList(ouUser)));
eventVisualization.getFilters().add(new BaseDimensionalObject(DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList(peA)));
// When
dimensionService.mergeAnalyticalObject(eventVisualization);
// Then
assertEquals(2, eventVisualization.getDataDimensionItems().size());
assertEquals(1, eventVisualization.getPeriods().size());
assertEquals(0, eventVisualization.getOrganisationUnits().size());
assertTrue(eventVisualization.isUserOrganisationUnit());
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class DimensionServiceTest method testMergeAnalyticalEventObjectOrgUnitGroupSet.
@Test
void testMergeAnalyticalEventObjectOrgUnitGroupSet() {
// Given
EventVisualization eventVisualization = new EventVisualization("any");
eventVisualization.getColumns().add(new BaseDimensionalObject(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X, Lists.newArrayList(deA, deB)));
eventVisualization.getRows().add(ouGroupSetA);
eventVisualization.getFilters().add(new BaseDimensionalObject(DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList(peA, peB)));
// When
dimensionService.mergeAnalyticalObject(eventVisualization);
// Then
assertEquals(2, eventVisualization.getDataDimensionItems().size());
assertEquals(2, eventVisualization.getPeriods().size());
assertEquals(1, eventVisualization.getOrganisationUnitGroupSetDimensions().size());
assertEquals(3, eventVisualization.getOrganisationUnitGroupSetDimensions().get(0).getItems().size());
}
Aggregations