dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02339
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 791: Simplified some methods.
------------------------------------------------------------
revno: 791
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Mon 2009-09-28 18:16:47 +0200
message:
Simplified some methods.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.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/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2009-05-28 11:18:43 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2009-09-28 16:16:47 +0000
@@ -239,11 +239,40 @@
return true;
}
+ /**
+ * Tests whether more than one aggregation level exists for the DataElement.
+ */
public boolean hasAggregationLevels()
{
return aggregationLevels != null && aggregationLevels.size() > 0;
}
+ /**
+ * Tests whether the DataElement is associated with a DataELementCategoryCombo
+ * with more than one DataElementCategory, or any DataElementCategory with more
+ * than one DataElementCategoryOption.
+ */
+ public boolean isMultiDimensional()
+ {
+ if ( categoryCombo != null )
+ {
+ if ( categoryCombo.getCategories().size() > 1 )
+ {
+ return true;
+ }
+
+ for ( DataElementCategory category : categoryCombo.getCategories() )
+ {
+ if ( category.getCategoryOptions().size() > 1 )
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java 2009-09-28 09:42:06 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java 2009-09-28 16:16:47 +0000
@@ -27,8 +27,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_SUM;
+import static org.hisp.dhis.dataelement.DataElement.TYPE_BOOL;
+import static org.hisp.dhis.dataelement.DataElement.TYPE_INT;
+import static org.hisp.dhis.dataelement.DataElement.TYPE_STRING;
import static org.hisp.dhis.expression.Expression.SEPARATOR;
-import static org.hisp.dhis.dataelement.DataElement.*;
import java.util.ArrayList;
import java.util.Collection;
@@ -44,7 +47,6 @@
import org.hisp.dhis.customvalue.CustomValueService;
import org.hisp.dhis.dataelement.CalculatedDataElement;
import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategory;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryOptionComboService;
@@ -135,48 +137,20 @@
public boolean hasMultiDimensionalDataElement( DataSet dataSet )
{
- int numberOfTotalColumns = 1;
-
- if ( dataSet.getDataElements().size() > 0 )
+ for ( DataElement element : dataSet.getDataElements() )
{
- for ( DataElement de : dataSet.getDataElements() )
+ if ( element.isMultiDimensional() )
{
- for ( DataElementCategory category : de.getCategoryCombo().getCategories() )
- {
- numberOfTotalColumns = numberOfTotalColumns * category.getCategoryOptions().size();
- }
-
- if ( numberOfTotalColumns > 1 )
- {
- return true;
- }
+ return true;
}
}
-
+
return false;
}
public String getScreenType( DataSet dataSet )
{
- int numberOfTotalColumns = 1;
-
- if ( dataSet.getDataElements().size() > 0 )
- {
- for ( DataElement de : dataSet.getDataElements() )
- {
- for ( DataElementCategory category : de.getCategoryCombo().getCategories() )
- {
- numberOfTotalColumns = numberOfTotalColumns * category.getCategoryOptions().size();
- }
-
- if ( numberOfTotalColumns > 1 )
- {
- return MULTI_DIMENSIONAL_FORM;
- }
- }
- }
-
- return DEFAULT_FORM;
+ return hasMultiDimensionalDataElement( dataSet ) ? MULTI_DIMENSIONAL_FORM : DEFAULT_FORM;
}
public Collection<Integer> getAllCalculatedDataElements( DataSet dataSet )
@@ -210,12 +184,10 @@
{
cde = (CalculatedDataElement) dataElement;
- if ( cde.isSaved() )
+ if ( !cde.isSaved() )
{
- continue;
- }
-
- calculatedDataElementMap.put( cde, dataElementService.getDataElementFactors( cde ) );
+ calculatedDataElementMap.put( cde, dataElementService.getDataElementFactors( cde ) );
+ }
}
}
@@ -224,7 +196,7 @@
public boolean hasSection( DataSet dataSet )
{
- List<Section> sections = (List<Section>) sectionService.getSectionByDataSet( dataSet );
+ Collection<Section> sections = sectionService.getSectionByDataSet( dataSet );
return sections.size() != 0;
}
@@ -267,14 +239,13 @@
factor = factorMap.get( operandId );
String dataElementIdString = operandId.substring( 0, operandId.indexOf( SEPARATOR ) );
- String optionComboIdString = operandId.substring( operandId.indexOf( SEPARATOR ) + 1, operandId
- .length() );
+ String optionComboIdString = operandId.substring( operandId.indexOf( SEPARATOR ) + 1, operandId.length() );
- DataElement de = dataElementService.getDataElement( Integer.parseInt( dataElementIdString ) );
+ DataElement element = dataElementService.getDataElement( Integer.parseInt( dataElementIdString ) );
DataElementCategoryOptionCombo optionCombo = dataElementCategoryOptionComboService
.getDataElementCategoryOptionCombo( Integer.parseInt( optionComboIdString ) );
- dataValue = dataValueService.getDataValue( organisationUnit, de, period, optionCombo );
+ dataValue = dataValueService.getDataValue( organisationUnit, element, period, optionCombo );
if ( dataValue != null )
{