use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.
the class QueryItemTest method before.
@BeforeEach
void before() {
opA = new Option("OptionA", "CODEA");
opA.setUid("UIDA");
opB = new Option("OptionB", "CODEB");
opB.setUid("UIDB");
opC = new Option("OptionC", "CODEC");
opC.setUid("UIDC");
osA = new OptionSet("OptionSetA", ValueType.TEXT, Lists.newArrayList(opA, opB, opC));
leA = new Legend("LegendA", 0d, 1d, "", "");
leA.setUid("UIDA");
leB = new Legend("LegendB", 1d, 2d, "", "");
leB.setUid("UIDB");
leC = new Legend("LegendC", 3d, 4d, "", "");
leC.setUid("UIDC");
lsA = new LegendSet("LegendSetA", "", Sets.newHashSet(leA, leB, leC));
prA = new Program("ProgramA");
prA.setUid("PRUIDA");
prB = new Program("ProgramB");
prB.setUid("PRUIDB");
deA = new DataElement("DataElementA");
deA.setOptionSet(osA);
deB = new DataElement("DataElementB");
deB.setLegendSets(Lists.newArrayList(lsA));
rspA = new RepeatableStageParams();
rspA.setStartIndex(1);
rspA.setCount(2);
rspB = new RepeatableStageParams();
rspB.setStartIndex(10);
rspB.setCount(20);
}
use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.
the class DimensionalObjectUtilsTest method testGetUidMapIsSchemeCodeCompositeObject.
@Test
void testGetUidMapIsSchemeCodeCompositeObject() {
Program prA = new Program();
prA.setUid("P123456789A");
prA.setCode("PCodeA");
DataElement deA = new DataElement("NameA");
DataElement deB = new DataElement("NameB");
deA.setUid("D123456789A");
deB.setUid("D123456789B");
deA.setCode("DCodeA");
deB.setCode("DCodeB");
ProgramDataElementDimensionItem pdeA = new ProgramDataElementDimensionItem(prA, deA);
ProgramDataElementDimensionItem pdeB = new ProgramDataElementDimensionItem(prA, deB);
List<ProgramDataElementDimensionItem> elements = Lists.newArrayList(pdeA, pdeB);
Map<String, String> map = DimensionalObjectUtils.getDimensionItemIdSchemeMap(elements, IdScheme.CODE);
assertEquals(2, map.size());
assertEquals("PCodeA.DCodeA", map.get("P123456789A.D123456789A"));
assertEquals("PCodeA.DCodeB", map.get("P123456789A.D123456789B"));
}
use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.
the class CategoryOptionComboTest method before.
@BeforeEach
void before() {
jan1 = new DateTime(2000, 1, 1, 0, 0).toDate();
jan2 = new DateTime(2000, 1, 2, 0, 0).toDate();
jan4 = new DateTime(2000, 1, 4, 0, 0).toDate();
jan5 = new DateTime(2000, 1, 5, 0, 0).toDate();
jan6 = new DateTime(2000, 1, 6, 0, 0).toDate();
optionA = new CategoryOption("optionA");
optionB = new CategoryOption("optionB");
optionC = new CategoryOption("optionC");
optionB.setStartDate(jan1);
optionB.setEndDate(jan4);
optionC.setStartDate(jan2);
optionC.setEndDate(jan5);
optionComboA = new CategoryOptionCombo();
optionComboB = new CategoryOptionCombo();
optionComboC = new CategoryOptionCombo();
optionComboA.setName("optionComboA");
optionComboB.setName("optionComboB");
optionComboC.setName("optionComboC");
optionComboA.addCategoryOption(optionA);
optionComboB.addCategoryOption(optionB);
optionComboC.addCategoryOption(optionA);
optionComboC.addCategoryOption(optionB);
optionComboC.addCategoryOption(optionC);
categoryComboA = new CategoryCombo();
categoryComboB = new CategoryCombo();
categoryComboC = new CategoryCombo();
categoryComboA.getOptionCombos().add(optionComboA);
categoryComboB.getOptionCombos().add(optionComboB);
categoryComboC.getOptionCombos().add(optionComboC);
optionComboA.setCategoryCombo(categoryComboA);
optionComboB.setCategoryCombo(categoryComboB);
optionComboC.setCategoryCombo(categoryComboC);
dataElement = new DataElement("dataElementA");
dataSetA = new DataSet("dataSetA", new DailyPeriodType());
dataSetB = new DataSet("dataSetB", new DailyPeriodType());
dataSetC = new DataSet("dataSetC", new DailyPeriodType());
dataSetA.setCategoryCombo(categoryComboA);
dataSetB.setCategoryCombo(categoryComboB);
dataSetB.setCategoryCombo(categoryComboC);
dataSetA.addDataSetElement(dataElement);
dataSetB.addDataSetElement(dataElement);
dataSetC.addDataSetElement(dataElement);
dataSetA.setOpenPeriodsAfterCoEndDate(0);
dataSetB.setOpenPeriodsAfterCoEndDate(1);
dataSetC.setOpenPeriodsAfterCoEndDate(2);
program = new Program();
}
use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.
the class CategoryOptionTest method getAdjustedDate_Program.
@Test
void getAdjustedDate_Program() {
CategoryOption categoryOption = new CategoryOption();
Program program = new Program("program");
assertNull(categoryOption.getAdjustedEndDate(program));
categoryOption.setEndDate(new DateTime(2020, 1, 1, 0, 0).toDate());
assertEquals(new DateTime(2020, 1, 1, 0, 0).toDate(), categoryOption.getAdjustedEndDate(program));
program.setOpenDaysAfterCoEndDate(3);
assertEquals(new DateTime(2020, 1, 4, 0, 0).toDate(), categoryOption.getAdjustedEndDate(program));
}
use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.
the class EventAnalyticsServiceTest method testDimensionRestrictionSuccessfully.
@Test
void testDimensionRestrictionSuccessfully() {
// Given
// A program
Program aProgram = createProgram('B', null, null, Sets.newHashSet(ouA, ouB), null);
aProgram.setUid("aProgram123");
idObjectManager.save(aProgram);
// The category options
CategoryOption coA = createCategoryOption('A');
CategoryOption coB = createCategoryOption('B');
categoryService.addCategoryOption(coA);
categoryService.addCategoryOption(coB);
// The categories
Category caA = createCategory('A', coA);
Category caB = createCategory('B', coB);
categoryService.addCategory(caA);
categoryService.addCategory(caB);
// The constraints
Set<Category> catDimensionConstraints = Sets.newHashSet(caA, caB);
// The user
User user = createUser("A", "F_VIEW_EVENT_ANALYTICS");
user.setCatDimensionConstraints(catDimensionConstraints);
userService.addUser(user);
enableDataSharing(user, aProgram, AccessStringHelper.DATA_READ_WRITE);
idObjectManager.update(user);
injectSecurityContext(user);
// All events in program B - 2017
EventQueryParams events_2017_params = new EventQueryParams.Builder().withOrganisationUnits(Lists.newArrayList(ouA)).withStartDate(getDate(2017, 1, 1)).withEndDate(getDate(2017, 12, 31)).withProgram(aProgram).build();
// When
Grid aggregatedDataValueGrid = eventAnalyticsService.getAggregatedEventData(events_2017_params);
// Then
boolean noCategoryRestrictionExceptionIsThrown = true;
assertThat(aggregatedDataValueGrid, is(notNullValue()));
assert (noCategoryRestrictionExceptionIsThrown);
}
Aggregations