dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #43727
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22166: Moved dimension constraint methods from UserService to DataElementCategoryService.
------------------------------------------------------------
revno: 22166
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2016-03-07 21:57:57 +0100
message:
Moved dimension constraint methods from UserService to DataElementCategoryService.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java
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/validation/DefaultValidationRuleService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidationRunContext.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/Validator.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
--
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/dataelement/DataElementCategoryService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java 2016-03-02 17:21:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java 2016-03-07 20:57:57 +0000
@@ -30,6 +30,7 @@
import org.hisp.dhis.common.IdentifiableProperty;
import org.hisp.dhis.hierarchy.HierarchyViolationException;
+import org.hisp.dhis.user.UserCredentials;
import java.util.Collection;
import java.util.List;
@@ -252,6 +253,15 @@
*/
List<DataElementCategoryOption> getDataElementCategoryOptions( DataElementCategory category );
+ /**
+ * Returns a set of CategoryOptions that may be seen by the current
+ * user, if the current user has any Category constraint(s).
+ *
+ * @param userCredentials User credentials to check restrictions for.
+ * @return Set of CategoryOptions if constrained, else null.
+ */
+ Set<DataElementCategoryOption> getCoDimensionConstraints( UserCredentials userCredentials );
+
// -------------------------------------------------------------------------
// CategoryCombo
// -------------------------------------------------------------------------
@@ -601,6 +611,15 @@
int getCategoryOptionGroupCountByName( String name );
+ /**
+ * Returns a set of CategoryOptionGroups that may be seen by the current
+ * user, if the current user has any CategoryOptionGroupSet constraint(s).
+ *
+ * @param userCredentials User credentials to check restrictions for.
+ * @return Set of CategoryOptionGroups if constrained, else null.
+ */
+ Set<CategoryOptionGroup> getCogDimensionConstraints( UserCredentials userCredentials );
+
// -------------------------------------------------------------------------
// CategoryOptionGroupSet
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java 2016-03-07 20:57:57 +0000
@@ -31,10 +31,6 @@
import java.util.Collection;
import java.util.Date;
import java.util.List;
-import java.util.Set;
-
-import org.hisp.dhis.dataelement.CategoryOptionGroup;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.dataset.DataSet;
/**
@@ -107,24 +103,6 @@
List<User> getUsersByUid( List<String> uids );
- /**
- * Returns a set of CategoryOptionGroups that may be seen by the current
- * user, if the current user has any CategoryOptionGroupSet constraint(s).
- *
- * @param userCredentials User credentials to check restrictions for.
- * @return Set of CategoryOptionGroups if constrained, else null.
- */
- Set<CategoryOptionGroup> getCogDimensionConstraints( UserCredentials userCredentials );
-
- /**
- * Returns a set of CategoryOptions that may be seen by the current
- * user, if the current user has any Category constraint(s).
- *
- * @param userCredentials User credentials to check restrictions for.
- * @return Set of CategoryOptions if constrained, else null.
- */
- Set<DataElementCategoryOption> getCoDimensionConstraints( UserCredentials userCredentials );
-
boolean isLastSuperUser( UserCredentials userCredentials );
boolean isLastSuperRole( UserAuthorityGroup userAuthorityGroup );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java 2016-01-28 17:55:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java 2016-03-07 20:57:57 +0000
@@ -50,7 +50,6 @@
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserCredentials;
-import org.hisp.dhis.user.UserService;
import org.springframework.transaction.annotation.Transactional;
import com.google.common.base.Function;
@@ -98,13 +97,6 @@
this.currentUserService = currentUserService;
}
- private UserService userService;
-
- public void setUserService( UserService userService )
- {
- this.userService = userService;
- }
-
private SecurityService securityService;
public void setSecurityService( SecurityService securityService )
@@ -269,8 +261,8 @@
int lowestNumberOrgUnitLevel = getCurrentUsersLowestNumberOrgUnitLevel();
- boolean canSeeAllDimensions = CollectionUtils.isEmpty( userService.getCoDimensionConstraints( userCredentials ) )
- && CollectionUtils.isEmpty( userService.getCogDimensionConstraints( userCredentials ) );
+ boolean canSeeAllDimensions = CollectionUtils.isEmpty( categoryService.getCoDimensionConstraints( userCredentials ) )
+ && CollectionUtils.isEmpty( categoryService.getCogDimensionConstraints( userCredentials ) );
List<DataApprovalLevel> approvalLevels = getAllDataApprovalLevels();
List<DataApprovalLevel> userDataApprovalLevels = new ArrayList<>();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2016-03-02 17:21:16 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2016-03-07 20:57:57 +0000
@@ -37,6 +37,7 @@
import org.hisp.dhis.common.IdentifiableObjectUtils;
import org.hisp.dhis.common.IdentifiableProperty;
import org.hisp.dhis.i18n.I18nService;
+import org.hisp.dhis.user.UserCredentials;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
@@ -374,6 +375,26 @@
return categoryOptionStore.getCountLikeName( name );
}
+ @Override
+ public Set<DataElementCategoryOption> getCoDimensionConstraints( UserCredentials userCredentials )
+ {
+ Set<DataElementCategoryOption> options = null;
+
+ Set<DataElementCategory> catConstraints = userCredentials.getCatDimensionConstraints();
+
+ if ( catConstraints != null && !catConstraints.isEmpty() )
+ {
+ options = new HashSet<>();
+
+ for ( DataElementCategory category : catConstraints )
+ {
+ options.addAll( getDataElementCategoryOptions( category ) );
+ }
+ }
+
+ return options;
+ }
+
// -------------------------------------------------------------------------
// CategoryCombo
// -------------------------------------------------------------------------
@@ -921,6 +942,26 @@
return categoryOptionGroupStore.getCountLikeName( name );
}
+ @Override
+ public Set<CategoryOptionGroup> getCogDimensionConstraints( UserCredentials userCredentials )
+ {
+ Set<CategoryOptionGroup> groups = null;
+
+ Set<CategoryOptionGroupSet> cogsConstraints = userCredentials.getCogsDimensionConstraints();
+
+ if ( cogsConstraints != null && !cogsConstraints.isEmpty() )
+ {
+ groups = new HashSet<>();
+
+ for ( CategoryOptionGroupSet cogs : cogsConstraints )
+ {
+ groups.addAll( getCategoryOptionGroups( cogs ) );
+ }
+ }
+
+ return groups;
+ }
+
// -------------------------------------------------------------------------
// CategoryOptionGroupSet
// -------------------------------------------------------------------------
@@ -1007,5 +1048,5 @@
public int getCategoryOptionGroupSetCountByName( String name )
{
return categoryOptionGroupSetStore.getCountLikeName( name );
- }
+ }
}
=== 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 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java 2016-03-07 20:57:57 +0000
@@ -31,20 +31,13 @@
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.common.AuditLogUtil;
import org.hisp.dhis.commons.filter.FilterUtils;
-import org.hisp.dhis.dataelement.CategoryOptionGroup;
-import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
-import org.hisp.dhis.dataelement.DataElementCategory;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
-import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.security.PasswordManager;
@@ -104,13 +97,6 @@
this.currentUserService = currentUserService;
}
- private DataElementCategoryService categoryService;
-
- public void setCategoryService( DataElementCategoryService categoryService )
- {
- this.categoryService = categoryService;
- }
-
private SystemSettingManager systemSettingManager;
public void setSystemSettingManager( SystemSettingManager systemSettingManager )
@@ -297,46 +283,6 @@
}
@Override
- public Set<CategoryOptionGroup> getCogDimensionConstraints( UserCredentials userCredentials )
- {
- Set<CategoryOptionGroup> groups = null;
-
- Set<CategoryOptionGroupSet> cogsConstraints = userCredentials.getCogsDimensionConstraints();
-
- if ( cogsConstraints != null && !cogsConstraints.isEmpty() )
- {
- groups = new HashSet<>();
-
- for ( CategoryOptionGroupSet cogs : cogsConstraints )
- {
- groups.addAll( categoryService.getCategoryOptionGroups( cogs ) );
- }
- }
-
- return groups;
- }
-
- @Override
- public Set<DataElementCategoryOption> getCoDimensionConstraints( UserCredentials userCredentials )
- {
- Set<DataElementCategoryOption> options = null;
-
- Set<DataElementCategory> catConstraints = userCredentials.getCatDimensionConstraints();
-
- if ( catConstraints != null && !catConstraints.isEmpty() )
- {
- options = new HashSet<>();
-
- for ( DataElementCategory category : catConstraints )
- {
- options.addAll( categoryService.getDataElementCategoryOptions( category ) );
- }
- }
-
- return options;
- }
-
- @Override
public boolean isLastSuperUser( UserCredentials userCredentials )
{
if ( !userCredentials.isSuper() )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java 2016-03-07 20:57:57 +0000
@@ -56,7 +56,6 @@
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserGroup;
-import org.hisp.dhis.user.UserService;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
@@ -159,13 +158,6 @@
this.organisationUnitService = organisationUnitService;
}
- private UserService userService;
-
- public void setUserService( UserService userService )
- {
- this.userService = userService;
- }
-
private CurrentUserService currentUserService;
public void setCurrentUserService( CurrentUserService currentUserService )
@@ -194,7 +186,7 @@
Collection<ValidationRule> rules = group != null ? group.getMembers() : getAllValidationRules();
Collection<ValidationResult> results = Validator.validate( sources, periods, rules, attributeCombo, null,
- constantService, expressionService, periodService, dataValueService, dataElementCategoryService, userService, currentUserService );
+ constantService, expressionService, periodService, dataValueService, dataElementCategoryService, currentUserService );
formatPeriods( results, format );
@@ -219,7 +211,7 @@
sources.add( source );
return Validator.validate( sources, periods, rules, null, null,
- constantService, expressionService, periodService, dataValueService, dataElementCategoryService, userService, currentUserService );
+ constantService, expressionService, periodService, dataValueService, dataElementCategoryService, currentUserService );
}
@Override
@@ -241,7 +233,7 @@
sources.add( source );
return Validator.validate( sources, periods, rules, attributeCombo, null,
- constantService, expressionService, periodService, dataValueService, dataElementCategoryService, userService, currentUserService );
+ constantService, expressionService, periodService, dataValueService, dataElementCategoryService, currentUserService );
}
@Override
@@ -267,7 +259,7 @@
+ ", last run: " + (lastScheduledRun == null ? "[none]" : lastScheduledRun) );
Collection<ValidationResult> results = Validator.validate( sources, periods, rules, null, lastScheduledRun,
- constantService, expressionService, periodService, dataValueService, dataElementCategoryService, userService, currentUserService );
+ constantService, expressionService, periodService, dataValueService, dataElementCategoryService, currentUserService );
log.info( "Validation run result count: " + results.size() );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidationRunContext.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidationRunContext.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidationRunContext.java 2016-03-07 20:57:57 +0000
@@ -46,7 +46,6 @@
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.UserCredentials;
-import org.hisp.dhis.user.UserService;
import java.util.Arrays;
import java.util.Collection;
@@ -136,7 +135,6 @@
* @param periodService period service
* @param dataValueService data value service
* @param dataElementCategoryService data element category service
- * @param userService user service
* @param currentUserService current user service
* @return context object for this run
*/
@@ -145,7 +143,7 @@
Map<String, Double> constantMap, ValidationRunType runType, Date lastScheduledRun,
ExpressionService expressionService, PeriodService periodService,
DataValueService dataValueService, DataElementCategoryService dataElementCategoryService,
- UserService userService, CurrentUserService currentUserService )
+ CurrentUserService currentUserService )
{
UserCredentials currentUserCredentials = currentUserService.getCurrentUser().getUserCredentials();
@@ -162,8 +160,8 @@
context.dataValueService = dataValueService;
context.dataElementCategoryService = dataElementCategoryService;
context.attributeCombo = attributeCombo;
- context.cogDimensionConstraints = userService.getCogDimensionConstraints( currentUserCredentials );
- context.coDimensionConstraints = userService.getCoDimensionConstraints( currentUserCredentials );
+ context.cogDimensionConstraints = dataElementCategoryService.getCogDimensionConstraints( currentUserCredentials );
+ context.coDimensionConstraints = dataElementCategoryService.getCoDimensionConstraints( currentUserCredentials );
context.initialize( sources, periods, rules );
return context;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/Validator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/Validator.java 2016-01-13 12:54:38 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/Validator.java 2016-03-07 20:57:57 +0000
@@ -44,7 +44,6 @@
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.system.util.SystemUtils;
import org.hisp.dhis.user.CurrentUserService;
-import org.hisp.dhis.user.UserService;
/**
* Evaluates validation rules.
@@ -79,12 +78,12 @@
Collection<Period> periods, Collection<ValidationRule> rules, DataElementCategoryOptionCombo attributeCombo,
Date lastScheduledRun, ConstantService constantService, ExpressionService expressionService,
PeriodService periodService, DataValueService dataValueService,
- DataElementCategoryService dataElementCategoryService, UserService userService,
+ DataElementCategoryService dataElementCategoryService,
CurrentUserService currentUserService )
{
ValidationRunContext context = ValidationRunContext.getNewContext( sources, periods, attributeCombo, rules,
constantService.getConstantMap(), ValidationRunType.SCHEDULED, lastScheduledRun, expressionService,
- periodService, dataValueService, dataElementCategoryService, userService, currentUserService );
+ periodService, dataValueService, dataElementCategoryService, currentUserService );
int threadPoolSize = getThreadPoolSize( context );
ExecutorService executor = Executors.newFixedThreadPool( threadPoolSize );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2016-03-07 19:55:24 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2016-03-07 20:57:57 +0000
@@ -681,7 +681,6 @@
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
- <property name="userService" ref="org.hisp.dhis.user.UserService" />
<property name="securityService" ref="org.hisp.dhis.security.SecurityService" />
</bean>
@@ -762,7 +761,6 @@
<property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />
<property name="messageService" ref="org.hisp.dhis.message.MessageService" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- <property name="userService" ref="org.hisp.dhis.user.UserService" />
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
<property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
</bean>
@@ -844,7 +842,6 @@
<property name="userCredentialsStore" ref="org.hisp.dhis.user.UserCredentialsStore" />
<property name="userAuthorityGroupStore" ref="org.hisp.dhis.user.UserAuthorityGroupStore" />
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
- <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
<property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
<property name="passwordManager" ref="org.hisp.dhis.security.PasswordManager" />
</bean>