use of org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext.DataValueContextBuilder in project dhis2-core by dhis2.
the class DataValueSetImportValidatorTest method createDataValueContext.
private DataValueContextBuilder createDataValueContext(DataValue dataValue) {
DataValueContextBuilder builder = DataValueContext.builder();
String deId = dataValue.getDataElement();
String period = dataValue.getPeriod();
String ouId = dataValue.getOrgUnit();
String coId = dataValue.getCategoryOptionCombo();
String aoId = dataValue.getAttributeOptionCombo();
if (deId != null) {
DataElement de = new DataElement();
de.setUid(deId);
de.setValueType(ValueType.BOOLEAN);
builder.dataElement(de);
}
if (period != null) {
Period p = PeriodType.getPeriodFromIsoString("2021-01");
builder.period(p);
}
if (ouId != null) {
OrganisationUnit ou = new OrganisationUnit();
ou.setUid(ouId);
builder.orgUnit(ou);
}
if (coId != null) {
builder.categoryOptionCombo(createMinimalOptionCombo(coId));
}
if (aoId != null) {
builder.attrOptionCombo(createMinimalOptionCombo(aoId));
}
return builder;
}
Aggregations