dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11993
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3539: Cleanup CDE
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 3539 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2011-05-08 10:21:11 +0200
message:
Cleanup CDE
removed:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/GetOptionCombosAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/AutoSaveDataEntryFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/GreySectionAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java 2011-05-07 23:05:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java 2011-05-08 08:06:40 +0000
@@ -92,14 +92,21 @@
*/
Collection<DataEntryForm> getAllDataEntryForms();
+ /**
+ * Return the DataEntryForms with the given collection of identifiers. If the
+ * given argument is null, all DataEntryForms are returned.
+ *
+ * @param identifiers the collection of identifiers.
+ * @return a collection of DataEntryForms.
+ */
Collection<DataEntryForm> getDataEntryForms( final Collection<Integer> identifiers );
/**
- * Prepare DataEntryForm code.
+ * Prepare DataEntryForm code for persisting.
*
* @return htmlCode the HTML code of the data entry form.
*/
- String prepareDataEntryFormCode( String htmlCode );
+ String prepareDataEntryFormForSave( String htmlCode );
/**
* Prepares the data entry form code by injecting the data element name and
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2011-05-07 23:05:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2011-05-08 08:06:40 +0000
@@ -122,7 +122,7 @@
return dataEntryFormStore.getAllDataEntryForms();
}
- public String prepareDataEntryFormCode( String htmlCode )
+ public String prepareDataEntryFormForSave( String htmlCode )
{
// ---------------------------------------------------------------------
// Buffer to contain the final result.
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/AutoSaveDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/AutoSaveDataEntryFormAction.java 2011-05-07 18:58:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/AutoSaveDataEntryFormAction.java 2011-05-08 08:06:40 +0000
@@ -104,7 +104,7 @@
if ( dataEntryForm == null )
{
- dataEntryForm = new DataEntryForm( nameField, dataEntryFormService.prepareDataEntryFormCode( designTextarea ) );
+ dataEntryForm = new DataEntryForm( nameField, dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
int id = dataEntryFormService.addDataEntryForm( dataEntryForm );
message = id + "";
@@ -114,12 +114,11 @@
else
{
dataEntryForm.setName( nameField );
- dataEntryForm.setHtmlCode( dataEntryFormService.prepareDataEntryFormCode( designTextarea ) );
+ dataEntryForm.setHtmlCode( dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
dataEntryFormService.updateDataEntryForm( dataEntryForm );
message = dataEntryForm.getId() + "";
}
return SUCCESS;
}
-
}
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/GetOptionCombosAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/GetOptionCombosAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/GetOptionCombosAction.java 1970-01-01 00:00:00 +0000
@@ -1,127 +0,0 @@
-package org.hisp.dhis.dataset.action.dataentryform;
-
-/*
- * 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.Iterator;
-import java.util.List;
-
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Bharath Kumar
- * @version $Id$
- */
-public class GetOptionCombosAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private DataElementService dataElementService;
-
- public void setDataElementService( DataElementService dataElementService )
- {
- this.dataElementService = dataElementService;
- }
-
-
- // -------------------------------------------------------------------------
- // Getters & Setters
- // -------------------------------------------------------------------------
-
- private int dataElementId;
-
- public void setDataElementId( int dataElementId )
- {
- this.dataElementId = dataElementId;
- }
-
- private List<String> optionComboIds;
-
- public List<String> getOptionComboIds()
- {
- return optionComboIds;
- }
-
- private List<String> optionComboNames;
-
- public List<String> getOptionComboNames()
- {
- return optionComboNames;
- }
-
- // -------------------------------------------------------------------------
- // Execute
- // -------------------------------------------------------------------------
-
- public String execute()
- throws Exception
- {
- optionComboIds = new ArrayList<String>();
- optionComboNames = new ArrayList<String>();
-
- DataElement dataElement = dataElementService.getDataElement( dataElementId );
-
- DataElementCategoryCombo dataElementCategoryCombo = dataElement.getCategoryCombo();
-
- List<DataElementCategoryOptionCombo> optionCombos = new ArrayList<DataElementCategoryOptionCombo>(
- dataElementCategoryCombo.getOptionCombos() );
-
- Iterator<DataElementCategoryOptionCombo> optionComboIterator = optionCombos.iterator();
-
- while ( optionComboIterator.hasNext() )
- {
- DataElementCategoryOptionCombo optionCombo = optionComboIterator.next();
-
- String optionComboName = optionCombo.getName();
-
- String optionComboId = String.valueOf( optionCombo.getId() );
-
- if ( optionComboId != null )
- {
- if ( optionComboName == null || optionComboName.trim().length() == 0 )
- {
- optionComboName = DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME;
- }
- }
-
- optionComboNames.add( optionComboName );
-
- optionComboIds.add( String.valueOf( optionCombo.getId() ) );
- }
-
- return SUCCESS;
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.java 2011-05-07 23:05:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.java 2011-05-08 08:06:40 +0000
@@ -97,8 +97,7 @@
if ( dataEntryForm == null )
{
- dataEntryForm = new DataEntryForm( nameField, dataEntryFormService
- .prepareDataEntryFormCode( designTextarea ) );
+ dataEntryForm = new DataEntryForm( nameField, dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
dataEntryFormService.addDataEntryForm( dataEntryForm );
dataset.setDataEntryForm( dataEntryForm );
@@ -107,7 +106,7 @@
else
{
dataEntryForm.setName( nameField );
- dataEntryForm.setHtmlCode( dataEntryFormService.prepareDataEntryFormCode( designTextarea ) );
+ dataEntryForm.setHtmlCode( dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
dataEntryFormService.updateDataEntryForm( dataEntryForm );
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/GreySectionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/GreySectionAction.java 2011-01-25 21:25:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/GreySectionAction.java 2011-05-08 08:17:20 +0000
@@ -33,7 +33,6 @@
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;
@@ -171,17 +170,9 @@
{
section = sectionService.getSection( sectionId.intValue() );
- for ( DataElement dataElement : section.getDataElements() )
- {
- if ( dataElement.isMultiDimensional() )
- {
- sectionIsMultiDimensional = true;
-
- break;
- }
- }
-
- categoryCombo = section.getDataElements().iterator().next().getCategoryCombo();
+ sectionIsMultiDimensional = section.hasMultiDimensionalDataElement();
+
+ categoryCombo = section.getCategoryCombo();
if ( sectionIsMultiDimensional )
{
@@ -200,11 +191,13 @@
for ( DataElementCategory cat : categoryCombo.getCategories() )
{
- if ( !cat.getCategoryOptions().isEmpty() )
+ int categoryOptionSize = cat.getCategoryOptions().size();
+
+ if ( catColSpan > 0 && categoryOptionSize > 0 )
{
- catColSpan = catColSpan / cat.getCategoryOptions().size();
+ catColSpan = catColSpan / categoryOptionSize;
- int total = optionCombos.size() / (catColSpan * cat.getCategoryOptions().size());
+ int total = optionCombos.size() / ( catColSpan * categoryOptionSize );
Collection<Integer> cols = new ArrayList<Integer>( total );
@@ -216,11 +209,10 @@
colRepeat.put( cat.getId(), cols );
}
}
- }
-
+ }
else
{
- defaultOptionComboId = categoryService.getDefaultDataElementCategoryOptionCombo().getId();
+ defaultOptionComboId = categoryService.getDefaultDataElementCategoryOptionCombo().getId();
}
for ( DataElementOperand operand : section.getGreyedFields() )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml 2011-05-07 22:48:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml 2011-05-08 08:20:31 +0000
@@ -362,15 +362,7 @@
<ref bean="org.hisp.dhis.dataset.DataSetService"/>
</property>
</bean>
-
- <bean id="org.hisp.dhis.dataset.action.dataentryform.GetOptionCombosAction"
- class="org.hisp.dhis.dataset.action.dataentryform.GetOptionCombosAction"
- scope="prototype">
- <property name="dataElementService">
- <ref bean="org.hisp.dhis.dataelement.DataElementService"/>
- </property>
- </bean>
-
+
<!-- Compulsory data elements -->
<bean
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml 2011-04-27 08:32:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml 2011-05-08 08:20:31 +0000
@@ -287,13 +287,7 @@
<result name="success" type="velocity-xml">/dhis-web-maintenance-dataset/responseSelDataElementList.vm</result>
<param name="javascripts">javascript/dataEntryForm.js,javascript/FCK/fckeditor.js</param>
</action>
-
- <action name="getOptionCombos"
- class="org.hisp.dhis.dataset.action.dataentryform.GetOptionCombosAction">
- <result name="success" type="velocity-xml">/dhis-web-maintenance-dataset/responseOptionCombo.vm</result>
- <param name="javascripts">javascript/dataEntryForm.js,javascript/FCK/fckeditor.js</param>
- </action>
-
+
<!-- Compulsory data elements -->
<action name="displayCompulsoryDataElementsForm"