← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11331: made programStageInstance a idObject (but no name, code). Added new property to importSummary cal...

 

------------------------------------------------------------
revno: 11331
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-07-04 13:19:49 +0700
message:
  made programStageInstance a idObject (but no name, code). Added new property to importSummary called 'reference', this is for sending back to UID reference (not location). This is used for programStageInstance which doesn't have any unique identifiers. WIP (need to update controllers, etc)
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java	2013-04-16 02:02:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java	2013-07-04 06:19:49 +0000
@@ -26,11 +26,11 @@
  */
 package org.hisp.dhis.program;
 
+import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.patientcomment.PatientComment;
 import org.hisp.dhis.sms.outbound.OutboundSms;
 
-import java.io.Serializable;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
@@ -40,8 +40,7 @@
  * @author Abyot Asalefew
  * @version $Id$
  */
-public class ProgramStageInstance
-    implements Serializable
+public class ProgramStageInstance extends BaseIdentifiableObject
 {
     /**
      * Determines if a de-serialized file is compatible with this class.
@@ -58,8 +57,6 @@
 
     public static final int SKIPPED_STATUS = 5;
 
-    private int id;
-
     private ProgramInstance programInstance;
 
     private ProgramStage programStage;
@@ -145,22 +142,6 @@
     // -------------------------------------------------------------------------
 
     /**
-     * @return the id
-     */
-    public int getId()
-    {
-        return id;
-    }
-
-    /**
-     * @param id the id to set
-     */
-    public void setId( int id )
-    {
-        this.id = id;
-    }
-
-    /**
      * @return the programInstance
      */
     public ProgramInstance getProgramInstance()

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2013-05-30 09:08:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2013-07-04 06:19:49 +0000
@@ -26,12 +26,7 @@
  */
 package org.hisp.dhis.program;
 
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.hisp.dhis.common.GenericStore;
+import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
@@ -42,12 +37,17 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.sms.outbound.OutboundSms;
 
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author Abyot Asalefew
  * @version $Id$
  */
 public interface ProgramStageInstanceStore
-    extends GenericStore<ProgramStageInstance>
+    extends GenericIdentifiableObjectStore<ProgramStageInstance>
 {
     String ID = ProgramStageInstanceStore.class.getName();
 
@@ -67,12 +67,12 @@
 
     /**
      * Get all {@link ProgramStageInstance program stage instances} for unit.
-     * 
-     * @param unit - the unit to get instances for.
-     * @param after - optional date the instance should be on or after.
-     * @param before - optional date the instance should be on or before.
+     *
+     * @param unit      - the unit to get instances for.
+     * @param after     - optional date the instance should be on or after.
+     * @param before    - optional date the instance should be on or before.
      * @param completed - optional flag to only get completed (<code>true</code>
-     *        ) or uncompleted (<code>false</code>) instances.
+     *                  ) or uncompleted (<code>false</code>) instances.
      * @return
      */
     public List<ProgramStageInstance> get( OrganisationUnit unit, Date after, Date before, Boolean completed );

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java	2013-05-30 08:57:44 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java	2013-07-04 06:19:49 +0000
@@ -204,6 +204,8 @@
         ProgramStageInstance programStageInstance = saveEventDate( program, organisationUnit, eventDate,
             event.getCompleted(), event.getCoordinate() );
 
+        importSummary.setReference( programStageInstance.getUid() );
+
         String storedBy = event.getStoredBy();
 
         if ( storedBy == null )

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java	2013-05-17 03:29:07 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java	2013-07-04 06:19:49 +0000
@@ -49,6 +49,8 @@
 
     private String dataSetComplete;
 
+    private String reference;
+
     public ImportSummary()
     {
     }
@@ -119,4 +121,16 @@
     {
         this.dataSetComplete = dataSetComplete;
     }
+
+    @JsonProperty
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public String getReference()
+    {
+        return reference;
+    }
+
+    public void setReference( String reference )
+    {
+        this.reference = reference;
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java	2013-06-05 12:02:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java	2013-07-04 06:19:49 +0000
@@ -52,7 +52,7 @@
         "organisationunit", "orgunitgroup", "orgunitgroupset", "dataelementcategoryoption", "dataelementgroup", "sqlview",
         "dataelement", "dataelementgroupset", "dataelementcategory", "categorycombo", "categoryoptioncombo", "map", "mapview",
         "reporttable", "report", "messageconversation", "message", "userinfo", "usergroup", "userrole", "maplegend",
-        "maplegendset", "maplayer", "section", "optionset", "program", "programstage"
+        "maplegendset", "maplayer", "section", "optionset", "program", "programstage", "programstageinstance"
     };
     
     private static final Map<String, String> TABLE_ID_MAP = DimensionalObjectUtils.asMap( 

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2013-05-30 09:08:10 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2013-07-04 06:19:49 +0000
@@ -96,6 +96,7 @@
 
     public int addProgramStageInstance( ProgramStageInstance programStageInstance )
     {
+        programStageInstance.setAutoFields();
         return programStageInstanceStore.save( programStageInstance );
     }
 
@@ -126,6 +127,7 @@
 
     public void updateProgramStageInstance( ProgramStageInstance programStageInstance )
     {
+        programStageInstance.setAutoFields();
         programStageInstanceStore.update( programStageInstance );
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml	2013-05-14 13:45:36 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml	2013-07-04 06:19:49 +0000
@@ -10,6 +10,12 @@
       <generator class="native" />
     </id>
 
+    <property name="uid" column="uid" unique="true" length="11" />
+
+    <property name="created" type="timestamp"/>
+
+    <property name="lastUpdated" type="timestamp"/>
+
     <many-to-one name="programInstance" class="org.hisp.dhis.program.ProgramInstance" column="programinstanceid"
       not-null="true" foreign-key="fk_programstageinstance_programinstanceid" />