← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5455: added link-generation for messaageconversation

 

------------------------------------------------------------
revno: 5455
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-12-16 14:38:59 +0100
message:
  added link-generation for messaageconversation
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversations.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MessageConversationController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.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-api/src/main/java/org/hisp/dhis/message/MessageConversations.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversations.java	2011-12-16 10:57:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversations.java	2011-12-16 13:38:59 +0000
@@ -30,6 +30,7 @@
 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.MessageConversationXmlAdapter;
 
@@ -46,7 +47,7 @@
  */
 @XmlRootElement( name = "messageConversations", namespace = Dxf2Namespace.NAMESPACE )
 @XmlAccessorType( value = XmlAccessType.NONE )
-public class MessageConversations
+public class MessageConversations extends BaseLinkableObject
 {
     private List<MessageConversation> messageConversations = new ArrayList<MessageConversation>();
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MessageConversationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MessageConversationController.java	2011-12-16 10:57:57 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MessageConversationController.java	2011-12-16 13:38:59 +0000
@@ -103,41 +103,10 @@
     @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
     public void postMessageConversationXML( HttpServletResponse response, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
     }
 
     @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
     public void postMessageConversationJSON( 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 putMessageConversationXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
-    {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
-    }
-
-    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
-    @ResponseStatus( value = HttpStatus.NO_CONTENT )
-    public void putMessageConversationJSON( @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 deleteMessageConversation( @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-14 14:28:04 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java	2011-12-16 13:38:59 +0000
@@ -27,15 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
 import javassist.util.proxy.ProxyObject;
-
-import javax.servlet.http.HttpServletRequest;
-
 import org.hisp.dhis.api.webdomain.Resource;
 import org.hisp.dhis.api.webdomain.Resources;
 import org.hisp.dhis.attribute.Attribute;
@@ -48,40 +40,17 @@
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.constant.Constant;
 import org.hisp.dhis.constant.Constants;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategories;
-import org.hisp.dhis.dataelement.DataElementCategory;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryCombos;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombos;
-import org.hisp.dhis.dataelement.DataElementCategoryOptions;
-import org.hisp.dhis.dataelement.DataElementGroup;
-import org.hisp.dhis.dataelement.DataElementGroupSet;
-import org.hisp.dhis.dataelement.DataElementGroupSets;
-import org.hisp.dhis.dataelement.DataElementGroups;
-import org.hisp.dhis.dataelement.DataElements;
+import org.hisp.dhis.dataelement.*;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSets;
 import org.hisp.dhis.document.Document;
 import org.hisp.dhis.document.Documents;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorGroup;
-import org.hisp.dhis.indicator.IndicatorGroupSet;
-import org.hisp.dhis.indicator.IndicatorGroupSets;
-import org.hisp.dhis.indicator.IndicatorGroups;
-import org.hisp.dhis.indicator.IndicatorType;
-import org.hisp.dhis.indicator.IndicatorTypes;
-import org.hisp.dhis.indicator.Indicators;
+import org.hisp.dhis.indicator.*;
 import org.hisp.dhis.mapping.MapView;
 import org.hisp.dhis.mapping.Maps;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupSets;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroups;
-import org.hisp.dhis.organisationunit.OrganisationUnits;
+import org.hisp.dhis.message.MessageConversation;
+import org.hisp.dhis.message.MessageConversations;
+import org.hisp.dhis.organisationunit.*;
 import org.hisp.dhis.report.Report;
 import org.hisp.dhis.report.Reports;
 import org.hisp.dhis.reporttable.ReportTable;
@@ -95,6 +64,12 @@
 import org.hisp.dhis.validation.ValidationRuleGroups;
 import org.hisp.dhis.validation.ValidationRules;
 
+import javax.servlet.http.HttpServletRequest;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
@@ -346,6 +321,37 @@
         {
             populateReportTable( (ReportTable) source, true );
         }
+        else if ( source instanceof MessageConversations )
+        {
+            populateMessageConversations( (MessageConversations) source, true );
+        }
+        else if ( source instanceof MessageConversation )
+        {
+            populateMessageConversation( (MessageConversation) source, true );
+        }
+    }
+
+    private void populateMessageConversations( MessageConversations messageConversations, boolean root )
+    {
+        messageConversations.setLink( getBasePath( messageConversations.getClass() ) );
+
+        if ( root )
+        {
+            for ( MessageConversation messageConversation : messageConversations.getMessageConversations() )
+            {
+                populateMessageConversation( messageConversation, false );
+            }
+        }
+    }
+
+    private void populateMessageConversation( MessageConversation messageConversation, boolean root )
+    {
+        populateIdentifiableObject( messageConversation );
+
+        if ( root )
+        {
+            handleIdentifiableObjectCollection( messageConversation.getUsers() );
+        }
     }
 
     private void populateReportTables( ReportTables reportTables, boolean root )