dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40378
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20465: don't require TEI for validation of TEA, it might be a new TEI which does not exist yet
------------------------------------------------------------
revno: 20465
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-10-02 16:07:28 +0700
message:
don't require TEI for validation of TEA, it might be a new TEI which does not exist yet
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.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/TrackedEntityAttributeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java 2015-09-30 08:57:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java 2015-10-02 09:07:28 +0000
@@ -189,15 +189,15 @@
/**
* Validate scope of tracked entity attribute. Will return true if attribute is non-unique.
*
- * @param trackedEntityInstance TrackedEntityInstance
* @param trackedEntityAttribute TrackedEntityAttribute
* @param value Value
+ * @param trackedEntityInstance TrackedEntityInstance - required if updating TEI
* @param organisationUnit OrganisationUnit - only required if org unit scoped
* @param program Program - only required if program scoped
* @return null if valid, a message if not
*/
- String validateScope( TrackedEntityInstance trackedEntityInstance, TrackedEntityAttribute trackedEntityAttribute,
- String value, OrganisationUnit organisationUnit, Program program );
+ String validateScope( TrackedEntityAttribute trackedEntityAttribute,
+ String value, TrackedEntityInstance trackedEntityInstance, OrganisationUnit organisationUnit, Program program );
/**
* Validate value against tracked entity attribute value type.
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java 2015-10-02 08:20:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java 2015-10-02 09:07:28 +0000
@@ -200,10 +200,9 @@
}
@Override
- public String validateScope( TrackedEntityInstance trackedEntityInstance, TrackedEntityAttribute trackedEntityAttribute,
- String value, OrganisationUnit organisationUnit, Program program )
+ public String validateScope( TrackedEntityAttribute trackedEntityAttribute,
+ String value, TrackedEntityInstance trackedEntityInstance, OrganisationUnit organisationUnit, Program program )
{
- Assert.notNull( trackedEntityInstance, "trackedEntityInstance is required." );
Assert.notNull( trackedEntityAttribute, "trackedEntityAttribute is required." );
if ( !trackedEntityAttribute.isUnique() )
@@ -248,9 +247,12 @@
Grid instances = trackedEntityInstanceService.getTrackedEntityInstancesGrid( params );
- if ( !(instances.getHeight() == 0 || instances.getHeight() == 1 && instances.getRow( 0 ).contains( trackedEntityInstance.getUid() )) )
+ if ( !(instances.getHeight() == 0) )
{
- return "Non-unique attribute value '" + value + "' for attribute " + trackedEntityAttribute.getUid();
+ if ( trackedEntityInstance == null || (instances.getHeight() == 1 && !instances.getRow( 0 ).contains( trackedEntityInstance.getUid() )) )
+ {
+ return "Non-unique attribute value '" + value + "' for attribute " + trackedEntityAttribute.getUid();
+ }
}
return null;
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2015-10-02 08:39:24 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2015-10-02 09:07:28 +0000
@@ -509,8 +509,8 @@
return importConflicts;
}
- String errorMessage = trackedEntityAttributeService.validateScope( trackedEntityInstance, trackedEntityAttribute,
- value, organisationUnit, program );
+ String errorMessage = trackedEntityAttributeService.validateScope( trackedEntityAttribute, value, trackedEntityInstance,
+ organisationUnit, program );
if ( errorMessage != null )
{
@@ -522,8 +522,8 @@
private void updateAttributeValues( Enrollment enrollment )
{
- org.hisp.dhis.trackedentity.TrackedEntityInstance trackedEntityInstance = teiService
- .getTrackedEntityInstance( enrollment.getTrackedEntityInstance() );
+ org.hisp.dhis.trackedentity.TrackedEntityInstance trackedEntityInstance = teiService.getTrackedEntityInstance(
+ enrollment.getTrackedEntityInstance() );
Map<String, String> attributeValueMap = Maps.newHashMap();
for ( Attribute attribute : enrollment.getAttributes() )
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java 2015-09-30 08:57:38 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java 2015-10-02 09:07:28 +0000
@@ -492,8 +492,8 @@
return importConflicts;
}
- String errorMessage = trackedEntityAttributeService.validateScope( trackedEntityInstance, trackedEntityAttribute,
- value, organisationUnit, null );
+ String errorMessage = trackedEntityAttributeService.validateScope( trackedEntityAttribute, value, trackedEntityInstance,
+ organisationUnit, null );
if ( errorMessage != null )
{