dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #42485
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21716: minor fix, add field filtering to audit controllers
------------------------------------------------------------
revno: 21716
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2016-01-14 11:49:33 +0700
message:
minor fix, add field filtering to audit controllers
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AuditController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.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-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AuditController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AuditController.java 2016-01-11 02:39:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AuditController.java 2016-01-14 04:49:33 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.google.common.collect.Lists;
import org.hisp.dhis.common.AuditType;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.common.Pager;
@@ -39,6 +40,7 @@
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.fieldfilter.FieldFilterService;
import org.hisp.dhis.node.NodeUtils;
+import org.hisp.dhis.node.Preset;
import org.hisp.dhis.node.types.CollectionNode;
import org.hisp.dhis.node.types.RootNode;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -52,6 +54,7 @@
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueAuditService;
import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueAudit;
import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueAuditService;
+import org.hisp.dhis.webapi.service.ContextService;
import org.hisp.dhis.webapi.utils.WebMessageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -88,6 +91,9 @@
@Autowired
private FieldFilterService fieldFilterService;
+ @Autowired
+ private ContextService contextService;
+
@RequestMapping( value = "dataValue", method = RequestMethod.GET )
public @ResponseBody RootNode getAggregateDataValueAudit(
@RequestParam( required = false, defaultValue = "" ) List<String> ds,
@@ -102,6 +108,13 @@
@RequestParam( required = false, defaultValue = "1" ) int page
) throws WebMessageException
{
+ List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );
+
+ if ( fields.isEmpty() )
+ {
+ fields.addAll( Preset.ALL.getFields() );
+ }
+
List<DataElement> dataElements = new ArrayList<>();
dataElements.addAll( getDataElements( de ) );
dataElements.addAll( getDataElementsByDataSet( ds ) );
@@ -139,7 +152,7 @@
CollectionNode trackedEntityAttributeValueAudits = rootNode.addChild( new CollectionNode( "dataValueAudits", true ) );
trackedEntityAttributeValueAudits.addChildren( fieldFilterService.filter( DataValueAudit.class,
- dataValueAudits, new ArrayList<>() ).getChildren() );
+ dataValueAudits, fields ).getChildren() );
return rootNode;
}
@@ -154,6 +167,13 @@
@RequestParam( required = false, defaultValue = "1" ) int page
) throws WebMessageException
{
+ List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );
+
+ if ( fields.isEmpty() )
+ {
+ fields.addAll( Preset.ALL.getFields() );
+ }
+
List<DataElement> dataElements = getDataElements( de );
List<ProgramStageInstance> programStageInstances = getProgramStageInstances( psi );
@@ -184,7 +204,7 @@
CollectionNode trackedEntityAttributeValueAudits = rootNode.addChild( new CollectionNode( "trackedEntityDataValueAudits", true ) );
trackedEntityAttributeValueAudits.addChildren( fieldFilterService.filter( TrackedEntityDataValueAudit.class,
- dataValueAudits, new ArrayList<>() ).getChildren() );
+ dataValueAudits, fields ).getChildren() );
return rootNode;
}
@@ -199,6 +219,8 @@
@RequestParam( required = false, defaultValue = "1" ) int page
) throws WebMessageException
{
+ List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );
+
List<TrackedEntityAttribute> trackedEntityAttributes = getTrackedEntityAttributes( tea );
List<TrackedEntityInstance> trackedEntityInstances = getTrackedEntityInstances( tei );
@@ -230,7 +252,7 @@
CollectionNode trackedEntityAttributeValueAudits = rootNode.addChild( new CollectionNode( "trackedEntityAttributeValueAudits", true ) );
trackedEntityAttributeValueAudits.addChildren( fieldFilterService.filter( TrackedEntityAttributeValueAudit.class,
- attributeValueAudits, new ArrayList<>() ).getChildren() );
+ attributeValueAudits, fields ).getChildren() );
return rootNode;
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java 2016-01-13 09:18:47 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java 2016-01-14 04:49:33 +0000
@@ -152,10 +152,10 @@
private FileResourceService fileResourceService;
@Autowired
- protected FieldFilterService fieldFilterService;
+ private FieldFilterService fieldFilterService;
@Autowired
- protected ContextService contextService;
+ private ContextService contextService;
// -------------------------------------------------------------------------
// READ