← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7055: TR, removed now obsolote code

 

------------------------------------------------------------
revno: 7055
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-05-27 23:57:33 +0200
message:
  TR, removed now obsolote code
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js


--
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/program/ProgramStageInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2012-05-15 02:36:43 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2012-05-27 21:57:33 +0000
@@ -89,10 +89,13 @@
 
     List<ProgramStageInstance> getProgramStageInstances( Patient patient, Boolean completed );
     
-    Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols, List<PatientIdentifierType> idens, List<String> fixedAttributes, List<PatientAttribute> attributes, List<DataElement> dataElements, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max, I18nFormat format, I18n i18n );
+    Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols,
+        List<PatientIdentifierType> identifiers, List<String> fixedAttributes, List<PatientAttribute> attributes,
+        List<DataElement> dataElements, Map<Integer, String> identifierKeys, Map<Integer, String> attributeKeys,
+        Map<Integer, String> dataElementKeys, Collection<Integer> organisationUnits,
+        int level, Date startDate, Date endDate, boolean descOrder,
+        Integer min, Integer max, I18nFormat format, I18n i18n );
     
-    Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols, List<PatientIdentifierType> idens, List<String> fixedAttributes, List<PatientAttribute> attributes, List<DataElement> dataElements, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, I18nFormat format, I18n i18n );
-
     int countProgramStageInstances( ProgramStage programStage, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate );
     
     List<Grid> getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n );

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2012-05-26 22:54:37 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2012-05-27 21:57:33 +0000
@@ -77,12 +77,13 @@
     List<ProgramStageInstance> get( Patient patient, Boolean completed);
     
     List<ProgramStageInstance> get( ProgramStage programStage, OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max );
+    
     Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols, Map<Integer, OrganisationUnitLevel> orgUnitLevelMap,
         List<PatientIdentifierType> identifiers, List<String> fixedAttributes, List<PatientAttribute> attributes,
         List<DataElement> dataElements, Map<Integer, String> identifierKeys, Map<Integer, String> attributeKeys,
         Map<Integer, String> dataElementKeys, Collection<Integer> orgUnits,
         int level, int maxLevel, Date startDate, Date endDate, boolean descOrder,
-        int min, int max, I18nFormat format, I18n i18n );
+        Integer min, Integer max, I18nFormat format, I18n i18n );
     
     /** Get all values and put it on the map.
      *  @return key: key-word_object-id

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-05-27 21:33:59 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-05-27 21:57:33 +0000
@@ -47,7 +47,6 @@
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patientdatavalue.PatientDataValue;
 import org.hisp.dhis.patientdatavalue.PatientDataValueService;
-import org.hisp.dhis.patientreport.PatientTabularReport;
 import org.hisp.dhis.system.grid.ListGrid;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -201,9 +200,9 @@
     public Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols,
         List<PatientIdentifierType> identifiers, List<String> fixedAttributes, List<PatientAttribute> attributes,
         List<DataElement> dataElements, Map<Integer, String> identifierKeys, Map<Integer, String> attributeKeys,
-        Map<Integer, String> dataElementKeys, Collection<Integer> upperOrgunitIds,
-        Collection<Integer> bottomOrgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc,
-        boolean orderByExecutionDateByAsc, int min, int max, I18nFormat format, I18n i18n )
+        Map<Integer, String> dataElementKeys, Collection<Integer> organisationUnits,
+        int level, Date startDate, Date endDate, boolean descOrder,
+        Integer min, Integer max, I18nFormat format, I18n i18n )
     {
         System.out.println("identifiers "+identifiers);
         System.out.println("fixedAttributes "+fixedAttributes);
@@ -218,31 +217,9 @@
         Map<Integer, OrganisationUnitLevel> orgUnitLevelMap = organisationUnitService.getOrganisationUnitLevelMap();
         
         return programStageInstanceStore.getTabularReport( programStage, hiddenCols, orgUnitLevelMap, identifiers, fixedAttributes, attributes, 
-            dataElements, identifierKeys, attributeKeys, dataElementKeys, upperOrgunitIds, level, maxLevel, startDate, endDate, !orderByOrgunitAsc, min, max, format, i18n );
+            dataElements, identifierKeys, attributeKeys, dataElementKeys, organisationUnits, level, maxLevel, startDate, endDate, descOrder, min, max, format, i18n );
     }
     
-    public Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols,
-        List<PatientIdentifierType> identifiers, List<String> fixedAttributes, List<PatientAttribute> attributes,
-        List<DataElement> dataElements, Map<Integer, String> identifierKeys, Map<Integer, String> attributeKeys,
-        Map<Integer, String> dataElementKeys, Collection<Integer> upperOrgunitIds,
-        Collection<Integer> bottomOrgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc,
-        boolean orderByExecutionDateByAsc, I18nFormat format, I18n i18n )
-    {
-        List<String> keys = new ArrayList<String>();
-        
-        Map<String, String> valuesMap = programStageInstanceStore.get( programStage, keys, identifierKeys,
-            fixedAttributes, attributeKeys, dataElementKeys, upperOrgunitIds, bottomOrgunitIds, startDate, endDate,
-            orderByOrgunitAsc, orderByExecutionDateByAsc );
-
-        if ( keys != null && keys.size() > 0 )
-        {
-            return createTabularGrid( level, hiddenCols, programStage, keys, valuesMap, identifiers, fixedAttributes,
-                attributes, dataElements, startDate, endDate, format, i18n );
-        }
-
-        return new ListGrid();
-    }
-
     @Override
     public int countProgramStageInstances( ProgramStage programStage, Map<Integer, String> searchingIdenKeys,
         Map<Integer, String> searchingAttrKeys, Map<Integer, String> searchingDEKeys, Collection<Integer> orgunitIds,
@@ -320,235 +297,4 @@
 
         return grids;
     }
-
-    // -------------------------------------------------------------------------
-    // Supportive methods
-    // -------------------------------------------------------------------------
-
-    private Grid createTabularGrid( Integer level, List<Boolean> hiddenCols, ProgramStage programStage,
-        List<String> keys, Map<String, String> valuesMap, List<PatientIdentifierType> idens,
-        List<String> fixedAttributes, List<PatientAttribute> attributes, List<DataElement> dataElements,
-        Date startDate, Date endDate, I18nFormat format, I18n i18n )
-    {
-        Grid grid = new ListGrid();
-
-        Program program = programStage.getProgram();
-
-        // ---------------------------------------------------------------------
-        // Create a grid
-        // ---------------------------------------------------------------------
-
-        grid.setTitle( program.getName() + " - " + programStage.getName() );
-        grid.setSubtitle( i18n.getString( "from" ) + " " + format.formatDate( startDate ) + " " + i18n.getString( "to" )
-            + " " + format.formatDate( endDate ) );
-
-        // ---------------------------------------------------------------------
-        // Headers
-        // ---------------------------------------------------------------------
-
-        // Report-date
-        grid.addHeader( new GridHeader( i18n.getString( "report_date" ), false, true ) );
-
-        // Organisation units
-        int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels();
-
-        boolean hasMetaData = !(hiddenCols.size() == idens.size() + attributes.size() + dataElements.size());
-        int index = 0;
-        
-        if ( !hasMetaData )
-        {
-            // Organisation units
-            for ( int i = level; i <= maxLevel; i++ )
-            {
-                grid.addHeader( new GridHeader( organisationUnitService.getOrganisationUnitLevelByLevel( i ).getName(),
-                    false, true ) );
-            }
-
-            // Fixed Attributes
-            if ( fixedAttributes != null && fixedAttributes.size() > 0 )
-            {
-                for ( String fixedAttribute : fixedAttributes )
-                {
-                    grid.addHeader( new GridHeader( i18n.getString( fixedAttribute ), false, true ) );
-                }
-            }
-        }
-        else
-        {
-            for ( int i = level; i <= maxLevel; i++ )
-            {
-                grid.addHeader( new GridHeader( organisationUnitService.getOrganisationUnitLevelByLevel( i ).getName(),
-                    hiddenCols.get( index ), true ) );
-                index++;
-            }
-            // Fixed Attributes
-            if ( fixedAttributes != null && fixedAttributes.size() > 0 )
-            {
-                for ( String fixedAttribute : fixedAttributes )
-                {
-                    grid.addHeader( new GridHeader( i18n.getString( fixedAttribute ), hiddenCols.get( index ), true ) );
-                    index++;
-                }
-            }
-        }
-
-        // Identifier types
-        if ( idens != null && idens.size() > 0 )
-        {
-            for ( PatientIdentifierType identifierType : idens )
-            {
-                grid.addHeader( new GridHeader( identifierType.getName(), hiddenCols.get( index ), true ) );
-                index++;
-            }
-        }
-
-        // Attributes
-        if ( attributes != null && attributes.size() > 0 )
-        {
-            for ( PatientAttribute attribute : attributes )
-            {
-                grid.addHeader( new GridHeader( attribute.getName(), hiddenCols.get( index ), true ) );
-                index++;
-            }
-        }
-
-        // Dataelements
-        if ( dataElements != null && dataElements.size() > 0 )
-        {
-            for ( DataElement dataElement : dataElements )
-            {
-                grid.addHeader( new GridHeader( dataElement.getName(), hiddenCols.get( index ), true ) );
-                index++;
-            }
-        }
-
-        // ---------------------------------------------------------------------
-        // Get patient-identifiers
-        // ---------------------------------------------------------------------
-
-        for ( String key : keys )
-        {
-            grid.addRow();
-
-            // -------------------------------------------------------------
-            // Report-date
-            // -------------------------------------------------------------
-
-            grid.addValue( valuesMap.get( key + "_" + PatientTabularReport.PREFIX_EXECUTION_DATE ) );
-
-            // -------------------------------------------------------------
-            // Add organisation units
-            // -------------------------------------------------------------
-
-            Integer orgunitId = Integer.parseInt( valuesMap.get( key + "_" + PatientTabularReport.PREFIX_ORGUNIT ) );
-            Map<Integer, String> hierarchyOrgunit = getHierarchyOrgunit( orgunitId, level );
-
-            for ( int i = level; i <= maxLevel; i++ )
-            {
-                if ( hierarchyOrgunit.get( i ) != null )
-                {
-                    grid.addValue( hierarchyOrgunit.get( i ) );
-                }
-                else
-                {
-                    grid.addValue( "" );
-                }
-            }
-
-            // -------------------------------------------------------------
-            // Fixed Attributes
-            // -------------------------------------------------------------
-
-            if ( fixedAttributes != null && fixedAttributes.size() > 0 )
-            {
-                for ( String fixedAttr : fixedAttributes )
-                {
-                    grid.addValue( valuesMap.get( key + "_" + PatientTabularReport.PREFIX_FIXED_ATTRIBUTE + "_"
-                        + fixedAttr ) );
-                }
-            }
-
-            // -------------------------------------------------------------
-            // Add patient-identifiers
-            // -------------------------------------------------------------
-
-            for ( PatientIdentifierType identifierType : idens )
-            {
-                String value = valuesMap.get( key + "_" + PatientTabularReport.PREFIX_IDENTIFIER_TYPE + "_"
-                    + identifierType.getId() );
-                value = (value == null) ? "" : value;
-                grid.addValue( value );
-            }
-
-            // ---------------------------------------------------------------------
-            // Get patient-attribute-values
-            // ---------------------------------------------------------------------
-
-            for ( PatientAttribute attribute : attributes )
-            {
-                String value = valuesMap.get( key + "_" + PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE + "_"
-                    + attribute.getId() );
-
-                value = (value == null) ? "" : value;
-
-                if ( attribute.getValueType().equals( PatientAttribute.TYPE_BOOL ) )
-                {
-                    if ( value.equals( "true" ) )
-                    {
-                        value = i18n.getString( "yes" );
-                    }
-                    else if ( value.equals( "false" ) )
-                    {
-                        value = i18n.getString( "no" );
-                    }
-                }
-
-                grid.addValue( value );
-            }
-
-            for ( DataElement dataElement : dataElements )
-            {
-                String value = valuesMap.get( key + "_" + PatientTabularReport.PREFIX_DATA_ELEMENT + "_"
-                    + dataElement.getId() );
-                value = (value == null) ? "" : value;
-                if ( dataElement.getType().equals( DataElement.VALUE_TYPE_BOOL ) )
-                {
-                    if ( value.equals( "true" ) )
-                    {
-                        value = i18n.getString( "yes" );
-                    }
-                    else if ( value.equals( "false" ) )
-                    {
-                        value = i18n.getString( "no" );
-                    }
-                }
-                
-                grid.addValue( value );
-            }
-
-        }
-
-        return grid;
-    }
-
-    private Map<Integer, String> getHierarchyOrgunit( int orgunitid, int level )
-    {
-        OrganisationUnit orgunit = organisationUnitService.getOrganisationUnit( orgunitid );
-
-        Map<Integer, String> hierarchyOrgunit = new HashMap<Integer, String>();
-
-        hierarchyOrgunit.put( organisationUnitService.getLevelOfOrganisationUnit( orgunit.getId() ), orgunit.getName() );
-
-        orgunit = orgunit.getParent();
-
-        while ( orgunit != null && organisationUnitService.getLevelOfOrganisationUnit( orgunit.getId() ) >= level )
-        {
-            hierarchyOrgunit.put( organisationUnitService.getLevelOfOrganisationUnit( orgunit.getId() ), orgunit
-                .getName() );
-
-            orgunit = orgunit.getParent();
-        }
-
-        return hierarchyOrgunit;
-    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-05-27 21:33:59 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-05-27 21:57:33 +0000
@@ -215,7 +215,7 @@
         List<DataElement> dataElements, Map<Integer, String> identifierKeys, Map<Integer, String> attributeKeys,
         Map<Integer, String> dataElementKeys, Collection<Integer> orgUnits,
         int level, int maxLevel, Date startDate, Date endDate, boolean descOrder,
-        int min, int max, I18nFormat format, I18n i18n )
+        Integer min, Integer max, I18nFormat format, I18n i18n )
     {
         Grid grid = new ListGrid();
         
@@ -285,8 +285,8 @@
         
         sql += "psi.executiondate ";
         sql += descOrder ? "desc " : "";
-        sql += "offset 0 limit 50 ";
-        sql += ") as tabular "; //TODO page
+        sql += min != null && max != null ? "offset 0 limit 50 " : ""; //TODO page size
+        sql += ") as tabular ";
         
         String operator = "where ";
         

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-05-26 22:54:37 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-05-27 21:57:33 +0000
@@ -286,41 +286,21 @@
         // Get orgunitIds
         // ---------------------------------------------------------------------
 
-        OrganisationUnit selectedOrgunit = organisationUnitService.getOrganisationUnit( orgunitId );
-
-        Set<Integer> upperOrgunitIds = new HashSet<Integer>();
-
-        Set<Integer> bottomOrgunitIds = new HashSet<Integer>();
-
-        int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels() - 1;
-        
+        Set<Integer> organisationUnits = new HashSet<Integer>();
+
         if ( facilityLB.equals( "selected" ) )
         {
-            upperOrgunitIds.add( orgunitId );
+            organisationUnits.add( orgunitId );
         }
         else if ( facilityLB.equals( "childrenOnly" ) )
         {
-            Set<OrganisationUnit> children = selectedOrgunit.getChildren();
-
-            for ( OrganisationUnit child : children )
-            {
-                upperOrgunitIds.add( child.getId() );
-            }
+            OrganisationUnit selectedOrgunit = organisationUnitService.getOrganisationUnit( orgunitId );
+            organisationUnits.addAll( new HashSet<Integer>( ConversionUtils.getIdentifiers( OrganisationUnit.class, selectedOrgunit.getChildren() ) ) );
         }
         else
         {
-            OrganisationUnitHierarchy hierarchy = organisationUnitService.getOrganisationUnitHierarchy();
-
-            Set<Integer> childOrgUnitIdentifiers = hierarchy.getChildren( selectedOrgunit.getId() );
-            upperOrgunitIds.add( orgunitId );
-            upperOrgunitIds.addAll( childOrgUnitIdentifiers );
-            
-            // Get bottom org unit
-            
-            Collection<OrganisationUnit> orgUnits = organisationUnitService.getOrganisationUnitsAtLevel( maxLevel, selectedOrgunit );
-            bottomOrgunitIds = new HashSet<Integer>( ConversionUtils.getIdentifiers( OrganisationUnit.class, orgUnits ) );
-            
-            //upperOrgunitIds.removeAll( bottomOrgunitIds ); //TODO fix
+            Set<Integer> children = organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunitId );
+            organisationUnits.addAll( children );
         }
 
         // ---------------------------------------------------------------------
@@ -345,12 +325,8 @@
 
         if ( type == null ) // Tabular report
         {
-            Set<Integer> orgunitIds = new HashSet<Integer>();
-            orgunitIds.addAll( upperOrgunitIds );
-            orgunitIds.addAll( bottomOrgunitIds );
-
             int totalRecords = programStageInstanceService.countProgramStageInstances( programStage, searchingIdenKeys,
-                searchingAttrKeys, searchingDEKeys, orgunitIds, startValue, endValue );
+                searchingAttrKeys, searchingDEKeys, organisationUnits, startValue, endValue );
 
             total = getNumberOfPages( totalRecords );
             
@@ -359,15 +335,15 @@
             
             grid = programStageInstanceService.getTabularReport( programStage, hiddenCols, identifierTypes,
                 fixedAttributes, patientAttributes, dataElements, searchingIdenKeys, searchingAttrKeys,
-                searchingDEKeys, upperOrgunitIds, bottomOrgunitIds, level, startValue, endValue, orderByOrgunitAsc,
-                orderByExecutionDateByAsc, paging.getStartPos(), paging.getPageSize(), format, i18n );
+                searchingDEKeys, organisationUnits, level, startValue, endValue, !orderByOrgunitAsc,
+                paging.getStartPos(), paging.getPageSize(), format, i18n );
         }
         else // Download as Excel
         {
             grid = programStageInstanceService.getTabularReport( programStage, hiddenCols, identifierTypes,
-                fixedAttributes, patientAttributes, dataElements, searchingIdenKeys, searchingAttrKeys, searchingDEKeys,
-                upperOrgunitIds, bottomOrgunitIds, level, startValue, endValue, orderByOrgunitAsc,
-                orderByExecutionDateByAsc, format, i18n );
+                fixedAttributes, patientAttributes, dataElements, searchingIdenKeys, searchingAttrKeys,
+                searchingDEKeys, organisationUnits, level, startValue, endValue, !orderByOrgunitAsc,
+                null, null, format, i18n );
         }
 
         System.out.println();

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-05-27 21:33:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-05-27 21:57:33 +0000
@@ -1094,11 +1094,7 @@
 			// Data element columns
 			
 			TR.cmp.params.dataelement.selected.store.each( function(r) {
-				++index;
-				console.log(TR.value.columns);
-				console.log(r);
-				
-				cols[index] = {
+				cols[++index] = {
 					header: TR.value.columns[index].name, 
 					dataIndex: 'col' + index,
 					height: TR.conf.layout.east_gridcolumn_height,