dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #01442
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 444: Updated indian validation module
------------------------------------------------------------
revno: 444
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Wed 2009-07-08 14:15:19 +0200
message:
Updated indian validation module
modified:
local/in/dhis-web-validationrule-in/pom.xml
local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/DetailedValidationAnalysisResultAction.java
local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/ExportToExcelAverageVAAction.java
local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/ExportToExcelDetailedVAAction.java
local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/GetFilteredDataElementsActionIN.java
local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java
local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/ValidationByAverageActionIN.java
local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/util/ValidationResultWorkbookGenerator.java
local/in/dhis-web-validationrule-in/src/main/resources/META-INF/dhis/beans.xml
=== modified file 'local/in/dhis-web-validationrule-in/pom.xml'
--- local/in/dhis-web-validationrule-in/pom.xml 2009-07-08 10:51:52 +0000
+++ local/in/dhis-web-validationrule-in/pom.xml 2009-07-08 12:15:19 +0000
@@ -51,6 +51,10 @@
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-support-system</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-support-webwork</artifactId>
+ </dependency>
<!-- India -->
@@ -59,15 +63,7 @@
<artifactId>dhis-service-aggregationengine-default</artifactId>
<version>${version}</version>
</dependency>
-
-
- <!-- WebWork -->
-
- <dependency>
- <groupId>com.opensymphony</groupId>
- <artifactId>webwork</artifactId>
- </dependency>
-
+
<!-- Other -->
<dependency>
=== modified file 'local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/DetailedValidationAnalysisResultAction.java'
--- local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/DetailedValidationAnalysisResultAction.java 2009-07-08 09:58:18 +0000
+++ local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/DetailedValidationAnalysisResultAction.java 2009-07-08 12:15:19 +0000
@@ -1,7 +1,6 @@
package org.hisp.dhis.validationrule.action;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
@@ -14,6 +13,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
+import org.amplecode.quick.StatementManager;
import org.hisp.dhis.aggregation.AggregationService;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -21,7 +21,6 @@
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.expression.Expression;
import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.jdbc.StatementManager;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.organisationunit.comparator.OrganisationUnitShortNameComparator;
@@ -38,108 +37,125 @@
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;
-public class DetailedValidationAnalysisResultAction extends ActionSupport
+public class DetailedValidationAnalysisResultAction
+ extends ActionSupport
{
private static final String NULL_REPLACEMENT = "0";
-
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
private StatementManager statementManager;
+
public void setStatementManager( StatementManager statementManager )
{
this.statementManager = statementManager;
}
private DataElementService dataElementService;
+
public void setDataElementService( DataElementService dataElementService )
{
this.dataElementService = dataElementService;
}
private AggregationService aggregationService;
+
public void setAggregationService( AggregationService aggregationService )
{
this.aggregationService = aggregationService;
}
- private DataElementCategoryOptionComboService dataElementCategoryOptionComboService;
- public void setDataElementCategoryOptionComboService( DataElementCategoryOptionComboService dataElementCategoryOptionComboService )
+ private DataElementCategoryOptionComboService dataElementCategoryOptionComboService;
+
+ public void setDataElementCategoryOptionComboService(
+ DataElementCategoryOptionComboService dataElementCategoryOptionComboService )
{
this.dataElementCategoryOptionComboService = dataElementCategoryOptionComboService;
}
private ValidationRuleService validationRuleService;
+
public void setValidationRuleService( ValidationRuleService validationRuleService )
{
this.validationRuleService = validationRuleService;
}
-
+
private I18nFormat format;
+
public void setFormat( I18nFormat format )
{
this.format = format;
}
private SelectionTreeManager selectionTreeManager;
+
public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
{
this.selectionTreeManager = selectionTreeManager;
}
-
+
private OrganisationUnitService organisationUnitService;
+
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
{
this.organisationUnitService = organisationUnitService;
}
-
+
private PeriodService periodService;
+
public void setPeriodService( PeriodService periodService )
{
this.periodService = periodService;
}
-
+
// -------------------------------------------------------------------------
// Input/output
- // -------------------------------------------------------------------------
-
- private String detailOption;
+ // -------------------------------------------------------------------------
+
+ private String detailOption;
+
public void setDetailOption( String detailOption )
{
this.detailOption = detailOption;
}
private String vRule;
+
public void setVRule( String rule )
{
vRule = rule;
}
- private String avgOption;
+ private String avgOption;
+
public void setAvgOption( String avgOption )
{
this.avgOption = avgOption;
}
- private String selOrgUnit;
+ private String selOrgUnit;
+
public void setSelOrgUnit( String selOrgUnit )
{
this.selOrgUnit = selOrgUnit;
}
private String startDate;
+
public String getStartDate()
{
return startDate;
}
-
+
public void setStartDate( String startDate )
{
this.startDate = startDate;
}
private String endDate;
+
public String getEndDate()
{
return endDate;
@@ -149,94 +165,101 @@
{
this.endDate = endDate;
}
-
+
private String includeChildren;
+
public void setIncludeChildren( String includeChildren )
{
this.includeChildren = includeChildren;
- }
-
+ }
private List<OrganisationUnit> selOrgUnitList;
+
public List<OrganisationUnit> getSelOrgUnitList()
{
return selOrgUnitList;
}
private List<ValidationRule> validationRuleList;
+
public List<ValidationRule> getValidationRuleList()
{
return validationRuleList;
}
- private List<Period> selPeriodList;
+ private List<Period> selPeriodList;
+
public List<Period> getSelPeriodList()
{
return selPeriodList;
}
- private Map<OrganisationUnit, Map<ValidationRule,List<String>>> orgUnitResultMap;
+ private Map<OrganisationUnit, Map<ValidationRule, List<String>>> orgUnitResultMap;
+
public Map<OrganisationUnit, Map<ValidationRule, List<String>>> getOrgUnitResultMap()
{
return orgUnitResultMap;
}
- private Map<OrganisationUnit, Map<ValidationRule,List<String>>> orgUnitColorMap;
+ private Map<OrganisationUnit, Map<ValidationRule, List<String>>> orgUnitColorMap;
+
public Map<OrganisationUnit, Map<ValidationRule, List<String>>> getOrgUnitColorMap()
{
return orgUnitColorMap;
}
-
+
private int validationRuleGroupId;
+
public void setValidationRuleGroupId( int validationRuleGroupId )
{
this.validationRuleGroupId = validationRuleGroupId;
}
- public int getValidationRuleGroupId( )
+
+ public int getValidationRuleGroupId()
{
return validationRuleGroupId;
}
-
+
// -------------------------------------------------------------------------
// Execute
// -------------------------------------------------------------------------
-
- @SuppressWarnings( "unchecked" )
+
+ @SuppressWarnings( "unchecked" )
public String execute()
{
statementManager.initialise();
-
+
// OrgansationUnit Info
-
+
selOrgUnitList = new ArrayList<OrganisationUnit>();
-
+
List<OrganisationUnit> sources = new ArrayList<OrganisationUnit>();
-
- if(detailOption != null && detailOption.equalsIgnoreCase( "yes" ))
+
+ if ( detailOption != null && detailOption.equalsIgnoreCase( "yes" ) )
{
sources.add( organisationUnitService.getOrganisationUnit( Integer.parseInt( selOrgUnit ) ) );
includeChildren = "immChild";
}
- else if(avgOption != null && avgOption.equalsIgnoreCase( "yes" ))
+ else if ( avgOption != null && avgOption.equalsIgnoreCase( "yes" ) )
{
sources.add( organisationUnitService.getOrganisationUnit( Integer.parseInt( selOrgUnit ) ) );
includeChildren = "false";
}
else
{
- sources = new ArrayList<OrganisationUnit>(selectionTreeManager.getSelectedOrganisationUnits());
+ sources = new ArrayList<OrganisationUnit>( selectionTreeManager.getSelectedOrganisationUnits() );
}
-
+
Collections.sort( sources, new OrganisationUnitShortNameComparator() );
if ( includeChildren.equalsIgnoreCase( "true" ) )
- {
+ {
for ( OrganisationUnit source : sources )
{
selOrgUnitList.addAll( getChildOrgUnitTree( source ) );
}
}
- else if( includeChildren.equalsIgnoreCase( "false" ) )
+ else if ( includeChildren.equalsIgnoreCase( "false" ) )
{
selOrgUnitList.addAll( sources );
}
@@ -248,62 +271,63 @@
List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>( source.getChildren() );
Collections.sort( organisationUnits, new OrganisationUnitShortNameComparator() );
selOrgUnitList.addAll( organisationUnits );
- }
+ }
}
-
+
// ValidationRule Info
- validationRuleList = new ArrayList<ValidationRule>();
- ValidationRuleGroup vrg = new ValidationRuleGroup();
- if(detailOption == null)
+ validationRuleList = new ArrayList<ValidationRule>();
+ ValidationRuleGroup vrg = new ValidationRuleGroup();
+ if ( detailOption == null )
{
- if( (validationRuleGroupId < 0 ) )
+ if ( (validationRuleGroupId < 0) )
{
- validationRuleList = new ArrayList<ValidationRule>( validationRuleService.getAllValidationRules());
+ validationRuleList = new ArrayList<ValidationRule>( validationRuleService.getAllValidationRules() );
}
else
{
- System.out.println("validationRuleGroupId == "+validationRuleGroupId);
+ System.out.println( "validationRuleGroupId == " + validationRuleGroupId );
vrg = validationRuleService.getValidationRuleGroup( validationRuleGroupId );
- validationRuleList.addAll( (Collection<? extends ValidationRule>) vrg.getMembers() );
- }
- }
+ validationRuleList.addAll( vrg.getMembers() );
+ }
+ }
else
{
ValidationRule vr = validationRuleService.getValidationRule( Integer.parseInt( vRule ) );
validationRuleList.add( vr );
- //validationRuleList = new ArrayList<ValidationRule>( validationRuleService.getAllValidationRules());
+ // validationRuleList = new ArrayList<ValidationRule>(
+ // validationRuleService.getAllValidationRules());
}
-
+
// Period Info
- Date sDate = format.parseDate( startDate );
- Date eDate = format.parseDate( endDate );
+ Date sDate = format.parseDate( startDate );
+ Date eDate = format.parseDate( endDate );
selPeriodList = new ArrayList<Period>();
- List<Period> periodList = new ArrayList<Period>(periodService.getIntersectingPeriods( sDate, eDate ));
+ List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriods( sDate, eDate ) );
Iterator<Period> it1 = periodList.iterator();
- while(it1.hasNext())
+ while ( it1.hasNext() )
{
- Period p1 = (Period) it1.next();
- if(p1.getPeriodType().getName().equalsIgnoreCase( "monthly" ))
+ Period p1 = it1.next();
+ if ( p1.getPeriodType().getName().equalsIgnoreCase( "monthly" ) )
{
selPeriodList.add( p1 );
- }
+ }
}
Collections.sort( selPeriodList, new PeriodStartDateComparator() );
-
+
orgUnitResultMap = new HashMap<OrganisationUnit, Map<ValidationRule, List<String>>>();
orgUnitColorMap = new HashMap<OrganisationUnit, Map<ValidationRule, List<String>>>();
-
+
Iterator sourceIterator = selOrgUnitList.iterator();
- while(sourceIterator.hasNext())
+ while ( sourceIterator.hasNext() )
{
OrganisationUnit orgUnit = (OrganisationUnit) sourceIterator.next();
-
+
Map<ValidationRule, List<String>> vrResultMap = new HashMap<ValidationRule, List<String>>();
Map<ValidationRule, List<String>> vrColorMap = new HashMap<ValidationRule, List<String>>();
-
+
Iterator validationIterator = validationRuleList.iterator();
- while(validationIterator.hasNext())
+ while ( validationIterator.hasNext() )
{
ValidationRule valRule = (ValidationRule) validationIterator.next();
Expression leftExpression = valRule.getLeftSide();
@@ -311,181 +335,184 @@
List<String> tempVRResultList = new ArrayList<String>();
List<String> tempVRColorList = new ArrayList<String>();
- Iterator periodIterator = selPeriodList.iterator();
- while(periodIterator.hasNext())
+ Iterator periodIterator = selPeriodList.iterator();
+ while ( periodIterator.hasNext() )
{
Period period = (Period) periodIterator.next();
-
- Double leftSide = getResultValue( leftExpression.getExpression(), period.getStartDate(), period.getEndDate(), orgUnit);
- Double rightSide = getResultValue( rightExpression.getExpression(), period.getStartDate(), period.getEndDate(), orgUnit);
-
- if( leftSide == null) leftSide = 0.0;
- if( rightSide == null ) rightSide = 0.0;
-
- String tempString = ""+leftSide;
- System.out.println("*************************************************");
- System.out.println(valRule.getName()+" ---- "+valRule.getOperator());
- if(valRule.getOperator().equalsIgnoreCase( ValidationRule.OPERATOR_EQUAL ))
+
+ Double leftSide = getResultValue( leftExpression.getExpression(), period.getStartDate(), period
+ .getEndDate(), orgUnit );
+ Double rightSide = getResultValue( rightExpression.getExpression(), period.getStartDate(), period
+ .getEndDate(), orgUnit );
+
+ if ( leftSide == null )
+ leftSide = 0.0;
+ if ( rightSide == null )
+ rightSide = 0.0;
+
+ String tempString = "" + leftSide;
+ System.out.println( "*************************************************" );
+ System.out.println( valRule.getName() + " ---- " + valRule.getOperator() );
+ if ( valRule.getOperator().equalsIgnoreCase( ValidationRule.OPERATOR_EQUAL ) )
{
- if(leftSide.doubleValue() == rightSide.doubleValue())
+ if ( leftSide.doubleValue() == rightSide.doubleValue() )
{
tempVRColorList.add( "green" );
- System.out.print("green green : ");
+ System.out.print( "green green : " );
}
else
{
tempVRColorList.add( "red" );
- System.out.print("red red : ");
+ System.out.print( "red red : " );
}
-
+
tempString += "=";
- }
- else if(valRule.getOperator().equalsIgnoreCase( ValidationRule.OPERATOR_NOT_EQUAL ))
+ }
+ else if ( valRule.getOperator().equalsIgnoreCase( ValidationRule.OPERATOR_NOT_EQUAL ) )
{
- if(leftSide.doubleValue() != rightSide.doubleValue())
+ if ( leftSide.doubleValue() != rightSide.doubleValue() )
{
tempVRColorList.add( "green" );
- System.out.print("green : ");
+ System.out.print( "green : " );
}
else
{
tempVRColorList.add( "red" );
- System.out.print("red : ");
+ System.out.print( "red : " );
}
tempString += "!=";
}
- else if(valRule.getOperator().equalsIgnoreCase( ValidationRule.OPERATOR_GREATER ))
+ else if ( valRule.getOperator().equalsIgnoreCase( ValidationRule.OPERATOR_GREATER ) )
{
- if(leftSide.doubleValue() > rightSide.doubleValue())
+ if ( leftSide.doubleValue() > rightSide.doubleValue() )
{
tempVRColorList.add( "green" );
- System.out.print("green : ");
+ System.out.print( "green : " );
}
else
{
tempVRColorList.add( "red" );
- System.out.print("red : ");
+ System.out.print( "red : " );
}
tempString += ">";
}
- else if(valRule.getOperator().equalsIgnoreCase( ValidationRule.OPERATOR_GREATER_EQUAL ))
+ else if ( valRule.getOperator().equalsIgnoreCase( ValidationRule.OPERATOR_GREATER_EQUAL ) )
{
- if(leftSide.doubleValue() >= rightSide.doubleValue())
+ if ( leftSide.doubleValue() >= rightSide.doubleValue() )
{
tempVRColorList.add( "green" );
- System.out.print("green : ");
+ System.out.print( "green : " );
}
else
{
tempVRColorList.add( "red" );
- System.out.print("red : ");
+ System.out.print( "red : " );
}
tempString += ">=";
}
- else if(valRule.getOperator().equalsIgnoreCase( ValidationRule.OPERATOR_LESSER ))
+ else if ( valRule.getOperator().equalsIgnoreCase( ValidationRule.OPERATOR_LESSER ) )
{
- if(leftSide.doubleValue() < rightSide.doubleValue())
+ if ( leftSide.doubleValue() < rightSide.doubleValue() )
{
tempVRColorList.add( "green" );
- System.out.print("green : ");
+ System.out.print( "green : " );
}
else
{
tempVRColorList.add( "red" );
- System.out.print("red : ");
+ System.out.print( "red : " );
}
tempString += "<";
}
- else if(valRule.getOperator().equalsIgnoreCase( ValidationRule.OPERATOR_LESSER_EQUAL ))
+ else if ( valRule.getOperator().equalsIgnoreCase( ValidationRule.OPERATOR_LESSER_EQUAL ) )
{
- if(leftSide.doubleValue() <= rightSide.doubleValue())
+ if ( leftSide.doubleValue() <= rightSide.doubleValue() )
{
tempVRColorList.add( "green" );
- System.out.print("green : ");
+ System.out.print( "green : " );
}
else
{
tempVRColorList.add( "red" );
- System.out.print("red : ");
+ System.out.print( "red : " );
}
tempString += "<=";
}
-
- //System.out.println("Operator : "+valRule.getOperator());
+
+ // System.out.println("Operator : "+valRule.getOperator());
tempString += rightSide;
- System.out.println(tempString + " : " );
+ System.out.println( tempString + " : " );
tempVRResultList.add( tempString );
}// Period While end
vrResultMap.put( valRule, tempVRResultList );
vrColorMap.put( valRule, tempVRColorList );
-
+
}// ValidationRule While end
-
+
orgUnitResultMap.put( orgUnit, vrResultMap );
- orgUnitColorMap.put( orgUnit, vrColorMap);
+ orgUnitColorMap.put( orgUnit, vrColorMap );
}// Source While end
ActionContext ctx = ActionContext.getContext();
HttpServletRequest req = (HttpServletRequest) ctx.get( ServletActionContext.HTTP_REQUEST );
HttpSession session = req.getSession();
-
+
session.setAttribute( "orgUnitResultMap", orgUnitResultMap );
session.setAttribute( "orgUnitColorMap", orgUnitColorMap );
session.setAttribute( "selPeriodList", selPeriodList );
session.setAttribute( "selOrgUnitList", selOrgUnitList );
session.setAttribute( "validationRuleList", validationRuleList );
-
+
statementManager.destroy();
- if(detailOption != null && detailOption.equalsIgnoreCase( "yes" ))
+ if ( detailOption != null && detailOption.equalsIgnoreCase( "yes" ) )
return "detForOneVR";
-
- return SUCCESS;
+
+ return SUCCESS;
}
-
-
-
-
- private double getResultValue( String formula, Date startDate, Date endDate, OrganisationUnit organisationUnit)
- {
+
+ private double getResultValue( String formula, Date startDate, Date endDate, OrganisationUnit organisationUnit )
+ {
try
- {
+ {
int deFlag1 = 0;
int deFlag2 = 0;
Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
-
+
Matcher matcher = pattern.matcher( formula );
- StringBuffer buffer = new StringBuffer();
-
+ StringBuffer buffer = new StringBuffer();
+
while ( matcher.find() )
{
String replaceString = matcher.group();
-
+
replaceString = replaceString.replaceAll( "[\\[\\]]", "" );
- String optionComboIdStr = replaceString.substring( replaceString.indexOf('.')+1, replaceString.length() );
-
- replaceString = replaceString.substring( 0, replaceString.indexOf('.') );
-
+ String optionComboIdStr = replaceString.substring( replaceString.indexOf( '.' ) + 1, replaceString
+ .length() );
+
+ replaceString = replaceString.substring( 0, replaceString.indexOf( '.' ) );
+
int dataElementId = Integer.parseInt( replaceString );
- int optionComboId = Integer.parseInt( optionComboIdStr );
-
-
- DataElement dataElement = dataElementService.getDataElement( dataElementId );
- DataElementCategoryOptionCombo optionCombo = dataElementCategoryOptionComboService.getDataElementCategoryOptionCombo( optionComboId );
-
- if(dataElement == null || optionCombo == null)
+ int optionComboId = Integer.parseInt( optionComboIdStr );
+
+ DataElement dataElement = dataElementService.getDataElement( dataElementId );
+ DataElementCategoryOptionCombo optionCombo = dataElementCategoryOptionComboService
+ .getDataElementCategoryOptionCombo( optionComboId );
+
+ if ( dataElement == null || optionCombo == null )
{
replaceString = NULL_REPLACEMENT;
matcher.appendReplacement( buffer, replaceString );
continue;
}
- if(dataElement.getType().equalsIgnoreCase( "int" ))
- {
- double aggregatedValue = aggregationService.getAggregatedDataValue( dataElement, optionCombo, startDate, endDate, organisationUnit );
- //System.out.println(aggregatedValue+" ---- "+dataElement.getName());
+ if ( dataElement.getType().equalsIgnoreCase( "int" ) )
+ {
+ double aggregatedValue = aggregationService.getAggregatedDataValue( dataElement, optionCombo,
+ startDate, endDate, organisationUnit );
+ // System.out.println(aggregatedValue+" ---- "+dataElement.getName());
if ( aggregatedValue == AggregationService.NO_VALUES_REGISTERED )
{
replaceString = NULL_REPLACEMENT;
@@ -497,7 +524,7 @@
}
}
else
- {
+ {
replaceString = NULL_REPLACEMENT;
}
@@ -507,55 +534,57 @@
matcher.appendTail( buffer );
String resultValue = "";
- if(deFlag1 == 0)
+ if ( deFlag1 == 0 )
{
double d = 0.0;
try
{
- //System.out.println("Expression : "+buffer.toString());
- if(buffer.toString().contains( "/0.0" ) || buffer.toString().contains( "/0" ) || buffer.toString().contains( "/((0.0" ) || buffer.toString().contains( "/((0" ))
+ // System.out.println("Expression : "+buffer.toString());
+ if ( buffer.toString().contains( "/0.0" ) || buffer.toString().contains( "/0" )
+ || buffer.toString().contains( "/((0.0" ) || buffer.toString().contains( "/((0" ) )
d = 0.0;
else
d = 0;
- d = MathUtils.calculateExpression(buffer.toString());
- }
- catch(ArithmeticException e)
- {
- d = 0.0;
- System.out.println("Divide By Zero ");
- }
- catch(Exception e)
- {
- d = 0.0;
- System.out.println("Divide By Zero ");
- }
- if(d == -1) d = 0.0;
- else
- {
- d = Math.round( d * Math.pow( 10, 2 ) ) / Math.pow( 10, 2 );
- resultValue = ""+ (int)d;
- }
-
- if(deFlag2 == 0)
+ d = MathUtils.calculateExpression( buffer.toString() );
+ }
+ catch ( ArithmeticException e )
+ {
+ d = 0.0;
+ System.out.println( "Divide By Zero " );
+ }
+ catch ( Exception e )
+ {
+ d = 0.0;
+ System.out.println( "Divide By Zero " );
+ }
+ if ( d == -1 )
+ d = 0.0;
+ else
+ {
+ d = Math.round( d * Math.pow( 10, 2 ) ) / Math.pow( 10, 2 );
+ resultValue = "" + (int) d;
+ }
+
+ if ( deFlag2 == 0 )
{
resultValue = " ";
}
}
else
{
- resultValue = buffer.toString();
+ resultValue = buffer.toString();
}
-
+
double finalResult = 0.0;
try
{
- finalResult = Double.parseDouble(resultValue);
+ finalResult = Double.parseDouble( resultValue );
}
- catch(Exception e)
+ catch ( Exception e )
{
finalResult = 0.0;
}
-
+
return finalResult;
}
catch ( NumberFormatException ex )
@@ -564,21 +593,20 @@
}
}
-
// Returns the OrgUnitTree for which Root is the orgUnit
public List<OrganisationUnit> getChildOrgUnitTree( OrganisationUnit orgUnit )
{
List<OrganisationUnit> orgUnitTree = new ArrayList<OrganisationUnit>();
orgUnitTree.add( orgUnit );
- List<OrganisationUnit> children = new ArrayList<OrganisationUnit>(orgUnit.getChildren());
+ List<OrganisationUnit> children = new ArrayList<OrganisationUnit>( orgUnit.getChildren() );
Collections.sort( children, new OrganisationUnitShortNameComparator() );
Iterator<OrganisationUnit> childIterator = children.iterator();
OrganisationUnit child;
while ( childIterator.hasNext() )
{
- child = (OrganisationUnit) childIterator.next();
+ child = childIterator.next();
orgUnitTree.addAll( getChildOrgUnitTree( child ) );
}
return orgUnitTree;
=== modified file 'local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/ExportToExcelAverageVAAction.java'
--- local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/ExportToExcelAverageVAAction.java 2009-07-08 09:58:18 +0000
+++ local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/ExportToExcelAverageVAAction.java 2009-07-08 12:15:19 +0000
@@ -82,6 +82,7 @@
// Action implementation
// -------------------------------------------------------------------------
+ @SuppressWarnings( "unchecked" )
public String execute()
throws Exception
{
@@ -177,7 +178,7 @@
Iterator<Period> it4 = selPeriodList.iterator();
while(it4.hasNext())
{
- Period p = (Period) it4.next();
+ Period p = it4.next();
tempStr = p.getStartDate()+ " To " + p.getEndDate();
sheet0.addCell( new Label( tempCol1, tempRow1, tempStr, wCellformat2) );
sheet0.mergeCells( tempCol1, tempRow1, tempCol1+1, tempRow1 );
@@ -189,7 +190,7 @@
Iterator<OrganisationUnit> it1 = selOrgUnitList.iterator();
while(it1.hasNext())
{
- OrganisationUnit ou = (OrganisationUnit) it1.next();
+ OrganisationUnit ou = it1.next();
tempCol1 = organisationUnitService.getLevelOfOrganisationUnit( ou )-1;
sheet0.addCell( new Label( tempCol1, tempRow1, ou.getShortName(), wCellformat4) );
@@ -200,7 +201,7 @@
Iterator<Integer> it2 = resultList.iterator();
while(it2.hasNext())
{
- Integer result = (Integer) it2.next();
+ Integer result = it2.next();
tempStr = String.valueOf( result );
if(result.intValue() < 0)
sheet0.addCell( new Label( tempCol1, tempRow1, tempStr, wCellformat4) );
=== modified file 'local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/ExportToExcelDetailedVAAction.java'
--- local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/ExportToExcelDetailedVAAction.java 2009-07-08 09:58:18 +0000
+++ local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/ExportToExcelDetailedVAAction.java 2009-07-08 12:15:19 +0000
@@ -75,6 +75,7 @@
// Action implementation
// -------------------------------------------------------------------------
+ @SuppressWarnings( "unchecked" )
public String execute()
throws Exception
{
@@ -139,7 +140,7 @@
while(it1.hasNext())
{
tempCol1 = 0;
- OrganisationUnit ou = (OrganisationUnit) it1.next();
+ OrganisationUnit ou = it1.next();
sheet0.addCell( new Label( tempCol1, tempRow1, ou.getShortName(), wCellformat2) );
sheet0.mergeCells( tempCol1, tempRow1, tempCol1+5, tempRow1 );
@@ -148,7 +149,7 @@
Iterator<Period> it4 = selPeriodList.iterator();
while(it4.hasNext())
{
- Period p = (Period) it4.next();
+ Period p = it4.next();
tempStr = p.getStartDate()+ " To " + p.getEndDate();
sheet0.addCell( new Label( tempCol1, tempRow1, tempStr, wCellformat2) );
sheet0.mergeCells( tempCol1, tempRow1, tempCol1+1, tempRow1 );
@@ -163,7 +164,7 @@
while(it2.hasNext())
{
tempCol1 = 0;
- ValidationRule vr = (ValidationRule) it2.next();
+ ValidationRule vr = it2.next();
List<String> vrResultList = vrResultMap.get( vr );
List<String> vrColorList = vrColorMap.get( vr );
@@ -177,7 +178,7 @@
Iterator<String> it3 = vrResultList.iterator();
while(it3.hasNext())
{
- tempStr = (String) it3.next();
+ tempStr = it3.next();
String tempColor = vrColorList.get( count1 );
if(tempColor.equalsIgnoreCase( "red" ))
{
=== modified file 'local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/GetFilteredDataElementsActionIN.java'
--- local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/GetFilteredDataElementsActionIN.java 2009-07-08 09:58:18 +0000
+++ local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/GetFilteredDataElementsActionIN.java 2009-07-08 12:15:19 +0000
@@ -159,11 +159,11 @@
// String filter
// ---------------------------------------------------------------------
- Iterator iterator = dataElements.iterator();
+ Iterator<DataElement> iterator = dataElements.iterator();
while ( iterator.hasNext() )
{
- DataElement element = (DataElement) iterator.next();
+ DataElement element = iterator.next();
String name = element.getName();
=== modified file 'local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java'
--- local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java 2009-07-08 09:58:18 +0000
+++ local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java 2009-07-08 12:15:19 +0000
@@ -141,7 +141,6 @@
// Execute
// -------------------------------------------------------------------------
- @SuppressWarnings( "unchecked" )
public String execute()
{
Collection<? extends Source> sources = selectionTreeManager.getSelectedOrganisationUnits();
=== modified file 'local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/ValidationByAverageActionIN.java'
--- local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/ValidationByAverageActionIN.java 2009-07-08 09:58:18 +0000
+++ local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/action/ValidationByAverageActionIN.java 2009-07-08 12:15:19 +0000
@@ -1,7 +1,6 @@
package org.hisp.dhis.validationrule.action;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Hashtable;
@@ -13,6 +12,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
+import org.amplecode.quick.StatementManager;
import org.hisp.dhis.aggregation.AggregationService;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -20,7 +20,6 @@
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.expression.Expression;
import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.jdbc.StatementManager;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -299,7 +298,7 @@
{
System.out.println("validationRuleGroupId == "+validationRuleGroupId);
vrg = validationRuleService.getValidationRuleGroup( validationRuleGroupId );
- validationRuleList.addAll( (Collection<? extends ValidationRule>) vrg.getMembers() );
+ validationRuleList.addAll( vrg.getMembers() );
}
}
else
@@ -318,7 +317,7 @@
Iterator<Period> it1 = periodList.iterator();
while(it1.hasNext())
{
- Period p1 = (Period) it1.next();
+ Period p1 = it1.next();
if(p1.getPeriodType().getName().equalsIgnoreCase( "monthly" ))
{
selPeriodList.add( p1 );
@@ -616,7 +615,7 @@
OrganisationUnit child;
while ( childIterator.hasNext() )
{
- child = (OrganisationUnit) childIterator.next();
+ child = childIterator.next();
orgUnitTree.addAll( getChildOrgUnitTree( child ) );
}
return orgUnitTree;
=== modified file 'local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/util/ValidationResultWorkbookGenerator.java'
--- local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/util/ValidationResultWorkbookGenerator.java 2009-07-08 09:58:18 +0000
+++ local/in/dhis-web-validationrule-in/src/main/java/org/hisp/dhis/validationrule/util/ValidationResultWorkbookGenerator.java 2009-07-08 12:15:19 +0000
@@ -96,7 +96,7 @@
sheet.addCell( new Label( MARGIN_LEFT + 1, row, format.formatPeriod( period ), text ) );
sheet.addCell( new Label( MARGIN_LEFT + 2, row, result.getValidationRule().getLeftSide().getDescription(), text ) );
sheet.addCell( new Number( MARGIN_LEFT + 3, row, result.getLeftsideValue(), text ) );
- sheet.addCell( new Label( MARGIN_LEFT + 4, row, i18n.getString( result.getValidationRule().getOperator(), text ) ) );
+ sheet.addCell( new Label( MARGIN_LEFT + 4, row, i18n.getString( result.getValidationRule().getOperator() ), text ) );
sheet.addCell( new Number( MARGIN_LEFT + 5, row, result.getRightsideValue(), text ) );
sheet.addCell( new Label( MARGIN_LEFT + 6, row, result.getValidationRule().getRightSide().getDescription(), text ) );
=== modified file 'local/in/dhis-web-validationrule-in/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-validationrule-in/src/main/resources/META-INF/dhis/beans.xml 2009-07-08 09:58:18 +0000
+++ local/in/dhis-web-validationrule-in/src/main/resources/META-INF/dhis/beans.xml 2009-07-08 12:15:19 +0000
@@ -227,7 +227,7 @@
<bean id="org.hisp.dhis.validationrule.action.ValidationByAverageActionIN"
class="org.hisp.dhis.validationrule.action.ValidationByAverageActionIN" scope="prototype">
<property name="statementManager">
- <ref bean="org.hisp.dhis.jdbc.StatementManager"/>
+ <ref bean="statementManager"/>
</property>
<property name="validationRuleService">
<ref bean="org.hisp.dhis.validation.ValidationRuleService"/>
@@ -257,7 +257,7 @@
scope="prototype">
<property name="statementManager">
- <ref bean="org.hisp.dhis.jdbc.StatementManager"/>
+ <ref bean="statementManager"/>
</property>
<property name="validationRuleService">
<ref bean="org.hisp.dhis.validation.ValidationRuleService"/>
--
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.