dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35640
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18231: Web api, added comment to forms resource
------------------------------------------------------------
revno: 18231
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-02-12 09:42:09 +0100
message:
Web api, added comment to forms resource
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/Forms.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/Field.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-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java 2015-02-12 08:42:09 +0000
@@ -84,7 +84,7 @@
for ( Section section : sections )
{
- List<Field> fields = inputsFromDataElements( new ArrayList<>( section.getDataElements() ), new ArrayList<>( section.getGreyedFields() ) );
+ List<Field> fields = inputFromDataElements( new ArrayList<>( section.getDataElements() ), new ArrayList<>( section.getGreyedFields() ) );
Group group = new Group();
group.setLabel( section.getDisplayName() );
@@ -103,7 +103,7 @@
}
else
{
- List<Field> fields = inputsFromDataElements( new ArrayList<>( dataSet.getDataElements() ) );
+ List<Field> fields = inputFromDataElements( new ArrayList<>( dataSet.getDataElements() ) );
Group group = new Group();
group.setLabel( DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME );
@@ -167,7 +167,7 @@
{
for ( ProgramStageSection section : programStage.getProgramStageSections() )
{
- List<Field> fields = inputsFromProgramStageDataElements( section.getProgramStageDataElements() );
+ List<Field> fields = inputFromProgramStageDataElements( section.getProgramStageDataElements() );
Group group = new Group();
group.setLabel( section.getDisplayName() );
@@ -178,7 +178,7 @@
}
else
{
- List<Field> fields = inputsFromProgramStageDataElements(
+ List<Field> fields = inputFromProgramStageDataElements(
new ArrayList<>( programStage.getProgramStageDataElements() ) );
Group group = new Group();
@@ -191,7 +191,7 @@
return form;
}
- private static List<Field> inputsFromProgramStageDataElements( List<ProgramStageDataElement> programStageDataElements )
+ private static List<Field> inputFromProgramStageDataElements( List<ProgramStageDataElement> programStageDataElements )
{
List<DataElement> dataElements = new ArrayList<>();
@@ -200,15 +200,15 @@
dataElements.add( programStageDataElement.getDataElement() );
}
- return inputsFromDataElements( dataElements, new ArrayList<DataElementOperand>() );
+ return inputFromDataElements( dataElements, new ArrayList<DataElementOperand>() );
}
- private static List<Field> inputsFromDataElements( List<DataElement> dataElements )
+ private static List<Field> inputFromDataElements( List<DataElement> dataElements )
{
- return inputsFromDataElements( dataElements, new ArrayList<DataElementOperand>() );
+ return inputFromDataElements( dataElements, new ArrayList<DataElementOperand>() );
}
- private static List<Field> inputsFromDataElements( List<DataElement> dataElements, final List<DataElementOperand> greyedFields )
+ private static List<Field> inputFromDataElements( List<DataElement> dataElements, final List<DataElementOperand> greyedFields )
{
List<Field> fields = new ArrayList<>();
@@ -324,14 +324,17 @@
public static void fillWithDataValues( Form form, Collection<DataValue> dataValues )
{
- Map<String, Field> cacheMap = buildCacheMap( form );
+ Map<String, Field> operandFieldMap = buildCacheMap( form );
for ( DataValue dataValue : dataValues )
{
DataElement dataElement = dataValue.getDataElement();
DataElementCategoryOptionCombo categoryOptionCombo = dataValue.getCategoryOptionCombo();
- cacheMap.get( dataElement.getUid() + "-" + categoryOptionCombo.getUid() ).setValue( dataValue.getValue() );
+ Field field = operandFieldMap.get( dataElement.getUid() + SEP + categoryOptionCombo.getUid() );
+
+ field.setValue( dataValue.getValue() );
+ field.setComment( dataValue.getComment() );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/Forms.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/Forms.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/Forms.java 2015-02-12 08:42:09 +0000
@@ -47,10 +47,14 @@
@JacksonXmlRootElement( localName = "forms", namespace = DxfNamespaces.DXF_2_0 )
public class Forms
{
- // maps ou.uid => org unit.
+ /**
+ * Maps ou.uid => org unit.
+ */
private Map<String, FormOrganisationUnit> organisationUnits = new HashMap<>();
- // maps dataSet.uid => form instance
+ /**
+ * Maps dataSet.uid => form instance.
+ */
private Map<String, Form> forms = new HashMap<>();
private Map<String, List<String>> optionSets = Maps.newHashMap();
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/Field.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/Field.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/Field.java 2015-02-12 08:42:09 +0000
@@ -46,6 +46,8 @@
private String categoryOptionCombo;
private String value;
+
+ private String comment;
private InputType type;
@@ -105,6 +107,18 @@
@JsonProperty
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public String getComment()
+ {
+ return comment;
+ }
+
+ public void setComment( String comment )
+ {
+ this.comment = comment;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public InputType getType()
{
return type;