dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28529
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14248: support creation of new TrackedEntityAttribute/TrackedEntityAttributeGroup through web-api
------------------------------------------------------------
revno: 14248
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-03-17 14:15:21 +0100
message:
support creation of new TrackedEntityAttribute/TrackedEntityAttributeGroup through web-api
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroup.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java
dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionServiceTest.java
dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStoreTest.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramInstanceServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramStageInstanceServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStoreTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminderServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStoreTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueStoreTest.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeGroupController.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.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/trackedentity/TrackedEntityAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2014-03-16 23:07:04 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2014-03-17 13:15:21 +0000
@@ -28,23 +28,22 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.hisp.dhis.common.BaseIdentifiableObject;
-import org.hisp.dhis.common.DxfNamespaces;
-import org.hisp.dhis.common.view.DetailedView;
-import org.hisp.dhis.common.view.WithoutOrganisationUnitsView;
-import org.hisp.dhis.period.PeriodType;
-
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;
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.DxfNamespaces;
+import org.hisp.dhis.common.view.DetailedView;
+import org.hisp.dhis.common.view.WithoutOrganisationUnitsView;
+import org.hisp.dhis.period.PeriodType;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
/**
* @author Abyot Asalefew
@@ -143,10 +142,10 @@
// Getters and setters
// -------------------------------------------------------------------------
- @JsonProperty( "personAttributeOptions" )
+ @JsonProperty( "trackedEntityAttributeOptions" )
@JsonView( { DetailedView.class } )
- @JacksonXmlElementWrapper( localName = "personAttributeOptions", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "personAttributeOption", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlElementWrapper( localName = "trackedEntityAttributeOptions", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "trackedEntityAttributeOption", namespace = DxfNamespaces.DXF_2_0 )
public Set<TrackedEntityAttributeOption> getAttributeOptions()
{
return attributeOptions == null ? new HashSet<TrackedEntityAttributeOption>() : attributeOptions;
@@ -233,10 +232,10 @@
this.valueType = valueType;
}
- @JsonProperty( "personAttributeGroup" )
+ @JsonProperty( "trackedEntityAttributeGroup" )
@JsonView( { DetailedView.class } )
@JsonSerialize( as = BaseIdentifiableObject.class )
- @JacksonXmlProperty( localName = "personAttributeGroup", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "trackedEntityAttributeGroup", namespace = DxfNamespaces.DXF_2_0 )
public TrackedEntityAttributeGroup getAttributeGroup()
{
return attributeGroup;
@@ -404,4 +403,4 @@
return age;
}
-}
\ No newline at end of file
+}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroup.java 2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroup.java 2014-03-17 13:15:21 +0000
@@ -28,25 +28,24 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hisp.dhis.common.BaseIdentifiableObject;
-import org.hisp.dhis.common.DxfNamespaces;
-import org.hisp.dhis.common.view.DetailedView;
-import org.hisp.dhis.common.view.ExportView;
-
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;
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.DxfNamespaces;
+import org.hisp.dhis.common.view.DetailedView;
+import org.hisp.dhis.common.view.ExportView;
+
+import java.util.ArrayList;
+import java.util.List;
/**
* @author Chau Thu Tran
*/
-@JacksonXmlRootElement(localName = "trackedEntityAttributeGroup", namespace = DxfNamespaces.DXF_2_0)
+@JacksonXmlRootElement( localName = "trackedEntityAttributeGroup", namespace = DxfNamespaces.DXF_2_0 )
public class TrackedEntityAttributeGroup
extends BaseIdentifiableObject
{
@@ -86,11 +85,11 @@
this.description = description;
}
- @JsonProperty("personAttributes")
- @JsonSerialize(contentAs = BaseIdentifiableObject.class)
- @JsonView({ DetailedView.class, ExportView.class })
- @JacksonXmlElementWrapper(localName = "personAttributes", namespace = DxfNamespaces.DXF_2_0)
- @JacksonXmlProperty(localName = "personAttribute", namespace = DxfNamespaces.DXF_2_0)
+ @JsonProperty( "trackedEntityAttributes" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "trackedEntityAttributes", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "trackedEntityAttribute", namespace = DxfNamespaces.DXF_2_0 )
public List<TrackedEntityAttribute> getAttributes()
{
return attributes;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java 2014-02-14 16:13:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java 2014-03-17 13:15:21 +0000
@@ -46,7 +46,7 @@
* @return A generated unique id of the added {@link TrackedEntityAttribute}
* .
*/
- int saveTrackedEntityAttribute( TrackedEntityAttribute attribute );
+ int addTrackedEntityAttribute( TrackedEntityAttribute attribute );
/**
* Deletes a {@link TrackedEntityAttribute}.
=== modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionServiceTest.java 2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionServiceTest.java 2014-03-17 13:15:21 +0000
@@ -222,7 +222,7 @@
// ---------------------------------------------------------------------
attribute = createTrackedEntityAttribute( 'A' );
- int attributeId = attributeService.saveTrackedEntityAttribute( attribute );
+ int attributeId = attributeService.addTrackedEntityAttribute( attribute );
TrackedEntityAttributeValue attributeValue = createTrackedEntityAttributeValue( 'A', entityInstance, attribute );
Set<TrackedEntityAttributeValue> attributeValues = new HashSet<TrackedEntityAttributeValue>();
=== modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStoreTest.java'
--- dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStoreTest.java 2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStoreTest.java 2014-03-17 13:15:21 +0000
@@ -219,7 +219,7 @@
// ---------------------------------------------------------------------
attribute = createTrackedEntityAttribute( 'A' );
- int attributeId = attributeService.saveTrackedEntityAttribute( attribute );
+ int attributeId = attributeService.addTrackedEntityAttribute( attribute );
TrackedEntityAttributeValue attributeValue = createTrackedEntityAttributeValue( 'A', entityInstance, attribute );
Set<TrackedEntityAttributeValue> attributeValues = new HashSet<TrackedEntityAttributeValue>();
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java 2014-03-07 10:59:18 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java 2014-03-17 13:15:21 +0000
@@ -86,7 +86,7 @@
return attributeStore.get( id );
}
- public int saveTrackedEntityAttribute( TrackedEntityAttribute attribute )
+ public int addTrackedEntityAttribute( TrackedEntityAttribute attribute )
{
return attributeStore.save( attribute );
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramInstanceServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramInstanceServiceTest.java 2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramInstanceServiceTest.java 2014-03-17 13:15:21 +0000
@@ -565,7 +565,7 @@
{
TrackedEntityAttribute attribute = createTrackedEntityAttribute( 'A' );
attribute.setValueType( TrackedEntityAttribute.TYPE_PHONE_NUMBER );
- attributeService.saveTrackedEntityAttribute( attribute );
+ attributeService.addTrackedEntityAttribute( attribute );
TrackedEntityAttributeValue attributeValue = createTrackedEntityAttributeValue( 'A', entityInstanceA, attribute );
attributeValue.setValue( "123456789" );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramStageInstanceServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramStageInstanceServiceTest.java 2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramStageInstanceServiceTest.java 2014-03-17 13:15:21 +0000
@@ -177,7 +177,7 @@
TrackedEntityAttribute attribute = createTrackedEntityAttribute( 'A' );
attribute.setValueType( TrackedEntityAttribute.TYPE_PHONE_NUMBER );
- attributeService.saveTrackedEntityAttribute( attribute );
+ attributeService.addTrackedEntityAttribute( attribute );
TrackedEntityAttributeValue attributeValue = createTrackedEntityAttributeValue( 'A', entityInstanceA, attribute );
attributeValue.setValue( "123456789" );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupServiceTest.java 2014-03-17 13:09:26 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupServiceTest.java 2014-03-17 13:15:21 +0000
@@ -64,9 +64,9 @@
TrackedEntityAttribute attributeB = createTrackedEntityAttribute( 'B' );
TrackedEntityAttribute attributeC = createTrackedEntityAttribute( 'C' );
- attributeService.saveTrackedEntityAttribute( attributeA );
- attributeService.saveTrackedEntityAttribute( attributeB );
- attributeService.saveTrackedEntityAttribute( attributeC );
+ attributeService.addTrackedEntityAttribute( attributeA );
+ attributeService.addTrackedEntityAttribute( attributeB );
+ attributeService.addTrackedEntityAttribute( attributeC );
List<TrackedEntityAttribute> attributesA = new ArrayList<TrackedEntityAttribute>();
attributesA.add( attributeA );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionServiceTest.java 2014-02-17 15:00:27 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionServiceTest.java 2014-03-17 13:15:21 +0000
@@ -63,8 +63,8 @@
attributeA = createTrackedEntityAttribute( 'A' );
attributeB = createTrackedEntityAttribute( 'B' );
- attributeService.saveTrackedEntityAttribute( attributeA );
- attributeService.saveTrackedEntityAttribute( attributeB );
+ attributeService.addTrackedEntityAttribute( attributeA );
+ attributeService.addTrackedEntityAttribute( attributeB );
attributeOptionA = createTrackedEntityAttributeOption( 'A', attributeA );
attributeOptionB = createTrackedEntityAttributeOption( 'B', attributeA );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStoreTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStoreTest.java 2014-03-17 13:09:26 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStoreTest.java 2014-03-17 13:15:21 +0000
@@ -78,8 +78,8 @@
@Test
public void testSaveTrackedEntityAttribute()
{
- int idA = attributeService.saveTrackedEntityAttribute( attributeA );
- int idB = attributeService.saveTrackedEntityAttribute( attributeB );
+ int idA = attributeService.addTrackedEntityAttribute( attributeA );
+ int idB = attributeService.addTrackedEntityAttribute( attributeB );
assertNotNull( attributeService.getTrackedEntityAttribute( idA ) );
assertNotNull( attributeService.getTrackedEntityAttribute( idB ) );
@@ -88,8 +88,8 @@
@Test
public void testDeleteTrackedEntityAttribute()
{
- int idA = attributeService.saveTrackedEntityAttribute( attributeA );
- int idB = attributeService.saveTrackedEntityAttribute( attributeB );
+ int idA = attributeService.addTrackedEntityAttribute( attributeA );
+ int idB = attributeService.addTrackedEntityAttribute( attributeB );
assertNotNull( attributeService.getTrackedEntityAttribute( idA ) );
assertNotNull( attributeService.getTrackedEntityAttribute( idB ) );
@@ -108,7 +108,7 @@
@Test
public void testUpdateTrackedEntityAttribute()
{
- int idA = attributeService.saveTrackedEntityAttribute( attributeA );
+ int idA = attributeService.addTrackedEntityAttribute( attributeA );
assertNotNull( attributeService.getTrackedEntityAttribute( idA ) );
@@ -121,8 +121,8 @@
@Test
public void testGetTrackedEntityAttributeById()
{
- int idA = attributeService.saveTrackedEntityAttribute( attributeA );
- int idB = attributeService.saveTrackedEntityAttribute( attributeB );
+ int idA = attributeService.addTrackedEntityAttribute( attributeA );
+ int idB = attributeService.addTrackedEntityAttribute( attributeB );
assertEquals( attributeA, attributeService.getTrackedEntityAttribute( idA ) );
assertEquals( attributeB, attributeService.getTrackedEntityAttribute( idB ) );
@@ -132,7 +132,7 @@
public void testGetTrackedEntityAttributeByUid()
{
attributeA.setUid( "uid" );
- attributeService.saveTrackedEntityAttribute( attributeA );
+ attributeService.addTrackedEntityAttribute( attributeA );
assertEquals( attributeA, attributeService.getTrackedEntityAttribute( "uid" ) );
}
@@ -140,7 +140,7 @@
@Test
public void testGetTrackedEntityAttributeByName()
{
- int idA = attributeService.saveTrackedEntityAttribute( attributeA );
+ int idA = attributeService.addTrackedEntityAttribute( attributeA );
assertNotNull( attributeService.getTrackedEntityAttribute( idA ) );
assertEquals( attributeA.getName(), attributeService.getTrackedEntityAttributeByName( "AttributeA" ).getName() );
@@ -149,8 +149,8 @@
@Test
public void testGetAllTrackedEntityAttributes()
{
- attributeService.saveTrackedEntityAttribute( attributeA );
- attributeService.saveTrackedEntityAttribute( attributeB );
+ attributeService.addTrackedEntityAttribute( attributeA );
+ attributeService.addTrackedEntityAttribute( attributeB );
assertTrue( equals( attributeService.getAllTrackedEntityAttributes(), attributeA, attributeB ) );
}
@@ -158,9 +158,9 @@
@Test
public void testGetTrackedEntityAttributesByValueType()
{
- attributeService.saveTrackedEntityAttribute( attributeA );
- attributeService.saveTrackedEntityAttribute( attributeB );
- attributeService.saveTrackedEntityAttribute( attributeC );
+ attributeService.addTrackedEntityAttribute( attributeA );
+ attributeService.addTrackedEntityAttribute( attributeB );
+ attributeService.addTrackedEntityAttribute( attributeC );
Collection<TrackedEntityAttribute> attributes = attributeService
.getTrackedEntityAttributesByValueType( TrackedEntityAttribute.TYPE_STRING );
@@ -181,9 +181,9 @@
attributeB.setMandatory( true );
attributeC.setMandatory( false );
- attributeService.saveTrackedEntityAttribute( attributeA );
- attributeService.saveTrackedEntityAttribute( attributeB );
- attributeService.saveTrackedEntityAttribute( attributeC );
+ attributeService.addTrackedEntityAttribute( attributeA );
+ attributeService.addTrackedEntityAttribute( attributeB );
+ attributeService.addTrackedEntityAttribute( attributeC );
Collection<TrackedEntityAttribute> attributes = attributeService.getTrackedEntityAttributesByMandatory( true );
assertEquals( 2, attributes.size() );
@@ -198,9 +198,9 @@
attributeB.setGroupBy( false );
attributeC.setGroupBy( false );
- attributeService.saveTrackedEntityAttribute( attributeA );
- attributeService.saveTrackedEntityAttribute( attributeB );
- attributeService.saveTrackedEntityAttribute( attributeC );
+ attributeService.addTrackedEntityAttribute( attributeA );
+ attributeService.addTrackedEntityAttribute( attributeB );
+ attributeService.addTrackedEntityAttribute( attributeC );
assertEquals( attributeA, attributeService.getTrackedEntityAttributeByGroupBy() );
}
@@ -208,9 +208,9 @@
@Test
public void testGetTrackedEntityAttributesWithoutGroup()
{
- attributeService.saveTrackedEntityAttribute( attributeA );
- attributeService.saveTrackedEntityAttribute( attributeB );
- attributeService.saveTrackedEntityAttribute( attributeC );
+ attributeService.addTrackedEntityAttribute( attributeA );
+ attributeService.addTrackedEntityAttribute( attributeB );
+ attributeService.addTrackedEntityAttribute( attributeC );
attributeGroupService.addTrackedEntityAttributeGroup( attributeGroup );
@@ -226,9 +226,9 @@
attributeB.setDisplayOnVisitSchedule( true );
attributeC.setDisplayOnVisitSchedule( false );
- attributeService.saveTrackedEntityAttribute( attributeA );
- attributeService.saveTrackedEntityAttribute( attributeB );
- attributeService.saveTrackedEntityAttribute( attributeC );
+ attributeService.addTrackedEntityAttribute( attributeA );
+ attributeService.addTrackedEntityAttribute( attributeB );
+ attributeService.addTrackedEntityAttribute( attributeC );
Collection<TrackedEntityAttribute> attributes = attributeService.getTrackedEntityAttributesByDisplayOnVisitSchedule( true );
assertEquals( 2, attributes.size() );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminderServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminderServiceTest.java 2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminderServiceTest.java 2014-03-17 13:15:21 +0000
@@ -46,12 +46,6 @@
import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceService;
import org.hisp.dhis.program.ProgramStageService;
-import org.hisp.dhis.trackedentity.TrackedEntityInstance;
-import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
-import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder;
-import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminderService;
-import org.hisp.dhis.trackedentity.TrackedEntityInstanceService;
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue;
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueService;
import org.hisp.dhis.user.User;
@@ -200,7 +194,7 @@
{
TrackedEntityAttribute attribute = createTrackedEntityAttribute( 'A' );
attribute.setValueType( TrackedEntityAttribute.TYPE_PHONE_NUMBER );
- attributeService.saveTrackedEntityAttribute( attribute );
+ attributeService.addTrackedEntityAttribute( attribute );
TrackedEntityAttributeValue attributeValue = createTrackedEntityAttributeValue( 'A', entityInstance, attribute );
attributeValue.setValue( "123456789" );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceServiceTest.java 2014-03-17 12:55:35 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceServiceTest.java 2014-03-17 13:15:21 +0000
@@ -119,7 +119,7 @@
organisationUnitService.addOrganisationUnit( organisationUnitB );
entityInstanceAttribute = createTrackedEntityAttribute( 'A' );
- attributeId = attributeService.saveTrackedEntityAttribute( entityInstanceAttribute );
+ attributeId = attributeService.addTrackedEntityAttribute( entityInstanceAttribute );
entityInstanceA1 = createTrackedEntityInstance( 'A', organisationUnit );
entityInstanceA2 = createTrackedEntityInstance( 'A', organisationUnitB );
@@ -476,7 +476,7 @@
TrackedEntityAttribute phoneAttribute = createTrackedEntityAttribute( 'B' );
phoneAttribute.setValueType( TrackedEntityAttribute.TYPE_PHONE_NUMBER );
- attributeService.saveTrackedEntityAttribute( phoneAttribute );
+ attributeService.addTrackedEntityAttribute( phoneAttribute );
Set<TrackedEntityAttributeValue> attributeValues = new HashSet<TrackedEntityAttributeValue>();
TrackedEntityAttributeValue attributeValue = createTrackedEntityAttributeValue( 'A', entityInstanceA3, phoneAttribute );
@@ -511,7 +511,7 @@
TrackedEntityAttribute entityInstanceAttribute = createTrackedEntityAttribute( 'B' );
entityInstanceAttribute.setValueType( TrackedEntityAttribute.TYPE_PHONE_NUMBER );
- attributeService.saveTrackedEntityAttribute( entityInstanceAttribute );
+ attributeService.addTrackedEntityAttribute( entityInstanceAttribute );
TrackedEntityAttributeValue attributeValue = createTrackedEntityAttributeValue( 'A', entityInstanceA1,
entityInstanceAttribute );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStoreTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStoreTest.java 2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStoreTest.java 2014-03-17 13:15:21 +0000
@@ -113,10 +113,10 @@
TrackedEntityAttribute entityInstanceAttributeB = createTrackedEntityAttribute( 'B' );
entityInstanceAttributeB.setUnique( true );
- attributeService.saveTrackedEntityAttribute( entityInstanceAttributeB );
+ attributeService.addTrackedEntityAttribute( entityInstanceAttributeB );
entityInstanceAttribute = createTrackedEntityAttribute( 'A' );
- attributeId = attributeService.saveTrackedEntityAttribute( entityInstanceAttribute );
+ attributeId = attributeService.addTrackedEntityAttribute( entityInstanceAttribute );
entityInstanceA1 = createTrackedEntityInstance( 'A', organisationUnit );
entityInstanceA2 = createTrackedEntityInstance( 'A', organisationUnitB );
@@ -264,7 +264,7 @@
TrackedEntityAttribute attribute = createTrackedEntityAttribute( 'C' );
attribute.setValueType( TrackedEntityAttribute.TYPE_PHONE_NUMBER );
- attributeService.saveTrackedEntityAttribute( attribute );
+ attributeService.addTrackedEntityAttribute( attribute );
TrackedEntityAttributeValue attributeValue = createTrackedEntityAttributeValue( 'A', entityInstanceA1,
attribute );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueServiceTest.java 2014-02-15 03:50:30 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueServiceTest.java 2014-03-17 13:15:21 +0000
@@ -120,9 +120,9 @@
attributeB = createTrackedEntityAttribute( 'B' );
attributeC = createTrackedEntityAttribute( 'C' );
- attributeService.saveTrackedEntityAttribute( attributeA );
- attributeService.saveTrackedEntityAttribute( attributeB );
- attributeService.saveTrackedEntityAttribute( attributeC );
+ attributeService.addTrackedEntityAttribute( attributeA );
+ attributeService.addTrackedEntityAttribute( attributeB );
+ attributeService.addTrackedEntityAttribute( attributeC );
attributeOpionA = createTrackedEntityAttributeOption( 'A', attributeC );
attributeOpionB = createTrackedEntityAttributeOption( 'B', attributeC );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueStoreTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueStoreTest.java 2014-02-15 03:50:30 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueStoreTest.java 2014-03-17 13:15:21 +0000
@@ -114,9 +114,9 @@
attributeB = createTrackedEntityAttribute( 'B' );
attributeC = createTrackedEntityAttribute( 'C' );
- attributeService.saveTrackedEntityAttribute( attributeA );
- attributeService.saveTrackedEntityAttribute( attributeB );
- attributeService.saveTrackedEntityAttribute( attributeC );
+ attributeService.addTrackedEntityAttribute( attributeA );
+ attributeService.addTrackedEntityAttribute( attributeB );
+ attributeService.addTrackedEntityAttribute( attributeC );
attributeOpionA = createTrackedEntityAttributeOption( 'A', attributeC );
attributeOpionB = createTrackedEntityAttributeOption( 'B', attributeC );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeController.java 2014-03-17 13:09:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeController.java 2014-03-17 13:15:21 +0000
@@ -28,14 +28,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
import org.hisp.dhis.api.controller.AbstractCrudController;
import org.hisp.dhis.api.controller.WebMetaData;
import org.hisp.dhis.api.controller.WebOptions;
+import org.hisp.dhis.api.utils.ContextUtils;
import org.hisp.dhis.common.Pager;
+import org.hisp.dhis.dxf2.utils.JacksonUtils;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
@@ -51,6 +49,9 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -63,7 +64,7 @@
public static final String RESOURCE_PATH = "/trackedEntityAttributes";
@Autowired
- private TrackedEntityAttributeService attributeService;
+ private TrackedEntityAttributeService trackedEntityAttributeService;
@Autowired
private ProgramService programService;
@@ -79,7 +80,7 @@
if ( withoutPrograms )
{
entityList = new ArrayList<TrackedEntityAttribute>(
- attributeService.getTrackedEntityAttributesWithoutProgram() );
+ trackedEntityAttributeService.getTrackedEntityAttributesWithoutProgram() );
}
else if ( options.getOptions().containsKey( "program" ) )
@@ -105,7 +106,7 @@
}
else
{
- entityList = new ArrayList<TrackedEntityAttribute>( attributeService.getAllTrackedEntityAttributes() );
+ entityList = new ArrayList<TrackedEntityAttribute>( trackedEntityAttributeService.getAllTrackedEntityAttributes() );
}
return entityList;
@@ -116,16 +117,25 @@
//--------------------------------------------------------------------------
@RequestMapping( method = RequestMethod.POST, consumes = { "application/xml", "text/xml" } )
+ @ResponseStatus( HttpStatus.CREATED )
public void postXmlObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
{
- throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ TrackedEntityAttribute trackedEntityAttribute = JacksonUtils.fromXml( input, TrackedEntityAttribute.class );
+ trackedEntityAttributeService.addTrackedEntityAttribute( trackedEntityAttribute );
+
+ response.setHeader( "Location", ContextUtils.getRootPath( request ) + RESOURCE_PATH + "/" + trackedEntityAttribute.getUid() );
}
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
+ @ResponseStatus( HttpStatus.CREATED )
public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
{
- throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ TrackedEntityAttribute trackedEntityAttribute = JacksonUtils.fromJson( input, TrackedEntityAttribute.class );
+ trackedEntityAttributeService.addTrackedEntityAttribute( trackedEntityAttribute );
+
+ response.setHeader( "Location", ContextUtils.getRootPath( request ) + RESOURCE_PATH + "/" + trackedEntityAttribute.getUid() );
}
+
//--------------------------------------------------------------------------
// PUT
//--------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeGroupController.java 2014-03-17 13:09:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeGroupController.java 2014-03-17 13:15:21 +0000
@@ -29,6 +29,8 @@
*/
import org.hisp.dhis.api.controller.AbstractCrudController;
+import org.hisp.dhis.api.utils.ContextUtils;
+import org.hisp.dhis.dxf2.utils.JacksonUtils;
import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup;
import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroupService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -61,16 +63,25 @@
//--------------------------------------------------------------------------
@RequestMapping( method = RequestMethod.POST, consumes = { "application/xml", "text/xml" } )
+ @ResponseStatus( HttpStatus.CREATED )
public void postXmlObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
{
- throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ TrackedEntityAttributeGroup trackedEntityAttributeGroup = JacksonUtils.fromXml( input, TrackedEntityAttributeGroup.class );
+ trackedEntityAttributeGroupService.addTrackedEntityAttributeGroup( trackedEntityAttributeGroup );
+
+ response.setHeader( "Location", ContextUtils.getRootPath( request ) + RESOURCE_PATH + "/" + trackedEntityAttributeGroup.getUid() );
}
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
+ @ResponseStatus( HttpStatus.CREATED )
public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
{
- throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ TrackedEntityAttributeGroup trackedEntityAttributeGroup = JacksonUtils.fromJson( input, TrackedEntityAttributeGroup.class );
+ trackedEntityAttributeGroupService.addTrackedEntityAttributeGroup( trackedEntityAttributeGroup );
+
+ response.setHeader( "Location", ContextUtils.getRootPath( request ) + RESOURCE_PATH + "/" + trackedEntityAttributeGroup.getUid() );
}
+
//--------------------------------------------------------------------------
// PUT
//--------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java 2014-02-14 16:13:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java 2014-03-17 13:15:21 +0000
@@ -196,7 +196,7 @@
attribute.setProgramScope( programScope );
}
- attributeService.saveTrackedEntityAttribute( attribute );
+ attributeService.addTrackedEntityAttribute( attribute );
if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( valueType ) )
{