=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java 2012-11-05 10:43:15 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java 2012-11-13 12:14:21 +0000 @@ -158,34 +158,27 @@ } UserAccount userAccount = new UserAccount(); + + // user account userAccount.setFirstName( currentUser.getFirstName() ); userAccount.setSurname( currentUser.getSurname() ); userAccount.setEmail( currentUser.getEmail() ); userAccount.setPhoneNumber( currentUser.getPhoneNumber() ); + // profile + userAccount.setIntroduction( currentUser.getIntroduction() ); + userAccount.setJobTitle( currentUser.getJobTitle() ); + userAccount.setGender( currentUser.getGender() ); + // currentUser.setBirthday( currentUser.getBirthday() ); + userAccount.setNationality( currentUser.getNationality() ); + userAccount.setEmployer( currentUser.getEmployer() ); + userAccount.setEducation( currentUser.getEducation() ); + userAccount.setInterests( currentUser.getInterests() ); + userAccount.setLanguages( currentUser.getLanguages() ); + JacksonUtils.toJson( response.getOutputStream(), userAccount ); } - @RequestMapping( value = "/user-account", method = RequestMethod.POST, consumes = "application/xml" ) - public void postUserAccountXml( HttpServletResponse response, HttpServletRequest request ) throws Exception - { - UserAccount userAccount = JacksonUtils.fromXml( request.getInputStream(), UserAccount.class ); - User currentUser = currentUserService.getCurrentUser(); - - if ( currentUser == null ) - { - ContextUtils.notFoundResponse( response, "User object is null, user is not authenticated." ); - return; - } - - currentUser.setFirstName( userAccount.getFirstName() ); - currentUser.setSurname( userAccount.getSurname() ); - currentUser.setEmail( userAccount.getEmail() ); - currentUser.setPhoneNumber( userAccount.getPhoneNumber() ); - - userService.updateUser( currentUser ); - } - @RequestMapping( value = "/user-account", method = RequestMethod.POST, consumes = "application/json" ) public void postUserAccountJson( HttpServletResponse response, HttpServletRequest request ) throws Exception { @@ -198,11 +191,23 @@ return; } + // basic user account currentUser.setFirstName( userAccount.getFirstName() ); currentUser.setSurname( userAccount.getSurname() ); currentUser.setEmail( userAccount.getEmail() ); currentUser.setPhoneNumber( userAccount.getPhoneNumber() ); + // profile + currentUser.setIntroduction( userAccount.getIntroduction() ); + currentUser.setJobTitle( userAccount.getJobTitle() ); + currentUser.setGender( userAccount.getGender() ); + // currentUser.setBirthday( userAccount.getBirthday() ); + currentUser.setNationality( userAccount.getNationality() ); + currentUser.setEmployer( userAccount.getEmployer() ); + currentUser.setEducation( userAccount.getEducation() ); + currentUser.setInterests( userAccount.getInterests() ); + currentUser.setLanguages( userAccount.getLanguages() ); + userService.updateUser( currentUser ); } @@ -244,7 +249,7 @@ Forms forms = new Forms(); Set organisationUnits = new HashSet(); - Set userDataSets = null; + Set userDataSets; Set userOrganisationUnits = new HashSet( currentUser.getOrganisationUnits() ); if ( currentUser.getUserCredentials().getAllAuthorities().contains( "ALL" ) ) === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/user/UserAccount.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/user/UserAccount.java 2012-10-30 11:56:01 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/user/UserAccount.java 2012-11-13 12:14:21 +0000 @@ -27,18 +27,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import org.hisp.dhis.common.Dxf2Namespace; - import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** * @author Morten Olav Hansen */ -@JacksonXmlRootElement( localName = "settings", namespace = Dxf2Namespace.NAMESPACE ) public class UserAccount { + // user account private String firstName; private String surname; @@ -47,12 +43,30 @@ private String phoneNumber; + // profile + private String introduction; + + private String jobTitle; + + private String gender; + + private String birthday; + + private String nationality; + + private String employer; + + private String education; + + private String interests; + + private String languages; + public UserAccount() { } - @JsonProperty(required = true) - @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE) + @JsonProperty( required = true ) public String getFirstName() { return firstName; @@ -63,8 +77,7 @@ this.firstName = firstName; } - @JsonProperty(required = true) - @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE) + @JsonProperty( required = true ) public String getSurname() { return surname; @@ -76,7 +89,6 @@ } @JsonProperty - @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE) public String getEmail() { return email; @@ -88,7 +100,6 @@ } @JsonProperty - @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE) public String getPhoneNumber() { return phoneNumber; @@ -98,4 +109,103 @@ { this.phoneNumber = phoneNumber; } + + @JsonProperty + public String getIntroduction() + { + return introduction; + } + + public void setIntroduction( String introduction ) + { + this.introduction = introduction; + } + + @JsonProperty + public String getJobTitle() + { + return jobTitle; + } + + public void setJobTitle( String jobTitle ) + { + this.jobTitle = jobTitle; + } + + @JsonProperty + public String getGender() + { + return gender; + } + + public void setGender( String gender ) + { + this.gender = gender; + } + + @JsonProperty + public String getBirthday() + { + return birthday; + } + + public void setBirthday( String birthday ) + { + this.birthday = birthday; + } + + @JsonProperty + public String getNationality() + { + return nationality; + } + + public void setNationality( String nationality ) + { + this.nationality = nationality; + } + + @JsonProperty + public String getEmployer() + { + return employer; + } + + public void setEmployer( String employer ) + { + this.employer = employer; + } + + @JsonProperty + public String getEducation() + { + return education; + } + + public void setEducation( String education ) + { + this.education = education; + } + + @JsonProperty + public String getInterests() + { + return interests; + } + + public void setInterests( String interests ) + { + this.interests = interests; + } + + @JsonProperty + public String getLanguages() + { + return languages; + } + + public void setLanguages( String languages ) + { + this.languages = languages; + } } === modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/base.vm' --- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/base.vm 2012-10-30 15:57:06 +0000 +++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/base.vm 2012-11-13 12:14:21 +0000 @@ -1,6 +1,6 @@ - - + + DHIS2 === modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/user-account.vm' --- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/user-account.vm 2012-10-30 14:02:06 +0000 +++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/user-account.vm 2012-11-13 12:14:21 +0000 @@ -4,13 +4,31 @@ $.mobile.loading( 'show' ); $.ajax({ - url: '../api/currentUser', + url: '../api/currentUser/user-account', dataType: 'json' }).success(function(data) { + // user account $('#firstNameInput').val(data.firstName); $('#surnameInput').val(data.surname); $('#emailInput').val(data.email); $('#phoneNumberInput').val(data.phoneNumber); + + // profile + $('#introductionInput').val(data.introduction); + $('#jobTitleInput').val(data.jobTitle); + + $('#genderInput').children().each(function ( idx, item ) { + item.selected = item.value == data.gender; + }); + + $('#genderInput').selectmenu('refresh') + + // $('#birthdayInput').val(data.birthday); + $('#nationalityInput').val(data.nationality); + $('#employerInput').val(data.employer); + $('#educationInput').val(data.education); + $('#interestsInput').val(data.interests); + $('#languagesInput').val(data.languages); }).complete(function() { $.mobile.loading( 'hide' ); }); @@ -26,7 +44,7 @@ $.mobile.loading( 'show' ); $.ajax({ - url: '../api/currentUser/user-account.json', + url: '../api/currentUser/user-account', contentType: 'application/json', data: JSON.stringify( settings ), type: 'POST' @@ -48,21 +66,59 @@
-
- - - - - - - - - - - - - -
+
+
    +
  • User Account
  • +
  • + + + + + + + + + + + +
  • +
  • Profile
  • +
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • +
+