Search in sources :

Example 1 with EventVisualization

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);
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Function(java.util.function.Function) ArrayList(java.util.ArrayList) EventVisualization(org.hisp.dhis.eventvisualization.EventVisualization) JpaQueryParameters(org.hisp.dhis.hibernate.JpaQueryParameters)

Example 2 with EventVisualization

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);
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EventVisualization(org.hisp.dhis.eventvisualization.EventVisualization) JpaQueryParameters(org.hisp.dhis.hibernate.JpaQueryParameters)

Example 3 with EventVisualization

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());
}
Also used : BaseDimensionalObject(org.hisp.dhis.common.BaseDimensionalObject) EventVisualization(org.hisp.dhis.eventvisualization.EventVisualization) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 4 with EventVisualization

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());
}
Also used : BaseDimensionalObject(org.hisp.dhis.common.BaseDimensionalObject) EventVisualization(org.hisp.dhis.eventvisualization.EventVisualization) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 5 with EventVisualization

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());
}
Also used : BaseDimensionalObject(org.hisp.dhis.common.BaseDimensionalObject) EventVisualization(org.hisp.dhis.eventvisualization.EventVisualization) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Aggregations

EventVisualization (org.hisp.dhis.eventvisualization.EventVisualization)31 Test (org.junit.jupiter.api.Test)20 DhisSpringTest (org.hisp.dhis.DhisSpringTest)11 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)7 BaseDimensionalObject (org.hisp.dhis.common.BaseDimensionalObject)7 User (org.hisp.dhis.user.User)7 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)4 Program (org.hisp.dhis.program.Program)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)3 JpaQueryParameters (org.hisp.dhis.hibernate.JpaQueryParameters)3 Interpretation (org.hisp.dhis.interpretation.Interpretation)3 UserAccess (org.hisp.dhis.user.sharing.UserAccess)3 ArrayList (java.util.ArrayList)2 Function (java.util.function.Function)2 Dashboard (org.hisp.dhis.dashboard.Dashboard)2 DataElement (org.hisp.dhis.dataelement.DataElement)2 EventChart (org.hisp.dhis.eventchart.EventChart)2 EventReport (org.hisp.dhis.eventreport.EventReport)2 UserAuthorityGroup (org.hisp.dhis.user.UserAuthorityGroup)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2