dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11987
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3537: Pushed method from web to service layer
------------------------------------------------------------
revno: 3537
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2011-05-08 00:48:54 +0200
message:
Pushed method from web to service layer
removed:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/css/pivot.css
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-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/ViewDataEntryFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.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 2010-12-23 11:56:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java 2011-05-07 22:48:54 +0000
@@ -94,6 +94,15 @@
* @return htmlCode.
*/
String prepareDataEntryFormCode( String preparedCode );
+
+ /**
+ * Prepares the data entry form code by injecting the dataElement name and
+ * and title for each entry field.
+ *
+ * @param htmlCode HTML code of the data entry form.
+ * @return HTML code for the data entry form injected with data element names.
+ */
+ String prepareDataEntryFormForEdit( String htmlCode );
Collection<DataEntryForm> listDisctinctDataEntryFormByProgramStageIds( List<Integer> programStageIds );
=== 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 2010-12-23 11:56:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2011-05-07 22:48:54 +0000
@@ -32,6 +32,10 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+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.system.util.Filter;
import org.hisp.dhis.system.util.FilterUtils;
import org.springframework.transaction.annotation.Transactional;
@@ -44,6 +48,8 @@
public class DefaultDataEntryFormService
implements DataEntryFormService
{
+ private static final Pattern IDENTIFIER_PATTERN = Pattern.compile( "value\\[(.*)\\].value:value\\[(.*)\\].value" );
+
// ------------------------------------------------------------------------
// Dependencies
// ------------------------------------------------------------------------
@@ -55,6 +61,20 @@
this.dataEntryFormStore = dataEntryFormStore;
}
+ private DataElementCategoryService categoryService;
+
+ public void setCategoryService( DataElementCategoryService categoryService )
+ {
+ this.categoryService = categoryService;
+ }
+
+ private DataElementService dataElementService;
+
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+
// ------------------------------------------------------------------------
// Implemented Methods
// ------------------------------------------------------------------------
@@ -164,6 +184,124 @@
return sb.toString();
}
+ public String prepareDataEntryFormForEdit( String htmlCode )
+ {
+ // ---------------------------------------------------------------------
+ // Buffer to contain the final result.
+ // ---------------------------------------------------------------------
+
+ StringBuffer sb = new StringBuffer();
+
+ // ---------------------------------------------------------------------
+ // Pattern to match data elements in the HTML code.
+ // ---------------------------------------------------------------------
+
+ Pattern patDataElement = Pattern.compile( "(<input.*?)[/]?>" );
+ Matcher matDataElement = patDataElement.matcher( htmlCode );
+
+ // ---------------------------------------------------------------------
+ // Iterate through all matching data element fields.
+ // ---------------------------------------------------------------------
+
+ while ( matDataElement.find() )
+ {
+ // -----------------------------------------------------------------
+ // Get input HTML code
+ // -----------------------------------------------------------------
+
+ String dataElementCode = matDataElement.group( 1 );
+
+ // -----------------------------------------------------------------
+ // Pattern to extract data element ID from data element field
+ // -----------------------------------------------------------------
+
+ Matcher dataElementMatcher = IDENTIFIER_PATTERN.matcher( dataElementCode );
+
+ if ( dataElementMatcher.find() && dataElementMatcher.groupCount() > 0 )
+ {
+ // -------------------------------------------------------------
+ // Get data element id,name, optionCombo id,name of data element
+ // -------------------------------------------------------------
+
+ int dataElementId = Integer.parseInt( dataElementMatcher.group( 1 ) );
+ DataElement dataElement = dataElementService.getDataElement( dataElementId );
+
+ int optionComboId = Integer.parseInt( dataElementMatcher.group( 2 ) );
+ DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( optionComboId );
+ String optionComboName = optionCombo != null ? optionCombo.getName() : "";
+
+ // -------------------------------------------------------------
+ // Insert name of data element in output code
+ // -------------------------------------------------------------
+
+ String displayValue = "Data element does not exist";
+
+ if ( dataElement != null )
+ {
+ displayValue = dataElement.getShortName() + " " + optionComboName;
+
+ if ( dataElementCode.contains( "value=\"\"" ) )
+ {
+ dataElementCode = dataElementCode.replace( "value=\"\"", "value=\"[ " + displayValue + " ]\"" );
+ }
+ else
+ {
+ dataElementCode += " value=\"[ " + displayValue + " ]\"";
+ }
+
+ StringBuilder title = new StringBuilder( "title=\"" ).append( dataElement.getId() ).append( " - " ).
+ append( dataElement.getName() ).append( " - " ).append( optionComboId ).append( " - " ).
+ append( optionComboName ).append( " - " ).append( dataElement.getType() ).append( "\"" );
+
+ if ( dataElementCode.contains( "title=\"\"" ) )
+ {
+ dataElementCode = dataElementCode.replace( "title=\"\"", title );
+ }
+ else
+ {
+ dataElementCode += " " + title;
+ }
+ }
+ else
+ {
+ if ( dataElementCode.contains( "value=\"\"" ) )
+ {
+ dataElementCode = dataElementCode.replace( "value=\"\"", "value=\"[ " + displayValue + " ]\"" );
+ }
+ else
+ {
+ dataElementCode += " value=\"[ " + displayValue + " ]\"";
+ }
+
+ if ( dataElementCode.contains( "title=\"\"" ) )
+ {
+ dataElementCode = dataElementCode.replace( "title=\"\"", "title=\"" + displayValue + "\"" );
+ }
+ else
+ {
+ dataElementCode += " title=\"" + displayValue + "\"";
+ }
+ }
+
+ // -------------------------------------------------------------
+ // Appends dataElementCode
+ // -------------------------------------------------------------
+
+ String appendCode = dataElementCode;
+ appendCode += "/>";
+ matDataElement.appendReplacement( sb, appendCode );
+ }
+ }
+
+ // ---------------------------------------------------------------------
+ // Add remaining code (after the last match), and return formatted code
+ // ---------------------------------------------------------------------
+
+ matDataElement.appendTail( sb );
+
+ return sb.toString();
+ }
+
public Collection<DataEntryForm> listDisctinctDataEntryFormByProgramStageIds( List<Integer> programStageIds )
{
if ( programStageIds == null || programStageIds.isEmpty() )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2011-04-23 18:52:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2011-05-07 22:48:54 +0000
@@ -308,8 +308,9 @@
</bean>
<bean id="org.hisp.dhis.dataentryform.DataEntryFormService" class="org.hisp.dhis.dataentryform.DefaultDataEntryFormService">
- <property name="dataEntryFormStore"
- ref="org.hisp.dhis.dataentryform.DataEntryFormStore" />
+ <property name="dataEntryFormStore" ref="org.hisp.dhis.dataentryform.DataEntryFormStore" />
+ <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+ <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
</bean>
<bean id="org.hisp.dhis.expression.ExpressionService" class="org.hisp.dhis.expression.DefaultExpressionService">
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/ViewDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/ViewDataEntryFormAction.java 2011-05-07 22:34:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/ViewDataEntryFormAction.java 2011-05-07 22:48:54 +0000
@@ -30,16 +30,12 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.hisp.dhis.dataelement.DataElement;
-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.DataElementOperandNameComparator;
import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.dataentryform.DataEntryFormService;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.user.UserSettingService;
@@ -53,8 +49,6 @@
public class ViewDataEntryFormAction
implements Action
{
- private static final Pattern IDENTIFIER_PATTERN = Pattern.compile( "value\\[(.*)\\].value:value\\[(.*)\\].value" );
-
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -66,13 +60,6 @@
this.dataSetService = dataSetService;
}
- private DataElementService dataElementService;
-
- public void setDataElementService( DataElementService dataElementService )
- {
- this.dataElementService = dataElementService;
- }
-
private DataElementCategoryService dataElementCategoryService;
public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService )
@@ -86,6 +73,13 @@
{
this.userSettingService = userSettingService;
}
+
+ private DataEntryFormService dataEntryFormService;
+
+ public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
+ {
+ this.dataEntryFormService = dataEntryFormService;
+ }
// -------------------------------------------------------------------------
// Getters & Setters
@@ -144,7 +138,7 @@
dataEntryForm = dataSet.getDataEntryForm();
- dataEntryValue = dataEntryForm != null ? prepareDataEntryFormForEdit( dataEntryForm.getHtmlCode() ) : "";
+ dataEntryValue = dataEntryForm != null ? dataEntryFormService.prepareDataEntryFormForEdit( dataEntryForm.getHtmlCode() ) : "";
autoSave = (Boolean) userSettingService.getUserSetting( UserSettingService.AUTO_SAVE_DATA_ENTRY_FORM, false );
@@ -154,129 +148,4 @@
return SUCCESS;
}
-
- /**
- * Prepares the data entry form code by injecting the dataElement name and
- * and title for each entry field.
- *
- * @param htmlCode HTML code of the data entry form.
- * @return HTML code for the data entry form injected with data element names.
- */
- private String prepareDataEntryFormForEdit( String htmlCode )
- {
- // ---------------------------------------------------------------------
- // Buffer to contain the final result.
- // ---------------------------------------------------------------------
-
- StringBuffer sb = new StringBuffer();
-
- // ---------------------------------------------------------------------
- // Pattern to match data elements in the HTML code.
- // ---------------------------------------------------------------------
-
- Pattern patDataElement = Pattern.compile( "(<input.*?)[/]?>" );
- Matcher matDataElement = patDataElement.matcher( htmlCode );
-
- // ---------------------------------------------------------------------
- // Iterate through all matching data element fields.
- // ---------------------------------------------------------------------
-
- while ( matDataElement.find() )
- {
- // -----------------------------------------------------------------
- // Get input HTML code
- // -----------------------------------------------------------------
-
- String dataElementCode = matDataElement.group( 1 );
-
- // -----------------------------------------------------------------
- // Pattern to extract data element ID from data element field
- // -----------------------------------------------------------------
-
- Matcher dataElementMatcher = IDENTIFIER_PATTERN.matcher( dataElementCode );
-
- if ( dataElementMatcher.find() && dataElementMatcher.groupCount() > 0 )
- {
- // -------------------------------------------------------------
- // Get data element id,name, optionCombo id,name of data element
- // -------------------------------------------------------------
-
- int dataElementId = Integer.parseInt( dataElementMatcher.group( 1 ) );
- DataElement dataElement = dataElementService.getDataElement( dataElementId );
-
- int optionComboId = Integer.parseInt( dataElementMatcher.group( 2 ) );
- DataElementCategoryOptionCombo optionCombo = dataElementCategoryService.getDataElementCategoryOptionCombo( optionComboId );
- String optionComboName = optionCombo != null ? optionCombo.getName() : "";
-
- // -------------------------------------------------------------
- // Insert name of data element in output code
- // -------------------------------------------------------------
-
- String displayValue = "Data element does not exist";
-
- if ( dataElement != null )
- {
- displayValue = dataElement.getShortName() + " " + optionComboName;
-
- if ( dataElementCode.contains( "value=\"\"" ) )
- {
- dataElementCode = dataElementCode.replace( "value=\"\"", "value=\"[ " + displayValue + " ]\"" );
- }
- else
- {
- dataElementCode += " value=\"[ " + displayValue + " ]\"";
- }
-
- StringBuilder title = new StringBuilder( "title=\"" ).append( dataElement.getId() ).append( " - " ).
- append( dataElement.getName() ).append( " - " ).append( optionComboId ).append( " - " ).
- append( optionComboName ).append( " - " ).append( dataElement.getType() ).append( "\"" );
-
- if ( dataElementCode.contains( "title=\"\"" ) )
- {
- dataElementCode = dataElementCode.replace( "title=\"\"", title );
- }
- else
- {
- dataElementCode += " " + title;
- }
- }
- else
- {
- if ( dataElementCode.contains( "value=\"\"" ) )
- {
- dataElementCode = dataElementCode.replace( "value=\"\"", "value=\"[ " + displayValue + " ]\"" );
- }
- else
- {
- dataElementCode += " value=\"[ " + displayValue + " ]\"";
- }
-
- if ( dataElementCode.contains( "title=\"\"" ) )
- {
- dataElementCode = dataElementCode.replace( "title=\"\"", "title=\"" + displayValue + "\"" );
- }
- else
- {
- dataElementCode += " title=\"" + displayValue + "\"";
- }
- }
-
- // -------------------------------------------------------------
- // Appends dataElementCode
- // -------------------------------------------------------------
-
- String appendCode = dataElementCode;
- appendCode += "/>";
- matDataElement.appendReplacement( sb, appendCode );
- }
- }
-
- // ---------------------------------------------------------------------
- // Add remaining code (after the last match), and return formatted code
- // ---------------------------------------------------------------------
-
- matDataElement.appendTail( sb );
-
- return sb.toString();
- }
}
=== 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-04-27 16:07:05 +0000
+++ 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
@@ -304,15 +304,15 @@
<property name="dataSetService">
<ref bean="org.hisp.dhis.dataset.DataSetService"/>
</property>
- <property name="dataElementService">
- <ref bean="org.hisp.dhis.dataelement.DataElementService"/>
- </property>
<property name="dataElementCategoryService">
<ref bean="org.hisp.dhis.dataelement.DataElementCategoryService"/>
</property>
<property name="userSettingService">
<ref bean="org.hisp.dhis.user.UserSettingService"/>
</property>
+ <property name="dataEntryFormService">
+ <ref bean="org.hisp.dhis.dataentryform.DataEntryFormService"/>
+ </property>
</bean>
<bean id="org.hisp.dhis.dataset.action.dataentryform.SaveDataEntryFormAction"
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/css/pivot.css'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/css/pivot.css 2010-10-15 10:06:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/css/pivot.css 1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
-.pivot td
-{
- border: 1px solid #d0d0d0;
- padding-top: 2px;
- padding-bottom: 3px;
- padding-left: 10px;
- padding-right: 10px;
-}
-
-div#criteria
-{
- position: relative;
- left: 2px;
- width: 230px;
- height: 150px;
- border: 1px solid #b0b0b0;
- background-color: #d9ece1;
- padding-left: 20px;
- margin-bottom: 6px;
-}
-
-div#pivot
-{
- position: relative;
- left: 2px;
- width: 230px;
- height: 130px;
- border: 1px solid #b0b0b0;
- background-color: #d9ece1;
- padding-left: 20px;
- margin-bottom: 6px;
-}
-
-td.column
-{
- background-color: #dae6f8;
- min-width: 60px;
- text-align: center;
-}
-
-td.row
-{
- background-color: #dae6f8;
- min-width: 120px;
-}
-
-td.cell
-{
- text-align: center;
-}
-
-div#pivotMenu
-{
- position: absolute;
- display: none;
-}