dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20579
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9434: minor format changes to sharing json
------------------------------------------------------------
revno: 9434
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-01-04 11:00:54 +0100
message:
minor format changes to sharing json
added:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/SharingUserGroups.java
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/Sharing.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/SharingUserGroupAccess.java
--
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-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java 2013-01-03 12:43:44 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java 2013-01-04 10:00:54 +0000
@@ -30,6 +30,7 @@
import org.hisp.dhis.api.utils.ContextUtils;
import org.hisp.dhis.api.webdomain.sharing.Sharing;
import org.hisp.dhis.api.webdomain.sharing.SharingUserGroupAccess;
+import org.hisp.dhis.api.webdomain.sharing.SharingUserGroups;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.IdentifiableObjectManager;
@@ -125,16 +126,12 @@
{
SharingUserGroupAccess sharingUserGroupAccess = new SharingUserGroupAccess();
sharingUserGroupAccess.setId( userGroupAccess.getUserGroup().getUid() );
+ sharingUserGroupAccess.setName( userGroupAccess.getUserGroup().getDisplayName() );
sharingUserGroupAccess.setAccess( userGroupAccess.getAccess() );
sharing.getObject().getUserGroupAccesses().add( sharingUserGroupAccess );
}
- for ( UserGroup userGroup : userGroupService.getAllUserGroups() )
- {
- sharing.getUserGroups().put( userGroup.getUid(), userGroup.getDisplayName() );
- }
-
JacksonUtils.toJson( response.getOutputStream(), sharing );
}
@@ -186,4 +183,17 @@
manager.update( object );
}
+
+ @RequestMapping( value = "/search", produces = { "application/json", "text/*" } )
+ public void searchUserGroups( @RequestParam String key, HttpServletResponse response ) throws IOException
+ {
+ SharingUserGroups sharingUserGroups = new SharingUserGroups();
+
+ for ( UserGroup userGroup : userGroupService.getUserGroupsBetweenByName( key, 0, Integer.MAX_VALUE ) )
+ {
+ sharingUserGroups.getUserGroups().put( userGroup.getUid(), userGroup.getDisplayName() );
+ }
+
+ JacksonUtils.toJson( response.getOutputStream(), sharingUserGroups );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/Sharing.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/Sharing.java 2013-01-03 12:43:44 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/Sharing.java 2013-01-04 10:00:54 +0000
@@ -29,9 +29,6 @@
import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -40,9 +37,6 @@
@JsonProperty
private SharingObject object = new SharingObject();
- @JsonProperty
- private Map<String, String> userGroups = new HashMap<String, String>();
-
public Sharing()
{
}
@@ -56,14 +50,4 @@
{
this.object = object;
}
-
- public Map<String, String> getUserGroups()
- {
- return userGroups;
- }
-
- public void setUserGroups( Map<String, String> userGroups )
- {
- this.userGroups = userGroups;
- }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/SharingUserGroupAccess.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/SharingUserGroupAccess.java 2013-01-03 12:43:44 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/SharingUserGroupAccess.java 2013-01-04 10:00:54 +0000
@@ -38,6 +38,9 @@
private String id;
@JsonProperty
+ private String name;
+
+ @JsonProperty
private String access;
public SharingUserGroupAccess()
@@ -54,6 +57,16 @@
this.id = id;
}
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
public String getAccess()
{
return access;
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/SharingUserGroups.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/SharingUserGroups.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/SharingUserGroups.java 2013-01-04 10:00:54 +0000
@@ -0,0 +1,56 @@
+package org.hisp.dhis.api.webdomain.sharing;
+
+/*
+ * Copyright (c) 2004-2012, 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.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class SharingUserGroups
+{
+ @JsonProperty
+ private Map<String, String> userGroups = new HashMap<String, String>();
+
+ public SharingUserGroups()
+ {
+ }
+
+ public Map<String, String> getUserGroups()
+ {
+ return userGroups;
+ }
+
+ public void setUserGroups( Map<String, String> userGroups )
+ {
+ this.userGroups = userGroups;
+ }
+}