dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12392
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3803: Removed type="chain" into dhis-web-dataentry.
------------------------------------------------------------
revno: 3803
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-05-31 14:54:15 +0700
message:
Removed type="chain" into dhis-web-dataentry.
removed:
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SectionFormAction.java
modified:
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SelectAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== removed file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java 2011-05-07 23:05:00 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java 1970-01-01 00:00:00 +0000
@@ -1,499 +0,0 @@
-package org.hisp.dhis.de.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.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategory;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryService;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataelement.comparator.DataElementSortOrderComparator;
-import org.hisp.dhis.dataentryform.DataEntryForm;
-import org.hisp.dhis.dataentryform.DataEntryFormService;
-import org.hisp.dhis.datalock.DataSetLock;
-import org.hisp.dhis.datalock.DataSetLockService;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueService;
-import org.hisp.dhis.de.comments.StandardCommentsManager;
-import org.hisp.dhis.de.state.SelectedStateManager;
-import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.minmax.MinMaxDataElement;
-import org.hisp.dhis.minmax.MinMaxDataElementService;
-import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.Period;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Abyot Asalefew
- * @version $Id$
- */
-public class FormAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private DataElementService dataElementService;
-
- public void setDataElementService( DataElementService dataElementService )
- {
- this.dataElementService = dataElementService;
- }
-
- private DataValueService dataValueService;
-
- public void setDataValueService( DataValueService dataValueService )
- {
- this.dataValueService = dataValueService;
- }
-
- private StandardCommentsManager standardCommentsManager;
-
- public void setStandardCommentsManager( StandardCommentsManager standardCommentsManager )
- {
- this.standardCommentsManager = standardCommentsManager;
- }
-
- private MinMaxDataElementService minMaxDataElementService;
-
- public void setMinMaxDataElementService( MinMaxDataElementService minMaxDataElementService )
- {
- this.minMaxDataElementService = minMaxDataElementService;
- }
-
- private SelectedStateManager selectedStateManager;
-
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
- {
- this.selectedStateManager = selectedStateManager;
- }
-
- private DataEntryFormService dataEntryFormService;
-
- public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
- {
- this.dataEntryFormService = dataEntryFormService;
- }
-
- private DataElementCategoryService categoryService;
-
- public void setCategoryService( DataElementCategoryService categoryService )
- {
- this.categoryService = categoryService;
- }
-
- private I18n i18n;
-
- public void setI18n( I18n i18n )
- {
- this.i18n = i18n;
- }
-
- private DataSetLockService dataSetLockService;
-
- public void setDataSetLockService( DataSetLockService dataSetLockService )
- {
- this.dataSetLockService = dataSetLockService;
- }
-
- // -------------------------------------------------------------------------
- // Comparator
- // -------------------------------------------------------------------------
-
- private Comparator<DataElement> dataElementComparator;
-
- public void setDataElementComparator( Comparator<DataElement> dataElementComparator )
- {
- this.dataElementComparator = dataElementComparator;
- }
-
- // -------------------------------------------------------------------------
- // DisplayPropertyHandler
- // -------------------------------------------------------------------------
-
- private DisplayPropertyHandler displayPropertyHandler;
-
- public void setDisplayPropertyHandler( DisplayPropertyHandler displayPropertyHandler )
- {
- this.displayPropertyHandler = displayPropertyHandler;
- }
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private Map<DataElementCategoryCombo, List<DataElement>> orderedDataElements = new HashMap<DataElementCategoryCombo, List<DataElement>>();
-
- public Map<DataElementCategoryCombo, List<DataElement>> getOrderedDataElements()
- {
- return orderedDataElements;
- }
-
- private Map<String, DataValue> dataValueMap;
-
- public Map<String, DataValue> getDataValueMap()
- {
- return dataValueMap;
- }
-
- private List<String> standardComments;
-
- public List<String> getStandardComments()
- {
- return standardComments;
- }
-
- private Map<String, String> dataElementValueTypeMap;
-
- public Map<String, String> getDataElementValueTypeMap()
- {
- return dataElementValueTypeMap;
- }
-
- private Map<String, MinMaxDataElement> minMaxMap;
-
- public Map<String, MinMaxDataElement> getMinMaxMap()
- {
- return minMaxMap;
- }
-
- private Integer integer = 0;
-
- public Integer getInteger()
- {
- return integer;
- }
-
- private Map<Integer, Map<Integer, Collection<DataElementCategoryOption>>> orderedOptionsMap = new HashMap<Integer, Map<Integer, Collection<DataElementCategoryOption>>>();
-
- public Map<Integer, Map<Integer, Collection<DataElementCategoryOption>>> getOrderedOptionsMap()
- {
- return orderedOptionsMap;
- }
-
- private Map<Integer, Collection<DataElementCategory>> orderedCategories = new HashMap<Integer, Collection<DataElementCategory>>();
-
- public Map<Integer, Collection<DataElementCategory>> getOrderedCategories()
- {
- return orderedCategories;
- }
-
- private Map<Integer, Integer> numberOfTotalColumns = new HashMap<Integer, Integer>();
-
- public Map<Integer, Integer> getNumberOfTotalColumns()
- {
- return numberOfTotalColumns;
- }
-
- private Map<Integer, Map<Integer, Collection<Integer>>> catColRepeat = new HashMap<Integer, Map<Integer, Collection<Integer>>>();
-
- public Map<Integer, Map<Integer, Collection<Integer>>> getCatColRepeat()
- {
- return catColRepeat;
- }
-
- private Map<Integer, Collection<DataElementCategoryOptionCombo>> orderdCategoryOptionCombos = new HashMap<Integer, Collection<DataElementCategoryOptionCombo>>();
-
- public Map<Integer, Collection<DataElementCategoryOptionCombo>> getOrderdCategoryOptionCombos()
- {
- return orderdCategoryOptionCombos;
- }
-
- private Collection<DataElementCategoryOptionCombo> allOptionCombos = new ArrayList<DataElementCategoryOptionCombo>();
-
- public Collection<DataElementCategoryOptionCombo> getAllOptionCombos()
- {
- return allOptionCombos;
- }
-
- private List<DataElementCategoryCombo> orderedCategoryCombos = new ArrayList<DataElementCategoryCombo>();
-
- public List<DataElementCategoryCombo> getOrderedCategoryCombos()
- {
- return orderedCategoryCombos;
- }
-
- private Boolean cdeFormExists;
-
- public Boolean getCdeFormExists()
- {
- return cdeFormExists;
- }
-
- private DataEntryForm dataEntryForm;
-
- public DataEntryForm getDataEntryForm()
- {
- return this.dataEntryForm;
- }
-
- private String customDataEntryFormCode;
-
- public String getCustomDataEntryFormCode()
- {
- return this.customDataEntryFormCode;
- }
-
- // -------------------------------------------------------------------------
- // Input/output
- // -------------------------------------------------------------------------
-
- private Integer selectedDataSetId;
-
- public void setSelectedDataSetId( Integer selectedDataSetId )
- {
- this.selectedDataSetId = selectedDataSetId;
- }
-
- public Integer getSelectedDataSetId()
- {
- return selectedDataSetId;
- }
-
- private Integer selectedPeriodIndex;
-
- public void setSelectedPeriodIndex( Integer selectedPeriodIndex )
- {
- this.selectedPeriodIndex = selectedPeriodIndex;
- }
-
- public Integer getSelectedPeriodIndex()
- {
- return selectedPeriodIndex;
- }
-
- private String disabled = " ";
-
- private String displayMode;
-
- public String getDisplayMode()
- {
- return displayMode;
- }
-
- public void setDisplayMode( String displayMode )
- {
- this.displayMode = displayMode;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- throws Exception
- {
- OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
-
- DataSet dataSet = selectedStateManager.getSelectedDataSet();
-
- Period period = selectedStateManager.getSelectedPeriod();
-
- DataSetLock dataSetLock = dataSetLockService.getDataSetLockByDataSetAndPeriod( dataSet, period );
-
- if ( dataSetLock != null && dataSetLock.getSources().contains( organisationUnit ) )
- {
- disabled = "disabled";
- }
-
- List<DataElement> dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
-
- if ( dataElements.isEmpty() )
- {
- return SUCCESS;
- }
-
- Collections.sort( dataElements, dataElementComparator );
-
- orderedDataElements = dataElementService.getGroupedDataElementsByCategoryCombo( dataElements );
-
- orderedCategoryCombos = dataElementService.getDataElementCategoryCombos( dataElements );
-
- for ( DataElementCategoryCombo categoryCombo : orderedCategoryCombos )
- {
- Collection<DataElementCategoryOptionCombo> optionCombos = categoryService.sortOptionCombos( categoryCombo );
-
- allOptionCombos.addAll( optionCombos );
-
- orderdCategoryOptionCombos.put( categoryCombo.getId(), optionCombos );
-
- // -----------------------------------------------------------------
- // Perform ordering of categories and their options so that they
- // could be displayed as in the paper form. Note that the total
- // number of entry cells to be generated are the multiple of options
- // from each category.
- // -----------------------------------------------------------------
-
- numberOfTotalColumns.put( categoryCombo.getId(), optionCombos.size() );
-
- orderedCategories.put( categoryCombo.getId(), categoryCombo.getCategories() );
-
- Map<Integer, Collection<DataElementCategoryOption>> optionsMap = new HashMap<Integer, Collection<DataElementCategoryOption>>();
-
- for ( DataElementCategory dec : categoryCombo.getCategories() )
- {
- optionsMap.put( dec.getId(), dec.getCategoryOptions() );
- }
-
- orderedOptionsMap.put( categoryCombo.getId(), optionsMap );
-
- // -----------------------------------------------------------------
- // Calculating the number of times each category should be repeated
- // -----------------------------------------------------------------
-
- Map<Integer, Integer> catRepeat = new HashMap<Integer, Integer>();
-
- Map<Integer, Collection<Integer>> colRepeat = new HashMap<Integer, Collection<Integer>>();
-
- int catColSpan = optionCombos.size();
-
- for ( DataElementCategory cat : categoryCombo.getCategories() )
- {
- int categoryOptionSize = cat.getCategoryOptions().size();
-
- if ( catColSpan > 0 && categoryOptionSize > 0 )
- {
- catColSpan = catColSpan / categoryOptionSize;
- int total = optionCombos.size() / ( catColSpan * categoryOptionSize );
- Collection<Integer> cols = new ArrayList<Integer>( total );
-
- for ( int i = 0; i < total; i++ )
- {
- cols.add( i );
- }
-
- /*
- * TODO Cols are made to be a collection simply to
- * facilitate a for loop in the velocity template - there
- * should be a better way of "for" doing a loop.
- */
-
- colRepeat.put( cat.getId(), cols );
-
- catRepeat.put( cat.getId(), catColSpan );
- }
- }
-
- catColRepeat.put( categoryCombo.getId(), colRepeat );
- }
-
- // ---------------------------------------------------------------------
- // Get the min/max values
- // ---------------------------------------------------------------------
-
- Collection<MinMaxDataElement> minMaxDataElements = minMaxDataElementService.getMinMaxDataElements(
- organisationUnit, dataElements );
-
- minMaxMap = new HashMap<String, MinMaxDataElement>( minMaxDataElements.size() );
-
- for ( MinMaxDataElement minMaxDataElement : minMaxDataElements )
- {
- minMaxMap.put( minMaxDataElement.getDataElement().getId() + ":"
- + minMaxDataElement.getOptionCombo().getId(), minMaxDataElement );
- }
-
- // ---------------------------------------------------------------------
- // Get the DataValues and create a map
- // ---------------------------------------------------------------------
-
- Collection<DataValue> dataValues = dataValueService.getDataValues( organisationUnit, period, dataElements,
- allOptionCombos );
-
- dataValueMap = new HashMap<String, DataValue>( dataValues.size() );
-
- for ( DataValue dataValue : dataValues )
- {
- Integer deId = dataValue.getDataElement().getId();
- Integer ocId = dataValue.getOptionCombo().getId();
-
- dataValueMap.put( deId.toString() + ':' + ocId.toString(), dataValue );
- }
-
- // ---------------------------------------------------------------------
- // Make the standard comments available
- // ---------------------------------------------------------------------
-
- standardComments = standardCommentsManager.getStandardComments();
-
- // ---------------------------------------------------------------------
- // Make the DataElement types available
- // ---------------------------------------------------------------------
-
- dataElementValueTypeMap = new HashMap<String, String>();
- dataElementValueTypeMap.put( DataElement.VALUE_TYPE_DATE, i18n.getString( "date" ) );
- dataElementValueTypeMap.put( DataElement.VALUE_TYPE_BOOL, i18n.getString( "yes_no" ) );
- dataElementValueTypeMap.put( DataElement.VALUE_TYPE_INT, i18n.getString( "number" ) );
- dataElementValueTypeMap.put( DataElement.VALUE_TYPE_STRING, i18n.getString( "text" ) );
-
- // ---------------------------------------------------------------------
- // Get the custom data entry form (if any)
- // ---------------------------------------------------------------------
-
- dataEntryForm = dataSet.getDataEntryForm();
-
- cdeFormExists = (dataEntryForm != null);
-
- if ( cdeFormExists )
- {
- customDataEntryFormCode = dataEntryFormService.prepareDataEntryFormForEntry(
- dataEntryForm.getHtmlCode(), dataValues, minMaxMap, disabled, i18n, dataSet );
- }
-
- // ---------------------------------------------------------------------
- // Working on the display of dataelements
- // ---------------------------------------------------------------------
-
- List<DataElement> des = new ArrayList<DataElement>();
-
- for ( DataElementCategoryCombo categoryCombo : orderedCategoryCombos )
- {
- des = (List<DataElement>) orderedDataElements.get( categoryCombo );
-
- displayPropertyHandler.handle( des );
- Collections.sort( des, new DataElementSortOrderComparator() );
-
- orderedDataElements.put( categoryCombo, des );
- }
-
- return SUCCESS;
- }
-}
=== removed file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SectionFormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SectionFormAction.java 2011-05-07 13:38:00 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SectionFormAction.java 1970-01-01 00:00:00 +0000
@@ -1,451 +0,0 @@
-package org.hisp.dhis.de.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.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategory;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryService;
-import org.hisp.dhis.dataelement.DataElementOperand;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.Section;
-import org.hisp.dhis.dataset.comparator.SectionOrderComparator;
-import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueService;
-import org.hisp.dhis.de.comments.StandardCommentsManager;
-import org.hisp.dhis.de.state.SelectedStateManager;
-import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.minmax.MinMaxDataElement;
-import org.hisp.dhis.minmax.MinMaxDataElementService;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.Period;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Tri
- * @version $Id: FormAction.java 4089 2007-11-24 13:30:44Z larshelg $
- */
-public class SectionFormAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private DataValueService dataValueService;
-
- public void setDataValueService( DataValueService dataValueService )
- {
- this.dataValueService = dataValueService;
- }
-
- private StandardCommentsManager standardCommentsManager;
-
- public void setStandardCommentsManager( StandardCommentsManager standardCommentsManager )
- {
- this.standardCommentsManager = standardCommentsManager;
- }
-
- private MinMaxDataElementService minMaxDataElementService;
-
- public void setMinMaxDataElementService( MinMaxDataElementService minMaxDataElementService )
- {
- this.minMaxDataElementService = minMaxDataElementService;
- }
-
- private SelectedStateManager selectedStateManager;
-
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
- {
- this.selectedStateManager = selectedStateManager;
- }
-
- private DataElementCategoryService categoryService;
-
- public void setCategoryService( DataElementCategoryService categoryService )
- {
- this.categoryService = categoryService;
- }
-
- private I18n i18n;
-
- public void setI18n( I18n i18n )
- {
- this.i18n = i18n;
- }
-
- // -------------------------------------------------------------------------
- // Input/output
- // -------------------------------------------------------------------------
-
- private List<Section> sections;
-
- public List<Section> getSections()
- {
- return sections;
- }
-
- private Map<String, DataValue> dataValueMap;
-
- public Map<String, DataValue> getDataValueMap()
- {
- return dataValueMap;
- }
-
- private List<String> standardComments;
-
- public List<String> getStandardComments()
- {
- return standardComments;
- }
-
- private Map<String, String> dataElementValueTypeMap;
-
- public Map<String, String> getDataElementValueTypeMap()
- {
- return dataElementValueTypeMap;
- }
-
- private Map<String, MinMaxDataElement> minMaxMap;
-
- public Map<String, MinMaxDataElement> getMinMaxMap()
- {
- return minMaxMap;
- }
-
- private Integer integer = 0;
-
- public Integer getInteger()
- {
- return integer;
- }
-
- private Integer selectedDataSetId;
-
- public void setSelectedDataSetId( Integer selectedDataSetId )
- {
- this.selectedDataSetId = selectedDataSetId;
- }
-
- public Integer getSelectedDataSetId()
- {
- return selectedDataSetId;
- }
-
- private Integer selectedPeriodIndex;
-
- public void setSelectedPeriodIndex( Integer selectedPeriodIndex )
- {
- this.selectedPeriodIndex = selectedPeriodIndex;
- }
-
- public Integer getSelectedPeriodIndex()
- {
- return selectedPeriodIndex;
- }
-
- private Map<Integer, Map<Integer, Collection<DataElementCategoryOption>>> orderedOptionsMap = new HashMap<Integer, Map<Integer, Collection<DataElementCategoryOption>>>();
-
- public Map<Integer, Map<Integer, Collection<DataElementCategoryOption>>> getOrderedOptionsMap()
- {
- return orderedOptionsMap;
- }
-
- private Map<Integer, Collection<DataElementCategory>> orderedCategories = new HashMap<Integer, Collection<DataElementCategory>>();
-
- public Map<Integer, Collection<DataElementCategory>> getOrderedCategories()
- {
- return orderedCategories;
- }
-
- private Map<Integer, Integer> numberOfTotalColumns = new HashMap<Integer, Integer>();
-
- public Map<Integer, Integer> getNumberOfTotalColumns()
- {
- return numberOfTotalColumns;
- }
-
- private Map<Integer, Map<Integer, Collection<Integer>>> catColRepeat = new HashMap<Integer, Map<Integer, Collection<Integer>>>();
-
- public Map<Integer, Map<Integer, Collection<Integer>>> getCatColRepeat()
- {
- return catColRepeat;
- }
-
- private Map<Integer, Collection<DataElementCategoryOptionCombo>> orderdCategoryOptionCombos = new HashMap<Integer, Collection<DataElementCategoryOptionCombo>>();
-
- public Map<Integer, Collection<DataElementCategoryOptionCombo>> getOrderdCategoryOptionCombos()
- {
- return orderdCategoryOptionCombos;
- }
-
- private List<DataElementCategoryOptionCombo> allOptionCombos = new ArrayList<DataElementCategoryOptionCombo>();
-
- public List<DataElementCategoryOptionCombo> getAllOptionCombos()
- {
- return allOptionCombos;
- }
-
- private List<DataElementCategoryCombo> orderedCategoryCombos = new ArrayList<DataElementCategoryCombo>();
-
- public List<DataElementCategoryCombo> getOrderedCategoryCombos()
- {
- return orderedCategoryCombos;
- }
-
- private Map<Integer, Boolean> sectionIsMultiDimensional = new HashMap<Integer, Boolean>();
-
- public Map<Integer, Boolean> getSectionIsMultiDimensional()
- {
- return sectionIsMultiDimensional;
- }
-
- private Map<Integer, Integer> sectionCombos = new HashMap<Integer, Integer>();
-
- public Map<Integer, Integer> getSectionCombos()
- {
- return sectionCombos;
- }
-
- private Map<String, Boolean> greyedFields = new HashMap<String, Boolean>();
-
- public Map<String, Boolean> getGreyedFields()
- {
- return greyedFields;
- }
-
- private String displayMode;
-
- public String getDisplayMode()
- {
- return displayMode;
- }
-
- public void setDisplayMode( String displayMode )
- {
- this.displayMode = displayMode;
- }
-
- private Integer defaultOptionComboId;
-
- public Integer getDefaultOptionComboId()
- {
- return defaultOptionComboId;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- throws Exception
- {
- OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
-
- DataSet dataSet = selectedStateManager.getSelectedDataSet();
-
- Period period = selectedStateManager.getSelectedPeriod();
-
- Collection<DataElement> dataElements = new ArrayList<DataElement>();
-
- dataElements = dataSet.getDataElements();
-
- if ( dataElements.size() == 0 )
- {
- return SUCCESS;
- }
-
- // ---------------------------------------------------------------------
- // Get the min/max values
- // ---------------------------------------------------------------------
-
- Collection<MinMaxDataElement> minMaxDataElements = minMaxDataElementService.getMinMaxDataElements(
- organisationUnit, dataElements );
-
- minMaxMap = new HashMap<String, MinMaxDataElement>( minMaxDataElements.size() );
-
- for ( MinMaxDataElement minMaxDataElement : minMaxDataElements )
- {
- minMaxMap.put( minMaxDataElement.getDataElement().getId() + ":"
- + minMaxDataElement.getOptionCombo().getId(), minMaxDataElement );
- }
-
- // ---------------------------------------------------------------------
- // Order the Sections
- // ---------------------------------------------------------------------
-
- sections = new ArrayList<Section>( dataSet.getSections() );
-
- Collections.sort( sections, new SectionOrderComparator() );
-
- // ---------------------------------------------------------------------
- // Get the category combos for the sections
- // ---------------------------------------------------------------------
-
- for ( Section section : sections )
- {
- DataElementCategoryCombo sectionCategoryCombo = section.getCategoryCombo();
-
- if ( sectionCategoryCombo != null )
- {
- orderedCategoryCombos.add( sectionCategoryCombo );
-
- sectionCombos.put( section.getId(), sectionCategoryCombo.getId() );
- }
-
- if ( section.hasMultiDimensionalDataElement() )
- {
- sectionIsMultiDimensional.put( section.getId(), true );
- }
-
- for ( DataElementOperand operand : section.getGreyedFields() )
- {
- greyedFields.put( operand.getDataElement().getId() + ":" + operand.getCategoryOptionCombo().getId(),
- true );
- }
- }
-
- defaultOptionComboId = categoryService.getDefaultDataElementCategoryOptionCombo().getId();
-
- for ( DataElementCategoryCombo categoryCombo : orderedCategoryCombos )
- {
- List<DataElementCategoryOptionCombo> optionCombos = categoryService.sortOptionCombos( categoryCombo );
-
- allOptionCombos.addAll( optionCombos );
-
- orderdCategoryOptionCombos.put( categoryCombo.getId(), optionCombos );
-
- // -----------------------------------------------------------------
- // Perform ordering of categories and their options so that they
- // could be displayed as in the paper form. Note that the total
- // number of entry cells to be generated are the multiple of options
- // from each category.
- // -----------------------------------------------------------------
-
- numberOfTotalColumns.put( categoryCombo.getId(), optionCombos.size() );
-
- orderedCategories.put( categoryCombo.getId(), categoryCombo.getCategories() );
-
- Map<Integer, Collection<DataElementCategoryOption>> optionsMap = new HashMap<Integer, Collection<DataElementCategoryOption>>();
-
- for ( DataElementCategory dec : categoryCombo.getCategories() )
- {
- optionsMap.put( dec.getId(), dec.getCategoryOptions() );
- }
-
- orderedOptionsMap.put( categoryCombo.getId(), optionsMap );
-
- // -----------------------------------------------------------------
- // Calculating the number of times each category should be repeated
- // -----------------------------------------------------------------
-
- Map<Integer, Integer> catRepeat = new HashMap<Integer, Integer>();
-
- Map<Integer, Collection<Integer>> colRepeat = new HashMap<Integer, Collection<Integer>>();
-
- int catColSpan = optionCombos.size();
-
- for ( DataElementCategory cat : categoryCombo.getCategories() )
- {
- int categoryOptionSize = cat.getCategoryOptions().size();
-
- if ( catColSpan > 0 && categoryOptionSize > 0 )
- {
- catColSpan = catColSpan / categoryOptionSize;
- int total = optionCombos.size() / ( catColSpan * categoryOptionSize );
- Collection<Integer> cols = new ArrayList<Integer>( total );
-
- for ( int i = 0; i < total; i++ )
- {
- cols.add( i );
- }
-
- /*
- * TODO Cols are made to be a collection simply to
- * facilitate a for loop in the velocity template - there
- * should be a better way of "for" doing a loop.
- */
-
- colRepeat.put( cat.getId(), cols );
-
- catRepeat.put( cat.getId(), catColSpan );
- }
- }
-
- catColRepeat.put( categoryCombo.getId(), colRepeat );
- }
-
- // ---------------------------------------------------------------------
- // Get the DataValues and create a map
- // ---------------------------------------------------------------------
-
- Collection<DataValue> dataValues = dataValueService.getDataValues( organisationUnit, period, dataElements,
- allOptionCombos );
-
- dataValueMap = new HashMap<String, DataValue>( dataValues.size() );
-
- for ( DataValue dataValue : dataValues )
- {
- Integer deId = dataValue.getDataElement().getId();
- Integer ocId = dataValue.getOptionCombo().getId();
-
- dataValueMap.put( deId.toString() + ':' + ocId.toString(), dataValue );
- }
-
- // ---------------------------------------------------------------------
- // Make the standard comments available
- // ---------------------------------------------------------------------
-
- standardComments = standardCommentsManager.getStandardComments();
-
- // ---------------------------------------------------------------------
- // Make the DataElement types available
- // ---------------------------------------------------------------------
-
- dataElementValueTypeMap = new HashMap<String, String>();
- dataElementValueTypeMap.put( DataElement.VALUE_TYPE_BOOL, i18n.getString( "yes_no" ) );
- dataElementValueTypeMap.put( DataElement.VALUE_TYPE_INT, i18n.getString( "int" ) );
- dataElementValueTypeMap.put( DataElement.VALUE_TYPE_NUMBER, i18n.getString( "number" ) );
- dataElementValueTypeMap.put( DataElement.VALUE_TYPE_POSITIVE_NUMBER, i18n.getString( "positiveNumber" ) );
- dataElementValueTypeMap.put( DataElement.VALUE_TYPE_NEGATIVE_NUMBER, i18n.getString( "negativeNumber" ) );
- dataElementValueTypeMap.put( DataElement.VALUE_TYPE_STRING, i18n.getString( "text" ) );
- dataElementValueTypeMap.put( DataElement.VALUE_TYPE_DATE, i18n.getString( "date" ) );
-
- return SUCCESS;
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SelectAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SelectAction.java 2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SelectAction.java 2011-05-31 07:54:15 +0000
@@ -27,16 +27,43 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategory;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryOption;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataelement.DataElementOperand;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataelement.comparator.DataElementSortOrderComparator;
+import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.dataentryform.DataEntryFormService;
import org.hisp.dhis.datalock.DataSetLock;
import org.hisp.dhis.datalock.DataSetLockService;
import org.hisp.dhis.dataset.CompleteDataSetRegistration;
import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.Section;
+import org.hisp.dhis.dataset.comparator.SectionOrderComparator;
+import org.hisp.dhis.datavalue.DataValue;
+import org.hisp.dhis.datavalue.DataValueService;
+import org.hisp.dhis.de.comments.StandardCommentsManager;
import org.hisp.dhis.de.state.SelectedStateManager;
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.minmax.MinMaxDataElement;
+import org.hisp.dhis.minmax.MinMaxDataElementService;
+import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
@@ -51,10 +78,26 @@
{
private static final Log log = LogFactory.getLog( SelectAction.class );
+ private static final String SECTION_FORM = "sectionform";
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
+ private DataEntryFormService dataEntryFormService;
+
+ public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
+ {
+ this.dataEntryFormService = dataEntryFormService;
+ }
+
+ private DataElementService dataElementService;
+
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+
private DataSetLockService dataSetLockService;
public void setDataSetLockService( DataSetLockService dataSetLockService )
@@ -76,6 +119,93 @@
this.registrationService = registrationService;
}
+ private DataValueService dataValueService;
+
+ public void setDataValueService( DataValueService dataValueService )
+ {
+ this.dataValueService = dataValueService;
+ }
+
+ private StandardCommentsManager standardCommentsManager;
+
+ public void setStandardCommentsManager( StandardCommentsManager standardCommentsManager )
+ {
+ this.standardCommentsManager = standardCommentsManager;
+ }
+
+ private MinMaxDataElementService minMaxDataElementService;
+
+ public void setMinMaxDataElementService( MinMaxDataElementService minMaxDataElementService )
+ {
+ this.minMaxDataElementService = minMaxDataElementService;
+ }
+
+ private DataElementCategoryService categoryService;
+
+ public void setCategoryService( DataElementCategoryService categoryService )
+ {
+ this.categoryService = categoryService;
+ }
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------
+ // Comparator
+ // -------------------------------------------------------------------------
+
+ private Comparator<DataElement> dataElementComparator;
+
+ public void setDataElementComparator( Comparator<DataElement> dataElementComparator )
+ {
+ this.dataElementComparator = dataElementComparator;
+ }
+
+ // -------------------------------------------------------------------------
+ // DisplayPropertyHandler
+ // -------------------------------------------------------------------------
+
+ private DisplayPropertyHandler displayPropertyHandler;
+
+ public void setDisplayPropertyHandler( DisplayPropertyHandler displayPropertyHandler )
+ {
+ this.displayPropertyHandler = displayPropertyHandler;
+ }
+
+ private Map<DataElementCategoryCombo, List<DataElement>> orderedDataElements = new HashMap<DataElementCategoryCombo, List<DataElement>>();
+
+ public Map<DataElementCategoryCombo, List<DataElement>> getOrderedDataElements()
+ {
+ return orderedDataElements;
+ }
+
+ private Boolean cdeFormExists;
+
+ public Boolean getCdeFormExists()
+ {
+ return cdeFormExists;
+ }
+
+ private String disabled = " ";
+
+ private DataEntryForm dataEntryForm;
+
+ public DataEntryForm getDataEntryForm()
+ {
+ return this.dataEntryForm;
+ }
+
+ private String customDataEntryFormCode;
+
+ public String getCustomDataEntryFormCode()
+ {
+ return this.customDataEntryFormCode;
+ }
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -87,13 +217,6 @@
this.displayMode = displayMode;
}
- private Integer selectedPeriodIndex;
-
- public void setSelectedPeriodIndex( Integer selectedPeriodIndex )
- {
- this.selectedPeriodIndex = selectedPeriodIndex;
- }
-
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -133,6 +256,149 @@
return registrationDate;
}
+ private List<Section> sections;
+
+ public List<Section> getSections()
+ {
+ return sections;
+ }
+
+ private Map<String, DataValue> dataValueMap;
+
+ public Map<String, DataValue> getDataValueMap()
+ {
+ return dataValueMap;
+ }
+
+ private List<String> standardComments;
+
+ public List<String> getStandardComments()
+ {
+ return standardComments;
+ }
+
+ private Map<String, String> dataElementValueTypeMap;
+
+ public Map<String, String> getDataElementValueTypeMap()
+ {
+ return dataElementValueTypeMap;
+ }
+
+ private Map<String, MinMaxDataElement> minMaxMap;
+
+ public Map<String, MinMaxDataElement> getMinMaxMap()
+ {
+ return minMaxMap;
+ }
+
+ private Integer integer = 0;
+
+ public Integer getInteger()
+ {
+ return integer;
+ }
+
+ private Integer selectedDataSetId;
+
+ public void setSelectedDataSetId( Integer selectedDataSetId )
+ {
+ this.selectedDataSetId = selectedDataSetId;
+ }
+
+ public Integer getSelectedDataSetId()
+ {
+ return selectedDataSetId;
+ }
+
+ private Integer selectedPeriodIndex;
+
+ public void setSelectedPeriodIndex( Integer selectedPeriodIndex )
+ {
+ this.selectedPeriodIndex = selectedPeriodIndex;
+ }
+
+ public Integer getSelectedPeriodIndex()
+ {
+ return selectedPeriodIndex;
+ }
+
+ private Map<Integer, Map<Integer, Collection<DataElementCategoryOption>>> orderedOptionsMap = new HashMap<Integer, Map<Integer, Collection<DataElementCategoryOption>>>();
+
+ public Map<Integer, Map<Integer, Collection<DataElementCategoryOption>>> getOrderedOptionsMap()
+ {
+ return orderedOptionsMap;
+ }
+
+ private Map<Integer, Collection<DataElementCategory>> orderedCategories = new HashMap<Integer, Collection<DataElementCategory>>();
+
+ public Map<Integer, Collection<DataElementCategory>> getOrderedCategories()
+ {
+ return orderedCategories;
+ }
+
+ private Map<Integer, Integer> numberOfTotalColumns = new HashMap<Integer, Integer>();
+
+ public Map<Integer, Integer> getNumberOfTotalColumns()
+ {
+ return numberOfTotalColumns;
+ }
+
+ private Map<Integer, Map<Integer, Collection<Integer>>> catColRepeat = new HashMap<Integer, Map<Integer, Collection<Integer>>>();
+
+ public Map<Integer, Map<Integer, Collection<Integer>>> getCatColRepeat()
+ {
+ return catColRepeat;
+ }
+
+ private Map<Integer, Collection<DataElementCategoryOptionCombo>> orderdCategoryOptionCombos = new HashMap<Integer, Collection<DataElementCategoryOptionCombo>>();
+
+ public Map<Integer, Collection<DataElementCategoryOptionCombo>> getOrderdCategoryOptionCombos()
+ {
+ return orderdCategoryOptionCombos;
+ }
+
+ private List<DataElementCategoryOptionCombo> allOptionCombos = new ArrayList<DataElementCategoryOptionCombo>();
+
+ public List<DataElementCategoryOptionCombo> getAllOptionCombos()
+ {
+ return allOptionCombos;
+ }
+
+ private List<DataElementCategoryCombo> orderedCategoryCombos = new ArrayList<DataElementCategoryCombo>();
+
+ public List<DataElementCategoryCombo> getOrderedCategoryCombos()
+ {
+ return orderedCategoryCombos;
+ }
+
+ private Map<Integer, Boolean> sectionIsMultiDimensional = new HashMap<Integer, Boolean>();
+
+ public Map<Integer, Boolean> getSectionIsMultiDimensional()
+ {
+ return sectionIsMultiDimensional;
+ }
+
+ private Map<Integer, Integer> sectionCombos = new HashMap<Integer, Integer>();
+
+ public Map<Integer, Integer> getSectionCombos()
+ {
+ return sectionCombos;
+ }
+
+ private Map<String, Boolean> greyedFields = new HashMap<String, Boolean>();
+
+ public Map<String, Boolean> getGreyedFields()
+ {
+ return greyedFields;
+ }
+
+ private Integer defaultOptionComboId;
+
+ public Integer getDefaultOptionComboId()
+ {
+ return defaultOptionComboId;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -141,9 +407,9 @@
throws Exception
{
organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
-
+
DataSet selectedDataSet = selectedStateManager.getSelectedDataSet();
-
+
// ---------------------------------------------------------------------
// Validate selected period
// ---------------------------------------------------------------------
@@ -156,14 +422,14 @@
if ( selectedPeriodIndex != null && selectedPeriodIndex >= 0 )
{
selectedStateManager.setSelectedPeriodIndex( selectedPeriodIndex );
-
+
period = selectedStateManager.getSelectedPeriod();
}
else
{
selectedStateManager.clearSelectedPeriod();
- return SUCCESS;
+ return INPUT;
}
// ---------------------------------------------------------------------
@@ -179,18 +445,19 @@
if ( dataSetLock != null && dataSetLock.getSources().contains( organisationUnit ) )
{
locked = true;
-
+
log.info( "Dataset '" + selectedDataSet.getName() + "' is locked " );
}
}
-
+
// ---------------------------------------------------------------------
// Get data set completeness info
// ---------------------------------------------------------------------
if ( selectedDataSet != null && period != null && organisationUnit != null )
{
- registration = registrationService.getCompleteDataSetRegistration( selectedDataSet, period, organisationUnit );
+ registration = registrationService.getCompleteDataSetRegistration( selectedDataSet, period,
+ organisationUnit );
registrationDate = registration != null ? registration.getDate() : new Date();
}
@@ -203,14 +470,244 @@
{
displayMode = selectedStateManager.getSelectedDisplayMode();
}
-
+
if ( !selectedStateManager.displayModeIsValid( displayMode ) )
{
displayMode = selectedStateManager.getDisplayMode();
}
-
+
selectedStateManager.setSelectedDisplayMode( displayMode );
+
+ // ---------------------------------------------------------------------
+ // Get entry form
+ // ---------------------------------------------------------------------
+
+ List<DataElement> dataElements = new ArrayList<DataElement>( selectedDataSet.getDataElements() );
+
+ if ( dataElements.isEmpty() )
+ {
+ return INPUT;
+ }
+ Collections.sort( dataElements, dataElementComparator );
+
+ // ---------------------------------------------------------------------
+ // Get the min/max values
+ // ---------------------------------------------------------------------
+
+ Collection<MinMaxDataElement> minMaxDataElements = minMaxDataElementService.getMinMaxDataElements(
+ organisationUnit, dataElements );
+
+ minMaxMap = new HashMap<String, MinMaxDataElement>( minMaxDataElements.size() );
+
+ for ( MinMaxDataElement minMaxDataElement : minMaxDataElements )
+ {
+ minMaxMap.put( minMaxDataElement.getDataElement().getId() + ":"
+ + minMaxDataElement.getOptionCombo().getId(), minMaxDataElement );
+ }
+
+ // ---------------------------------------------------------------------
+ // Get the min/max values
+ // ---------------------------------------------------------------------
+
+ orderedDataElements = dataElementService.getGroupedDataElementsByCategoryCombo( dataElements );
+
+ orderedCategoryCombos = dataElementService.getDataElementCategoryCombos( dataElements );
+
+ for ( DataElementCategoryCombo categoryCombo : orderedCategoryCombos )
+ {
+ Collection<DataElementCategoryOptionCombo> optionCombos = categoryService.sortOptionCombos( categoryCombo );
+
+ allOptionCombos.addAll( optionCombos );
+
+ orderdCategoryOptionCombos.put( categoryCombo.getId(), optionCombos );
+
+ // -----------------------------------------------------------------
+ // Perform ordering of categories and their options so that they
+ // could be displayed as in the paper form. Note that the total
+ // number of entry cells to be generated are the multiple of options
+ // from each category.
+ // -----------------------------------------------------------------
+
+ numberOfTotalColumns.put( categoryCombo.getId(), optionCombos.size() );
+
+ orderedCategories.put( categoryCombo.getId(), categoryCombo.getCategories() );
+
+ Map<Integer, Collection<DataElementCategoryOption>> optionsMap = new HashMap<Integer, Collection<DataElementCategoryOption>>();
+
+ for ( DataElementCategory dec : categoryCombo.getCategories() )
+ {
+ optionsMap.put( dec.getId(), dec.getCategoryOptions() );
+ }
+
+ orderedOptionsMap.put( categoryCombo.getId(), optionsMap );
+
+ // -----------------------------------------------------------------
+ // Calculating the number of times each category should be repeated
+ // -----------------------------------------------------------------
+
+ Map<Integer, Integer> catRepeat = new HashMap<Integer, Integer>();
+
+ Map<Integer, Collection<Integer>> colRepeat = new HashMap<Integer, Collection<Integer>>();
+
+ int catColSpan = optionCombos.size();
+
+ for ( DataElementCategory cat : categoryCombo.getCategories() )
+ {
+ int categoryOptionSize = cat.getCategoryOptions().size();
+
+ if ( catColSpan > 0 && categoryOptionSize > 0 )
+ {
+ catColSpan = catColSpan / categoryOptionSize;
+ int total = optionCombos.size() / (catColSpan * categoryOptionSize);
+ Collection<Integer> cols = new ArrayList<Integer>( total );
+
+ for ( int i = 0; i < total; i++ )
+ {
+ cols.add( i );
+ }
+
+ colRepeat.put( cat.getId(), cols );
+
+ catRepeat.put( cat.getId(), catColSpan );
+ }
+ }
+
+ catColRepeat.put( categoryCombo.getId(), colRepeat );
+ }
+
+ // ---------------------------------------------------------------------
+ // Get the DataValues and create a map
+ // ---------------------------------------------------------------------
+
+ Collection<DataValue> dataValues = dataValueService.getDataValues( organisationUnit, period, dataElements,
+ allOptionCombos );
+
+ dataValueMap = new HashMap<String, DataValue>( dataValues.size() );
+
+ for ( DataValue dataValue : dataValues )
+ {
+ Integer deId = dataValue.getDataElement().getId();
+ Integer ocId = dataValue.getOptionCombo().getId();
+
+ dataValueMap.put( deId.toString() + ':' + ocId.toString(), dataValue );
+ }
+
+ // ---------------------------------------------------------------------
+ // Make the standard comments available
+ // ---------------------------------------------------------------------
+
+ standardComments = standardCommentsManager.getStandardComments();
+
+ // ---------------------------------------------------------------------
+ // Make the DataElement types available
+ // ---------------------------------------------------------------------
+
+ dataElementValueTypeMap = new HashMap<String, String>();
+ dataElementValueTypeMap.put( DataElement.VALUE_TYPE_DATE, i18n.getString( "date" ) );
+ dataElementValueTypeMap.put( DataElement.VALUE_TYPE_BOOL, i18n.getString( "yes_no" ) );
+ dataElementValueTypeMap.put( DataElement.VALUE_TYPE_INT, i18n.getString( "number" ) );
+ dataElementValueTypeMap.put( DataElement.VALUE_TYPE_STRING, i18n.getString( "text" ) );
+
+ // ---------------------------------------------------------------------
+ // Get data entry form
+ // ---------------------------------------------------------------------
+
+ if( displayMode.equals( SECTION_FORM ) )
+ {
+ getSectionForm( dataElements, selectedDataSet );
+ }
+ else
+ {
+ getOtherDataEntryForm( dataElements, selectedDataSet, dataValues );
+ }
+
return displayMode;
}
+
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
+ private void getSectionForm( Collection<DataElement> dataElements, DataSet dataSet )
+ {
+ // ---------------------------------------------------------------------
+ // Order the Sections
+ // ---------------------------------------------------------------------
+
+ sections = new ArrayList<Section>( dataSet.getSections() );
+
+ Collections.sort( sections, new SectionOrderComparator() );
+
+ // ---------------------------------------------------------------------
+ // Get the category combos for the sections
+ // ---------------------------------------------------------------------
+
+ for ( Section section : sections )
+ {
+ DataElementCategoryCombo sectionCategoryCombo = section.getCategoryCombo();
+
+ if ( sectionCategoryCombo != null )
+ {
+ orderedCategoryCombos.add( sectionCategoryCombo );
+
+ sectionCombos.put( section.getId(), sectionCategoryCombo.getId() );
+ }
+
+ if ( section.hasMultiDimensionalDataElement() )
+ {
+ sectionIsMultiDimensional.put( section.getId(), true );
+ }
+
+ for ( DataElementOperand operand : section.getGreyedFields() )
+ {
+ greyedFields.put( operand.getDataElement().getId() + ":" + operand.getCategoryOptionCombo().getId(),
+ true );
+ }
+ }
+
+ defaultOptionComboId = categoryService.getDefaultDataElementCategoryOptionCombo().getId();
+
+ }
+
+ private void getOtherDataEntryForm( List<DataElement> dataElements, DataSet dataSet,
+ Collection<DataValue> dataValues )
+ {
+ DataSetLock dataSetLock = dataSetLockService.getDataSetLockByDataSetAndPeriod( dataSet, period );
+
+ if ( dataSetLock != null && dataSetLock.getSources().contains( organisationUnit ) )
+ {
+ disabled = "disabled";
+ }
+
+ // ---------------------------------------------------------------------
+ // Get the custom data entry form (if any)
+ // ---------------------------------------------------------------------
+
+ dataEntryForm = dataSet.getDataEntryForm();
+
+ cdeFormExists = (dataEntryForm != null);
+
+ if ( cdeFormExists )
+ {
+ customDataEntryFormCode = dataEntryFormService.prepareDataEntryFormForEntry( dataEntryForm.getHtmlCode(),
+ dataValues, minMaxMap, disabled, i18n, dataSet );
+ }
+
+ // ---------------------------------------------------------------------
+ // Working on the display of dataelements
+ // ---------------------------------------------------------------------
+
+ List<DataElement> des = new ArrayList<DataElement>();
+
+ for ( DataElementCategoryCombo categoryCombo : orderedCategoryCombos )
+ {
+ des = (List<DataElement>) orderedDataElements.get( categoryCombo );
+
+ displayPropertyHandler.handle( des );
+ Collections.sort( des, new DataElementSortOrderComparator() );
+
+ orderedDataElements.put( categoryCombo, des );
+ }
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2011-05-10 08:58:10 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2011-05-31 07:54:15 +0000
@@ -49,30 +49,17 @@
</bean>
<bean id="org.hisp.dhis.de.action.SelectAction" class="org.hisp.dhis.de.action.SelectAction" scope="prototype">
- <property name="dataSetLockService" ref="org.hisp.dhis.datalock.DataSetLockService" />
- <property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />
- <property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
- </bean>
-
- <bean id="org.hisp.dhis.de.action.FormAction" class="org.hisp.dhis.de.action.FormAction" scope="prototype">
- <property name="dataSetLockService" ref="org.hisp.dhis.datalock.DataSetLockService" />
- <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
- <property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
<property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService" />
+ <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+ <property name="dataSetLockService" ref="org.hisp.dhis.datalock.DataSetLockService" />
+ <property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />
+ <property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
+ <property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
<property name="standardCommentsManager" ref="org.hisp.dhis.de.comments.StandardCommentsManager" />
<property name="minMaxDataElementService" ref="org.hisp.dhis.minmax.MinMaxDataElementService" />
- <property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />
<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
</bean>
- <bean id="org.hisp.dhis.de.action.SectionFormAction" class="org.hisp.dhis.de.action.SectionFormAction" scope="prototype">
- <property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService"/>
- <property name="standardCommentsManager" ref="org.hisp.dhis.de.comments.StandardCommentsManager"/>
- <property name="minMaxDataElementService" ref="org.hisp.dhis.minmax.MinMaxDataElementService"/>
- <property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager"/>
- <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService"/>
- </bean>
-
<bean id="org.hisp.dhis.de.action.SaveValueAction" class="org.hisp.dhis.de.action.SaveValueAction" scope="prototype">
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml 2011-05-08 19:22:16 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml 2011-05-31 07:54:15 +0000
@@ -40,22 +40,10 @@
</action>
<action name="select" class="org.hisp.dhis.de.action.SelectAction">
- <result name="customform" type="chain">customform</result>
- <result name="sectionform" type="chain">sectionform</result>
- <result name="defaultform" type="chain">defaultform</result>
- <result name="success" type="velocity">/dhis-web-dataentry/responseVoid.vm</result>
- </action>
-
- <action name="customform" class="org.hisp.dhis.de.action.FormAction">
- <result name="success" type="velocity">/dhis-web-dataentry/customForm.vm</result>
- </action>
-
- <action name="sectionform" class="org.hisp.dhis.de.action.SectionFormAction">
- <result name="success" type="velocity">/dhis-web-dataentry/sectionForm.vm</result>
- </action>
-
- <action name="defaultform" class="org.hisp.dhis.de.action.FormAction">
- <result name="success" type="velocity">/dhis-web-dataentry/defaultForm.vm</result>
+ <result name="customform" type="velocity">/dhis-web-dataentry/customForm.vm</result>
+ <result name="sectionform" type="velocity">/dhis-web-dataentry/sectionForm.vm</result>
+ <result name="defaultform" type="velocity">/dhis-web-dataentry/defaultForm.vm</result>
+ <result name="input" type="velocity">/dhis-web-dataentry/responseVoid.vm</result>
</action>
<action name="saveValue" class="org.hisp.dhis.de.action.SaveValueAction">