Search in sources :

Example 36 with DataElementGroup

use of org.hisp.dhis.dataelement.DataElementGroup in project dhis2-core by dhis2.

the class PreheatServiceTest method testPreheatReferenceCODE.

@Test
void testPreheatReferenceCODE() {
    DataElementGroup dataElementGroup = new DataElementGroup("DataElementGroupA");
    dataElementGroup.setAutoFields();
    DataElement de1 = createDataElement('A');
    DataElement de2 = createDataElement('B');
    DataElement de3 = createDataElement('C');
    manager.save(de1);
    manager.save(de2);
    manager.save(de3);
    User user = createUser('A');
    manager.save(user);
    dataElementGroup.addDataElement(de1);
    dataElementGroup.addDataElement(de2);
    dataElementGroup.addDataElement(de3);
    dataElementGroup.setCreatedBy(user);
    manager.save(dataElementGroup);
    PreheatParams params = new PreheatParams();
    params.setPreheatIdentifier(PreheatIdentifier.CODE);
    params.setPreheatMode(PreheatMode.REFERENCE);
    params.getObjects().put(DataElement.class, Lists.newArrayList(de1, de2));
    params.getObjects().put(User.class, Lists.newArrayList(user));
    preheatService.validate(params);
    Preheat preheat = preheatService.preheat(params);
    assertFalse(preheat.isEmpty());
    assertFalse(preheat.isEmpty(PreheatIdentifier.CODE));
    assertFalse(preheat.isEmpty(PreheatIdentifier.CODE, DataElement.class));
    assertTrue(preheat.isEmpty(PreheatIdentifier.CODE, DataElementGroup.class));
    assertTrue(preheat.containsKey(PreheatIdentifier.CODE, DataElement.class, de1.getCode()));
    assertTrue(preheat.containsKey(PreheatIdentifier.CODE, DataElement.class, de2.getCode()));
    assertFalse(preheat.containsKey(PreheatIdentifier.CODE, DataElement.class, de3.getCode()));
    assertFalse(preheat.containsKey(PreheatIdentifier.CODE, DataElementGroup.class, dataElementGroup.getCode()));
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) User(org.hisp.dhis.user.User) DataElementGroup(org.hisp.dhis.dataelement.DataElementGroup) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 37 with DataElementGroup

use of org.hisp.dhis.dataelement.DataElementGroup in project dhis2-core by dhis2.

the class PreheatServiceTest method testPreheatReferenceUID.

@Test
void testPreheatReferenceUID() {
    DataElementGroup dataElementGroup = new DataElementGroup("DataElementGroupA");
    dataElementGroup.setAutoFields();
    DataElement de1 = createDataElement('A');
    DataElement de2 = createDataElement('B');
    DataElement de3 = createDataElement('C');
    manager.save(de1);
    manager.save(de2);
    manager.save(de3);
    User user = createUser('A');
    manager.save(user);
    dataElementGroup.addDataElement(de1);
    dataElementGroup.addDataElement(de2);
    dataElementGroup.addDataElement(de3);
    dataElementGroup.setCreatedBy(user);
    manager.save(dataElementGroup);
    PreheatParams params = new PreheatParams();
    params.setPreheatMode(PreheatMode.REFERENCE);
    params.getObjects().put(DataElement.class, Lists.newArrayList(de1, de2));
    params.getObjects().put(User.class, Lists.newArrayList(user));
    preheatService.validate(params);
    Preheat preheat = preheatService.preheat(params);
    assertFalse(preheat.isEmpty());
    assertFalse(preheat.isEmpty(PreheatIdentifier.UID));
    assertFalse(preheat.isEmpty(PreheatIdentifier.UID, DataElement.class));
    assertTrue(preheat.isEmpty(PreheatIdentifier.UID, DataElementGroup.class));
    assertFalse(preheat.isEmpty(PreheatIdentifier.UID, User.class));
    assertTrue(preheat.containsKey(PreheatIdentifier.UID, DataElement.class, de1.getUid()));
    assertTrue(preheat.containsKey(PreheatIdentifier.UID, DataElement.class, de2.getUid()));
    assertFalse(preheat.containsKey(PreheatIdentifier.UID, DataElement.class, de3.getUid()));
    assertFalse(preheat.containsKey(PreheatIdentifier.UID, DataElementGroup.class, dataElementGroup.getUid()));
    assertTrue(preheat.containsKey(PreheatIdentifier.UID, User.class, user.getUid()));
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) User(org.hisp.dhis.user.User) DataElementGroup(org.hisp.dhis.dataelement.DataElementGroup) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 38 with DataElementGroup

use of org.hisp.dhis.dataelement.DataElementGroup in project dhis2-core by dhis2.

the class PreheatServiceTest method testPreheatReferenceWithScanCODE.

@Test
void testPreheatReferenceWithScanCODE() {
    DataElementGroup dataElementGroup = fromJson("preheat/degACodeRef.json", DataElementGroup.class);
    defaultSetup();
    PreheatParams params = new PreheatParams();
    params.setPreheatIdentifier(PreheatIdentifier.CODE);
    params.setPreheatMode(PreheatMode.REFERENCE);
    params.getObjects().put(DataElementGroup.class, Lists.newArrayList(dataElementGroup));
    preheatService.validate(params);
    Preheat preheat = preheatService.preheat(params);
    assertFalse(preheat.isEmpty());
    assertFalse(preheat.isEmpty(PreheatIdentifier.CODE));
    assertFalse(preheat.isEmpty(PreheatIdentifier.CODE, DataElement.class));
    assertTrue(preheat.isEmpty(PreheatIdentifier.CODE, DataElementGroup.class));
    assertTrue(preheat.containsKey(PreheatIdentifier.CODE, DataElement.class, "DataElementCodeA"));
    assertTrue(preheat.containsKey(PreheatIdentifier.CODE, DataElement.class, "DataElementCodeB"));
    assertTrue(preheat.containsKey(PreheatIdentifier.CODE, DataElement.class, "DataElementCodeC"));
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) DataElementGroup(org.hisp.dhis.dataelement.DataElementGroup) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 39 with DataElementGroup

use of org.hisp.dhis.dataelement.DataElementGroup in project dhis2-core by dhis2.

the class CriteriaQueryEngineTest method createDataElements.

@BeforeEach
void createDataElements() {
    userService = _userService;
    DataElement dataElementA = addDataElement('A', ValueType.NUMBER, "2001");
    DataElement dataElementB = addDataElement('B', ValueType.BOOLEAN, "2002");
    DataElement dataElementC = addDataElement('C', ValueType.INTEGER, "2003");
    DataElement dataElementD = addDataElement('D', ValueType.NUMBER, "2004");
    DataElement dataElementE = addDataElement('E', ValueType.BOOLEAN, "2005");
    DataElement dataElementF = addDataElement('F', ValueType.INTEGER, "2006");
    DataElementGroup dataElementGroupA = createDataElementGroup('A');
    dataElementGroupA.addDataElement(dataElementA);
    dataElementGroupA.addDataElement(dataElementB);
    dataElementGroupA.addDataElement(dataElementC);
    dataElementGroupA.addDataElement(dataElementD);
    DataElementGroup dataElementGroupB = createDataElementGroup('B');
    dataElementGroupB.addDataElement(dataElementE);
    dataElementGroupB.addDataElement(dataElementF);
    identifiableObjectManager.save(dataElementGroupA);
    identifiableObjectManager.save(dataElementGroupB);
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) DataElementGroup(org.hisp.dhis.dataelement.DataElementGroup) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 40 with DataElementGroup

use of org.hisp.dhis.dataelement.DataElementGroup in project dhis2-core by dhis2.

the class InMemoryQueryEngineTest method createDataElements.

@BeforeEach
void createDataElements() {
    DataElement dataElementA = createDataElement('A');
    dataElementA.setValueType(ValueType.NUMBER);
    DataElement dataElementB = createDataElement('B');
    dataElementB.setValueType(ValueType.BOOLEAN);
    DataElement dataElementC = createDataElement('C');
    dataElementC.setValueType(ValueType.INTEGER);
    DataElement dataElementD = createDataElement('D');
    dataElementD.setValueType(ValueType.NUMBER);
    DataElement dataElementE = createDataElement('E');
    dataElementE.setValueType(ValueType.BOOLEAN);
    DataElement dataElementF = createDataElement('F');
    dataElementF.setValueType(ValueType.INTEGER);
    dataElementA.setCreated(Year.parseYear("2001").getStart());
    dataElementB.setCreated(Year.parseYear("2002").getStart());
    dataElementC.setCreated(Year.parseYear("2003").getStart());
    dataElementD.setCreated(Year.parseYear("2004").getStart());
    dataElementE.setCreated(Year.parseYear("2005").getStart());
    dataElementF.setCreated(Year.parseYear("2006").getStart());
    dataElements.clear();
    dataElements.add(dataElementA);
    dataElements.add(dataElementB);
    dataElements.add(dataElementC);
    dataElements.add(dataElementD);
    dataElements.add(dataElementE);
    dataElements.add(dataElementF);
    DataElementGroup dataElementGroupA = createDataElementGroup('A');
    dataElementGroupA.addDataElement(dataElementA);
    dataElementGroupA.addDataElement(dataElementB);
    dataElementGroupA.addDataElement(dataElementC);
    DataElementGroup dataElementGroupB = createDataElementGroup('B');
    dataElementGroupB.addDataElement(dataElementD);
    dataElementGroupB.addDataElement(dataElementE);
    dataElementGroupB.addDataElement(dataElementF);
    dataElementGroups.add(dataElementGroupA);
    dataElementGroups.add(dataElementGroupB);
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) DataElementGroup(org.hisp.dhis.dataelement.DataElementGroup) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

DataElementGroup (org.hisp.dhis.dataelement.DataElementGroup)55 DataElement (org.hisp.dhis.dataelement.DataElement)31 Test (org.junit.jupiter.api.Test)29 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)17 ArrayList (java.util.ArrayList)15 User (org.hisp.dhis.user.User)15 DataSet (org.hisp.dhis.dataset.DataSet)9 List (java.util.List)8 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)8 Set (java.util.Set)7 DhisSpringTest (org.hisp.dhis.DhisSpringTest)7 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)6 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)6 DataElementGroupSet (org.hisp.dhis.dataelement.DataElementGroupSet)6 DimensionalObject (org.hisp.dhis.common.DimensionalObject)5 LegendSet (org.hisp.dhis.legend.LegendSet)5 OptionSet (org.hisp.dhis.option.OptionSet)5 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)5 PeriodType (org.hisp.dhis.period.PeriodType)5 DimensionItemKeywords (org.hisp.dhis.common.DimensionItemKeywords)4