dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17874
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7291: local/in CCEM work in progress
------------------------------------------------------------
revno: 7291
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-06-14 11:28:42 +0530
message:
local/in CCEM work in progress
removed:
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/ViewCatalogTypeDataEntryFormAction.java
added:
local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogDataEntryService.java
local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogDataEntryService.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/DeleteCatalogDataEntryFormAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/SaveCatalogDataEntryFormAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/ValidateCatalogDataEntryFormAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/ViewCatalogDataEntryFormAction.java
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogDataEntryForm.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/viewCatalogTypeDataEntryForm.js
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/viewCatalogDataEntryForm.vm
modified:
local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml
local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/org/hisp/dhis/coldchain/hibernate/CatalogType.hbm.xml
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeDetailsAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ShowAddCatalogFormAction.java
local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml
local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties
local/in/dhis-web-coldchain/src/main/resources/struts.xml
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addCatalogForm.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogTypeList.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalogType.js
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonCatalogType.vm
local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/util/DashBoardService.java
--
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
=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogDataEntryService.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogDataEntryService.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogDataEntryService.java 2012-06-14 05:58:42 +0000
@@ -0,0 +1,27 @@
+package org.hisp.dhis.coldchain.catalog;
+
+import java.util.Collection;
+import java.util.regex.Pattern;
+
+import org.hisp.dhis.i18n.I18n;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version CatalogDataEntryService.java Jun 7, 2012 5:12:27 PM
+ */
+public interface CatalogDataEntryService
+{
+ final Pattern INPUT_PATTERN = Pattern.compile( "(<input.*?)[/]?>", Pattern.DOTALL );
+
+ final Pattern IDENTIFIER_PATTERN_FIELD = Pattern.compile( "id=\"(\\d+)-(\\d+)-val\"" );
+
+ //--------------------------------------------------------------------------
+ // ProgramDataEntryService
+ //--------------------------------------------------------------------------
+
+ String prepareDataEntryFormForCatalog( String htmlCode, Collection<CatalogDataValue> dataValues, String disabled,
+ I18n i18n, CatalogType catalogType );
+
+ String prepareDataEntryFormForEdit( String htmlCode );
+}
=== added file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogDataEntryService.java'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogDataEntryService.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogDataEntryService.java 2012-06-14 05:58:42 +0000
@@ -0,0 +1,1279 @@
+package org.hisp.dhis.coldchain.catalog;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang.BooleanUtils;
+import org.hisp.dhis.i18n.I18n;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version DefaultCatalogDataEntryService.java Jun 7, 2012 5:18:09 PM
+ */
+public class DefaultCatalogDataEntryService implements CatalogDataEntryService
+{
+
+ private static final String EMPTY = "";
+
+ private static final String CATALOG_TYPE_ATTRIBUTE_DOES_NOT_EXIST = "[ Catalogtype attribute does not exist ]";
+
+ private static final String EMPTY_VALUE_TAG = "value=\"\"";
+
+ private static final String EMPTY_TITLE_TAG = "title=\"\"";
+
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private CatalogTypeAttributeService catalogTypeAttributeService;
+
+ public void setCatalogTypeAttributeService( CatalogTypeAttributeService catalogTypeAttributeService )
+ {
+ this.catalogTypeAttributeService = catalogTypeAttributeService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Implementation methods
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String prepareDataEntryFormForCatalog( String htmlCode, Collection<CatalogDataValue> dataValues, String disabled,
+ I18n i18n, CatalogType catalogType )
+ {
+ Map<Integer, Collection<CatalogDataValue>> mapDataValue = new HashMap<Integer, Collection<CatalogDataValue>>();
+
+ String result = "";
+
+ result = populateCustomDataEntryForTextBox( htmlCode, dataValues, disabled, i18n, catalogType, mapDataValue );
+
+ result = populateCustomDataEntryForCOMBO( htmlCode, dataValues, disabled, i18n, catalogType, mapDataValue );
+
+ result = populateCustomDataEntryForDate( result, dataValues, disabled, i18n, catalogType, mapDataValue );
+
+ result = populateCustomDataEntryForBoolean( result, dataValues, disabled, i18n, catalogType, mapDataValue );
+
+ result = populateI18nStrings( result, i18n );
+
+ return result;
+ }
+
+
+
+ public String prepareDataEntryFormForEdit( String htmlCode )
+ {
+ String result = populateCustomDataEntryForDate( htmlCode );
+
+ result = populateCustomDataEntryForBoolean( result );
+
+ result = populateCustomDataEntryForTextBox( result );
+
+ result = populateCustomDataEntryForCOMBO( result );
+
+ return result;
+ }
+
+
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
+ private String populateCustomDataEntryForTextBox( String htmlCode )
+ {
+ // ---------------------------------------------------------------------
+ // Metadata code to add to HTML before outputting
+ // ---------------------------------------------------------------------
+
+ StringBuffer sb = new StringBuffer();
+
+ // ---------------------------------------------------------------------
+ // Pattern to match catalogType attribute in the HTML code
+ // ---------------------------------------------------------------------
+
+ Matcher inputMatcher = INPUT_PATTERN.matcher( htmlCode );
+
+ // ---------------------------------------------------------------------
+ // Iterate through all matching catalogType attribute fields
+ // ---------------------------------------------------------------------
+
+ while ( inputMatcher.find() )
+ {
+ // -----------------------------------------------------------------
+ // Get HTML input field code
+ // -----------------------------------------------------------------
+
+ String catalogTypeAttributeCode = inputMatcher.group( 1 );
+
+ String inputHTML = inputMatcher.group();
+ inputHTML = inputHTML.replace( ">", "" );
+
+ Matcher identifierMatcher = CatalogDataEntryService.IDENTIFIER_PATTERN_FIELD.matcher( catalogTypeAttributeCode );
+
+ if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
+ {
+ // -------------------------------------------------------------
+ // Get catalogType attribute ID of catalogType attribute
+ // -------------------------------------------------------------
+
+ int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) );
+
+ CatalogTypeAttribute catalogTypeAttribute = catalogTypeAttributeService.getCatalogTypeAttribute( catalogTypeAttributeId );
+
+ if ( catalogTypeAttribute != null && (!CatalogTypeAttribute.TYPE_INT.equalsIgnoreCase( catalogTypeAttribute.getValueType() ) && !CatalogTypeAttribute.TYPE_STRING.equalsIgnoreCase( catalogTypeAttribute.getValueType() )) )
+ {
+ continue;
+ }
+
+
+ String displayValue = ( catalogTypeAttribute == null ) ? " value=\"" + CATALOG_TYPE_ATTRIBUTE_DOES_NOT_EXIST + "\" "
+ : " value=\"[ " + catalogTypeAttribute.getName() + " ]\"";
+
+ inputHTML = inputHTML.contains( EMPTY_VALUE_TAG ) ? inputHTML.replace( EMPTY_VALUE_TAG, displayValue )
+ : inputHTML + " " + displayValue;
+
+ String displayTitle = ( catalogTypeAttribute == null ) ? " title=\"" + CATALOG_TYPE_ATTRIBUTE_DOES_NOT_EXIST + "\" "
+ : " title=\"" + catalogTypeAttribute.getId() + "." + catalogTypeAttribute.getName() + "-"
+ + catalogTypeAttribute.getValueType() + "\" ";
+
+ inputHTML = inputHTML.contains( EMPTY_TITLE_TAG ) ? inputHTML.replace( EMPTY_TITLE_TAG, displayTitle )
+ : inputHTML + " " + displayTitle;
+
+ inputHTML = inputHTML + ">";
+
+ inputMatcher.appendReplacement( sb, inputHTML );
+ }
+ }
+
+ inputMatcher.appendTail( sb );
+
+ return (sb.toString().isEmpty()) ? htmlCode : sb.toString();
+ }
+
+
+ private String populateCustomDataEntryForCOMBO( String htmlCode )
+ {
+ // ---------------------------------------------------------------------
+ // Metadata code to add to HTML before outputting
+ // ---------------------------------------------------------------------
+
+ StringBuffer sb = new StringBuffer();
+
+ // ---------------------------------------------------------------------
+ // Pattern to match catalogType attribute in the HTML code
+ // ---------------------------------------------------------------------
+
+ Matcher inputMatcher = INPUT_PATTERN.matcher( htmlCode );
+
+ // ---------------------------------------------------------------------
+ // Iterate through all matching catalogType attribute fields
+ // ---------------------------------------------------------------------
+
+ while ( inputMatcher.find() )
+ {
+ // -----------------------------------------------------------------
+ // Get HTML input field code
+ // -----------------------------------------------------------------
+
+ String catalogTypeAttributeCode = inputMatcher.group( 1 );
+
+ String inputHTML = inputMatcher.group();
+ inputHTML = inputHTML.replace( ">", "" );
+
+ Matcher identifierMatcher = CatalogDataEntryService.IDENTIFIER_PATTERN_FIELD.matcher( catalogTypeAttributeCode );
+
+ if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
+ {
+ // -------------------------------------------------------------
+ // Get catalogType attribute ID of catalogType attribute
+ // -------------------------------------------------------------
+
+ int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) );
+
+ CatalogTypeAttribute catalogTypeAttribute = catalogTypeAttributeService.getCatalogTypeAttribute( catalogTypeAttributeId );
+
+ if ( catalogTypeAttribute != null && !CatalogTypeAttribute.TYPE_COMBO.equalsIgnoreCase( catalogTypeAttribute.getValueType() ) )
+ {
+ continue;
+ }
+
+
+ String displayValue = ( catalogTypeAttribute == null ) ? " value=\"" + CATALOG_TYPE_ATTRIBUTE_DOES_NOT_EXIST + "\" "
+ : " value=\"[ " + catalogTypeAttribute.getName() + " ]\"";
+
+ inputHTML = inputHTML.contains( EMPTY_VALUE_TAG ) ? inputHTML.replace( EMPTY_VALUE_TAG, displayValue )
+ : inputHTML + " " + displayValue;
+
+ String displayTitle = ( catalogTypeAttribute == null ) ? " title=\"" + CATALOG_TYPE_ATTRIBUTE_DOES_NOT_EXIST + "\" "
+ : " title=\"" + catalogTypeAttribute.getId() + "." + catalogTypeAttribute.getName() + "-"
+ + catalogTypeAttribute.getValueType() + "\" ";
+
+ inputHTML = inputHTML.contains( EMPTY_TITLE_TAG ) ? inputHTML.replace( EMPTY_TITLE_TAG, displayTitle )
+ : inputHTML + " " + displayTitle;
+
+ inputHTML = inputHTML + ">";
+
+ inputMatcher.appendReplacement( sb, inputHTML );
+ }
+ }
+
+ inputMatcher.appendTail( sb );
+
+ return (sb.toString().isEmpty()) ? htmlCode : sb.toString();
+ }
+
+
+ private String populateCustomDataEntryForBoolean( String htmlCode )
+ {
+ // ---------------------------------------------------------------------
+ // Metadata code to add to HTML before outputting
+ // ---------------------------------------------------------------------
+
+ StringBuffer sb = new StringBuffer();
+
+ // ---------------------------------------------------------------------
+ // Pattern to match catalogType attribute in the HTML code
+ // ---------------------------------------------------------------------
+
+ Matcher inputMatcher = INPUT_PATTERN.matcher( htmlCode );
+
+ // ---------------------------------------------------------------------
+ // Iterate through all matching catalogType attribute fields
+ // ---------------------------------------------------------------------
+
+ while ( inputMatcher.find() )
+ {
+ String inputHTML = inputMatcher.group();
+ inputHTML = inputHTML.replace( ">", "" );
+
+ // -----------------------------------------------------------------
+ // Get HTML input field code
+ // -----------------------------------------------------------------
+
+ String catalogTypeAttributeCode = inputMatcher.group( 1 );
+
+ Matcher identifierMatcher = IDENTIFIER_PATTERN_FIELD.matcher( catalogTypeAttributeCode );
+
+ if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
+ {
+ // -------------------------------------------------------------
+ // Get catalogType attribute ID of catalogType attribute
+ // -------------------------------------------------------------
+ int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) );
+
+ CatalogTypeAttribute catalogTypeAttribute = catalogTypeAttributeService.getCatalogTypeAttribute( catalogTypeAttributeId );
+
+ if ( catalogTypeAttribute != null && !CatalogTypeAttribute.TYPE_BOOL.equalsIgnoreCase( catalogTypeAttribute.getValueType() ) )
+ {
+ continue;
+ }
+
+ String displayValue = ( catalogTypeAttribute == null) ? " value=\"" + CATALOG_TYPE_ATTRIBUTE_DOES_NOT_EXIST + "\" "
+ : " value=\"[ " + catalogTypeAttribute.getName() + " ]\" ";
+
+ inputHTML = inputHTML.contains( EMPTY_VALUE_TAG ) ? inputHTML.replace( EMPTY_VALUE_TAG, displayValue )
+ : inputHTML + " " + displayValue;
+
+ String displayTitle = ( catalogTypeAttribute == null) ? " title=\"" + CATALOG_TYPE_ATTRIBUTE_DOES_NOT_EXIST + "\" "
+ : " title=\"" + catalogTypeAttribute.getId() + "." + catalogTypeAttribute.getName() + "-"
+ + catalogTypeAttribute.getValueType() + "\" ";
+
+ inputHTML = inputHTML.contains( EMPTY_TITLE_TAG ) ? inputHTML.replace( EMPTY_TITLE_TAG, displayTitle )
+ : inputHTML + " " + displayTitle;
+
+ inputHTML = inputHTML + ">";
+
+ inputMatcher.appendReplacement( sb, inputHTML );
+ }
+ }
+
+ inputMatcher.appendTail( sb );
+
+ return (sb.toString().isEmpty()) ? htmlCode : sb.toString();
+ }
+
+
+ private String populateCustomDataEntryForDate( String htmlCode )
+ {
+ // ---------------------------------------------------------------------
+ // Metadata code to add to HTML before outputting
+ // ---------------------------------------------------------------------
+
+ StringBuffer sb = new StringBuffer();
+
+ // ---------------------------------------------------------------------
+ // Pattern to match data elements in the HTML code
+ // ---------------------------------------------------------------------
+
+ Matcher inputMatcher = INPUT_PATTERN.matcher( htmlCode );
+
+ // ---------------------------------------------------------------------
+ // Iterate through all matching data element fields
+ // ---------------------------------------------------------------------
+
+ while ( inputMatcher.find() )
+ {
+ String inputHTML = inputMatcher.group();
+
+ inputHTML = inputHTML.replace( ">", "" );
+
+ // -----------------------------------------------------------------
+ // Get HTML input field code
+ // -----------------------------------------------------------------
+
+ String catalogTypeAttributeCode = inputMatcher.group( 1 );
+
+ Matcher identifierMatcher = IDENTIFIER_PATTERN_FIELD.matcher( catalogTypeAttributeCode );
+
+ if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
+ {
+ // -------------------------------------------------------------
+ // Get catalogType attribute ID of catalogType attribute
+ // -------------------------------------------------------------
+
+ int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) );
+
+ CatalogTypeAttribute catalogTypeAttribute = catalogTypeAttributeService.getCatalogTypeAttribute( catalogTypeAttributeId );
+
+ //int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
+ //DataElement dataElement = dataElementService.getDataElement( dataElementId );
+
+ if ( catalogTypeAttribute != null && !CatalogTypeAttribute.TYPE_DATE.equalsIgnoreCase( catalogTypeAttribute.getValueType() ) )
+ {
+ continue;
+ }
+
+ String displayValue = ( catalogTypeAttribute == null ) ? " value=\"" + CATALOG_TYPE_ATTRIBUTE_DOES_NOT_EXIST + "\""
+ : " value=\"[ " + catalogTypeAttribute.getName() + " ]\"";
+
+ inputHTML = inputHTML.contains( EMPTY_VALUE_TAG ) ? inputHTML.replace( EMPTY_VALUE_TAG, displayValue )
+ : inputHTML + " " + displayValue;
+
+ String displayTitle = (catalogTypeAttribute == null) ? " title=\"" + CATALOG_TYPE_ATTRIBUTE_DOES_NOT_EXIST + "\""
+ : " title=\"" + catalogTypeAttribute.getId() + "." + catalogTypeAttribute.getName() + "-"
+ + catalogTypeAttribute.getValueType() + "\" ";
+
+ inputHTML = inputHTML.contains( EMPTY_TITLE_TAG ) ? inputHTML.replace( EMPTY_TITLE_TAG, displayTitle )
+ : inputHTML + " " + displayTitle;
+
+ inputHTML = inputHTML + ">";
+
+ inputMatcher.appendReplacement( sb, inputHTML );
+ }
+ }
+
+ inputMatcher.appendTail( sb );
+
+ return (sb.toString().isEmpty()) ? htmlCode : sb.toString();
+ }
+
+ private String populateCustomDataEntryForBoolean( String dataEntryFormCode,
+ Collection<CatalogDataValue> dataValues, String disabled, I18n i18n, CatalogType catalogType,Map<Integer, Collection<CatalogDataValue>> mapDataValue )
+ {
+ // ---------------------------------------------------------------------
+ // Inline Javascript to add to HTML before outputting
+ // ---------------------------------------------------------------------
+
+ final String jsCodeForBoolean = " name=\"entryselect\" $DISABLED data=\"{mandatory:$MANDATORY, catalogTypeAttributeName:'$CATALOGTYPEATTRIBUTENAME' }\" onchange=\"saveOpt( $CATALOGTYPEATTRIBUTEID )\" style=\" text-align:center;\" ";
+
+ StringBuffer sb = new StringBuffer();
+
+ // ---------------------------------------------------------------------
+ // Pattern to match CatalogTypeAttributes in the HTML code
+ // ---------------------------------------------------------------------
+
+ Matcher CatalogTypeAttributeMatcher = INPUT_PATTERN.matcher( dataEntryFormCode );
+
+ // ---------------------------------------------------------------------
+ // Iterate through all matching catalogTypeAttribute fields
+ // ---------------------------------------------------------------------
+
+ Map<Integer, CatalogTypeAttribute> catalogTypeAttributeMap = getCatalogTypeAttributeMap( catalogType );
+
+ while ( CatalogTypeAttributeMatcher.find() )
+ {
+ // -----------------------------------------------------------------
+ // Get HTML input field code
+ // -----------------------------------------------------------------
+
+ String mandatory = "null";
+
+
+ String catalogTypeAttributeCode = CatalogTypeAttributeMatcher.group( 1 );
+
+ Matcher identifierMatcher = IDENTIFIER_PATTERN_FIELD.matcher( catalogTypeAttributeCode );
+ if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
+ {
+
+ // -------------------------------------------------------------
+ // Get catalogType attribute ID of catalogType attribute
+ // -------------------------------------------------------------
+
+ int catalogTypeId = Integer.parseInt( identifierMatcher.group( 1 ) );
+
+ int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) );
+
+ CatalogTypeAttribute catalogTypeAttribute = null;
+
+ String catalogTypeName = catalogType.getName();
+
+ if ( catalogTypeId != catalogType.getId() )
+ {
+ catalogTypeAttribute = catalogTypeAttributeService.getCatalogTypeAttribute( catalogTypeAttributeId );
+ }
+ else
+ {
+ catalogTypeAttribute = catalogTypeAttributeMap.get( catalogTypeAttributeId );
+
+ if ( catalogTypeAttribute == null )
+ {
+ return i18n.getString( "some_catalogType_attribute_not_exist" );
+ }
+
+ mandatory = BooleanUtils.toStringTrueFalse( catalogTypeAttribute.isMandatory() );
+ }
+
+ if ( catalogTypeAttribute == null )
+ {
+ continue;
+ }
+
+ if ( !CatalogTypeAttribute.TYPE_BOOL.equalsIgnoreCase( catalogTypeAttribute.getValueType() ) )
+ {
+ continue;
+ }
+
+ // -------------------------------------------------------------
+ // Find type of catalogType attribute
+ // -------------------------------------------------------------
+
+ String catalogTypeAttributeType = catalogTypeAttribute.getValueType();
+
+ // -------------------------------------------------------------
+ // Find existing value of catalogType Attribute
+ // -------------------------------------------------------------
+
+ CatalogDataValue catalogDataValue = null;
+
+
+ String catalogTypeAttributeValue = EMPTY;
+
+ if ( catalogTypeId != catalogType.getId() )
+ {
+
+
+ Collection<CatalogDataValue> catalogDataValues = mapDataValue.get( catalogTypeId );
+
+ if ( catalogDataValues == null )
+ {
+
+ }
+
+ catalogDataValue = getValue( catalogDataValues, catalogTypeAttributeId );
+
+ catalogTypeAttributeValue = catalogDataValue != null ? catalogDataValue.getValue() : catalogTypeAttributeValue;
+ }
+ else
+ {
+
+ catalogDataValue = getValue( dataValues, catalogTypeAttributeId );
+
+ if ( catalogDataValue != null )
+ {
+ catalogTypeAttributeValue = catalogDataValue.getValue();
+ }
+ }
+
+ String appendCode = catalogTypeAttributeCode.replaceFirst( "input", "select" );
+ appendCode = appendCode.replace( "name=\"entryselect\"", jsCodeForBoolean );
+
+ // -------------------------------------------------------------
+ // Add title
+ // -------------------------------------------------------------
+
+ if ( catalogTypeAttributeCode.contains( "title=\"\"" ) )
+ {
+ appendCode = appendCode.replace( "title=\"\"", "title=\"" + catalogTypeAttribute.getId() + "."
+ + catalogTypeAttribute.getName() + "-" + catalogTypeAttributeType + "\" " );
+ }
+ else
+ {
+ appendCode += "title=\"" + catalogTypeAttribute.getId() + "." + catalogTypeAttribute.getName() + "-"
+ + catalogTypeAttributeType + "\" ";
+ }
+
+ appendCode += ">";
+ appendCode += "<option value=\"\">" + i18n.getString( "Please select" ) + "</option>";
+ appendCode += "<option value=\"true\">" + i18n.getString( "yes" ) + "</option>";
+ appendCode += "<option value=\"false\">" + i18n.getString( "no" ) + "</option>";
+
+ // -------------------------------------------------------------
+ // Insert value of catalogType Attribute in output code
+ // -------------------------------------------------------------
+
+ if ( catalogDataValue != null )
+ {
+ if ( catalogTypeAttributeValue.equalsIgnoreCase( "true" ) )
+ {
+ appendCode = appendCode.replace( "<option value=\"true\">", "<option value=\""
+ + i18n.getString( "true" ) + "\" selected>" );
+ }
+
+ if ( catalogTypeAttributeValue.equalsIgnoreCase( "false" ) )
+ {
+ appendCode = appendCode.replace( "<option value=\"false\">", "<option value=\""
+ + i18n.getString( "false" ) + "\" selected>" );
+ }
+ }
+
+ appendCode += "</select>";
+
+ // -----------------------------------------------------------
+ // Check if this dataElement is from another programStage then
+ // disable
+ // If programStagsInstance is completed then disabled it
+ // -----------------------------------------------------------
+
+ disabled = "";
+ if ( catalogTypeId != catalogType.getId() )
+ {
+ disabled = "disabled";
+ }
+ // -----------------------------------------------------------
+ //
+ // -----------------------------------------------------------
+
+ appendCode = appendCode.replace( "$CATALOGTYPEATTRIBUTEID", String.valueOf( catalogTypeAttributeId ) );
+ appendCode = appendCode.replace( "$CATALOGTYPEID", String.valueOf( catalogTypeId ) );
+ appendCode = appendCode.replace( "$CATALOGTYPENAME", catalogTypeName );
+ appendCode = appendCode.replace( "$CATALOGTYPEATTRIBUTENAME", catalogTypeAttribute.getName() );
+ appendCode = appendCode.replace( "$CATALOGTYPEATTRIBUTETYPE", catalogTypeAttributeType );
+ appendCode = appendCode.replace( "$DISABLED", disabled );
+ appendCode = appendCode.replace( "$MANDATORY", mandatory );
+ appendCode = appendCode.replace( "i18n_yes", i18n.getString( "yes" ) );
+ appendCode = appendCode.replace( "i18n_no", i18n.getString( "no" ) );
+ appendCode = appendCode.replace( "i18n_select_value", i18n.getString( "select_value" ) );
+ appendCode = appendCode.replace( "$SAVEMODE", "false" );
+
+ appendCode = appendCode.replaceAll( "\\$", "\\\\\\$" );
+
+ CatalogTypeAttributeMatcher.appendReplacement( sb, appendCode );
+ }
+ }
+
+ CatalogTypeAttributeMatcher.appendTail( sb );
+
+ return sb.toString();
+ }
+
+
+ private String populateCustomDataEntryForTextBox( String dataEntryFormCode,
+ Collection<CatalogDataValue> dataValues, String disabled, I18n i18n, CatalogType catalogType,
+ Map<Integer, Collection<CatalogDataValue>> mapDataValue )
+ {
+ // ---------------------------------------------------------------------
+ // Inline Javascript to add to HTML before outputting
+ // ---------------------------------------------------------------------
+
+ final String jsCodeForInputs = " $DISABLED onchange=\"saveVal( $CATALOGTYPEATTRIBUTEID )\" data=\"{mandatory:$MANDATORY, catalogTypeAttributeName:'$CATALOGTYPEATTRIBUTENAME', catalogTypeAttributeValueType:'$CATALOGTYPEATTRIBUTEVALUETYPE'}\" onkeypress=\"return keyPress(event, this)\" style=\" text-align:center;\" ";
+ // final String jsCodeForOptions = " $DISABLED options='$OPTIONS' catalogTypeAttributeId=\"$CATALOGTYPEATTRIBUTEID\" data=\"{mandatory:$MANDATORY, catalogTypeAttributeName:'$CATALOGTYPEATTRIBUTENAME', catalogTypeAttributeValueType:'$CATALOGTYPEATTRIBUTEVALUETYPE'}\" onkeypress=\"return keyPress(event, this)\" style=\" text-align:center;\" ";
+
+
+ StringBuffer sb = new StringBuffer();
+
+ // ---------------------------------------------------------------------
+ // Pattern to match CatalogTypeAttributes in the HTML code
+ // ---------------------------------------------------------------------
+
+
+
+ Pattern INPUT_PATTERN = Pattern.compile( "(<input.*?)[/]?>", Pattern.DOTALL );
+
+ Matcher CatalogTypeAttributeMatcher = INPUT_PATTERN.matcher( dataEntryFormCode );
+
+ // ---------------------------------------------------------------------
+ // Iterate through all matching catalogTypeAttribute fields
+ // ---------------------------------------------------------------------
+
+ Map<Integer, CatalogTypeAttribute> catalogTypeAttributeMap = getCatalogTypeAttributeMap( catalogType );
+
+ // Map<Integer, DataElement> dataElementMap = getDataElementMap( programStage );
+
+ while ( CatalogTypeAttributeMatcher.find() )
+ {
+ // -----------------------------------------------------------------
+ // Get HTML input field code
+ // -----------------------------------------------------------------
+
+ String mandatory = "null";
+
+ String catalogTypeAttributeCode = CatalogTypeAttributeMatcher.group( 1 );
+
+ Matcher identifierMatcher = IDENTIFIER_PATTERN_FIELD.matcher( catalogTypeAttributeCode );
+
+ if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
+ {
+ // -------------------------------------------------------------
+ // Get catalogType attribute ID of catalogType attribute
+ // -------------------------------------------------------------
+
+ int catalogTypeId = Integer.parseInt( identifierMatcher.group( 1 ) );
+
+ int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) );
+
+ CatalogTypeAttribute catalogTypeAttribute = null;
+
+ String catalogTypeName = catalogType.getName();
+
+
+ if ( catalogTypeId != catalogType.getId() )
+ {
+ catalogTypeAttribute = catalogTypeAttributeService.getCatalogTypeAttribute( catalogTypeAttributeId );
+ }
+
+ else
+ {
+ catalogTypeAttribute = catalogTypeAttributeMap.get( catalogTypeAttributeId );
+
+ if ( catalogTypeAttribute == null )
+ {
+ return i18n.getString( "some_catalogType_attribute_not_exist" );
+ }
+
+ mandatory = BooleanUtils.toStringTrueFalse( catalogTypeAttribute.isMandatory() );
+
+ }
+
+ if ( catalogTypeAttribute == null )
+ {
+ continue;
+ }
+
+ if ( !CatalogTypeAttribute.TYPE_INT.equalsIgnoreCase( catalogTypeAttribute.getValueType() )
+ && !CatalogTypeAttribute.TYPE_STRING.equalsIgnoreCase( catalogTypeAttribute.getValueType() ) )
+ {
+ continue;
+ }
+
+
+ // -------------------------------------------------------------
+ // Find type of catalogType attribute
+ // -------------------------------------------------------------
+
+ String catalogTypeAttributeType = catalogTypeAttribute.getValueType();
+
+
+ // -------------------------------------------------------------
+ // Find existing value of catalogType Attribute
+ // -------------------------------------------------------------
+
+ CatalogDataValue catalogDataValue = null;
+
+
+ String catalogTypeAttributeValue = EMPTY;
+
+
+
+ if ( catalogTypeId != catalogType.getId() )
+ {
+
+
+ Collection<CatalogDataValue> catalogDataValues = mapDataValue.get( catalogTypeId );
+
+ if ( catalogDataValues == null )
+ {
+
+ }
+
+ catalogDataValue = getValue( catalogDataValues, catalogTypeAttributeId );
+
+ catalogTypeAttributeValue = catalogDataValue != null ? catalogDataValue.getValue() : catalogTypeAttributeValue;
+ }
+ else
+ {
+ catalogDataValue = getValue( dataValues, catalogTypeAttributeId );
+
+ if ( catalogDataValue != null )
+ {
+ catalogTypeAttributeValue = catalogDataValue.getValue();
+ }
+ }
+
+ // -------------------------------------------------------------
+ // Insert title information - Data element id, name, type, min,
+ // max
+ // -------------------------------------------------------------
+
+
+ if ( catalogTypeAttributeCode.contains( "title=\"\"" ) )
+ {
+ catalogTypeAttributeCode = catalogTypeAttributeCode.replace( "title=\"\"", "title=\"" + catalogTypeAttribute.getId() + "."
+ + catalogTypeAttribute.getName() + " (" + catalogTypeAttributeType + ")\" " );
+ }
+ else
+ {
+ catalogTypeAttributeCode += "title=\"" + catalogTypeAttribute.getId() + "." + catalogTypeAttribute.getName() + " ("
+ + catalogTypeAttributeType + ")\" ";
+ }
+
+ // -------------------------------------------------------------
+ // Insert value of catalogType Attribute in output code
+ // -------------------------------------------------------------
+
+ String appendCode = catalogTypeAttributeCode;
+
+ if ( appendCode.contains( "value=\"\"" ) )
+ {
+ appendCode = appendCode.replace( "value=\"\"", "value=\"" + catalogTypeAttributeValue + "\"" );
+ }
+ else
+ {
+ appendCode += "value=\"" + catalogTypeAttributeValue + "\"";
+ }
+
+ appendCode += jsCodeForInputs;
+
+
+ appendCode += " />";
+
+
+ disabled = "";
+
+ if ( catalogTypeId != catalogType.getId() )
+ {
+ disabled = "disabled=\"\"";
+ }
+
+ // -----------------------------------------------------------
+ //
+ // -----------------------------------------------------------
+
+ appendCode = appendCode.replace( "$CATALOGTYPEATTRIBUTEID", String.valueOf( catalogTypeAttributeId ) );
+ appendCode = appendCode.replace( "$CATALOGTYPEID", String.valueOf( catalogTypeId ) );
+ appendCode = appendCode.replace( "$CATALOGTYPENAME", catalogTypeName );
+ appendCode = appendCode.replace( "$CATALOGTYPEATTRIBUTENAME", catalogTypeAttribute.getName() );
+ appendCode = appendCode.replace( "$CATALOGTYPEATTRIBUTEVALUETYPE", catalogTypeAttributeType );
+ appendCode = appendCode.replace( "$DISABLED", disabled );
+ appendCode = appendCode.replace( "$MANDATORY", mandatory );
+ appendCode = appendCode.replace( "$SAVEMODE", "false" );
+ appendCode = appendCode.replaceAll( "\\$", "\\\\\\$" );
+
+ System.out.println( "---appendCode---" + appendCode );
+
+ CatalogTypeAttributeMatcher.appendReplacement( sb, appendCode );
+ }
+ }
+
+ CatalogTypeAttributeMatcher.appendTail( sb );
+
+ return sb.toString();
+ }
+
+
+
+
+
+ private String populateCustomDataEntryForCOMBO( String dataEntryFormCode,
+ Collection<CatalogDataValue> dataValues, String disabled, I18n i18n, CatalogType catalogType,
+ Map<Integer, Collection<CatalogDataValue>> mapDataValue )
+ {
+ // ---------------------------------------------------------------------
+ // Inline Javascript to add to HTML before outputting
+ // ---------------------------------------------------------------------
+
+ //final String jsCodeForInputs = " $DISABLED onchange=\"saveVal( $CATALOGTYPEATTRIBUTEID )\" data=\"{mandatory:$MANDATORY, catalogTypeAttributeName:'$CATALOGTYPEATTRIBUTENAME', catalogTypeAttributeValueType:'$CATALOGTYPEATTRIBUTEVALUETYPE'}\" onkeypress=\"return keyPress(event, this)\" style=\" text-align:center;\" ";
+ final String jsCodeForOptions = " $DISABLED options='$OPTIONS' catalogTypeAttributeId=\"$CATALOGTYPEATTRIBUTEID\" data=\"{mandatory:$MANDATORY, catalogTypeAttributeName:'$CATALOGTYPEATTRIBUTENAME', catalogTypeAttributeValueType:'$CATALOGTYPEATTRIBUTEVALUETYPE'}\" onkeypress=\"return keyPress(event, this)\" style=\" text-align:center;\" ";
+
+
+ StringBuffer sb = new StringBuffer();
+
+ // ---------------------------------------------------------------------
+ // Pattern to match CatalogTypeAttributes in the HTML code
+ // ---------------------------------------------------------------------
+
+
+
+ Pattern INPUT_PATTERN = Pattern.compile( "(<input.*?)[/]?>", Pattern.DOTALL );
+
+ Matcher CatalogTypeAttributeMatcher = INPUT_PATTERN.matcher( dataEntryFormCode );
+
+ // ---------------------------------------------------------------------
+ // Iterate through all matching catalogTypeAttribute fields
+ // ---------------------------------------------------------------------
+
+ Map<Integer, CatalogTypeAttribute> catalogTypeAttributeMap = getCatalogTypeAttributeMap( catalogType );
+
+ // Map<Integer, DataElement> dataElementMap = getDataElementMap( programStage );
+
+ while ( CatalogTypeAttributeMatcher.find() )
+ {
+ // -----------------------------------------------------------------
+ // Get HTML input field code
+ // -----------------------------------------------------------------
+
+ String mandatory = "null";
+
+ String catalogTypeAttributeCode = CatalogTypeAttributeMatcher.group( 1 );
+
+ Matcher identifierMatcher = IDENTIFIER_PATTERN_FIELD.matcher( catalogTypeAttributeCode );
+
+ if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
+ {
+ // -------------------------------------------------------------
+ // Get catalogType attribute ID of catalogType attribute
+ // -------------------------------------------------------------
+
+ int catalogTypeId = Integer.parseInt( identifierMatcher.group( 1 ) );
+
+ int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) );
+
+ CatalogTypeAttribute catalogTypeAttribute = null;
+
+ String catalogTypeName = catalogType.getName();
+
+
+ if ( catalogTypeId != catalogType.getId() )
+ {
+ catalogTypeAttribute = catalogTypeAttributeService.getCatalogTypeAttribute( catalogTypeAttributeId );
+ }
+
+ else
+ {
+ catalogTypeAttribute = catalogTypeAttributeMap.get( catalogTypeAttributeId );
+
+ if ( catalogTypeAttribute == null )
+ {
+ return i18n.getString( "some_catalogType_attribute_not_exist" );
+ }
+
+ mandatory = BooleanUtils.toStringTrueFalse( catalogTypeAttribute.isMandatory() );
+
+ }
+
+ if ( catalogTypeAttribute == null )
+ {
+ continue;
+ }
+
+ if ( !CatalogTypeAttribute.TYPE_COMBO.equalsIgnoreCase( catalogTypeAttribute.getValueType() ) )
+ {
+ continue;
+ }
+
+ // -------------------------------------------------------------
+ // Find type of catalogType attribute
+ // -------------------------------------------------------------
+
+ String catalogTypeAttributeType = catalogTypeAttribute.getValueType();
+
+
+ // -------------------------------------------------------------
+ // Find existing value of catalogType Attribute
+ // -------------------------------------------------------------
+
+ CatalogDataValue catalogDataValue = null;
+
+
+ String catalogTypeAttributeValue = EMPTY;
+
+
+
+ if ( catalogTypeId != catalogType.getId() )
+ {
+
+ Collection<CatalogDataValue> catalogDataValues = mapDataValue.get( catalogTypeId );
+
+ if ( catalogDataValues == null )
+ {
+
+ }
+
+ catalogDataValue = getValue( catalogDataValues, catalogTypeAttributeId );
+
+ catalogTypeAttributeValue = catalogDataValue != null ? catalogDataValue.getValue() : catalogTypeAttributeValue;
+ }
+ else
+ {
+ catalogDataValue = getValue( dataValues, catalogTypeAttributeId );
+
+ if ( catalogDataValue != null )
+ {
+ catalogTypeAttributeValue = catalogDataValue.getValue();
+ }
+ }
+
+ // Insert title information - Data element id, name, type, min,
+ // max
+ // -------------------------------------------------------------
+
+ if ( catalogTypeAttributeCode.contains( "title=\"\"" ) )
+ {
+ catalogTypeAttributeCode = catalogTypeAttributeCode.replace( "title=\"\"", "title=\"" + catalogTypeAttribute.getId() + "."
+ + catalogTypeAttribute.getName() + " (" + catalogTypeAttributeType + ")\" " );
+ }
+ else
+ {
+ catalogTypeAttributeCode += "title=\"" + catalogTypeAttribute.getId() + "." + catalogTypeAttribute.getName() + " ("
+ + catalogTypeAttributeType + ")\" ";
+ }
+
+ // -------------------------------------------------------------
+ // Insert value of catalogType Attribute in output code
+ // -------------------------------------------------------------
+
+ String appendCode = catalogTypeAttributeCode;
+
+ if ( appendCode.contains( "value=\"\"" ) )
+ {
+ appendCode = appendCode.replace( "value=\"\"", "value=\"" + catalogTypeAttributeValue + "\"" );
+ }
+ else
+ {
+ appendCode += "value=\"" + catalogTypeAttributeValue + "\"";
+ }
+
+ if ( catalogTypeAttribute.getAttributeOptions() != null )
+ {
+ appendCode += jsCodeForOptions;
+
+ appendCode = appendCode.replace( "$OPTIONS", catalogTypeAttribute.getAttributeOptions().toString() );
+ }
+
+ appendCode += " />";
+
+
+ disabled = "";
+
+ if ( catalogTypeId != catalogType.getId() )
+ {
+ disabled = "disabled=\"\"";
+ }
+
+ // -----------------------------------------------------------
+ //
+ // -----------------------------------------------------------
+
+ appendCode = appendCode.replace( "$CATALOGTYPEATTRIBUTEID", String.valueOf( catalogTypeAttributeId ) );
+ appendCode = appendCode.replace( "$CATALOGTYPEID", String.valueOf( catalogTypeId ) );
+ appendCode = appendCode.replace( "$CATALOGTYPENAME", catalogTypeName );
+ appendCode = appendCode.replace( "$CATALOGTYPEATTRIBUTENAME", catalogTypeAttribute.getName() );
+ appendCode = appendCode.replace( "$CATALOGTYPEATTRIBUTEVALUETYPE", catalogTypeAttributeType );
+ appendCode = appendCode.replace( "$DISABLED", disabled );
+ appendCode = appendCode.replace( "$MANDATORY", mandatory );
+ appendCode = appendCode.replace( "$SAVEMODE", "false" );
+ appendCode = appendCode.replaceAll( "\\$", "\\\\\\$" );
+
+ System.out.println( "---appendCode---" + appendCode );
+
+ CatalogTypeAttributeMatcher.appendReplacement( sb, appendCode );
+ }
+ }
+
+ CatalogTypeAttributeMatcher.appendTail( sb );
+
+ return sb.toString();
+ }
+
+
+ private String populateCustomDataEntryForDate( String dataEntryFormCode, Collection<CatalogDataValue> dataValues,
+ String disabled, I18n i18n, CatalogType catalogType, Map<Integer, Collection<CatalogDataValue>> mapDataValue )
+ {
+ // ---------------------------------------------------------------------
+ // Inline Javascript to add to HTML before outputting
+ // ---------------------------------------------------------------------
+
+ final String jsCodeForDate = " name=\"entryfield\" $DISABLED data=\"{mandatory:$MANDATORY, catalogTypeAttributeName:'$CATALOGTYPEATTRIBUTENAME'}\" onchange=\"saveVal( $CATALOGTYPEATTRIBUTEID )\" style=\" text-align:center;\" ";
+
+ // ---------------------------------------------------------------------
+ // Metadata code to add to HTML before outputting
+ // ---------------------------------------------------------------------
+
+ final String jQueryCalendar = "<script> " + "datePicker(\"$CATALOGTYPEID-$CATALOGTYPEATTRIBUTEID-val\", false)"
+ + ";</script>";
+
+ //System.out.println( "jQueryCalendar" + jQueryCalendar + "--- $CATALOGTYPEID----" + catalogType.getId());
+
+ StringBuffer sb = new StringBuffer();
+
+
+ // ---------------------------------------------------------------------
+ // Pattern to match CatalogTypeAttributes in the HTML code
+ // ---------------------------------------------------------------------
+
+ Pattern catalogTypeAttributePattern = Pattern.compile( "(<input.*?)[/]?/>" );
+
+ Matcher CatalogTypeAttributeMatcher = catalogTypeAttributePattern.matcher( dataEntryFormCode );
+
+ // ---------------------------------------------------------------------
+ // Pattern to extract catalogTypeAttribute ID from catalogTypeAttribute field
+ // ---------------------------------------------------------------------
+
+ // ---------------------------------------------------------------------
+ // Iterate through all matching catalogTypeAttribute fields
+ // ---------------------------------------------------------------------
+
+ Map<Integer, CatalogTypeAttribute> catalogTypeAttributeMap = getCatalogTypeAttributeMap( catalogType );
+
+
+
+ while ( CatalogTypeAttributeMatcher.find() )
+ {
+ // -----------------------------------------------------------------
+ // Get HTML input field code
+ // -----------------------------------------------------------------
+
+ String mandatory = "null";
+
+
+
+ String catalogTypeAttributeCode = CatalogTypeAttributeMatcher.group( 1 );
+
+ Matcher identifierMatcher = IDENTIFIER_PATTERN_FIELD.matcher( catalogTypeAttributeCode );
+
+ if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
+ {
+ // -------------------------------------------------------------
+ // Get data element ID of data element
+ // -------------------------------------------------------------
+
+ int catalogTypeId = Integer.parseInt( identifierMatcher.group( 1 ) );
+
+ int catalogTypeAttributeId = Integer.parseInt( identifierMatcher.group( 2 ) );
+
+ CatalogTypeAttribute catalogTypeAttribute = null;
+
+ String catalogTypeName = catalogType.getName();
+
+
+ if ( catalogTypeId != catalogType.getId() )
+ {
+ catalogTypeAttribute = catalogTypeAttributeService.getCatalogTypeAttribute( catalogTypeAttributeId );
+ }
+ else
+ {
+
+
+ catalogTypeAttribute = catalogTypeAttributeMap.get( catalogTypeAttributeId );
+
+ if ( catalogTypeAttribute == null )
+ {
+ return i18n.getString( "some_catalogType_attribute_not_exist" );
+ }
+
+ mandatory = BooleanUtils.toStringTrueFalse( catalogTypeAttribute.isMandatory() );
+
+ }
+
+ if ( catalogTypeAttribute == null )
+ {
+ continue;
+ }
+ if ( !CatalogTypeAttribute.TYPE_DATE.equalsIgnoreCase( catalogTypeAttribute.getValueType() ) )
+ {
+ continue;
+ }
+
+ // -------------------------------------------------------------
+ // Find type of catalogType attribute
+ // -------------------------------------------------------------
+
+ String catalogTypeAttributeType = catalogTypeAttribute.getValueType();
+
+
+ // -------------------------------------------------------------
+ // Find existing value of catalogType Attribute
+ // -------------------------------------------------------------
+
+ CatalogDataValue catalogDataValue = null;
+
+
+ String catalogTypeAttributeValue = EMPTY;
+
+ if ( catalogTypeId != catalogType.getId() )
+ {
+
+
+ Collection<CatalogDataValue> catalogDataValues = mapDataValue.get( catalogTypeId );
+
+ if ( catalogDataValues == null )
+ {
+
+ }
+
+ catalogDataValue = getValue( catalogDataValues, catalogTypeAttributeId );
+
+ catalogTypeAttributeValue = catalogDataValue != null ? catalogDataValue.getValue() : catalogTypeAttributeValue;
+ }
+ else
+ {
+
+ catalogDataValue = getValue( dataValues, catalogTypeAttributeId );
+
+ catalogTypeAttributeValue = catalogDataValue != null ? catalogDataValue.getValue() : catalogTypeAttributeValue;
+ }
+
+
+ // -------------------------------------------------------------
+ // Insert value of catalogTypeAttribute in output code
+ // -------------------------------------------------------------
+
+ if ( catalogTypeAttributeCode.contains( "value=\"\"" ) )
+ {
+ catalogTypeAttributeCode = catalogTypeAttributeCode.replace( "value=\"\"", "value=\"" + catalogTypeAttributeValue + "\"" );
+ }
+ else
+ {
+ catalogTypeAttributeCode += "value=\"" + catalogTypeAttributeValue + "\"";
+ }
+
+ // -------------------------------------------------------------
+ // Insert title information - catalogTypeAttribute id, name, type,
+ // -------------------------------------------------------------
+
+ if ( catalogTypeAttributeCode.contains( "title=\"\"" ) )
+ {
+ catalogTypeAttributeCode = catalogTypeAttributeCode.replace( "title=\"\"", "title=\"" + catalogTypeAttribute.getId() + "."
+ + catalogTypeAttribute.getName() + " (" + catalogTypeAttributeType + ")\" " );
+ }
+ else
+ {
+ catalogTypeAttributeCode += "title=\"" + catalogTypeAttribute.getId() + "." + catalogTypeAttribute.getName() + " ("
+ + catalogTypeAttributeType + ")\" ";
+ }
+
+ // -------------------------------------------------------------
+ // Append Javascript code and meta data (type/min/max) for
+ // persisting to output code, and insert value and type for
+ // fields
+ // -------------------------------------------------------------
+
+ String appendCode = catalogTypeAttributeCode + "/>";
+ appendCode = appendCode.replace( "name=\"entryfield\"", jsCodeForDate );
+
+
+ disabled = "";
+ if ( catalogTypeId != catalogType.getId() )
+ {
+ disabled = "disabled=\"\"";
+ }
+
+ appendCode += jQueryCalendar;
+
+ // -------------------------------------------------------------
+ //
+ // -------------------------------------------------------------
+
+ appendCode = appendCode.replace( "$CATALOGTYPEATTRIBUTEID", String.valueOf( catalogTypeAttributeId ) );
+ appendCode = appendCode.replace( "$CATALOGTYPEID", String.valueOf( catalogTypeId ) );
+ appendCode = appendCode.replace( "$CATALOGTYPENAME", catalogTypeName );
+ appendCode = appendCode.replace( "$CATALOGTYPEATTRIBUTENAME", catalogTypeAttribute.getName() );
+ appendCode = appendCode.replace( "$CATALOGTYPEATTRIBUTETYPE", catalogTypeAttributeType );
+ appendCode = appendCode.replace( "$DISABLED", disabled );
+ appendCode = appendCode.replace( "$MANDATORY", mandatory );
+ appendCode = appendCode.replace( "$SAVEMODE", "false" );
+
+ appendCode = appendCode.replaceAll( "\\$", "\\\\\\$" );
+
+
+ // System.out.println( "---appendCode---" + appendCode );
+
+ CatalogTypeAttributeMatcher.appendReplacement( sb, appendCode );
+ }
+ }
+
+ CatalogTypeAttributeMatcher.appendTail( sb );
+
+ return sb.toString();
+ }
+
+ /**
+ * Replaces i18n string in the custom form code.
+ *
+ * @param dataEntryFormCode the data entry form html.
+ * @param i18n the I18n object.
+ * @return internationalized data entry form html.
+ */
+ private String populateI18nStrings( String dataEntryFormCode, I18n i18n )
+ {
+ StringBuffer sb = new StringBuffer();
+
+ // ---------------------------------------------------------------------
+ // Pattern to match i18n strings in the HTML code
+ // ---------------------------------------------------------------------
+
+ Pattern i18nPattern = Pattern.compile( "(<i18n.*?)[/]?</i18n>", Pattern.DOTALL );
+ Matcher i18nMatcher = i18nPattern.matcher( dataEntryFormCode );
+
+ // ---------------------------------------------------------------------
+ // Iterate through all matching i18n element fields
+ // ---------------------------------------------------------------------
+
+ while ( i18nMatcher.find() )
+ {
+ String i18nCode = i18nMatcher.group( 1 );
+
+ i18nCode = i18nCode.replaceAll( "<i18n>", "" );
+
+ i18nCode = i18n.getString( i18nCode );
+
+ i18nMatcher.appendReplacement( sb, i18nCode );
+ }
+
+ i18nMatcher.appendTail( sb );
+
+ String result = sb.toString();
+
+ result.replaceAll( "</i18n>", "" );
+
+ return result;
+ }
+
+
+ /**
+ * Returns the value of the CatalogDataValue in the Collection of DataValues
+ * with the given data element identifier.
+ */
+ private CatalogDataValue getValue( Collection<CatalogDataValue> dataValues, int catalogTypeAttributeId )
+ {
+ for ( CatalogDataValue dataValue : dataValues )
+ {
+ if ( dataValue.getCatalogTypeAttribute().getId() == catalogTypeAttributeId )
+ {
+ return dataValue;
+ }
+ }
+
+ return null;
+ }
+
+
+
+ /**
+ * Returns a Map of all DataElements in the given ProgramStage where the key
+ * is the DataElement identifier and the value is the DataElement.
+ */
+ private Map<Integer, CatalogTypeAttribute> getCatalogTypeAttributeMap( CatalogType catalogType )
+ {
+ Collection<CatalogTypeAttribute> catalogTypeAttributes = catalogType.getCatalogTypeAttributes();
+
+ if ( catalogType == null )
+ {
+ return null;
+ }
+ Map<Integer, CatalogTypeAttribute> map = new HashMap<Integer, CatalogTypeAttribute>();
+
+ for ( CatalogTypeAttribute attribute : catalogTypeAttributes )
+ {
+ map.put( attribute.getId(), attribute );
+ }
+
+ return map;
+ }
+
+
+
+
+}
=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml 2012-06-13 06:35:38 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml 2012-06-14 05:58:42 +0000
@@ -182,14 +182,20 @@
<property name="periodStore" ref="org.hisp.dhis.period.PeriodStore"/>
</bean>
+ <!-- Catalog Custom data entry form -->
+
+ <bean id="org.hisp.dhis.coldchain.catalog.CatalogDataEntryService"
+ class="org.hisp.dhis.coldchain.catalog.DefaultCatalogDataEntryService">
+ <property name="catalogTypeAttributeService" ref="org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeService"/>
+ </bean>
+
<!-- CCEM Report Manager -->
<bean id="org.hisp.dhis.coldchain.reports.CCEMReportManager"
class="org.hisp.dhis.coldchain.reports.DefaultCCEMReportManager">
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
<property name="jdbcTemplate" ref="jdbcTemplate"/>
- </bean>
-
-
+ </bean>
+
<!-- DeletionHandlers -->
</beans>
=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/org/hisp/dhis/coldchain/hibernate/CatalogType.hbm.xml'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/org/hisp/dhis/coldchain/hibernate/CatalogType.hbm.xml 2012-05-30 10:46:26 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/org/hisp/dhis/coldchain/hibernate/CatalogType.hbm.xml 2012-06-14 05:58:42 +0000
@@ -32,5 +32,6 @@
<many-to-one name="dataEntryForm" class="org.hisp.dhis.dataentryform.DataEntryForm"
foreign-key="fk_catalogtype_dataentryform" />
+
</class>
</hibernate-mapping>
=== modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeDetailsAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeDetailsAction.java 2012-04-25 09:03:17 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeDetailsAction.java 2012-06-14 05:58:42 +0000
@@ -61,7 +61,7 @@
{
catalogType = catalogTypeService.getCatalogType( id );
-
+ //catalogType.getDataEntryForm().getName();
catalogTypeAttributes = catalogType.getCatalogTypeAttributes();
return SUCCESS;
=== modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ShowAddCatalogFormAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ShowAddCatalogFormAction.java 2012-05-30 10:46:26 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/ShowAddCatalogFormAction.java 2012-06-14 05:58:42 +0000
@@ -1,11 +1,16 @@
package org.hisp.dhis.coldchain.catalog.action;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
+import org.hisp.dhis.coldchain.catalog.CatalogDataEntryService;
+import org.hisp.dhis.coldchain.catalog.CatalogDataValue;
import org.hisp.dhis.coldchain.catalog.CatalogType;
import org.hisp.dhis.coldchain.catalog.CatalogTypeAttribute;
import org.hisp.dhis.coldchain.catalog.CatalogTypeService;
+import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.i18n.I18n;
import com.opensymphony.xwork2.Action;
@@ -22,6 +27,13 @@
{
this.catalogTypeService = catalogTypeService;
}
+
+ private CatalogDataEntryService catalogDataEntryService;
+
+ public void setCatalogDataEntryService( CatalogDataEntryService catalogDataEntryService )
+ {
+ this.catalogDataEntryService = catalogDataEntryService;
+ }
// -------------------------------------------------------------------------
// Input/Output
@@ -55,30 +67,71 @@
{
return catalogType;
}
-
+
+ private String customDataEntryFormCode;
+
+ public String getCustomDataEntryFormCode()
+ {
+ return customDataEntryFormCode;
+ }
+
+ private I18n i18n;
+
+ public I18n getI18n()
+ {
+ return i18n;
+ }
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
+
+
+
+
public String execute()
{
catalogType = catalogTypeService.getCatalogType( catalogTypeId );
- //catalogTypeAttributes = catalogType.getCatalogTypeAttributes();
-
- catalogTypeAttributes = new ArrayList<CatalogTypeAttribute> ( catalogType.getCatalogTypeAttributes());
- //Collections.sort( catalogTypeAttributes, new CatalogTypeAttributeComparator() );
-
- /*
- System.out.println( "Name of CatalogType is ====== :" + catalogType.getName() );
- System.out.println( "Size of catalogTypeAttributes :" + catalogTypeAttributes.size() );
- for( CatalogTypeAttribute catalogTypeAttribute : catalogTypeAttributes )
+ String disabled = "";
+ if ( catalogType != null )
{
- System.out.println( "Name :" + catalogTypeAttribute.getName() );
- System.out.println( "valueType :" + catalogTypeAttribute.getValueType() );
- System.out.println( "Is mandatory :" + catalogTypeAttribute.isMandatory() );
+ // ---------------------------------------------------------------------
+ // Get data-entry-form
+ // ---------------------------------------------------------------------
+
+ DataEntryForm dataEntryForm = catalogType.getDataEntryForm();
+
+ if ( dataEntryForm != null )
+ {
+ Collection<CatalogDataValue> catalogDataValues = new ArrayList<CatalogDataValue>();
+
+ customDataEntryFormCode = catalogDataEntryService.prepareDataEntryFormForCatalog( dataEntryForm.getHtmlCode(), catalogDataValues, disabled, i18n, catalogType );
+ }
+
+ catalogTypeAttributes = new ArrayList<CatalogTypeAttribute> ( catalogType.getCatalogTypeAttributes());
+ //Collections.sort( catalogTypeAttributes, new CatalogTypeAttributeComparator() );
+
+ /*
+ System.out.println( "Name of CatalogType is ====== :" + catalogType.getName() );
+ System.out.println( "Size of catalogTypeAttributes :" + catalogTypeAttributes.size() );
+ for( CatalogTypeAttribute catalogTypeAttribute : catalogTypeAttributes )
+ {
+ System.out.println( "Name :" + catalogTypeAttribute.getName() );
+ System.out.println( "valueType :" + catalogTypeAttribute.getValueType() );
+ System.out.println( "Is mandatory :" + catalogTypeAttribute.isMandatory() );
+ }
+ */
}
- */
+
+
return SUCCESS;
}
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/DeleteCatalogDataEntryFormAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/DeleteCatalogDataEntryFormAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/DeleteCatalogDataEntryFormAction.java 2012-06-14 05:58:42 +0000
@@ -0,0 +1,87 @@
+package org.hisp.dhis.coldchain.catalog.dataentryform.action;
+
+import org.hisp.dhis.coldchain.catalog.CatalogType;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeService;
+import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.dataentryform.DataEntryFormService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version DeleteCatalogDataEntryFormAction.java Jun 8, 2012 4:33:05 PM
+ */
+public class DeleteCatalogDataEntryFormAction implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private DataEntryFormService dataEntryFormService;
+
+ public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
+ {
+ this.dataEntryFormService = dataEntryFormService;
+ }
+
+ private CatalogTypeService catalogTypeService;
+
+ public void setCatalogTypeService( CatalogTypeService catalogTypeService )
+ {
+ this.catalogTypeService = catalogTypeService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Getters & setters
+ // -------------------------------------------------------------------------
+
+ private Integer dataEntryFormId;
+
+ public void setDataEntryFormId( Integer dataEntryFormId )
+ {
+ this.dataEntryFormId = dataEntryFormId;
+ }
+
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ private Integer catalogTypeId;
+
+ public void setCatalogTypeId( Integer catalogTypeId )
+ {
+ this.catalogTypeId = catalogTypeId;
+ }
+
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ DataEntryForm dataEntryForm = dataEntryFormService.getDataEntryForm( dataEntryFormId );
+
+ CatalogType catalogType = catalogTypeService.getCatalogType( catalogTypeId );
+
+ DataEntryForm catalogTypeDataEntryForm = catalogType.getDataEntryForm();
+
+ if ( catalogTypeDataEntryForm != null && catalogTypeDataEntryForm.equals( dataEntryForm ) )
+ {
+ catalogType.setDataEntryForm( null );
+
+ catalogTypeService.updateCatalogType( catalogType );
+ }
+
+ dataEntryFormService.deleteDataEntryForm( dataEntryForm );
+
+ return SUCCESS;
+ }
+}
+
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/SaveCatalogDataEntryFormAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/SaveCatalogDataEntryFormAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/SaveCatalogDataEntryFormAction.java 2012-06-14 05:58:42 +0000
@@ -0,0 +1,119 @@
+package org.hisp.dhis.coldchain.catalog.dataentryform.action;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.coldchain.catalog.CatalogType;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeService;
+import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.dataentryform.DataEntryFormService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version SaveCatalogDataEntryFormAction.java Jun 7, 2012 4:09:05 PM
+ */
+public class SaveCatalogDataEntryFormAction implements Action
+{
+ Log logger = LogFactory.getLog( getClass() );
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private DataEntryFormService dataEntryFormService;
+
+ public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
+ {
+ this.dataEntryFormService = dataEntryFormService;
+ }
+
+ private CatalogTypeService catalogTypeService;
+
+ public void setCatalogTypeService( CatalogTypeService catalogTypeService )
+ {
+ this.catalogTypeService = catalogTypeService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Getters & Setters
+ // -------------------------------------------------------------------------
+
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ private String designTextarea;
+
+ public void setDesignTextarea( String designTextarea )
+ {
+ this.designTextarea = designTextarea;
+ }
+
+ private Integer catalogTypeId;
+
+ public void setCatalogTypeId( Integer catalogTypeId )
+ {
+ this.catalogTypeId = catalogTypeId;
+ }
+
+
+ private Integer catalogDataEntryFormId;
+
+ public void setCatalogDataEntryFormId( Integer catalogDataEntryFormId )
+ {
+ this.catalogDataEntryFormId = catalogDataEntryFormId;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute() throws Exception
+ {
+ CatalogType catalogType = catalogTypeService.getCatalogType( catalogTypeId );
+
+ DataEntryForm catalogDataEntryForm = null;
+
+ // ---------------------------------------------------------------------
+ // Get data-entry-form
+ // ---------------------------------------------------------------------
+
+ if ( catalogDataEntryFormId == null )
+ {
+ catalogDataEntryForm = catalogType.getDataEntryForm();
+
+ }
+ else
+ {
+ catalogDataEntryForm = dataEntryFormService.getDataEntryForm( catalogDataEntryFormId );
+ }
+
+ // ---------------------------------------------------------------------
+ // Save data-entry-form
+ // ---------------------------------------------------------------------
+
+ if ( catalogDataEntryForm == null )
+ {
+ catalogDataEntryForm = new DataEntryForm( name, dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
+ dataEntryFormService.addDataEntryForm( catalogDataEntryForm );
+ }
+ else
+ {
+ catalogDataEntryForm.setName( name );
+ catalogDataEntryForm.setHtmlCode( dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
+ dataEntryFormService.updateDataEntryForm( catalogDataEntryForm );
+ }
+
+ catalogType.setDataEntryForm( catalogDataEntryForm );
+ catalogTypeService.updateCatalogType( catalogType );
+
+ return SUCCESS;
+ }
+
+}
+
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/ValidateCatalogDataEntryFormAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/ValidateCatalogDataEntryFormAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/ValidateCatalogDataEntryFormAction.java 2012-06-14 05:58:42 +0000
@@ -0,0 +1,83 @@
+package org.hisp.dhis.coldchain.catalog.dataentryform.action;
+
+import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.dataentryform.DataEntryFormService;
+import org.hisp.dhis.i18n.I18n;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version ValidateCatalogDataEntryFormAction.java Jun 7, 2012 2:42:06 PM
+ */
+public class ValidateCatalogDataEntryFormAction implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependency
+ // -------------------------------------------------------------------------
+
+ private DataEntryFormService dataEntryFormService;
+
+ public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
+ {
+ this.dataEntryFormService = dataEntryFormService;
+ }
+
+ // -------------------------------------------------------------------------
+ // I18n
+ // -------------------------------------------------------------------------
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------
+ // Getters & Setters
+ // -------------------------------------------------------------------------
+
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ private Integer catalogDataEntryFormId;
+
+ public void setCatalogDataEntryFormId( Integer catalogDataEntryFormId )
+ {
+ this.catalogDataEntryFormId = catalogDataEntryFormId;
+ }
+
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ DataEntryForm match = dataEntryFormService.getDataEntryFormByName( name );
+
+ if ( match != null && ( catalogDataEntryFormId == null || match.getId() != catalogDataEntryFormId.intValue()) )
+ {
+ message = i18n.getString( "duplicate_names" );
+
+ return ERROR;
+ }
+
+ return SUCCESS;
+ }
+}
+
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/ViewCatalogDataEntryFormAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/ViewCatalogDataEntryFormAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/ViewCatalogDataEntryFormAction.java 2012-06-14 05:58:42 +0000
@@ -0,0 +1,113 @@
+package org.hisp.dhis.coldchain.catalog.dataentryform.action;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.coldchain.catalog.CatalogDataEntryService;
+import org.hisp.dhis.coldchain.catalog.CatalogType;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeAttribute;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeService;
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.dataentryform.DataEntryForm;
+
+import com.opensymphony.xwork2.Action;
+
+public class ViewCatalogDataEntryFormAction implements Action
+{
+
+ // -------------------------------------------------------------------------
+ // Dependency
+ // -------------------------------------------------------------------------
+ private CatalogTypeService catalogTypeService;
+
+ public void setCatalogTypeService( CatalogTypeService catalogTypeService )
+ {
+ this.catalogTypeService = catalogTypeService;
+ }
+
+ private CatalogDataEntryService catalogDataEntryService;
+
+ public void setCatalogDataEntryService( CatalogDataEntryService catalogDataEntryService )
+ {
+ this.catalogDataEntryService = catalogDataEntryService;
+ }
+ // -------------------------------------------------------------------------
+ // Getters & Setters
+ // -------------------------------------------------------------------------
+
+
+
+ private Integer catalogTypeId;
+
+ public void setCatalogTypeId( Integer catalogTypeId )
+ {
+ this.catalogTypeId = catalogTypeId;
+ }
+
+ private DataEntryForm dataEntryForm;
+
+ public DataEntryForm getDataEntryForm()
+ {
+ return dataEntryForm;
+ }
+
+ private CatalogType catalogType;
+
+ public CatalogType getCatalogType()
+ {
+ return catalogType;
+ }
+
+ private String dataEntryValue;
+
+ public String getDataEntryValue()
+ {
+ return dataEntryValue;
+ }
+
+ private List<CatalogTypeAttribute> catalogTypeAttributes = new ArrayList<CatalogTypeAttribute>();
+
+ public List<CatalogTypeAttribute> getCatalogTypeAttributes()
+ {
+ return catalogTypeAttributes;
+ }
+
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+
+ public String execute()
+ throws Exception
+ {
+ catalogType = catalogTypeService.getCatalogType( catalogTypeId );
+
+
+ // ---------------------------------------------------------------------
+ // Get dataEntryForm of selected catalogtype
+ // ---------------------------------------------------------------------
+
+ dataEntryForm = catalogType.getDataEntryForm();
+
+ if ( dataEntryForm != null )
+ {
+ dataEntryValue = catalogDataEntryService.prepareDataEntryFormForEdit( dataEntryForm.getHtmlCode() );
+ }
+ else
+ {
+ dataEntryValue = "";
+ }
+
+ // ---------------------------------------------------------------------
+ // Get CatalogType Attribute
+ // ---------------------------------------------------------------------
+
+ catalogTypeAttributes = new ArrayList<CatalogTypeAttribute> ( catalogType.getCatalogTypeAttributes());
+
+ Collections.sort( catalogTypeAttributes, new IdentifiableObjectNameComparator() );
+
+ return SUCCESS;
+ }
+}
=== removed file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/ViewCatalogTypeDataEntryFormAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/ViewCatalogTypeDataEntryFormAction.java 2012-05-17 09:53:19 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/dataentryform/action/ViewCatalogTypeDataEntryFormAction.java 1970-01-01 00:00:00 +0000
@@ -1,63 +0,0 @@
-package org.hisp.dhis.coldchain.catalog.dataentryform.action;
-
-import org.hisp.dhis.coldchain.catalog.CatalogType;
-import org.hisp.dhis.coldchain.catalog.CatalogTypeService;
-import org.hisp.dhis.dataentryform.DataEntryForm;
-import org.hisp.dhis.dataentryform.DataEntryFormService;
-
-import com.opensymphony.xwork2.Action;
-
-public class ViewCatalogTypeDataEntryFormAction implements Action
-{
-
- // -------------------------------------------------------------------------
- // Dependency
- // -------------------------------------------------------------------------
- private CatalogTypeService catalogTypeService;
-
- public void setCatalogTypeService( CatalogTypeService catalogTypeService )
- {
- this.catalogTypeService = catalogTypeService;
- }
-
- private DataEntryFormService dataEntryFormService;
-
- public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
- {
- this.dataEntryFormService = dataEntryFormService;
- }
-
- // -------------------------------------------------------------------------
- // Getters & Setters
- // -------------------------------------------------------------------------
-
- private Integer catalogTypeId;
-
- public void setCatalogTypeId( Integer catalogTypeId )
- {
- this.catalogTypeId = catalogTypeId;
- }
-
- private DataEntryForm dataEntryForm;
-
- public DataEntryForm getDataEntryForm()
- {
- return dataEntryForm;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- throws Exception
- {
- CatalogType catalogType = catalogTypeService.getCatalogType( catalogTypeId );
-
- // ---------------------------------------------------------------------
- // Get dataEntryForm of selected catalogtype
- // ---------------------------------------------------------------------
-
- return SUCCESS;
- }
-}
=== modified file 'local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml 2012-06-13 06:35:38 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml 2012-06-14 05:58:42 +0000
@@ -164,6 +164,58 @@
<!-- catalog -->
+<!-- Data Entry Form -->
+ <bean
+ id="org.hisp.dhis.coldchain.catalog.dataentryform.action.ViewCatalogDataEntryFormAction"
+ class="org.hisp.dhis.coldchain.catalog.dataentryform.action.ViewCatalogDataEntryFormAction"
+ scope="prototype">
+ <!--<property name="dataEntryFormService">
+ <ref bean="org.hisp.dhis.dataentryform.DataEntryFormService" />
+ </property>-->
+ <property name="catalogTypeService">
+ <ref bean="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ </property>
+ <property name="catalogDataEntryService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogDataEntryService" />
+ </bean>
+
+ <!-- Validation -->
+ <bean
+ id="org.hisp.dhis.coldchain.catalog.dataentryform.action.ValidateCatalogDataEntryFormAction"
+ class="org.hisp.dhis.coldchain.catalog.dataentryform.action.ValidateCatalogDataEntryFormAction"
+ scope="prototype">
+ <property name="dataEntryFormService">
+ <ref bean="org.hisp.dhis.dataentryform.DataEntryFormService" />
+ </property>
+ </bean>
+
+ <!-- Save Form -->
+ <bean
+ id="org.hisp.dhis.coldchain.catalog.dataentryform.action.SaveCatalogDataEntryFormAction"
+ class="org.hisp.dhis.coldchain.catalog.dataentryform.action.SaveCatalogDataEntryFormAction"
+ scope="prototype">
+ <property name="dataEntryFormService">
+ <ref bean="org.hisp.dhis.dataentryform.DataEntryFormService" />
+ </property>
+ <property name="catalogTypeService">
+ <ref bean="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ </property>
+ </bean>
+
+ <!-- Delete Form -->
+ <bean
+ id="org.hisp.dhis.coldchain.catalog.dataentryform.action.DeleteCatalogDataEntryFormAction"
+ class="org.hisp.dhis.coldchain.catalog.dataentryform.action.DeleteCatalogDataEntryFormAction"
+ scope="prototype">
+ <property name="dataEntryFormService">
+ <ref bean="org.hisp.dhis.dataentryform.DataEntryFormService" />
+ </property>
+ <property name="catalogTypeService">
+ <ref bean="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ </property>
+ </bean>
+
+
<!-- Catalog List -->
<bean id="org.hisp.dhis.coldchain.catalog.action.CatalogListAction"
class="org.hisp.dhis.coldchain.catalog.action.CatalogListAction"
@@ -189,7 +241,9 @@
class="org.hisp.dhis.coldchain.catalog.action.ShowAddCatalogFormAction"
scope="prototype">
<property name="catalogTypeService"
- ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ <property name="catalogDataEntryService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogDataEntryService" />
</bean>
=== modified file 'local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties'
--- local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties 2012-06-13 06:35:38 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties 2012-06-14 05:58:42 +0000
@@ -118,6 +118,20 @@
upload_catalog_image = Upload catalog image
working_status = Working status
+
+
+design_data_entry_form = Design data entry form
+dataentryform_management_for_catalogType = Data entry form management for catalogtype
+dataentryform_details = Data entry form details
+design_dataentry_form = Design data entry form
+specify_catalogType_attribute = Please specify a catalogtype attribute
+catalogType_attribute_is_inserted = This catalogtype attribute is inserted into form
+delete_program_data_entry_confirm = Do you want to delete program data entry ?
+duplicate_names = Name is already in use
+delete_catalogType_data_entry_confirm = Do you want to delete catalogtype data entry form ?
+data_entry_form = Data entry form
+show_all_items = Show all items
+
ccem_reports_page = CCEM Reports
ccem_reports_list = Report List
ccem_reports_period_list = Period
=== modified file 'local/in/dhis-web-coldchain/src/main/resources/struts.xml'
--- local/in/dhis-web-coldchain/src/main/resources/struts.xml 2012-06-13 06:35:38 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/struts.xml 2012-06-14 05:58:42 +0000
@@ -159,6 +159,35 @@
<!-- catalog -->
+ <!-- Data Entry Form -->
+
+ <action name="viewCatalogDataEntryForm"
+ class="org.hisp.dhis.coldchain.catalog.dataentryform.action.ViewCatalogDataEntryFormAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-coldchain/viewCatalogDataEntryForm.vm</param>
+ <param name="javascripts">../dhis-web-commons/ckeditor/ckeditor.js,../dhis-web-commons/ckeditor/adapters/jquery.js,javascript/viewCatalogTypeDataEntryForm.js</param>
+ </action>
+
+ <!-- Validation -->
+ <action name="validateCatalogTypeDataEntryForm"
+ class="org.hisp.dhis.coldchain.catalog.dataentryform.action.ValidateCatalogDataEntryFormAction">
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="error" type="velocity-json">../dhis-web-commons/ajax/jsonResponseError.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <!-- Save Form -->
+ <action name="saveCatalogDataEntryForm" class="org.hisp.dhis.coldchain.catalog.dataentryform.action.SaveCatalogDataEntryFormAction">
+ <result name="success" type="redirect">catalogType.action</result>
+ </action>
+
+ <!-- Delete Form -->
+ <action name="delCatalogDataEntryForm" class="org.hisp.dhis.coldchain.catalog.dataentryform.action.DeleteCatalogDataEntryFormAction">
+ <result name="success" type="redirect">catalogType.action</result>
+ </action>
+
+
+
<!-- Catalog List -->
<action name="catalog" class="org.hisp.dhis.coldchain.catalog.action.CatalogListAction">
<result name="success" type="velocity">/main.vm</result>
@@ -181,6 +210,8 @@
<action name="showAddCataLogForm" class="org.hisp.dhis.coldchain.catalog.action.ShowAddCatalogFormAction">
<result name="success" type="velocity">/content.vm</result>
<param name="page">/dhis-web-coldchain/showAddCatalogForm.vm</param>
+ <!--<param name="page">/dhis-web-coldchain/catalogDataEntryForm.vm</param>-->
+ <param name="stylesheets">css/style.css</param>
<param name="requiredAuthorities">F_CATALOG_ADD</param>
</action>
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addCatalogForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addCatalogForm.vm 2012-05-30 10:46:26 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addCatalogForm.vm 2012-06-14 05:58:42 +0000
@@ -30,17 +30,17 @@
<tr><td> </td><td> </td></tr>
</table>
-<div id='addCatalogFormDiv'></div> <!-- Add Catalog Form -->
-
-
+<div id='addCatalogFormDiv'></div> <!-- Add Catalog Form -->
+<!--<div id='catalogDataEntryFormDiv'></div>-->
+#parse( "/dhis-web-commons/loader/loader.vm" )
<p>
<input type="submit" class="button" value="$i18n.getString( 'add' )"/>
<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='catalog.action'" />
</p>
</form>
-#parse( "/dhis-web-commons/loader/loader.vm" )
+
<script>
var i18n_error_connect_to_server = '$encoder.jsEscape( $i18n.getString( "error_connect_to_server" ) , "'" )';
- var i18n_add_person_successfully = '$encoder.jsEscape( $i18n.getString( "add_person_successfully" ) , "'" )';
+ var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_items" ) , "'")';
</script>
\ No newline at end of file
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogDataEntryForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogDataEntryForm.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogDataEntryForm.vm 2012-06-14 05:58:42 +0000
@@ -0,0 +1,74 @@
+<script>
+ jQuery("#entryFormContainer").ready(function(){
+ alert("uuuuuu");
+ entryFormContainerOnReady();
+
+ });
+</script>
+
+<div id='entryFormContainer'>
+
+<div id='entryForm' >
+ #if( $customDataEntryFormCode )
+ <div id="customEntryScreenContainer">
+ $customDataEntryFormCode
+
+ </div>
+</div>
+#else
+ <table>
+ <tr><th colspan="2" class="heading-column">$i18n.getString( "catalogType_details" )</th></tr>
+ <tr>
+ <td><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><input type="text" id="name" name="name" class="{validate:{required:true, rangelength:[4,160]}}"/></td>
+ </tr>
+
+ <tr>
+ <td><label>$i18n.getString( "description" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><input type="text" id="description" name="description" class="{validate:{required:true, minlength:4}}"/></td>
+ </tr>
+ <!--<tr><th colspan="2" class="heading-column">$i18n.getString( "catalogType_attribute" )</th></tr>-->
+ #foreach($attribute in $catalogTypeAttributes )
+ <tr>
+ <td class='text-column'><label>$attribute.name #if($attribute.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em> #end</label></td>
+ <td class="input-column">
+ #if( $attribute.valueType == "YES/NO" )
+ <select id="attr$attribute.id" name="attr$attribute.id" >
+ <option value="" >[$i18n.getString( "please_select" )]</option>
+ <option value="true">$i18n.getString( "yes" )</option>
+ <option value="false" >$i18n.getString( "no" )</option>
+ </select>
+ #elseif( $attribute.valueType == "DATE" )
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" class='#validate( "default" $attribute.mandatory )' />
+ <script type="text/javascript">
+ datePickerValid( 'attr$attribute.id' );
+ </script>
+ #elseif( $attribute.valueType == "COMBO" )
+ <select id="attr$attribute.id" name="attr$attribute.id" class='#validate( "default" $attribute.mandatory )'>
+ <option value="">[$i18n.getString( "please_select" )]</option>
+ #foreach ($option in $attribute.attributeOptions )
+ <option value="$option.id" >$option.name</option>
+ #end
+ </select>
+ #else
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" />
+ #end
+ </td>
+ </tr>
+
+ #end
+ </table>
+#end
+
+
+<div id='inputCriteriaDiv' class="page inputCriteria" style="display:none;width:480px;height:29px;">
+ <!--<input type="button" class='button' id="completeInBelowBtn" value="$i18n.getString('complete')" onClick="doComplete()" disabled="disabled">-->
+ <!--<input type="button" class='button' id="validationInBelowBtn" value="$i18n.getString('run_validation')" onClick="javascript: runValidation();" >-->
+</div>
+
+</div>
+
+<div id='validateProgramDiv'></div>
+<script>
+
+</script>
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogTypeList.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogTypeList.vm 2012-05-30 10:46:26 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalogTypeList.vm 2012-06-14 05:58:42 +0000
@@ -39,7 +39,7 @@
<a href="showUploadCatalogTypeImageForm.action?id=$catalogType.id" title="$i18n.getString( 'upload_image' )"><img src="images/upload.png" alt="$i18n.getString( 'upload_image' )"></a>
<a href="editCatalogTypeForm.action?id=$catalogType.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a>
<a href="javascript:removeItem( '$catalogType.id', '$encoder.jsEncode( $catalogType.name )', i18n_confirm_delete , 'removeCatalogType.action' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( "remove" )"></a>
- <a href="viewCatalogTypeDataEntryForm.action?catalogTypeId=$catalogType.id" title="$i18n.getString( "design_data_entry_form" )"><img src="../images/edit_layout.png" alt="$i18n.getString( "design_data_entry_form" )"></a>
+ <!--<a href="viewCatalogDataEntryForm.action?catalogTypeId=$catalogType.id" title="$i18n.getString( 'design_data_entry_form' )"><img src="../images/edit_layout.png" alt="$i18n.getString( 'design_data_entry_form' )"></a>-->
<a href="javascript:showCalatogTypeDetails( $catalogType.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a>
</td>
</tr>
@@ -61,6 +61,7 @@
<p><label class="bold">$i18n.getString( "name" ):</label><br/><span id="nameField"></span></p>
<p><label class="bold">$i18n.getString( "description" ):</label><br/><span id="descriptionField"></span></p>
<p><label class="bold">$i18n.getString( "no_of_catalogTypeAttributes" ):</label><br><span id="catalogTypeattributesCountField"></span></p>
+ <p><label class="bold">$i18n.getString( "data_entry_form" ):</label><br><span id="dataEntryFormNameField"></span></p>
</div>
<div id="warningArea" style="position:fixed;right:10px;top:200px;display:none">
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js 2012-05-04 09:05:30 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js 2012-06-14 05:58:42 +0000
@@ -20,17 +20,37 @@
var catalogTypeList = document.getElementById("catalogType");
var catalogTypeId = catalogTypeList.options[ catalogTypeList.selectedIndex ].value;
- hideById('addCatalogFormDiv');
- jQuery('#loaderDiv').show();
- contentDiv = 'addCatalogFormDiv';
-
+
+ setInnerHTML('addCatalogFormDiv', '');
+ showById('addCatalogFormDiv');
+
+
+ //setInnerHTML('catalogDataEntryFormDiv', '');
+ setInnerHTML('addCatalogFormDiv', '');
+ //showById('dataEntryFormDiv');
+ showById('addCatalogFormDiv');
+
+ //hideById('addCatalogFormDiv');
+ //jQuery('#loaderDiv').show();
+ //contentDiv = 'addCatalogFormDiv';
+
+
+ //jQuery(".stage-object-selected").removeClass('stage-object-selected');
+ //var tempCatalogTypeId = jQuery( '#' + catalogTypeId );
+ //tempCatalogTypeId.addClass('stage-object-selected');
+
+
+
+ showLoader();
jQuery('#addCatalogFormDiv').load('showAddCataLogForm.action',
{
catalogTypeId:catalogTypeId
}, function()
{
- showById('addCatalogFormDiv');
- jQuery('#loaderDiv').hide();
+
+ hideLoader();
+ //showById('addCatalogFormDiv');
+ //jQuery('#loaderDiv').hide();
});
hideLoader();
}
@@ -85,6 +105,134 @@
removeItem( catalogId, name, i18n_confirm_delete, 'removeCatalog.action' );
}
+
+//-----------------------------------------------------------------
+//
+//-----------------------------------------------------------------
+
+
+TOGGLE = {
+ init : function() {
+ jQuery(".togglePanel").each(function(){
+ jQuery(this).next("table:first").addClass("sectionClose");
+ jQuery(this).addClass("close");
+ jQuery(this).click(function(){
+ var table = jQuery(this).next("table:first");
+ if( table.hasClass("sectionClose")){
+ table.removeClass("sectionClose").addClass("sectionOpen");
+ jQuery(this).removeClass("close").addClass("open");
+ window.scroll(0,jQuery(this).position().top);
+ }else if( table.hasClass("sectionOpen")){
+ table.removeClass("sectionOpen").addClass("sectionClose");
+ jQuery(this).removeClass("open").addClass("close");
+ }
+ });
+ });
+ }
+ };
+
+
+
+function entryFormContainerOnReady()
+{
+ alert( "options");
+ var currentFocus = undefined;
+
+ if( jQuery("#entryFormContainer") ) {
+
+ jQuery("input[name='entryfield'],select[name='entryselect']").each(function(){
+ jQuery(this).focus(function(){
+ currentFocus = this;
+ });
+
+ jQuery(this).addClass("inputText");
+ });
+
+ TOGGLE.init();
+
+ jQuery("#entryForm :input").each(function()
+ {
+ if( jQuery(this).attr( 'options' )!= null )
+ {
+
+ autocompletedField(jQuery(this).attr('id'));
+ }
+ });
+ }
+}
+
+
+function autocompletedField( idField )
+{
+ var input = jQuery( "#" + idField )
+ var catalogTypeAttributeId = input.attr( 'catalogTypeAttributeId' );
+ var options = new Array();
+ options = input.attr('options').replace('[', '').replace(']', '').split(', ');
+ options.push(" ");
+
+ input.autocomplete({
+ delay: 0,
+ minLength: 0,
+ source: options,
+ select: function( event, ui ) {
+ input.val(ui.item.value);
+ //saveVal( catalogTypeAttributeId );
+ input.autocomplete( "close" );
+ },
+ change: function( event, ui ) {
+ if ( !ui.item ) {
+ var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
+ valid = false;
+ for (var i = 0; i < options.length; i++)
+ {
+ if (options[i].match( matcher ) ) {
+ this.selected = valid = true;
+ break;
+ }
+ }
+ if ( !valid ) {
+ // remove invalid value, as it didn't match anything
+ $( this ).val( "" );
+ input.data( "autocomplete" ).term = "";
+ return false;
+ }
+ }
+ //saveVal( catalogTypeAttributeId );
+ }
+ })
+ .addClass( "ui-widget" );
+
+ this.button = $( "<button type='button'> </button>" )
+ .attr( "tabIndex", -1 )
+ .attr( "title", i18n_show_all_items )
+ .insertAfter( input )
+ .button({
+ icons: {
+ primary: "ui-icon-triangle-1-s"
+ },
+ text: false
+ })
+ .addClass( "optionset-small-button" )
+ .click(function() {
+ // close if already visible
+ if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
+ input.autocomplete( "close" );
+ return;
+ }
+
+ // work around a bug (likely same cause as #5265)
+ $( this ).blur();
+
+ // pass empty string as value to search for, displaying all results
+ input.autocomplete( "search", "" );
+ input.focus();
+ });
+}
+
+
+
+
+
//----------------------------------------------------------------
// Update Catalog
//----------------------------------------------------------------
@@ -103,5 +251,17 @@
});
hideLoader();
}
-*/
-
+
+
+ $(document).ready(function() {
+ $('#j_username').focus();
+
+ $('#loginForm').bind('submit', function() {
+ $('#submit').attr('disabled', 'disabled');
+ $('#reset').attr('disabled', 'disabled');
+
+ sessionStorage.removeItem( 'orgUnitSelected' );
+ });
+ });
+
+*/
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalogType.js'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalogType.js 2012-04-25 09:03:17 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalogType.js 2012-06-14 05:58:42 +0000
@@ -7,7 +7,8 @@
jQuery.getJSON( 'getCatalogTypeDetails.action', { id: catalogTypeId }, function ( json ) {
setInnerHTML( 'nameField', json.catalogType.name );
setInnerHTML( 'descriptionField', json.catalogType.description );
- setInnerHTML( 'catalogTypeattributesCountField', json.catalogType.catalogTypeAttributeCount );
+ setInnerHTML( 'catalogTypeattributesCountField', json.catalogType.catalogTypeAttributeCount );
+ setInnerHTML( 'dataEntryFormNameField', json.catalogType.dataEntryForm );
showDetails();
});
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/viewCatalogTypeDataEntryForm.js'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/viewCatalogTypeDataEntryForm.js 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/viewCatalogTypeDataEntryForm.js 2012-06-14 05:58:42 +0000
@@ -0,0 +1,127 @@
+
+
+var catalogTypeAttributeSelector;
+
+
+jQuery(function(){
+ catalogTypeAttributeSelector = jQuery("#catalogTypeAttributeSelection").dialog({
+ title: i18n_catalogType_attribute,
+ height: 350,
+ width:350,
+ autoOpen: false,
+ zIndex:99999
+ });
+
+
+
+
+});
+
+
+function openCatalogTypeAttributeSelector()
+{
+ catalogTypeAttributeSelector.dialog("open");
+}
+
+// delete dataentry form
+function deleteCatalogDataEntryForm( catalogDataEntryFormId, catalogTypeId )
+{
+ if( window.confirm( i18n_delete_catalogType_data_entry_confirm ) )
+ {
+ window.location.href = 'delCatalogDataEntryForm.action?dataEntryFormId=' + catalogDataEntryFormId + "&catalogTypeId=" + catalogTypeId;
+ }
+}
+
+
+function filterCatalogTypeAttributes( filter, container, list )
+{
+ var filterLower = filter.toString().toLowerCase();
+
+ var catalogTypeAttributeList = jQuery( container + " " + list );
+
+ catalogTypeAttributeList.empty();
+
+ jQuery( container + " " + list + "Store" ).children().each( function(i, item){
+ item = jQuery( item );
+ var toMatch = item.text().toString().toLowerCase();
+ if( toMatch.indexOf(filterLower) != -1 ){
+ catalogTypeAttributeList.append( "<option value='" + item.attr('value') + "'>" + item.text() + "</option>" );
+ };
+ });
+}
+
+
+
+
+function insertCatalogTypeAttribute( source, catalogTypeId )
+{
+ var oEditor = jQuery("#designTextarea").ckeditorGet();
+ var catalogTypeAttribute = JSON.parse( jQuery( source + ' #catalogTypeAttributeIds').val() );
+
+ if( catalogTypeAttribute == null )
+ {
+ jQuery( source + " #message_").html( "<span class='bold'>" + i18n_specify_catalogType_attribute + "</span>" );
+ return;
+ } else {
+ jQuery( source + " #message_").html( "" );
+ }
+
+ var catalogTypeAttributeId = catalogTypeAttribute.id;
+ var catalogTypeAttributeName = catalogTypeAttribute.name;
+ var catalogTypeAttributevalueType = catalogTypeAttribute.valueType;
+
+ var htmlCode = "";
+ var id = catalogTypeId + "-" + catalogTypeAttributeId + "-val" ;
+
+ if ( catalogTypeAttributevalueType == "YES/NO" )
+ {
+ var titleValue = "-- " + catalogTypeAttributeId + "." + catalogTypeAttributeName + " ("+catalogTypeAttributevalueType+") --";
+ var displayName = catalogTypeAttributeName;
+ htmlCode = "<input title=\"" + titleValue + "\" name=\"entryselect\" id=\"" + id + "\" value=\"" + displayName + "\" title=\"" + displayName + "\">";
+ }
+ else if ( catalogTypeAttributevalueType == "DATE" )
+ {
+ var titleValue = "-- " + catalogTypeAttributeId + "." + catalogTypeAttributeName + " ("+catalogTypeAttributevalueType+") --";
+ var displayName = catalogTypeAttributeName;
+ htmlCode = "<input title=\"" + titleValue + " \"name=\"entryfield\" id=\"" + id + "\" value=\"" + displayName + "\" title=\"" + displayName + "\">";
+ }
+ else if ( catalogTypeAttributevalueType == "NUMBER" || catalogTypeAttributevalueType == "TEXT" )
+ {
+ var titleValue = "-- " + catalogTypeAttributeId + "." + catalogTypeAttributeName +" (" + catalogTypeAttributevalueType + ") --";
+ var displayName = catalogTypeAttributeName;
+ htmlCode += "<input title=\"" + titleValue + "\" value=\"" + displayName + "\" name=\"entryfield\" id=\"" + id + "\" />";
+ }
+
+
+ else if ( catalogTypeAttributevalueType == "COMBO" )
+ {
+ var titleValue = "-- " + catalogTypeAttributeId + "." + catalogTypeAttributeName +" (" + catalogTypeAttributevalueType + ") --";
+ var displayName = catalogTypeAttributeName;
+ htmlCode += "<input title=\"" + titleValue + "\" value=\"" + displayName + "\" name=\"entryfield\" id=\"" + id + "\" />";
+ }
+
+ if( checkExisted( id ) )
+ {
+ jQuery( source + " #message_").html( "<span class='bold'>" + i18n_catalogType_attribute_is_inserted + "</span>" );
+ return;
+ }else{
+ jQuery( source + " #message_").html("");
+ }
+
+ oEditor.insertHtml( htmlCode );
+}
+
+function checkExisted( id )
+{
+ var result = false;
+ var html = jQuery("#designTextarea").ckeditorGet().getData();
+ var input = jQuery( html ).find("select, :text");
+
+ input.each( function(i, item){
+ if( id == item.id ) result = true;
+ });
+
+ return result;
+}
+
+
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonCatalogType.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonCatalogType.vm 2012-04-25 09:03:17 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jsonCatalogType.vm 2012-06-14 05:58:42 +0000
@@ -4,6 +4,7 @@
"name": "$!encoder.jsonEncode( ${catalogType.name} )",
"description": "$!encoder.jsonEncode( ${catalogType.description} )",
"catalogTypeAttributeCount": "${catalogTypeAttributes.size()}",
+ "dataEntryForm": "$!encoder.jsonEncode( ${catalogType.dataEntryForm.name} )",
#set( $size = ${catalogTypeAttributes.size()} )
"catalogTypeAttribute": [
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/viewCatalogDataEntryForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/viewCatalogDataEntryForm.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/viewCatalogDataEntryForm.vm 2012-06-14 05:58:42 +0000
@@ -0,0 +1,165 @@
+<script type="text/javascript">
+
+ jQuery(document).ready( function()
+ {
+ validation( 'saveCatalogDataEntryForm', function( form )
+ {
+ setInnerHTML( 'designTextarea' , jQuery("#designTextarea").ckeditorGet().getData() );
+ form.submit();
+ } );
+
+ jQuery('#designTextarea').ckeditor();
+ jQuery("#designTextarea").ckeditorGet().setData('$encoder.jsEscape( $dataEntryValue, "'" )');
+
+ checkValueIsExist( "name", "validateCatalogTypeDataEntryForm.action", { catalogDataEntryFormId: '$!catalogType.dataEntryForm.id' } );
+ });
+
+ var i18n_catalogType_attribute_is_inserted = '$encoder.jsEscape( $i18n.getString( "catalogType_attribute_is_inserted" ) , "'" )';
+ var i18n_specify_catalogType_attribute = '$encoder.jsEscape( $i18n.getString( "specify_catalogType_attribute" ) , "'" )';
+ var i18n_catalogType_attribute = "$i18n.getString( 'catalogType_attribute' )";
+
+ var previousName = '';
+</script>
+
+<style type="text/css">
+#catalogTypeAttributeSelection{
+ padding: 0.5em;
+ z-index:999999;
+ font-size:10pt;
+
+}
+
+.ui-dialog-titlebar
+{
+ padding:0.1em 0.1em 0.1em 0.1em;
+}
+#ui-dialog-title-catalogTypeAttributeSelection{
+ font-size:10pt;
+ color:#FFFFFF;
+ margin: 0;
+}
+
+#catalogTypeAttributeSelection tr{
+ cursor:default;
+}
+
+#catalogTypeAttributeSelection tr.selected{
+ background-color:#2B0AAF;
+ color:#FFFFFF;
+}
+
+#dataElementList{
+ margin-top:5px;
+}
+
+#message_{
+ display:block;
+ color:red;
+}
+
+</style>
+
+
+
+
+
+
+<form id="saveCatalogDataEntryForm" name="saveCatalogDataEntryForm" action="saveCatalogDataEntryForm.action" method="post">
+<input type="hidden" name="catalogTypeId" id="catalogTypeId" value="$!catalogType.id"/>
+<input type="hidden" name="catalogDataEntryFormId" id="catalogDataEntryFormId" value="$!catalogType.dataEntryForm.id"/>
+<h3>$i18n.getString( "dataentryform_management_for_catalogType" ): $catalogType.name </h3>
+<div class="container" >
+ <table id="detailsList" width="100%">
+ <col/>
+ <tr>
+ <th>$i18n.getString( "dataentryform_details" )</th>
+ <td align="right" rowspan="2">
+ <!--#if( !$existingDataEntryForms.isEmpty() )
+ <input type="button" style="width:250px" value="$i18n.getString( 'load_existed_form' )" onclick="openloadExistedForm()"/><br>
+ #end -->
+ #if(!$catalogTypeAttributes.isEmpty())
+ <input type="button" style="width:250px" value="$i18n.getString( 'catalogType_attribute' )" onclick="openCatalogTypeAttributeSelector()"/><br>
+ #end
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <label>$i18n.getString( "name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label>
+ <input type="text" id="name" value="$!dataEntryForm.name" name="name" class="{validate:{required:true,rangelength:[4,150],alphanumericwithbasicpuncspaces:true,firstletteralphabet:false}}" style="width:20em">
+ </td>
+ </tr>
+ </table>
+ <table width="100%">
+ <tr>
+ <th>$i18n.getString( "design_dataentry_form" )</th>
+ </tr>
+ <tr>
+ <td>
+ <div>
+ <textarea id="designTextarea" name="designTextarea"></textarea>
+ </div>
+ </td>
+ </tr>
+ </table>
+</div>
+
+<table width="100%">
+ <tr>
+ <td align="right">
+ <input type="submit" name="save" value="$i18n.getString( 'save' )" style="width:100px"/>
+ <input type="button" name="cancel" value="$i18n.getString( 'cancel' )" style="width:100px" onclick="window.location='catalogType.action'">
+ #if( $!dataEntryForm )
+ <input type="button" name="delete" value="$i18n.getString( 'delete' )" style="width:100px" onclick="deleteCatalogDataEntryForm( $catalogType.dataEntryForm.id, $catalogType.id )" />
+ #end
+ </td>
+ </tr>
+</table>
+
+</form>
+
+
+<div id="catalogTypeAttributeSelection">
+ <table>
+ <tr>
+ <td>
+ <span class="bold">$i18n.getString( "catalogType_attribute" )</span><br>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input type="text" style="min-width:290px" onkeyup="filterCatalogTypeAttributes( this.value, '#catalogTypeAttributeSelection', '#catalogTypeAttributeIds')"/>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <select id="catalogTypeAttributeIds" name="catalogTypeAttributeIds" style="min-width:300px" multiple="multiple" size="10" ondblclick="insertCatalogTypeAttribute( '#catalogTypeAttributeSelection', '$catalogType.id')">
+ #foreach( $attr in $catalogTypeAttributes)
+ #set($attrJSON = '{' + '"id"' + ":" + $attr.id + "," + '"name"' + ':"' + "$attr.name" + '",' + '"valueType"' + ':"' + "$attr.valueType" + '"}' );
+ <option value='$attrJSON'>$encoder.htmlEncode( $attr.name )</option>
+ #end
+ </select>
+ <select id="catalogTypeAttributeIdsStore" multiple="multiple" style="display:none">
+ #foreach( $attr in $catalogTypeAttributes)
+ #set($attrJSON = '{' + '"id"' + ":" + $attr.id + "," + '"name"' + ':"' + "$attr.name" + '",' + '"valueType"' + ':"' + "$attr.valueType" + '"}' );
+ <option value='$attrJSON'>$encoder.htmlEncode( $attr.name )</option>
+ #end
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input type="button" value="Insert" id="insert" name="insert" onclick="insertCatalogTypeAttribute( '#catalogTypeAttributeSelection', '$catalogType.id')"/>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <span id="message_"></span>
+ </td>
+ </tr>
+ </table>
+</div>
+
+<script>
+ var i18n_delete_catalogType_data_entry_confirm = '$encoder.jsEscape( $i18n.getString( "delete_catalogType_data_entry_confirm" ) , "'" )';
+</script>
+
=== modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/util/DashBoardService.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/util/DashBoardService.java 2012-06-06 10:13:06 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/util/DashBoardService.java 2012-06-14 05:58:42 +0000
@@ -150,7 +150,7 @@
throw new RuntimeException( "Illegal DataElement id", e );
}
}
-/*
+
public String getPeriodIdForIDSPPopulation( )
{
String periodIdResult = "-1";
@@ -179,7 +179,7 @@
return periodIdResult;
}
-*/
+
public Integer getConfirmedCount( String orgUnitIdsByComma, String dataSetId, String periodId )
{
Integer confirmedCount = 0;
@@ -207,7 +207,7 @@
return confirmedCount;
}
- /*
+
public String getPeriodIdForIDSPOutBreak( )
{
String periodIdResult = "-1";
@@ -281,7 +281,7 @@
System.out.println( "PeriodId : " +periodIdResult );
return periodIdResult;
}
- */
+
public Integer getAggregatedData( String orgUnitIdsByComma, String deIdsByComma, String periodId )
{
Integer aggData = 0;