dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35655
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18240: TEI query, fixed issue related to value type
------------------------------------------------------------
revno: 18240
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-02-12 16:16:32 +0100
message:
TEI query, fixed issue related to value type
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.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/common/QueryItem.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java 2015-02-10 18:40:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java 2015-02-12 15:16:32 +0000
@@ -32,6 +32,7 @@
import java.util.Collection;
import java.util.List;
+import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
import org.hisp.dhis.util.ObjectUtils;
/**
@@ -110,13 +111,13 @@
return filters != null && !filters.isEmpty();
}
- public static List<QueryItem> getQueryItems( Collection<? extends NameableObject> objects )
+ public static List<QueryItem> getQueryItems( Collection<TrackedEntityAttribute> attributes )
{
List<QueryItem> queryItems = new ArrayList<>();
- for ( NameableObject object : objects )
+ for ( TrackedEntityAttribute attribute : attributes )
{
- queryItems.add( new QueryItem( object, null, null ) );
+ queryItems.add( new QueryItem( attribute, attribute.getValueType(), attribute.hasOptionSet() ? attribute.getOptionSet().getUid() : null ) );
}
return queryItems;
=== 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 2015-02-10 18:09:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2015-02-12 15:16:32 +0000
@@ -52,11 +52,6 @@
public class TrackedEntityAttribute
extends BaseDimensionalObject
{
- /**
- * Determines if a de-serialized file is compatible with this class.
- */
- private static final long serialVersionUID = 3026922158464592390L;
-
public static final String TYPE_DATE = "date";
public static final String TYPE_STRING = "string";
public static final String TYPE_NUMBER = "number";
@@ -140,6 +135,23 @@
return optionSet != null;
}
+ /**
+ * Checks whether the given value is present among the options in the option
+ * set of this attribute, matching on code.
+ */
+ public Boolean isValidOptionValue( String value )
+ {
+ for ( Option option : this.getOptionSet().getOptions() )
+ {
+ if ( option.getCode().equals( value ) )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
@@ -331,19 +343,6 @@
this.confidential = confidential;
}
- public Boolean isValidOptionValue( String value )
- {
- for ( Option option : this.getOptionSet().getOptions() )
- {
- if ( option.getCode().equals( value ) )
- {
- return true;
- }
- }
-
- return false;
- }
-
@Override
public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
{
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java 2015-02-10 18:40:27 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java 2015-02-12 15:16:32 +0000
@@ -200,14 +200,12 @@
{
if ( params.hasProgram() )
{
- params.addAttributesIfNotExist( QueryItem.getQueryItems( params.getProgram()
- .getTrackedEntityAttributes() ) );
+ params.addAttributesIfNotExist( QueryItem.getQueryItems( params.getProgram().getTrackedEntityAttributes() ) );
}
else
{
Collection<TrackedEntityAttribute> filters = attributeService.getAllTrackedEntityAttributes();
- Collection<TrackedEntityAttribute> attributes = attributeService
- .getTrackedEntityAttributesDisplayInList();
+ Collection<TrackedEntityAttribute> attributes = attributeService.getTrackedEntityAttributesDisplayInList();
filters.removeAll( attributes );
params.addAttributesIfNotExist( QueryItem.getQueryItems( attributes ) );