=== 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 @@ -76,12 +76,12 @@ { private static final Log log = LogFactory.getLog( DefaultMetaDataDependencyService.class ); - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) private final Set> SPECIAL_CASE_CLASSES = Sets.newHashSet( DataElement.class, DataElementCategoryCombo.class, Indicator.class, OrganisationUnit.class, ValidationRule.class ); - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) private final Set> SKIP_DEPENDENCY_CHECK_CLASSES = Sets.newHashSet( User.class ); - + //------------------------------------------------------------------------------------------------------- // Dependencies //------------------------------------------------------------------------------------------------------- @@ -109,7 +109,7 @@ Map> identifiableObjectMap = new HashMap<>(); List schemas = schemaService.getMetadataSchemas(); - + for ( Map.Entry identifiableObjectUidEntry : identifiableObjectUidMap.entrySet() ) { String className = identifiableObjectUidEntry.getKey(); @@ -155,7 +155,7 @@ Set dependencySet = getDependencySet( identifiableObjects ); List schemas = schemaService.getMetadataSchemas(); - + for ( IdentifiableObject dependency : dependencySet ) { for ( Schema schema : schemas ) @@ -218,7 +218,7 @@ private List computeAllDependencies( IdentifiableObject identifiableObject ) { List finalDependencies = new ArrayList<>(); - + List dependencies = getDependencies( identifiableObject ); if ( dependencies.isEmpty() ) @@ -244,16 +244,16 @@ private List getDependencies( IdentifiableObject identifiableObject ) { List dependencies = new ArrayList<>(); - + if ( identifiableObject == null || SKIP_DEPENDENCY_CHECK_CLASSES.contains( identifiableObject.getClass() ) ) { return dependencies; } - + List fields = ReflectionUtils.getAllFields( identifiableObject.getClass() ); - + List 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 ) {