dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15344
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5523: added uid, etc to usergroup, added controller
------------------------------------------------------------
revno: 5523
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-12-21 12:37:17 +0100
message:
added uid, etc to usergroup, added controller
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/UserGroupXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroups.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserGroupController.java
dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/userGroup.xsl
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupService.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/DefaultUserGroupService.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/UserGroup.hbm.xml
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/webdomain/Resources.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
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/UserGroupXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/UserGroupXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/UserGroupXmlAdapter.java 2011-12-21 11:37:17 +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.UserGroup;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class UserGroupXmlAdapter extends XmlAdapter<BaseIdentifiableObject, UserGroup>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public UserGroup unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ UserGroup userGroup = new UserGroup();
+
+ userGroup.setUid( identifiableObject.getUid() );
+ userGroup.setLastUpdated( identifiableObject.getLastUpdated() );
+ userGroup.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return userGroup;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( UserGroup userGroup ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( userGroup );
+ }
+}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java 2011-11-24 14:36:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java 2011-12-21 11:37:17 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.user;
/*
- * Copyright (c) 2004-2010, University of Oslo
+ * Copyright (c) 2004-2011, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,12 +27,20 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.adapter.UserXmlAdapter;
+
+import javax.xml.bind.annotation.*;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.HashSet;
import java.util.Set;
-import org.hisp.dhis.common.BaseIdentifiableObject;
-
-public class UserGroup
+@XmlRootElement( name = "userGroup", namespace = Dxf2Namespace.NAMESPACE )
+@XmlAccessorType( value = XmlAccessType.NONE )
+public class UserGroup
extends BaseIdentifiableObject
{
/**
@@ -44,16 +52,16 @@
* Set of related users
*/
private Set<User> members = new HashSet<User>();
-
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
public UserGroup()
{
-
+
}
-
+
public UserGroup( String name )
{
this.name = name;
@@ -65,7 +73,7 @@
this.members = members;
}
-
+
// -------------------------------------------------------------------------
// hashCode, equals and toString
// -------------------------------------------------------------------------
@@ -80,7 +88,7 @@
{
return false;
}
- else if ( !( object instanceof UserGroup ) )
+ else if ( !(object instanceof UserGroup) )
{
return false;
}
@@ -99,6 +107,11 @@
// Getters and setters
// -------------------------------------------------------------------------
+ @XmlElementWrapper( name = "users" )
+ @XmlElement( name = "user" )
+ @XmlJavaTypeAdapter( UserXmlAdapter.class )
+ @JsonProperty
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public Set<User> getMembers()
{
return members;
@@ -108,5 +121,4 @@
{
this.members = members;
}
-
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupService.java 2011-01-04 15:43:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupService.java 2011-12-21 11:37:17 +0000
@@ -2,28 +2,29 @@
import java.util.Collection;
-
public interface UserGroupService
{
String ID = UserGroupService.class.getName();
void addUserGroup( UserGroup userGroup );
-
+
void updateUserGroup( UserGroup userGroup );
-
+
void deleteUserGroup( UserGroup userGroup );
-
+
UserGroup getUserGroup( int userGroupId );
-
+
+ UserGroup getUserGroup( String uid );
+
Collection<UserGroup> getAllUserGroups();
-
+
UserGroup getUserGroupByName( String name );
Collection<UserGroup> getUserGroupsBetween( int first, int max );
-
+
Collection<UserGroup> getUserGroupsBetweenByName( String name, int first, int max );
-
+
int getUserGroupCount();
-
- int getUserGroupCountByName( String name );
+
+ int getUserGroupCountByName( String name );
}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroups.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroups.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroups.java 2011-12-21 11:37:17 +0000
@@ -0,0 +1,67 @@
+package org.hisp.dhis.user;
+
+/*
+ * 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.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.hisp.dhis.common.BaseCollection;
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.adapter.UserGroupXmlAdapter;
+
+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;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@XmlRootElement( name = "userGroups", namespace = Dxf2Namespace.NAMESPACE )
+@XmlAccessorType( value = XmlAccessType.NONE )
+public class UserGroups extends BaseCollection
+{
+ private List<UserGroup> userGroups = new ArrayList<UserGroup>();
+
+ @XmlElement( name = "userGroup" )
+ @XmlJavaTypeAdapter( UserGroupXmlAdapter.class )
+ @JsonProperty( value = "userGroups" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+ public List<UserGroup> getUserGroups()
+ {
+ return userGroups;
+ }
+
+ public void setUserGroups( List<UserGroup> userGroups )
+ {
+ this.userGroups = userGroups;
+ }
+}
=== 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 18:41:43 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java 2011-12-21 11:37:17 +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", "userinfo" };
+ "reporttable", "report", "messageconversation", "userinfo", "usergroup" };
// -------------------------------------------------------------------------
// Dependencies
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserGroupService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserGroupService.java 2011-06-13 13:40:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserGroupService.java 2011-12-21 11:37:17 +0000
@@ -82,6 +82,12 @@
}
@Override
+ public UserGroup getUserGroup( String uid )
+ {
+ return userGroupStore.getByUid( uid );
+ }
+
+ @Override
public UserGroup getUserGroupByName( String name )
{
return userGroupStore.getByName( name );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/UserGroup.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/UserGroup.hbm.xml 2011-05-28 21:25:46 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/UserGroup.hbm.xml 2011-12-21 11:37:17 +0000
@@ -1,7 +1,9 @@
<?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"
+ [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+ >
<hibernate-mapping>
<class name="org.hisp.dhis.user.UserGroup" table="usergroup">
@@ -9,12 +11,11 @@
<id name="id" column="usergroupid">
<generator class="native" />
</id>
-
- <property name="name" not-null="true" unique="true" length="230" />
+ &identifiableProperties;
<set name="members" table="usergroupmembers">
<key column="usergroupid" foreign-key="fk_usergroupmembers_usergroupid" />
- <many-to-many column="userid" class="org.hisp.dhis.user.User" foreign-key="fk_usergroup_userid" />
+ <many-to-many column="userid" class="org.hisp.dhis.user.User" foreign-key="fk_usergroup_userid" />
</set>
</class>
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserGroupController.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserGroupController.java 2011-12-21 11:37:17 +0000
@@ -0,0 +1,145 @@
+package org.hisp.dhis.api.controller;
+
+/*
+ * 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.api.utils.IdentifiableObjectParams;
+import org.hisp.dhis.api.utils.WebLinkPopulator;
+import org.hisp.dhis.user.UserGroup;
+import org.hisp.dhis.user.UserGroupService;
+import org.hisp.dhis.user.UserGroups;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.util.ArrayList;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Controller
+@RequestMapping( value = UserGroupController.RESOURCE_PATH )
+public class UserGroupController
+{
+ public static final String RESOURCE_PATH = "/userGroups";
+
+ @Autowired
+ private UserGroupService userGroupService;
+
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.GET )
+ public String getUserGroups( IdentifiableObjectParams params, Model model, HttpServletRequest request )
+ {
+ UserGroups userGroups = new UserGroups();
+ userGroups.setUserGroups( new ArrayList<UserGroup>( userGroupService.getAllUserGroups() ) );
+
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulator listener = new WebLinkPopulator( request );
+ listener.addLinks( userGroups );
+ }
+
+ model.addAttribute( "model", userGroups );
+
+ return "userGroups";
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.GET )
+ public String getUserGroup( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
+ {
+ UserGroup userGroup = userGroupService.getUserGroup( uid );
+
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulator listener = new WebLinkPopulator( request );
+ listener.addLinks( userGroup );
+ }
+
+ model.addAttribute( "model", userGroup );
+
+ return "userGroup";
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postUserGroupXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postUserGroupJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putUserGroupXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putUserGroupJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void deleteUserGroup( @PathVariable( "uid" ) String uid ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
+}
=== 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-20 09:32:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java 2011-12-21 11:37:17 +0000
@@ -59,6 +59,8 @@
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.validation.ValidationRule;
import org.hisp.dhis.validation.ValidationRuleGroup;
@@ -314,6 +316,14 @@
{
populateUser( (User) source, true );
}
+ else if ( source instanceof UserGroups )
+ {
+ populateUserGroups( (UserGroups) source, true );
+ }
+ else if ( source instanceof UserGroup )
+ {
+ populateUserGroup( (UserGroup) source, true );
+ }
else if ( source instanceof ReportTables )
{
populateReportTables( (ReportTables) source, true );
@@ -434,6 +444,29 @@
}
}
+ private void populateUserGroups( UserGroups userGroups, boolean root )
+ {
+ userGroups.setLink( getBasePath( userGroups.getClass() ) );
+
+ if ( root )
+ {
+ for ( UserGroup userGroup : userGroups.getUserGroups() )
+ {
+ populateUserGroup( userGroup, false );
+ }
+ }
+ }
+
+ private void populateUserGroup( UserGroup userGroup, boolean root )
+ {
+ populateIdentifiableObject( userGroup );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( userGroup.getMembers() );
+ }
+ }
+
private void populateSqlViews( SqlViews sqlViews, boolean root )
{
sqlViews.setLink( getBasePath( sqlViews.getClass() ) );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Resources.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Resources.java 2011-12-19 22:11:19 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Resources.java 2011-12-21 11:37:17 +0000
@@ -49,6 +49,7 @@
import org.hisp.dhis.report.Reports;
import org.hisp.dhis.reporttable.ReportTables;
import org.hisp.dhis.sqlview.SqlViews;
+import org.hisp.dhis.user.UserGroups;
import org.hisp.dhis.user.Users;
import org.hisp.dhis.validation.ValidationRuleGroups;
import org.hisp.dhis.validation.ValidationRules;
@@ -135,6 +136,7 @@
resources.add( new Resource( "ReportTables", ReportTables.class, requestMethods, mediaTypes ) );
resources.add( new Resource( "SqlViews", SqlViews.class, requestMethods, mediaTypes ) );
resources.add( new Resource( "Users", Users.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "UserGroups", UserGroups.class, requestMethods, mediaTypes ) );
resources.add( new Resource( "ValidationRules", ValidationRules.class, requestMethods, mediaTypes ) );
resources.add( new Resource( "ValidationRuleGroups", ValidationRuleGroups.class, requestMethods, mediaTypes ) );
}
=== 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-20 09:32:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl 2011-12-21 11:37:17 +0000
@@ -12,7 +12,7 @@
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:reportTables">
+ d:sqlViews|d:validationRules|d:validationRuleGroups|d:users|d:userGroups|d:reportTables">
<xsl:choose>
<xsl:when test="@page">
=== 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-16 19:36:39 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl 2011-12-21 11:37:17 +0000
@@ -40,6 +40,7 @@
<xsl:include href="validationRuleGroup.xsl" />
<xsl:include href="sqlView.xsl" />
<xsl:include href="user.xsl" />
+ <xsl:include href="userGroup.xsl" />
<xsl:include href="grid.xsl" />
<xsl:include href="messageConversations.xsl" />
<xsl:include href="messageConversation.xsl" />
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/userGroup.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/userGroup.xsl 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/userGroup.xsl 2011-12-21 11:37:17 +0000
@@ -0,0 +1,39 @@
+<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:userGroup">
+ <div class="userGroup">
+ <h2>
+ <xsl:value-of select="@name" />
+ </h2>
+ <table>
+ <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>Code</td>
+ <td> <xsl:value-of select="@code" /> </td>
+ </tr>
+ </table>
+
+ <xsl:apply-templates select="d:users" mode="short" />
+ </div>
+ </xsl:template>
+
+ <xsl:template match="d:userGroups" mode="short">
+ <xsl:if test="count(child::*) > 0">
+ <h3>UserGroups</h3>
+ <table class="userGroups">
+ <xsl:apply-templates select="child::*" mode="row"/>
+ </table>
+ </xsl:if>
+ </xsl:template>
+
+</xsl:stylesheet>