← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21447: Minor, use AnnotationUtils.findAnnotation() instead of Method.getAnnotation() as its supports met...

 

------------------------------------------------------------
revno: 21447
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-12-14 17:57:26 +0100
message:
  Minor, use AnnotationUtils.findAnnotation() instead of Method.getAnnotation() as its supports method overrides
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetaDataDependencyService.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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetaDataDependencyService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetaDataDependencyService.java	2015-09-13 21:54:23 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetaDataDependencyService.java	2015-12-14 16:57:26 +0000
@@ -28,18 +28,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-
+import com.fasterxml.jackson.annotation.JsonView;
+import com.google.common.collect.Sets;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hibernate.proxy.HibernateProxy;
@@ -64,9 +54,19 @@
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.validation.ValidationRule;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.annotation.AnnotationUtils;
 
-import com.fasterxml.jackson.annotation.JsonView;
-import com.google.common.collect.Sets;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
 
 /**
  * @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
@@ -76,12 +76,12 @@
 {
     private static final Log log = LogFactory.getLog( DefaultMetaDataDependencyService.class );
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     private final Set<Class<? extends BaseIdentifiableObject>> SPECIAL_CASE_CLASSES = Sets.newHashSet( DataElement.class, DataElementCategoryCombo.class, Indicator.class, OrganisationUnit.class, ValidationRule.class );
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     private final Set<Class<User>> SKIP_DEPENDENCY_CHECK_CLASSES = Sets.newHashSet( User.class );
-    
+
     //-------------------------------------------------------------------------------------------------------
     // Dependencies
     //-------------------------------------------------------------------------------------------------------
@@ -109,7 +109,7 @@
         Map<String, List<IdentifiableObject>> identifiableObjectMap = new HashMap<>();
 
         List<Schema> schemas = schemaService.getMetadataSchemas();
-        
+
         for ( Map.Entry<String, Object> identifiableObjectUidEntry : identifiableObjectUidMap.entrySet() )
         {
             String className = identifiableObjectUidEntry.getKey();
@@ -155,7 +155,7 @@
         Set<IdentifiableObject> dependencySet = getDependencySet( identifiableObjects );
 
         List<Schema> schemas = schemaService.getMetadataSchemas();
-        
+
         for ( IdentifiableObject dependency : dependencySet )
         {
             for ( Schema schema : schemas )
@@ -218,7 +218,7 @@
     private List<IdentifiableObject> computeAllDependencies( IdentifiableObject identifiableObject )
     {
         List<IdentifiableObject> finalDependencies = new ArrayList<>();
-        
+
         List<IdentifiableObject> dependencies = getDependencies( identifiableObject );
 
         if ( dependencies.isEmpty() )
@@ -244,16 +244,16 @@
     private List<IdentifiableObject> getDependencies( IdentifiableObject identifiableObject )
     {
         List<IdentifiableObject> dependencies = new ArrayList<>();
-        
+
         if ( identifiableObject == null || SKIP_DEPENDENCY_CHECK_CLASSES.contains( identifiableObject.getClass() ) )
         {
             return dependencies;
         }
-        
+
         List<Field> fields = ReflectionUtils.getAllFields( identifiableObject.getClass() );
-        
+
         List<Schema> schemas = schemaService.getMetadataSchemas();
-        
+
         for ( Field field : fields )
         {
             for ( Schema schema : schemas )
@@ -417,9 +417,9 @@
 
     public boolean isExportView( Method method )
     {
-        if ( method.isAnnotationPresent( JsonView.class ) )
+        if ( AnnotationUtils.findAnnotation( method, JsonView.class ) != null )
         {
-            Class<?>[] viewClasses = method.getAnnotation( JsonView.class ).value();
+            Class<?>[] viewClasses = AnnotationUtils.findAnnotation( method, JsonView.class ).value();
 
             for ( Class<?> viewClass : viewClasses )
             {