← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20068: Add Program set in UserAuthorityGroup object.

 

------------------------------------------------------------
revno: 20068
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-09-09 13:18:52 -0700
message:
  Add Program set in UserAuthorityGroup object.
removed:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/DefineProgramUserroleAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programUserrole.vm
added:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetProgramsAction.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserAuthorityGroup.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/UserAuthorityGroup.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPrograms.vm
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties
  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/javascript/program.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programList.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddRoleAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetRoleAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateRoleAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addRoleForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allRole.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/role.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateRoleForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateRoleForm.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/user/UserAuthorityGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserAuthorityGroup.java	2015-09-07 13:13:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserAuthorityGroup.java	2015-09-09 20:18:52 +0000
@@ -35,6 +35,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.google.common.collect.Sets;
+
 import org.apache.commons.collections.CollectionUtils;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
@@ -44,6 +45,7 @@
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.program.Program;
 import org.hisp.dhis.schema.annotation.PropertyRange;
 
 import java.util.ArrayList;
@@ -61,8 +63,9 @@
     public static final String AUTHORITY_ALL = "ALL";
 
     public static final String[] CRITICAL_AUTHS = { "ALL", "F_SCHEDULING_ADMIN", "F_SYSTEM_SETTING",
-        "F_SQLVIEW_PUBLIC_ADD", "F_SQLVIEW_PRIVATE_ADD", "F_SQLVIEW_DELETE", "F_SQLVIEW_EXECUTE", "F_SQLVIEW_MANAGEMENT",
-        "F_USERROLE_PUBLIC_ADD", "F_USERROLE_PRIVATE_ADD", "F_USERROLE_DELETE", "F_USERROLE_LIST" };
+        "F_SQLVIEW_PUBLIC_ADD", "F_SQLVIEW_PRIVATE_ADD", "F_SQLVIEW_DELETE", "F_SQLVIEW_EXECUTE",
+        "F_SQLVIEW_MANAGEMENT", "F_USERROLE_PUBLIC_ADD", "F_USERROLE_PRIVATE_ADD", "F_USERROLE_DELETE",
+        "F_USERROLE_LIST" };
 
     /**
      * Required and unique.
@@ -75,7 +78,9 @@
 
     @Scanned
     private Set<DataSet> dataSets = new HashSet<>();
-    
+
+    private Set<Program> programs = new HashSet<>();
+
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -111,6 +116,18 @@
         return authorities != null && CollectionUtils.containsAny( authorities, Sets.newHashSet( CRITICAL_AUTHS ) );
     }
 
+    public void addProgam( Program program )
+    {
+        programs.add( program );
+        program.getUserRoles().add( this );
+    }
+
+    public boolean removeProgam( Program program )
+    {
+        programs.remove( program );
+        return program.getUserRoles().remove( this );
+    }
+
     // -------------------------------------------------------------------------
     // Getters and setters
     // -------------------------------------------------------------------------
@@ -203,6 +220,26 @@
         authorities.clear();
     }
 
+    public void removeAllPrograms()
+    {
+        programs.clear();
+    }
+
+    @JsonProperty
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlElementWrapper( localName = "programs", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "programs", namespace = DxfNamespaces.DXF_2_0 )
+    public Set<Program> getPrograms()
+    {
+        return programs;
+    }
+
+    public void setPrograms( Set<Program> programs )
+    {
+        this.programs = programs;
+    }
+
     @Override
     public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
     {
@@ -218,7 +255,8 @@
             }
             else if ( strategy.isMerge() )
             {
-                description = userAuthorityGroup.getDescription() == null ? description : userAuthorityGroup.getDescription();
+                description = userAuthorityGroup.getDescription() == null ? description : userAuthorityGroup
+                    .getDescription();
             }
 
             removeAllAuthorities();
@@ -226,6 +264,9 @@
 
             removeAllDataSets();
             dataSets.addAll( userAuthorityGroup.getDataSets() );
+
+            removeAllPrograms();
+            programs.addAll( userAuthorityGroup.getPrograms() );
         }
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2015-09-01 14:28:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2015-09-09 20:18:52 +0000
@@ -56,7 +56,7 @@
 
     <property name="ignoreOverdueEvents" />
 
-    <set name="userRoles" table="program_userroles">
+    <set name="userRoles" table="program_userroles" inverse="true">
       <key column="programid" />
       <many-to-many class="org.hisp.dhis.user.UserAuthorityGroup"
         column="userroleid" foreign-key="fk_program_userroles" />

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/UserAuthorityGroup.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/UserAuthorityGroup.hbm.xml	2014-03-24 18:52:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/UserAuthorityGroup.hbm.xml	2015-09-09 20:18:52 +0000
@@ -35,6 +35,11 @@
       <many-to-many column="datasetid" class="org.hisp.dhis.dataset.DataSet" foreign-key="fk_userroledataset_datasetid" />
     </set>
 
+    <set name="programs" table="userroleprogram">
+      <key column="userroleid" foreign-key="fk_userroleprogram_userroleid" />
+      <many-to-many column="programid" class="org.hisp.dhis.program.Program" foreign-key="fk_userroleprogram_programid" />
+    </set>
+    
     <!-- Access properties -->
     <many-to-one name="user" class="org.hisp.dhis.user.User" column="userid" foreign-key="fk_userrole_userid" />
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js	2015-07-02 07:05:55 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js	2015-09-09 20:18:52 +0000
@@ -33,7 +33,7 @@
 			for ( i in json.programs ) {
 				if(json.programs[i].programType=='WITH_REGISTRATION'){
 					count++;
-					jQuery( '#program').append( '<option value="' + json.programs[i].uid +'" type="' + json.programs[i].programType + '">' + json.programs[i].name + '</option>' );
+					jQuery( '#program').append( '<option value="' + json.programs[i].id +'" type="' + json.programs[i].programType + '">' + json.programs[i].name + '</option>' );
 				}
 			}
 			if(count==0){

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPrograms.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPrograms.vm	2015-07-02 07:05:55 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPrograms.vm	2015-09-09 20:18:52 +0000
@@ -3,8 +3,7 @@
 	"programs": [
 		#foreach( $program in $programs )
 		  {
-			"id"  : ${program.id} ,
-			"uid" : "${program.uid}" ,
+			"id"  : "$!{program.uid}",
 			"name": "$!encoder.jsonEncode( ${program.name} )",
 			"programType": "$program.programType"
 		  }#if( $velocityCount < $size ),#end

=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetProgramsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetProgramsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetProgramsAction.java	2015-09-09 20:18:52 +0000
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.commons.action;
+
+import static org.apache.commons.lang3.StringUtils.isNotBlank;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.paging.ActionPagingSupport;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * $version GetProgramsAction.java Sep 8, 2015 3:44:27 PM $
+ */
+public class GetProgramsAction extends ActionPagingSupport<Program>
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private List<Program> programs = new ArrayList<>();
+
+    public List<Program> getPrograms()
+    {
+        return programs;
+    }
+
+    private String key;
+
+    public String getKey()
+    {
+        return key;
+    }
+
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        if ( isNotBlank( key ) )
+        {
+            this.paging = createPaging( programService.getProgramCountByName( key ) );
+
+            programs = programService.getProgramBetweenByName( key, paging.getStartPos(),
+                paging.getPageSize() );
+        }
+        else
+        {
+            this.paging = createPaging( programService.getProgramCount() );
+            
+            programs = programService.getProgramsBetween( paging.getStartPos(),
+                paging.getPageSize() );
+        }
+
+        Collections.sort( programs, IdentifiableObjectNameComparator.INSTANCE );
+
+        return SUCCESS;
+    }
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2015-09-09 08:59:43 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2015-09-09 20:18:52 +0000
@@ -410,6 +410,11 @@
     <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
   </bean>
 
+  <bean id="org.hisp.dhis.commons.action.GetProgramsAction" class="org.hisp.dhis.commons.action.GetProgramsAction"
+    scope="prototype">
+    <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+  </bean>
+  
   <bean id="org.hisp.dhis.commons.action.GetIndicatorAction" class="org.hisp.dhis.commons.action.GetIndicatorAction"
     scope="prototype">
     <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2015-09-08 15:56:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2015-09-09 20:18:52 +0000
@@ -678,7 +678,14 @@
       </result>
       <param name="onExceptionReturn">plainTextError</param>
     </action>
-
+    
+  	<action name="getPrograms" class="org.hisp.dhis.commons.action.GetProgramsAction">
+      <result name="success" type="velocity-json">
+        /dhis-web-commons/ajax/jsonPrograms.vm
+      </result>
+      <param name="onExceptionReturn">plainTextError</param>
+    </action>
+    
     <action name="getDataSetsMinified" class="org.hisp.dhis.commons.action.GetDataSetsAction">
       <result name="success" type="velocity-json">
         /dhis-web-commons/ajax/jsonminDataSets.vm

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/DefineProgramUserroleAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/DefineProgramUserroleAction.java	2015-05-13 03:05:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/DefineProgramUserroleAction.java	1970-01-01 00:00:00 +0000
@@ -1,107 +0,0 @@
-package org.hisp.dhis.trackedentity.action.program;
-
-/*
- * Copyright (c) 2004-2015, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramService;
-import org.hisp.dhis.user.UserAuthorityGroup;
-import org.hisp.dhis.user.UserService;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Chau Thu Tran
- * @version DefineProgramUserroleAction.java 12:43:40 PM Feb 19, 2013 $
- */
-public class DefineProgramUserroleAction
-    implements Action
-{// -------------------------------------------------------------------------
-    // Dependency
-    // -------------------------------------------------------------------------
-
-    private ProgramService programService;
-
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-
-    private UserService userService;
-
-    public void setUserService( UserService userService )
-    {
-        this.userService = userService;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private Integer id;
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    private Collection<String> urSelected = new HashSet<>();
-
-    public void setUrSelected( Collection<String> urSelected )
-    {
-        this.urSelected = urSelected;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    public String execute()
-        throws Exception
-    {
-        Program program = programService.getProgram( id );
-
-        Set<UserAuthorityGroup> userAuthorities = new HashSet<>();
-
-        for ( String id : urSelected )
-        {
-            userAuthorities.add( userService.getUserAuthorityGroup( id ) );
-        }
-
-        program.setUserRoles( userAuthorities );
-
-        programService.updateProgram( program );
-
-        return SUCCESS;
-    }
-
-}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml	2015-06-19 10:48:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml	2015-09-09 20:18:52 +0000
@@ -229,14 +229,6 @@
     <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
   </bean>
 
-  <bean
-    id="org.hisp.dhis.trackedentity.action.program.DefineProgramUserroleAction"
-    class="org.hisp.dhis.trackedentity.action.program.DefineProgramUserroleAction"
-    scope="prototype">
-    <property name="userService" ref="org.hisp.dhis.user.UserService" />
-    <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-  </bean>
-
   <!-- Program_OrganisationUnit Association -->
 
   <bean

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties	2015-09-01 14:28:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties	2015-09-09 20:18:52 +0000
@@ -336,7 +336,6 @@
 avg_dataelement_value = Average of data element values
 min_dataelement_value = Minimum of data element values
 max_dataelement_value = Maximum of data element values
-assign_program_to_userroles = Assign program to user roles
 property_is_inserted = Property already exists in form
 please_insert_all_required_fields = Please insert all required fields
 required_fields_valivation = Required fields validation

=== 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-06-19 07:35:50 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml	2015-09-09 20:18:52 +0000
@@ -251,20 +251,6 @@
       <param name="onExceptionReturn">plainTextError</param>
     </action>
 
-    <action name="showProgramUserroleForm"
-      class="org.hisp.dhis.trackedentity.action.program.GetProgramAction">
-      <result name="success" type="velocity">/main.vm</result>
-      <param name="page">/dhis-web-maintenance-program/programUserrole.vm</param>
-      <param name="javascripts">javascript/program.js</param>
-      <param name="stylesheets">style/basic.css</param>
-      <param name="anyAuthorities">F_PROGRAM_PUBLIC_ADD,F_PROGRAM_PRIVATE_ADD</param>
-    </action>
-
-    <action name="defineProgramUserrole"
-      class="org.hisp.dhis.trackedentity.action.program.DefineProgramUserroleAction">
-      <result name="success" type="redirect">program.action</result>
-    </action>
-
     <!-- Program_OrganisationUnit Association -->
 
     <action name="defineProgramAssociationsForm"

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/program.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/program.js	2015-09-02 21:39:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/program.js	2015-09-09 20:18:52 +0000
@@ -13,10 +13,6 @@
   location.href = 'programIndicator.action?programId=' + context.id;
 }
 
-function showProgramUserRoleForm( context ) {
-  location.href = 'showProgramUserroleForm.action?id=' + context.id;
-}
-
 function showUpdateProgramForm( context ) {
   location.href = 'showUpdateProgramForm.action?id=' + context.id;
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programList.vm	2015-08-09 19:19:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programList.vm	2015-09-09 20:18:52 +0000
@@ -7,7 +7,6 @@
     <li data-enabled="canManage"><a data-target-fn="showSharingDialogWithContext"><i class="fa fa-share"></i>&nbsp;&nbsp;$i18n.getString( "sharing_settings" )</a></li>
     <li data-enabled="canUpdate"><a data-target-fn="showUpdateProgramForm"><i class="fa fa-edit"></i>&nbsp;&nbsp;$i18n.getString( "edit" )</a></li>
     <li data-enabled="canUpdate"><a data-target-fn="defineProgramAssociationsForm"><i class="fa fa-plus"></i>&nbsp;&nbsp;$i18n.getString( "assign_program_to_orgunits" )</a></li>
-    <li data-enabled="canUpdate"><a data-target-fn="showProgramUserRoleForm"><i class="fa fa-plus"></i>&nbsp;&nbsp;$i18n.getString( "assign_program_to_userroles" )</a></li>
 	<li data-enabled="canDefinedProgramEntryForm"><a data-target-fn="viewProgramEntryForm"><i class="fa fa-edit"></i>&nbsp;&nbsp;$i18n.getString( "design_custom_registration_form" )</a></li>
     <li data-enabled="canUpdate"><a data-target-fn="programStageManagement"><i class="fa fa-edit"></i>&nbsp;&nbsp;$i18n.getString( "view_program_stages" )</a></li>
     <li data-enabled="canUpdate"><a data-target-fn="programIndicatorManagementForm"><i class="fa fa-edit"></i>&nbsp;&nbsp;$i18n.getString( "view_program_indicators" )</a></li>

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programUserrole.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programUserrole.vm	2015-05-13 03:05:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programUserrole.vm	1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
-<script>
-  $(document).ready(function() {
-    $('#urAvailable').selected({
-      url: '../api/userRoles.json?canIssue=true',
-      target: $('#urSelected'),
-      search: $('#urAvailableSearch'),
-      iterator: 'userRoles'
-    });
-  });
-</script>
-
-<h3>$i18n.getString( "assign_program_to_userroles" )</h3>
-
-<h4>$encoder.htmlEncode($program.displayName)</h4>
-
-<form name="userRole" action="defineProgramUserrole.action" method="POST" onsubmit="$('#urSelected').find('option').attr('selected', 'selected')">
-  <input type="hidden" name="id" value="$program.id"/>
-
-  #jqSelected({
-    "prefix": "ur",
-    "i18n_available": "available",
-    "i18n_selected": "selected",
-    "objects": $!program.userRoles
-  })
-
-  <br>
-  <input type="submit" value="$i18n.getString( 'ok' )" style="width:100px"/>
-  <input type="button" value="$i18n.getString( 'cancel' )" style="width:100px" onclick="window.location = 'program.action'"/>
-</form>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddRoleAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddRoleAction.java	2015-03-11 11:01:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddRoleAction.java	2015-09-09 20:18:52 +0000
@@ -33,8 +33,11 @@
 import org.apache.commons.lang3.StringUtils;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.user.UserAuthorityGroup;
 import org.hisp.dhis.user.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -64,6 +67,9 @@
         this.dataSetService = dataSetService;
     }
 
+    @Autowired
+    private ProgramService programService;
+    
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
@@ -95,12 +101,19 @@
     {
         this.selectedListAuthority = selectedListAuthority;
     }
+    
+	private Collection<String> selectedProgramList = new ArrayList<>();
+
+	public void setSelectedProgramList(Collection<String> selectedProgramList) {
+		this.selectedProgramList = selectedProgramList;
+	}
 
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
-    @Override
+  
+	@Override
     public String execute()
         throws Exception
     {
@@ -115,6 +128,12 @@
             group.getDataSets().add( dataSet );
         }
 
+        for ( String id : selectedProgramList )
+        {
+            Program program = programService.getProgram( id );
+            group.getPrograms().add( program );
+        }
+        
         group.getAuthorities().addAll( selectedListAuthority );
 
         userService.addUserAuthorityGroup( group );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetRoleAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetRoleAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetRoleAction.java	2015-09-09 20:18:52 +0000
@@ -35,9 +35,12 @@
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.security.authority.SystemAuthoritiesProvider;
 import org.hisp.dhis.user.UserAuthorityGroup;
 import org.hisp.dhis.user.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
 
@@ -72,6 +75,9 @@
     {
         this.authoritiesProvider = authoritiesProvider;
     }
+
+    @Autowired
+    private ProgramService programService;
     
     // -------------------------------------------------------------------------
     // Input
@@ -101,15 +107,28 @@
     {
         return availableDataSets;
     }
-
-    private List<DataSet> roleDataSets;
+    
+	private List<DataSet> roleDataSets;
 
     public List<DataSet> getRoleDataSets()
     {
         return roleDataSets;
     }
 
-    private List<String> availableAuthorities;
+    private List<Program> availablePrograms;
+
+    public List<Program> getAvailablePrograms() 
+    {
+		return availablePrograms;
+	}
+
+    private List<Program> rolePrograms;
+    
+    public List<Program> getRolePrograms() {
+		return rolePrograms;
+	}
+
+	private List<String> availableAuthorities;
 
     public List<String> getAvailableAuthorities()
     {
@@ -147,6 +166,18 @@
 
         Collections.sort( roleDataSets, IdentifiableObjectNameComparator.INSTANCE );
 
+        
+        availablePrograms = new ArrayList<>( programService.getAllPrograms() );
+
+        availablePrograms.removeAll( userAuthorityGroup.getPrograms() );
+
+        Collections.sort( availablePrograms, IdentifiableObjectNameComparator.INSTANCE );
+        
+        
+        rolePrograms = new ArrayList<>( userAuthorityGroup.getPrograms() );
+
+        Collections.sort( rolePrograms, IdentifiableObjectNameComparator.INSTANCE );
+
         // ---------------------------------------------------------------------
         // Authorities
         // ---------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateRoleAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateRoleAction.java	2015-03-11 11:01:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateRoleAction.java	2015-09-09 20:18:52 +0000
@@ -33,8 +33,11 @@
 import org.apache.commons.lang3.StringUtils;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.user.UserAuthorityGroup;
 import org.hisp.dhis.user.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -64,6 +67,9 @@
         this.dataSetService = dataSetService;
     }
 
+    @Autowired
+    private ProgramService programService;
+    
     private String message;
 
     public String getMessage()
@@ -109,6 +115,12 @@
     {
         this.selectedListAuthority = selectedListAuthority;
     }
+    
+    private Collection<String> selectedProgramList = new ArrayList<>();
+
+	public void setSelectedProgramList(Collection<String> selectedProgramList) {
+		this.selectedProgramList = selectedProgramList;
+	}
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -124,6 +136,7 @@
         group.setDescription( StringUtils.trimToNull( description ) );
 
         group.getDataSets().clear();
+        group.getPrograms().clear();
         group.getAuthorities().clear();
 
         for ( String id : selectedList )
@@ -132,6 +145,12 @@
             group.getDataSets().add( dataSet );
         }
 
+        for ( String id : selectedProgramList )
+        {
+            Program program = programService.getProgram( id );
+            group.getPrograms().add( program );
+        }
+        
         group.getAuthorities().addAll( selectedListAuthority );
 
         userService.updateUserAuthorityGroup( group );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties	2015-06-23 19:48:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties	2015-09-09 20:18:52 +0000
@@ -382,4 +382,5 @@
 self_registered_users = Self-registered users
 replicate=Replicate
 resend_invitation=Resend invitation
-invitation_sent=Invitation sent
\ No newline at end of file
+invitation_sent=Invitation sent
+programs = Programs
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addRoleForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addRoleForm.vm	2014-03-25 08:01:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addRoleForm.vm	2015-09-09 20:18:52 +0000
@@ -13,6 +13,19 @@
 				return option;
 			}
 		});
+		
+		jQuery("#availableProgramList").dhisAjaxSelect({
+			source: "../dhis-web-commons-ajax-json/getPrograms.action",
+			iterator: 'programs',
+			connectedTo: 'selectedProgramList',
+			handler: function(item) {
+				var option = jQuery("<option />");
+				option.text( item.name );
+				option.attr( "value", item.id );
+
+				return option;
+			}
+		});
 
 		jQuery("#availableListAuthority").dhisAjaxSelect({
 			source: "getSystemAuthorities.action",
@@ -81,6 +94,24 @@
 			<select id="selectedList" name="selectedList" multiple="multiple" style="height: 200px; width: 100%; margin-top: 22px;"></select>
         </td>
 	</tr>
+	
+	<tr>
+		<td><label>$i18n.getString( "programs" )</label></td>		
+		<td>
+          <select id="availableProgramList" name="availableProgramList" multiple="multiple" style="height: 200px; width: 100%;"></select>
+        </td>
+
+        <td style="text-align:center">
+        	<input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'availableProgramList' );"/><br/>
+            <input type="button" value="&lt;" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'selectedProgramList' );"/><br/>
+			<input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'availableProgramList' );"/><br/>
+			<input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'selectedProgramList' );"/>
+        </td>
+
+		<td>
+			<select id="selectedProgramList" name="selectedProgramList" multiple="multiple" style="height: 200px; width: 100%; margin-top: 22px;"></select>
+        </td>
+	</tr>
 		
 	<tr>
 		<td><label>$i18n.getString( "authorities" )</label></td>		

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allRole.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allRole.vm	2014-06-13 08:08:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allRole.vm	2015-09-09 20:18:52 +0000
@@ -60,6 +60,7 @@
         <p><label>$i18n.getString( "name" ):</label><br/><span id="nameField"></span></p>
         <p><label>$i18n.getString( "members" ):</label><br/><span id="membersField"></span></p>
         <p><label>$i18n.getString( "data_sets" ):</label><br/><span id="dataSetsField"></span></p>
+        <p><label>$i18n.getString( "programs" ):</label><br/><span id="programssField"></span></p>
         <p><label>$i18n.getString( "id" ):</label><br/><span id="idField"></span></p>
       </div>
 			

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/role.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/role.js	2014-06-13 08:08:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/role.js	2015-09-09 20:18:52 +0000
@@ -7,6 +7,7 @@
     setInnerHTML('nameField', json.userRole.name);
     setInnerHTML('membersField', json.userRole.members);
     setInnerHTML('dataSetsField', json.userRole.dataSets);
+    setInnerHTML('programsField', json.userRole.programs);
     setInnerHTML('idField', json.userRole.uid);
 
     showDetails();

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateRoleForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateRoleForm.js	2011-04-11 11:16:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateRoleForm.js	2015-09-09 20:18:52 +0000
@@ -5,6 +5,7 @@
 	validation2( 'updateRoleForm', function( form )
 	{
 		selectAllById( 'selectedList' );
+		selectAllById( 'selectedProgramList' );
 		selectAllById( 'selectedListAuthority' );
 		form.submit();
 	}, {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateRoleForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateRoleForm.vm	2014-12-16 11:22:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateRoleForm.vm	2015-09-09 20:18:52 +0000
@@ -14,6 +14,20 @@
 			}
 		});
 
+		
+		jQuery("#availableProgramList").dhisAjaxSelect({
+			source: "../dhis-web-commons-ajax-json/getPrograms.action",
+			iterator: 'programs',
+			connectedTo: 'selectedProgramList',
+			handler: function(item) {
+				var option = jQuery("<option />");
+				option.text( item.name );
+				option.attr( "value", item.id );
+
+				return option;
+			}
+		});
+		
 		jQuery("#availableListAuthority").dhisAjaxSelect({
 			source: "getSystemAuthorities.action",
 			iterator: 'systemAuthorities',
@@ -21,7 +35,7 @@
 			handler: function(item) {
 				var option = jQuery("<option />");
 				option.text( item.name );
-        option.attr( "value", item.id );
+				option.attr( "value", item.id );
 
 				return option;
 			}
@@ -88,6 +102,28 @@
 		</tr>
 		
 		<tr>
+			<td><label>$i18n.getString( "programs" )</label></td>		
+			<td>
+			  <select id="availableProgramList" name="availableProgramList" multiple="multiple" style="height: 200px; width: 100%;"></select>
+			</td>
+
+			<td style="text-align:center">
+				<input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'availableProgramList' );"/><br/>
+				<input type="button" value="&lt;" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'selectedProgramList' );"/><br/>
+				<input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'availableProgramList' );"/><br/>
+				<input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'selectedProgramList' );"/>
+			</td>
+
+			<td>
+				<select id="selectedProgramList" name="selectedProgramList" multiple="multiple" style="height: 200px; width: 100%; margin-top: 22px;">
+				#foreach ( $selectedProgram in $rolePrograms )
+					<option value="$selectedProgram.uid">$encoder.htmlEncode( $selectedProgram.name )</option>
+            	#end
+				</select>
+			</td>
+		</tr>
+		
+		<tr>
 			<td><label>$i18n.getString( "authorities" )</label></td>
 
 			<td>