← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12416: minor change

 

------------------------------------------------------------
revno: 12416
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-10-03 13:55:58 +0200
message:
  minor change
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.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/interpretation/Interpretation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java	2013-09-18 10:30:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java	2013-10-03 11:55:58 +0000
@@ -28,13 +28,16 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
+import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.annotation.Scanned;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
@@ -45,17 +48,14 @@
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.reporttable.ReportTable;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
 
 /**
  * @author Lars Helge Overland
  */
-@JacksonXmlRootElement( localName = "interpretation", namespace = DxfNamespaces.DXF_2_0)
+@JacksonXmlRootElement( localName = "interpretation", namespace = DxfNamespaces.DXF_2_0 )
 public class Interpretation
     extends BaseIdentifiableObject
 {
@@ -63,19 +63,19 @@
     public static final String TYPE_MAP = "map";
     public static final String TYPE_REPORT_TABLE = "reportTable";
     public static final String TYPE_DATASET_REPORT = "dataSetReport";
-    
+
     private Chart chart;
 
     private Map map;
-    
+
     private ReportTable reportTable;
-    
+
     private DataSet dataSet;
-    
+
     private Period period; // Applicable to report table and data set report
-    
+
     private OrganisationUnit organisationUnit; // Applicable to chart, report table and data set report
-    
+
     private String text;
 
     @Scanned
@@ -104,7 +104,7 @@
         this.text = text;
         this.created = new Date();
     }
-    
+
     public Interpretation( ReportTable reportTable, Period period, OrganisationUnit organisationUnit, String text )
     {
         this.reportTable = reportTable;
@@ -113,7 +113,7 @@
         this.text = text;
         this.created = new Date();
     }
-    
+
     public Interpretation( DataSet dataSet, Period period, OrganisationUnit organisationUnit, String text )
     {
         this.dataSet = dataSet;
@@ -126,7 +126,7 @@
     // -------------------------------------------------------------------------
     // Logic
     // -------------------------------------------------------------------------
-    
+
     @JsonProperty
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getType()
@@ -147,10 +147,32 @@
         {
             return TYPE_DATASET_REPORT;
         }
-        
-        return null;
-    }
-    
+
+        return null;
+    }
+
+    public IdentifiableObject getObject()
+    {
+        if ( chart != null )
+        {
+            return chart;
+        }
+        else if ( map != null )
+        {
+            return map;
+        }
+        else if ( reportTable != null )
+        {
+            return reportTable;
+        }
+        else if ( dataSet != null )
+        {
+            return dataSet;
+        }
+
+        return null;
+    }
+
     public void addComment( InterpretationComment comment )
     {
         this.comments.add( comment );
@@ -160,27 +182,27 @@
     {
         return chart != null;
     }
-    
+
     public boolean isMapInterpretation()
     {
         return map != null;
     }
-    
+
     public boolean isReportTableInterpretation()
     {
         return reportTable != null;
     }
-    
+
     public boolean isDataSetReportInterpretation()
     {
         return dataSet != null;
     }
-    
+
     public PeriodType getPeriodType()
     {
         return period != null ? period.getPeriodType() : null;
     }
-    
+
     // -------------------------------------------------------------------------
     // Get and set methods
     // -------------------------------------------------------------------------
@@ -194,7 +216,7 @@
     @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Chart getChart()
     {
         return chart;
@@ -208,7 +230,7 @@
     @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Map getMap()
     {
         return map;
@@ -222,7 +244,7 @@
     @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public ReportTable getReportTable()
     {
         return reportTable;
@@ -236,7 +258,7 @@
     @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public DataSet getDataSet()
     {
         return dataSet;
@@ -250,7 +272,7 @@
     @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Period getPeriod()
     {
         return period;
@@ -264,7 +286,7 @@
     @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public OrganisationUnit getOrganisationUnit()
     {
         return organisationUnit;
@@ -277,7 +299,7 @@
 
     @JsonProperty
     @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getText()
     {
         return text;
@@ -290,8 +312,8 @@
 
     @JsonProperty
     @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlElementWrapper( localName = "comments", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "comment", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlElementWrapper( localName = "comments", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "comment", namespace = DxfNamespaces.DXF_2_0 )
     public List<InterpretationComment> getComments()
     {
         return comments;