use of org.hisp.dhis.dataelement.DataElement in project dhis2-core by dhis2.
the class QueryServiceTest method createDataElements.
@Before
public 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());
identifiableObjectManager.save(dataElementB);
identifiableObjectManager.save(dataElementE);
identifiableObjectManager.save(dataElementA);
identifiableObjectManager.save(dataElementC);
identifiableObjectManager.save(dataElementF);
identifiableObjectManager.save(dataElementD);
}
use of org.hisp.dhis.dataelement.DataElement in project dhis2-core by dhis2.
the class ObjectBundleServiceFavoritesTest method testCreateMetadataWithChartsWithPeriods1.
@Test
public void testCreateMetadataWithChartsWithPeriods1() throws IOException {
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/favorites/metadata_with_chart_periods1.json").getInputStream(), RenderFormat.JSON);
ObjectBundleParams params = new ObjectBundleParams();
params.setObjectBundleMode(ObjectBundleMode.COMMIT);
params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE);
params.setObjects(metadata);
ObjectBundle bundle = objectBundleService.create(params);
ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle);
assertTrue(validate.getErrorReports().isEmpty());
objectBundleService.commit(bundle);
List<DataSet> dataSets = manager.getAll(DataSet.class);
List<OrganisationUnit> organisationUnits = manager.getAll(OrganisationUnit.class);
List<DataElement> dataElements = manager.getAll(DataElement.class);
List<Chart> charts = manager.getAll(Chart.class);
assertEquals(1, dataSets.size());
assertEquals(1, organisationUnits.size());
assertEquals(4, dataElements.size());
assertEquals(4, charts.size());
Chart chart = manager.get(Chart.class, "ziCoxdcXRQz");
assertNotNull(chart);
assertEquals(5, chart.getPeriods().size());
}
use of org.hisp.dhis.dataelement.DataElement in project dhis2-core by dhis2.
the class ObjectBundleServiceProgramTest method testCreateSimpleProgramWithSectionsNoReg.
@Test
public void testCreateSimpleProgramWithSectionsNoReg() throws IOException {
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/program_noreg_sections.json").getInputStream(), RenderFormat.JSON);
ObjectBundleParams params = new ObjectBundleParams();
params.setObjectBundleMode(ObjectBundleMode.COMMIT);
params.setImportStrategy(ImportStrategy.CREATE);
params.setObjects(metadata);
ObjectBundle bundle = objectBundleService.create(params);
ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle);
assertTrue(validate.getErrorReports().isEmpty());
objectBundleService.commit(bundle);
List<DataSet> dataSets = manager.getAll(DataSet.class);
List<OrganisationUnit> organisationUnits = manager.getAll(OrganisationUnit.class);
List<DataElement> dataElements = manager.getAll(DataElement.class);
List<UserAuthorityGroup> userRoles = manager.getAll(UserAuthorityGroup.class);
List<User> users = manager.getAll(User.class);
List<ValidationRule> validationRules = manager.getAll(ValidationRule.class);
List<Program> programs = manager.getAll(Program.class);
List<ProgramStage> programStages = manager.getAll(ProgramStage.class);
List<ProgramStageDataElement> programStageDataElements = manager.getAll(ProgramStageDataElement.class);
List<ProgramStageSection> programStageSections = manager.getAll(ProgramStageSection.class);
assertFalse(dataSets.isEmpty());
assertFalse(organisationUnits.isEmpty());
assertFalse(dataElements.isEmpty());
assertFalse(users.isEmpty());
assertFalse(userRoles.isEmpty());
assertEquals(1, validationRules.size());
assertEquals(1, programs.size());
assertEquals(1, programStages.size());
assertEquals(3, programStageDataElements.size());
assertEquals(2, programStageSections.size());
ProgramStage programStage = programStages.get(0);
assertEquals(3, programStage.getProgramStageDataElements().size());
assertEquals(2, programStage.getProgramStageSections().size());
}
use of org.hisp.dhis.dataelement.DataElement in project dhis2-core by dhis2.
the class ObjectBundleServiceProgramTest method testCreateSimpleProgramNoReg.
@Test
public void testCreateSimpleProgramNoReg() throws IOException {
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/program_noreg.json").getInputStream(), RenderFormat.JSON);
ObjectBundleParams params = new ObjectBundleParams();
params.setObjectBundleMode(ObjectBundleMode.COMMIT);
params.setImportStrategy(ImportStrategy.CREATE);
params.setObjects(metadata);
ObjectBundle bundle = objectBundleService.create(params);
ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle);
assertTrue(validate.getErrorReports().isEmpty());
objectBundleService.commit(bundle);
List<DataSet> dataSets = manager.getAll(DataSet.class);
List<OrganisationUnit> organisationUnits = manager.getAll(OrganisationUnit.class);
List<DataElement> dataElements = manager.getAll(DataElement.class);
List<UserAuthorityGroup> userRoles = manager.getAll(UserAuthorityGroup.class);
List<User> users = manager.getAll(User.class);
List<ValidationRule> validationRules = manager.getAll(ValidationRule.class);
List<Program> programs = manager.getAll(Program.class);
List<ProgramStage> programStages = manager.getAll(ProgramStage.class);
List<ProgramStageDataElement> programStageDataElements = manager.getAll(ProgramStageDataElement.class);
assertFalse(dataSets.isEmpty());
assertFalse(organisationUnits.isEmpty());
assertFalse(dataElements.isEmpty());
assertFalse(users.isEmpty());
assertFalse(userRoles.isEmpty());
assertEquals(1, validationRules.size());
assertEquals(1, programs.size());
assertEquals(1, programStages.size());
assertEquals(3, programStageDataElements.size());
ProgramStage programStage = programStages.get(0);
assertEquals(3, programStage.getProgramStageDataElements().size());
}
use of org.hisp.dhis.dataelement.DataElement in project dhis2-core by dhis2.
the class ObjectBundleServiceProgramTest method testCreateSimpleProgramReg.
@Test
public void testCreateSimpleProgramReg() throws IOException {
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/program_reg1.json").getInputStream(), RenderFormat.JSON);
ObjectBundleParams params = new ObjectBundleParams();
params.setObjectBundleMode(ObjectBundleMode.COMMIT);
params.setImportStrategy(ImportStrategy.CREATE);
params.setObjects(metadata);
ObjectBundle bundle = objectBundleService.create(params);
ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle);
assertTrue(validate.getErrorReports().isEmpty());
objectBundleService.commit(bundle);
List<OrganisationUnit> organisationUnits = manager.getAll(OrganisationUnit.class);
List<DataElement> dataElements = manager.getAll(DataElement.class);
List<UserAuthorityGroup> userRoles = manager.getAll(UserAuthorityGroup.class);
List<User> users = manager.getAll(User.class);
List<Program> programs = manager.getAll(Program.class);
List<ProgramStage> programStages = manager.getAll(ProgramStage.class);
List<ProgramStageDataElement> programStageDataElements = manager.getAll(ProgramStageDataElement.class);
List<ProgramTrackedEntityAttribute> programTrackedEntityAttributes = manager.getAll(ProgramTrackedEntityAttribute.class);
assertFalse(organisationUnits.isEmpty());
assertFalse(dataElements.isEmpty());
assertFalse(users.isEmpty());
assertFalse(userRoles.isEmpty());
assertEquals(1, programs.size());
assertEquals(2, programStages.size());
assertEquals(4, programStageDataElements.size());
assertEquals(2, programTrackedEntityAttributes.size());
}
Aggregations