dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36811
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18824: add back support for tracker associate in tracker API
------------------------------------------------------------
revno: 18824
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-04-08 11:43:57 +0700
message:
add back support for tracker associate in tracker API
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java
dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAddUpdateAttributeAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm
--
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-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2015-03-31 03:17:35 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2015-04-08 04:43:57 +0000
@@ -78,6 +78,8 @@
private OptionSet optionSet;
+ private TrackedEntity trackedEntity;
+
private String expression;
private Boolean displayOnVisitSchedule = false;
@@ -345,6 +347,20 @@
}
@JsonProperty
+ @JsonSerialize( as = BaseIdentifiableObject.class )
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public TrackedEntity getTrackedEntity()
+ {
+ return trackedEntity;
+ }
+
+ public void setTrackedEntity( TrackedEntity trackedEntity )
+ {
+ this.trackedEntity = trackedEntity;
+ }
+
+ @JsonProperty
@JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public Boolean getConfidential()
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml 2015-03-18 13:03:25 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml 2015-04-08 04:43:57 +0000
@@ -27,6 +27,9 @@
<many-to-one name="optionSet" class="org.hisp.dhis.option.OptionSet"
column="optionsetid" foreign-key="fk_trackedentityattribute_optionsetid" />
+ <many-to-one name="trackedEntity" class="org.hisp.dhis.trackedentity.TrackedEntity"
+ column="trackedentityid" foreign-key="fk_trackedentityattribute_trackedentityid" />
+
<many-to-one name="legendSet" class="org.hisp.dhis.legend.LegendSet" column="legendsetid"
foreign-key="fk_dataelement_legendset" />
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java 2015-03-19 05:16:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java 2015-04-08 04:43:57 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.opensymphony.xwork2.Action;
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.legend.LegendService;
@@ -36,10 +37,9 @@
import org.hisp.dhis.system.util.AttributeUtils;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
+import org.hisp.dhis.trackedentity.TrackedEntityService;
import org.springframework.beans.factory.annotation.Autowired;
-import com.opensymphony.xwork2.Action;
-
import java.util.List;
/**
@@ -67,11 +67,14 @@
}
@Autowired
+ private TrackedEntityService trackedEntityService;
+
+ @Autowired
private OptionService optionService;
@Autowired
private PeriodService periodService;
-
+
@Autowired
private LegendService legendService;
@@ -144,7 +147,14 @@
{
this.optionSetId = optionSetId;
}
-
+
+ private Integer trackedEntityId;
+
+ public void setTrackedEntityId( Integer trackedEntityId )
+ {
+ this.trackedEntityId = trackedEntityId;
+ }
+
private Integer legendSetId;
public void setLegendSetId( Integer legendSetId )
@@ -160,12 +170,12 @@
}
private Boolean confidential;
-
+
public void setConfidential( Boolean confidential )
{
this.confidential = confidential;
}
-
+
private List<String> jsonAttributeValues;
public void setJsonAttributeValues( List<String> jsonAttributeValues )
@@ -213,7 +223,7 @@
{
programScope = true;
}
-
+
trackedEntityAttribute.setOrgunitScope( orgunitScope );
trackedEntityAttribute.setProgramScope( programScope );
}
@@ -221,7 +231,11 @@
{
trackedEntityAttribute.setOptionSet( optionService.getOptionSet( optionSetId ) );
}
-
+ else if ( valueType.equals( TrackedEntityAttribute.TYPE_TRACKER_ASSOCIATE ) )
+ {
+ trackedEntityAttribute.setTrackedEntity( trackedEntityService.getTrackedEntity( trackedEntityId ) );
+ }
+
if ( legendSetId != null )
{
trackedEntityAttribute.setLegendSet( legendService.getLegendSet( legendSetId ) );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAddUpdateAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAddUpdateAttributeAction.java 2015-03-19 09:29:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAddUpdateAttributeAction.java 2015-04-08 04:43:57 +0000
@@ -40,8 +40,10 @@
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.system.util.AttributeUtils;
+import org.hisp.dhis.trackedentity.TrackedEntity;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
+import org.hisp.dhis.trackedentity.TrackedEntityService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
@@ -64,6 +66,9 @@
private TrackedEntityAttributeService trackedEntityAttributeService;
@Autowired
+ private TrackedEntityService trackedEntityService;
+
+ @Autowired
private ProgramService programService;
@Autowired
@@ -138,6 +143,13 @@
return attributeValues;
}
+ private List<TrackedEntity> trackedEntities;
+
+ public List<TrackedEntity> getTrackedEntities()
+ {
+ return trackedEntities;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -160,9 +172,11 @@
optionSets = new ArrayList<>( optionService.getAllOptionSets() );
legendSets = legendService.getAllLegendSets();
attributes = new ArrayList<>( attributeService.getTrackedEntityAttributeAttributes() );
+ trackedEntities = new ArrayList<>( trackedEntityService.getAllTrackedEntity() );
Collections.sort( optionSets );
Collections.sort( legendSets );
+ Collections.sort( trackedEntities );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java 2015-03-19 05:16:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java 2015-04-08 04:43:57 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.opensymphony.xwork2.Action;
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.legend.LegendService;
@@ -36,10 +37,9 @@
import org.hisp.dhis.system.util.AttributeUtils;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
+import org.hisp.dhis.trackedentity.TrackedEntityService;
import org.springframework.beans.factory.annotation.Autowired;
-import com.opensymphony.xwork2.Action;
-
import java.util.List;
/**
@@ -67,6 +67,9 @@
}
@Autowired
+ private TrackedEntityService trackedEntityService;
+
+ @Autowired
private OptionService optionService;
@Autowired
@@ -138,6 +141,13 @@
this.optionSetId = optionSetId;
}
+ private Integer trackedEntityId;
+
+ public void setTrackedEntityId( Integer trackedEntityId )
+ {
+ this.trackedEntityId = trackedEntityId;
+ }
+
private Integer legendSetId;
public void setLegendSetId( Integer legendSetId )
@@ -167,12 +177,12 @@
}
private Boolean confidential;
-
+
public void setConfidential( Boolean confidential )
{
this.confidential = confidential;
}
-
+
private List<String> jsonAttributeValues;
public void setJsonAttributeValues( List<String> jsonAttributeValues )
@@ -228,6 +238,10 @@
{
trackedEntityAttribute.setOptionSet( optionService.getOptionSet( optionSetId ) );
}
+ else if ( valueType.equals( TrackedEntityAttribute.TYPE_TRACKER_ASSOCIATE ) )
+ {
+ trackedEntityAttribute.setTrackedEntity( trackedEntityService.getTrackedEntity( trackedEntityId ) );
+ }
if ( legendSetId != null )
{
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml 2015-03-19 11:14:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml 2015-04-08 04:43:57 +0000
@@ -368,7 +368,7 @@
<param name="page">/dhis-web-maintenance-program/programStageList.vm</param>
<param name="javascripts">javascript/programStage.js</param>
</action>
-
+
<action name="sortProgramStagesForm"
class="org.hisp.dhis.trackedentity.action.program.GetProgramAction">
<result name="success" type="velocity">/main.vm</result>
@@ -377,7 +377,7 @@
<param name="stylesheets">style/basic.css</param>
<param name="requiredAuthorities">F_PROGRAMSTAGE_ADD</param>
</action>
-
+
<action name="sortProgramStages"
class="org.hisp.dhis.trackedentity.action.programstage.SortProgramStagesAction">
<result name="success" type="redirect">programStage.action?id=${id}</result>
@@ -814,8 +814,8 @@
</result>
<param name="onExceptionReturn">plainTextError</param>
</action>
-
- <action name="getOptions"
+
+ <action name="getOptions"
class="org.hisp.dhis.trackedentity.action.caseaggregation.GetOptionsAction">
<result name="success" type="velocity-json">
/dhis-web-maintenance-program/jsonOptions.vm
@@ -959,9 +959,10 @@
<action name="getProgramExpressionDescription"
class="org.hisp.dhis.trackedentity.action.validation.GetProgramExpressionDescriptionAction">
<result name="success" type="velocity">
- /dhis-web-commons/ajax/jsonResponseSuccess.vm
- </result> <result name="error" type="velocity">
- /dhis-web-commons/ajax/jsonResponseError.vm
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm
+ </result>
+ <result name="error" type="velocity">
+ /dhis-web-commons/ajax/jsonResponseError.vm
</result>
<param name="onExceptionReturn">plainTextError</param>
</action>
@@ -1075,7 +1076,8 @@
class="org.hisp.dhis.trackedentity.action.programindicator.GetProgramIndicatorDescriptionAction">
<result name="success" type="velocity-json">
/dhis-web-commons/ajax/jsonResponseSuccess.vm
- </result> <result name="error" type="velocity-json">
+ </result>
+ <result name="error" type="velocity-json">
/dhis-web-commons/ajax/jsonResponseError.vm
</result>
</action>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm 2015-03-19 09:29:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm 2015-04-08 04:43:57 +0000
@@ -91,7 +91,7 @@
<option value="string">$i18n.getString( "text" )</option>
<option value="letter">$i18n.getString( "letter_only" )</option>
<option value="bool">$i18n.getString( "yes_no" )</option>
- <option value="trueOnly">$i18n.getString( "yes_only" )</option>
+ <option value="trueOnly">$i18n.getString( "yes_only" )</option>
<option value="date">$i18n.getString( "date" )</option>
<option value="phoneNumber">$i18n.getString( "phone_number" )</option>
<option value="phoneNumber">$i18n.getString( "email" )</option>
@@ -102,16 +102,27 @@
</td>
<td></td>
</tr>
- <tr id="optionSetRow" class="hidden">
+
+ <tr id="optionSetRow" class="hidden">
<td><label for="optionSetId">$i18n.getString( "option_set" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td><select id="optionSetId" name="optionSetId" class="{validate:{required:true}}" disabled>
#foreach($optionSet in $optionSets)
- <option value="$optionSet.id">$optionSet.name</option>
+ <option value="$optionSet.id">$encoder.htmlEncode($optionSet.name)</option>
#end
</select>
</td>
</tr>
+ <tr id="trackedEntityRow" class="hidden">
+ <td><label for="trackedEntityId">$i18n.getString( "tracked_entity" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><select id="trackedEntityId" name="trackedEntityId" class="{validate:{required:true}}" disabled>
+ #foreach( $trackedEntity in $trackedEntities )
+ <option value="$trackedEntity.id">$encoder.htmlEncode($trackedEntity.name)</option>
+ #end
+ </select>
+ </td>
+ </tr>
+
<tr>
<td><label for="legendSetId">$i18n.getString( 'legend_set' )</label></td>
<td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js 2014-07-02 12:11:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js 2015-04-08 04:43:57 +0000
@@ -82,19 +82,25 @@
function typeOnChange() {
var type = getFieldValue('valueType');
- if( type=="optionSet"){
+
+ hideById("optionSetRow");
+ disable("optionSetId");
+ hideById("trackedEntityRow");
+ disable("trackedEntityId");
+
+ if( type == "optionSet" ) {
showById("optionSetRow");
enable("optionSetId");
}
- else{
- hideById("optionSetRow");
- disable("optionSetId");
+ else if( type == "trackerAssociate" ) {
+ showById("trackedEntityRow");
+ enable("trackedEntityId");
}
-
- if( type=="number" || type=='string' || type=='letter' || type=='phoneNumber' ){
+
+ if( type == "number" || type == 'string' || type == 'letter' || type == 'phoneNumber' ) {
enable("unique");
}
- else{
+ else {
disable("unique");
}
}
@@ -119,4 +125,3 @@
jQuery('#valueType [value=optionSet]').show();
}
}
-
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm 2015-03-19 09:29:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm 2015-04-08 04:43:57 +0000
@@ -87,19 +87,19 @@
<option value="number" #if( $attribute.valueType == 'number' ) selected="selected" #end>$i18n.getString( "number" )</option>
<option value="string" #if( $attribute.valueType == 'string' ) selected="selected" #end>$i18n.getString( "text" )</option>
<option value="letter" #if( $attribute.valueType == 'letter' ) selected="selected" #end>$i18n.getString( "letter_only" )</option>
- <option value="bool" #if( $attribute.unique=='true' ) style='display:none' #end #if( $attribute.valueType == 'bool' ) selected="selected" #end>$i18n.getString( "yes_no" )</option>
+ <option value="bool" #if( $attribute.unique=='true' ) style='display:none' #end #if( $attribute.valueType == 'bool' ) selected="selected" #end>$i18n.getString( "yes_no" )</option>
<option value="trueOnly" #if( $attribute.unique=='true' ) style='display:none' #end #if( $attribute.valueType == 'trueOnly' ) selected="selected" #end >$i18n.getString( "yes_only" )</option>
- <option value="date" #if( $attribute.unique=='true' ) style='display:none' #end #if( $attribute.valueType == 'date' ) selected="selected" #end>$i18n.getString( "date" )</option>
+ <option value="date" #if( $attribute.unique=='true' ) style='display:none' #end #if( $attribute.valueType == 'date' ) selected="selected" #end>$i18n.getString( "date" )</option>
<option value="phoneNumber" #if( $attribute.valueType == 'phoneNumber' ) selected="selected" #end>$i18n.getString( "phone_number" )</option>
<option value="email" #if( $attribute.valueType == 'email' ) selected="selected" #end>$i18n.getString( "email" )</option>
- <option value="trackerAssociate" #if( $attribute.unique=='true' ) style='display:none' #end #if( $attribute.valueType == 'trackerAssociate' ) selected="selected" #end>$i18n.getString( "tracker_associate" )</option>
- <option value="users" #if( $attribute.unique=='true' ) style='display:none' #end #if( $attribute.valueType == 'users' ) selected="selected" #end>$i18n.getString( "users" )</option>
- <option value="optionSet" #if( $attribute.unique=='true' ) style='display:none' #end #if( $attribute.valueType == 'optionSet' ) selected="selected" #end>$i18n.getString( "option_set" )</option>
+ <option value="trackerAssociate" #if( $attribute.unique=='true' ) style='display:none' #end #if( $attribute.valueType == 'trackerAssociate' ) selected="selected" #end>$i18n.getString( "tracker_associate" )</option>
+ <option value="users" #if( $attribute.unique=='true' ) style='display:none' #end #if( $attribute.valueType == 'users' ) selected="selected" #end>$i18n.getString( "users" )</option>
+ <option value="optionSet" #if( $attribute.unique=='true' ) style='display:none' #end #if( $attribute.valueType == 'optionSet' ) selected="selected" #end>$i18n.getString( "option_set" )</option>
</select>
</td>
</tr>
-
- <tr id="optionSetRow" #if($attribute.optionSet) #else class="hidden" #end>
+
+ <tr id="optionSetRow" #if($attribute.optionSet) #else class="hidden" #end>
<td><label for="optionSetId">$i18n.getString( "option_set" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td><select id="optionSetId" name="optionSetId" class="{validate:{required:true}}">
#foreach($optionSet in $optionSets)
@@ -108,7 +108,17 @@
</select>
</td>
</tr>
-
+
+ <tr id="trackedEntityRow" #if($attribute.trackedEntity) #else class="hidden" #end>
+ <td><label for="trackedEntityId">$i18n.getString( "tracked_entity" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><select id="trackedEntityId" name="trackedEntityId" class="{validate:{required:true}}">
+ #foreach( $trackedEntity in $trackedEntities )
+ <option value="$trackedEntity.id" #if($attribute.trackedEntity.id==$trackedEntity.id) selected#end>$encoder.htmlEncode($trackedEntity.name)</option>
+ #end
+ </select>
+ </td>
+ </tr>
+
<tr>
<td><label for="legendSetId">$i18n.getString( 'legend_set' )</label></td>
<td>