← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17922: Mark LinkableObject.href as property type URL, in Excel serializer, use property type to render o...

 

------------------------------------------------------------
revno: 17922
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-01-09 10:39:22 +0700
message:
  Mark LinkableObject.href as property type URL, in Excel serializer, use property type to render out links (EMAIL/URL)
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseLinkableObject.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/serializers/ExcelNodeSerializer.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/common/BaseLinkableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseLinkableObject.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseLinkableObject.java	2015-01-09 03:39:22 +0000
@@ -31,11 +31,13 @@
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.schema.PropertyType;
+import org.hisp.dhis.schema.annotation.Property;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
-@JacksonXmlRootElement( localName = "linkableObject", namespace = DxfNamespaces.DXF_2_0)
+@JacksonXmlRootElement( localName = "linkableObject", namespace = DxfNamespaces.DXF_2_0 )
 public class BaseLinkableObject
     implements LinkableObject
 {
@@ -48,6 +50,7 @@
     @Override
     @JsonProperty
     @JacksonXmlProperty( isAttribute = true )
+    @Property( PropertyType.URL )
     public String getHref()
     {
         return href;

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/serializers/ExcelNodeSerializer.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/serializers/ExcelNodeSerializer.java	2014-12-16 19:16:17 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/serializers/ExcelNodeSerializer.java	2015-01-09 03:39:22 +0000
@@ -44,6 +44,7 @@
 import org.hisp.dhis.node.types.ComplexNode;
 import org.hisp.dhis.node.types.RootNode;
 import org.hisp.dhis.node.types.SimpleNode;
+import org.hisp.dhis.schema.PropertyType;
 import org.springframework.context.annotation.Scope;
 import org.springframework.context.annotation.ScopedProxyMode;
 import org.springframework.stereotype.Component;
@@ -154,13 +155,24 @@
                             XSSFCell cell = row.createCell( cellIdx++ );
                             cell.setCellValue( getValue( (SimpleNode) property ) );
 
-                            if ( "href".equals( property.getName() ) )
+                            if ( property.getProperty() != null )
                             {
-                                XSSFHyperlink hyperlink = creationHelper.createHyperlink( Hyperlink.LINK_URL );
-                                hyperlink.setAddress( getValue( (SimpleNode) property ) );
-                                hyperlink.setLabel( getValue( (SimpleNode) property ) );
-
-                                cell.setHyperlink( hyperlink );
+                                if ( PropertyType.URL.equals( property.getProperty().getPropertyType() ) )
+                                {
+                                    XSSFHyperlink hyperlink = creationHelper.createHyperlink( Hyperlink.LINK_URL );
+                                    hyperlink.setAddress( getValue( (SimpleNode) property ) );
+                                    hyperlink.setLabel( getValue( (SimpleNode) property ) );
+
+                                    cell.setHyperlink( hyperlink );
+                                }
+                                else if ( PropertyType.EMAIL.equals( property.getProperty().getPropertyType() ) )
+                                {
+                                    XSSFHyperlink hyperlink = creationHelper.createHyperlink( Hyperlink.LINK_EMAIL );
+                                    hyperlink.setAddress( getValue( (SimpleNode) property ) );
+                                    hyperlink.setLabel( getValue( (SimpleNode) property ) );
+
+                                    cell.setHyperlink( hyperlink );
+                                }
                             }
                         }
                     }