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());
}
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();
}
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));
}
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));
}
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;
}
Aggregations