Search in sources :

Example 26 with EventVisualization

use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.

the class TranslationServiceTest method testEventVisualizationTranslations.

@Test
void testEventVisualizationTranslations() {
    Program prA = createProgram('A', null, null);
    manager.save(prA);
    EventVisualization evA = new EventVisualization("evA");
    evA.setProgram(prA);
    evA.setType(EventVisualizationType.COLUMN);
    evA.setBaseLineLabel("BaseLineLabel");
    evA.setDomainAxisLabel("DomainAxisLabel");
    evA.setRangeAxisLabel("RangeAxisLabel");
    evA.setTargetLineLabel("TargetLineLabel");
    evA.setTitle("Title");
    evA.setSubtitle("SubTitle");
    manager.save(evA);
    Set<Translation> translations = new HashSet<>();
    translations.add(new Translation(locale.getLanguage(), "baseLineLabel", "translated BaseLineLabel"));
    translations.add(new Translation(locale.getLanguage(), "domainAxisLabel", "translated DomainAxisLabel"));
    translations.add(new Translation(locale.getLanguage(), "rangeAxisLabel", "translated RangeAxisLabel"));
    translations.add(new Translation(locale.getLanguage(), "targetLineLabel", "translated TargetLineLabel"));
    translations.add(new Translation(locale.getLanguage(), "title", "translated Title"));
    translations.add(new Translation(locale.getLanguage(), "subtitle", "translated SubTitle"));
    manager.updateTranslations(evA, translations);
    EventVisualization updated = manager.get(EventVisualization.class, evA.getUid());
    assertEquals("translated BaseLineLabel", updated.getDisplayBaseLineLabel());
    assertEquals("translated DomainAxisLabel", updated.getDisplayDomainAxisLabel());
    assertEquals("translated RangeAxisLabel", updated.getDisplayRangeAxisLabel());
    assertEquals("translated TargetLineLabel", updated.getDisplayTargetLineLabel());
    assertEquals("translated Title", updated.getDisplayTitle());
    assertEquals("translated SubTitle", updated.getDisplaySubtitle());
}
Also used : Program(org.hisp.dhis.program.Program) EventVisualization(org.hisp.dhis.eventvisualization.EventVisualization) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 27 with EventVisualization

use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.

the class HibernateEventVisualizationStore method countEventVisualizationCreated.

private int countEventVisualizationCreated(final Date startingAt, final EventVisualizationSet eventVisualizationSet) {
    final CriteriaBuilder builder = getCriteriaBuilder();
    final JpaQueryParameters<EventVisualization> params = new JpaQueryParameters<EventVisualization>().addPredicates(getSharingPredicates(builder)).addPredicate(root -> builder.greaterThanOrEqualTo(root.get("created"), startingAt)).count(root -> builder.countDistinct(root.get("id")));
    setCorrectPredicates(eventVisualizationSet, builder, params);
    return getCount(builder, params).intValue();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) LINE_LIST(org.hisp.dhis.eventvisualization.EventVisualizationType.LINE_LIST) Date(java.util.Date) SessionFactory(org.hibernate.SessionFactory) Set(java.util.Set) JpaQueryParameters(org.hisp.dhis.hibernate.JpaQueryParameters) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) EventVisualization(org.hisp.dhis.eventvisualization.EventVisualization) HibernateAnalyticalObjectStore(org.hisp.dhis.common.hibernate.HibernateAnalyticalObjectStore) ArrayList(java.util.ArrayList) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) EventVisualizationStore(org.hisp.dhis.eventvisualization.EventVisualizationStore) List(java.util.List) Predicate(javax.persistence.criteria.Predicate) CurrentUserService(org.hisp.dhis.user.CurrentUserService) PIVOT_TABLE(org.hisp.dhis.eventvisualization.EventVisualizationType.PIVOT_TABLE) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) AclService(org.hisp.dhis.security.acl.AclService) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) Repository(org.springframework.stereotype.Repository) Root(javax.persistence.criteria.Root) EventVisualization(org.hisp.dhis.eventvisualization.EventVisualization)

Example 28 with EventVisualization

use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.

the class DashboardCascadeSharingTest method testCascadeShareEventVisualizationError.

@Test
void testCascadeShareEventVisualizationError() {
    DataElement dataElementA = createDataElement('A');
    dataElementA.setSharing(Sharing.builder().publicAccess(DEFAULT).build());
    objectManager.save(dataElementA, false);
    Program program = createProgram('Y', null, null);
    objectManager.save(program);
    EventVisualization eventVisualizationA = createEventVisualization('A', program);
    eventVisualizationA.setSharing(Sharing.builder().publicAccess(DEFAULT).build());
    eventVisualizationA.addDataDimensionItem(dataElementA);
    objectManager.save(eventVisualizationA, false);
    Sharing sharing = new Sharing();
    sharing.setPublicAccess(DEFAULT);
    sharing.addUserAccess(new UserAccess(userB, DEFAULT));
    Dashboard dashboard = createDashboardWithItem("A", sharing);
    dashboard.getItems().get(0).setEventVisualization(eventVisualizationA);
    objectManager.save(dashboard, false);
    CascadeSharingReport report = cascadeSharingService.cascadeSharing(dashboard, new CascadeSharingParameters());
    assertEquals(0, report.getUpdateObjects().size());
    assertFalse(aclService.canRead(userB, eventVisualizationA));
    assertFalse(aclService.canRead(userB, dataElementA));
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) Program(org.hisp.dhis.program.Program) Sharing(org.hisp.dhis.user.sharing.Sharing) UserAccess(org.hisp.dhis.user.sharing.UserAccess) Dashboard(org.hisp.dhis.dashboard.Dashboard) EventVisualization(org.hisp.dhis.eventvisualization.EventVisualization) Test(org.junit.jupiter.api.Test)

Example 29 with EventVisualization

use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.

the class InterpretationController method writeEventReportInterpretation.

@PostMapping(value = "/eventReport/{uid}", consumes = { "text/html", "text/plain" })
@ResponseBody
@Deprecated
public WebMessage writeEventReportInterpretation(@PathVariable("uid") String uid, @RequestParam(value = "ou", required = false) String orgUnitUid, @CurrentUser User currentUser, @RequestBody String text) throws WebMessageException {
    EventReport eventReport = idObjectManager.get(EventReport.class, uid);
    if (eventReport == null) {
        return conflict("Event report does not exist or is not accessible: " + uid);
    }
    final EventVisualization eventVisualization = idObjectManager.get(EventVisualization.class, eventReport.getUid());
    OrganisationUnit orgUnit = getUserOrganisationUnit(orgUnitUid, eventReport, currentUser);
    return createInterpretation(new Interpretation(eventVisualization, eventReport, orgUnit, text));
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Interpretation(org.hisp.dhis.interpretation.Interpretation) EventReport(org.hisp.dhis.eventreport.EventReport) EventVisualization(org.hisp.dhis.eventvisualization.EventVisualization) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 30 with EventVisualization

use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.

the class EventVisualizationController method deserializeJsonEntity.

@Override
protected EventVisualization deserializeJsonEntity(final HttpServletRequest request) throws IOException {
    final EventVisualization eventVisualization = super.deserializeJsonEntity(request);
    prepare(eventVisualization);
    return eventVisualization;
}
Also used : EventVisualization(org.hisp.dhis.eventvisualization.EventVisualization)

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