← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5395: converted user to idObject

 

------------------------------------------------------------
revno: 5395
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-12-13 19:41:43 +0100
message:
  converted user to idObject
removed:
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/users.xsl
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/UserXmlAdapter.java
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/user.xsl
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/Users.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl


--
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/common/BaseIdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java	2011-12-13 15:44:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java	2011-12-13 18:41:43 +0000
@@ -58,7 +58,7 @@
     protected int id;
 
     /**
-     * The Unique Identifer for this Object.
+     * The Unique Identifier for this Object.
      */
     protected String uid;
 

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/UserXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/UserXmlAdapter.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/UserXmlAdapter.java	2011-12-13 18:41:43 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.user.User;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class UserXmlAdapter extends XmlAdapter<BaseIdentifiableObject, User>
+{
+    private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+    @Override
+    public User unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+    {
+        User user = new User();
+
+        user.setUid( identifiableObject.getUid() );
+        user.setLastUpdated( identifiableObject.getLastUpdated() );
+        user.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+        return user;
+    }
+
+    @Override
+    public BaseIdentifiableObject marshal( User user ) throws Exception
+    {
+        return baseIdentifiableObjectXmlAdapter.marshal( user );
+    }
+}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java	2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java	2011-12-13 18:41:43 +0000
@@ -39,7 +39,6 @@
 
 import javax.xml.bind.annotation.*;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import java.io.Serializable;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
@@ -51,15 +50,13 @@
 @XmlRootElement( name = "user", namespace = Dxf2Namespace.NAMESPACE )
 @XmlAccessorType( value = XmlAccessType.NONE )
 public class User
-    implements Serializable
+    extends BaseIdentifiableObject
 {
     /**
      * Determines if a de-serialized file is compatible with this class.
      */
     private static final long serialVersionUID = 859837727604102353L;
 
-    private int id;
-
     /**
      * Required.
      */
@@ -168,8 +165,14 @@
     /**
      * Returns the concatenated first name and surname.
      */
+    @Override
     public String getName()
     {
+        if ( userCredentials != null )
+        {
+            return userCredentials.getUsername();
+        }
+
         return firstName + " " + surname;
     }
 
@@ -205,16 +208,6 @@
     // Getters and setters
     // -------------------------------------------------------------------------
 
-    public int getId()
-    {
-        return id;
-    }
-
-    public void setId( int id )
-    {
-        this.id = id;
-    }
-
     @XmlElement
     @JsonProperty
     public String getFirstName()

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java	2011-10-03 10:33:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java	2011-12-13 18:41:43 +0000
@@ -1,12 +1,12 @@
 package org.hisp.dhis.user;
 
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.Map;
 
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-
 /*
  * Copyright (c) 2004-2010, University of Oslo
  * All rights reserved.
@@ -56,7 +56,7 @@
 
     /**
      * Adds a User.
-     * 
+     *
      * @param user the User to add.
      * @return the generated identifier.
      */
@@ -64,22 +64,30 @@
 
     /**
      * Updates a User.
-     * 
+     *
      * @param user the User to update.
      */
     void updateUser( User user );
 
     /**
      * Retrieves the User with the given identifier.
-     * 
-     * @param idn the identifier of the User to retrieve.
+     *
+     * @param id the identifier of the User to retrieve.
      * @return the User.
      */
     User getUser( int id );
 
     /**
+     * Retrieves the User with the given unique identifier.
+     *
+     * @param id the identifier of the User to retrieve.
+     * @return the User.
+     */
+    User getUser( String uid );
+
+    /**
      * Returns a Collection of all Users.
-     * 
+     *
      * @return a Collection of Users.
      */
     Collection<User> getAllUsers();
@@ -87,14 +95,14 @@
     /**
      * Returns a Collection of the Users which are not associated with any
      * OrganisationUnits.
-     * 
+     *
      * @return a Collection of Users.
      */
     Collection<User> getUsersWithoutOrganisationUnit();
 
     /**
      * Returns a Collection of Users which are having given Phone number.
-     * 
+     *
      * @param phoneNumber
      * @return a Collection of Users.
      */
@@ -102,7 +110,7 @@
 
     /**
      * Deletes a User.
-     * 
+     *
      * @param user the User to delete.
      */
     void deleteUser( User user );
@@ -125,7 +133,7 @@
 
     /**
      * Adds a UserCredentials.
-     * 
+     *
      * @param userCredentials the UserCredentials to add.
      * @return the User which the UserCredentials is associated with.
      */
@@ -133,14 +141,14 @@
 
     /**
      * Updates a UserCredentials.
-     * 
+     *
      * @param userCredentials the UserCredentials to update.
      */
     void updateUserCredentials( UserCredentials userCredentials );
 
     /**
      * Retrieves the UserCredentials of the given User.
-     * 
+     *
      * @param user the User.
      * @return the UserCredentials.
      */
@@ -149,7 +157,7 @@
     /**
      * Retrieves the UserCredentials associated with the User with the given
      * name.
-     * 
+     *
      * @param username the name of the User.
      * @return the UserCredentials.
      */
@@ -157,7 +165,7 @@
 
     /**
      * Retrieves all UserCredentials.
-     * 
+     *
      * @return a Collection of UserCredentials.
      */
     Collection<UserCredentials> getAllUserCredentials();
@@ -165,26 +173,26 @@
     /**
      * Updates the last login date of UserCredentials with the given username
      * with the current date.
-     *   
+     *
      * @param username the username of the UserCredentials.
      */
     void setLastLogin( String username );
-    
+
     /**
      * Deletes a UserCredentials.
-     * 
+     *
      * @param userCredentials the UserCredentials.
      */
     void deleteUserCredentials( UserCredentials userCredentials );
 
     /**
      * Get the UserCredentials with the corresponding identifiers.
-     * 
+     *
      * @param identifiers the collection of identifiers.
      * @return a collection of users.
      */
     Collection<UserCredentials> getUsers( Collection<Integer> identifiers, User user );
-    
+
     Collection<UserCredentials> searchUsersByName( String key );
 
     Collection<UserCredentials> getUsersBetween( int first, int max );
@@ -198,23 +206,23 @@
     Collection<UserCredentials> getUsersByOrganisationUnitBetween( OrganisationUnit orgUnit, int first, int max );
 
     Collection<UserCredentials> getUsersByOrganisationUnitBetweenByName( OrganisationUnit orgUnit, String name,
-        int first, int max );
-    
+                                                                         int first, int max );
+
     Collection<UserCredentials> getInactiveUsers( int months );
-    
+
     Collection<UserCredentials> getInactiveUsers( int months, int first, int max );
-    
+
     int getInactiveUsersCount( int months );
 
     int getActiveUsersCount( int days );
-    
+
     // -------------------------------------------------------------------------
     // UserAuthorityGroup
     // -------------------------------------------------------------------------
 
     /**
      * Adds a UserAuthorityGroup.
-     * 
+     *
      * @param userAuthorityGroup the UserAuthorityGroup.
      * @return the generated identifier.
      */
@@ -222,14 +230,15 @@
 
     /**
      * Updates a UserAuthorityGroup.
-     * 
+     *
      * @param userAuthorityGroup the UserAuthorityGroup.
      */
     void updateUserAuthorityGroup( UserAuthorityGroup userAuthorityGroup );
 
-    /**2
+    /**
+     * 2
      * Retrieves the UserAuthorityGroup with the given identifier.
-     * 
+     *
      * @param id the identifier of the UserAuthorityGroup to retrieve.
      * @return the UserAuthorityGroup.
      */
@@ -237,7 +246,7 @@
 
     /**
      * Retrieves the UserAuthorityGroup with the given name.
-     * 
+     *
      * @param name the name of the UserAuthorityGroup to retrieve.
      * @return the UserAuthorityGroup.
      */
@@ -245,28 +254,28 @@
 
     /**
      * Deletes a UserAuthorityGroup.
-     * 
+     *
      * @param userAuthorityGroup the UserAuthorityGroup to delete.
      */
     void deleteUserAuthorityGroup( UserAuthorityGroup userAuthorityGroup );
 
     /**
      * Retrieves all UserAuthorityGroups.
-     * 
+     *
      * @return a Collectio of UserAuthorityGroups.
      */
     Collection<UserAuthorityGroup> getAllUserAuthorityGroups();
 
     /**
      * Retrieves all UserAuthorityGroups.
-     * 
+     *
      * @return a Collectio of UserAuthorityGroups.
      */
     Collection<UserAuthorityGroup> getUserRolesBetween( int first, int max );
 
     /**
      * Retrieves all UserAuthorityGroups.
-     * 
+     *
      * @return a Collectio of UserAuthorityGroups.
      */
     Collection<UserAuthorityGroup> getUserRolesBetweenByName( String name, int first, int max );
@@ -276,21 +285,21 @@
     int getUserRoleCount();
 
     int getUserRoleCountByName( String name );
-    
+
     // -------------------------------------------------------------------------
     // UserSettings
     // -------------------------------------------------------------------------
 
     /**
      * Adds a UserSetting.
-     * 
+     *
      * @param userSetting the UserSetting to add.
      */
     void addUserSetting( UserSetting userSetting );
 
     /**
      * Updates a UserSetting.
-     * 
+     *
      * @param userSetting the UserSetting to update.
      */
     void updateUserSetting( UserSetting userSetting );
@@ -298,7 +307,7 @@
     /**
      * Retrieves the UserSetting associated with the given User for the given
      * UserSetting name.
-     * 
+     *
      * @param user the User.
      * @param name the name of the UserSetting.
      * @return the UserSetting.
@@ -307,7 +316,7 @@
 
     /**
      * Retrieves all UserSettings for the given User.
-     * 
+     *
      * @param user the User.
      * @return a Collection of UserSettings.
      */
@@ -315,7 +324,7 @@
 
     /**
      * Deletes a UserSetting.
-     * 
+     *
      * @param userSetting the UserSetting to delete.
      */
     void deleteUserSetting( UserSetting userSetting );
@@ -323,10 +332,10 @@
     /**
      * Returns a Map with an entry for all UserSettings with the given name where
      * the key is the user and the value is the value of the user setting.
-     * 
-     * @param name the name of the UserSetting.
-     * @param defaultValue the value to return if the UserSetting value is null.  
+     *
+     * @param name         the name of the UserSetting.
+     * @param defaultValue the value to return if the UserSetting value is null.
      * @return a Map.
      */
-    Map<User,Serializable> getUserSettings( String name, Serializable defaultValue );
+    Map<User, Serializable> getUserSettings( String name, Serializable defaultValue );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java	2011-10-03 10:33:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java	2011-12-13 18:41:43 +0000
@@ -61,13 +61,21 @@
 
     /**
      * Retrieves the User with the given identifier.
-     * 
-     * @param idn the identifier of the User to retrieve.
+     *
+     * @param id the identifier of the User to retrieve.
      * @return the User.
      */
     User getUser( int id );
 
     /**
+     * Retrieves the User with the given unique identifier.
+     *
+     * @param id the identifier of the User to retrieve.
+     * @return the User.
+     */
+    User getUser( String uid );
+
+    /**
      * Returns a Collection of all Users.
      * 
      * @return a Collection of Users.

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/Users.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/Users.java	2011-12-03 14:31:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/Users.java	2011-12-13 18:41:43 +0000
@@ -28,13 +28,17 @@
  */
 
 import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.BaseLinkableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.adapter.UserXmlAdapter;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -48,7 +52,9 @@
     private List<User> users = new ArrayList<User>();
 
     @XmlElement( name = "user" )
+    @XmlJavaTypeAdapter( UserXmlAdapter.class )
     @JsonProperty( value = "users" )
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
     public List<User> getUsers()
     {
         return users;

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java	2011-12-13 16:29:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java	2011-12-13 18:41:43 +0000
@@ -53,7 +53,7 @@
         "indicatorgroup", "datadictionary", "validationrulegroup", "validationrule", "dataset", "orgunitlevel", "document",
         "organisationunit", "orgunitgroup", "orgunitgroupset", "dataelementcategoryoption", "dataelementgroup", "sqlview",
         "dataelement", "dataelementgroupset", "dataelementcategory", "categorycombo", "categoryoptioncombo", "mapview", 
-        "reporttable", "report", "messageconversation" };
+        "reporttable", "report", "messageconversation", "userinfo" };
 
     // -------------------------------------------------------------------------
     // Dependencies

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java	2011-10-03 10:33:46 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java	2011-12-13 18:41:43 +0000
@@ -1,12 +1,5 @@
 package org.hisp.dhis.user;
 
-import java.io.Serializable;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
@@ -19,6 +12,9 @@
 import org.hisp.dhis.system.util.FilterUtils;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.Serializable;
+import java.util.*;
+
 /*
  * Copyright (c) 2004-2010, University of Oslo
  * All rights reserved.
@@ -181,6 +177,11 @@
         return userStore.getUser( userId );
     }
 
+    public User getUser( String uid )
+    {
+        return userStore.getUser( uid );
+    }
+
     public int getUserCount()
     {
         return userStore.getUserCount();
@@ -213,7 +214,7 @@
     }
 
     public Collection<UserCredentials> getUsersByOrganisationUnitBetweenByName( OrganisationUnit unit, String userName,
-        int first, int max )
+                                                                                int first, int max )
     {
         return userStore.getUsersByOrganisationUnitBetweenByName( unit, userName, first, max );
     }
@@ -389,7 +390,7 @@
     {
         Calendar cal = PeriodType.createCalendarInstance();
         cal.add( Calendar.MONTH, (months * -1) );
-        
+
         return userStore.getInactiveUsers( cal.getTime() );
     }
 
@@ -445,16 +446,16 @@
     {
         return userStore.getUserSetting( user, name );
     }
-    
-    public Map<User,Serializable> getUserSettings( String name, Serializable defaultValue )
+
+    public Map<User, Serializable> getUserSettings( String name, Serializable defaultValue )
     {
-        Map<User,Serializable> map = new HashMap<User, Serializable>();
-        
+        Map<User, Serializable> map = new HashMap<User, Serializable>();
+
         for ( UserSetting setting : userStore.getUserSettings( name ) )
         {
             map.put( setting.getUser(), setting.getValue() != null ? setting.getValue() : defaultValue );
         }
-        
+
         return map;
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java	2011-10-06 15:39:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java	2011-12-13 18:41:43 +0000
@@ -27,12 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
 import org.hibernate.Criteria;
 import org.hibernate.Query;
 import org.hibernate.Session;
@@ -41,11 +35,9 @@
 import org.hibernate.criterion.Projections;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.user.User;
-import org.hisp.dhis.user.UserAuthorityGroup;
-import org.hisp.dhis.user.UserCredentials;
-import org.hisp.dhis.user.UserSetting;
-import org.hisp.dhis.user.UserStore;
+import org.hisp.dhis.user.*;
+
+import java.util.*;
 
 /**
  * @author Nguyen Hong Duc
@@ -90,6 +82,16 @@
         return (User) session.get( User.class, id );
     }
 
+    public User getUser( String uid )
+    {
+        Session session = sessionFactory.getCurrentSession();
+
+        Criteria criteria = session.createCriteria( User.class );
+        criteria.add( Restrictions.like( "uid", uid ) );
+
+        return (User) criteria.uniqueResult();
+    }
+
     @SuppressWarnings( "unchecked" )
     public Collection<User> getAllUsers()
     {
@@ -256,7 +258,7 @@
     }
 
     public Collection<UserCredentials> getUsersByOrganisationUnitBetweenByName( OrganisationUnit orgUnit, String name,
-        int first, int max )
+                                                                                int first, int max )
     {
         return getBlockUser( findByName( toUserCredentials( orgUnit.getUsers() ), name ), first, max );
     }
@@ -332,7 +334,7 @@
 
         return rs != null ? rs.intValue() : 0;
     }
-    
+
     // -------------------------------------------------------------------------
     // UserAuthorityGroup
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml	2011-09-21 14:43:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml	2011-12-13 18:41:43 +0000
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <!DOCTYPE hibernate-mapping PUBLIC
-  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";>
+    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+    "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";>
 
 <hibernate-mapping>
   <class name="org.hisp.dhis.user.User" lazy="false" table="userinfo">
@@ -12,6 +12,12 @@
       <generator class="native" />
     </id>
 
+    <property name="uid" column="uid" length="11" />
+
+    <property name="code" column="code" not-null="false" unique="true" length="50" />
+
+    <property name="lastUpdated" type="timestamp" />
+
     <property name="surname" not-null="true" length="160" />
 
     <property name="firstName" not-null="true" length="160" />
@@ -20,10 +26,10 @@
 
     <property name="phoneNumber" length="80" />
 
-	<one-to-one name="userCredentials" class="org.hisp.dhis.user.UserCredentials" foreign-key="fk_userinfo_userid"/>
+    <one-to-one name="userCredentials" class="org.hisp.dhis.user.UserCredentials" foreign-key="fk_userinfo_userid" />
 
-    <set name="organisationUnits" table="usermembership">      
-      <cache usage="read-write" />      
+    <set name="organisationUnits" table="usermembership">
+      <cache usage="read-write" />
       <key column="userinfoid" foreign-key="fk_usermembership_userinfoid" />
       <many-to-many class="org.hisp.dhis.organisationunit.OrganisationUnit" column="organisationunitid"
         foreign-key="fk_userinfo_organisationunitid" />
@@ -35,7 +41,7 @@
       <cache usage="read-write" />
       <key column="userinfoid" />
       <many-to-many class="org.hisp.dhis.attribute.AttributeValue" column="attributevalueid" unique="true" />
-  </set>
+    </set>
 
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java	2011-12-12 11:37:04 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java	2011-12-13 18:41:43 +0000
@@ -80,10 +80,10 @@
         return "users";
     }
 
-    @RequestMapping( value = "/{id}", method = RequestMethod.GET )
-    public String getUser( @PathVariable( "id" ) Integer id, IdentifiableObjectParams params, Model model, HttpServletRequest request )
+    @RequestMapping( value = "/{uid}", method = RequestMethod.GET )
+    public String getUser( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
     {
-        User user = userService.getUser( id );
+        User user = userService.getUser( uid );
 
         if ( params.hasLinks() )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java	2011-12-13 14:04:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java	2011-12-13 18:41:43 +0000
@@ -53,6 +53,8 @@
 import org.hisp.dhis.report.Reports;
 import org.hisp.dhis.sqlview.SqlView;
 import org.hisp.dhis.sqlview.SqlViews;
+import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.Users;
 import org.hisp.dhis.validation.ValidationRule;
 import org.hisp.dhis.validation.ValidationRuleGroup;
 import org.hisp.dhis.validation.ValidationRuleGroups;
@@ -299,6 +301,37 @@
         {
             populateReport( (Report) source, true );
         }
+        else if ( source instanceof Users )
+        {
+            populateUsers( (Users) source, true );
+        }
+        else if ( source instanceof User )
+        {
+            populateUser( (User) source, true );
+        }
+    }
+
+    private void populateUsers( Users users, boolean root )
+    {
+        users.setLink( getBasePath( users.getClass() ) );
+
+        if ( root )
+        {
+            for ( User user : users.getUsers() )
+            {
+                populateUser( user, false );
+            }
+        }
+    }
+
+    private void populateUser( User user, boolean root )
+    {
+        populateIdentifiableObject( user );
+
+        if ( root )
+        {
+            handleIdentifiableObjectCollection( user.getOrganisationUnits() );
+        }
     }
 
     private void populateSqlViews( SqlViews sqlViews, boolean root )
@@ -881,11 +914,11 @@
             }
         }
     }
-    
+
     private void populateReports( Reports reports, boolean root )
     {
         reports.setLink( getBasePath( Report.class ) );
-        
+
         if ( root )
         {
             for ( Report report : reports.getReports() )
@@ -894,11 +927,11 @@
             }
         }
     }
-    
+
     private void populateReport( Report report, boolean root )
     {
         report.setLink( getPathWithUid( report ) );
-        
+
         if ( root )
         {
         }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl	2011-12-13 17:44:28 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl	2011-12-13 18:41:43 +0000
@@ -12,7 +12,7 @@
     d:organisationUnits|d:dataElementGroups|d:dataElementGroupSets|
     d:indicatorGroups|d:indicatorGroupSets|d:organisationUnitGroups|
     d:organisationUnitGroupSets|d:indicatorTypes|d:attributeTypes|d:reports|
-    d:sqlViews|d:validationRules|d:validationRuleGroups">
+    d:sqlViews|d:validationRules|d:validationRuleGroups|d:users">
     <h3> <xsl:value-of select="local-name()"/> </h3>
 
     <table border="1">

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl	2011-12-13 17:44:28 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl	2011-12-13 18:41:43 +0000
@@ -39,6 +39,7 @@
     <xsl:include href="validationRule.xsl"/>
     <xsl:include href="validationRuleGroup.xsl"/>
     <xsl:include href="sqlView.xsl"/>
+    <xsl:include href="user.xsl"/>
     <!-- etc ... -->
 
 </xsl:stylesheet>

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/user.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/user.xsl	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/user.xsl	2011-12-13 18:41:43 +0000
@@ -0,0 +1,51 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0"
+                xmlns="http://www.w3.org/1999/xhtml";
+                xmlns:d="http://dhis2.org/schema/dxf/2.0";
+    >
+
+  <xsl:template match="d:user">
+    <div class="user">
+      <h2>
+        <xsl:value-of select="@name" />
+      </h2>
+      <table border="1">
+        <tr>
+          <td>ID</td>
+          <td> <xsl:value-of select="@id" /> </td>
+        </tr>
+        <tr>
+          <td>Last Updated</td>
+          <td> <xsl:value-of select="@lastUpdated" /> </td>
+        </tr>
+        <tr>
+          <td>First Name</td>
+          <td> <xsl:value-of select="d:firstName" /> </td>
+        </tr>
+        <tr>
+          <td>Surname</td>
+          <td> <xsl:value-of select="d:surname" /> </td>
+        </tr>
+        <tr>
+          <td>EMail</td>
+          <td> <xsl:value-of select="d:email" /> </td>
+        </tr>
+        <tr>
+          <td>PhoneNumber</td>
+          <td> <xsl:value-of select="d:phoneNumber" /> </td>
+        </tr>
+      </table>
+
+      <xsl:apply-templates select="d:organisationUnits" mode="short" />
+    </div>
+  </xsl:template>
+
+  <xsl:template match="d:users" mode="short">
+    <xsl:if test="count(child::*) > 0">
+      <h3>Users</h3>
+      <table border="1" class="users">
+        <xsl:apply-templates select="child::*" mode="row"/>
+      </table>
+    </xsl:if>
+  </xsl:template>
+
+</xsl:stylesheet>

=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/users.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/users.xsl	2011-12-07 14:04:35 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/users.xsl	1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0"
-                xmlns="http://www.w3.org/1999/xhtml";
-                xmlns:d="http://dhis2.org/schema/dxf/2.0";
-    >
-  <xsl:include href="identifiable-row.xsl" />
-  <xsl:include href="html-wrapper.xsl" />
-  <xsl:include href="list.xsl" />
-
-  <xsl:param name="title">Users</xsl:param>
-  <xsl:param name="elements">users</xsl:param>
-
-  <xsl:template match="d:user">
-    <xsl:apply-templates />
-  </xsl:template>
-</xsl:stylesheet>