Search in sources :

Example 21 with LegendSet

use of org.hisp.dhis.legend.LegendSet in project dhis2-core by dhis2.

the class QueryItemLocatorTest method verifyDimensionWithLegendSetReturnsDataElement.

@Test
void verifyDimensionWithLegendSetReturnsDataElement() {
    String legendSetUid = CodeGenerator.generateUid();
    DataElement dataElementA = createDataElement('A');
    ProgramStage programStageA = createProgramStage('A', programA);
    programStageA.setProgramStageDataElements(Sets.newHashSet(createProgramStageDataElement(programStageA, dataElementA, 1)));
    programA.setProgramStages(Sets.newHashSet(programStageA));
    LegendSet legendSetA = createLegendSet('A');
    when(dataElementService.getDataElement(dimension)).thenReturn(dataElementA);
    when(legendSetService.getLegendSet(legendSetUid)).thenReturn(legendSetA);
    QueryItem queryItem = subject.getQueryItemFromDimension(dimension + ITEM_SEP + legendSetUid, programA, EventOutputType.EVENT);
    assertThat(queryItem, is(notNullValue()));
    assertThat(queryItem.getItem(), is(dataElementA));
    assertThat(queryItem.getProgram(), is(programA));
    assertThat(queryItem.getProgramStage(), is(nullValue()));
    assertThat(queryItem.getLegendSet(), is(legendSetA));
}
Also used : DhisConvenienceTest.createProgramStageDataElement(org.hisp.dhis.DhisConvenienceTest.createProgramStageDataElement) DataElement(org.hisp.dhis.dataelement.DataElement) DhisConvenienceTest.createDataElement(org.hisp.dhis.DhisConvenienceTest.createDataElement) QueryItem(org.hisp.dhis.common.QueryItem) LegendSet(org.hisp.dhis.legend.LegendSet) DhisConvenienceTest.createLegendSet(org.hisp.dhis.DhisConvenienceTest.createLegendSet) DhisConvenienceTest.createProgramStage(org.hisp.dhis.DhisConvenienceTest.createProgramStage) ProgramStage(org.hisp.dhis.program.ProgramStage) Test(org.junit.jupiter.api.Test)

Example 22 with LegendSet

use of org.hisp.dhis.legend.LegendSet in project dhis2-core by dhis2.

the class DataSetDeletionHandler method deleteLegendSet.

private void deleteLegendSet(LegendSet legendSet) {
    for (DataSet dataSet : idObjectManager.getAllNoAcl(DataSet.class)) {
        for (LegendSet ls : dataSet.getLegendSets()) {
            if (legendSet.equals(ls)) {
                dataSet.getLegendSets().remove(ls);
                idObjectManager.updateNoAcl(dataSet);
            }
        }
    }
}
Also used : LegendSet(org.hisp.dhis.legend.LegendSet)

Example 23 with LegendSet

use of org.hisp.dhis.legend.LegendSet in project dhis2-core by dhis2.

the class IndicatorDeletionHandler method deleteLegendSet.

private void deleteLegendSet(LegendSet legendSet) {
    for (Indicator indicator : indicatorService.getAllIndicators()) {
        for (LegendSet ls : indicator.getLegendSets()) {
            if (legendSet.equals(ls)) {
                indicator.getLegendSets().remove(ls);
                indicatorService.updateIndicator(indicator);
            }
        }
    }
}
Also used : LegendSet(org.hisp.dhis.legend.LegendSet)

Example 24 with LegendSet

use of org.hisp.dhis.legend.LegendSet in project dhis2-core by dhis2.

the class DhisConvenienceTest method createLegendSet.

public static LegendSet createLegendSet(char uniqueCharacter) {
    LegendSet legendSet = new LegendSet();
    legendSet.setAutoFields();
    legendSet.setName("LegendSet" + uniqueCharacter);
    return legendSet;
}
Also used : LegendSet(org.hisp.dhis.legend.LegendSet)

Aggregations

LegendSet (org.hisp.dhis.legend.LegendSet)24 Test (org.junit.jupiter.api.Test)10 DataElement (org.hisp.dhis.dataelement.DataElement)8 QueryItem (org.hisp.dhis.common.QueryItem)4 Legend (org.hisp.dhis.legend.Legend)4 ProgramStage (org.hisp.dhis.program.ProgramStage)4 DhisSpringTest (org.hisp.dhis.DhisSpringTest)3 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)3 List (java.util.List)2 DhisConvenienceTest.createDataElement (org.hisp.dhis.DhisConvenienceTest.createDataElement)2 DhisConvenienceTest.createLegendSet (org.hisp.dhis.DhisConvenienceTest.createLegendSet)2 DhisConvenienceTest.createProgramStage (org.hisp.dhis.DhisConvenienceTest.createProgramStage)2 DhisConvenienceTest.createProgramStageDataElement (org.hisp.dhis.DhisConvenienceTest.createProgramStageDataElement)2 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)2 Dashboard (org.hisp.dhis.dashboard.Dashboard)2 ObjectBundleValidationReport (org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport)2 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)2