dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08623
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2105: Simplification
------------------------------------------------------------
revno: 2105
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2010-11-18 14:11:49 +0100
message:
Simplification
modified:
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadDisplayModesAction.java
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/webapp/dhis-web-dataentry/javascript/form.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadDisplayModesAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadDisplayModesAction.java 2010-11-17 18:26:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadDisplayModesAction.java 2010-11-18 13:11:49 +0000
@@ -53,10 +53,10 @@
{
DataSet dataSet = selectedStateManager.getSelectedDataSet();
- customForm = dataSet.getSections() != null && dataSet.getSections().size() > 0;
-
- sectionForm = dataSet.getDataEntryForm() != null;
-
+ customForm = dataSet.getDataEntryForm() != null;
+
+ sectionForm = dataSet.getSections() != null && dataSet.getSections().size() > 0;
+
displayMode = selectedStateManager.getSelectedDisplayMode();
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 2010-11-18 12:28:04 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SelectAction.java 2010-11-18 13:11:49 +0000
@@ -27,11 +27,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
+import static org.hisp.dhis.de.state.SelectedStateManager.ALLOWED_FORM_TYPES;
+import static org.hisp.dhis.de.state.SelectedStateManager.CUSTOM_FORM;
+import static org.hisp.dhis.de.state.SelectedStateManager.DEFAULT_FORM;
+import static org.hisp.dhis.de.state.SelectedStateManager.SECTION_FORM;
+
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
-import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
@@ -43,8 +45,6 @@
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.comparator.DataSetNameComparator;
import org.hisp.dhis.de.screen.DataEntryScreenManager;
import org.hisp.dhis.de.state.SelectedStateManager;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -52,8 +52,6 @@
import com.opensymphony.xwork2.ActionSupport;
-import static org.hisp.dhis.de.state.SelectedStateManager.*;
-
/**
* @author Torgeir Lorange Ostby
* @version $Id: SelectAction.java 5930 2008-10-15 03:30:52Z tri $
@@ -81,13 +79,6 @@
this.dataEntryScreenManager = dataEntryScreenManager;
}
- private DataSetService dataSetService;
-
- public void setDataSetService( DataSetService dataSetService )
- {
- this.dataSetService = dataSetService;
- }
-
private CompleteDataSetRegistrationService registrationService;
public void setRegistrationService( CompleteDataSetRegistrationService registrationService )
@@ -120,20 +111,6 @@
return period;
}
- private List<DataSet> dataSets = new ArrayList<DataSet>();
-
- public Collection<DataSet> getDataSets()
- {
- return dataSets;
- }
-
- private List<Period> periods = new ArrayList<Period>();
-
- public Collection<Period> getPeriods()
- {
- return periods;
- }
-
private boolean locked;
public boolean isLocked()
@@ -141,20 +118,6 @@
return locked;
}
- private Boolean hasSection;
-
- public Boolean getHasSection()
- {
- return hasSection;
- }
-
- private Boolean customDataEntryFormExists;
-
- public Boolean getCustomDataEntryFormExists()
- {
- return this.customDataEntryFormExists;
- }
-
private Collection<Integer> calculatedDataElementIds;
public Collection<Integer> getCalculatedDataElementIds()
@@ -189,35 +152,13 @@
private String displayMode;
- public String getDisplayMode()
- {
- return displayMode;
- }
-
public void setDisplayMode( String displayMode )
{
this.displayMode = displayMode;
}
- private Integer selectedDataSetId;
-
- public Integer getSelectedDataSetId()
- {
- return selectedDataSetId;
- }
-
- public void setSelectedDataSetId( Integer selectedDataSetId )
- {
- this.selectedDataSetId = selectedDataSetId;
- }
-
private Integer selectedPeriodIndex;
- public Integer getSelectedPeriodIndex()
- {
- return selectedPeriodIndex;
- }
-
public void setSelectedPeriodIndex( Integer selectedPeriodIndex )
{
this.selectedPeriodIndex = selectedPeriodIndex;
@@ -230,69 +171,12 @@
public String execute()
throws Exception
{
- /*
- // ---------------------------------------------------------------------
- // Validate selected OrganisationUnit
- // ---------------------------------------------------------------------
-
- organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
-
- if ( organisationUnit == null )
- {
- selectedStateManager.clearSelectedDataSet();
- selectedStateManager.clearSelectedPeriod();
-
- return SUCCESS;
- }
-
- // ---------------------------------------------------------------------
- // Load and sort DataSets
- // ---------------------------------------------------------------------
-
- dataSets = selectedStateManager.loadDataSetsForSelectedOrgUnit();
-
- Collections.sort( dataSets, new DataSetNameComparator() );
-
- // ---------------------------------------------------------------------
- // Validate selected DataSet
- // ---------------------------------------------------------------------
-
- DataSet selectedDataSet;
-
- if ( selectedDataSetId != null )
- {
- selectedDataSet = dataSetService.getDataSet( selectedDataSetId );
- }
- else
- {
- selectedDataSet = selectedStateManager.getSelectedDataSet();
- }
-
- if ( selectedDataSet != null && dataSets.contains( selectedDataSet ) )
- {
- selectedDataSetId = selectedDataSet.getId();
- selectedStateManager.setSelectedDataSet( selectedDataSet );
- }
- else
- {
- selectedStateManager.clearSelectedDataSet();
- selectedStateManager.clearSelectedPeriod();
-
- return SUCCESS;
- }
-*/
organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
DataSet selectedDataSet = selectedStateManager.getSelectedDataSet();
// ---------------------------------------------------------------------
- // Generate Periods
- // ---------------------------------------------------------------------
-
- periods = selectedStateManager.getPeriodList();
-
- // ---------------------------------------------------------------------
- // Validate selected Period
+ // Validate selected period
// ---------------------------------------------------------------------
if ( selectedPeriodIndex == null )
@@ -300,9 +184,10 @@
selectedPeriodIndex = selectedStateManager.getSelectedPeriodIndex();
}
- if ( selectedPeriodIndex != null && selectedPeriodIndex >= 0 && selectedPeriodIndex < periods.size() )
+ if ( selectedPeriodIndex != null && selectedPeriodIndex >= 0 )
{
- selectedStateManager.setSelectedPeriodIndex( selectedPeriodIndex );
+ selectedStateManager.setSelectedPeriodIndex( selectedPeriodIndex );
+
period = selectedStateManager.getSelectedPeriod();
}
else
@@ -312,9 +197,9 @@
return SUCCESS;
}
- // -----------------------------------------------------------------------
- // For Data Locking
- // -----------------------------------------------------------------------
+ // ---------------------------------------------------------------------
+ // Get data locking info
+ // ---------------------------------------------------------------------
if ( selectedDataSet != null )
{
@@ -325,30 +210,23 @@
if ( dataSetLock != null && dataSetLock.getSources().contains( organisationUnit ) )
{
locked = true;
+
log.info( "Dataset '" + selectedDataSet.getName() + "' is locked " );
}
}
// ---------------------------------------------------------------------
- // Get CalculatedDataElement info
+ // Get calculated data element info
// ---------------------------------------------------------------------
calculatedDataElementIds = dataEntryScreenManager.getAllCalculatedDataElements( selectedDataSet );
calculatedDataElementMap = dataEntryScreenManager.getNonSavedCalculatedDataElements( selectedDataSet );
// ---------------------------------------------------------------------
- // Get display info
- // ---------------------------------------------------------------------
-
- hasSection = selectedDataSet.getSections() != null && selectedDataSet.getSections().size() > 0;
-
- customDataEntryFormExists = selectedDataSet.getDataEntryForm() != null;
-
- // ---------------------------------------------------------------------
- // Make available information about dataSet completeness
- // ---------------------------------------------------------------------
-
- if ( selectedDataSetId != null && selectedPeriodIndex != null && organisationUnit != null )
+ // Get data set completeness info
+ // ---------------------------------------------------------------------
+
+ if ( selectedDataSet != null && period != null && organisationUnit != null )
{
registration = registrationService.getCompleteDataSetRegistration( selectedDataSet, period,
organisationUnit );
@@ -356,6 +234,23 @@
registrationDate = registration != null ? registration.getDate() : new Date();
}
+ // ---------------------------------------------------------------------
+ // Get display mode
+ // ---------------------------------------------------------------------
+
+ if ( displayMode == null )
+ {
+ displayMode = selectedStateManager.getSelectedDisplayMode();
+ }
+ else
+ {
+ selectedStateManager.setSelectedDisplayMode( displayMode );
+ }
+
+ boolean hasSection = selectedDataSet.getSections() != null && selectedDataSet.getSections().size() > 0;
+
+ boolean customDataEntryFormExists = selectedDataSet.getDataEntryForm() != null;
+
if ( displayMode == null || !ALLOWED_FORM_TYPES.contains( displayMode ) )
{
if ( customDataEntryFormExists )
@@ -372,8 +267,6 @@
}
}
- selectedStateManager.setSelectedDisplayMode( displayMode );
-
return displayMode;
}
}
=== 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 2010-11-18 12:28:04 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2010-11-18 13:11:49 +0000
@@ -65,7 +65,6 @@
<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="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
<property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
<property name="dataEntryScreenManager" ref="org.hisp.dhis.de.screen.DataEntryScreenManager" />
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2010-11-18 12:28:04 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2010-11-18 13:11:49 +0000
@@ -152,13 +152,11 @@
function displayEntryFormInternal( callback )
{
- var dataSetId = $( '#selectedDataSetId' ).val();
var periodIndex = $( '#selectedPeriodIndex' ).val();
- if ( dataSetId && dataSetId != -1 && periodIndex && periodIndex != -1 )
+ if ( periodIndex && periodIndex != -1 )
{
- var url = 'select.action?selectedDataSetId=' + dataSetId +
- '&selectedPeriodIndex=' + periodIndex +
+ var url = 'select.action?selectedPeriodIndex=' + periodIndex +
'&displayMode=' + $("input[name='displayMode']:checked").val();
$( '#entryForm' ).load( url, callback );