dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #06317
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1987: Added final property frequencyOrder to all PeriodType implementations, which enables easy compare...
------------------------------------------------------------
revno: 1987
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Mon 2010-06-14 17:51:12 +0200
message:
Added final property frequencyOrder to all PeriodType implementations, which enables easy compare of length of periodicity. Added properties aggregationOperator and frequencyOrder to DataElementOperand. Commented out incorrect implementations of delete methods in HibernateDataValueAuditStore for now, please fix.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/OnChangePeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SurveyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java
dhis-2/dhis-api/src/test/java/org/hisp/dhis/dataelement/OperandTest.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DataValueAuditDeletionHandler.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.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/DataElementOperand.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java 2010-06-10 12:03:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java 2010-06-14 15:51:12 +0000
@@ -45,13 +45,21 @@
private static final String SPACE = "";
private static final String COLUMN_PREFIX = "de";
private static final String COLUMN_SEPARATOR = "_";
-
+
+ // -------------------------------------------------------------------------
+ // Persisted properties
+ // -------------------------------------------------------------------------
+
private int id;
private DataElement dataElement;
private DataElementCategoryOptionCombo categoryOptionCombo;
-
+
+ // -------------------------------------------------------------------------
+ // Populated properties
+ // -------------------------------------------------------------------------
+
private int dataElementId;
private int optionComboId;
@@ -59,9 +67,13 @@
private String operandId;
private String operandName;
+
+ private String aggregationOperator;
private List<Integer> aggregationLevels = new ArrayList<Integer>();
-
+
+ private int frequencyOrder;
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
@@ -91,13 +103,15 @@
this.operandName = operandName;
}
- public DataElementOperand( int dataElementId, int optionComboId, String operandName, List<Integer> aggregationLevels )
+ public DataElementOperand( int dataElementId, int optionComboId, String operandName, String aggregationOperator, List<Integer> aggregationLevels, int frequencyOrder )
{
this.dataElementId = dataElementId;
this.optionComboId = optionComboId;
this.operandId = dataElementId + SEPARATOR + optionComboId;
this.operandName = operandName;
+ this.aggregationOperator = aggregationOperator;
this.aggregationLevels = aggregationLevels;
+ this.frequencyOrder = frequencyOrder;
}
// -------------------------------------------------------------------------
@@ -187,7 +201,7 @@
{
return COLUMN_PREFIX + dataElementId + COLUMN_SEPARATOR + optionComboId;
}
-
+
// -------------------------------------------------------------------------
// Getters & setters
// -------------------------------------------------------------------------
@@ -262,6 +276,16 @@
this.operandName = operandName;
}
+ public String getAggregationOperator()
+ {
+ return aggregationOperator;
+ }
+
+ public void setAggregationOperator( String aggregationOperator )
+ {
+ this.aggregationOperator = aggregationOperator;
+ }
+
public List<Integer> getAggregationLevels()
{
return aggregationLevels;
@@ -272,6 +296,16 @@
this.aggregationLevels = aggregationLevels;
}
+ public int getFrequencyOrder()
+ {
+ return frequencyOrder;
+ }
+
+ public void setFrequencyOrder( int frequencyOrder )
+ {
+ this.frequencyOrder = frequencyOrder;
+ }
+
// -------------------------------------------------------------------------
// hashCode, equals, toString, compareTo
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java 2010-06-14 15:51:12 +0000
@@ -72,7 +72,13 @@
return new Period( this, fixedDate, fixedDate );
}
-
+
+ @Override
+ public int getFrequencyOrder()
+ {
+ return 1;
+ }
+
// -------------------------------------------------------------------------
// CalendarPeriodType functionality
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java 2010-06-14 15:51:12 +0000
@@ -81,6 +81,12 @@
return new Period( this, startDate, cal.getTime() );
}
+ @Override
+ public int getFrequencyOrder()
+ {
+ return 3;
+ }
+
// -------------------------------------------------------------------------
// CalendarPeriodType functionality
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/OnChangePeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/OnChangePeriodType.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/OnChangePeriodType.java 2010-06-14 15:51:12 +0000
@@ -78,6 +78,12 @@
return new Period( this, startDate, cal.getTime() );
}
+ @Override
+ public int getFrequencyOrder()
+ {
+ return 0;
+ }
+
// -------------------------------------------------------------------------
// OnChange functionality
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java 2010-06-14 15:51:12 +0000
@@ -140,6 +140,14 @@
* @return the valid Period based on the given date
*/
public abstract Period createPeriod( Date date );
+
+ /**
+ * Returns a comparable value for the frequency length of this PeriodType.
+ * Shortest is 0.
+ *
+ * @return the frequency order.
+ */
+ public abstract int getFrequencyOrder();
// -------------------------------------------------------------------------
// Calendar support
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java 2010-06-14 15:51:12 +0000
@@ -83,6 +83,12 @@
return new Period( this, startDate, cal.getTime() );
}
+ @Override
+ public int getFrequencyOrder()
+ {
+ return 4;
+ }
+
// -------------------------------------------------------------------------
// CalendarPeriodType functionality
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriodType.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriodType.java 2010-06-14 15:51:12 +0000
@@ -79,4 +79,10 @@
return new Period( this, startDate, endDate );
}
+
+ @Override
+ public int getFrequencyOrder()
+ {
+ return 0;
+ }
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java 2010-06-14 15:51:12 +0000
@@ -83,6 +83,12 @@
return new Period( this, startDate, cal.getTime() );
}
+ @Override
+ public int getFrequencyOrder()
+ {
+ return 5;
+ }
+
// -------------------------------------------------------------------------
// CalendarPeriodType functionality
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SurveyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SurveyPeriodType.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SurveyPeriodType.java 2010-06-14 15:51:12 +0000
@@ -69,4 +69,10 @@
return new Period( this, fixedDate, fixedDate );
}
+
+ @Override
+ public int getFrequencyOrder()
+ {
+ return 0;
+ }
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java 2010-06-14 15:51:12 +0000
@@ -83,6 +83,12 @@
return new Period( this, startDate, cal.getTime() );
}
+ @Override
+ public int getFrequencyOrder()
+ {
+ return 7;
+ }
+
// -------------------------------------------------------------------------
// CalendarPeriodType functionality
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java 2010-06-14 15:51:12 +0000
@@ -81,6 +81,12 @@
return new Period( this, startDate, cal.getTime() );
}
+ @Override
+ public int getFrequencyOrder()
+ {
+ return 2;
+ }
+
// -------------------------------------------------------------------------
// CalendarPeriodType functionality
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java 2010-06-14 15:51:12 +0000
@@ -80,6 +80,12 @@
return new Period( this, startDate, cal.getTime() );
}
+ @Override
+ public int getFrequencyOrder()
+ {
+ return 6;
+ }
+
// -------------------------------------------------------------------------
// CalendarPeriodType functionality
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/dataelement/OperandTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/dataelement/OperandTest.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/dataelement/OperandTest.java 2010-06-14 15:51:12 +0000
@@ -43,11 +43,11 @@
@Test
public void getRelevantAggregationLevel()
{
- DataElementOperand operand = new DataElementOperand( 1, 1, "Operand", new ArrayList<Integer>() );
+ DataElementOperand operand = new DataElementOperand( 1, 1, "Operand", null, new ArrayList<Integer>(), 0 );
assertNull( operand.getRelevantAggregationLevel( 1 ) );
- operand = new DataElementOperand( 1, 1, "Operand", Arrays.asList( 3, 5 ) );
+ operand = new DataElementOperand( 1, 1, "Operand", null, Arrays.asList( 3, 5 ), 0 );
assertEquals( new Integer( 3 ), operand.getRelevantAggregationLevel( 1 ) );
assertEquals( new Integer( 3 ), operand.getRelevantAggregationLevel( 2 ) );
@@ -60,12 +60,12 @@
@Test
public void aggregationLevelIsValid()
{
- DataElementOperand operand = new DataElementOperand( 1, 1, "Operand", new ArrayList<Integer>() );
+ DataElementOperand operand = new DataElementOperand( 1, 1, "Operand", null, new ArrayList<Integer>(), 0 );
assertTrue( operand.aggregationLevelIsValid( 1, 3 ) );
assertTrue( operand.aggregationLevelIsValid( 4, 3 ) );
- operand = new DataElementOperand( 1, 1, "Operand", Arrays.asList( 3, 5 ) );
+ operand = new DataElementOperand( 1, 1, "Operand", null, Arrays.asList( 3, 5 ), 0 );
assertTrue( operand.aggregationLevelIsValid( 2, 2 ) );
assertTrue( operand.aggregationLevelIsValid( 2, 3 ) );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2010-04-22 11:50:55 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2010-06-14 15:51:12 +0000
@@ -395,12 +395,14 @@
Set<DataElementCategoryOptionCombo> categoryOptionCombos = dataElement.getCategoryCombo()
.getOptionCombos();
+ int frequencyOrder = dataElement.getPeriodType() != null ? dataElement.getPeriodType().getFrequencyOrder() : 0;
+
if ( categoryOptionCombos.size() > 1 && !(dataElement instanceof CalculatedDataElement) )
{
for ( DataElementCategoryOptionCombo optionCombo : categoryOptionCombos )
{
DataElementOperand operand = new DataElementOperand( dataElement.getId(), optionCombo.getId(), dataElement.getName()
- + optionCombo.getName(), new ArrayList<Integer>( dataElement.getAggregationLevels() ) );
+ + optionCombo.getName(), dataElement.getAggregationOperator(), new ArrayList<Integer>( dataElement.getAggregationLevels() ), frequencyOrder );
operands.add( operand );
}
@@ -408,7 +410,7 @@
else
{
DataElementOperand operand = new DataElementOperand( dataElement.getId(), categoryOptionCombos.iterator().next().getId(),
- dataElement.getName(), new ArrayList<Integer>( dataElement.getAggregationLevels() ) );
+ dataElement.getName(), dataElement.getAggregationOperator(), new ArrayList<Integer>( dataElement.getAggregationLevels() ), frequencyOrder );
operands.add( operand );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DataValueAuditDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DataValueAuditDeletionHandler.java 2010-06-09 10:37:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DataValueAuditDeletionHandler.java 2010-06-14 15:51:12 +0000
@@ -85,9 +85,10 @@
{
dataValueAuditService.deleteByDataElementCategoryOptionCombo( categoryOptionCombo );
}
+
+ @Override
public void deleteDataValue( DataValue dataValue )
{
dataValueAuditService.deleteDataValueAuditByDataValue( dataValue );
}
-
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java 2010-06-09 10:37:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java 2010-06-14 15:51:12 +0000
@@ -128,27 +128,30 @@
}
}
}
-
+
public int deleteByPeriod( Period period )
{
+ /*
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery( "delete DataValueAudit where period = :period" );
query.setEntity( "period", period );
return query.executeUpdate();
-
-
+ */
+ return 0;
}
-
+
public int deleteByDataElementCategoryOptionCombo( DataElementCategoryOptionCombo optionCombo )
{
- Session session = sessionFactory.getCurrentSession();
-
- Query query = session.createQuery( "delete DataValueAudit where optionCombo = :optionCombo" );
- query.setEntity( "optionCombo", optionCombo );
-
- return query.executeUpdate();
+ /*
+ Session session = sessionFactory.getCurrentSession();
+
+ Query query = session.createQuery( "delete DataValueAudit where optionCombo = :optionCombo" );
+ query.setEntity( "optionCombo", optionCombo );
+
+ return query.executeUpdate();
+ */
+ return 0;
}
-
}