← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21224: Program short name

 

------------------------------------------------------------
revno: 21224
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-11-27 17:04:36 +0100
message:
  Program short name
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramDataElement.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/UpdateProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramForm.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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2015-11-19 04:01:09 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2015-11-27 16:04:36 +0000
@@ -36,6 +36,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.google.common.collect.Sets;
 import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.BaseNameableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.MergeStrategy;
@@ -65,7 +66,7 @@
  */
 @JacksonXmlRootElement( localName = "program", namespace = DxfNamespaces.DXF_2_0 )
 public class Program
-    extends BaseIdentifiableObject
+    extends BaseNameableObject
     implements VersionedObject
 {
     private String description;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramDataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramDataElement.java	2015-11-26 21:26:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramDataElement.java	2015-11-27 16:04:36 +0000
@@ -82,7 +82,7 @@
     @Override
     public String getShortName()
     {
-        return program.getDisplayName() + " " + dataElement.getDisplayShortName();
+        return program.getDisplayShortName() + " " + dataElement.getDisplayShortName();
     }
     
     @JsonProperty

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java	2015-11-26 21:26:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java	2015-11-27 16:04:36 +0000
@@ -112,7 +112,7 @@
     @Override
     public String getShortName()
     {
-        return program.getDisplayName() + " " + attribute.getDisplayShortName();
+        return program.getDisplayShortName() + " " + attribute.getDisplayShortName();
     }
     
     @JsonProperty

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2015-11-27 09:40:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2015-11-27 16:04:36 +0000
@@ -717,6 +717,7 @@
         executeSql( "UPDATE optionset SET version=0 WHERE version IS NULL" );
         executeSql( "UPDATE dataset SET version=0 WHERE version IS NULL" );
         executeSql( "UPDATE program SET version=0 WHERE version IS NULL" );
+        executeSql( "update program set shortname = substring(name,0,50) where shortname is null" );
         executeSql( "update program set categorycomboid = " + defaultCategoryComboId + " where categorycomboid is null" );
         executeSql( "update programstageinstance set attributeoptioncomboid = " + defaultOptionComboId + " where attributeoptioncomboid is null" );
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2015-11-23 06:52:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2015-11-27 16:04:36 +0000
@@ -16,6 +16,8 @@
     &identifiableProperties;
 
     <property name="name" column="name" not-null="true" length="230" />
+    
+    <property name="shortName" column="shortname" unique="true" length="50" />
 
     <property name="description" type="text" />
 

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js	2015-10-23 08:32:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js	2015-11-27 16:04:36 +0000
@@ -455,6 +455,10 @@
             "required" : true,
             "rangelength" : [ 2, 230 ]
         },
+        "shortName" : {
+            "required" : true,
+            "rangelength" : [ 2, 50 ]
+        },
         "trackedEntityId" : {
             "required" : true
         },

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java	2015-11-23 06:52:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java	2015-11-27 16:04:36 +0000
@@ -101,6 +101,13 @@
     {
         this.name = name;
     }
+    
+    private String shortName;
+
+    public void setShortName( String shortName )
+    {
+        this.shortName = shortName;
+    }
 
     private String description;
 
@@ -274,6 +281,7 @@
         Program program = new Program();
 
         program.setName( StringUtils.trimToNull( name ) );
+        program.setShortName( StringUtils.trimToNull( shortName ) );
         program.setDescription( StringUtils.trimToNull( description ) );
         program.setVersion( 1 );
         program.setEnrollmentDateLabel( StringUtils.trimToNull( enrollmentDateLabel ) );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/UpdateProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/UpdateProgramAction.java	2015-11-23 06:52:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/UpdateProgramAction.java	2015-11-27 16:04:36 +0000
@@ -95,6 +95,13 @@
         this.name = name;
     }
 
+    private String shortName;
+
+    public void setShortName( String shortName )
+    {
+        this.shortName = shortName;
+    }
+
     private String description;
 
     public void setDescription( String description )
@@ -297,6 +304,7 @@
 
         Program program = programService.getProgram( id );
         program.setName( StringUtils.trimToNull( name ) );
+        program.setShortName( StringUtils.trimToNull( shortName ) );
         program.setDescription( StringUtils.trimToNull( description ) );
         program.setEnrollmentDateLabel( StringUtils.trimToNull( enrollmentDateLabel ) );
         program.setIncidentDateLabel( StringUtils.trimToNull( incidentDateLabel ) );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramForm.vm	2015-11-18 14:08:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramForm.vm	2015-11-27 16:04:36 +0000
@@ -80,6 +80,12 @@
 		</tr>	
 		
 		<tr>
+			<td style="width:200px"><label for="shortName">$i18n.getString( "short_name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+			<td><input type="text" id="shortName" name="shortName" ></td>
+			<td></td>
+		</tr>	
+		
+		<tr>
 			<td><label for="description">$i18n.getString( "description" )</label></td>
 			<td><textarea id="description" name="description"></textarea></td>
 			<td></td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramForm.vm	2015-11-18 14:08:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramForm.vm	2015-11-27 16:04:36 +0000
@@ -83,6 +83,12 @@
 		</tr>	
 		
 		<tr>
+			<td style="width:200px"><label for="shortName">$i18n.getString( "short_name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+			<td><input type="text" id="shortName" name="shortName" value="$encoder.htmlEncode( $program.shortName )" class="{validate:{required:true}}"></td>
+			<td></td>
+		</tr>	
+		
+		<tr>
 			<td><label for="description">$i18n.getString( "description" )</label></td>
 			<td><textarea id="description" name="description">$!encoder.htmlEncode( $program.description )</textarea></td>
 			<td></td>