=== removed directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dashboard' === removed file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dashboard/GetChartAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dashboard/GetChartAction.java 2011-09-27 12:03:32 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dashboard/GetChartAction.java 1970-01-01 00:00:00 +0000 @@ -1,124 +0,0 @@ -package org.hisp.dhis.light.action.dashboard; - -/* - * 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 org.hisp.dhis.chart.ChartService; -import org.hisp.dhis.i18n.I18nFormat; -import org.jfree.chart.JFreeChart; - -import com.opensymphony.xwork2.Action; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class GetChartAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private ChartService chartService; - - public void setChartService( ChartService chartService ) - { - this.chartService = chartService; - } - - private I18nFormat format; - - public void setFormat( I18nFormat format ) - { - this.format = format; - } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private Integer id; - - public void setId( Integer id ) - { - this.id = id; - } - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private JFreeChart chart; - - public JFreeChart getChart() - { - return chart; - } - - private int height; - - public int getHeight() - { - return height; - } - - public void setHeight( int height ) - { - this.height = height; - } - - private int width; - - public int getWidth() - { - return width; - } - - public void setWidth( int width ) - { - this.width = width; - } - - // ------------------------------------------------------------------------- - // Action implemenation - // ------------------------------------------------------------------------- - - public String execute() - { - if ( id != null ) - { - chart = chartService.getJFreeChart( id, format ); - - height = 280; - - width = 400; - } - - return SUCCESS; - } -} === removed file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dashboard/GetReportAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dashboard/GetReportAction.java 2011-09-27 12:03:32 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dashboard/GetReportAction.java 1970-01-01 00:00:00 +0000 @@ -1,105 +0,0 @@ -package org.hisp.dhis.light.action.dashboard; - -/* - * 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 org.hisp.dhis.common.Grid; -import org.hisp.dhis.i18n.I18nFormat; -import org.hisp.dhis.reporttable.ReportTableService; - -import com.opensymphony.xwork2.Action; - -public class GetReportAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private ReportTableService reportTableService; - - public void setReportTableService( ReportTableService reportTableService ) - { - this.reportTableService = reportTableService; - } - - private I18nFormat format; - - public void setFormat( I18nFormat format ) - { - this.format = format; - } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private Integer id; - - public void setId( Integer id ) - { - this.id = id; - } - - private Integer reportingPeriod; - - public void setReportingPeriod( Integer reportingPeriod ) - { - this.reportingPeriod = reportingPeriod; - } - - private Integer organisationUnitId; - - public void setOrganisationUnitId( Integer organisationUnitId ) - { - this.organisationUnitId = organisationUnitId; - } - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private Grid grid; - - public Grid getGrid() - { - return grid; - } - - // ------------------------------------------------------------------------- - // Result implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - throws Exception - { - grid = reportTableService.getReportTableGrid( id, format, reportingPeriod, organisationUnitId ); - - return SUCCESS; - } -} === removed file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dashboard/GetReportParamsAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dashboard/GetReportParamsAction.java 2011-09-27 12:03:32 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dashboard/GetReportParamsAction.java 1970-01-01 00:00:00 +0000 @@ -1,157 +0,0 @@ -package org.hisp.dhis.light.action.dashboard; - -/* - * 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.SortedMap; -import java.util.TreeMap; - -import org.hisp.dhis.i18n.I18nFormat; -import org.hisp.dhis.oust.manager.SelectionTreeManager; -import org.hisp.dhis.period.MonthlyPeriodType; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.period.PeriodType; -import org.hisp.dhis.report.Report; -import org.hisp.dhis.reporttable.ReportParams; -import org.hisp.dhis.reporttable.ReportTable; -import org.hisp.dhis.reporttable.ReportTableService; - -import com.opensymphony.xwork2.Action; - -/** - * @author Lars Helge Overland - */ -public class GetReportParamsAction - implements Action -{ - private static final int AVAILABLE_REPORTING_MONTHS = 24; - - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private ReportTableService reportTableService; - - public void setReportTableService( ReportTableService reportTableService ) - { - this.reportTableService = reportTableService; - } - - private SelectionTreeManager selectionTreeManager; - - public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager ) - { - this.selectionTreeManager = selectionTreeManager; - } - - private I18nFormat format; - - public void setFormat( I18nFormat format ) - { - this.format = format; - } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private Integer id; - - public Integer getId() - { - return id; - } - - public void setId( Integer id ) - { - this.id = id; - } - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private ReportParams reportParams; - - public ReportParams getReportParams() - { - return reportParams; - } - - private SortedMap reportingPeriods = new TreeMap(); - - public SortedMap getReportingPeriods() - { - return reportingPeriods; - } - - private Report report; - - public Report getReport() - { - return report; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - { - selectionTreeManager.setCurrentUserOrganisationUnitAsSelected(); - - if ( id != null ) - { - ReportTable reportTable = reportTableService.getReportTable( id, ReportTableService.MODE_REPORT_TABLE ); - - if ( reportTable != null ) - { - reportParams = reportTable.getReportParams(); - - if ( reportParams.isParamReportingMonth() ) - { - MonthlyPeriodType periodType = new MonthlyPeriodType(); - - Calendar cal = PeriodType.createCalendarInstance(); - - for ( int i = 0; i < AVAILABLE_REPORTING_MONTHS; i++ ) - { - int month = i + 1; - cal.add( Calendar.MONTH, -1 ); - Period period = periodType.createPeriod( cal.getTime() ); - String periodName = format.formatPeriod( period ); - - reportingPeriods.put( month, periodName ); - } - } - } - } - - return SUCCESS; - } -} === removed file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dashboard/ProvideContentAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dashboard/ProvideContentAction.java 2011-09-27 12:03:32 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dashboard/ProvideContentAction.java 1970-01-01 00:00:00 +0000 @@ -1,99 +0,0 @@ -package org.hisp.dhis.light.action.dashboard; - -import java.util.ArrayList; -import java.util.List; - -import org.hisp.dhis.dashboard.DashboardConfiguration; -import org.hisp.dhis.dashboard.DashboardContent; -import org.hisp.dhis.dashboard.DashboardManager; -import org.hisp.dhis.dashboard.DashboardService; -import org.hisp.dhis.document.Document; -import org.hisp.dhis.reporttable.ReportTable; -import org.hisp.dhis.user.CurrentUserService; -import org.hisp.dhis.user.User; - -import com.opensymphony.xwork2.Action; - -public class ProvideContentAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private DashboardService dashboardService; - - public void setDashboardService( DashboardService dashboardService ) - { - this.dashboardService = dashboardService; - } - - private DashboardManager dashboardManager; - - public void setDashboardManager( DashboardManager dashboardManager ) - { - this.dashboardManager = dashboardManager; - } - - private CurrentUserService currentUserService; - - public void setCurrentUserService( CurrentUserService currentUserService ) - { - this.currentUserService = currentUserService; - } - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private List reportTables; - - public List getReportTables() - { - return reportTables; - } - - private List documents; - - public List getDocuments() - { - return documents; - } - - private List charts = new ArrayList(); - - public List getCharts() - { - return charts; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - throws Exception - { - DashboardConfiguration config = dashboardManager.getConfiguration(); - - for ( int i = 0; i < 8; i++ ) - { - String id = config.getAreaItems().get( DashboardManager.CHART_AREA_PREFIX + (i + 1) ); - - if ( id != null ) - { - charts.add( id ); - } - } - - User user = currentUserService.getCurrentUser(); - - DashboardContent content = dashboardService.getDashboardContent( user ); - - reportTables = content.getReportTables(); - - documents = content.getDocuments(); - - return SUCCESS; - } -} === removed directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry' === removed file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/GetDataSetsAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/GetDataSetsAction.java 2011-09-27 12:25:21 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/GetDataSetsAction.java 1970-01-01 00:00:00 +0000 @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2004-2011, 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. - */ - -package org.hisp.dhis.light.action.dataentry; - -import java.util.ArrayList; -import java.util.List; - -import org.hisp.dhis.dataset.DataSet; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.system.filter.DataSetTypeFilter; -import org.hisp.dhis.system.util.FilterUtils; - -import com.opensymphony.xwork2.Action; - -/** - * @author mortenoh - */ -public class GetDataSetsAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private OrganisationUnitService organisationUnitService; - - public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) - { - this.organisationUnitService = organisationUnitService; - } - - // ------------------------------------------------------------------------- - // Input & Output - // ------------------------------------------------------------------------- - - private Integer organisationUnitId; - - public void setOrganisationUnitId( Integer organisationUnitId ) - { - this.organisationUnitId = organisationUnitId; - } - - public Integer getOrganisationUnitId() - { - return organisationUnitId; - } - - private List dataSets = new ArrayList(); - - public List getDataSets() - { - return dataSets; - } - - // ------------------------------------------------------------------------- - // Action Implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - { - if ( organisationUnitId != null ) - { - OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId ); - dataSets = new ArrayList( organisationUnit.getDataSets() ); - FilterUtils.filter( dataSets, new DataSetTypeFilter( DataSet.TYPE_SECTION ) ); - } - - return SUCCESS; - } -} === removed file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/GetOrganisationUnitsAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/GetOrganisationUnitsAction.java 2011-09-27 12:03:32 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/GetOrganisationUnitsAction.java 1970-01-01 00:00:00 +0000 @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2004-2011, 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. - */ - -package org.hisp.dhis.light.action.dataentry; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator; -import org.hisp.dhis.user.CurrentUserService; -import org.hisp.dhis.user.User; - -import com.opensymphony.xwork2.Action; - -/** - * @author mortenoh - */ -public class GetOrganisationUnitsAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private CurrentUserService currentUserService; - - public void setCurrentUserService( CurrentUserService currentUserService ) - { - this.currentUserService = currentUserService; - } - - // ------------------------------------------------------------------------- - // Input & Output - // ------------------------------------------------------------------------- - - private List organisationUnits = new ArrayList(); - - public List getOrganisationUnits() - { - return organisationUnits; - } - - // ------------------------------------------------------------------------- - // Action Implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - { - User user = currentUserService.getCurrentUser(); - - if ( user != null ) - { - organisationUnits = new ArrayList( user.getOrganisationUnits() ); - Collections.sort( organisationUnits, new OrganisationUnitNameComparator() ); - } - - return SUCCESS; - } -} === removed file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/GetPeriodsAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/GetPeriodsAction.java 2011-09-27 12:03:32 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/GetPeriodsAction.java 1970-01-01 00:00:00 +0000 @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2004-2011, 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. - */ -package org.hisp.dhis.light.action.dataentry; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.hisp.dhis.dataset.CompleteDataSetRegistration; -import org.hisp.dhis.dataset.CompleteDataSetRegistrationService; -import org.hisp.dhis.dataset.DataSet; -import org.hisp.dhis.dataset.DataSetService; -import org.hisp.dhis.i18n.I18nFormat; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.period.CalendarPeriodType; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter; -import org.hisp.dhis.system.util.FilterUtils; - -import com.opensymphony.xwork2.Action; - -/** - * @author mortenoh - */ -public class GetPeriodsAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private OrganisationUnitService organisationUnitService; - - public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) - { - this.organisationUnitService = organisationUnitService; - } - - private DataSetService dataSetService; - - public void setDataSetService( DataSetService dataSetService ) - { - this.dataSetService = dataSetService; - } - - private CompleteDataSetRegistrationService registrationService; - - public void setRegistrationService( CompleteDataSetRegistrationService registrationService ) - { - this.registrationService = registrationService; - } - - private I18nFormat format; - - public void setFormat( I18nFormat format ) - { - this.format = format; - } - - // ------------------------------------------------------------------------- - // Input & Output - // ------------------------------------------------------------------------- - - private Integer organisationUnitId; - - public void setOrganisationUnitId( Integer organisationUnitId ) - { - this.organisationUnitId = organisationUnitId; - } - - public Integer getOrganisationUnitId() - { - return organisationUnitId; - } - - private Integer dataSetId; - - public void setDataSetId( Integer dataSetId ) - { - this.dataSetId = dataSetId; - } - - public Integer getDataSetId() - { - return dataSetId; - } - - private Map periodCompletedMap = new HashMap(); - - public Map getPeriodCompletedMap() - { - return periodCompletedMap; - } - - private List periods = new ArrayList(); - - public List getPeriods() - { - return periods; - } - - // ------------------------------------------------------------------------- - // Action Implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - { - if ( dataSetId != null ) - { - OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId ); - DataSet dataSet = dataSetService.getDataSet( dataSetId ); - CalendarPeriodType periodType = (CalendarPeriodType) dataSet.getPeriodType(); - periods = periodType.generatePeriods( new Date() ); - FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() ); - - for ( Period period : periods ) - { - period.setName( format.formatPeriod( period ) ); - - CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, - period, organisationUnit ); - - periodCompletedMap.put( period, registration != null ? true : false ); - } - } - - return SUCCESS; - } -} === removed file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/GetSectionFormAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/GetSectionFormAction.java 2011-09-28 09:35:12 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/GetSectionFormAction.java 1970-01-01 00:00:00 +0000 @@ -1,286 +0,0 @@ -/* - * 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. - */ - -package org.hisp.dhis.light.action.dataentry; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -import org.apache.commons.collections.CollectionUtils; -import org.hisp.dhis.dataanalysis.DataAnalysisService; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; -import org.hisp.dhis.dataset.CompleteDataSetRegistration; -import org.hisp.dhis.dataset.CompleteDataSetRegistrationService; -import org.hisp.dhis.dataset.DataSet; -import org.hisp.dhis.dataset.DataSetService; -import org.hisp.dhis.datavalue.DataValue; -import org.hisp.dhis.datavalue.DataValueService; -import org.hisp.dhis.datavalue.DeflatedDataValue; -import org.hisp.dhis.minmax.MinMaxDataElement; -import org.hisp.dhis.minmax.MinMaxDataElementService; -import org.hisp.dhis.minmax.validation.MinMaxValuesGenerationService; -import org.hisp.dhis.options.SystemSettingManager; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.period.PeriodService; -import org.hisp.dhis.system.util.ListUtils; - -import com.opensymphony.xwork2.Action; - -/** - * @author mortenoh - */ -public class GetSectionFormAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private OrganisationUnitService organisationUnitService; - - public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) - { - this.organisationUnitService = organisationUnitService; - } - - private DataValueService dataValueService; - - public void setDataValueService( DataValueService dataValueService ) - { - this.dataValueService = dataValueService; - } - - private DataSetService dataSetService; - - public void setDataSetService( DataSetService dataSetService ) - { - this.dataSetService = dataSetService; - } - - private CompleteDataSetRegistrationService registrationService; - - public void setRegistrationService( CompleteDataSetRegistrationService registrationService ) - { - this.registrationService = registrationService; - } - - private PeriodService periodService; - - public void setPeriodService( PeriodService periodService ) - { - this.periodService = periodService; - } - - private DataAnalysisService stdDevOutlierAnalysisService; - - public void setStdDevOutlierAnalysisService( DataAnalysisService stdDevOutlierAnalysisService ) - { - this.stdDevOutlierAnalysisService = stdDevOutlierAnalysisService; - } - - private DataAnalysisService minMaxOutlierAnalysisService; - - public void setMinMaxOutlierAnalysisService( DataAnalysisService minMaxOutlierAnalysisService ) - { - this.minMaxOutlierAnalysisService = minMaxOutlierAnalysisService; - } - - private SystemSettingManager systemSettingManager; - - public void setSystemSettingManager( SystemSettingManager systemSettingManager ) - { - this.systemSettingManager = systemSettingManager; - } - - private MinMaxValuesGenerationService minMaxValuesGenerationService; - - public void setMinMaxValuesGenerationService( MinMaxValuesGenerationService minMaxValuesGenerationService ) - { - this.minMaxValuesGenerationService = minMaxValuesGenerationService; - } - - private MinMaxDataElementService minMaxDataElementService; - - public void setMinMaxDataElementService( MinMaxDataElementService minMaxDataElementService ) - { - this.minMaxDataElementService = minMaxDataElementService; - } - - // ------------------------------------------------------------------------- - // Input & Output - // ------------------------------------------------------------------------- - - private Integer organisationUnitId; - - public void setOrganisationUnitId( Integer organisationUnitId ) - { - this.organisationUnitId = organisationUnitId; - } - - public Integer getOrganisationUnitId() - { - return organisationUnitId; - } - - private String periodId; - - public void setPeriodId( String periodId ) - { - this.periodId = periodId; - } - - public String getPeriodId() - { - return periodId; - } - - private Integer dataSetId; - - public void setDataSetId( Integer dataSetId ) - { - this.dataSetId = dataSetId; - } - - public Integer getDataSetId() - { - return dataSetId; - } - - private DataSet dataSet; - - public DataSet getDataSet() - { - return dataSet; - } - - private Map dataValues = new HashMap(); - - public Map getDataValues() - { - return dataValues; - } - - private Map validationErrors = new HashMap(); - - public Map getValidationErrors() - { - return validationErrors; - } - - private Boolean complete = false; - - public void setComplete( Boolean complete ) - { - this.complete = complete; - } - - public Boolean getComplete() - { - return complete; - } - - private String page; - - public String getPage() - { - return page; - } - - // ------------------------------------------------------------------------- - // Action Implementation - // ------------------------------------------------------------------------- - - @SuppressWarnings( "unchecked" ) - @Override - public String execute() - { - OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId ); - - Period period = periodService.getPeriodByExternalId( periodId ); - - dataSet = dataSetService.getDataSet( dataSetId ); - - List values = new ArrayList( dataValueService.getDataValues( organisationUnit, period, - dataSet.getDataElements() ) ); - - for ( DataValue dataValue : values ) - { - DataElement dataElement = dataValue.getDataElement(); - DataElementCategoryOptionCombo optionCombo = dataValue.getOptionCombo(); - - String key = String.format( "DE%dOC%d", dataElement.getId(), optionCombo.getId() ); - String value = dataValue.getValue(); - - dataValues.put( key, value ); - } - - Collection minmaxs = minMaxDataElementService.getMinMaxDataElements( organisationUnit, - dataSet.getDataElements() ); - - Collection deflatedDataValues = new HashSet(); - - if ( minmaxs == null ) - { - Double factor = (Double) systemSettingManager.getSystemSetting( - SystemSettingManager.KEY_FACTOR_OF_DEVIATION, 2.0 ); - - Collection stdDevs = stdDevOutlierAnalysisService.analyse( organisationUnit, - dataSet.getDataElements(), ListUtils.getCollection( period ), factor ); - - Collection minMaxs = minMaxOutlierAnalysisService.analyse( organisationUnit, - dataSet.getDataElements(), ListUtils.getCollection( period ), null ); - - deflatedDataValues = CollectionUtils.union( stdDevs, minMaxs ); - } - else - { - deflatedDataValues = minMaxValuesGenerationService.findOutliers( organisationUnit, - ListUtils.getCollection( period ), minmaxs ); - } - - for ( DeflatedDataValue deflatedDataValue : deflatedDataValues ) - { - String key = String.format( "DE%dOC%d", deflatedDataValue.getDataElementId(), - deflatedDataValue.getCategoryOptionComboId() ); - validationErrors.put( key, deflatedDataValue ); - } - - CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period, - organisationUnit ); - - complete = registration != null ? true : false; - - return SUCCESS; - } -} === removed file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/SaveSectionFormAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/SaveSectionFormAction.java 2011-09-27 12:03:32 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/dataentry/SaveSectionFormAction.java 1970-01-01 00:00:00 +0000 @@ -1,305 +0,0 @@ -/* - * 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. - */ - -package org.hisp.dhis.light.action.dataentry; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.apache.struts2.ServletActionContext; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; -import org.hisp.dhis.dataelement.DataElementCategoryService; -import org.hisp.dhis.dataelement.DataElementService; -import org.hisp.dhis.dataset.CompleteDataSetRegistration; -import org.hisp.dhis.dataset.CompleteDataSetRegistrationService; -import org.hisp.dhis.dataset.DataSet; -import org.hisp.dhis.dataset.DataSetService; -import org.hisp.dhis.dataset.Section; -import org.hisp.dhis.datavalue.DataValue; -import org.hisp.dhis.datavalue.DataValueService; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.period.PeriodType; -import org.hisp.dhis.user.CurrentUserService; -import org.hisp.dhis.util.ContextUtils; - -import com.opensymphony.xwork2.Action; -import com.opensymphony.xwork2.ActionContext; - -/** - * @author mortenoh - */ -public class SaveSectionFormAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private CurrentUserService currentUserService; - - public void setCurrentUserService( CurrentUserService currentUserService ) - { - this.currentUserService = currentUserService; - } - - private OrganisationUnitService organisationUnitService; - - public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) - { - this.organisationUnitService = organisationUnitService; - } - - private DataElementService dataElementService; - - public void setDataElementService( DataElementService dataElementService ) - { - this.dataElementService = dataElementService; - } - - private DataElementCategoryService categoryService; - - public void setCategoryService( DataElementCategoryService categoryService ) - { - this.categoryService = categoryService; - } - - private DataValueService dataValueService; - - public void setDataValueService( DataValueService dataValueService ) - { - this.dataValueService = dataValueService; - } - - private DataSetService dataSetService; - - public void setDataSetService( DataSetService dataSetService ) - { - this.dataSetService = dataSetService; - } - - private CompleteDataSetRegistrationService registrationService; - - public void setRegistrationService( CompleteDataSetRegistrationService registrationService ) - { - this.registrationService = registrationService; - } - - // ------------------------------------------------------------------------- - // Input & Output - // ------------------------------------------------------------------------- - - private Integer organisationUnitId; - - public void setOrganisationUnitId( Integer organisationUnitId ) - { - this.organisationUnitId = organisationUnitId; - } - - public Integer getOrganisationUnitId() - { - return organisationUnitId; - } - - private String periodId; - - public void setPeriodId( String periodId ) - { - this.periodId = periodId; - } - - public String getPeriodId() - { - return periodId; - } - - private Integer dataSetId; - - public void setDataSetId( Integer dataSetId ) - { - this.dataSetId = dataSetId; - } - - public Integer getDataSetId() - { - return dataSetId; - } - - private DataSet dataSet; - - public DataSet getDataSet() - { - return dataSet; - } - - private Map dataValues = new HashMap(); - - public Map getDataValues() - { - return dataValues; - } - - private Boolean complete = false; - - public void setComplete( Boolean complete ) - { - this.complete = complete; - } - - public Boolean getComplete() - { - return complete; - } - - private Boolean validated; - - public void setValidated( Boolean validated ) - { - this.validated = validated; - } - - public Boolean getValidated() - { - return validated; - } - - // ------------------------------------------------------------------------- - // Action Implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - { - OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId ); - - Period period = PeriodType.createPeriodExternalId( periodId ); - - String storedBy = currentUserService.getCurrentUsername(); - - dataSet = dataSetService.getDataSet( dataSetId ); - - if ( storedBy == null ) - { - storedBy = "[unknown]"; - } - - HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get( - ServletActionContext.HTTP_REQUEST ); - Map parameterMap = ContextUtils.getParameterMap( request ); - - for ( String key : parameterMap.keySet() ) - { - if ( key.startsWith( "DE" ) && key.indexOf( "OC" ) != -1 ) - { - String[] splitKey = key.split( "OC" ); - Integer dataElementId = Integer.parseInt( splitKey[0].substring( 2 ) ); - Integer optionComboId = Integer.parseInt( splitKey[1] ); - String value = parameterMap.get( key ); - - DataElement dataElement = dataElementService.getDataElement( dataElementId ); - DataElementCategoryOptionCombo optionCombo = categoryService - .getDataElementCategoryOptionCombo( optionComboId ); - - DataValue dataValue = dataValueService - .getDataValue( organisationUnit, dataElement, period, optionCombo ); - - value = value.trim(); - - if ( dataValue == null ) - { - if ( value != null && value.length() != 0 ) - { - dataValue = new DataValue( dataElement, period, organisationUnit, value, storedBy, new Date(), - null, optionCombo ); - dataValueService.addDataValue( dataValue ); - } - } - else - { - dataValue.setValue( value ); - dataValue.setTimestamp( new Date() ); - dataValue.setStoredBy( storedBy ); - - dataValueService.updateDataValue( dataValue ); - } - } - } - - for ( Section section : dataSet.getSections() ) - { - for ( DataElement dataElement : section.getDataElements() ) - { - for ( DataElementCategoryOptionCombo optionCombo : dataElement.getCategoryCombo().getOptionCombos() ) - { - DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, period, - optionCombo ); - - String key = String.format( "DE%dOC%d", dataElement.getId(), optionCombo.getId() ); - String value = ""; - - if ( dataValue != null ) - { - value = dataValue.getValue(); - } - - dataValues.put( key, value ); - } - } - } - - CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period, - organisationUnit ); - - if ( registration == null && complete ) - { - registration = new CompleteDataSetRegistration(); - registration.setDataSet( dataSet ); - registration.setPeriod( period ); - registration.setSource( organisationUnit ); - registration.setDate( new Date() ); - - registrationService.saveCompleteDataSetRegistration( registration ); - } - else if ( registration != null && !complete ) - { - registrationService.deleteCompleteDataSetRegistration( registration ); - } - - if ( validated == null || !validated ) - { - validated = true; - return ERROR; - } - - return SUCCESS; - } -} === added directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard' === added directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action' === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/GetChartAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/GetChartAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/GetChartAction.java 2011-09-28 10:34:08 +0000 @@ -0,0 +1,124 @@ +package org.hisp.dhis.light.dashboard.action; + +/* + * 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 org.hisp.dhis.chart.ChartService; +import org.hisp.dhis.i18n.I18nFormat; +import org.jfree.chart.JFreeChart; + +import com.opensymphony.xwork2.Action; + +/** + * @author Lars Helge Overland + * @version $Id$ + */ +public class GetChartAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ChartService chartService; + + public void setChartService( ChartService chartService ) + { + this.chartService = chartService; + } + + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private JFreeChart chart; + + public JFreeChart getChart() + { + return chart; + } + + private int height; + + public int getHeight() + { + return height; + } + + public void setHeight( int height ) + { + this.height = height; + } + + private int width; + + public int getWidth() + { + return width; + } + + public void setWidth( int width ) + { + this.width = width; + } + + // ------------------------------------------------------------------------- + // Action implemenation + // ------------------------------------------------------------------------- + + public String execute() + { + if ( id != null ) + { + chart = chartService.getJFreeChart( id, format ); + + height = 280; + + width = 400; + } + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/GetReportAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/GetReportAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/GetReportAction.java 2011-09-28 10:34:08 +0000 @@ -0,0 +1,105 @@ +package org.hisp.dhis.light.dashboard.action; + +/* + * 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 org.hisp.dhis.common.Grid; +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.reporttable.ReportTableService; + +import com.opensymphony.xwork2.Action; + +public class GetReportAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ReportTableService reportTableService; + + public void setReportTableService( ReportTableService reportTableService ) + { + this.reportTableService = reportTableService; + } + + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private Integer reportingPeriod; + + public void setReportingPeriod( Integer reportingPeriod ) + { + this.reportingPeriod = reportingPeriod; + } + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private Grid grid; + + public Grid getGrid() + { + return grid; + } + + // ------------------------------------------------------------------------- + // Result implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + grid = reportTableService.getReportTableGrid( id, format, reportingPeriod, organisationUnitId ); + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/GetReportParamsAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/GetReportParamsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/GetReportParamsAction.java 2011-09-28 10:34:08 +0000 @@ -0,0 +1,157 @@ +package org.hisp.dhis.light.dashboard.action; + +/* + * 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.SortedMap; +import java.util.TreeMap; + +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.oust.manager.SelectionTreeManager; +import org.hisp.dhis.period.MonthlyPeriodType; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.period.PeriodType; +import org.hisp.dhis.report.Report; +import org.hisp.dhis.reporttable.ReportParams; +import org.hisp.dhis.reporttable.ReportTable; +import org.hisp.dhis.reporttable.ReportTableService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Lars Helge Overland + */ +public class GetReportParamsAction + implements Action +{ + private static final int AVAILABLE_REPORTING_MONTHS = 24; + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ReportTableService reportTableService; + + public void setReportTableService( ReportTableService reportTableService ) + { + this.reportTableService = reportTableService; + } + + private SelectionTreeManager selectionTreeManager; + + public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager ) + { + this.selectionTreeManager = selectionTreeManager; + } + + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer id; + + public Integer getId() + { + return id; + } + + public void setId( Integer id ) + { + this.id = id; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private ReportParams reportParams; + + public ReportParams getReportParams() + { + return reportParams; + } + + private SortedMap reportingPeriods = new TreeMap(); + + public SortedMap getReportingPeriods() + { + return reportingPeriods; + } + + private Report report; + + public Report getReport() + { + return report; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + selectionTreeManager.setCurrentUserOrganisationUnitAsSelected(); + + if ( id != null ) + { + ReportTable reportTable = reportTableService.getReportTable( id, ReportTableService.MODE_REPORT_TABLE ); + + if ( reportTable != null ) + { + reportParams = reportTable.getReportParams(); + + if ( reportParams.isParamReportingMonth() ) + { + MonthlyPeriodType periodType = new MonthlyPeriodType(); + + Calendar cal = PeriodType.createCalendarInstance(); + + for ( int i = 0; i < AVAILABLE_REPORTING_MONTHS; i++ ) + { + int month = i + 1; + cal.add( Calendar.MONTH, -1 ); + Period period = periodType.createPeriod( cal.getTime() ); + String periodName = format.formatPeriod( period ); + + reportingPeriods.put( month, periodName ); + } + } + } + } + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/ProvideContentAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/ProvideContentAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/ProvideContentAction.java 2011-09-28 10:34:08 +0000 @@ -0,0 +1,99 @@ +package org.hisp.dhis.light.dashboard.action; + +import java.util.ArrayList; +import java.util.List; + +import org.hisp.dhis.dashboard.DashboardConfiguration; +import org.hisp.dhis.dashboard.DashboardContent; +import org.hisp.dhis.dashboard.DashboardManager; +import org.hisp.dhis.dashboard.DashboardService; +import org.hisp.dhis.document.Document; +import org.hisp.dhis.reporttable.ReportTable; +import org.hisp.dhis.user.CurrentUserService; +import org.hisp.dhis.user.User; + +import com.opensymphony.xwork2.Action; + +public class ProvideContentAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private DashboardService dashboardService; + + public void setDashboardService( DashboardService dashboardService ) + { + this.dashboardService = dashboardService; + } + + private DashboardManager dashboardManager; + + public void setDashboardManager( DashboardManager dashboardManager ) + { + this.dashboardManager = dashboardManager; + } + + private CurrentUserService currentUserService; + + public void setCurrentUserService( CurrentUserService currentUserService ) + { + this.currentUserService = currentUserService; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private List reportTables; + + public List getReportTables() + { + return reportTables; + } + + private List documents; + + public List getDocuments() + { + return documents; + } + + private List charts = new ArrayList(); + + public List getCharts() + { + return charts; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + DashboardConfiguration config = dashboardManager.getConfiguration(); + + for ( int i = 0; i < 8; i++ ) + { + String id = config.getAreaItems().get( DashboardManager.CHART_AREA_PREFIX + (i + 1) ); + + if ( id != null ) + { + charts.add( id ); + } + } + + User user = currentUserService.getCurrentUser(); + + DashboardContent content = dashboardService.getDashboardContent( user ); + + reportTables = content.getReportTables(); + + documents = content.getDocuments(); + + return SUCCESS; + } +} === added directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry' === added directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action' === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetsAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetsAction.java 2011-09-28 10:34:08 +0000 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2004-2011, 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. + */ + +package org.hisp.dhis.light.dataentry.action; + +import java.util.ArrayList; +import java.util.List; + +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.system.filter.DataSetTypeFilter; +import org.hisp.dhis.system.util.FilterUtils; + +import com.opensymphony.xwork2.Action; + +/** + * @author mortenoh + */ +public class GetDataSetsAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId() + { + return organisationUnitId; + } + + private List dataSets = new ArrayList(); + + public List getDataSets() + { + return dataSets; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + { + if ( organisationUnitId != null ) + { + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId ); + dataSets = new ArrayList( organisationUnit.getDataSets() ); + FilterUtils.filter( dataSets, new DataSetTypeFilter( DataSet.TYPE_SECTION ) ); + } + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetOrganisationUnitsAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetOrganisationUnitsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetOrganisationUnitsAction.java 2011-09-28 10:34:08 +0000 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2004-2011, 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. + */ + +package org.hisp.dhis.light.dataentry.action; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator; +import org.hisp.dhis.user.CurrentUserService; +import org.hisp.dhis.user.User; + +import com.opensymphony.xwork2.Action; + +/** + * @author mortenoh + */ +public class GetOrganisationUnitsAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private CurrentUserService currentUserService; + + public void setCurrentUserService( CurrentUserService currentUserService ) + { + this.currentUserService = currentUserService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private List organisationUnits = new ArrayList(); + + public List getOrganisationUnits() + { + return organisationUnits; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + { + User user = currentUserService.getCurrentUser(); + + if ( user != null ) + { + organisationUnits = new ArrayList( user.getOrganisationUnits() ); + Collections.sort( organisationUnits, new OrganisationUnitNameComparator() ); + } + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java 2011-09-28 10:34:08 +0000 @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2004-2011, 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. + */ +package org.hisp.dhis.light.dataentry.action; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.hisp.dhis.dataset.CompleteDataSetRegistration; +import org.hisp.dhis.dataset.CompleteDataSetRegistrationService; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.period.CalendarPeriodType; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter; +import org.hisp.dhis.system.util.FilterUtils; + +import com.opensymphony.xwork2.Action; + +/** + * @author mortenoh + */ +public class GetPeriodsAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + private CompleteDataSetRegistrationService registrationService; + + public void setRegistrationService( CompleteDataSetRegistrationService registrationService ) + { + this.registrationService = registrationService; + } + + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId() + { + return organisationUnitId; + } + + private Integer dataSetId; + + public void setDataSetId( Integer dataSetId ) + { + this.dataSetId = dataSetId; + } + + public Integer getDataSetId() + { + return dataSetId; + } + + private Map periodCompletedMap = new HashMap(); + + public Map getPeriodCompletedMap() + { + return periodCompletedMap; + } + + private List periods = new ArrayList(); + + public List getPeriods() + { + return periods; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + { + if ( dataSetId != null ) + { + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId ); + DataSet dataSet = dataSetService.getDataSet( dataSetId ); + CalendarPeriodType periodType = (CalendarPeriodType) dataSet.getPeriodType(); + periods = periodType.generatePeriods( new Date() ); + FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() ); + + for ( Period period : periods ) + { + period.setName( format.formatPeriod( period ) ); + + CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, + period, organisationUnit ); + + periodCompletedMap.put( period, registration != null ? true : false ); + } + } + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java 2011-09-28 10:34:08 +0000 @@ -0,0 +1,195 @@ +/* + * 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. + */ + +package org.hisp.dhis.light.dataentry.action; + +import java.util.HashMap; +import java.util.Map; + +import org.hisp.dhis.dataset.CompleteDataSetRegistration; +import org.hisp.dhis.dataset.CompleteDataSetRegistrationService; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.datavalue.DeflatedDataValue; +import org.hisp.dhis.light.dataentry.utils.SectionFormUtils; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.period.PeriodService; + +import com.opensymphony.xwork2.Action; + +/** + * @author mortenoh + */ +public class GetSectionFormAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + private CompleteDataSetRegistrationService registrationService; + + public void setRegistrationService( CompleteDataSetRegistrationService registrationService ) + { + this.registrationService = registrationService; + } + + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } + + private SectionFormUtils sectionFormUtils; + + public void setSectionFormUtils( SectionFormUtils sectionFormUtils ) + { + this.sectionFormUtils = sectionFormUtils; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId() + { + return organisationUnitId; + } + + private String periodId; + + public void setPeriodId( String periodId ) + { + this.periodId = periodId; + } + + public String getPeriodId() + { + return periodId; + } + + private Integer dataSetId; + + public void setDataSetId( Integer dataSetId ) + { + this.dataSetId = dataSetId; + } + + public Integer getDataSetId() + { + return dataSetId; + } + + private DataSet dataSet; + + public DataSet getDataSet() + { + return dataSet; + } + + private Map dataValues = new HashMap(); + + public Map getDataValues() + { + return dataValues; + } + + private Map validationErrors = new HashMap(); + + public Map getValidationErrors() + { + return validationErrors; + } + + private Boolean complete = false; + + public void setComplete( Boolean complete ) + { + this.complete = complete; + } + + public Boolean getComplete() + { + return complete; + } + + private String page; + + public String getPage() + { + return page; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + { + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId ); + + Period period = periodService.getPeriodByExternalId( periodId ); + + dataSet = dataSetService.getDataSet( dataSetId ); + + dataValues = sectionFormUtils.getDataValueMap( organisationUnit, dataSet, period ); + + validationErrors = sectionFormUtils.getValidationErrorMap( organisationUnit, dataSet, period ); + + CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period, + organisationUnit ); + + complete = registration != null ? true : false; + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java 2011-09-28 10:34:08 +0000 @@ -0,0 +1,309 @@ +/* + * 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. + */ + +package org.hisp.dhis.light.dataentry.action; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.struts2.ServletActionContext; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.dataset.CompleteDataSetRegistration; +import org.hisp.dhis.dataset.CompleteDataSetRegistrationService; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.datavalue.DataValue; +import org.hisp.dhis.datavalue.DataValueService; +import org.hisp.dhis.datavalue.DeflatedDataValue; +import org.hisp.dhis.light.dataentry.utils.SectionFormUtils; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.period.PeriodService; +import org.hisp.dhis.user.CurrentUserService; +import org.hisp.dhis.util.ContextUtils; + +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionContext; + +/** + * @author mortenoh + */ +public class SaveSectionFormAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private CurrentUserService currentUserService; + + public void setCurrentUserService( CurrentUserService currentUserService ) + { + this.currentUserService = currentUserService; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private DataElementService dataElementService; + + public void setDataElementService( DataElementService dataElementService ) + { + this.dataElementService = dataElementService; + } + + private DataElementCategoryService categoryService; + + public void setCategoryService( DataElementCategoryService categoryService ) + { + this.categoryService = categoryService; + } + + private DataValueService dataValueService; + + public void setDataValueService( DataValueService dataValueService ) + { + this.dataValueService = dataValueService; + } + + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + private CompleteDataSetRegistrationService registrationService; + + public void setRegistrationService( CompleteDataSetRegistrationService registrationService ) + { + this.registrationService = registrationService; + } + + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } + + private SectionFormUtils sectionFormUtils; + + public void setSectionFormUtils( SectionFormUtils sectionFormUtils ) + { + this.sectionFormUtils = sectionFormUtils; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId() + { + return organisationUnitId; + } + + private String periodId; + + public void setPeriodId( String periodId ) + { + this.periodId = periodId; + } + + public String getPeriodId() + { + return periodId; + } + + private Integer dataSetId; + + public void setDataSetId( Integer dataSetId ) + { + this.dataSetId = dataSetId; + } + + public Integer getDataSetId() + { + return dataSetId; + } + + private DataSet dataSet; + + public DataSet getDataSet() + { + return dataSet; + } + + private Map dataValues = new HashMap(); + + public Map getDataValues() + { + return dataValues; + } + + private Map validationErrors = new HashMap(); + + public Map getValidationErrors() + { + return validationErrors; + } + + private Boolean complete = false; + + public void setComplete( Boolean complete ) + { + this.complete = complete; + } + + public Boolean getComplete() + { + return complete; + } + + private Boolean validated; + + public void setValidated( Boolean validated ) + { + this.validated = validated; + } + + public Boolean getValidated() + { + return validated; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + { + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId ); + + Period period = periodService.getPeriodByExternalId( periodId ); + + String storedBy = currentUserService.getCurrentUsername(); + + dataSet = dataSetService.getDataSet( dataSetId ); + + if ( storedBy == null ) + { + storedBy = "[unknown]"; + } + + HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get( + ServletActionContext.HTTP_REQUEST ); + Map parameterMap = ContextUtils.getParameterMap( request ); + + for ( String key : parameterMap.keySet() ) + { + if ( key.startsWith( "DE" ) && key.indexOf( "OC" ) != -1 ) + { + String[] splitKey = key.split( "OC" ); + Integer dataElementId = Integer.parseInt( splitKey[0].substring( 2 ) ); + Integer optionComboId = Integer.parseInt( splitKey[1] ); + String value = parameterMap.get( key ); + + DataElement dataElement = dataElementService.getDataElement( dataElementId ); + DataElementCategoryOptionCombo optionCombo = categoryService + .getDataElementCategoryOptionCombo( optionComboId ); + + DataValue dataValue = dataValueService + .getDataValue( organisationUnit, dataElement, period, optionCombo ); + + value = value.trim(); + + if ( dataValue == null ) + { + if ( value != null && value.length() != 0 ) + { + dataValue = new DataValue( dataElement, period, organisationUnit, value, storedBy, new Date(), + null, optionCombo ); + dataValueService.addDataValue( dataValue ); + } + } + else + { + dataValue.setValue( value ); + dataValue.setTimestamp( new Date() ); + dataValue.setStoredBy( storedBy ); + + dataValueService.updateDataValue( dataValue ); + } + } + } + + CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period, + organisationUnit ); + + if ( registration == null && complete ) + { + registration = new CompleteDataSetRegistration(); + registration.setDataSet( dataSet ); + registration.setPeriod( period ); + registration.setSource( organisationUnit ); + registration.setDate( new Date() ); + + registrationService.saveCompleteDataSetRegistration( registration ); + } + else if ( registration != null && !complete ) + { + registrationService.deleteCompleteDataSetRegistration( registration ); + } + + dataValues = sectionFormUtils.getDataValueMap( organisationUnit, dataSet, period ); + + validationErrors = sectionFormUtils.getValidationErrorMap( organisationUnit, dataSet, period ); + + if ( validated == null || !validated ) + { + validated = true; + return ERROR; + } + + return SUCCESS; + } +} === added directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils' === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils/SectionFormUtils.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils/SectionFormUtils.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils/SectionFormUtils.java 2011-09-28 10:34:08 +0000 @@ -0,0 +1,167 @@ +/* + * 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. + */ + +package org.hisp.dhis.light.dataentry.utils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import org.apache.commons.collections.CollectionUtils; +import org.hisp.dhis.dataanalysis.DataAnalysisService; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.datavalue.DataValue; +import org.hisp.dhis.datavalue.DataValueService; +import org.hisp.dhis.datavalue.DeflatedDataValue; +import org.hisp.dhis.minmax.MinMaxDataElement; +import org.hisp.dhis.minmax.MinMaxDataElementService; +import org.hisp.dhis.minmax.validation.MinMaxValuesGenerationService; +import org.hisp.dhis.options.SystemSettingManager; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.system.util.ListUtils; + +/** + * @author mortenoh + */ +public class SectionFormUtils +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private DataValueService dataValueService; + + public void setDataValueService( DataValueService dataValueService ) + { + this.dataValueService = dataValueService; + } + + private DataAnalysisService stdDevOutlierAnalysisService; + + public void setStdDevOutlierAnalysisService( DataAnalysisService stdDevOutlierAnalysisService ) + { + this.stdDevOutlierAnalysisService = stdDevOutlierAnalysisService; + } + + private DataAnalysisService minMaxOutlierAnalysisService; + + public void setMinMaxOutlierAnalysisService( DataAnalysisService minMaxOutlierAnalysisService ) + { + this.minMaxOutlierAnalysisService = minMaxOutlierAnalysisService; + } + + private SystemSettingManager systemSettingManager; + + public void setSystemSettingManager( SystemSettingManager systemSettingManager ) + { + this.systemSettingManager = systemSettingManager; + } + + private MinMaxValuesGenerationService minMaxValuesGenerationService; + + public void setMinMaxValuesGenerationService( MinMaxValuesGenerationService minMaxValuesGenerationService ) + { + this.minMaxValuesGenerationService = minMaxValuesGenerationService; + } + + private MinMaxDataElementService minMaxDataElementService; + + public void setMinMaxDataElementService( MinMaxDataElementService minMaxDataElementService ) + { + this.minMaxDataElementService = minMaxDataElementService; + } + + // ------------------------------------------------------------------------- + // Utils + // ------------------------------------------------------------------------- + + @SuppressWarnings( "unchecked" ) + public Map getValidationErrorMap( OrganisationUnit organisationUnit, DataSet dataSet, + Period period ) + { + Map validationErrorMap = new HashMap(); + + Collection minmaxs = minMaxDataElementService.getMinMaxDataElements( organisationUnit, + dataSet.getDataElements() ); + + Collection deflatedDataValues = new HashSet(); + + if ( minmaxs == null ) + { + Double factor = (Double) systemSettingManager.getSystemSetting( + SystemSettingManager.KEY_FACTOR_OF_DEVIATION, 2.0 ); + + Collection stdDevs = stdDevOutlierAnalysisService.analyse( organisationUnit, + dataSet.getDataElements(), ListUtils.getCollection( period ), factor ); + + Collection minMaxs = minMaxOutlierAnalysisService.analyse( organisationUnit, + dataSet.getDataElements(), ListUtils.getCollection( period ), null ); + + deflatedDataValues = CollectionUtils.union( stdDevs, minMaxs ); + } + else + { + deflatedDataValues = minMaxValuesGenerationService.findOutliers( organisationUnit, + ListUtils.getCollection( period ), minmaxs ); + } + + for ( DeflatedDataValue deflatedDataValue : deflatedDataValues ) + { + String key = String.format( "DE%dOC%d", deflatedDataValue.getDataElementId(), + deflatedDataValue.getCategoryOptionComboId() ); + validationErrorMap.put( key, deflatedDataValue ); + } + + return validationErrorMap; + } + + public Map getDataValueMap( OrganisationUnit organisationUnit, DataSet dataSet, Period period ) + { + Map dataValueMap = new HashMap(); + List values = new ArrayList( dataValueService.getDataValues( organisationUnit, period, + dataSet.getDataElements() ) ); + + for ( DataValue dataValue : values ) + { + DataElement dataElement = dataValue.getDataElement(); + DataElementCategoryOptionCombo optionCombo = dataValue.getOptionCombo(); + + String key = String.format( "DE%dOC%d", dataElement.getId(), optionCombo.getId() ); + String value = dataValue.getValue(); + + dataValueMap.put( key, value ); + } + + return dataValueMap; + } +} === modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2011-09-27 12:03:32 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2011-09-28 10:34:08 +0000 @@ -7,27 +7,8 @@ - - - - - - - - - - - - - - - - - + - - - @@ -35,7 +16,29 @@ - + + + + + + + + + + + + + + + + + + + + + + @@ -44,28 +47,30 @@ + + - - - - === modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml 2011-09-27 12:03:32 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml 2011-09-28 10:34:08 +0000 @@ -14,27 +14,27 @@ - + /dhis-web-light/main.vm /dhis-web-light/selectOrganisationUnit.vm - + /dhis-web-light/main.vm /dhis-web-light/selectDataSet.vm - + /dhis-web-light/main.vm /dhis-web-light/selectPeriod.vm - + /dhis-web-light/main.vm /dhis-web-light/dataEntry.vm - + /dhis-web-light/index.action /dhis-web-light/main.vm /dhis-web-light/dataEntry.vm @@ -42,22 +42,22 @@ - + /dhis-web-light/dashboard_page.vm /dhis-web-light/dashboard.vm - + /dhis-web-light/dashboard_page.vm /dhis-web-commons/ajax/htmlGrid.vm - + /dhis-web-light/dashboard_page.vm /dhis-web-light/inputReportParamsForm.vm - + 480 800