dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28751
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14396: removed all /api/type/query and /api/type/search functionality, should be replaced by new filter
------------------------------------------------------------
revno: 14396
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-03-25 11:14:39 +0100
message:
removed all /api/type/query and /api/type/search functionality, should be replaced by new filter
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/dataelement/GeneratedDataElementOperandController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/UserController.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/user/UserCredentials.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java 2014-03-23 18:26:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java 2014-03-25 10:14:39 +0000
@@ -28,11 +28,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
+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.IdentifiableObjectUtils;
@@ -41,12 +42,10 @@
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.dataset.DataSet;
-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 java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
/**
* @author Nguyen Hong Duc
@@ -175,7 +174,7 @@
Set<String> all = new HashSet<String>( getAllAuthorities() );
return all.removeAll( auths );
}
-
+
/**
* Tests whether the user has the given authority. Returns true in any case
* if the user has the ALL authority.
@@ -186,12 +185,12 @@
{
return false;
}
-
+
final Set<String> auths = getAllAuthorities();
-
+
return auths.contains( UserAuthorityGroup.AUTHORITY_ALL ) || auths.contains( auth );
}
-
+
/**
* Indicates whether this user credentials is a super user, implying that the
* ALL authority is present in at least one of the user authority groups of
@@ -234,9 +233,9 @@
* of this user credentials, or this user credentials must have the ALL
* authority.
*
- * @param group the user authority group.
+ * @param group the user authority group.
* @param canGrantOwnUserAuthorityGroups indicates whether this users can grant
- * its own authoritiy groups to others.
+ * its own authoritiy groups to others.
*/
public boolean canIssue( UserAuthorityGroup group, boolean canGrantOwnUserAuthorityGroups )
{
@@ -256,7 +255,7 @@
{
return false;
}
-
+
return authorities.containsAll( group.getAuthorities() );
}
@@ -288,9 +287,9 @@
* Indicates whether this user credentials can issue all of the user authority
* groups in the given collection.
*
- * @param groups the collection of user authority groups.
+ * @param groups the collection of user authority groups.
* @param canGrantOwnUserAuthorityGroups indicates whether this users can grant
- * its own authoritiy groups to others.
+ * its own authoritiy groups to others.
*/
public boolean canIssueAll( Collection<UserAuthorityGroup> groups, boolean canGrantOwnUserAuthorityGroups )
{
@@ -453,8 +452,8 @@
}
@JsonProperty
- @JsonView( { DetailedView.class, ExportView.class } )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ @JsonView({ DetailedView.class, ExportView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getOpenId()
{
return openId;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java 2014-03-23 18:26:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java 2014-03-25 10:14:39 +0000
@@ -28,17 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.common.AuditLogUtil;
@@ -53,6 +42,17 @@
import org.hisp.dhis.system.util.FilterUtils;
import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS;
+
/**
* @author Chau Thu Tran
*/
@@ -231,7 +231,7 @@
public Collection<UserCredentials> getUsers( final Collection<Integer> identifiers, User user )
{
boolean canGrantOwnUserAuthorityGroups = (Boolean) systemSettingManager.getSystemSetting( KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS, false );
-
+
Collection<UserCredentials> userCredentials = getAllUserCredentials();
FilterUtils.filter( userCredentials, new UserCredentialsCanUpdateFilter( user, canGrantOwnUserAuthorityGroups ) );
@@ -243,7 +243,8 @@
{
return identifiers.contains( object.getId() );
}
- } );
+ }
+ );
}
public List<User> getUsersByUid( List<String> uids )
@@ -401,13 +402,13 @@
}
}
}
-
+
public void canIssueFilter( Collection<UserAuthorityGroup> userRoles )
{
User user = currentUserService.getCurrentUser();
-
+
boolean canGrantOwnUserAuthorityGroups = (Boolean) systemSettingManager.getSystemSetting( KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS, false );
-
+
FilterUtils.filter( userRoles, new UserAuthorityGroupCanIssueFilter( user, canGrantOwnUserAuthorityGroups ) );
}
@@ -539,14 +540,14 @@
{
return userCredentialsStore.getActiveUsersCount( since );
}
-
+
public void canUpdateFilter( Collection<UserCredentials> userCredentials )
{
User user = currentUserService.getCurrentUser();
-
+
boolean canGrantOwnUserAuthorityGroups = (Boolean) systemSettingManager.getSystemSetting( KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS, false );
-
- FilterUtils.filter( userCredentials, new UserCredentialsCanUpdateFilter( user, canGrantOwnUserAuthorityGroups ) );
+
+ FilterUtils.filter( userCredentials, new UserCredentialsCanUpdateFilter( user, canGrantOwnUserAuthorityGroups ) );
}
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java 2014-03-25 10:00:42 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java 2014-03-25 10:14:39 +0000
@@ -30,7 +30,6 @@
import com.google.common.collect.Maps;
import org.hisp.dhis.api.controller.exception.NotFoundException;
-import org.hisp.dhis.api.controller.exception.NotFoundForQueryException;
import org.hisp.dhis.api.utils.WebUtils;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.IdentifiableObject;
@@ -173,35 +172,6 @@
return StringUtils.uncapitalize( getEntitySimpleName() ) + "List";
}
- @RequestMapping( value = "/query/{query}", method = RequestMethod.GET )
- public String query( @PathVariable String query, @RequestParam Map<String, String> parameters, Model model, HttpServletRequest request ) throws Exception
- {
- WebOptions options = new WebOptions( parameters );
- WebMetaData metaData = new WebMetaData();
- List<T> entityList = queryForEntityList( metaData, options, query );
-
- ReflectionUtils.invokeSetterMethod( ExchangeClasses.getAllExportMap().get( getEntityClass() ), metaData, entityList );
-
- String viewClass = options.getViewClass( "basic" );
-
- if ( viewClass.equals( "basic" ) || viewClass.equals( "sharingBasic" ) )
- {
- handleLinksAndAccess( options, metaData, entityList, false );
- }
- else
- {
- handleLinksAndAccess( options, metaData, entityList, true );
- }
-
- postProcessEntities( entityList );
- postProcessEntities( entityList, options, parameters );
-
- model.addAttribute( "model", metaData );
- model.addAttribute( "viewClass", viewClass );
-
- return StringUtils.uncapitalize( getEntitySimpleName() ) + "List";
- }
-
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
public String getObject( @PathVariable( "uid" ) String uid, @RequestParam Map<String, String> parameters,
Model model, HttpServletRequest request, HttpServletResponse response ) throws Exception
@@ -233,32 +203,6 @@
return StringUtils.uncapitalize( getEntitySimpleName() );
}
- @RequestMapping( value = "/search/{query}", method = RequestMethod.GET )
- public String search( @PathVariable String query, @RequestParam Map<String, String> parameters,
- Model model, HttpServletRequest request, HttpServletResponse response ) throws Exception
- {
- WebOptions options = new WebOptions( parameters );
- T entity = searchForEntity( getEntityClass(), query );
-
- if ( entity == null )
- {
- throw new NotFoundForQueryException( query );
- }
-
- if ( options.hasLinks() )
- {
- WebUtils.generateLinks( entity );
- }
-
- postProcessEntity( entity );
- postProcessEntity( entity, options, parameters );
-
- model.addAttribute( "model", entity );
- model.addAttribute( "viewClass", "detailed" );
-
- return StringUtils.uncapitalize( getEntitySimpleName() );
- }
-
//--------------------------------------------------------------------------
// POST
//--------------------------------------------------------------------------
@@ -347,11 +291,6 @@
// Helpers
//--------------------------------------------------------------------------
- protected T searchForEntity( Class<T> clazz, String query )
- {
- return manager.search( clazz, query );
- }
-
protected List<T> getEntityList( WebMetaData metaData, WebOptions options )
{
List<T> entityList;
@@ -379,26 +318,6 @@
return entityList;
}
- protected List<T> queryForEntityList( WebMetaData metaData, WebOptions options, String query )
- {
- List<T> entityList = queryForList( getEntityClass(), query );
-
- if ( options.hasPaging() )
- {
- Pager pager = new Pager( options.getPage(), entityList.size(), options.getPageSize() );
- metaData.setPager( pager );
-
- entityList = PagerUtils.pageCollection( entityList, pager );
- }
-
- return entityList;
- }
-
- protected List<T> queryForList( Class<T> clazz, String query )
- {
- return new ArrayList<T>( manager.filter( getEntityClass(), query ) );
- }
-
protected T getEntity( String uid )
{
return manager.getNoAcl( getEntityClass(), uid ); //TODO consider ACL
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/dataelement/GeneratedDataElementOperandController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/dataelement/GeneratedDataElementOperandController.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/dataelement/GeneratedDataElementOperandController.java 2014-03-25 10:14:39 +0000
@@ -28,13 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-
import org.hisp.dhis.api.controller.AbstractCrudController;
import org.hisp.dhis.api.controller.WebMetaData;
import org.hisp.dhis.api.controller.WebOptions;
@@ -47,12 +40,11 @@
import org.hisp.dhis.dataelement.DataElementOperand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.util.StringUtils;
-import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
/**
* @author Lars Helge Overland
@@ -71,7 +63,7 @@
protected List<DataElementOperand> getEntityList( WebMetaData metaData, WebOptions options )
{
List<DataElement> dataElements = null;
-
+
if ( options.getOptions().containsKey( "dataElementGroup" ) )
{
DataElementGroup group = manager.get( DataElementGroup.class, options.getOptions().get( "dataElementGroup" ) );
@@ -87,65 +79,16 @@
{
dataElements = new ArrayList<DataElement>( manager.getAllSorted( DataElement.class ) );
}
-
+
List<DataElementOperand> entityList = new ArrayList<DataElementOperand>( categoryService.getOperands( dataElements ) );
-
+
if ( options.hasPaging() )
{
Pager pager = new Pager( options.getPage(), entityList.size(), options.getPageSize() );
metaData.setPager( pager );
- entityList = PagerUtils.pageCollection( entityList, pager );
+ entityList = PagerUtils.pageCollection( entityList, pager );
}
return entityList;
}
-
- @Override
- @RequestMapping( value = "/query/{query}", method = RequestMethod.GET )
- public String query( @PathVariable String query, @RequestParam Map<String, String> parameters, Model model, HttpServletRequest request ) throws Exception
- {
- WebOptions options = new WebOptions( parameters );
- WebMetaData metaData = new WebMetaData();
-
- List<DataElementOperand> allOperands = new ArrayList<DataElementOperand>( categoryService.getOperands( manager.getAllSorted( DataElement.class ) ) );
- List<DataElementOperand> dataElementOperands = new ArrayList<DataElementOperand>();
-
- //TODO this will not scale well
-
- for ( DataElementOperand operand : allOperands )
- {
- if ( operand.getDisplayName().toLowerCase().contains( query.toLowerCase() ) )
- {
- dataElementOperands.add( operand );
- }
- }
-
- if ( options.hasPaging() )
- {
- Pager pager = new Pager( options.getPage(), dataElementOperands.size(), options.getPageSize() );
- metaData.setPager( pager );
- dataElementOperands = PagerUtils.pageCollection( dataElementOperands, pager );
- }
-
- metaData.setDataElementOperands( dataElementOperands );
-
- String viewClass = options.getViewClass( "basic" );
-
- if ( viewClass.equals( "basic" ) || viewClass.equals( "sharingBasic" ) )
- {
- handleLinksAndAccess( options, metaData, dataElementOperands, false );
- }
- else
- {
- handleLinksAndAccess( options, metaData, dataElementOperands, true );
- }
-
- postProcessEntities( dataElementOperands );
- postProcessEntities( dataElementOperands, options, parameters );
-
- model.addAttribute( "model", metaData );
- model.addAttribute( "viewClass", viewClass );
-
- return StringUtils.uncapitalize( getEntitySimpleName() ) + "List";
- }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/UserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/UserController.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/UserController.java 2014-03-25 10:14:39 +0000
@@ -110,20 +110,4 @@
{
return userService.getUser( uid );
}
-
- //--------------------------------------------------------------------------
- // Overrides
- //--------------------------------------------------------------------------
-
- @Override
- public User searchForEntity( Class<User> clazz, String query )
- {
- return userService.searchForUser( query );
- }
-
- @Override
- public List<User> queryForList( Class<User> clazz, String query )
- {
- return userService.queryForUsers( query );
- }
}