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