dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #00111
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 38: Subversion -> Bazaar completed.
------------------------------------------------------------
revno: 38
committer: Jan Henrik Overland janhenrik.overland@xxxxxxxxx
branch nick: trunk
timestamp: Tue 2009-03-10 20:39:59 +0530
message:
Subversion -> Bazaar completed.
added:
webservice/dhis-webservice-expoze/src/main/resources/jsonIndicatorGroups.vm
webservice/dhis-webservice-expoze/src/main/resources/xmlIndicatorGroups.vm
webservice/dhis-webservice-expoze/src/main/resources/xmlcompOrganisationUnits.vm
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/gis/LegendSet.java
dhis-2/dhis-services/dhis-service-gis/src/main/java/org/hisp/dhis/gis/DefaultLegendService.java
dhis-2/dhis-services/dhis-service-gis/src/main/java/org/hisp/dhis/gis/hibernate/HibernateLegendStore.java
webservice/dhis-webservice-expoze/src/main/resources/dispatcher.xml
webservice/dhis-webservice-expoze/src/main/resources/jsonLegendMinMax.vm
webservice/dhis-webservice-expoze/src/main/resources/xmlLegendMinMax.vm
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/gis/LegendSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/gis/LegendSet.java 2009-03-09 08:28:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/gis/LegendSet.java 2009-03-10 15:09:59 +0000
@@ -139,11 +139,23 @@
return true;
}
- public Legend getMinLegend(){
- return Collections.min(this.legends, new LegendComparator());
+ public Legend getMinLegend()
+ {
+ if ( legends != null && legends.size() > 0 )
+ {
+ return Collections.min(this.legends, new LegendComparator() );
+ }
+
+ return null;
}
- public Legend getMaxLegend(){
- return Collections.max(this.legends, new LegendComparator());
+ public Legend getMaxLegend()
+ {
+ if ( legends != null && legends.size() > 0 )
+ {
+ return Collections.max(this.legends, new LegendComparator());
+ }
+
+ return null;
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-gis/src/main/java/org/hisp/dhis/gis/DefaultLegendService.java'
--- dhis-2/dhis-services/dhis-service-gis/src/main/java/org/hisp/dhis/gis/DefaultLegendService.java 2009-03-09 08:28:19 +0000
+++ dhis-2/dhis-services/dhis-service-gis/src/main/java/org/hisp/dhis/gis/DefaultLegendService.java 2009-03-10 15:09:59 +0000
@@ -129,8 +129,9 @@
legendStore.updateLegendSet( legendSet );
}
- public LegendSet getLegendSetOfIndicator(int indicatorId) {
- return legendStore.getLegendSetOfIndicator(indicatorId);
- }
-
+ public LegendSet getLegendSetOfIndicator( int indicatorId )
+ {
+ return legendStore.getLegendSetOfIndicator( indicatorId );
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-gis/src/main/java/org/hisp/dhis/gis/hibernate/HibernateLegendStore.java'
--- dhis-2/dhis-services/dhis-service-gis/src/main/java/org/hisp/dhis/gis/hibernate/HibernateLegendStore.java 2009-03-09 08:28:19 +0000
+++ dhis-2/dhis-services/dhis-service-gis/src/main/java/org/hisp/dhis/gis/hibernate/HibernateLegendStore.java 2009-03-10 15:09:59 +0000
@@ -43,137 +43,159 @@
* @author Tran Thanh Tri
* @version $Id: Feature.java 28-01-2008 16:06:00 $
*/
-public class HibernateLegendStore implements LegendStore {
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private HibernateSessionManager sessionManager;
-
- public void setSessionManager(HibernateSessionManager sessionManager) {
- this.sessionManager = sessionManager;
- }
-
- private IndicatorService indicatorService;
-
- public void updateLegendSet(LegendSet legendSet) {
- Session session = sessionManager.getCurrentSession();
-
- session.update(legendSet);
- }
-
- // -------------------------------------------------------------------------
- // LegendStore implementation
- // -------------------------------------------------------------------------
-
- public void setIndicatorService(IndicatorService indicatorService) {
- this.indicatorService = indicatorService;
- }
-
- public void addLegend(Legend legend) {
- Session session = sessionManager.getCurrentSession();
-
- session.save(legend);
- }
-
- public void deleteLegend(Legend legend) {
- Session session = sessionManager.getCurrentSession();
-
- session.delete(legend);
- }
-
- public Legend getLegend(int legendId) {
- Session session = sessionManager.getCurrentSession();
-
- return (Legend) session.get(Legend.class, new Integer(legendId));
- }
-
- @SuppressWarnings("unchecked")
- public Set<Legend> getLegendByMaxMin(double max, double min) {
- Session session = sessionManager.getCurrentSession();
-
- Criteria criteria = session.createCriteria(Legend.class);
- criteria.add(Restrictions.eq("max", max));
- criteria.add(Restrictions.eq("min", min));
-
- return (Set<Legend>) criteria.list();
- }
-
- public void updateLegend(Legend legend) {
- Session session = sessionManager.getCurrentSession();
-
- session.update(legend);
-
- }
-
- @SuppressWarnings("unchecked")
- public Set<Legend> getAllLegend() {
- Session session = sessionManager.getCurrentSession();
-
- Criteria criteria = session.createCriteria(Legend.class);
-
- return new HashSet<Legend>(criteria.list());
- }
-
- public Legend getLegendByName(String name) {
- Session session = sessionManager.getCurrentSession();
-
- Criteria criteria = session.createCriteria(Legend.class);
- criteria.add(Restrictions.eq("name", name));
-
- return (Legend) criteria.uniqueResult();
- }
-
- public void addLegendSet(LegendSet legendSet) {
- Session session = sessionManager.getCurrentSession();
-
- session.save(legendSet);
- }
-
- public void deleteLegendSet(LegendSet legendSet) {
- Session session = sessionManager.getCurrentSession();
-
- session.delete(legendSet);
- }
-
- @SuppressWarnings("unchecked")
- public Set<LegendSet> getAllLegendSet() {
- Session session = sessionManager.getCurrentSession();
-
- Criteria criteria = session.createCriteria(LegendSet.class);
-
- return new HashSet<LegendSet>(criteria.list());
- }
-
- public LegendSet getLegendSet(int id) {
- Session session = sessionManager.getCurrentSession();
-
- return (LegendSet) session.get(LegendSet.class, new Integer(id));
- }
-
- public LegendSet getLegendSet(String name) {
- Session session = sessionManager.getCurrentSession();
- Criteria criteria = session.createCriteria(LegendSet.class);
- criteria.add(Restrictions.eq("name", name));
- return (LegendSet) criteria.uniqueResult();
- }
-
- public LegendSet getLegendSet(Indicator indicator) {
- Set<LegendSet> legendSets = getAllLegendSet();
-
- for (LegendSet legendSet : legendSets) {
- for (Indicator temp : legendSet.getIndicators()) {
- if (temp.equals(indicator)) {
- return legendSet;
- }
- }
- }
-
- return null;
- }
-
- public LegendSet getLegendSetOfIndicator(int indicatorId) {
- return this.getLegendSet(indicatorService.getIndicator(indicatorId));
- }
-
+public class HibernateLegendStore
+ implements LegendStore
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private HibernateSessionManager sessionManager;
+
+ public void setSessionManager( HibernateSessionManager sessionManager )
+ {
+ this.sessionManager = sessionManager;
+ }
+
+ private IndicatorService indicatorService;
+
+ public void updateLegendSet( LegendSet legendSet )
+ {
+ Session session = sessionManager.getCurrentSession();
+
+ session.update( legendSet );
+ }
+
+ // -------------------------------------------------------------------------
+ // LegendStore implementation
+ // -------------------------------------------------------------------------
+
+ public void setIndicatorService( IndicatorService indicatorService )
+ {
+ this.indicatorService = indicatorService;
+ }
+
+ public void addLegend( Legend legend )
+ {
+ Session session = sessionManager.getCurrentSession();
+
+ session.save( legend );
+ }
+
+ public void deleteLegend( Legend legend )
+ {
+ Session session = sessionManager.getCurrentSession();
+
+ session.delete( legend );
+ }
+
+ public Legend getLegend( int legendId )
+ {
+ Session session = sessionManager.getCurrentSession();
+
+ return (Legend) session.get( Legend.class, new Integer( legendId ) );
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public Set<Legend> getLegendByMaxMin( double max, double min )
+ {
+ Session session = sessionManager.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( Legend.class );
+ criteria.add( Restrictions.eq( "max", max ) );
+ criteria.add( Restrictions.eq( "min", min ) );
+
+ return (Set<Legend>) criteria.list();
+ }
+
+ public void updateLegend( Legend legend )
+ {
+ Session session = sessionManager.getCurrentSession();
+
+ session.update( legend );
+
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public Set<Legend> getAllLegend()
+ {
+ Session session = sessionManager.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( Legend.class );
+
+ return new HashSet<Legend>( criteria.list() );
+ }
+
+ public Legend getLegendByName( String name )
+ {
+ Session session = sessionManager.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( Legend.class );
+ criteria.add( Restrictions.eq( "name", name ) );
+
+ return (Legend) criteria.uniqueResult();
+ }
+
+ public void addLegendSet( LegendSet legendSet )
+ {
+ Session session = sessionManager.getCurrentSession();
+
+ session.save( legendSet );
+ }
+
+ public void deleteLegendSet( LegendSet legendSet )
+ {
+ Session session = sessionManager.getCurrentSession();
+
+ session.delete( legendSet );
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public Set<LegendSet> getAllLegendSet()
+ {
+ Session session = sessionManager.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( LegendSet.class );
+
+ return new HashSet<LegendSet>( criteria.list() );
+ }
+
+ public LegendSet getLegendSet( int id )
+ {
+ Session session = sessionManager.getCurrentSession();
+
+ return (LegendSet) session.get( LegendSet.class, new Integer( id ) );
+ }
+
+ public LegendSet getLegendSet( String name )
+ {
+ Session session = sessionManager.getCurrentSession();
+ Criteria criteria = session.createCriteria( LegendSet.class );
+ criteria.add( Restrictions.eq( "name", name ) );
+ return (LegendSet) criteria.uniqueResult();
+ }
+
+ public LegendSet getLegendSet( Indicator indicator )
+ {
+ Set<LegendSet> legendSets = getAllLegendSet();
+
+ for ( LegendSet legendSet : legendSets )
+ {
+ for ( Indicator temp : legendSet.getIndicators() )
+ {
+ if ( temp.equals( indicator ) )
+ {
+ return legendSet;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public LegendSet getLegendSetOfIndicator( int indicatorId )
+ {
+ return this.getLegendSet( indicatorService.getIndicator( indicatorId ) );
+ }
+
}
=== modified file 'webservice/dhis-webservice-expoze/src/main/resources/dispatcher.xml'
--- webservice/dhis-webservice-expoze/src/main/resources/dispatcher.xml 2009-03-09 08:28:19 +0000
+++ webservice/dhis-webservice-expoze/src/main/resources/dispatcher.xml 2009-03-10 15:09:59 +0000
@@ -592,10 +592,16 @@
<format>xml</format>
</response>
<response>
+ <format>xmlcomp</format>
+ <template>xmlcompOrganisationUnits.vm</template>
+ <contentType>application/json</contentType>
+ </response>
+ <response>
<format>json</format>
<template>jsonOrganisationUnits.vm</template>
<contentType>application/json</contentType>
</response>
+
</responses>
</request>
@@ -1000,29 +1006,6 @@
</response>
</responses>
</request>
-
- <request>
- <name>getLegendMinAndMaxOfIndicator</name>
- <bean>org.hisp.dhis.gis.LegendService</bean>
- <method>getLegendSetOfIndicator</method>
- <parameters>
- <parameter>
- <type>int</type>
- <name>indicatorId</name>
- </parameter>
- </parameters>
- <template>xmlLegendMinMax.vm</template>
- <responses>
- <response>
- <format>xml</format>
- </response>
- <response>
- <format>json</format>
- <template>jsonLegendMinMax.vm</template>
- <contentType>application/json</contentType>
- </response>
- </responses>
- </request>
</requests>
=== added file 'webservice/dhis-webservice-expoze/src/main/resources/jsonIndicatorGroups.vm'
--- webservice/dhis-webservice-expoze/src/main/resources/jsonIndicatorGroups.vm 1970-01-01 00:00:00 +0000
+++ webservice/dhis-webservice-expoze/src/main/resources/jsonIndicatorGroups.vm 2009-03-10 15:09:59 +0000
@@ -0,0 +1,9 @@
+#set( $size = $object.size() )
+{ "indicatorGroups": [
+#foreach( $indicatorGroup in $object )
+ {
+ "id": $!{indicatorGroup.id},
+ "name": "$!{indicatorGroup.name}",
+ }#if( $velocityCount < $size ),#end
+#end
+] }
\ No newline at end of file
=== modified file 'webservice/dhis-webservice-expoze/src/main/resources/jsonLegendMinMax.vm'
--- webservice/dhis-webservice-expoze/src/main/resources/jsonLegendMinMax.vm 2009-03-09 08:28:19 +0000
+++ webservice/dhis-webservice-expoze/src/main/resources/jsonLegendMinMax.vm 2009-03-10 15:09:59 +0000
@@ -4,8 +4,8 @@
"name": "$!{object.name}",
"min-value": "$!{object.getMinLegend().min}",
"min-color": "$!{object.getMinLegend().color}",
- "max-value": "$!{object.getMaxLegend().max}",
- "max-color": "$!{object.getMaxLegend().color}"
+ "max-value": "$!{object.getMaxLegend().max}",
+ "max-color": "$!{object.getMaxLegend().color}"
}
]
}
=== added file 'webservice/dhis-webservice-expoze/src/main/resources/xmlIndicatorGroups.vm'
--- webservice/dhis-webservice-expoze/src/main/resources/xmlIndicatorGroups.vm 1970-01-01 00:00:00 +0000
+++ webservice/dhis-webservice-expoze/src/main/resources/xmlIndicatorGroups.vm 2009-03-10 15:09:59 +0000
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<indicatorGroups>
+#foreach( $indicatorGroup in $object )
+ <indicatorGroup>
+ <id>$indicatorGroup.id</id>
+ <name>$!encoder.xmlEncode( $indicatorGroup.name )</name>
+ </indicatorGroup>
+#end
+</indicatorGroups>
\ No newline at end of file
=== modified file 'webservice/dhis-webservice-expoze/src/main/resources/xmlLegendMinMax.vm'
--- webservice/dhis-webservice-expoze/src/main/resources/xmlLegendMinMax.vm 2009-03-09 08:28:19 +0000
+++ webservice/dhis-webservice-expoze/src/main/resources/xmlLegendMinMax.vm 2009-03-10 15:09:59 +0000
@@ -2,8 +2,8 @@
<legendSet>
<id>$object.id</id>
<name>$!encoder.xmlEncode( $object.name )</name>
- <min-value>$object.getMinLegend().min</min-value>
- <min-color>$object.getMinLegend().color</min-color>
- <max-value>$object.getMaxLegend().max</max-value>
- <max-color>$object.getMaxLegend().color</max-color>
+ <min-value>$!object.getMinLegend().min</min-value>
+ <min-color>$!object.getMinLegend().color</min-color>
+ <max-value>$!object.getMaxLegend().max</max-value>
+ <max-color>$!object.getMaxLegend().color</max-color>
</legendSet>
=== added file 'webservice/dhis-webservice-expoze/src/main/resources/xmlcompOrganisationUnits.vm'
--- webservice/dhis-webservice-expoze/src/main/resources/xmlcompOrganisationUnits.vm 1970-01-01 00:00:00 +0000
+++ webservice/dhis-webservice-expoze/src/main/resources/xmlcompOrganisationUnits.vm 2009-03-10 15:09:59 +0000
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<organisationUnits>
+#foreach ( $unit in $object )
+ <organisationUnit id="$unit.id" name="$!encoder.xmlEncode( $unit.name )" geoCode="$!encoder.xmlEncode( $unit.geoCode )"></organisationUnit>
+#end
+</organisationUnits>
\ No newline at end of file
--
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.