use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.
the class SchemaIdResponseMapperTest method testGetSchemeIdResponseMapWhenOutputDataElementIdSchemeIsSetToCodeForDataValueSet.
@Test
void testGetSchemeIdResponseMapWhenOutputDataElementIdSchemeIsSetToCodeForDataValueSet() {
// Given
final List<DataElementOperand> dataElementOperandsStub = stubDataElementOperands();
final OrganisationUnit orUnitStub = stubOrgUnit();
final Period periodStub = stubPeriod();
final DataQueryParams theDataQueryParams = stubQueryParams(dataElementOperandsStub, orUnitStub, periodStub, DATA_VALUE_SET);
theDataQueryParams.setOutputDataElementIdScheme(CODE);
// When
final Map<String, String> responseMap = schemaIdResponseMapper.getSchemeIdResponseMap(theDataQueryParams);
// Then
final String orgUnitUid = orUnitStub.getUid();
final String periodIsoDate = periodStub.getIsoDate();
final DataElement dataElementA = dataElementOperandsStub.get(0).getDataElement();
final DataElement dataElementB = dataElementOperandsStub.get(1).getDataElement();
final CategoryOptionCombo categoryOptionComboC = dataElementOperandsStub.get(0).getCategoryOptionCombo();
assertThat(responseMap.get(orgUnitUid), is(equalTo(orUnitStub.getUid())));
assertThat(responseMap.get(periodIsoDate), is(equalTo(periodStub.getUid())));
assertThat(responseMap.get(dataElementA.getUid()), is(equalTo(dataElementA.getCode())));
assertThat(responseMap.get(dataElementB.getUid()), is(equalTo(dataElementB.getCode())));
assertThat(responseMap.get(categoryOptionComboC.getUid()), is(equalTo(categoryOptionComboC.getCode())));
assertThat(responseMap.get(categoryOptionComboC.getUid()), is(equalTo(categoryOptionComboC.getCode())));
}
use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.
the class SchemaIdResponseMapperTest method stubDataElementOperands.
private List<DataElementOperand> stubDataElementOperands() {
final DataElement dataElementA = new DataElement("NameA");
dataElementA.setUid("uid1234567A");
dataElementA.setCode("CodeA");
final DataElement dataElementB = new DataElement("NameB");
dataElementB.setUid("uid1234567B");
dataElementB.setCode("CodeB");
final CategoryOptionCombo categoryOptionCombo = new CategoryOptionCombo();
categoryOptionCombo.setName("NameC");
categoryOptionCombo.setUid("uid1234567C");
categoryOptionCombo.setCode("CodeC");
final DataElementOperand dataElementOperandA = new DataElementOperand(dataElementA, categoryOptionCombo);
final DataElementOperand dataElementOperandB = new DataElementOperand(dataElementB, categoryOptionCombo);
return newArrayList(dataElementOperandA, dataElementOperandB);
}
use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.
the class SchemaIdResponseMapperTest method testGetSchemeIdResponseMapWhenOutputIdSchemeIsSetToUid.
@Test
void testGetSchemeIdResponseMapWhenOutputIdSchemeIsSetToUid() {
// Given
final List<DataElementOperand> dataElementOperandsStub = stubDataElementOperands();
final OrganisationUnit orUnitStub = stubOrgUnit();
final Period periodStub = stubPeriod();
final DataQueryParams theDataQueryParams = stubQueryParams(dataElementOperandsStub, orUnitStub, periodStub);
theDataQueryParams.setOutputIdScheme(UUID);
// When
final Map<String, String> responseMap = schemaIdResponseMapper.getSchemeIdResponseMap(theDataQueryParams);
// Then
final String orgUnitUid = orUnitStub.getUid();
final String periodIsoDate = periodStub.getIsoDate();
final DataElement dataElementA = dataElementOperandsStub.get(0).getDataElement();
final DataElement dataElementB = dataElementOperandsStub.get(1).getDataElement();
final CategoryOptionCombo categoryOptionComboC = dataElementOperandsStub.get(0).getCategoryOptionCombo();
assertThat(responseMap.get(orgUnitUid), is(emptyOrNullString()));
assertThat(responseMap.get(periodIsoDate), is(emptyOrNullString()));
assertThat(responseMap.get(dataElementA.getUid()), is(emptyOrNullString()));
assertThat(responseMap.get(dataElementB.getUid()), is(emptyOrNullString()));
assertThat(responseMap.get(categoryOptionComboC.getUid()), is(emptyOrNullString()));
assertThat(responseMap.get(categoryOptionComboC.getUid()), is(emptyOrNullString()));
}
use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.
the class SchemaIdResponseMapperTest method testGetSchemeIdResponseMapWhenOutputOrgUnitIdSchemeIsSetToCodeForDataValueSet.
@Test
void testGetSchemeIdResponseMapWhenOutputOrgUnitIdSchemeIsSetToCodeForDataValueSet() {
// Given
final List<DataElementOperand> dataElementOperandsStub = stubDataElementOperands();
final OrganisationUnit orUnitStub = stubOrgUnit();
final Period periodStub = stubPeriod();
final DataQueryParams theDataQueryParams = stubQueryParams(dataElementOperandsStub, orUnitStub, periodStub, DATA_VALUE_SET);
theDataQueryParams.setOutputOrgUnitIdScheme(CODE);
// When
final Map<String, String> responseMap = schemaIdResponseMapper.getSchemeIdResponseMap(theDataQueryParams);
// Then
final String orgUnitUid = orUnitStub.getUid();
final String periodIsoDate = periodStub.getIsoDate();
final DataElement dataElementA = dataElementOperandsStub.get(0).getDataElement();
final DataElement dataElementB = dataElementOperandsStub.get(1).getDataElement();
final CategoryOptionCombo categoryOptionComboC = dataElementOperandsStub.get(0).getCategoryOptionCombo();
assertThat(responseMap.get(orgUnitUid), is(equalTo(orUnitStub.getCode())));
assertThat(responseMap.get(periodIsoDate), is(equalTo(periodStub.getUid())));
assertThat(responseMap.get(dataElementA.getUid()), is(emptyOrNullString()));
assertThat(responseMap.get(dataElementB.getUid()), is(emptyOrNullString()));
assertThat(responseMap.get(categoryOptionComboC.getUid()), is(emptyOrNullString()));
assertThat(responseMap.get(categoryOptionComboC.getUid()), is(emptyOrNullString()));
}
use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.
the class DefaultPdfDataEntryFormService method insertTable_DataSetSections.
private void insertTable_DataSetSections(PdfPTable mainTable, PdfWriter writer, Rectangle rectangle, Collection<DataElement> dataElements, String sectionName) throws IOException, DocumentException {
boolean hasBorder = true;
// Add Section Name and Section Spacing
insertTable_TextRow(writer, mainTable, TEXT_BLANK);
if (sectionName != null && !sectionName.isEmpty()) {
insertTable_TextRow(writer, mainTable, sectionName, pdfFormFontSettings.getFont(PdfFormFontSettings.FONTTYPE_SECTIONHEADER));
}
// Create A Table To Add For Each Section
PdfPTable table = new PdfPTable(2);
table.setWidths(new int[] { 2, 1 });
table.setWidthPercentage(100.0f);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
// row.
for (DataElement dataElement : dataElements) {
for (CategoryOptionCombo categoryOptionCombo : dataElement.getSortedCategoryOptionCombos()) {
String categoryOptionComboDisplayName = "";
// Hide Default category option combo name
if (!categoryOptionCombo.isDefault()) {
categoryOptionComboDisplayName = categoryOptionCombo.getDisplayName();
}
addCell_Text(table, PdfDataEntryFormUtil.getPdfPCell(hasBorder), dataElement.getFormNameFallback() + " " + categoryOptionComboDisplayName, Element.ALIGN_RIGHT);
String strFieldLabel = PdfDataEntryFormUtil.LABELCODE_DATAENTRYTEXTFIELD + dataElement.getUid() + "_" + categoryOptionCombo.getUid();
ValueType valueType = dataElement.getValueType();
// Yes Only case - render as check-box
if (ValueType.TRUE_ONLY == valueType) {
addCell_WithCheckBox(table, writer, PdfDataEntryFormUtil.getPdfPCell(hasBorder), strFieldLabel);
} else if (ValueType.BOOLEAN == valueType) {
// Create Yes - true, No - false, Select..
String[] optionList = new String[] { "[No Value]", "Yes", "No" };
String[] valueList = new String[] { "", "true", "false" };
// addCell_WithRadioButton(table, writer, strFieldLabel);
addCell_WithDropDownListField(table, rectangle, writer, PdfDataEntryFormUtil.getPdfPCell(hasBorder), strFieldLabel, optionList, valueList);
} else if (valueType.isNumeric()) {
Rectangle rectNum = new Rectangle(TEXTBOXWIDTH_NUMBERTYPE, PdfDataEntryFormUtil.CONTENT_HEIGHT_DEFAULT);
addCell_WithTextField(table, rectNum, writer, PdfDataEntryFormUtil.getPdfPCell(hasBorder), strFieldLabel, PdfFieldCell.TYPE_TEXT_NUMBER);
} else {
addCell_WithTextField(table, rectangle, writer, PdfDataEntryFormUtil.getPdfPCell(hasBorder), strFieldLabel);
}
}
}
PdfPCell cell_withInnerTable = new PdfPCell(table);
cell_withInnerTable.setBorder(Rectangle.NO_BORDER);
mainTable.addCell(cell_withInnerTable);
}
Aggregations