dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30781
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15647: various fixes to ProgramStage, ProgramStageSection, adds link from programStageSection => program...
------------------------------------------------------------
revno: 15647
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-06-12 11:41:31 +0200
message:
various fixes to ProgramStage, ProgramStageSection, adds link from programStageSection => programStage
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java
dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml
dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageSection.hbm.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CrudControllerAdvice.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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java 2014-05-26 11:54:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java 2014-06-12 09:41:31 +0000
@@ -37,6 +37,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.DxfNamespaces;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.dataentryform.DataEntryForm;
@@ -73,6 +74,7 @@
private Set<ProgramStageDataElement> programStageDataElements = new HashSet<ProgramStageDataElement>();
+ @Scanned
private Set<ProgramStageSection> programStageSections = new HashSet<ProgramStageSection>();
private DataEntryForm dataEntryForm;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java 2014-05-26 13:53:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java 2014-06-12 09:41:31 +0000
@@ -30,6 +30,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@@ -45,12 +46,14 @@
/**
* @author Chau Thu Tran
*/
-@JacksonXmlRootElement( localName = "programStageSection", namespace = DxfNamespaces.DXF_2_0 )
+@JacksonXmlRootElement(localName = "programStageSection", namespace = DxfNamespaces.DXF_2_0)
public class ProgramStageSection
extends BaseIdentifiableObject
{
private static final long serialVersionUID = 3141607927546197116L;
+ private ProgramStage programStage;
+
private List<ProgramStageDataElement> programStageDataElements = new ArrayList<ProgramStageDataElement>();
private Integer sortOrder;
@@ -78,17 +81,21 @@
}
// -------------------------------------------------------------------------
- // Constructors
+ // Getters and setters
// -------------------------------------------------------------------------
- public Integer getSortOrder()
+ @JsonProperty
+ @JsonSerialize( as = BaseIdentifiableObject.class )
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public ProgramStage getProgramStage()
{
- return sortOrder;
+ return programStage;
}
- public void setSortOrder( Integer sortOrder )
+ public void setProgramStage( ProgramStage programStage )
{
- this.sortOrder = sortOrder;
+ this.programStage = programStage;
}
@JsonProperty
@@ -105,6 +112,19 @@
this.programStageDataElements = programStageDataElements;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public Integer getSortOrder()
+ {
+ return sortOrder;
+ }
+
+ public void setSortOrder( Integer sortOrder )
+ {
+ this.sortOrder = sortOrder;
+ }
+
@Override
public void mergeWith( IdentifiableObject other )
{
@@ -114,6 +134,9 @@
{
ProgramStageSection programStageSection = (ProgramStageSection) other;
+ programStage = programStageSection.getProgramStage();
+ sortOrder = programStageSection.getSortOrder();
+
programStageDataElements.clear();
programStageDataElements.addAll( programStageSection.getProgramStageDataElements() );
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java 2014-06-12 09:11:27 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java 2014-06-12 09:41:31 +0000
@@ -468,7 +468,7 @@
}
sessionFactory.getCurrentSession().flush();
- ReflectionUtils.invokeSetterMethod( "programStageDataElements", object, Sets.newHashSet() );
+ ReflectionUtils.invokeSetterMethod( "programStageDataElements", object, Lists.newArrayList() );
sessionFactory.getCurrentSession().flush();
}
@@ -589,7 +589,7 @@
reattachFields( object, fields );
- log.debug( "Trying to save new object => " + ImportUtils.getDisplayName( object ) + " (" + object.getClass().getSimpleName() + ")" );
+ log.warn( "Trying to save new object => " + ImportUtils.getDisplayName( object ) + " (" + object.getClass().getSimpleName() + ")" );
objectBridge.saveObject( object );
updatePeriodTypes( object );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml 2014-05-30 14:14:52 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml 2014-06-12 09:41:31 +0000
@@ -39,7 +39,7 @@
<property name="standardInterval" />
<set name="programStageSections" order-by="sortOrder" cascade="all">
- <key column="programStageid" />
+ <key column="programstageid" />
<one-to-many class="org.hisp.dhis.program.ProgramStageSection" />
</set>
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageSection.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageSection.hbm.xml 2013-02-07 10:25:34 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageSection.hbm.xml 2014-06-12 09:41:31 +0000
@@ -15,6 +15,9 @@
<property name="name" column="name" not-null="true" unique="true" length="230" />
+ <many-to-one name="programStage" class="org.hisp.dhis.program.ProgramStage"
+ column="programstageid" foreign-key="fk_program_programstageid" />
+
<list name="programStageDataElements" table="programstagesection_dataelement">
<key column="programstagesectionid" />
<list-index column="section_sort_order" base="1" />
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CrudControllerAdvice.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CrudControllerAdvice.java 2014-06-11 19:13:57 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CrudControllerAdvice.java 2014-06-12 09:41:31 +0000
@@ -95,7 +95,7 @@
return new ResponseEntity<>( ex.getMessage(), headers, HttpStatus.CONFLICT );
}
- @ExceptionHandler( IllegalQueryException.class )
+ @ExceptionHandler( { IllegalQueryException.class, IllegalArgumentException.class } )
public ResponseEntity<String> handleError( IllegalQueryException ex )
{
HttpHeaders headers = new HttpHeaders();
@@ -103,13 +103,4 @@
return new ResponseEntity<>( ex.getMessage(), headers, HttpStatus.CONFLICT );
}
-
- @ExceptionHandler( IllegalArgumentException.class )
- public ResponseEntity<String> handleError( IllegalArgumentException ex )
- {
- HttpHeaders headers = new HttpHeaders();
- headers.add( "Content-Type", MediaType.TEXT_PLAIN_VALUE );
-
- return new ResponseEntity<>( ex.getMessage(), headers, HttpStatus.CONFLICT );
- }
}