dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #34346
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17631: use AbstractCrudController for DimensionController object/field filtering
------------------------------------------------------------
revno: 17631
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-12-01 12:43:13 +0700
message:
use AbstractCrudController for DimensionController object/field filtering
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.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/DimensionController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java 2014-12-01 05:36:11 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java 2014-12-01 05:43:13 +0000
@@ -28,6 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.google.common.base.Enums;
+import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import org.hisp.dhis.common.DimensionService;
import org.hisp.dhis.common.DimensionalObject;
@@ -37,9 +39,7 @@
import org.hisp.dhis.common.PagerUtils;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dxf2.objectfilter.ObjectFilterService;
-import org.hisp.dhis.webapi.service.ContextService;
-import org.hisp.dhis.webapi.service.LinkService;
+import org.hisp.dhis.node.config.InclusionStrategy;
import org.hisp.dhis.webapi.utils.ContextUtils;
import org.hisp.dhis.webapi.webdomain.WebMetaData;
import org.hisp.dhis.webapi.webdomain.WebOptions;
@@ -60,7 +60,7 @@
@Controller
@RequestMapping( value = DimensionController.RESOURCE_PATH )
-public class DimensionController
+public class DimensionController extends AbstractCrudController<DimensionalObject>
{
public static final String RESOURCE_PATH = "/dimensions";
@@ -74,57 +74,20 @@
@Autowired
private IdentifiableObjectManager identifiableObjectManager;
- @Autowired
- private LinkService linkService;
-
- @Autowired
- protected ObjectFilterService objectFilterService;
-
- @Autowired
- protected ContextService contextService;
-
// -------------------------------------------------------------------------
// Controller
// -------------------------------------------------------------------------
- @RequestMapping( method = RequestMethod.GET )
- public String getDimensions( @RequestParam( value = "links", defaultValue = "true", required = false ) Boolean links,
- Model model )
+ @Override
+ protected List<DimensionalObject> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
{
- List<String> filters = Lists.newArrayList( contextService.getParameterValues( "filter" ) );
-
- List<DimensionalObject> dimensions = dimensionService.getAllDimensions();
- dimensions = objectFilterService.filter( dimensions, filters );
-
- WebMetaData metaData = new WebMetaData();
- metaData.setDimensions( dimensions );
-
- model.addAttribute( "model", metaData );
-
- if ( links )
- {
- linkService.generateLinks( metaData, false );
- }
-
- return "dimensions";
+ return dimensionService.getAllDimensions();
}
- @RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getDimension( @PathVariable( "uid" ) String uid,
- @RequestParam( value = "links", defaultValue = "true", required = false ) Boolean links,
- Model model )
+ @Override
+ protected List<DimensionalObject> getEntity( String uid, WebOptions options )
{
- DimensionalObject dimension = dimensionService.getDimensionalObjectCopy( uid, true );
-
- model.addAttribute( "model", dimension );
- model.addAttribute( "viewClass", "dimensional" );
-
- if ( links )
- {
- linkService.generateLinks( dimension, true );
- }
-
- return "dimension";
+ return Lists.newArrayList( dimensionService.getDimensionalObjectCopy( uid, true ) );
}
@RequestMapping( value = "/{uid}/items", method = RequestMethod.GET )