← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1471: Added Populator class for fixing DataEntryForm.

 

------------------------------------------------------------
revno: 1471
committer: Viet <Viet@Viet-Laptop>
branch nick: trunk
timestamp: Tue 2010-02-23 20:08:20 +0530
message:
  Added Populator class for fixing DataEntryForm.
added:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormPopulator.java
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm


--
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 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormPopulator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormPopulator.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormPopulator.java	2010-02-23 14:38:20 +0000
@@ -0,0 +1,44 @@
+package org.hisp.dhis.dataentryform;
+
+import org.amplecode.quick.StatementManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.dataelement.OptionsCategoriesDefaultSortOrderPopulator;
+import org.hisp.dhis.system.startup.AbstractStartupRoutine;
+
+public class DataEntryFormPopulator extends AbstractStartupRoutine {
+	private static final Log log = LogFactory
+			.getLog(OptionsCategoriesDefaultSortOrderPopulator.class);
+	private StatementManager statementManager;
+
+	public void setStatementManager(StatementManager statementManager) {
+		this.statementManager = statementManager;
+	}
+
+
+	public void execute() throws Exception {
+		
+		log.info("Update association between DataEntryForm table  and DataEntryFormAssociation table");
+		//      For mysql
+		//executeSql("alter table dataentryform drop foreign key fk_dataentryform_datasetid;");
+		
+		// 		For postgres
+		executeSql("alter table dataentryform drop constraint fk_dataentryform_datasetid;");
+
+		executeSql("insert into dataentryformassociation  select 'dataset', datasetid, dataentryformid from dataentryform ; ");
+		executeSql("alter table dataentryform drop column datasetid;");
+		
+		log.info("Finished Update association between DataEntryForm table  and DataEntryFormAssociation table");
+
+	}
+
+	private int executeSql(String sql) {
+		try {
+			return statementManager.getHolder().getStatement().executeUpdate(sql);
+		} catch (Exception ex) {
+			log.debug(ex);
+			return -1;
+		}
+	}
+
+}

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2010-02-22 09:19:15 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2010-02-23 14:38:20 +0000
@@ -394,6 +394,12 @@
   
   <!-- Startup routine definitions -->
 	
+  <bean id="org.hisp.dhis.dataentryform.DataEntryFormPopulator"
+    class="org.hisp.dhis.dataentryform.DataEntryFormPopulator">
+  	<property name="statementManager" ref="statementManager"/>
+    <property name="runlevel" value="1"/>
+  </bean>
+	
   <bean id="org.hisp.dhis.period.PeriodTypePopulator"
     class="org.hisp.dhis.period.PeriodTypePopulator">
     <property name="periodStore"
@@ -473,6 +479,7 @@
           <ref local="org.hisp.dhis.dataelement.UuidPopulator"/>
 		  <ref local="org.hisp.dhis.organisationunit.OrganisationUnitHierarchyVerifier"/>
           <ref local="org.hisp.dhis.organisationunit.OrganisationUnitGroupSetPopulator"/>
+          <ref local="org.hisp.dhis.dataentryform.DataEntryFormPopulator"/>
         </list>
       </list>
     </property>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java	2010-02-22 09:19:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidatePatientAction.java	2010-02-23 14:38:20 +0000
@@ -217,36 +217,56 @@
         }
 
         // Check ID duplicate
-
-        HttpServletRequest request = ServletActionContext.getRequest();
-
-        Collection<PatientIdentifierType> identifiers = identifierTypeService.getAllPatientIdentifierTypes();
-
-        if ( identifiers != null && identifiers.size() > 0 )
+        
+        Patient p = new Patient();
+        if (birthDate != null) {
+			birthDate = birthDate.trim();
+
+			if (birthDate.length() != 0) {
+				p.setBirthDate(format.parseDate(birthDate));
+			} else {
+				if (age != null) {
+					p.setBirthDateFromAge(age.intValue());
+				}
+			}
+		} else {
+			if (age != null) {
+				p.setBirthDateFromAge(age.intValue());
+			}
+		}
+        
+        if( p.getIntegerValueOfAge() >= 5 )
         {
-            String value = null;
-            String idDuplicate = "";
-            for ( PatientIdentifierType iden : identifiers )
-            {
-                value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + iden.getId() );
-                if ( StringUtils.isNotBlank( value ) )
-                {
-                    PatientIdentifier identifier = patientIdentifierService.get( iden, value );
-                    if( identifier != null && ( id == null || identifier.getPatient().getId() != id  ))
-                    {
-                        idDuplicate += iden.getName()+", ";
-                    }
-                }
-            }
-            
-            if( StringUtils.isNotBlank( idDuplicate ) ) 
-            {
-                idDuplicate = StringUtils.substringBeforeLast( idDuplicate, "," );      
-                message = i18n.getString("identifier_duplicate") +": "+ idDuplicate;
-                return INPUT;
-            }
+        	 HttpServletRequest request = ServletActionContext.getRequest();
+
+             Collection<PatientIdentifierType> identifiers = identifierTypeService.getAllPatientIdentifierTypes();
+
+             if ( identifiers != null && identifiers.size() > 0 )
+             {
+                 String value = null;
+                 String idDuplicate = "";
+                 for ( PatientIdentifierType iden : identifiers )
+                 {
+                     value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + iden.getId() );
+                     if ( StringUtils.isNotBlank( value ) )
+                     {
+                         PatientIdentifier identifier = patientIdentifierService.get( iden, value );
+                         if( identifier != null && ( id == null || identifier.getPatient().getId() != id  ))
+                         {
+                             idDuplicate += iden.getName()+", ";
+                         }
+                     }
+                 }
+                 
+                 if( StringUtils.isNotBlank( idDuplicate ) ) 
+                 {
+                     idDuplicate = StringUtils.substringBeforeLast( idDuplicate, "," );      
+                     message = i18n.getString("identifier_duplicate") +": "+ idDuplicate;
+                     return INPUT;
+                 }
+             }
         }
-
+        
         // ---------------------------------------------------------------------
         // Validation success
         // ---------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2010-02-22 09:19:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2010-02-23 14:38:20 +0000
@@ -305,7 +305,7 @@
 			<result name="success" type="velocity">/main.vm</result>
 			<param name="page">/dhis-web-maintenance-patient/patient.vm</param>
 			<param name="menu">/dhis-web-maintenance-patient/menuWithTree.vm</param>
-			<param name="menuTreeHeight">321</param>
+			<param name="menuTreeHeight">285</param>
 			<param name="javascripts">
 				../dhis-web-commons/ouwt/ouwt.js,javascript/patient.js</param>
 		</action>
@@ -327,7 +327,7 @@
 			<result name="success" type="velocity">/main.vm</result>
 			<param name="page">/dhis-web-maintenance-patient/listPatient.vm</param>
 			<param name="menu">/dhis-web-maintenance-patient/menuWithTree.vm</param>
-			<param name="menuTreeHeight">321</param>
+			<param name="menuTreeHeight">285</param>
 			<param name="javascripts">
 				../dhis-web-commons/ouwt/ouwt.js,javascript/patient.js</param>
 		</action>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm	2010-02-22 09:19:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientForm.vm	2010-02-23 14:38:20 +0000
@@ -1,8 +1,6 @@
 #macro( validate $type $require )
   #if( $type == "int" )
   	{validate:{ number:true #if($require), required:true #end }}
-  #elseif( $type == "string" )
-  	{validate:{ alphanumeric:true #if($require), required:true #end }}
   #elseif( $require )
   	{validate:{required:true}}
   #end