=== removed 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 2011-05-05 21:14:56 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/OnChangePeriodType.java 1970-01-01 00:00:00 +0000 @@ -1,138 +0,0 @@ -package org.hisp.dhis.period; - -/* - * Copyright (c) 2004-2010, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Calendar; -import java.util.Date; - -/** - * PeriodType for on-change Periods. - * - * @author Torgeir Lorange Ostby - * @version $Id: OnChangePeriodType.java 3640 2007-10-15 12:05:12Z torgeilo $ - */ -public class OnChangePeriodType - extends PeriodType -{ - /** - * Determines if a de-serialized file is compatible with this class. - */ - private static final long serialVersionUID = 299664418759849772L; - - private static final int INSURMOUNTABLE_YEAR = 9999; - - /** - * The name of the OnChangePeriodType, which is "OnChange". - */ - public static final String NAME = "OnChange"; - - // ------------------------------------------------------------------------- - // PeriodType functionality - // ------------------------------------------------------------------------- - - @Override - public String getName() - { - return NAME; - } - - @Override - public Period createPeriod() - { - return createPeriod( createCalendarInstance() ); - } - - @Override - public Period createPeriod( Date date ) - { - return createPeriod( createCalendarInstance( date ) ); - } - - private Period createPeriod( Calendar cal ) - { - Date startDate = cal.getTime(); - cal.set( Calendar.YEAR, INSURMOUNTABLE_YEAR ); - cal.set( Calendar.DAY_OF_YEAR, cal.getActualMaximum( Calendar.DAY_OF_YEAR ) ); - return new Period( this, startDate, cal.getTime() ); - } - - @Override - public int getFrequencyOrder() - { - return 0; - } - - // ------------------------------------------------------------------------- - // OnChange functionality - // ------------------------------------------------------------------------- - - /** - * Sets the end date of the given Period to today - 1 day. - * - * @param period the Period to change. - */ - public static void setEndDateYesterday( Period period ) - { - Calendar cal = createCalendarInstance(); - cal.add( Calendar.DAY_OF_YEAR, -1 ); - - period.setEndDate( cal.getTime() ); - } - - /** - * Sets the end date of the given Period to 9999/12/31. - * - * @param period the Period to change. - */ - public static void setEndDateInfinite( Period period ) - { - Calendar cal = createCalendarInstance(); - cal.set( Calendar.YEAR, INSURMOUNTABLE_YEAR ); - cal.set( Calendar.DAY_OF_YEAR, cal.getActualMaximum( Calendar.DAY_OF_YEAR ) ); - - period.setEndDate( cal.getTime() ); - } - - @Override - public String getIsoDate( Period period ) - { - throw new UnsupportedOperationException( "Not supported yet." ); - } - - @Override - public Period createPeriod( String isoDate ) - { - throw new UnsupportedOperationException( "Not supported yet." ); - } - - @Override - public String getIsoFormat() - { - throw new UnsupportedOperationException( "Not supported yet." ); - } -} === 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 2011-09-16 07:53:59 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java 2011-10-12 11:48:47 +0000 @@ -56,34 +56,28 @@ // Available PeriodTypes // ------------------------------------------------------------------------- - private static List periodTypes; - - private static Map periodTypeMap; - - static - { - periodTypes = new ArrayList(); - periodTypes.add( new DailyPeriodType() ); - periodTypes.add( new WeeklyPeriodType() ); - periodTypes.add( new MonthlyPeriodType() ); - periodTypes.add( new BiMonthlyPeriodType() ); - periodTypes.add( new QuarterlyPeriodType() ); - periodTypes.add( new SixMonthlyPeriodType() ); - periodTypes.add( new YearlyPeriodType() ); - periodTypes.add( new FinancialAprilPeriodType() ); - periodTypes.add( new FinancialJulyPeriodType() ); - periodTypes.add( new FinancialOctoberPeriodType() ); - // periodTypes.add( new OnChangePeriodType() ); - // periodTypes.add( new SurveyPeriodType() ); - - periodTypeMap = new HashMap(); - - for ( PeriodType periodType : periodTypes ) + private static final List PERIOD_TYPES = new ArrayList() + { { + add( new DailyPeriodType() ); + add( new WeeklyPeriodType() ); + add( new MonthlyPeriodType() ); + add( new BiMonthlyPeriodType() ); + add( new QuarterlyPeriodType() ); + add( new SixMonthlyPeriodType() ); + add( new YearlyPeriodType() ); + add( new FinancialAprilPeriodType() ); + add( new FinancialJulyPeriodType() ); + add( new FinancialOctoberPeriodType() ); + } }; + + private static final Map PERIOD_TYPE_MAP = new HashMap() + { { + for ( PeriodType periodType : PERIOD_TYPES ) { - periodTypeMap.put( periodType.getName(), periodType ); + put( periodType.getName(), periodType ); } - } - + } }; + /** * Returns all available PeriodTypes in their natural order. * @@ -91,7 +85,7 @@ */ public static List getAvailablePeriodTypes() { - return new ArrayList( periodTypes ); + return new ArrayList( PERIOD_TYPES ); } /** @@ -103,7 +97,7 @@ */ public static PeriodType getPeriodTypeByName( String name ) { - return periodTypeMap.get( name ); + return PERIOD_TYPE_MAP.get( name ); } public static PeriodType getByNameIgnoreCase( String name ) @@ -129,12 +123,12 @@ { index -= 1; - if ( index < 0 || index > periodTypes.size() - 1 ) + if ( index < 0 || index > PERIOD_TYPES.size() - 1 ) { return null; } - return periodTypes.get( index ); + return PERIOD_TYPES.get( index ); } // ------------------------------------------------------------------------- === removed 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 2011-05-05 21:14:56 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SurveyPeriodType.java 1970-01-01 00:00:00 +0000 @@ -1,101 +0,0 @@ -package org.hisp.dhis.period; - -/* - * Copyright (c) 2004-2010, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Date; - -/** - * PeriodType for survey Periods. A valid survey Period has equal startDate and - * endDate. - * - * @author Torgeir Lorange Ostby - * @version $Id: SurveyPeriodType.java 2973 2007-03-03 19:05:45Z torgeilo $ - */ -public class SurveyPeriodType - extends PeriodType -{ - /** - * Determines if a de-serialized file is compatible with this class. - */ - private static final long serialVersionUID = 8032118463759330180L; - - /** - * The name of the SurveyPeriodType, which is "Survey". - */ - public static final String NAME = "Survey"; - - // ------------------------------------------------------------------------- - // PeriodType functionality - // ------------------------------------------------------------------------- - - @Override - public String getName() - { - return NAME; - } - - @Override - public Period createPeriod() - { - Date date = createCalendarInstance().getTime(); - - return new Period( this, date, date ); - } - - @Override - public Period createPeriod( Date date ) - { - Date fixedDate = createCalendarInstance( date ).getTime(); - - return new Period( this, fixedDate, fixedDate ); - } - - @Override - public int getFrequencyOrder() - { - return 0; - } - - @Override - public String getIsoDate( Period period ) - { - throw new UnsupportedOperationException( "Not supported yet." ); - } - - @Override - public Period createPeriod( String isoDate ) - { - throw new UnsupportedOperationException( "Not supported yet." ); - } - - @Override - public String getIsoFormat() - { - throw new UnsupportedOperationException( "Not supported yet." ); - } -} === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2011-10-10 13:26:01 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2011-10-12 11:48:47 +0000 @@ -99,38 +99,32 @@ public static final int NONE = 0; public static final Map PRETTY_COLUMNS = new HashMap() - { - private static final long serialVersionUID = 4194194769957136714L; - { - put( CATEGORYCOMBO_ID, "Category combination ID" ); - put( INDICATOR_ID, "Indicator ID" ); - put( INDICATOR_NAME, "Indicator" ); - put( INDICATOR_CODE, "Indicator code" ); - put( PERIOD_ID, "Period ID" ); - put( PERIOD_NAME, "Period" ); - put( PERIOD_CODE, "Period code" ); - put( ORGANISATIONUNIT_ID, "Organisation unit ID" ); - put( ORGANISATIONUNIT_NAME, "Organisation unit" ); - put( ORGANISATIONUNIT_CODE, "Organisation unit code" ); - put( REPORTING_MONTH_COLUMN_NAME, "Reporting month" ); - put( PARAM_ORGANISATIONUNIT_COLUMN_NAME, "Organisation unit parameter" ); - put( ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME, "Organisation unit is parent" ); - } - }; + { { + put( CATEGORYCOMBO_ID, "Category combination ID" ); + put( INDICATOR_ID, "Indicator ID" ); + put( INDICATOR_NAME, "Indicator" ); + put( INDICATOR_CODE, "Indicator code" ); + put( PERIOD_ID, "Period ID" ); + put( PERIOD_NAME, "Period" ); + put( PERIOD_CODE, "Period code" ); + put( ORGANISATIONUNIT_ID, "Organisation unit ID" ); + put( ORGANISATIONUNIT_NAME, "Organisation unit" ); + put( ORGANISATIONUNIT_CODE, "Organisation unit code" ); + put( REPORTING_MONTH_COLUMN_NAME, "Reporting month" ); + put( PARAM_ORGANISATIONUNIT_COLUMN_NAME, "Organisation unit parameter" ); + put( ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME, "Organisation unit is parent" ); + } }; public static final Map, String> CLASS_ID_MAP = new HashMap, String>() - { - private static final long serialVersionUID = 4742098364404485991L; - { - put( Indicator.class, INDICATOR_ID ); - put( DataElement.class, DATAELEMENT_ID ); - put( DataElementCategoryOptionCombo.class, CATEGORYCOMBO_ID ); - put( DataElementCategoryOption.class, CATEGORYOPTION_ID ); - put( DataSet.class, DATASET_ID ); - put( Period.class, PERIOD_ID ); - put( OrganisationUnit.class, ORGANISATIONUNIT_ID ); - } - }; + { { + put( Indicator.class, INDICATOR_ID ); + put( DataElement.class, DATAELEMENT_ID ); + put( DataElementCategoryOptionCombo.class, CATEGORYCOMBO_ID ); + put( DataElementCategoryOption.class, CATEGORYOPTION_ID ); + put( DataSet.class, DATASET_ID ); + put( Period.class, PERIOD_ID ); + put( OrganisationUnit.class, ORGANISATIONUNIT_ID ); + } }; private static final String EMPTY = ""; @@ -285,7 +279,7 @@ /** * The name of the reporting month based on the report param. */ - private String reportingMonthName; + private String reportingPeriodName; /** * The name of the (parent) organisation unit based on the report param. @@ -339,7 +333,7 @@ List dataSets, List periods, List relativePeriods, List units, List relativeUnits, DataElementCategoryCombo categoryCombo, boolean doIndicators, boolean doPeriods, boolean doUnits, RelativePeriods relatives, ReportParams reportParams, - I18nFormat i18nFormat, String reportingMonthName ) + I18nFormat i18nFormat, String reportingPeriodName ) { this.name = name; this.regression = regression; @@ -357,7 +351,7 @@ this.relatives = relatives; this.reportParams = reportParams; this.i18nFormat = i18nFormat; - this.reportingMonthName = reportingMonthName; + this.reportingPeriodName = reportingPeriodName; } // ------------------------------------------------------------------------- @@ -1043,14 +1037,14 @@ i18nFormat = format; } - public String getReportingMonthName() + public String getReportingPeriodName() { - return reportingMonthName; + return reportingPeriodName; } - public void setReportingMonthName( String reportingMonthName ) + public void setReportingPeriodName( String reportingPeriodName ) { - this.reportingMonthName = reportingMonthName; + this.reportingPeriodName = reportingPeriodName; } public String getOrganisationUnitName() === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/PeriodType.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/PeriodType.hbm.xml 2011-09-16 07:53:59 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/PeriodType.hbm.xml 2011-10-12 11:48:47 +0000 @@ -22,8 +22,6 @@ - - === modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14ObjectMappingUtil.java' --- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14ObjectMappingUtil.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14ObjectMappingUtil.java 2011-10-12 11:48:47 +0000 @@ -33,7 +33,6 @@ import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.period.DailyPeriodType; import org.hisp.dhis.period.MonthlyPeriodType; -import org.hisp.dhis.period.OnChangePeriodType; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.period.QuarterlyPeriodType; import org.hisp.dhis.period.SixMonthlyPeriodType; @@ -58,7 +57,7 @@ periodTypeMap.put( 1, new MonthlyPeriodType() ); periodTypeMap.put( 2, new QuarterlyPeriodType() ); periodTypeMap.put( 3, new YearlyPeriodType() ); - periodTypeMap.put( 4, new OnChangePeriodType() ); + periodTypeMap.put( 4, new MonthlyPeriodType() ); // Should be OnChange, which is un-supported periodTypeMap.put( 5, new DailyPeriodType() ); // Should be Survey, which is un-supported periodTypeMap.put( 6, new DailyPeriodType() ); periodTypeMap.put( 7, new WeeklyPeriodType() ); === modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/PeriodTypeConverter.java' --- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/PeriodTypeConverter.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/PeriodTypeConverter.java 2011-10-12 11:48:47 +0000 @@ -34,9 +34,7 @@ import org.hisp.dhis.importexport.XMLConverter; import org.hisp.dhis.period.DailyPeriodType; import org.hisp.dhis.period.MonthlyPeriodType; -import org.hisp.dhis.period.OnChangePeriodType; import org.hisp.dhis.period.QuarterlyPeriodType; -import org.hisp.dhis.period.SurveyPeriodType; import org.hisp.dhis.period.WeeklyPeriodType; import org.hisp.dhis.period.YearlyPeriodType; @@ -143,42 +141,6 @@ writer.closeElement(); // --------------------------------------------------------------------- - // OnChange - // --------------------------------------------------------------------- - - writer.openElement( ELEMENT_NAME ); - - writer.writeElement( FIELD_ID, String.valueOf( 4 ) ); - writer.writeElement( FIELD_NAME_ENG, OnChangePeriodType.NAME ); - writer.writeElement( FIELD_NAME, OnChangePeriodType.NAME ); - writer.writeElement( FIELD_SORT_ORDER, String.valueOf( 4 ) ); - writer.writeElement( FIELD_ANNUALISATION_FACTOR, String.valueOf( 0 ) ); - writer.writeElement( FIELD_UPPER_RANGE_DAY_COUNT, String.valueOf( 0 ) ); - writer.writeElement( FIELD_FIRST_DAY_OF_WEEK, String.valueOf( 1 ) ); - writer.writeElement( FIELD_FIRST_WEEK_OF_YEAR, String.valueOf( 0 ) ); - writer.writeElement( FIELD_SUPPORTED, String.valueOf( 0 ) ); - - writer.closeElement(); - - // --------------------------------------------------------------------- - // Survey - // --------------------------------------------------------------------- - - writer.openElement( ELEMENT_NAME ); - - writer.writeElement( FIELD_ID, String.valueOf( 5 ) ); - writer.writeElement( FIELD_NAME_ENG, SurveyPeriodType.NAME ); - writer.writeElement( FIELD_NAME, SurveyPeriodType.NAME ); - writer.writeElement( FIELD_SORT_ORDER, String.valueOf( 5 ) ); - writer.writeElement( FIELD_ANNUALISATION_FACTOR, String.valueOf( 0 ) ); - writer.writeElement( FIELD_UPPER_RANGE_DAY_COUNT, String.valueOf( 0 ) ); - writer.writeElement( FIELD_FIRST_DAY_OF_WEEK, String.valueOf( 1 ) ); - writer.writeElement( FIELD_FIRST_WEEK_OF_YEAR, String.valueOf( 0 ) ); - writer.writeElement( FIELD_SUPPORTED, String.valueOf( 0 ) ); - - writer.closeElement(); - - // --------------------------------------------------------------------- // Daily // --------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2011-10-10 13:58:57 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2011-10-12 11:48:47 +0000 @@ -376,18 +376,18 @@ { reportTable.setRelativePeriods( periodService.reloadPeriods( reportTable.getRelatives().getRelativePeriods( reportingPeriod, format, !reportTable.isDoPeriods() ) ) ); - reportTable.setReportingMonthName( reportTable.getRelatives().getReportingMonthName( reportingPeriod, + reportTable.setReportingPeriodName( reportTable.getRelatives().getReportingMonthName( reportingPeriod, format ) ); - log.info( "Reporting period date from report param: " + reportTable.getReportingMonthName() ); + log.info( "Reporting period date from report param: " + reportTable.getReportingPeriodName() ); } else { reportTable.setRelativePeriods( periodService.reloadPeriods( reportTable.getRelatives().getRelativePeriods( 1, format, !reportTable.isDoPeriods() ) ) ); - reportTable.setReportingMonthName( reportTable.getRelatives().getReportingMonthName( 1, format ) ); + reportTable.setReportingPeriodName( reportTable.getRelatives().getReportingMonthName( 1, format ) ); - log.info( "Reporting period date default: " + reportTable.getReportingMonthName() ); + log.info( "Reporting period date default: " + reportTable.getReportingPeriodName() ); } // --------------------------------------------------------------------- @@ -469,7 +469,7 @@ private Grid getGrid( ReportTable reportTable ) { String subtitle = StringUtils.trimToEmpty( reportTable.getOrganisationUnitName() ) + SPACE - + StringUtils.trimToEmpty( reportTable.getReportingMonthName() ); + + StringUtils.trimToEmpty( reportTable.getReportingPeriodName() ); Grid grid = new ListGrid().setTitle( reportTable.getName() ).setSubtitle( subtitle ); @@ -545,7 +545,7 @@ grid.addValue( object.getCode() ); } - grid.addValue( reportTable.getReportingMonthName() ); + grid.addValue( reportTable.getReportingPeriodName() ); grid.addValue( reportTable.getOrganisationUnitName() ); grid.addValue( isCurrentParent( row ) ? YES : NO );