dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26280
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13023: PDF checkbox value changed from On/Off --> true/false
------------------------------------------------------------
revno: 13023
committer: James Chang <jamesbchang@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-11-26 15:13:23 +0700
message:
PDF checkbox value changed from On/Off --> true/false
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/DefaultPdfDataEntryFormService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/PdfDataEntryFormUtil.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/PdfFieldCell.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/DefaultPdfDataEntryFormService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/DefaultPdfDataEntryFormService.java 2013-11-04 23:12:03 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/DefaultPdfDataEntryFormService.java 2013-11-26 08:13:23 +0000
@@ -698,7 +698,7 @@
checkbox.setBorderColor( Color.BLACK );
PdfFormField checkboxfield = checkbox.getCheckField();
- checkboxfield.setFieldName( strfldName );
+ checkboxfield.setFieldName( strfldName + "_" + PdfFieldCell.TPYEDEFINE_NAME + PdfFieldCell.TYPE_CHECKBOX );
setCheckboxAppearance(checkboxfield, writer.getDirectContent(), sizeDefault);
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/PdfDataEntryFormUtil.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/PdfDataEntryFormUtil.java 2013-10-02 06:24:18 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/PdfDataEntryFormUtil.java 2013-11-26 08:13:23 +0000
@@ -250,8 +250,8 @@
dataValue.setOrgUnit( orgUnitUID );
dataValue.setPeriod( period.getIsoDate() );
- dataValue.setValue( form.getField( fldName ) );
-
+ dataValue.setValue( fieldValueFormat( strArrFldName, form.getField( fldName ) ) );
+
dataValue.setStoredBy( DATAVALUE_IMPORT_STOREBY );
dataValue.setComment( DATAVALUE_IMPORT_COMMENT );
dataValue.setFollowup( false );
@@ -283,4 +283,29 @@
return dataValueSet;
}
+
+ private static String fieldValueFormat( String[] strArrFldName, String fldValue )
+ {
+ // For checkbox, we need to change value from Off/On --> false/true
+ if( strArrFldName.length == 4
+ && strArrFldName[3].substring( 0, 1 ).compareTo( PdfFieldCell.TPYEDEFINE_NAME ) == 0 )
+ {
+ int fieldType = Integer.parseInt( strArrFldName[3].substring( 1 ) );
+
+ if( fieldType == PdfFieldCell.TYPE_CHECKBOX )
+ {
+ if( fldValue.compareTo( "On" ) == 0 )
+ {
+ fldValue = "true";
+ }
+ else if( fldValue.compareTo( "Off" ) == 0 )
+ {
+ fldValue = "false";
+ }
+ }
+ }
+
+ return fldValue;
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/PdfFieldCell.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/PdfFieldCell.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/PdfFieldCell.java 2013-11-26 08:13:23 +0000
@@ -67,6 +67,8 @@
public final static int TPYE_LABEL = 6;
+ public final static String TPYEDEFINE_NAME = "T";
+
private final static float RADIOBUTTON_WIDTH = 10.0f;
private final static float RADIOBUTTON_TEXTOFFSET = 3.0f;