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