=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java 2013-09-16 17:04:01 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java 2013-09-17 16:22:09 +0000 @@ -214,8 +214,9 @@ } /** - * Assembles a DimensionalObject. Collapses indicators, data elements, data - * element operands and data sets into the dx dimension. + * Assembles a DimensionalObject based on the persisted properties of this + * AnalyticalObject. Collapses indicators, data elements, data element + * operands and data sets into the dx dimension. * * Collapses fixed and relative periods into the pe dimension. Collapses * fixed and user organisation units into the ou dimension. @@ -363,6 +364,8 @@ * fixed and user organisation units into the ou dimension, where user * organisation units properties are represented by enums (e.g. USER_ORG_UNIT). * + * This method is useful when serializing the AnalyticalObject. + * * @param dimension the dimension identifier. * @return a list of DimensionalObjects. */ === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObjectUtils.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObjectUtils.java 2013-08-23 15:56:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObjectUtils.java 2013-09-17 16:22:09 +0000 @@ -88,4 +88,18 @@ return list; } + + /** + * Returns a list typed with the desired erasure based on the given collection. + * This operation implies an unchecked cast and it is the responsibility of + * the caller to make sure the cast is valid. + * + * @param collection the collection. + * @param the class type. + * @return a list. + */ + public static List asTypedList( Collection collection, Class clazz ) + { + return asTypedList( collection ); + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2013-08-23 15:56:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2013-09-17 16:22:09 +0000 @@ -28,41 +28,40 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import static org.hisp.dhis.common.DimensionalObject.ORGUNIT_DIM_ID; + 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.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import org.hisp.dhis.common.BaseAnalyticalObject; import org.hisp.dhis.common.BaseIdentifiableObject; +import org.hisp.dhis.common.DimensionalObject; import org.hisp.dhis.common.DxfNamespaces; import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.common.adapter.JacksonPeriodDeserializer; -import org.hisp.dhis.common.adapter.JacksonPeriodSerializer; -import org.hisp.dhis.common.adapter.JacksonPeriodTypeDeserializer; -import org.hisp.dhis.common.adapter.JacksonPeriodTypeSerializer; +import org.hisp.dhis.common.NameableObjectUtils; import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.common.view.ExportView; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementGroup; -import org.hisp.dhis.dataelement.DataElementOperand; -import org.hisp.dhis.indicator.Indicator; -import org.hisp.dhis.indicator.IndicatorGroup; +import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet; -import org.hisp.dhis.organisationunit.OrganisationUnitLevel; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.period.PeriodType; +import org.hisp.dhis.user.User; + +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.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** + * For analytical data, organisation units and indicators/data elements are + * dimensions, and period is filter. + * * @author Jan Henrik Overland */ @JacksonXmlRootElement( localName = "mapView", namespace = DxfNamespaces.DXF_2_0) public class MapView - extends BaseIdentifiableObject + extends BaseAnalyticalObject { public static final String LAYER_BOUNDARY = "boundary"; public static final String LAYER_THEMATIC1 = "thematic1"; @@ -82,22 +81,6 @@ private String valueType; - private IndicatorGroup indicatorGroup; - - private Indicator indicator; - - private DataElementGroup dataElementGroup; - - private DataElement dataElement; - - private DataElementOperand dataElementOperand; - - private Period period; - - private OrganisationUnit parentOrganisationUnit; - - private OrganisationUnitLevel organisationUnitLevel; - private String legendType; private Integer method; @@ -120,43 +103,54 @@ private Integer areaRadius; + // ------------------------------------------------------------------------- + // Transient properties + // ------------------------------------------------------------------------- + + private transient I18nFormat format; + private transient String parentGraph; private transient int parentLevel; private transient List organisationUnitsAtLevel = new ArrayList(); + private transient List organisationUnitsInGroups = new ArrayList(); + public MapView() { } - public MapView( String layer, String name, String valueType, IndicatorGroup indicatorGroup, Indicator indicator, - DataElementGroup dataElementGroup, DataElement dataElement, - Period period, OrganisationUnit parentOrganisationUnit, OrganisationUnitLevel organisationUnitLevel, - String legendType, Integer method, Integer classes, String colorLow, String colorHigh, - MapLegendSet legendSet, Integer radiusLow, Integer radiusHigh, Double opacity ) - { - this.layer = layer; - this.name = name; - this.valueType = valueType; - this.indicatorGroup = indicatorGroup; - this.indicator = indicator; - this.dataElementGroup = dataElementGroup; - this.dataElement = dataElement; - this.period = period; - this.parentOrganisationUnit = parentOrganisationUnit; - this.organisationUnitLevel = organisationUnitLevel; - this.legendType = legendType; - this.method = method; - this.classes = classes; - this.colorLow = colorLow; - this.colorHigh = colorHigh; - this.legendSet = legendSet; - this.radiusLow = radiusLow; - this.radiusHigh = radiusHigh; - this.opacity = opacity; - } - + // ------------------------------------------------------------------------- + // Analytical + // ------------------------------------------------------------------------- + + @Override + public void init( User user, Date date, OrganisationUnit organisationUnit, + List organisationUnitsAtLevel, List organisationUnitsInGroups, I18nFormat format ) + { + this.user = user; + this.relativePeriodDate = date; + this.relativeOrganisationUnit = organisationUnit; + this.organisationUnitsAtLevel = organisationUnitsAtLevel; + this.organisationUnitsInGroups = organisationUnitsInGroups; + } + + @Override + public void populateAnalyticalProperties() + { + columns.addAll( getDimensionalObjectList( DimensionalObject.ORGUNIT_DIM_ID ) ); + columns.addAll( getDimensionalObjectList( DimensionalObject.DATA_X_DIM_ID ) ); + filters.addAll( getDimensionalObjectList( DimensionalObject.PERIOD_DIM_ID ) ); + } + + public List getAllOrganisationUnits() + { + DimensionalObject object = getDimensionalObject( ORGUNIT_DIM_ID, relativePeriodDate, user, true, organisationUnitsAtLevel, organisationUnitsInGroups, format ); + + return object != null ? NameableObjectUtils.asTypedList( object.getItems(), OrganisationUnit.class ) : null; + } + // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- @@ -170,7 +164,7 @@ @Override public String getName() { - return indicator != null ? indicator.getName() : dataElement != null ? dataElement.getName() : uid; + return indicators != null ? indicators.get( 0 ).getName() : dataElements != null ? dataElements.get( 0 ).getName() : uid; } @JsonProperty @@ -200,133 +194,6 @@ } @JsonProperty - @JsonSerialize( as = BaseIdentifiableObject.class ) - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) - public IndicatorGroup getIndicatorGroup() - { - return indicatorGroup; - } - - public void setIndicatorGroup( IndicatorGroup indicatorGroup ) - { - this.indicatorGroup = indicatorGroup; - } - - @JsonProperty - @JsonSerialize( as = BaseIdentifiableObject.class ) - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) - public Indicator getIndicator() - { - return indicator; - } - - public void setIndicator( Indicator indicator ) - { - this.indicator = indicator; - } - - @JsonProperty - @JsonSerialize( as = BaseIdentifiableObject.class ) - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) - public DataElementGroup getDataElementGroup() - { - return dataElementGroup; - } - - public void setDataElementGroup( DataElementGroup dataElementGroup ) - { - this.dataElementGroup = dataElementGroup; - } - - @JsonProperty - @JsonSerialize( as = BaseIdentifiableObject.class ) - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) - public DataElement getDataElement() - { - return dataElement; - } - - public void setDataElement( DataElement dataElement ) - { - this.dataElement = dataElement; - } - - @JsonProperty - @JsonSerialize( as = BaseIdentifiableObject.class ) - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) - public DataElementOperand getDataElementOperand() - { - return dataElementOperand; - } - - public void setDataElementOperand( DataElementOperand dataElementOperand ) - { - this.dataElementOperand = dataElementOperand; - } - - @JsonProperty - @JsonSerialize( using = JacksonPeriodTypeSerializer.class ) - @JsonDeserialize( using = JacksonPeriodTypeDeserializer.class ) - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) - public PeriodType getPeriodType() - { - return period != null ? period.getPeriodType() : null; - } - - public void setPeriodType( PeriodType periodType ) - { - // ignore - } - - @JsonProperty - @JsonSerialize( using = JacksonPeriodSerializer.class ) - @JsonDeserialize( using = JacksonPeriodDeserializer.class ) - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) - public Period getPeriod() - { - return period; - } - - public void setPeriod( Period period ) - { - this.period = period; - } - - @JsonProperty - @JsonSerialize( as = BaseIdentifiableObject.class ) - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) - public OrganisationUnit getParentOrganisationUnit() - { - return parentOrganisationUnit; - } - - public void setParentOrganisationUnit( OrganisationUnit parentOrganisationUnit ) - { - this.parentOrganisationUnit = parentOrganisationUnit; - } - - @JsonProperty - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) - public OrganisationUnitLevel getOrganisationUnitLevel() - { - return organisationUnitLevel; - } - - public void setOrganisationUnitLevel( OrganisationUnitLevel organisationUnitLevel ) - { - this.organisationUnitLevel = organisationUnitLevel; - } - - @JsonProperty @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) public String getLegendType() @@ -497,23 +364,6 @@ this.parentLevel = parentLevel; } - public List getOrganisationUnitsAtLevel() - { - return organisationUnitsAtLevel; - } - - public void setOrganisationUnitsAtLevel( List organisationUnitsAtLevel ) - { - this.organisationUnitsAtLevel = organisationUnitsAtLevel; - } - - @Override - public String toString() - { - return "[Indicator: " + indicator + ", org unit: " + - parentOrganisationUnit + ", period: " + period + ", value type: " + valueType + "]"; - } - @Override public void mergeWith( IdentifiableObject other ) { @@ -525,13 +375,6 @@ layer = mapView.getLayer() == null ? layer : mapView.getLayer(); valueType = mapView.getValueType() == null ? valueType : mapView.getValueType(); - indicatorGroup = mapView.getIndicatorGroup() == null ? indicatorGroup : mapView.getIndicatorGroup(); - indicator = mapView.getIndicator() == null ? indicator : mapView.getIndicator(); - dataElementGroup = mapView.getDataElementGroup() == null ? dataElementGroup : mapView.getDataElementGroup(); - dataElement = mapView.getDataElement() == null ? dataElement : mapView.getDataElement(); - period = mapView.getPeriod() == null ? period : mapView.getPeriod(); - parentOrganisationUnit = mapView.getParentOrganisationUnit() == null ? parentOrganisationUnit : mapView.getParentOrganisationUnit(); - organisationUnitLevel = mapView.getOrganisationUnitLevel() == null ? organisationUnitLevel : mapView.getOrganisationUnitLevel(); legendType = mapView.getLegendType() == null ? legendType : mapView.getLegendType(); method = mapView.getMethod() == null ? method : mapView.getMethod(); classes = mapView.getClasses() == null ? classes : mapView.getClasses(); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2013-09-13 11:22:35 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2013-09-17 16:22:09 +0000 @@ -38,7 +38,6 @@ import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.indicator.IndicatorService; import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitLevel; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodService; @@ -316,8 +315,10 @@ { if ( mapView != null ) { - mapView.getParentOrganisationUnit().setLevel( - organisationUnitService.getLevelOfOrganisationUnit( mapView.getParentOrganisationUnit().getId() ) ); + for ( OrganisationUnit unit : mapView.getOrganisationUnits() ) + { + unit.setLevel( organisationUnitService.getLevelOfOrganisationUnit( unit.getId() ) ); + } } } @@ -336,10 +337,10 @@ Indicator indicator = indicatorService.getIndicator( indicatorUid ); OrganisationUnit unit = organisationUnitService.getOrganisationUnit( organisationUnitUid ); - mapView.setIndicator( indicator ); - mapView.setPeriod( period ); - mapView.setParentOrganisationUnit( unit ); - mapView.setOrganisationUnitLevel( new OrganisationUnitLevel( level, "" ) ); + mapView.getIndicators().add( indicator ); + mapView.getPeriods().add( period ); + mapView.getOrganisationUnits().add( unit ); + mapView.getOrganisationUnitLevels().add( level ); mapView.setName( indicator.getName() ); mapView.setValueType( MapView.VALUE_TYPE_INDICATOR ); @@ -356,10 +357,9 @@ { //TODO poor performance, fix - if ( mapView.getParentOrganisationUnit() != null ) + for ( OrganisationUnit unit : mapView.getOrganisationUnits() ) { - mapView.getParentOrganisationUnit().setLevel( - organisationUnitService.getLevelOfOrganisationUnit( mapView.getParentOrganisationUnit().getId() ) ); + unit.setLevel( organisationUnitService.getLevelOfOrganisationUnit( unit.getId() ) ); } } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java 2013-09-17 16:22:09 +0000 @@ -31,11 +31,7 @@ import java.util.Iterator; import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementGroup; -import org.hisp.dhis.dataelement.DataElementOperand; -import org.hisp.dhis.dataelement.DataElementOperandService; import org.hisp.dhis.indicator.Indicator; -import org.hisp.dhis.indicator.IndicatorGroup; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.Period; import org.hisp.dhis.system.deletion.DeletionHandler; @@ -58,13 +54,6 @@ this.mappingService = mappingService; } - private DataElementOperandService operandService; - - public void setOperandService( DataElementOperandService operandService ) - { - this.operandService = operandService; - } - // ------------------------------------------------------------------------- // DeletionHandler implementation // ------------------------------------------------------------------------- @@ -76,23 +65,11 @@ } @Override - public void deleteMapView( MapView mapView ) - { - DataElementOperand operand = mapView.getDataElementOperand(); - - if ( operand != null ) - { - mapView.setDataElementOperand( null ); - operandService.deleteDataElementOperand( operand ); - } - } - - @Override public String allowDeletePeriod( Period period ) { for ( MapView mapView : mappingService.getAllMapViews() ) { - if ( mapView.getPeriod().equals( period ) ) + if ( mapView.getPeriods().contains( period ) ) { return mapView.getName(); } @@ -100,24 +77,7 @@ return null; } - - @Override - public void deleteIndicatorGroup( IndicatorGroup indicatorGroup ) - { - Iterator mapViews = mappingService.getAllMapViews().iterator(); - while ( mapViews.hasNext() ) - { - MapView mapView = mapViews.next(); - - if ( mapView.getIndicatorGroup() != null && mapView.getIndicatorGroup().equals( indicatorGroup ) ) - { - mapViews.remove(); - mappingService.deleteMapView( mapView ); - } - } - } - @Override public void deleteIndicator( Indicator indicator ) { @@ -127,24 +87,7 @@ { MapView mapView = mapViews.next(); - if ( mapView.getIndicator() != null && mapView.getIndicator().equals( indicator ) ) - { - mapViews.remove(); - mappingService.deleteMapView( mapView ); - } - } - } - - @Override - public void deleteDataElementGroup( DataElementGroup dataElementGroup ) - { - Iterator mapViews = mappingService.getAllMapViews().iterator(); - - while ( mapViews.hasNext() ) - { - MapView mapView = mapViews.next(); - - if ( mapView.getDataElementGroup() != null && mapView.getDataElementGroup().equals( dataElementGroup ) ) + if ( mapView.getIndicators() != null && mapView.getIndicators().contains( indicator ) ) { mapViews.remove(); mappingService.deleteMapView( mapView ); @@ -161,7 +104,7 @@ { MapView mapView = mapViews.next(); - if ( mapView.getDataElement() != null && mapView.getDataElement().equals( dataElement ) ) + if ( mapView.getDataElements() != null && mapView.getDataElements().contains( dataElement ) ) { mapViews.remove(); mappingService.deleteMapView( mapView ); @@ -178,7 +121,7 @@ { MapView mapView = mapViews.next(); - if ( mapView.getParentOrganisationUnit() != null && mapView.getParentOrganisationUnit().equals( organisationUnit ) ) + if ( mapView.getOrganisationUnits() != null && mapView.getOrganisationUnits().contains( organisationUnit ) ) { mapViews.remove(); mappingService.deleteMapView( mapView ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-09-14 23:13:35 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-09-17 16:22:09 +0000 @@ -635,9 +635,41 @@ executeSql( "delete from usersetting where name = 'dashboardConfig' or name = 'dashboardConfiguration'" ); executeSql( "ALTER TABLE interpretation ALTER COLUMN userid DROP NOT NULL" ); + upgradeMapViewsToAnalyticalObject(); + log.info( "Tables updated" ); } + private void upgradeMapViewsToAnalyticalObject() + { + executeSql( "insert into mapview_dataelements ( mapviewid, sort_order, dataelementid ) select mapviewid, 0, dataelementid from mapview where dataelementid is not null" ); + executeSql( "alter table mapview drop column dataelementid" ); + + executeSql( "insert into mapview_dataelementoperands ( mapviewid, sort_order, dataelementoperandid ) select mapviewid, 0, dataelementoperandid from mapview where dataelementoperandid is not null" ); + executeSql( "alter table mapview drop column dataelementoperandid" ); + + executeSql( "insert into mapview_indicators ( mapviewid, sort_order, indicatorid ) select mapviewid, 0, indicatorid from mapview where indicatorid is not null" ); + executeSql( "alter table mapview drop column indicatorid" ); + + executeSql( "insert into mapview_organisationunits ( mapviewid, sort_order, organisationunitid ) select mapviewid, 0, parentorganisationunitid from mapview where parentorganisationunitid is not null" ); + executeSql( "alter table mapview drop column parentorganisationunitid" ); + + executeSql( "insert into mapview_periods ( mapviewid, sort_order, periodid ) select mapviewid, 0, periodid from mapview where periodid is not null" ); + executeSql( "alter table mapview drop column periodid" ); + + executeSql( "insert into mapview_orgunitlevels ( mapviewid, sort_order, orgunitlevel ) select m.mapviewid, 0, o.level " + + "from mapview m join orgunitlevel o on (m.organisationunitlevelid=o.orgunitlevelid) where m.organisationunitlevelid is not null" ); + + System.out.println(); + System.out.println("insert into mapview_orgunitlevels ( mapviewid, sort_order, orgunitlevel ) select m.mapviewid, 0, o.level " + + "from mapview m join orgunitlevel o on (m.organisationunitlevelid=o.orgunitlevelid) where m.organisationunitlevelid is not null"); + + executeSql( "alter table mapview drop column organisationunitlevelid" ); + + executeSql( "alter table mapview drop column dataelementgroupid" ); + executeSql( "alter table mapview drop column indicatorgroupid" ); + } + private void upgradeChartRelativePeriods() { BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( RelativePeriodsBatchHandler.class ).init(); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-09-13 13:00:37 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-09-17 16:22:09 +0000 @@ -1057,7 +1057,6 @@ - === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml 2013-09-09 18:40:14 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml 2013-09-17 16:22:09 +0000 @@ -22,29 +22,52 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + === modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java' --- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java 2013-09-09 11:48:46 +0000 +++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java 2013-09-17 16:22:09 +0000 @@ -28,8 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.common.NameableObjectUtils.getList; - import java.awt.Color; import java.awt.Graphics; import java.awt.image.BufferedImage; @@ -161,15 +159,29 @@ private InternalMapLayer getSingleInternalMapLayer( MapView mapView ) { - if ( mapView == null || mapView.getPeriod() == null || mapView.getParentOrganisationUnit() == null ) + if ( mapView == null ) { return null; } boolean isIndicator = MapView.VALUE_TYPE_INDICATOR.equals( mapView.getValueType() ); - List organisationUnits = new ArrayList( organisationUnitService. - getOrganisationUnitsAtLevel( mapView.getOrganisationUnitLevel().getLevel(), mapView.getParentOrganisationUnit() ) ); + List atLevels = new ArrayList(); + List inGroups = new ArrayList(); + + if ( mapView.hasOrganisationUnitLevels() ) + { + atLevels.addAll( organisationUnitService.getOrganisationUnitsAtLevels( mapView.getOrganisationUnitLevels(), mapView.getOrganisationUnits() ) ); + } + + if ( mapView.hasItemOrganisationUnitGroups() ) + { + inGroups.addAll( organisationUnitService.getOrganisationUnits( mapView.getItemOrganisationUnitGroups(), mapView.getOrganisationUnits() ) ); + } + + mapView.init( null, null, null, atLevels, inGroups, null ); + + List organisationUnits = mapView.getAllOrganisationUnits(); java.util.Map uidOuMap = new HashMap(); @@ -178,12 +190,12 @@ uidOuMap.put( ou.getUid(), ou ); } - mapView.setOrganisationUnitsAtLevel( organisationUnits ); - - Grid grid = getDataGrid( mapView ); - + DataQueryParams params = analyticsService.getFromAnalyticalObject( mapView, null ); + + Grid grid = analyticsService.getAggregatedDataValues( params ); + Collection mapValues = getMapValues( grid ); - + if ( mapValues.isEmpty() ) { return null; @@ -193,7 +205,7 @@ String name = mapView.getName(); // Get the period - Period period = mapView.getPeriod(); + Period period = mapView.getPeriods().get( 0 ); //TODO make more robust // Get the low and high radii int radiusLow = !isIndicator ? mapView.getRadiusLow() : DEFAULT_RADIUS_LOW; @@ -255,30 +267,6 @@ } /** - * Creates a Grid with aggregated data. - */ - private Grid getDataGrid( MapView mapView ) - { - DataQueryParams params = new DataQueryParams(); - - if ( mapView.getIndicator() != null ) - { - params.setIndicators( getList( mapView.getIndicator() ) ); - } - else if ( mapView.getDataElement() != null ) - { - params.setDataElements( getList( mapView.getDataElement() ) ); - } - - //TODO operands - - params.setOrganisationUnits( mapView.getOrganisationUnitsAtLevel() ); - params.setFilterPeriods( getList( mapView.getPeriod() ) ); - - return analyticsService.getAggregatedDataValues( params ); - } - - /** * Creates a list of aggregated map values. */ private List getMapValues( Grid grid ) @@ -289,8 +277,8 @@ { if ( row != null && row.size() >= 3 ) { - String ou = (String) row.get( 1 ); - Double value = (Double) row.get( 2 ); + String ou = (String) row.get( 0 ); + Double value = (Double) row.get( ( row.size() - 1 ) ); mapValues.add( new MapValue( ou, value ) ); } === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml' --- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml 2013-08-15 11:30:31 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml 2013-09-17 16:22:09 +0000 @@ -70,7 +70,7 @@ - + === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml' --- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml 2013-08-15 11:30:31 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml 2013-09-17 16:22:09 +0000 @@ -31,7 +31,7 @@ - + === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java 2013-09-13 11:22:35 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java 2013-09-17 16:22:09 +0000 @@ -28,8 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.period.PeriodType.getPeriodFromIsoString; - import java.awt.image.BufferedImage; import java.io.InputStream; import java.util.Iterator; @@ -41,6 +39,7 @@ import org.hisp.dhis.api.controller.AbstractCrudController; import org.hisp.dhis.api.utils.ContextUtils; import org.hisp.dhis.api.utils.ContextUtils.CacheStrategy; +import org.hisp.dhis.common.DimensionService; import org.hisp.dhis.dataelement.DataElementOperandService; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dxf2.utils.JacksonUtils; @@ -51,8 +50,10 @@ import org.hisp.dhis.mapping.Map; import org.hisp.dhis.mapping.MapView; import org.hisp.dhis.mapping.MappingService; +import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.user.CurrentUserService; import org.springframework.beans.factory.annotation.Autowired; @@ -104,6 +105,9 @@ @Autowired private MapGenerationService mapGenerationService; + + @Autowired + private DimensionService dimensionService; @Autowired private ContextUtils contextUtils; @@ -194,22 +198,22 @@ @Override public void postProcessEntity( Map map ) throws Exception { + I18nFormat format = i18nManager.getI18nFormat(); + for ( MapView view : map.getMapViews() ) { - if ( view != null ) + view.populateAnalyticalProperties(); + + for ( OrganisationUnit organisationUnit : view.getOrganisationUnits() ) { - if ( view.getPeriod() != null ) - { - I18nFormat format = i18nManager.getI18nFormat(); - - view.getPeriod().setName( format.formatPeriod( view.getPeriod() ) ); - } - - if ( view.getParentOrganisationUnit() != null ) - { - String parentUid = view.getParentOrganisationUnit().getUid(); - view.setParentGraph( view.getParentOrganisationUnit().getParentGraph() + "/" + parentUid ); - view.setParentLevel( organisationUnitService.getLevelOfOrganisationUnit( view.getParentOrganisationUnit().getId() ) ); + view.getParentGraphMap().put( organisationUnit.getUid(), organisationUnit.getParentGraph() ); + } + + if ( view.getPeriods() != null && !view.getPeriods().isEmpty() ) + { + for ( Period period : view.getPeriods() ) + { + period.setName( format.formatPeriod( period ) ); } } } @@ -233,54 +237,12 @@ private void mergeMap( Map map ) { - if ( map.getUser() != null ) - { - map.setUser( currentUserService.getCurrentUser() ); - } } private void mergeMapView( MapView view ) { - if ( view.getIndicatorGroup() != null ) - { - view.setIndicatorGroup( indicatorService.getIndicatorGroup( view.getIndicatorGroup().getUid() ) ); - } - - if ( view.getIndicator() != null ) - { - view.setIndicator( indicatorService.getIndicator( view.getIndicator().getUid() ) ); - } - - if ( view.getDataElementGroup() != null ) - { - view.setDataElementGroup( dataElementService.getDataElementGroup( view.getDataElementGroup().getUid() ) ); - } - - if ( view.getDataElement() != null ) - { - view.setDataElement( dataElementService.getDataElement( view.getDataElement().getUid() ) ); - } + dimensionService.mergeAnalyticalObject( view ); - if ( view.getDataElementOperand() != null ) - { - view.setDataElementOperand( operandService.getDataElementOperandByUid( view.getDataElementOperand().getUid() ) ); - } - - if ( view.getPeriod() != null ) - { - view.setPeriod( periodService.reloadPeriod( getPeriodFromIsoString( view.getPeriod().getUid() ) ) ); - } - - if ( view.getParentOrganisationUnit() != null ) - { - view.setParentOrganisationUnit( organisationUnitService.getOrganisationUnit( view.getParentOrganisationUnit().getUid() ) ); - } - - if ( view.getOrganisationUnitLevel() != null ) - { - view.setOrganisationUnitLevel( organisationUnitService.getOrganisationUnitLevel( view.getOrganisationUnitLevel().getUid() ) ); - } - if ( view.getLegendSet() != null ) { view.setLegendSet( mappingService.getMapLegendSet( view.getLegendSet().getUid() ) ); === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/green/green.css' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/green/green.css 2013-09-16 16:18:38 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/green/green.css 2013-09-17 16:22:09 +0000 @@ -61,7 +61,7 @@ top: 0px; left: 0px; right: 0px; - box-shadow: 0 0 2px #000; + box-shadow: 0 0 3px #222; } #headerBanner @@ -215,7 +215,7 @@ left: 0px; padding-top: 6px; border-right: 1px solid #ddd; - box-shadow: #eee 0 0 2px 0; + box-shadow: #ddd 0 0 2px 0; } #leftBarContents === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/india/india.css' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/india/india.css 2013-09-16 16:18:38 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/india/india.css 2013-09-17 16:22:09 +0000 @@ -61,7 +61,7 @@ top: 0px; left: 0px; right: 0px; - box-shadow: 0 0 2px #000; + box-shadow: 0 0 3px #222; } #headerBanner @@ -215,7 +215,7 @@ left: 0px; padding-top: 6px; border-right: 1px solid #ddd; - box-shadow: #eee 0 0 2px 0; + box-shadow: #ddd 0 0 2px 0; } #leftBarContents === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/light_blue/light_blue.css' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/light_blue/light_blue.css 2013-09-16 16:18:38 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/light_blue/light_blue.css 2013-09-17 16:22:09 +0000 @@ -61,7 +61,7 @@ top: 0px; left: 0px; right: 0px; - box-shadow: 0 0 2px #000; + box-shadow: 0 0 3px #222; } #headerBanner @@ -215,7 +215,7 @@ left: 0px; padding-top: 6px; border-right: 1px solid #ddd; - box-shadow: #eee 0 0 2px 0; + box-shadow: #ddd 0 0 2px 0; } #leftBarContents === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/vietnam/vietnam.css' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/vietnam/vietnam.css 2013-09-16 16:18:38 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/vietnam/vietnam.css 2013-09-17 16:22:09 +0000 @@ -61,7 +61,7 @@ top: 0px; left: 0px; right: 0px; - box-shadow: 0 0 2px #000; + box-shadow: 0 0 3px #222; } #headerBanner @@ -215,7 +215,7 @@ left: 0px; padding-top: 6px; border-right: 1px solid #ddd; - box-shadow: #eee 0 0 2px 0; + box-shadow: #ddd 0 0 2px 0; } #leftBarContents === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/pom.xml' --- dhis-2/dhis-web/dhis-web-dashboard-integration/pom.xml 2013-05-31 08:27:38 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/pom.xml 2013-09-17 16:22:09 +0000 @@ -45,6 +45,10 @@ org.hisp.dhis + dhis-service-mapgeneration + + + org.hisp.dhis dhis-service-core