← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6412: added more user* related web-api rendering

 

------------------------------------------------------------
revno: 6412
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-03-28 11:29:38 +0200
message:
  added more user* related web-api rendering
added:
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/userAuthorityGroup.xsl
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/userCredentials.xsl
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.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
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/user.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/user/UserCredentials.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java	2012-03-19 16:35:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java	2012-03-28 09:29:38 +0000
@@ -245,7 +245,7 @@
 
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public String getPassword()
     {
         return password;
@@ -269,8 +269,8 @@
     @JsonProperty
     @JsonSerialize( contentAs = BaseIdentifiableObject.class )
     @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlElementWrapper( localName = "userAuthorityGroups" )
-    @JacksonXmlProperty( localName = "userAuthorityGroup" )
+    @JacksonXmlElementWrapper( localName = "userAuthorityGroups", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "userAuthorityGroup", namespace = Dxf2Namespace.NAMESPACE )
     public Set<UserAuthorityGroup> getUserAuthorityGroups()
     {
         return userAuthorityGroups;
@@ -283,7 +283,7 @@
 
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public String getUsername()
     {
         return username;

=== 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	2012-03-27 17:38:48 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java	2012-03-28 09:29:38 +0000
@@ -54,10 +54,7 @@
 import org.hisp.dhis.reporttable.ReportTables;
 import org.hisp.dhis.sqlview.SqlView;
 import org.hisp.dhis.sqlview.SqlViews;
-import org.hisp.dhis.user.User;
-import org.hisp.dhis.user.UserGroup;
-import org.hisp.dhis.user.UserGroups;
-import org.hisp.dhis.user.Users;
+import org.hisp.dhis.user.*;
 import org.hisp.dhis.validation.ValidationRule;
 import org.hisp.dhis.validation.ValidationRuleGroup;
 import org.hisp.dhis.validation.ValidationRuleGroups;
@@ -336,6 +333,14 @@
         {
             populateUserGroup( (UserGroup) source, true );
         }
+        else if ( source instanceof UserAuthorityGroups )
+        {
+            populateUserAuthorityGroups( (UserAuthorityGroups) source, true );
+        }
+        else if ( source instanceof UserAuthorityGroup )
+        {
+            populateUserAuthorityGroup( (UserAuthorityGroup) source, true );
+        }
         else if ( source instanceof ReportTables )
         {
             populateReportTables( (ReportTables) source, true );
@@ -479,6 +484,29 @@
         }
     }
 
+    private void populateUserAuthorityGroups( UserAuthorityGroups userAuthorityGroups, boolean root )
+    {
+        userAuthorityGroups.setLink( getBasePath( userAuthorityGroups.getClass() ) );
+
+        if ( root )
+        {
+            for ( UserAuthorityGroup userAuthorityGroup : userAuthorityGroups.getUserAuthorityGroups() )
+            {
+                populateUserAuthorityGroup( userAuthorityGroup, false );
+            }
+        }
+    }
+
+    private void populateUserAuthorityGroup( UserAuthorityGroup userAuthorityGroup, boolean root )
+    {
+        populateIdentifiableObject( userAuthorityGroup );
+
+        if ( root )
+        {
+            handleIdentifiableObjectCollection( userAuthorityGroup.getDataSets() );
+        }
+    }
+
     private void populateSqlViews( SqlViews sqlViews, boolean root )
     {
         sqlViews.setLink( getBasePath( sqlViews.getClass() ) );

=== 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	2012-03-27 20:10:41 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl	2012-03-28 09:29:38 +0000
@@ -17,7 +17,8 @@
       d:organisationUnits|d:dataElementGroups|d:dataElementGroupSets|d:dataSets|
       d:documents|d:indicatorGroups|d:indicatorGroupSets|d:organisationUnitGroups|
       d:organisationUnitGroupSets|d:indicatorTypes|d:attributeTypes|d:reports|d:constants|
-      d:sqlViews|d:validationRules|d:validationRuleGroups|d:users|d:userGroups|d:reportTables">
+      d:sqlViews|d:validationRules|d:validationRuleGroups|d:users|d:userGroups|d:userAuthorityGroups|
+      d:reportTables">
 
     <h3>
       <xsl:value-of select="local-name()" />

=== 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	2012-03-27 21:38:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl	2012-03-28 09:29:38 +0000
@@ -43,6 +43,8 @@
   <xsl:include href="sqlView.xsl" />
   <xsl:include href="user.xsl" />
   <xsl:include href="userGroup.xsl" />
+  <xsl:include href="userAuthorityGroup.xsl" />
+  <xsl:include href="userCredentials.xsl" />
   <xsl:include href="grid.xsl" />
   <xsl:include href="messageConversations.xsl" />
   <xsl:include href="messageConversation.xsl" />

=== modified 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	2012-03-27 17:38:48 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/user.xsl	2012-03-28 09:29:38 +0000
@@ -30,7 +30,7 @@
           <td> <xsl:value-of select="d:surname" /> </td>
         </tr>
         <tr>
-          <td>EMail</td>
+          <td>E-Mail</td>
           <td> <xsl:value-of select="d:email" /> </td>
         </tr>
         <tr>
@@ -39,7 +39,7 @@
         </tr>
       </table>
 
-      <xsl:apply-templates select="d:organisationUnits" mode="short" />
+      <xsl:apply-templates select="d:userCredentials|d:organisationUnits" mode="short" />
     </div>
   </xsl:template>
 

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/userAuthorityGroup.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/userAuthorityGroup.xsl	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/userAuthorityGroup.xsl	2012-03-28 09:29:38 +0000
@@ -0,0 +1,52 @@
+<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:userAuthorityGroup">
+    <div class="userAuthorityGroup">
+      <h2>
+        <xsl:value-of select="@d:name" />
+      </h2>
+      <table>
+        <tr>
+          <td>ID</td>
+          <td> <xsl:value-of select="@d:id" /> </td>
+        </tr>
+        <tr>
+          <td>Last Updated</td>
+          <td> <xsl:value-of select="@d:lastUpdated" /> </td>
+        </tr>
+        <tr>
+          <td>Code</td>
+          <td> <xsl:value-of select="@d:code" /> </td>
+        </tr>
+      </table>
+
+      <xsl:apply-templates select="d:authorities|d:dataSets" mode="short" />
+    </div>
+  </xsl:template>
+
+  <xsl:template match="d:authorities" mode="short">
+    <xsl:if test="count(child::*) > 0">
+      <h3>Authorities</h3>
+      <ul>
+        <xsl:apply-templates select="child::*" mode="row"/>
+      </ul>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="d:authority" mode="row">
+    <li><xsl:value-of select="." /> </li>
+  </xsl:template>
+
+  <xsl:template match="d:userAuthorityGroups" mode="short">
+    <xsl:if test="count(child::*) > 0">
+      <h3>UserAuthorityGroups</h3>
+      <table class="userAuthorityGroups">
+        <xsl:apply-templates select="child::*" mode="row"/>
+      </table>
+    </xsl:if>
+  </xsl:template>
+
+</xsl:stylesheet>

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/userCredentials.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/userCredentials.xsl	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/userCredentials.xsl	2012-03-28 09:29:38 +0000
@@ -0,0 +1,24 @@
+<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:userCredentials" mode="short">
+    <xsl:if test="count(child::*) > 0">
+      <h3>UserCredentials</h3>
+      <table class="userCredentials">
+        <tr>
+          <td>Username</td>
+          <td> <xsl:value-of select="d:username" /> </td>
+        </tr>
+        <tr>
+          <td>Password</td>
+          <td> <xsl:value-of select="d:password" /> </td>
+        </tr>
+      </table>
+
+      <xsl:apply-templates select="d:userAuthorityGroups" mode="short" />
+    </xsl:if>
+  </xsl:template>
+
+</xsl:stylesheet>