← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12833: merge with branch lp:~rosu-ovi/+junk/dhis2-importexport-gsoc2013, detailed meta-data export, more...

 

Merge authors:
  Rosu Ovidiu rosu.ovi@xxxxxxxxx
------------------------------------------------------------
revno: 12833 [merge]
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-10-30 13:51:03 +0100
message:
  merge with branch lp:~rosu-ovi/+junk/dhis2-importexport-gsoc2013, detailed meta-data export, more fixes coming
removed:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonConcept.vm
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/filter/
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/filter/Filter.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/filter/FilterService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/filter/FilterStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/filter/
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/filter/DefaultFilterService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/filter/hibernate/
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/filter/hibernate/HibernateFilterStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/filter/
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/filter/hibernate/
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/filter/hibernate/Filter.hbm.xml
  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/FilterOptions.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaDataDependencyService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/FilterController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/FilteredMetaDataController.java
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/filter.xsl
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonConcept.vm
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/FilterExportFormAction.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/FilterListAction.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/GetFilterListSortOrderAction.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/SaveFilterListSortOrderAction.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2FilteredMetaDataExport.vm
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/filterExportForm.vm
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/detailedMetaDataImport.js
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filter.js
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filteredMetaDataExport.js
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/utils.js
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/sortFilterForm.vm
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExportService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/Options.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml
  dhis-2/dhis-support/dhis-support-test/src/main/resources/log4j.properties
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml
  dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties
  dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2MetaDataExport.vm
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/index.vm
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/mainMenu.vm


--
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
=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/filter'
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/filter/Filter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/filter/Filter.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/filter/Filter.java	2013-10-30 12:51:03 +0000
@@ -0,0 +1,101 @@
+package org.hisp.dhis.filter;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.common.BaseNameableObject;
+import org.hisp.dhis.common.DxfNamespaces;
+import org.hisp.dhis.common.view.DetailedView;
+import org.hisp.dhis.common.view.ExportView;
+
+/**
+ * @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+ */
+@JacksonXmlRootElement(localName = "filter", namespace = DxfNamespaces.DXF_2_0)
+public class Filter
+    extends BaseNameableObject
+{
+    /**
+     * Determines if a de-serialized file is compatible with this class.
+     */
+    private static final long serialVersionUID = 8736213901318412954L;
+
+    private String jsonFilter;
+
+    private Integer sortOrder;
+
+    //--------------------------------------------------------------------------
+    // Constructors
+    //--------------------------------------------------------------------------
+
+    public Filter()
+    {
+    }
+
+    public Filter( String name )
+    {
+        this.name = name;
+    }
+
+    public Filter( String uid, String description, String name, String jsonFilter )
+    {
+        super( uid, description, name );
+        this.jsonFilter = jsonFilter;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters and setters properties
+    // -------------------------------------------------------------------------
+
+    @JsonProperty
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    public String getJsonFilter()
+    {
+        return jsonFilter;
+    }
+
+    public void setJsonFilter( String jsonFilter )
+    {
+        this.jsonFilter = jsonFilter;
+    }
+
+    public Integer getSortOrder()
+    {
+        return sortOrder;
+    }
+
+    public void setSortOrder( Integer sortOrder )
+    {
+        this.sortOrder = sortOrder;
+    }
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/filter/FilterService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/filter/FilterService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/filter/FilterService.java	2013-10-30 12:51:03 +0000
@@ -0,0 +1,57 @@
+package org.hisp.dhis.filter;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.Collection;
+
+/**
+ * @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+ */
+public interface FilterService
+{
+    Filter getFilter( Integer id );
+
+    Filter getFilterByUid( String uid );
+
+    Collection<Filter> getAllFilters();
+
+    Collection<Filter> getFiltersBetweenByName( String name, int first, int max );
+
+    Collection<Filter> getFiltersBetween( int first, int max );
+
+    void saveFilter( Filter filter );
+
+    void updateFilter( Filter filter );
+
+    void deleteFilter( Filter filter );
+
+    int getFilterCountByName( String name );
+
+    int getFilterCount();
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/filter/FilterStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/filter/FilterStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/filter/FilterStore.java	2013-10-30 12:51:03 +0000
@@ -0,0 +1,39 @@
+package org.hisp.dhis.filter;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+
+/**
+ * @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+ */
+public interface FilterStore
+    extends GenericIdentifiableObjectStore<Filter>
+{
+}

=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/filter'
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/filter/DefaultFilterService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/filter/DefaultFilterService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/filter/DefaultFilterService.java	2013-10-30 12:51:03 +0000
@@ -0,0 +1,136 @@
+package org.hisp.dhis.filter;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.i18n.I18nService;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Collection;
+
+import static org.hisp.dhis.i18n.I18nUtils.*;
+
+/**
+ * @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+ */
+@Transactional
+public class DefaultFilterService
+    implements FilterService
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private FilterStore filterStore;
+
+    public FilterStore getFilterStore()
+    {
+        return filterStore;
+    }
+
+    public void setFilterStore( FilterStore filterStore )
+    {
+        this.filterStore = filterStore;
+    }
+
+    private I18nService i18nService;
+
+    public I18nService getI18nService()
+    {
+        return i18nService;
+    }
+
+    public void setI18nService( I18nService i18nService )
+    {
+        this.i18nService = i18nService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Logic
+    // -------------------------------------------------------------------------
+
+    @Override
+    public Filter getFilter( Integer id )
+    {
+        return filterStore.get( id );
+    }
+
+    @Override
+    public Filter getFilterByUid( String uid )
+    {
+        return filterStore.getByUid( uid );
+    }
+
+    @Override
+    public Collection<Filter> getAllFilters()
+    {
+        return filterStore.getAll();
+    }
+
+    @Override
+    public Collection<Filter> getFiltersBetweenByName( String name, int first, int max )
+    {
+        return getObjectsBetweenByName( i18nService, filterStore, name, first, max );
+    }
+
+    @Override
+    public Collection<Filter> getFiltersBetween( int first, int max )
+    {
+        return getObjectsBetween( i18nService, filterStore, first, max );
+    }
+
+    @Override
+    public void saveFilter( Filter filter )
+    {
+        filterStore.save( filter );
+    }
+
+    @Override
+    public void updateFilter( Filter filter )
+    {
+        filterStore.update( filter );
+    }
+
+    @Override
+    public void deleteFilter( Filter filter )
+    {
+        filterStore.delete( filter );
+    }
+
+    @Override
+    public int getFilterCountByName( String name )
+    {
+        return getCountByName( i18nService, filterStore, name );
+    }
+
+    @Override
+    public int getFilterCount()
+    {
+        return filterStore.getCount();
+    }
+}

=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/filter/hibernate'
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/filter/hibernate/HibernateFilterStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/filter/hibernate/HibernateFilterStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/filter/hibernate/HibernateFilterStore.java	2013-10-30 12:51:03 +0000
@@ -0,0 +1,42 @@
+package org.hisp.dhis.filter.hibernate;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.filter.Filter;
+import org.hisp.dhis.filter.FilterStore;
+
+/**
+ * @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+ */
+public class HibernateFilterStore
+    extends HibernateIdentifiableObjectStore<Filter>
+    implements FilterStore
+{
+}

=== 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	2013-10-23 22:03:17 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2013-10-25 19:53:21 +0000
@@ -55,6 +55,13 @@
     <property name="jdbcTemplate" ref="jdbcTemplate" />
   </bean>
 
+  <!--@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>-->
+  <bean id="org.hisp.dhis.filter.FilterStore" class="org.hisp.dhis.filter.hibernate.HibernateFilterStore">
+    <property name="clazz" value="org.hisp.dhis.filter.Filter" />
+    <property name="sessionFactory" ref="sessionFactory" />
+    <property name="cacheable" value="true" />
+  </bean>
+
   <bean id="org.hisp.dhis.indicator.IndicatorStore" class="org.hisp.dhis.indicator.hibernate.HibernateIndicatorStore">
     <property name="clazz" value="org.hisp.dhis.indicator.Indicator" />
     <property name="sessionFactory" ref="sessionFactory" />
@@ -583,6 +590,12 @@
     <property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />
   </bean>
 
+  <!--@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>-->
+  <bean id="org.hisp.dhis.filter.FilterService" class="org.hisp.dhis.filter.DefaultFilterService">
+    <property name="filterStore" ref="org.hisp.dhis.filter.FilterStore" />
+    <property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />
+  </bean>
+
   <bean id="org.hisp.dhis.option.OptionService" class="org.hisp.dhis.option.DefaultOptionService">
     <property name="optionStore" ref="org.hisp.dhis.option.OptionStore" />
     <property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />

=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/filter'
=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/filter/hibernate'
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/filter/hibernate/Filter.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/filter/hibernate/Filter.hbm.xml	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/filter/hibernate/Filter.hbm.xml	2013-10-30 12:51:03 +0000
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
+  [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+  >
+<hibernate-mapping>
+  <class name="org.hisp.dhis.filter.Filter" table="filter">
+
+    <cache usage="read-write" />
+
+    <id name="id" column="filterid">
+      <generator class="native" />
+    </id>
+
+    &identifiableProperties;
+
+    <property name="name" column="name" not-null="true" unique="true" length="160" />
+
+    <property name="description" type="text" />
+
+    <property name="jsonFilter" column="jsonfilter" type="text" />
+
+  </class>
+</hibernate-mapping>

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java	2013-10-30 12:51:03 +0000
@@ -28,15 +28,15 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Map;
-
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import net.sf.json.JSONObject;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.IdentifiableObjectManager;
+import org.hisp.dhis.filter.Filter;
+import org.hisp.dhis.filter.FilterService;
 import org.hisp.dhis.scheduling.TaskId;
 import org.hisp.dhis.system.notification.NotificationLevel;
 import org.hisp.dhis.system.notification.Notifier;
@@ -46,6 +46,14 @@
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
@@ -54,11 +62,9 @@
     implements ExportService
 {
     private static final Log log = LogFactory.getLog( DefaultExportService.class );
-
     //-------------------------------------------------------------------------------------------------------
     // Dependencies
     //-------------------------------------------------------------------------------------------------------
-
     @Autowired
     protected IdentifiableObjectManager manager;
 
@@ -68,8 +74,14 @@
     @Autowired
     private Notifier notifier;
 
+    @Autowired
+    private MetaDataDependencyService metaDataDependencyService;
+
+    @Autowired
+    private FilterService filterService;
+
     //-------------------------------------------------------------------------------------------------------
-    // ExportService Implementation
+    // ExportService Implementation - MetaData
     //-------------------------------------------------------------------------------------------------------
 
     @Override
@@ -139,4 +151,120 @@
 
         return metaData;
     }
+
+    //-------------------------------------------------------------------------------------------------------
+    // ExportService Implementation - Detailed MetaData Export
+    //-------------------------------------------------------------------------------------------------------
+
+    //@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+    @Override
+    public MetaData getFilteredMetaData( FilterOptions filterOptions ) throws IOException
+    {
+        return getFilteredMetaData( filterOptions, null );
+    }
+
+    @Override
+    public MetaData getFilteredMetaData( FilterOptions filterOptions, TaskId taskId ) throws IOException
+    {
+        MetaData metaData = new MetaData();
+        metaData.setCreated( new Date() );
+
+        log.info( "User '" + currentUserService.getCurrentUsername() + "' started export at " + new Date() );
+
+        if ( taskId != null )
+        {
+            notifier.notify( taskId, "Exporting meta-data" );
+        }
+
+        Object jsonFilter = filterOptions.getRestrictionsJson().get( "jsonFilter" );
+        String json;
+
+        if ( jsonFilter == null )
+        {
+            json = "{}";
+        }
+        else
+        {
+            json = jsonFilter.toString();
+        }
+
+
+        Map<String, List<String>> identifiableObjectUidMap = new ObjectMapper().readValue( json, new TypeReference<HashMap<String, List<String>>>()
+        {
+        } );
+
+        Map<String, List<IdentifiableObject>> identifiableObjectMap;
+
+        if ( filterOptions.getRestrictionsJson().get( "exportDependencies" ).equals( "true" ) )
+        {
+            identifiableObjectMap = metaDataDependencyService.getIdentifiableObjectWithDependencyMap( identifiableObjectUidMap );
+        }
+        else
+        {
+            identifiableObjectMap = metaDataDependencyService.getIdentifiableObjectMap( identifiableObjectUidMap );
+        }
+
+        for ( Map.Entry<String, List<IdentifiableObject>> identifiableObjectEntry : identifiableObjectMap.entrySet() )
+        {
+            String message = "Exporting " + identifiableObjectEntry.getValue().size() + " " + StringUtils.capitalize( identifiableObjectEntry.getKey() );
+            log.info( message );
+
+            if ( taskId != null )
+            {
+                notifier.notify( taskId, message );
+            }
+
+            ReflectionUtils.invokeSetterMethod( identifiableObjectEntry.getKey(), metaData, identifiableObjectEntry.getValue() );
+        }
+
+        log.info( "Export done at " + new Date() );
+
+        if ( taskId != null )
+        {
+            notifier.notify( taskId, NotificationLevel.INFO, "Export done", true );
+        }
+
+        return metaData;
+    }
+
+    //-------------------------------------------------------------------------------------------------------
+    // ExportService Implementation - Filter functionality
+    //-------------------------------------------------------------------------------------------------------
+
+    @Override
+    public List<Filter> getFilters()
+    {
+        return (List<Filter>) filterService.getAllFilters();
+    }
+
+    @Override
+    public void saveFilter( JSONObject json ) throws IOException
+    {
+        Filter filter = new Filter( json.getString( "name" ) );
+        filter.setDescription( json.getString( "description" ) );
+        filter.setJsonFilter( json.getString( "jsonFilter" ) );
+        filter.setAutoFields();
+
+        filterService.saveFilter( filter );
+    }
+
+    @Override
+    public void updateFilter( JSONObject json ) throws IOException
+    {
+        Filter filter = filterService.getFilterByUid( json.getString( "uid" ) );
+        filter.setName( json.getString( "name" ) );
+        filter.setDescription( json.getString( "description" ) );
+        filter.setJsonFilter( json.getString( "jsonFilter" ) );
+        filter.setLastUpdated( new Date() );
+
+        filterService.updateFilter( filter );
+    }
+
+    @Override
+    public void deleteFilter( JSONObject json ) throws IOException
+    {
+        Filter filter = filterService.getFilterByUid( json.getString( "uid" ) );
+
+        filterService.deleteFilter( filter );
+    }
 }

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultMetaDataDependencyService.java	2013-10-30 12:51:03 +0000
@@ -0,0 +1,398 @@
+package org.hisp.dhis.dxf2.metadata;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.fasterxml.jackson.annotation.JsonView;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.proxy.HibernateProxy;
+import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.IdentifiableObjectManager;
+import org.hisp.dhis.common.view.ExportView;
+import org.hisp.dhis.constant.Constant;
+import org.hisp.dhis.constant.ConstantService;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.expression.Expression;
+import org.hisp.dhis.expression.ExpressionService;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.system.util.ReflectionUtils;
+import org.hisp.dhis.validation.ValidationRule;
+import org.springframework.beans.factory.annotation.Autowired;
+
+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>
+ */
+public class DefaultMetaDataDependencyService
+    implements MetaDataDependencyService
+{
+    private static final Log log = LogFactory.getLog( DefaultMetaDataDependencyService.class );
+
+    private final Class[] specialCases = new Class[]{ DataElement.class, Indicator.class, OrganisationUnit.class, ValidationRule.class };
+
+    //-------------------------------------------------------------------------------------------------------
+    // Dependencies
+    //-------------------------------------------------------------------------------------------------------
+
+    @Autowired
+    private IdentifiableObjectManager manager;
+
+    @Autowired
+    private ExpressionService expressionService;
+
+    @Autowired
+    private ConstantService constantService;
+
+    @Autowired
+    private OrganisationUnitService organisationUnitService;
+
+    //--------------------------------------------------------------------------
+    // Get MetaData dependency Map
+    //--------------------------------------------------------------------------
+
+    public Map<String, List<IdentifiableObject>> getIdentifiableObjectMap( Map<String, List<String>> identifiableObjectUidMap )
+    {
+        Map<String, List<IdentifiableObject>> identifiableObjectMap = new HashMap<String, List<IdentifiableObject>>();
+
+        for ( Map.Entry<String, List<String>> identifiableObjectUidEntry : identifiableObjectUidMap.entrySet() )
+        {
+            String className = identifiableObjectUidEntry.getKey();
+            for ( Map.Entry<Class<? extends IdentifiableObject>, String> entry : ExchangeClasses.getExportMap().entrySet() )
+            {
+                if ( entry.getValue().equals( className ) )
+                {
+                    Class<? extends IdentifiableObject> identifiableObjectClass = entry.getKey();
+                    Collection<? extends IdentifiableObject> identifiableObjects = manager.getByUid( identifiableObjectClass, identifiableObjectUidEntry.getValue() );
+
+                    identifiableObjectMap.put( entry.getValue(), new ArrayList<IdentifiableObject>( identifiableObjects ) );
+                }
+            }
+        }
+
+        return identifiableObjectMap;
+    }
+
+    public Map<String, List<IdentifiableObject>> getIdentifiableObjectWithDependencyMap( Map<String, List<String>> identifiableObjectUidMap )
+    {
+        Map<String, List<IdentifiableObject>> identifiableObjectMap = getIdentifiableObjectMap( identifiableObjectUidMap );
+        Collection<IdentifiableObject> identifiableObjects = new HashSet<IdentifiableObject>();
+
+        for ( Map.Entry<String, List<IdentifiableObject>> identifiableObjectEntry : identifiableObjectMap.entrySet() )
+        {
+            identifiableObjects.addAll( identifiableObjectEntry.getValue() );
+        }
+
+        Set<IdentifiableObject> dependencySet = getDependencySet( identifiableObjects );
+
+        for ( IdentifiableObject dependency : dependencySet )
+        {
+            for ( Map.Entry<Class<? extends IdentifiableObject>, String> entry : ExchangeClasses.getExportMap().entrySet() )
+            {
+                if ( entry.getKey().equals( dependency.getClass() ) )
+                {
+                    if ( identifiableObjectMap.get( entry.getValue() ) != null )
+                    {
+                        identifiableObjectMap.get( entry.getValue() ).add( dependency );
+                    }
+                    else
+                    {
+                        List<IdentifiableObject> idObjects = new ArrayList<IdentifiableObject>();
+                        idObjects.add( dependency );
+
+                        identifiableObjectMap.put( entry.getValue(), idObjects );
+                    }
+                }
+            }
+        }
+
+        return identifiableObjectMap;
+    }
+
+    //--------------------------------------------------------------------------
+    // Get MetaData dependency Set
+    //--------------------------------------------------------------------------
+
+    @Override
+    public Set<IdentifiableObject> getDependencySet( IdentifiableObject identifiableObject )
+    {
+        Set<IdentifiableObject> dependencySet = new HashSet<IdentifiableObject>();
+        dependencySet.addAll( computeAllDependencies( identifiableObject ) );
+
+        if ( isSpecialCase( identifiableObject ) )
+        {
+            dependencySet.addAll( computeSpecialDependencyCase( identifiableObject ) );
+        }
+
+        return dependencySet;
+    }
+
+    @Override
+    public Set<IdentifiableObject> getDependencySet( Collection<? extends IdentifiableObject> identifiableObjects )
+    {
+        Set<IdentifiableObject> dependencySet = new HashSet<IdentifiableObject>();
+
+        for ( IdentifiableObject identifiableObject : identifiableObjects )
+        {
+            dependencySet.addAll( getDependencySet( identifiableObject ) );
+        }
+
+        return dependencySet;
+    }
+
+    //--------------------------------------------------------------------------
+    // Compute dependencies
+    //--------------------------------------------------------------------------
+
+    private List<IdentifiableObject> computeAllDependencies( IdentifiableObject identifiableObject )
+    {
+        List<IdentifiableObject> finalDependencies = new ArrayList<IdentifiableObject>();
+        List<IdentifiableObject> dependencies = getDependencies( identifiableObject );
+
+        if ( dependencies.isEmpty() )
+        {
+            return finalDependencies;
+        }
+        else
+        {
+            for ( IdentifiableObject dependency : dependencies )
+            {
+                log.debug( "[ COMPUTING DEPENDENCY ] : " + dependency.getName() );
+
+                finalDependencies.add( dependency );
+
+                List<IdentifiableObject> computedDependencies = computeAllDependencies( dependency );
+                finalDependencies.addAll( computedDependencies );
+            }
+
+            return finalDependencies;
+        }
+    }
+
+    private List<IdentifiableObject> getDependencies( IdentifiableObject identifiableObject )
+    {
+        List<IdentifiableObject> dependencies = new ArrayList<IdentifiableObject>();
+        List<Field> fields = ReflectionUtils.getAllFields( identifiableObject.getClass() );
+
+        for ( Field field : fields )
+        {
+            for ( Map.Entry<Class<? extends IdentifiableObject>, String> entry : ExchangeClasses.getExportMap().entrySet() )
+            {
+                if ( ReflectionUtils.isType( field, entry.getKey() ) )
+                {
+                    Method getterMethod = ReflectionUtils.findGetterMethod( field.getName(), identifiableObject );
+                    IdentifiableObject dependencyObject = ReflectionUtils.invokeGetterMethod( field.getName(), identifiableObject );
+
+                    if ( dependencyObject != null && isExportView( getterMethod ) )
+                    {
+                        log.debug( "[ DEPENDENCY OBJECT ] : " + dependencyObject.getName() );
+
+                        if ( dependencyObject instanceof HibernateProxy )
+                        {
+                            Object hibernateProxyObject = ((HibernateProxy) dependencyObject).getHibernateLazyInitializer().getImplementation();
+                            IdentifiableObject deProxyDependencyObject = (IdentifiableObject) hibernateProxyObject;
+
+                            dependencies.add( deProxyDependencyObject );
+                        }
+                        else
+                        {
+                            dependencies.add( dependencyObject );
+                        }
+                    }
+                }
+                else if ( ReflectionUtils.isCollection( field.getName(), identifiableObject, entry.getKey() ) )
+                {
+                    Method getterMethod = ReflectionUtils.findGetterMethod( field.getName(), identifiableObject );
+                    Collection<IdentifiableObject> dependencyCollection = ReflectionUtils.invokeGetterMethod( field.getName(), identifiableObject );
+
+                    if ( dependencyCollection != null && isExportView( getterMethod ) )
+                    {
+                        for ( IdentifiableObject dependencyElement : dependencyCollection )
+                        {
+                            log.debug( "[ DEPENDENCY COLLECTION ELEMENT ] : " + dependencyElement.getName() );
+
+                            if ( dependencyElement instanceof HibernateProxy )
+                            {
+                                Object hibernateProxyObject = ((HibernateProxy) dependencyElement).getHibernateLazyInitializer().getImplementation();
+                                IdentifiableObject deProxyDependencyObject = (IdentifiableObject) hibernateProxyObject;
+
+                                dependencies.add( deProxyDependencyObject );
+                            }
+                            else
+                            {
+                                dependencies.add( dependencyElement );
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return dependencies;
+    }
+
+    //--------------------------------------------------------------------------
+    // Compute special case dependencies
+    //--------------------------------------------------------------------------
+
+    private boolean isSpecialCase( IdentifiableObject identifiableObject )
+    {
+        for ( Class specialCase : specialCases )
+        {
+            if ( identifiableObject.getClass().equals( specialCase ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    private Set<IdentifiableObject> computeSpecialDependencyCase( IdentifiableObject identifiableObject )
+    {
+        Set<IdentifiableObject> resultSet = new HashSet<IdentifiableObject>();
+
+        if ( identifiableObject instanceof Indicator )
+        {
+            List<Indicator> indicators = new ArrayList<Indicator>();
+            indicators.add( (Indicator) identifiableObject );
+
+            Set<DataElement> dataElementSet = expressionService.getDataElementsInIndicators( indicators );
+
+            resultSet.addAll( dataElementSet );
+            resultSet.addAll( getDependencySet( dataElementSet ) );
+
+            Set<Constant> constantSet = new HashSet<Constant>();
+
+            List<String> expressions = new ArrayList<String>();
+            Collections.addAll( expressions, ((Indicator) identifiableObject).getNumerator(), ((Indicator) identifiableObject).getDenominator() );
+
+            for ( String expression : expressions )
+            {
+                Matcher matcher = ExpressionService.CONSTANT_PATTERN.matcher( expression );
+                while ( matcher.find() )
+                {
+                    String co = matcher.group( 1 );
+                    constantSet.add( constantService.getConstant( co ) );
+                }
+            }
+
+            resultSet.addAll( constantSet );
+            resultSet.addAll( getDependencySet( constantSet ) );
+
+            return resultSet;
+        }
+        else if ( identifiableObject instanceof ValidationRule )
+        {
+            Set<DataElement> dataElementSet = new HashSet<DataElement>();
+
+            Expression leftSide = ReflectionUtils.invokeGetterMethod( "leftSide", identifiableObject );
+            Expression rightSide = ReflectionUtils.invokeGetterMethod( "rightSide", identifiableObject );
+
+            dataElementSet.addAll( expressionService.getDataElementsInExpression( leftSide.getExpression() ) );
+            dataElementSet.addAll( expressionService.getDataElementsInExpression( rightSide.getExpression() ) );
+
+            resultSet.addAll( dataElementSet );
+            resultSet.addAll( getDependencySet( dataElementSet ) );
+
+            Set<Constant> constantSet = new HashSet<Constant>();
+            constantSet.addAll( constantService.getAllConstants() );
+
+            resultSet.addAll( constantSet );
+            resultSet.addAll( getDependencySet( constantSet ) );
+
+            return resultSet;
+        }
+        else if ( identifiableObject instanceof DataElement )
+        {
+            Set<DataElementCategoryOptionCombo> dataElementCategoryOptionComboSet = new HashSet<DataElementCategoryOptionCombo>();
+            dataElementCategoryOptionComboSet.addAll( ((DataElement) identifiableObject).getCategoryCombo().getOptionCombos() );
+
+            resultSet.addAll( dataElementCategoryOptionComboSet );
+            resultSet.addAll( getDependencySet( dataElementCategoryOptionComboSet ) );
+
+            return resultSet;
+        }
+        else if ( identifiableObject instanceof OrganisationUnit )
+        {
+            Set<OrganisationUnitLevel> organisationUnitLevelSet = new HashSet<OrganisationUnitLevel>();
+            int level = ((OrganisationUnit) identifiableObject).getOrganisationUnitLevel();
+
+            while ( level > 0 )
+            {
+                organisationUnitLevelSet.add( organisationUnitService.getOrganisationUnitLevelByLevel( level ) );
+                level--;
+            }
+
+            resultSet.addAll( organisationUnitLevelSet );
+            resultSet.addAll( getDependencySet( organisationUnitLevelSet ) );
+
+            return resultSet;
+        }
+        else
+        {
+            return resultSet;
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    // Utils
+    //--------------------------------------------------------------------------
+
+    public boolean isExportView( Method method )
+    {
+        if ( method.isAnnotationPresent( JsonView.class ) )
+        {
+            Class[] viewClasses = method.getAnnotation( JsonView.class ).value();
+
+            for ( Class viewClass : viewClasses )
+            {
+                if ( viewClass.equals( ExportView.class ) )
+                {
+                    return true;
+                }
+            }
+        }
+
+        return false;
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java	2013-10-15 07:40:07 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExchangeClasses.java	2013-10-25 19:53:21 +0000
@@ -47,6 +47,7 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.Section;
 import org.hisp.dhis.document.Document;
+import org.hisp.dhis.filter.Filter;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorGroup;
 import org.hisp.dhis.indicator.IndicatorGroupSet;
@@ -197,6 +198,12 @@
         // special class which is created on demand in association with other objects
         exportClasses.remove( DataElementOperand.class );
         importClasses.remove( DataElementOperand.class );
+
+        //@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+        allExportClasses.put( Filter.class, "filters" );
+        // Filters are not available for export/import for now
+        exportClasses.remove( Filter.class );
+        importClasses.remove( Filter.class );
     }
 
     public static Map<Class<? extends IdentifiableObject>, String> getAllExportMap()

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExportService.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExportService.java	2013-09-15 17:29:23 +0000
@@ -28,8 +28,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import net.sf.json.JSONObject;
+import org.hisp.dhis.filter.Filter;
 import org.hisp.dhis.scheduling.TaskId;
 
+import java.io.IOException;
+import java.util.List;
+
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
@@ -38,4 +43,17 @@
     MetaData getMetaData( Options options );
 
     MetaData getMetaData( Options options, TaskId taskId );
+
+//  @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+    MetaData getFilteredMetaData( FilterOptions filterOptions ) throws IOException;
+
+    MetaData getFilteredMetaData( FilterOptions filterOptions, TaskId taskId ) throws IOException;
+
+    List<Filter> getFilters();
+
+    void saveFilter( JSONObject json ) throws IOException;
+
+    void updateFilter( JSONObject json ) throws IOException;
+
+    void deleteFilter( JSONObject json ) throws IOException;
 }

=== added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/FilterOptions.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/FilterOptions.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/FilterOptions.java	2013-10-30 12:51:03 +0000
@@ -0,0 +1,62 @@
+package org.hisp.dhis.dxf2.metadata;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import net.sf.json.JSONObject;
+
+/**
+ * @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+ */
+public class FilterOptions
+    extends Options
+{
+    private JSONObject restrictionsJson;
+
+    //--------------------------------------------------------------------------
+    // Constructors
+    //--------------------------------------------------------------------------
+
+    public FilterOptions( JSONObject restrictionsJson )
+    {
+        this.restrictionsJson = restrictionsJson;
+    }
+
+    //--------------------------------------------------------------------------
+    // Getters & Setters
+    //--------------------------------------------------------------------------
+
+    public JSONObject getRestrictionsJson()
+    {
+        return restrictionsJson;
+    }
+
+    public void setRestrictionsJson( JSONObject restrictionsJson )
+    {
+        this.restrictionsJson = restrictionsJson;
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java	2013-09-27 10:43:38 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java	2013-10-25 18:39:01 +0000
@@ -50,6 +50,7 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.Section;
 import org.hisp.dhis.document.Document;
+import org.hisp.dhis.filter.Filter;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorGroup;
 import org.hisp.dhis.indicator.IndicatorGroupSet;
@@ -181,6 +182,9 @@
 
     private List<RelationshipType> relationshipTypes = new ArrayList<RelationshipType>();
 
+    //@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+    private List<Filter> filters = new ArrayList<Filter>();
+
     private List<PatientIdentifierType> personIdentifierTypes = new ArrayList<PatientIdentifierType>();
 
     private List<PatientAttribute> personAttributeTypes = new ArrayList<PatientAttribute>();
@@ -814,6 +818,20 @@
         this.dimensions = dimensions;
     }
 
+    //@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+    @JsonProperty
+    @JacksonXmlElementWrapper(localName = "filters", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty(localName = "filter", namespace = DxfNamespaces.DXF_2_0)
+    public List<Filter> getFilters()
+    {
+        return filters;
+    }
+
+    public void setFilters( List<Filter> filters )
+    {
+        this.filters = filters;
+    }
+
     @Override
     public String toString()
     {

=== added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaDataDependencyService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaDataDependencyService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaDataDependencyService.java	2013-08-27 06:44:31 +0000
@@ -0,0 +1,49 @@
+package org.hisp.dhis.dxf2.metadata;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.common.IdentifiableObject;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+ */
+public interface MetaDataDependencyService
+{
+    Map<String, List<IdentifiableObject>> getIdentifiableObjectMap( Map<String, List<String>> identifiableObjectUidMap );
+
+    Map<String, List<IdentifiableObject>> getIdentifiableObjectWithDependencyMap( Map<String, List<String>> identifiableObjectUidMap );
+
+    Set<IdentifiableObject> getDependencySet( IdentifiableObject identifiableObject );
+
+    Set<IdentifiableObject> getDependencySet( Collection<? extends IdentifiableObject> identifiableObjects );
+}

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/Options.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/Options.java	2013-09-02 10:37:36 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/Options.java	2013-09-08 17:26:58 +0000
@@ -163,6 +163,10 @@
         this.assumeTrue = options.get( "assumeTrue" ) == null || options.get( "assumeTrue" ).equalsIgnoreCase( "true" );
     }
 
+    public Options()
+    {
+    }
+
     //--------------------------------------------------------------------------
     // Get options for classes/strings etc
     //--------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml	2013-10-08 17:16:47 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml	2013-10-25 18:39:01 +0000
@@ -203,4 +203,7 @@
   <bean id="pdfDataEntryFormService" class="org.hisp.dhis.dxf2.pdfform.DefaultPdfDataEntryFormService" scope="prototype">
   </bean>
 
+  <!--@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>-->
+  <bean id="org.hisp.dhis.dxf2.metadata.MetaDataDependencyService" class="org.hisp.dhis.dxf2.metadata.DefaultMetaDataDependencyService" scope="prototype" />
+
 </beans>

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml	2013-10-16 07:16:05 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml	2013-10-25 19:53:21 +0000
@@ -116,6 +116,9 @@
   
   <cache name="org.hisp.dhis.dataset.LockException" maxElementsInMemory="1000" />
 
+  <!--@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>-->
+  <cache name="org.hisp.dhis.filter.Filter" maxElementsInMemory="100" />
+
   <!-- Hibernate Associations -->
 
   <cache name="org.hisp.dhis.dataelement.DataElementCategoryCombo.categories" maxElementsInMemory="300" />

=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/resources/log4j.properties'
--- dhis-2/dhis-support/dhis-support-test/src/main/resources/log4j.properties	2009-10-31 01:31:57 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/resources/log4j.properties	2013-08-11 09:19:11 +0000
@@ -7,5 +7,5 @@
 log4j.appender.console.layout.ConversionPattern = * %-5p %d{ABSOLUTE} %m (%F [%t])%n
 
 # Categories (order: DEBUG, INFO, WARN, ERROR, FATAL)
-log4j.rootCategory = FATAL, console
+log4j.rootCategory = ERROR, console
 log4j.category.org.hisp.dhis = WARN

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/FilterController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/FilterController.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/FilterController.java	2013-09-08 14:37:41 +0000
@@ -0,0 +1,43 @@
+package org.hisp.dhis.api.controller;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.filter.Filter;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+ */
+@Controller
+@RequestMapping( value = FilterController.RESOURCE_PATH )
+public class FilterController
+        extends AbstractCrudController<Filter>
+{
+    public static final String RESOURCE_PATH = "/filters";
+}

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/FilteredMetaDataController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/FilteredMetaDataController.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/FilteredMetaDataController.java	2013-09-16 13:33:28 +0000
@@ -0,0 +1,261 @@
+package org.hisp.dhis.api.controller;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import net.sf.json.JSONObject;
+import org.hisp.dhis.api.utils.ContextUtils;
+import org.hisp.dhis.common.view.ExportView;
+import org.hisp.dhis.dxf2.metadata.*;
+import org.hisp.dhis.dxf2.metadata.tasks.ImportMetaDataTask;
+import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.filter.Filter;
+import org.hisp.dhis.importexport.ImportStrategy;
+import org.hisp.dhis.scheduling.TaskCategory;
+import org.hisp.dhis.scheduling.TaskId;
+import org.hisp.dhis.system.notification.Notifier;
+import org.hisp.dhis.system.scheduling.Scheduler;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.GZIPOutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+ */
+@Controller
+public class FilteredMetaDataController
+{
+    public static final String RESOURCE_PATH = "/filteredMetaData";
+
+    @Autowired
+    private ExportService exportService;
+
+    @Qualifier( "contextUtils" )
+    @Autowired
+    private ContextUtils contextUtils;
+
+    @Autowired
+    private Scheduler scheduler;
+
+    @Autowired
+    private ImportService importService;
+
+    @Autowired
+    private CurrentUserService currentUserService;
+
+    @Autowired
+    private Notifier notifier;
+
+    private boolean dryRun;
+
+    private ImportStrategy strategy;
+
+    //--------------------------------------------------------------------------
+    // Getters & Setters
+    //--------------------------------------------------------------------------
+
+    public void setDryRun( boolean dryRun )
+    {
+        this.dryRun = dryRun;
+    }
+
+    public void setStrategy( String strategy )
+    {
+        this.strategy = ImportStrategy.valueOf( strategy );
+    }
+
+    //--------------------------------------------------------------------------
+    // Detailed MetaData Export - POST Requests
+    //--------------------------------------------------------------------------
+
+    @RequestMapping( value = FilteredMetaDataController.RESOURCE_PATH, headers = "Accept=application/json" )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
+    public String detailedExport( @RequestParam Map<String, String> parameters, Model model ) throws IOException
+    {
+        WebOptions options = new WebOptions( parameters );
+        MetaData metaData = exportService.getMetaData( options );
+
+        model.addAttribute( "model", metaData );
+        model.addAttribute( "viewClass", "export" );
+
+        return "export";
+    }
+
+    @RequestMapping( method = RequestMethod.POST, value = FilteredMetaDataController.RESOURCE_PATH + ".xml", produces = "*/*" )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
+    public void exportXml( @RequestParam String exportJsonValue, HttpServletResponse response ) throws IOException
+    {
+        FilterOptions filterOptions = new FilterOptions( JSONObject.fromObject( exportJsonValue ) );
+        MetaData metaData = exportService.getFilteredMetaData( filterOptions );
+
+        contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, ContextUtils.CacheStrategy.NO_CACHE, "metaData.xml", true );
+        JacksonUtils.toXmlWithView( response.getOutputStream(), metaData, ExportView.class );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, value = FilteredMetaDataController.RESOURCE_PATH + ".json", produces = "*/*" )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
+    public void exportJson( @RequestParam String exportJsonValue, HttpServletResponse response ) throws IOException
+    {
+        FilterOptions filterOptions = new FilterOptions( JSONObject.fromObject( exportJsonValue ) );
+        MetaData metaData = exportService.getFilteredMetaData( filterOptions );
+
+        contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JSON, ContextUtils.CacheStrategy.NO_CACHE, "metaData.json", true );
+        JacksonUtils.toJsonWithView( response.getOutputStream(), metaData, ExportView.class );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, value = { FilteredMetaDataController.RESOURCE_PATH + ".xml.zip" }, produces = "*/*" )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
+    public void exportZippedXML( @RequestParam String exportJsonValue, HttpServletResponse response ) throws IOException
+    {
+        FilterOptions filterOptions = new FilterOptions( JSONObject.fromObject( exportJsonValue ) );
+        MetaData metaData = exportService.getFilteredMetaData( filterOptions );
+
+        contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_ZIP, ContextUtils.CacheStrategy.NO_CACHE, "metaData.xml.zip", true );
+        response.addHeader( ContextUtils.HEADER_CONTENT_TRANSFER_ENCODING, "binary" );
+
+        ZipOutputStream zip = new ZipOutputStream( response.getOutputStream() );
+        zip.putNextEntry( new ZipEntry( "metaData.xml" ) );
+
+        JacksonUtils.toXmlWithView( zip, metaData, ExportView.class );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, value = { FilteredMetaDataController.RESOURCE_PATH + ".json.zip" }, produces = "*/*" )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
+    public void exportZippedJSON( @RequestParam String exportJsonValue, HttpServletResponse response ) throws IOException
+    {
+        FilterOptions filterOptions = new FilterOptions( JSONObject.fromObject( exportJsonValue ) );
+        MetaData metaData = exportService.getFilteredMetaData( filterOptions );
+
+        contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_ZIP, ContextUtils.CacheStrategy.NO_CACHE, "metaData.json.zip", true );
+        response.addHeader( ContextUtils.HEADER_CONTENT_TRANSFER_ENCODING, "binary" );
+
+        ZipOutputStream zip = new ZipOutputStream( response.getOutputStream() );
+        zip.putNextEntry( new ZipEntry( "metaData.json" ) );
+
+        JacksonUtils.toJsonWithView( zip, metaData, ExportView.class );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, value = { FilteredMetaDataController.RESOURCE_PATH + ".xml.gz" }, produces = "*/*" )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
+    public void exportGZippedXML( @RequestParam String exportJsonValue, HttpServletResponse response ) throws IOException
+    {
+        FilterOptions filterOptions = new FilterOptions( JSONObject.fromObject( exportJsonValue ) );
+        MetaData metaData = exportService.getFilteredMetaData( filterOptions );
+
+        contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_GZIP, ContextUtils.CacheStrategy.NO_CACHE, "metaData.xml.gz", true );
+        response.addHeader( ContextUtils.HEADER_CONTENT_TRANSFER_ENCODING, "binary" );
+
+        GZIPOutputStream gzip = new GZIPOutputStream( response.getOutputStream() );
+        JacksonUtils.toXmlWithView( gzip, metaData, ExportView.class );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, value = { FilteredMetaDataController.RESOURCE_PATH + ".json.gz" }, produces = "*/*" )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
+    public void exportGZippedJSON( @RequestParam String exportJsonValue, HttpServletResponse response ) throws IOException
+    {
+        FilterOptions filterOptions = new FilterOptions( JSONObject.fromObject( exportJsonValue ) );
+        MetaData metaData = exportService.getFilteredMetaData( filterOptions );
+
+        contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_GZIP, ContextUtils.CacheStrategy.NO_CACHE, "metaData.json.gz", true );
+        response.addHeader( ContextUtils.HEADER_CONTENT_TRANSFER_ENCODING, "binary" );
+
+        GZIPOutputStream gzip = new GZIPOutputStream( response.getOutputStream() );
+        JacksonUtils.toJsonWithView( gzip, metaData, ExportView.class );
+    }
+
+    //--------------------------------------------------------------------------
+    // Detailed MetaData Export - Filter functionality
+    //--------------------------------------------------------------------------
+
+    @RequestMapping( method = RequestMethod.GET, value = FilteredMetaDataController.RESOURCE_PATH + "/getFilters" )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
+    public @ResponseBody String getFilters( HttpServletRequest request, HttpServletResponse response ) throws IOException
+    {
+        List<Filter> filters = exportService.getFilters();
+        contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JSON, ContextUtils.CacheStrategy.NO_CACHE );
+        return JacksonUtils.toJsonAsString( filters );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, value = FilteredMetaDataController.RESOURCE_PATH + "/saveFilter" )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
+    public void saveFilter( @RequestBody JSONObject json, HttpServletResponse response ) throws IOException
+    {
+        exportService.saveFilter( json );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, value = FilteredMetaDataController.RESOURCE_PATH + "/updateFilter" )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
+    public void updateFilter( @RequestBody JSONObject json, HttpServletResponse response ) throws IOException
+    {
+        exportService.updateFilter( json );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, value = FilteredMetaDataController.RESOURCE_PATH + "/deleteFilter" )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
+    public void deleteFilter( @RequestBody JSONObject json, HttpServletResponse response ) throws IOException
+    {
+        exportService.deleteFilter( json );
+    }
+
+    //--------------------------------------------------------------------------
+    // Detailed MetaData Import - POST Requests
+    //--------------------------------------------------------------------------
+
+    @RequestMapping( method = RequestMethod.POST, value = FilteredMetaDataController.RESOURCE_PATH + "/importDetailedMetaData" )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_IMPORT')" )
+    public void importDetailedMetaData( @RequestBody JSONObject json, HttpServletResponse response ) throws IOException
+    {
+        strategy = ImportStrategy.valueOf( json.getString( "strategy" ) );
+        dryRun = json.getBoolean( "dryRun" );
+
+        TaskId taskId = new TaskId( TaskCategory.METADATA_IMPORT, currentUserService.getCurrentUser() );
+        User user = currentUserService.getCurrentUser();
+
+        MetaData metaData = new ObjectMapper().readValue( json.getString( "metaData" ), MetaData.class );
+
+        ImportOptions importOptions = new ImportOptions();
+        importOptions.setStrategy( strategy.toString() );
+        importOptions.setDryRun( dryRun );
+
+        scheduler.executeTask( new ImportMetaDataTask( user.getUid(), importService, importOptions, taskId, metaData ) );
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java	2013-09-18 12:45:52 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java	2013-10-25 20:37:23 +0000
@@ -97,7 +97,7 @@
     }
 
     public void configureResponse( HttpServletResponse response, String contentType, CacheStrategy cacheStrategy,
-        String filename, boolean attachment )
+                                   String filename, boolean attachment )
     {
         if ( contentType != null )
         {
@@ -296,4 +296,4 @@
         byte[] encodedAuthorisation = Base64.encode( authorisation.getBytes() );
         headers.add( "Authorization", "Basic " + new String( encodedAuthorisation ) );
     }
-}
+}
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/filter.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/filter.xsl	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/filter.xsl	2013-09-14 14:03:39 +0000
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0"
+                xmlns="http://www.w3.org/1999/xhtml";
+                xmlns:d="http://dhis2.org/schema/dxf/2.0";
+        >
+    <!--@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>-->
+    <xsl:template match="d:filter">
+        <div class="filter">
+            <h2> <xsl:value-of select="@name" /> </h2>
+
+            <table>
+                <tr>
+                    <td>ID</td>
+                    <td> <xsl:value-of select="@id" /> </td>
+                </tr>
+                <tr>
+                    <td>Created</td>
+                    <td> <xsl:value-of select="@created" /> </td>
+                </tr>
+                <tr>
+                    <td>Last Updated</td>
+                    <td> <xsl:value-of select="@lastUpdated" /> </td>
+                </tr>
+                <tr>
+                    <td>MetaData UIDs</td>
+                    <td> <xsl:value-of select="d:metaDataUids" /> </td>
+                </tr>
+            </table>
+
+        </div>
+    </xsl:template>
+
+</xsl:stylesheet>

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl	2013-09-09 12:45:37 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl	2013-09-14 11:26:52 +0000
@@ -46,6 +46,7 @@
   <xsl:include href="validationRule.xsl" />
   <xsl:include href="validationRuleGroup.xsl" />
   <xsl:include href="sqlView.xsl" />
+
   <xsl:include href="user.xsl" />
   <xsl:include href="userGroup.xsl" />
   <xsl:include href="userAuthorityGroup.xsl" />
@@ -60,6 +61,9 @@
   <xsl:include href="event.xsl" />
   <xsl:include href="dashboard.xsl" />
 
+  <!--@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>-->
+  <xsl:include href="filter.xsl" />
+
   <!-- Config elements -->
 
   <xsl:include href="config/sms.xsl" />

=== removed file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonConcept.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonConcept.vm	2011-09-27 07:36:07 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonConcept.vm	1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
-{ "concept":
-  {
-    "id": "$!{concept.id}",
-	"name": "$encoder.jsonEncode( $!{concept.name} )"
-  }
-}

=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonConcept.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonConcept.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonConcept.vm	2013-10-25 20:37:23 +0000
@@ -0,0 +1,6 @@
+{ "concept":
+  {
+    "id": "$!{concept.id}",
+	"name": "$encoder.jsonEncode( $!{concept.name} )"
+  }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml	2013-08-22 17:09:11 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml	2013-09-01 20:44:11 +0000
@@ -269,6 +269,8 @@
         <value>F_REPORTTABLE_EXTERNAL</value>
         <value>F_METADATA_EXPORT</value>
         <value>F_METADATA_IMPORT</value>
+        <value>F_METADATA_SUBSET_IMPORT</value>
+        <value>F_METADATA_SUBSET_EXPORT</value>
       </set>
     </property>
   </bean>

=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/FilterExportFormAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/FilterExportFormAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/FilterExportFormAction.java	2013-10-30 12:51:03 +0000
@@ -0,0 +1,133 @@
+package org.hisp.dhis.importexport.action.dxf2;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.filter.Filter;
+
+/**
+ * @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+ */
+public class FilterExportFormAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private String name;
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    private String uid;
+
+    public String getUid()
+    {
+        return uid;
+    }
+
+    public void setUid( String uid )
+    {
+        this.uid = uid;
+    }
+
+    private String description;
+
+    public String getDescription()
+    {
+        return description;
+    }
+
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    private String jsonFilter;
+
+    public String getJsonFilter()
+    {
+        return jsonFilter;
+    }
+
+    public void setJsonFilter( String jsonFilter )
+    {
+        this.jsonFilter = jsonFilter;
+    }
+
+    public String command;
+
+    public String getCommand()
+    {
+        return command;
+    }
+
+    public void setCommand( String command )
+    {
+        this.command = command;
+    }
+
+// -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private Filter filter = new Filter();
+
+    public Filter getFilter()
+    {
+        return filter;
+    }
+
+    public void setFilter( Filter filter )
+    {
+        this.filter = filter;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action Implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute() throws Exception
+    {
+        filter.setName( name );
+        filter.setUid( uid );
+        filter.setDescription( description );
+        filter.setJsonFilter( jsonFilter );
+
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/FilterListAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/FilterListAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/FilterListAction.java	2013-08-19 22:52:16 +0000
@@ -0,0 +1,109 @@
+package org.hisp.dhis.importexport.action.dxf2;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.filter.Filter;
+import org.hisp.dhis.filter.FilterService;
+import org.hisp.dhis.paging.ActionPagingSupport;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+
+/**
+ * @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+ */
+public class FilterListAction
+        extends ActionPagingSupport<Filter>
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private FilterService filterService;
+
+    public void setFilterService( FilterService filterService )
+    {
+        this.filterService = filterService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input & Output
+    // -------------------------------------------------------------------------
+
+    private List<Filter> filters;
+
+    public List<Filter> getFilters()
+    {
+        return filters;
+    }
+
+    public void setFilters( List<Filter> filters )
+    {
+        this.filters = filters;
+    }
+
+    private String key;
+
+    public String getKey()
+    {
+        return key;
+    }
+
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute() throws Exception
+    {
+        if ( isNotBlank( key ) ) // Filter on key only if set
+        {
+            this.paging = createPaging( filterService.getFilterCountByName( key ) );
+
+            filters = new ArrayList<Filter>( filterService.getFiltersBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+        } else
+        {
+            this.paging = createPaging( filterService.getFilterCount() );
+
+            filters = new ArrayList<Filter>( filterService.getFiltersBetween( paging.getStartPos(), paging.getPageSize() ) );
+        }
+
+        Collections.sort( filters, IdentifiableObjectNameComparator.INSTANCE );
+
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/GetFilterListSortOrderAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/GetFilterListSortOrderAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/GetFilterListSortOrderAction.java	2013-08-19 22:52:16 +0000
@@ -0,0 +1,81 @@
+package org.hisp.dhis.importexport.action.dxf2;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.filter.Filter;
+import org.hisp.dhis.filter.FilterService;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+ */
+public class GetFilterListSortOrderAction
+        implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private FilterService filterService;
+
+    public void setFilterService( FilterService filterService )
+    {
+        this.filterService = filterService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private List<Filter> filters;
+
+    public List<Filter> getFilters()
+    {
+        return filters;
+    }
+
+    public void setFilters( List<Filter> filters )
+    {
+        this.filters = filters;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute() throws Exception
+    {
+        filters = new ArrayList<Filter>( filterService.getAllFilters() );
+
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/SaveFilterListSortOrderAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/SaveFilterListSortOrderAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/SaveFilterListSortOrderAction.java	2013-08-19 22:52:16 +0000
@@ -0,0 +1,83 @@
+package org.hisp.dhis.importexport.action.dxf2;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.filter.Filter;
+import org.hisp.dhis.filter.FilterService;
+
+import java.util.List;
+
+/**
+ * @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+ */
+public class SaveFilterListSortOrderAction
+        implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private FilterService filterService;
+
+    public void setFilterService( FilterService filterService )
+    {
+        this.filterService = filterService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private List<String> filters;
+
+    public void setFilters( List<String> filters )
+    {
+        this.filters = filters;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        int sortOrder = 1;
+
+        for ( String id : filters )
+        {
+            Filter filter = filterService.getFilter( Integer.parseInt( id ) );
+
+            filter.setSortOrder( sortOrder++ );
+
+            filterService.updateFilter( filter );
+        }
+
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml	2013-10-01 13:16:44 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml	2013-10-30 12:51:03 +0000
@@ -208,4 +208,24 @@
     class="org.hisp.dhis.importexport.action.event.GetImportEventSummariesAction" scope="prototype">
   </bean>
 
+  <!--@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>-->
+  <bean id="org.hisp.dhis.importexport.action.dxf2.FilterListAction"
+    class="org.hisp.dhis.importexport.action.dxf2.FilterListAction" scope="prototype">
+    <property name="filterService" ref="org.hisp.dhis.filter.FilterService" />
+  </bean>
+
+  <bean id="org.hisp.dhis.importexport.action.dxf2.GetFilterListSortOrderAction"
+    class="org.hisp.dhis.importexport.action.dxf2.GetFilterListSortOrderAction" scope="prototype">
+    <property name="filterService" ref="org.hisp.dhis.filter.FilterService" />
+  </bean>
+
+  <bean id="org.hisp.dhis.importexport.action.dxf2.SaveFilterListSortOrderAction"
+    class="org.hisp.dhis.importexport.action.dxf2.SaveFilterListSortOrderAction" scope="prototype">
+    <property name="filterService" ref="org.hisp.dhis.filter.FilterService" />
+  </bean>
+
+  <bean id="org.hisp.dhis.importexport.action.dxf2.FilterExportFormAction"
+    class="org.hisp.dhis.importexport.action.dxf2.FilterExportFormAction" scope="prototype">
+  </bean>
+
 </beans>

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties	2013-10-07 17:58:57 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties	2013-10-30 12:51:03 +0000
@@ -333,4 +333,114 @@
 value_not_negative_integer=Value is not a valid negative integer
 value_is_zero_and_not_zero_significant=Value is zero and not zero-significant
 value_not_zero_or_positive_integer=Value is not a valid zero or positive integer
-comment_too_long=Comment is too long
\ No newline at end of file
+comment_too_long=Comment is too long
+
+intro_filtered_metadata_export=Export filtered meta-data like data elements and organisation units to the standard DHIS 2 exchange format.
+filtered_metadata_export=Meta-Data Detailed Export
+
+apply=Apply
+sort=Sort
+
+add_new_filter=Add new Filter
+ad_hoc_export=Ad hoc export
+create_new_filter=Create new Filter
+filter_sort_order=Filter sort order
+edit_filter=Edit Filter
+filter_details=Filter Details
+validate_filter=Filter name cannot be empty.
+
+export_with_dependencies=Export with dependencies
+
+attribute_types=Attribute Types
+available_attribute_types=Available Attribute Types
+selected_attribute_types=Selected Attribute Types
+
+categories=Categories
+available_categories=Available Categories
+selected_categories=Selected Categories
+
+available_charts=Available Charts
+selected_charts=Selected Charts
+
+concepts=Concepts
+available_concepts=Available Concepts
+selected_concepts=Selected Concepts
+
+available_constants=Available Constants
+selected_constants=Selected Constants
+
+available_dataDictionaries=Available Data Dictionaries
+selected_dataDictionaries=Selected Data Dictionaries
+
+available_dataElementGroupSets=Available Data Element Group Sets
+selected_dataElementGroupSets=Selected Data Element Group Sets
+
+available_dataElementGroups=Available Data Element Groups
+selected_dataElementGroups=Selected Data Element Groups
+
+documents=Documents
+available_documents=Available Documents
+selected_documents=Selected Documents
+
+available_indicatorGroupSets=Available Indicator Group Sets
+selected_indicatorGroupSets=Selected Indicator Group Sets
+
+available_indicatorGroups=Available Indicator Groups
+selected_indicatorGroups=Selected Indicator Groups
+
+indicator_types=Indicator types
+available_indicatorTypes=Available Indicator Types
+selected_indicatorTypes=Selected Indicator Types
+
+map_legend_sets=Map legend sets
+available_mapLegendSets=Available Map Legend Sets
+selected_mapLegendSets=Selected Map Legend Sets
+
+maps=Maps
+available_maps=Available Maps
+selected_maps=Selected Maps
+
+option_sets=Option sets
+available_optionSets=Available Option Sets
+selected_optionSets=Selected Option Sets
+
+available_organisationUnitGroupSets=Available Organisation Unit Group Sets
+selected_organisationUnitGroupSets=Selected Organisation Unit Group Sets
+
+available_organisationUnitGroups=Available Organisation Unit Groups
+selected_organisationUnitGroups=Selected Organisation Unit Groups
+
+available_organisationUnitLevels=Available Organisation Unit Levels
+selected_organisationUnitLevels=Selected Organisation Unit Levels
+
+available_organisationUnits=Available Organisation Units
+selected_organisationUnits=Selected Organisation Units
+
+available_reportTables=Available Report Tables
+selected_reportTables=Selected Report Tables
+
+available_reports=Available Reports
+selected_reports=Selected Reports
+
+sql_views=Sql views
+available_sqlViews=Available Sql Views
+selected_sqlViews=Selected Sql Views
+
+available_userGroups=Available User Groups
+selected_userGroups=Selected User Groups
+
+available_userRoles=Available User Roles
+selected_userRoles=Selected User Roles
+
+available_users=Available Users
+selected_users=Selected Users
+
+validation_rule_groups=Validation rule groups
+available_validationRuleGroups=Available Validation Rule Groups
+selected_validationRuleGroups=Selected Validation Rule Groups
+
+available_validationRules=Available Validation Rules
+selected_validationRules=Selected Validation Rules
+
+select_all_values=Select All Values
+deselect_all_values=Deselect All Values

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml	2013-10-03 07:24:47 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml	2013-10-30 12:51:03 +0000
@@ -310,6 +310,35 @@
       <param name="onExceptionReturn">plainTextError</param>
     </action>
 
+    <!--@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>-->
+    <action name="dxf2FilteredMetaDataExport" class="org.hisp.dhis.importexport.action.dxf2.FilterListAction">
+      <result name="success" type="velocity">/main.vm</result>
+      <param name="menu">/dhis-web-importexport/mainMenu.vm</param>
+      <param name="page">/dhis-web-importexport/dxf2FilteredMetaDataExport.vm</param>
+      <param name="javascripts">javascript/filter.js</param>
+      <param name="requiredAuthorities">F_METADATA_EXPORT</param>
+    </action>
+
+    <action name="showSortFilterForm" class="org.hisp.dhis.importexport.action.dxf2.GetFilterListSortOrderAction">
+      <result name="success" type="velocity">/main.vm</result>
+      <param name="menu">/dhis-web-importexport/mainMenu.vm</param>
+      <param name="page">/dhis-web-importexport/sortFilterForm.vm</param>
+      <param name="requiredAuthorities">F_METADATA_EXPORT</param>
+    </action>
+
+    <action name="filterExportForm" class="org.hisp.dhis.importexport.action.dxf2.FilterExportFormAction">
+      <result name="success" type="velocity">/main.vm</result>
+      <param name="menu">/dhis-web-importexport/mainMenu.vm</param>
+      <param name="page">/dhis-web-importexport/filterExportForm.vm</param>
+      <param name="javascripts">javascript/filteredMetaDataExport.js,javascript/utils.js</param>
+      <param name="requiredAuthorities">F_METADATA_EXPORT</param>
+    </action>
+
+    <action name="saveFilterListSortOrder" class="org.hisp.dhis.importexport.action.dxf2.SaveFilterListSortOrderAction">
+      <result name="success" type="redirect">dxf2FilteredMetaDataExport.action</result>
+      <param name="requiredAuthorities">F_METADATA_EXPORT</param>
+    </action>
+
   </package>
 
 </struts>

=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2FilteredMetaDataExport.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2FilteredMetaDataExport.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2FilteredMetaDataExport.vm	2013-10-30 12:51:03 +0000
@@ -0,0 +1,108 @@
+<script type="text/javascript">
+    var i18n_export = '$i18n.getString( "export" )';
+</script>
+
+##@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+
+<h3>$i18n.getString( "filtered_metadata_export" ) #openHelp( "filtered_metadata_export" )</h3>
+
+<!-- FILTER EXPORT FORM -->
+<div id="mainDivFilter" style="width: 70%;">
+    <table class="mainPageTable">
+        <tr>
+            <td style="vertical-align:top">
+                <table width="100%">
+                    <tr>
+                        <td>#filterDiv( "dxf2FilteredMetaDataExport" )</td>
+                        <td colspan="9" style="text-align:right">
+                            <form id="formFilter" method="POST" action="filterExportForm.action">
+                                <input type="hidden" name="name" value=""/>
+                                <input type="hidden" name="uid" value=""/>
+                                <input type="hidden" name="description" value=""/>
+                                <input type="hidden" name="jsonFilter" value=''/>
+                                <input type="hidden" name="command" value=""/>
+                                <input type="button" value="$i18n.getString( 'sort' )" onclick="window.location.href='showSortFilterForm.action';" style="width: 100px;"/>
+                                <input type="button" value="$i18n.getString( "add_new_filter" )" onclick="submitFilterForm( 'addNew' );" style="width: 100px;"/>
+                                <input type="button" value="$i18n.getString( "ad_hoc_export" )" onclick="submitFilterForm( 'addAdHoc' );" style="width: 140px;"/>
+                            </form>
+                        </td>
+                    </tr>
+                </table>
+
+                <!-- FILTER TABLE -->
+                <table id="filterList" class="listTable">
+                    <col/>
+                    <col width="115"/>
+                    <thead>
+                    <tr>
+                        <th>$i18n.getString( "name" )</th>
+                        <th class="{sorter: false}">$i18n.getString( "operations" )</th>
+                    </tr>
+                    </thead>
+                    <tbody id="filterTableBody">
+                        #foreach( $filter in $filters )
+                        <tr id="tr${filter.uid}">
+                            <td>$filter.name</td>
+                            <td>
+                                <a href="javascript:exportFilterButton( '$filter.uid' );" title="$i18n.getString( 'export' )"><img src="../images/start_process.png" alt="$i18n.getString( 'export' )"/></a>
+                                <a href="javascript:editFilterButton( '$filter.uid' );" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a>
+                                <a href="javascript:removeFilterButton( '$filter.uid' );" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a>
+                                <a href="javascript:showFilterDetails( '$filter.uid' );" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a>
+                            </td>
+                        </tr>
+                        #end
+                    </tbody>
+                </table>
+                <p></p>
+                #parse( "/dhis-web-commons/paging/paging.vm" )
+            </td>
+            <td id="detailsData">
+                <div id="detailsArea" style="display: none;">
+                    <div id="hideDetailsArea">
+                        <a href="javascript:hideDetails();" title="$i18n.getString( 'hide_details' )"><img src="../images/hide.png" alt="$i18n.getString( 'hide_details' )"/></a>
+                    </div>
+                    <p><label>$i18n.getString( "name" ):</label><br/><span id="nameField"></span></p>
+                    <p><label>$i18n.getString( "description" ):</label><br/><span id="descriptionField"></span></p>
+                </div>
+            </td>
+        </tr>
+    </table>
+</div>
+
+<!-- EXPORT DIALOG -->
+<div id="exportDialog" style="display: none;">
+    <form id="exportForm" action="" method="post">
+        <input type="hidden" id="exportJsonValue" name="exportJsonValue" >
+    </form>
+    <table>
+        <tr>
+            <td colspan="2">
+                <select id="format" style="width: 250px; font-size: 10pt;">
+                    <option value="xml">XML</option>
+                    <option value="json">Json</option>
+                </select>
+            </td>
+        </tr>
+        <tr>
+            <td colspan="2">
+                <select id="compression" style="width: 250px; font-size: 10pt;">
+                    <option value="zip">Zipped</option>
+                    <option value="gz">GZipped</option>
+                    <option value="uncompressed">Uncompressed</option>
+                </select>
+            </td>
+        </tr>
+        <tr>
+            <td colspan="2">
+                <input type="checkbox" id="exportDependencies" name="exportDependencies"/>
+                <label for="exportDependencies" style="font-size: 10pt;">$i18n.getString( "export_with_dependencies" ) #openHelp( "export_with_dependencies" )</label>
+            </td>
+        </tr>
+        <tr>
+            <td colspan="2">
+                <input type="hidden" id="exportJson" value=''/>
+                <input type="button" id="exportButton" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-state-active2" value="$i18n.getString( 'export' )" style="width:250px; font-size: 10pt;" onclick="exportFilteredMetaData();"/>
+            </td>
+        </tr>
+    </table>
+</div>

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2MetaDataExport.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2MetaDataExport.vm	2013-07-19 12:50:17 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2MetaDataExport.vm	2013-09-01 20:44:11 +0000
@@ -73,7 +73,6 @@
         url += "?assumeTrue=false&" + $("#exportForm").serialize();
 
         log("url" + url);
-
         window.location=url;
     }
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm	2013-09-02 10:37:36 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm	2013-09-08 17:26:58 +0000
@@ -103,4 +103,4 @@
 	
 </table>
 
-</form>
+</form>
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/filterExportForm.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/filterExportForm.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/filterExportForm.vm	2013-10-30 12:51:03 +0000
@@ -0,0 +1,367 @@
+<script type="text/javascript">
+    var i18n_export = '$i18n.getString( "export" )';
+    var i18n_select_all = '$i18n.getString( "select_all" )';
+
+    var i18n_available_attributeTypes = '$i18n.getString( "available_attribute_types" )';
+    var i18n_selected_attributeTypes = '$i18n.getString( "selected_attribute_types" )';
+
+    var i18n_available_categories = '$i18n.getString( "available_categories" )';
+    var i18n_selected_categories = '$i18n.getString( "selected_categories" )';
+
+    var i18n_available_charts = '$i18n.getString( "available_charts" )';
+    var i18n_selected_charts = '$i18n.getString( "selected_charts" )';
+
+    var i18n_available_concepts = '$i18n.getString( "available_concepts" )';
+    var i18n_selected_concepts = '$i18n.getString( "selected_concepts" )';
+
+    var i18n_available_constants = '$i18n.getString( "available_constants" )';
+    var i18n_selected_constants = '$i18n.getString( "selected_constants" )';
+
+    var i18n_available_dataDictionaries = '$i18n.getString( "available_dataDictionaries" )';
+    var i18n_selected_dataDictionaries = '$i18n.getString( "selected_dataDictionaries" )';
+
+    var i18n_available_dataElementGroupSets = '$i18n.getString( "available_dataElementGroupSets" )';
+    var i18n_selected_dataElementGroupSets = '$i18n.getString( "selected_dataElementGroupSets" )';
+
+    var i18n_available_dataElementGroups = '$i18n.getString( "available_dataElementGroups" )';
+    var i18n_selected_dataElementGroups = '$i18n.getString( "selected_dataElementGroups" )';
+
+    var i18n_available_dataElements = '$i18n.getString( "available_data_elements" )';
+    var i18n_selected_dataElements = '$i18n.getString( "selected_data_elements" )';
+
+    var i18n_available_dataSets = '$i18n.getString( "available_datasets" )';
+    var i18n_selected_dataSets = '$i18n.getString( "selected_datasets" )';
+
+    var i18n_available_documents = '$i18n.getString( "available_documents" )';
+    var i18n_selected_documents = '$i18n.getString( "selected_documents" )';
+
+    var i18n_available_indicatorGroupSets = '$i18n.getString( "available_indicatorGroupSets" )';
+    var i18n_selected_indicatorGroupSets = '$i18n.getString( "selected_indicatorGroupSets" )';
+
+    var i18n_available_indicatorGroups = '$i18n.getString( "available_indicatorGroups" )';
+    var i18n_selected_indicatorGroups = '$i18n.getString( "selected_indicatorGroups" )';
+
+    var i18n_available_indicatorTypes = '$i18n.getString( "available_indicatorTypes" )';
+    var i18n_selected_indicatorTypes = '$i18n.getString( "selected_indicatorTypes" )';
+
+    var i18n_available_indicators = '$i18n.getString( "available_indicators" )';
+    var i18n_selected_indicators = '$i18n.getString( "selected_indicators" )';
+
+    var i18n_available_mapLegendSets = '$i18n.getString( "available_mapLegendSets" )';
+    var i18n_selected_mapLegendSets = '$i18n.getString( "selected_mapLegendSets" )';
+
+    var i18n_available_maps = '$i18n.getString( "available_maps" )';
+    var i18n_selected_maps = '$i18n.getString( "selected_maps" )';
+
+    var i18n_available_optionSets = '$i18n.getString( "available_optionSets" )';
+    var i18n_selected_optionSets = '$i18n.getString( "selected_optionSets" )';
+
+    var i18n_available_organisationUnitGroupSets = '$i18n.getString( "available_organisationUnitGroupSets" )';
+    var i18n_selected_organisationUnitGroupSets = '$i18n.getString( "selected_organisationUnitGroupSets" )';
+
+    var i18n_available_organisationUnitGroups = '$i18n.getString( "available_organisationUnitGroups" )';
+    var i18n_selected_organisationUnitGroups = '$i18n.getString( "selected_organisationUnitGroups" )';
+
+    var i18n_available_organisationUnitLevels = '$i18n.getString( "available_organisationUnitLevels" )';
+    var i18n_selected_organisationUnitLevels = '$i18n.getString( "selected_organisationUnitLevels" )';
+
+    var i18n_available_organisationUnits = '$i18n.getString( "available_organisationUnits" )';
+    var i18n_selected_organisationUnits = '$i18n.getString( "selected_organisationUnits" )';
+
+    var i18n_available_reportTables = '$i18n.getString( "available_reportTables" )';
+    var i18n_selected_reportTables = '$i18n.getString( "selected_reportTables" )';
+
+    var i18n_available_reports = '$i18n.getString( "available_reports" )';
+    var i18n_selected_reports = '$i18n.getString( "selected_reports" )';
+
+    var i18n_available_sqlViews = '$i18n.getString( "available_sqlViews" )';
+    var i18n_selected_sqlViews = '$i18n.getString( "selected_sqlViews" )';
+
+    var i18n_available_userGroups = '$i18n.getString( "available_userGroups" )';
+    var i18n_selected_userGroups = '$i18n.getString( "selected_userGroups" )';
+
+    var i18n_available_userRoles = '$i18n.getString( "available_userRoles" )';
+    var i18n_selected_userRoles = '$i18n.getString( "selected_userRoles" )';
+
+    var i18n_available_users = '$i18n.getString( "available_users" )';
+    var i18n_selected_users = '$i18n.getString( "selected_users" )';
+
+    var i18n_available_validationRuleGroups = '$i18n.getString( "available_validationRuleGroups" )';
+    var i18n_selected_validationRuleGroups = '$i18n.getString( "selected_validationRuleGroups" )';
+
+    var i18n_available_validationRules = '$i18n.getString( "available_validationRules" )';
+    var i18n_selected_validationRules = '$i18n.getString( "selected_validationRules" )';
+
+    var i18n_validate_filter = '$i18n.getString( "validate_filter" )';
+
+    var i18n_move_selected = '$i18n.getString( "move_selected" )';
+    var i18n_remove_selected = '$i18n.getString( "remove_selected" )';
+    var i18n_move_all = '$i18n.getString( "move_all" )';
+    var i18n_remove_all = '$i18n.getString( "remove_all" )';
+    var i18n_filter = '$i18n.getString( "filter" )';
+</script>
+
+##@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+
+#if ($command == "addNew")
+    <h3>$i18n.getString( "create_new_filter" )</h3>
+#elseif($command == "update")
+    <h3>$i18n.getString( "edit_filter" )</h3>
+#elseif($command == "addAdHoc")
+    <h3>$i18n.getString( "ad_hoc_export" )</h3>
+#end
+
+<!-- FILTER FORM -->
+<form id="formFilter" name="formFilter" class="inputForm">
+    <input type="hidden" id="jsonFilter" name="jsonFilter" value='$filter.jsonFilter'/>
+    #if ($command == "addNew" || $command == "addAdHoc")
+        <input type="hidden" id="uid" name="uid" value=""/>
+    #elseif ($command == "update")
+        <input type="hidden" id="uid" name="uid" value="$filter.uid"/>
+    #end
+
+    #if ($command == "addNew" || $command == "update")
+        <div>
+            <table id="detailsList" style="width: 400px;">
+                <tr>
+                    <th colspan="2">$i18n.getString( "filter_details" )</th>
+                </tr>
+                <tr>
+                    <td><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+                    <td>
+                        <input type="text" id="name" name="name" maxlength="150" value="$filter.name" style="width: 100%;">
+                    </td>
+                </tr>
+                <tr>
+                    <td><label>$i18n.getString( "description" )</label></td>
+                    <td>
+                        <input type="text" id="description" name="description" value="$filter.description" style="width: 100%;">
+                    </td>
+                </tr>
+            </table>
+        </div>
+    #end
+</form>
+
+<!-- METADATA ACCORDION -->
+<div id="mainDivAccordion" style="margin-bottom: 10px; margin-top: 10px; width: 90%;">
+    <!-- ATTRIBUTES TYPES SELECTION -->
+    <h6 id="headingAttributeTypes" style="font-size: 10pt;"><label>$i18n.getString( "attribute_types" )</label></h6>
+
+    <div id="mainDivAttributeTypes" style="margin: 5px;"></div>
+
+    <!-- CATEGORIES SELECTION -->
+    <h6 id="headingDimensions" style="font-size: 10pt;"><label>$i18n.getString( "categories" )</label></h6>
+
+    <div id="mainDivDimensions" style="margin: 5px;"></div>
+
+    <!-- CHARTS SELECTION -->
+    <h6 id="headingCharts" style="font-size: 10pt;"><label>$i18n.getString( "charts" )</label></h6>
+
+    <div id="mainDivCharts" style="margin: 5px;"></div>
+
+    <!-- CONCEPTS SELECTION -->
+    <h6 id="headingConcepts" style="font-size: 10pt;"><label>$i18n.getString( "concepts" )</label></h6>
+
+    <div id="mainDivConcepts" style="margin: 5px;"></div>
+
+    <!-- CONSTANTS SELECTION -->
+    <h6 id="headingConstants" style="font-size: 10pt;"><label>$i18n.getString( "constants" )</label></h6>
+
+    <div id="mainDivConstants" style="margin: 5px;"></div>
+
+    <!-- DATA DICTIONARIES SELECTION -->
+    <h6 id="headingDataDictionaries" style="font-size: 10pt;"><label>$i18n.getString( "data_dictionaries" )</label></h6>
+
+    <div id="mainDivDataDictionaries" style="margin: 5px;"></div>
+
+    <!-- DATA ELEMENT GROUP SETS SELECTION -->
+    <h6 id="headingDataElementGroupSets" style="font-size: 10pt;"><label>$i18n.getString( "data_element_group_sets" )</label></h6>
+
+    <div id="mainDivDataElementGroupSets" style="margin: 5px;"></div>
+
+    <!-- DATA ELEMENT GROUPS SELECTION -->
+    <h6 id="headingDataElementGroups" style="font-size: 10pt;"><label>$i18n.getString( "data_element_groups" )</label></h6>
+
+    <div id="mainDivDataElementGroups" style="margin: 5px;"></div>
+
+    <!-- DATA ELEMENTS SELECTION -->
+    <h6 id="headingDataElements" style="font-size: 10pt;"><label>$i18n.getString( "data_elements" )</label></h6>
+
+    <div id="mainDivDataElements" style="margin: 5px;"></div>
+
+    <!-- DATA SETS SELECTION -->
+    <h6 id="headingDataSets" style="font-size: 10pt;"><label>$i18n.getString( "data_sets" )</label></h6>
+
+    <div id="mainDivDataSets" style="margin: 5px;"></div>
+
+    <!-- DOCUMENTS SELECTION -->
+    <h6 id="headingDocuments" style="font-size: 10pt;"><label>$i18n.getString( "documents" )</label></h6>
+
+    <div id="mainDivDocuments" style="margin: 5px;"></div>
+
+    <!-- INDICATOR GROUP SETS SELECTION -->
+    <h6 id="headingIndicatorGroupSets" style="font-size: 10pt;"><label>$i18n.getString( "indicator_group_sets" )</label></h6>
+
+    <div id="mainDivIndicatorGroupSets" style="margin: 5px;"></div>
+
+    <!-- INDICATOR GROUPS SELECTION -->
+    <h6 id="headingIndicatorGroups" style="font-size: 10pt;"><label>$i18n.getString( "indicator_groups" )</label></h6>
+
+    <div id="mainDivIndicatorGroups" style="margin: 5px;"></div>
+
+    <!-- INDICATOR TYPES SELECTION -->
+    <h6 id="headingIndicatorTypes" style="font-size: 10pt;"><label>$i18n.getString( "indicator_types" )</label></h6>
+
+    <div id="mainDivIndicatorTypes" style="margin: 5px;"></div>
+
+    <!-- INDICATORS SELECTION -->
+    <h6 id="headingIndicators" style="font-size: 10pt;"><label>$i18n.getString( "indicators" )</label></h6>
+
+    <div id="mainDivIndicators" style="margin: 5px;"></div>
+
+    <!-- MAP LEGEND SETS SELECTION -->
+    <h6 id="headingMapLegendSets" style="font-size: 10pt;"><label>$i18n.getString( "map_legend_sets" )</label></h6>
+
+    <div id="mainDivMapLegendSets" style="margin: 5px;"></div>
+
+    <!-- MAPS SELECTION -->
+    <h6 id="headingMaps" style="font-size: 10pt;"><label>$i18n.getString( "maps" )</label></h6>
+
+    <div id="mainDivMaps" style="margin: 5px;"></div>
+
+    <!-- OPTION SETS SELECTION -->
+    <h6 id="headingOptionSets" style="font-size: 10pt;"><label>$i18n.getString( "option_sets" )</label></h6>
+
+    <div id="mainDivOptionSets" style="margin: 5px;"></div>
+
+    <!-- ORGANISATION UNIT GROUP SETS SELECTION -->
+    <h6 id="headingOrganisationUnitGroupSets" style="font-size: 10pt;"><label>$i18n.getString( "organisation_unit_group_sets" )</label></h6>
+
+    <div id="mainDivOrganisationUnitGroupSets" style="margin: 5px;"></div>
+
+    <!-- ORGANISATION UNIT GROUPS SELECTION -->
+    <h6 id="headingOrganisationUnitGroups" style="font-size: 10pt;"><label>$i18n.getString( "organisation_unit_groups" )</label></h6>
+
+    <div id="mainDivOrganisationUnitGroups" style="margin: 5px;"></div>
+
+    <!-- ORGANISATION UNIT LEVELS SELECTION -->
+    <h6 id="headingOrganisationUnitLevels" style="font-size: 10pt;"><label>$i18n.getString( "organisation_unit_levels" )</label></h6>
+
+    <div id="mainDivOrganisationUnitLevels" style="margin: 5px;"></div>
+
+    <!-- ORGANISATION UNITS SELECTION -->
+    <h6 id="headingOrganisationUnits" style="font-size: 10pt;"><label>$i18n.getString( "organisation_units" )</label></h6>
+
+    <div id="mainDivOrganisationUnits" style="margin: 5px;"></div>
+
+    <!-- REPORT TABLES SELECTION -->
+    <h6 id="headingReportTables" style="font-size: 10pt;"><label>$i18n.getString( "report_tables" )</label></h6>
+
+    <div id="mainDivReportTables" style="margin: 5px;"></div>
+
+    <!-- REPORTS SELECTION -->
+    <h6 id="headingReports" style="font-size: 10pt;"><label>$i18n.getString( "reports" )</label></h6>
+
+    <div id="mainDivReports" style="margin: 5px;"></div>
+
+    <!-- SQL VIEWS SELECTION -->
+    <h6 id="headingSqlViews" style="font-size: 10pt;"><label>$i18n.getString( "sql_views" )</label></h6>
+
+    <div id="mainDivSqlViews" style="margin: 5px;"></div>
+
+    <!-- USER GROUPS SELECTION -->
+    <h6 id="headingUserGroups" style="font-size: 10pt;"><label>$i18n.getString( "user_groups" )</label></h6>
+
+    <div id="mainDivUserGroups" style="margin: 5px;"></div>
+
+    <!-- USER ROLES SELECTION -->
+    <h6 id="headingUserRoles" style="font-size: 10pt;"><label>$i18n.getString( "user_roles" )</label></h6>
+
+    <div id="mainDivUserRoles" style="margin: 5px;"></div>
+
+    <!-- USERS SELECTION -->
+    <h6 id="headingUsers" style="font-size: 10pt;"><label>$i18n.getString( "users" )</label></h6>
+
+    <div id="mainDivUsers" style="margin: 5px;"></div>
+
+    <!-- VALIDATION RULE GROUPS SELECTION -->
+    <h6 id="headingValidationRuleGroups" style="font-size: 10pt;"><label>$i18n.getString( "validation_rule_groups" )</label></h6>
+
+    <div id="mainDivValidationRuleGroups" style="margin: 5px;"></div>
+
+    <!-- VALIDATION RULES SELECTION -->
+    <h6 id="headingValidationRules" style="font-size: 10pt;"><label>$i18n.getString( "validation_rules" )</label></h6>
+
+    <div id="mainDivValidationRules" style="margin: 5px;"></div>
+</div>
+
+<!-- METADATA ACCORDION COMMANDS -->
+<div>
+    <table id="detailsList">
+        <tr>
+            <td colspan="2">
+                <input type="button" value="$i18n.getString( 'select_all_values' )" style="width:125px;" onclick="selectAllValues();"/>
+                <input type="button" value="$i18n.getString( 'deselect_all_values' )" style="width:125px;" onclick="deselectAllValues();"/>
+            </td>
+        </tr>
+        <tr>
+            #if($command == "addNew")
+                <td colspan="2">
+                    <input type="button" value="$i18n.getString( 'add_new' )" onclick="saveFilter();" style="width:125px" />
+                    <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.history.back();" style="width:125px" />
+                </td>
+            #elseif ($command == "update")
+                <td colspan="2">
+                    <input type="button" value="$i18n.getString( 'save' )" onclick="updateFilter();" style="width:125px" />
+                    <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.history.back();" style="width:125px" />
+                </td>
+            #elseif($command == "addAdHoc")
+                <td colspan="2">
+                    <input type="button" value="$i18n.getString( 'export' )" onclick="startExport();" style="width:125px" />
+                    <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.history.back();" style="width:125px" />
+                </td>
+            #end
+        </tr>
+    </table>
+</div>
+
+<!-- EXPORT DIALOG -->
+#if($command == "addAdHoc")
+    <div id="exportDialog" style="display: none;">
+        <form id="exportForm" action="" method="post">
+            <input type="hidden" id="exportJsonValue" name="exportJsonValue" >
+        </form>
+        <table>
+            <tr>
+                <td colspan="2">
+                    <select id="format" style="width: 250px; font-size: 10pt;">
+                        <option value="xml">XML</option>
+                        <option value="json">Json</option>
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <td colspan="2">
+                    <select id="compression" style="width: 250px; font-size: 10pt;">
+                        <option value="zip">Zipped</option>
+                        <option value="gz">GZipped</option>
+                        <option value="uncompressed">Uncompressed</option>
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <td colspan="2">
+                    <input type="checkbox" id="exportDependencies" name="exportDependencies"/>
+                    <label for="exportDependencies" style="font-size: 10pt;">$i18n.getString( "export_with_dependencies" ) #openHelp( "exportDependencies" )</label>
+                </td>
+            </tr>
+            <tr>
+                <td colspan="2">
+                    <input type="hidden" id="exportJson" value=''/>
+                    <input type="button" id="exportButton" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-state-active2" value="$i18n.getString( 'export' )" style="width:250px; font-size: 10pt;" onclick="exportFilteredMetaData();"/>
+                </td>
+            </tr>
+        </table>
+    </div>
+#end

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/index.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/index.vm	2013-10-01 13:16:44 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/index.vm	2013-10-30 12:51:03 +0000
@@ -9,6 +9,8 @@
     #introListImgItem( "displayExternalImportMenu.action" "dhis14_import" "import" )
 
     #introListImgItem( "dxf2MetaDataExport.action" "metadata_export" "export" )
+##  @author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+    #introListImgItem( "dxf2FilteredMetaDataExport.action" "filtered_metadata_export" "export")
     #introListImgItem( "displayDataValueExportForm.action" "data_export" "export" )
     #introListImgItem( "displayEventExportForm.action" "event_data_export" "export" )
     #introListImgItem( "displayExternalExportMenu.action" "export_to_other_systems" "export" )

=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/detailedMetaDataImport.js'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/detailedMetaDataImport.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/detailedMetaDataImport.js	2013-09-16 13:33:28 +0000
@@ -0,0 +1,434 @@
+//@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+
+// Global Variables
+var metaDataArray = [ "AttributeTypes", "Dimensions", "Charts", "Concepts", "Constants", "DataDictionaries", "DataElementGroupSets",
+    "DataElementGroups", "DataElements", "DataSets", "Documents", "IndicatorGroupSets", "IndicatorGroups", "Indicators",
+    "IndicatorTypes", "MapLegendSets", "Maps", "OptionSets", "OrganisationUnitGroupSets", "OrganisationUnitGroups",
+    "OrganisationUnitLevels", "OrganisationUnits", "ReportTables", "Reports", "SqlViews", "UserGroups", "UserRoles",
+    "Users", "ValidationRuleGroups", "ValidationRules" ];
+
+// -----------------------------------------------------------------------------
+// MetaData Category Accordion
+// -----------------------------------------------------------------------------
+jQuery( function ()
+{
+    if ( !jQuery.isEmptyObject( metaDataJson ) )
+    {
+        loadMetaDataCategories( metaDataJson );
+        $( "#mainDivAccordion" ).accordion(
+            {
+                active: false,
+                collapsible: true,
+                clearStyle: true,
+                autoHeight: false
+            } );
+
+        selectAllMetaDataCategories();
+        selectAllValues();
+        loadMetaDataAccordionEvents( metaDataJson );
+    }
+
+    loadFile();
+} );
+
+// Collapsed MetaData Category information
+function loadMetaDataCategories( metaData )
+{
+    for ( var i = 0; i < metaDataArray.length; i++ )
+    {
+        if ( metaData.hasOwnProperty( lowercaseFirstLetter( metaDataArray[i] ) ) )
+        {
+            $( "#heading" + metaDataArray[i] ).show();
+            $( "#div" + metaDataArray[i] ).show();
+            $( "#metaDataCommands" ).show();
+
+            insertMetaDataCategoryHeadingDesign( metaDataArray[i] );
+            preventAccordionCollapse( metaDataArray[i] );
+
+            $( "#checkboxSelectAll" + metaDataArray[i] ).change( function ()
+            {
+                var metaDataCategoryName = $( this ).attr( "name" );
+
+                if ( $( this ).is( ":checked" ) )
+                {
+                    selectAllValuesByCategory( metaDataCategoryName );
+                } else
+                {
+                    deselectValuesByCategory( metaDataCategoryName );
+                }
+            } );
+        } else
+        {
+            metaDataArray.splice( i, 1 );
+            i--;
+        }
+    }
+}
+
+// Insert MetaData HTML & CSS heading design
+function insertMetaDataCategoryHeadingDesign( metaDataCategoryName )
+{
+    var design = generateMetaDataHeadingDesign( metaDataCategoryName );
+    $( "#heading" + metaDataCategoryName ).append( design );
+}
+
+// Insert MetaData HTML & CSS for a Category
+function insertMetaDataCategoryDesign( metaDataCategoryName )
+{
+    if ( $( "#mainDiv" + metaDataCategoryName ).is( ":empty" ) )
+    {
+        var design = generateMetaDataCategoryDesign( metaDataCategoryName );
+        $( "#mainDiv" + metaDataCategoryName ).append( design );
+        loadMetaData( metaDataCategoryName );
+    } else
+    {
+        $( "#mainDiv" + metaDataCategoryName ).show();
+        deselectAllValues();
+    }
+}
+
+// Generate MetaData Heading design
+function generateMetaDataHeadingDesign( metaDataCategoryName )
+{
+    var design =
+            '<div id="divSelectAll' + metaDataCategoryName + '" style="float: right;">'
+          +     '<input id="checkboxSelectAll' + metaDataCategoryName + '" name="' + metaDataCategoryName + '" type="checkbox"/>'
+          +     '<label id="labelSelectAll' + metaDataCategoryName + '" for="' + metaDataCategoryName + '" style="font-size: 10pt;">' + i18n_select_all + '</label>'
+          + '</div>'
+        ;
+
+    return design;
+}
+
+// Generate MetaData HTML & CSS for a Category
+function generateMetaDataCategoryDesign( metaDataCategoryName )
+{
+    var i18n_available_metadata = getI18nAvailableMetaData( metaDataCategoryName );
+    var i18n_selected_metadata = getI18nSelectedMetaData( metaDataCategoryName );
+    var design =
+                  '<table id="selectionArea'+metaDataCategoryName + '" style="border: 1px solid #ccc; padding: 15px;  margin-top: 10px; margin-bottom: 10px;">'
+                + '<colgroup>'
+                +    '<col style="width: 500px;"/>'
+                +    '<col/>'
+                +    '<col style="width: 500px"/>'
+                + '</colgroup>'
+                + '<thead>'
+                +    '<tr>'
+                +        '<th>' + i18n_available_metadata + '</th>'
+                +        '<th>' + i18n_filter + '</th>'
+                +        '<th>' + i18n_selected_metadata + '</th>'
+                +    '</tr>'
+                + '</thead>'
+                +        '<tbody>'
+                +            '<tr>'
+                +                '<td>'
+                +                   '<select id="available' + metaDataCategoryName + '" multiple="multiple" style="height: 200px; width: 100%; margin-top: 10px;"></select>'
+                +               '</td>'
+                +               '<td>'
+                +                   '<input id="moveSelected' + metaDataCategoryName +'" type="button" value="&gt;" title="' + i18n_move_selected + '" style="width:50px"'
+                +                       'onclick="moveSelected( \'' + metaDataCategoryName + '\' );"/><br/>'
+                +                   '<input id="removeSelected' + metaDataCategoryName + '" type="button" value="&lt;" title="' + i18n_remove_selected + '" style="width:50px"'
+                +                       'onclick="removeSelected( \'' + metaDataCategoryName + '\' );"/><br/>'
+                +                   '<input id="select' + metaDataCategoryName + '" type="button" value="&gt;&gt;" title="' + i18n_move_all + '" style="width:50px"'
+                +                       'onclick="moveAll( \'' + metaDataCategoryName + '\' );"/><br/>'
+                +                   '<input id="deselect' + metaDataCategoryName + '" type="button" value="&lt;&lt;" title="' + i18n_remove_all +  '" style="width:50px"'
+                +                       'onclick="removeAll( \'' + metaDataCategoryName + '\' );"/><br/>'
+                +               '</td>'
+                +               '<td>'
+                +                   '<select id="selected' + metaDataCategoryName + '" name="selected' + metaDataCategoryName + '" multiple="multiple" style="height: 200px; width: 100%; margin-top: 10px;"></select>'
+                +               '</td>'
+                +           '</tr>'
+                +       '</tbody>'
+                + '</table>'
+        ;
+
+    return design;
+}
+
+// Move all selected items
+function moveSelected( metaDataCategoryName )
+{
+    $( "#available" + metaDataCategoryName + " option:selected" ).each( function ()
+    {
+        $( "#checkboxSelectAll" + metaDataCategoryName ).attr( "checked", true );
+
+        var option = jQuery( "<option/>" );
+        option.text( $( this ).attr( "name" ) );
+        option.attr( "name", $( this ).attr( "name" ) );
+        option.attr( "value", $( this ).attr( "value" ) );
+        option.attr( "selected", "selected" );
+
+        $( "#selected" + metaDataCategoryName ).append( option );
+        $( this ).remove();
+    } );
+
+    if ( $( "#selected" + metaDataCategoryName + " option" ).length > 0 )
+    {
+        $( "#heading" + metaDataCategoryName ).css( "background", "#CFFFB3 50% 50% repeat-x" );
+    }
+}
+
+// Remove all selected items
+function removeSelected( metaDataCategoryName )
+{
+    $( "#selected" + metaDataCategoryName + " option:selected" ).each( function ()
+    {
+        var option = jQuery( "<option/>" );
+        option.text( $( this ).attr( "name" ) );
+        option.attr( "name", $( this ).attr( "name" ) );
+        option.attr( "value", $( this ).attr( "value" ) );
+        option.attr( "selected", "selected" );
+
+        $( "#available" + metaDataCategoryName ).append( option );
+        $( this ).remove();
+    } );
+
+    if ( $( "#selected" + metaDataCategoryName + " option" ).length == 0 )
+    {
+        $( "#heading" + metaDataCategoryName ).css( "background", "" );
+    }
+
+    if ( $( "#available" + metaDataCategoryName + " option" ).length > 0 )
+    {
+        $( "#checkboxSelectAll" + metaDataCategoryName ).attr( "checked", false );
+    }
+}
+
+// Move all items
+function moveAll( metaDataCategoryName )
+{
+    $( "#available" + metaDataCategoryName + " option" ).each( function ()
+    {
+        var option = jQuery( "<option/>" );
+        option.text( $( this ).attr( "name" ) );
+        option.attr( "name", $( this ).attr( "name" ) );
+        option.attr( "value", $( this ).attr( "value" ) );
+        option.attr( "selected", "selected" );
+
+        $( "#selected" + metaDataCategoryName ).append( option );
+        $( this ).remove();
+    } );
+
+    $( "#checkboxSelectAll" + metaDataCategoryName ).attr( "checked", true );
+    $( "#heading" + metaDataCategoryName ).css( "background", "#CFFFB3 50% 50% repeat-x" );
+}
+
+// Remove all items
+function removeAll( metaDataCategoryName )
+{
+    $( "#selected" + metaDataCategoryName + " option" ).each( function ()
+    {
+        var option = jQuery( "<option/>" );
+        option.text( $( this ).attr( "name" ) );
+        option.attr( "name", $( this ).attr( "name" ) );
+        option.attr( "value", $( this ).attr( "value" ) );
+        option.attr( "selected", "selected" );
+
+        $( "#available" + metaDataCategoryName ).append( option );
+        $( this ).remove();
+    } );
+
+    $( "#checkboxSelectAll" + metaDataCategoryName ).attr( "checked", false );
+    $( "#heading" + metaDataCategoryName ).css( "background", "" );
+}
+
+// -----------------------------------------------------------------------------
+// Load MetaData by Category
+// -----------------------------------------------------------------------------
+
+// Load MetaData by Category
+function loadMetaData( metaDataCategoryName )
+{
+    var metaDataCategoryProperty = lowercaseFirstLetter( metaDataCategoryName );
+    if ( metaDataJson.hasOwnProperty( metaDataCategoryProperty ) )
+    {
+        var metaDataCategoryArray = metaDataJson[metaDataCategoryProperty];
+        for ( var i = 0; i < metaDataCategoryArray.length; i++ )
+        {
+            var option = jQuery( "<option/>" );
+            option.text( metaDataCategoryArray[i].name );
+            option.attr( "name", metaDataCategoryArray[i].name );
+            option.attr( "value", metaDataCategoryArray[i].id );
+            option.attr( "selected", "selected" );
+
+            $( "#selected" + metaDataCategoryName ).append( option );
+            $( "#heading" + metaDataCategoryName ).css( "background", "#CFFFB3 50% 50% repeat-x" );
+        }
+    }
+}
+
+// -----------------------------------------------------------------------------
+// MetaData Category Accordion Commands
+// -----------------------------------------------------------------------------
+
+// Load MetaData Category Accordion Events
+function loadMetaDataAccordionEvents( metaData )
+{
+    for ( var i = 0; i < metaDataArray.length; i++ )
+    {
+        if ( metaData.hasOwnProperty( lowercaseFirstLetter( metaDataArray[i] ) ) )
+        {
+            $( "#heading" + metaDataArray[i] ).click( {metaDataCategoryName: metaDataArray[i]}, selectMetaDataCategoryByHeading );
+        }
+    }
+}
+
+// Select a MetaData Category from the MetaData accordion by heading
+function selectMetaDataCategoryByHeading( categoryName )
+{
+    var metaDataCategoryName = categoryName.data.metaDataCategoryName;
+    if ( $( "#mainDiv" + metaDataCategoryName ).children().length == 0 )
+    {
+        insertMetaDataCategoryDesign( metaDataCategoryName );
+    }
+}
+
+// Select a MetaData Category from the MetaData accordion
+function selectMetaDataCategory( metaDataCategoryName )
+{
+    if ( $( "#mainDiv" + metaDataCategoryName ).children().length == 0 )
+    {
+        insertMetaDataCategoryDesign( metaDataCategoryName );
+    }
+}
+
+// Select all MetaData categories from the accordion
+function selectAllMetaDataCategories()
+{
+    for ( var i = 0; i < metaDataArray.length; i++ )
+    {
+        selectMetaDataCategory( metaDataArray[i] );
+    }
+}
+
+// Select all values
+function selectAllValues()
+{
+    for ( var i = 0; i < metaDataArray.length; i++ )
+    {
+        $( "#select" + metaDataArray[i] ).click();
+    }
+}
+
+// Deselect all values
+function deselectAllValues()
+{
+    for ( var i = 0; i < metaDataArray.length; i++ )
+    {
+        $( "#deselect" + metaDataArray[i] ).click();
+        $( "#available" + metaDataArray[i] ).find( "option" ).each( function ()
+        {
+            $( this ).prop( "selected", false );
+        } );
+    }
+}
+
+// Select all values by category
+function selectAllValuesByCategory( metaDataCategoryName )
+{
+    $( "#select" + metaDataCategoryName ).click();
+}
+
+// Deselect all values by category
+function deselectValuesByCategory( metaDataCategoryName )
+{
+    $( "#deselect" + metaDataCategoryName ).click();
+
+    $( "#available" + metaDataCategoryName ).find( "option" ).each( function ()
+    {
+        $( this ).prop( "selected", false );
+    } );
+}
+
+// -----------------------------------------------------------------------------
+// Process file
+// -----------------------------------------------------------------------------
+
+// Load file
+function loadFile()
+{
+    $( "#upload" ).change( function ()
+    {
+        $( "#loadFile" ).submit();
+    } );
+}
+
+// -----------------------------------------------------------------------------
+// Process import MetaData Json
+// -----------------------------------------------------------------------------
+
+// Process import MetaData Json
+function processImportMetaDataJson()
+{
+    for ( var i = 0; i < metaDataArray.length; i++ )
+    {
+        var metaDataCategoryProperty = lowercaseFirstLetter( metaDataArray[i] );
+
+        if ( metaDataJson.hasOwnProperty( metaDataCategoryProperty ) )
+        {
+            var metaDataCategoryArray = metaDataJson[metaDataCategoryProperty];
+            for ( var j = 0; j < metaDataCategoryArray.length; j++ )
+            {
+                var existsMetaDataCategoryOption = $( "#selected" + metaDataArray[i] + " option[value='" + metaDataCategoryArray[j].id + "']" ).length !== 0;
+
+                if ( !existsMetaDataCategoryOption )
+                {
+                    (metaDataJson[metaDataCategoryProperty]).splice( j, 1 );
+                    j--;
+                }
+            }
+
+            if ( metaDataJson[metaDataCategoryProperty].length == 0 )
+            {
+                delete metaDataJson[metaDataCategoryProperty];
+            }
+        }
+    }
+
+    return metaDataJson;
+}
+
+// -----------------------------------------------------------------------------
+// Import
+// -----------------------------------------------------------------------------
+
+// Import detailed MetaData
+function importDetailedMetaData()
+{
+    var importMetaDataJson = {};
+
+    importMetaDataJson.metaData = processImportMetaDataJson();
+    importMetaDataJson.dryRun = $("#dryRun" ).find(":selected" ).val();
+    importMetaDataJson.strategy = $("#strategy" ).find(":selected" ).val();
+
+    $.ajax(
+        {
+            type: "POST",
+            url: "../api/filteredMetaData/importDetailedMetaData",
+            data: JSON.stringify( importMetaDataJson ),
+            contentType: "application/json",
+            success: function ()
+            {
+                console.log( "Exported JSON: " + JSON.stringify( importMetaDataJson ) );
+            },
+            error: function ( request, status, error )
+            {
+                console.log( request.responseText );
+                console.log( arguments );
+                alert( "Import process failed." );
+            }
+        } );
+}
+
+// -----------------------------------------------------------------------------
+// Utils
+// -----------------------------------------------------------------------------
+
+// Stop accordion collapse
+function preventAccordionCollapse( metaDataCategoryName )
+{
+    $( "#heading" + metaDataCategoryName ).find( "input" ).click( function ( e )
+    {
+        e.stopPropagation();
+    } );
+}

=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filter.js'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filter.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filter.js	2013-10-30 12:51:03 +0000
@@ -0,0 +1,176 @@
+
+// Global Variables
+var filters = [];
+
+// -----------------------------------------------------------------------------
+// Document ready
+// -----------------------------------------------------------------------------
+jQuery( function ()
+    {
+        tableSorter( "filterList" );
+        loadFilters();
+    }
+);
+
+// Create a new Filter form
+function submitFilterForm( command )
+{
+    $( "input[name='command']" ).val( command );
+    $( "#formFilter" ).submit();
+}
+
+// -----------------------------------------------------------------------------
+// Load Filters
+// -----------------------------------------------------------------------------
+
+// Load Filters
+function loadFilters()
+{
+    $.ajax( {
+        type: "GET",
+        url: "../api/filteredMetaData/getFilters",
+        dataType: "json",
+        success: function( response ) {
+            filters = response;
+        },
+        error: function( request, status, error ) {
+            alert("Getting filters process failed.");
+        }
+    });
+}
+
+// Show Filter details
+function showFilterDetails( filterUid )
+{
+    $( "#detailsArea" ).show( "fast" );
+    for ( var i = 0; i < filters.length; i++ )
+    {
+        if ( filters[i].id == filterUid )
+        {
+            setInnerHTML( 'nameField', filters[i].name );
+            setInnerHTML( 'descriptionField', filters[i].description );
+        }
+    }
+}
+
+// -----------------------------------------------------------------------------
+// Export Filtered MetaData
+// -----------------------------------------------------------------------------
+
+// Start export
+function exportFilterButton( filterUid )
+{
+    for ( var i = 0; i < filters.length; i++ )
+    {
+        if ( filters[i].id == filterUid )
+        {
+            $( "#exportJson" ).attr( "value", filters[i].metaDataUids );
+            jQuery( "#exportDialog" ).dialog( {
+                title: i18n_export,
+                modal: true
+            } );
+        }
+    }
+}
+
+// Export MetaData
+function exportFilteredMetaData()
+{
+    var exportJson = {};
+    exportJson.exportDependencies = $( "#exportDependencies" ).is( ":checked" ).toString();
+    exportJson.metaDataUids = $( "#exportJson" ).val();
+
+    $( "#exportJsonValue" ).val( JSON.stringify( exportJson ) );
+
+    document.getElementById( 'exportForm' ).action = getURL();
+    $( "#exportForm" ).submit();
+    $( "#exportDialog" ).dialog( "close" );
+}
+
+// Generate Export URL
+function getURL()
+{
+    var url = "../api/filteredMetaData";
+    var format = $( "#format" ).val();
+    var compression = $( "#compression" ).val();
+    url += "." + format;
+
+    if(compression == "zip")
+    {
+        url += ".zip";
+    }
+    else if(compression == "gz")
+    {
+        url += ".gz";
+    }
+
+    return url;
+}
+
+// -----------------------------------------------------------------------------
+// Edit a Filter
+// -----------------------------------------------------------------------------
+
+// Edit a Filter
+function editFilterButton( filterUid )
+{
+    for ( var i = 0; i < filters.length; i++ )
+    {
+        if ( filters[i].id == filterUid )
+        {
+            $( "input[name='name']" ).val( filters[i].name );
+            $( "input[name='description']" ).val( filters[i].description );
+            $( "input[name='uid']" ).val( filters[i].id );
+            $( "input[name='metaDataUids']" ).val( filters[i].metaDataUids );
+            $( "input[name='command']" ).val( "update" );
+        }
+    }
+
+    $( "#formFilter" ).submit();
+}
+
+// -----------------------------------------------------------------------------
+// Delete a Filter
+// -----------------------------------------------------------------------------
+
+// Delete a Filter
+function removeFilterButton( filterUid )
+{
+    var filter = {};
+    for ( var i = 0; i < filters.length; i++ )
+    {
+        if ( filters[i].id == filterUid )
+        {
+            filter = filters[i];
+        }
+    }
+
+    var json = JSON.stringify( replaceIdWithUid( filter ) );
+
+    $.ajax( {
+        type: "POST",
+        url: "../api/filteredMetaData/deleteFilter",
+        contentType: "application/json",
+        data: json,
+        success: function ()
+        {
+            $( "#tr" + filter.uid ).remove();
+        },
+        error: function ( request, status, error )
+        {
+            alert( "Remove filter process failed." );
+        }
+    } );
+}
+
+// -----------------------------------------------------------------------------
+// Utils
+// -----------------------------------------------------------------------------
+
+// Replace id with uid
+function replaceIdWithUid( object )
+{
+    object.uid = object.id;
+    delete object.id;
+    return object;
+}

=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filteredMetaDataExport.js'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filteredMetaDataExport.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filteredMetaDataExport.js	2013-10-30 12:51:03 +0000
@@ -0,0 +1,536 @@
+//@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+
+// Global Variables
+var metaDataArray = [ "AttributeTypes", "Dimensions", "Charts", "Concepts", "Constants", "DataDictionaries", "DataElementGroupSets",
+    "DataElementGroups", "DataElements", "DataSets", "Documents", "IndicatorGroupSets", "IndicatorGroups", "Indicators",
+    "IndicatorTypes", "MapLegendSets", "Maps", "OptionSets", "OrganisationUnitGroupSets", "OrganisationUnitGroups",
+    "OrganisationUnitLevels", "OrganisationUnits", "ReportTables", "Reports", "SqlViews", "UserGroups", "UserRoles",
+    "Users", "ValidationRuleGroups", "ValidationRules" ];
+
+// -----------------------------------------------------------------------------
+// MetaData Category Accordion
+// -----------------------------------------------------------------------------
+jQuery( function ()
+{
+    loadMetaDataCategories();
+
+    $( "#mainDivAccordion" ).accordion( {
+        active: false,
+        collapsible: true,
+        clearStyle: true,
+        autoHeight: false
+    } );
+
+    loadMetaDataAccordionEvents();
+
+    // TODO: Improve performance on applying filters
+    if ( $( "#jsonFilter" ).attr( "value" ) != "" )
+    {
+        selectAllMetaDataCategories();
+        $( "body" ).ajaxComplete( function ()
+        {
+            applyFilter();
+        } );
+    }
+} );
+
+// Collapsed MetaData Category information
+function loadMetaDataCategories()
+{
+    for ( var i = 0; i < metaDataArray.length; i++ )
+    {
+        insertMetaDataCategoryHeadingDesign( metaDataArray[i] );
+        preventAccordionCollapse( metaDataArray[i] );
+
+        $( "#checkboxSelectAll" + metaDataArray[i] ).change( function ()
+        {
+            var metaDataCategoryName = $( this ).attr( "name" );
+
+            if ( $( this ).is( ":checked" ) )
+            {
+                $( this ).attr( 'checked', true );
+                selectAllValuesByCategory( metaDataCategoryName );
+            } else
+            {
+                deselectValuesByCategory( metaDataCategoryName );
+            }
+        } );
+    }
+}
+
+// Insert MetaData HTML & CSS heading design
+function insertMetaDataCategoryHeadingDesign( metaDataCategoryName )
+{
+    var design = generateMetaDataHeadingDesign( metaDataCategoryName );
+    $( "#heading" + metaDataCategoryName ).append( design );
+}
+
+// Insert MetaData HTML & CSS for a Category
+function insertMetaDataCategoryDesign( metaDataCategoryName )
+{
+    if ( $( "#mainDiv" + metaDataCategoryName ).is( ":empty" ) )
+    {
+        var design = generateMetaDataCategoryDesign( metaDataCategoryName );
+        $( "#mainDiv" + metaDataCategoryName ).append( design );
+        loadMetaData( metaDataCategoryName );
+    } else
+    {
+        deselectAllValues();
+    }
+}
+
+// Generate MetaData Heading design
+function generateMetaDataHeadingDesign( metaDataCategoryName )
+{
+    var design =
+          '<div id="divSelectAll' + metaDataCategoryName + '" style="float: right;">'
+        +     '<input id="checkboxSelectAll' + metaDataCategoryName + '" name="' + metaDataCategoryName + '" type="checkbox"/>'
+        +     '<label id="labelSelectAll' + metaDataCategoryName + '" for="' + metaDataCategoryName + '" style="font-size: 10pt;">' + i18n_select_all + '</label>'
+        + '</div>'
+    ;
+
+    return design;
+}
+
+// Generate MetaData HTML & CSS for a Category
+function generateMetaDataCategoryDesign( metaDataCategoryName )
+{
+    var i18n_available_metadata = getI18nAvailableMetaData( metaDataCategoryName );
+    var i18n_selected_metadata = getI18nSelectedMetaData( metaDataCategoryName );
+    var design =
+          '<table id="selectionArea'+metaDataCategoryName + '" style="border: 1px solid #ccc; padding: 15px;  margin-top: 10px; margin-bottom: 10px;">'
+        + '<colgroup>'
+        +    '<col style="width: 500px;"/>'
+        +    '<col/>'
+        +    '<col style="width: 500px"/>'
+        + '</colgroup>'
+        + '<thead>'
+        +    '<tr>'
+        +        '<th>' + i18n_available_metadata + '</th>'
+        +        '<th>' + i18n_filter + '</th>'
+        +        '<th>' + i18n_selected_metadata + '</th>'
+        +    '</tr>'
+        + '</thead>'
+        +        '<tbody>'
+        +            '<tr>'
+        +                '<td>'
+        +                   '<select id="available' + metaDataCategoryName + '" multiple="multiple" style="height: 200px; width: 100%;"></select>'
+        +               '</td>'
+        +               '<td>'
+        +                   '<input id="moveSelected' + metaDataCategoryName +'" type="button" value="&gt;" title="' + i18n_move_selected + '" style="width:50px"'
+        +                       'onclick="moveSelected( \'' + metaDataCategoryName + '\' );"/><br/>'
+        +                   '<input id="removeSelected' + metaDataCategoryName + '" type="button" value="&lt;" title="' + i18n_remove_selected + '" style="width:50px"'
+        +                       'onclick="removeSelected( \'' + metaDataCategoryName + '\' );"/><br/>'
+        +                   '<input id="select' + metaDataCategoryName + '" type="button" value="&gt;&gt;" title="' + i18n_move_all + '" style="width:50px"'
+        +                       'onclick="moveAll( \'' + metaDataCategoryName + '\' );"/><br/>'
+        +                   '<input id="deselect' + metaDataCategoryName + '" type="button" value="&lt;&lt;" title="' + i18n_remove_all +  '" style="width:50px"'
+        +                       'onclick="removeAll( \'' + metaDataCategoryName + '\' );"/><br/>'
+        +               '</td>'
+        +               '<td>'
+        +                   '<select id="selected' + metaDataCategoryName + '" name="selected' + metaDataCategoryName + '" multiple="multiple" style="height: 200px; width: 100%; margin-top: 25px;"></select>'
+        +               '</td>'
+        +           '</tr>'
+        +       '</tbody>'
+        + '</table>'
+    ;
+
+    return design;
+}
+
+// Move all selected items
+function moveSelected( metaDataCategoryName )
+{
+    dhisAjaxSelect_moveAllSelected( "available" + metaDataCategoryName );
+    if ( $( "#selected" + metaDataCategoryName + " option" ).length > 0 )
+    {
+        $( "#heading" + metaDataCategoryName ).css( "background", "#CFFFB3 50% 50% repeat-x" );
+    }
+
+    if ( $( "#available" + metaDataCategoryName + " option" ).length == 0 )
+    {
+        $( "#checkboxSelectAll" + metaDataCategoryName ).attr( "checked", true );
+    }
+}
+
+// Remove all selected items
+function removeSelected( metaDataCategoryName )
+{
+    dhisAjaxSelect_moveAllSelected( "selected" + metaDataCategoryName );
+    if ( $( "#selected" + metaDataCategoryName + " option" ).length == 0 )
+    {
+        $( "#heading" + metaDataCategoryName ).css( "background", "" );
+    }
+
+    if ( $( "#available" + metaDataCategoryName + " option" ).length > 0 )
+    {
+        $( "#checkboxSelectAll" + metaDataCategoryName ).attr( "checked", false );
+    }
+}
+
+// Move all items
+function moveAll( metaDataCategoryName )
+{
+    dhisAjaxSelect_moveAll( "available" + metaDataCategoryName );
+    $( "#checkboxSelectAll" + metaDataCategoryName ).attr( "checked", true );
+    $( "#heading" + metaDataCategoryName ).css( "background", "#CFFFB3 50% 50% repeat-x" );
+}
+
+// Remove all items
+function removeAll( metaDataCategoryName )
+{
+    dhisAjaxSelect_moveAll( "selected" + metaDataCategoryName );
+    $( "#checkboxSelectAll" + metaDataCategoryName ).attr( "checked", false );
+    $( "#heading" + metaDataCategoryName ).css( "background", "" );
+}
+
+// -----------------------------------------------------------------------------
+// Filter Object
+// -----------------------------------------------------------------------------
+
+// Filter
+function Filter()
+{
+    this.name = $( "#name" ).attr( "value" );
+    this.uid = $( "#uid" ).attr( "value" );
+    this.description = $( "#description" ).attr( "value" );
+    this.jsonFilter = $( "#jsonFilter" ).attr( "value" );
+}
+
+// -----------------------------------------------------------------------------
+// Load MetaData by Category
+// -----------------------------------------------------------------------------
+
+// Load MetaData by Category
+function loadMetaData( metaDataCategoryName )
+{
+    $( "#available" + metaDataCategoryName ).dhisAjaxSelect(
+        {
+            source: "../api/" + lowercaseFirstLetter( metaDataCategoryName ) + ".json?links=false&paging=false",
+            iterator: lowercaseFirstLetter( metaDataCategoryName ),
+            connectedTo: "selected" + metaDataCategoryName,
+            handler: function ( item )
+            {
+                var option = jQuery( "<option/>" );
+                option.text( item.name );
+                option.attr( "name", item.name );
+                option.attr( "value", item.id );
+
+                return option;
+            }
+        } );
+}
+
+// -----------------------------------------------------------------------------
+// MetaData Category Accordion Commands
+// -----------------------------------------------------------------------------
+
+// Load MetaData Category Accordion Events
+function loadMetaDataAccordionEvents()
+{
+    for ( var i = 0; i < metaDataArray.length; i++ )
+    {
+        $( "#heading" + metaDataArray[i] ).click( {metaDataCategoryName: metaDataArray[i]}, selectMetaDataCategoryByHeading );
+    }
+}
+
+// Select a MetaData Category from the MetaData accordion by heading
+function selectMetaDataCategoryByHeading( categoryName )
+{
+    var metaDataCategoryName = categoryName.data.metaDataCategoryName;
+    if ( $( "#mainDiv" + metaDataCategoryName ).children().length == 0 )
+    {
+        insertMetaDataCategoryDesign( metaDataCategoryName );
+    }
+}
+
+// Get all selected Uids
+function getSelectedUidsJson()
+{
+    var jsonFilter = {};
+
+    for ( var i = 0; i < metaDataArray.length; i++ )
+    {
+        var metaDataCategoryValues = [];
+
+        var values = $( "#selected" + metaDataArray[i] ).val();
+
+        if ( values != undefined )
+        {
+            metaDataCategoryValues = values;
+        }
+
+        if ( metaDataCategoryValues.length != 0 )
+        {
+            var metaDataCategory = lowercaseFirstLetter( metaDataArray[i] );
+            jsonFilter[metaDataCategory] = metaDataCategoryValues;
+        }
+    }
+
+    return jsonFilter;
+}
+
+// Select a MetaData Category from the MetaData accordion
+function selectMetaDataCategory( metaDataCategoryName )
+{
+    if ( $( "#mainDiv" + metaDataCategoryName ).children().length == 0 )
+    {
+        insertMetaDataCategoryDesign( metaDataCategoryName );
+    }
+}
+
+// Select all MetaData categories from the accordion
+function selectAllMetaDataCategories()
+{
+    for ( var i = 0; i < metaDataArray.length; i++ )
+    {
+        insertMetaDataCategoryDesign( metaDataArray[i] );
+    }
+}
+
+// Select all values
+function selectAllValues()
+{
+    for ( var i = 0; i < metaDataArray.length; i++ )
+    {
+        selectAllValuesByCategory( metaDataArray[i] );
+    }
+}
+
+// Deselect all values
+function deselectAllValues()
+{
+    for ( var i = 0; i < metaDataArray.length; i++ )
+    {
+        deselectValuesByCategory( metaDataArray[i] );
+    }
+}
+
+// Select all values by category
+function selectAllValuesByCategory( metaDataCategoryName )
+{
+    selectMetaDataCategory( metaDataCategoryName );
+
+    $( "body" ).ajaxComplete( function ()
+    {
+        $( "#select" + metaDataCategoryName ).click();
+    } );
+
+    $( "#select" + metaDataCategoryName ).click();
+}
+
+// Deselect all values by category
+function deselectValuesByCategory( metaDataCategoryName )
+{
+    $( "#deselect" + metaDataCategoryName ).click();
+
+    $( "#available" + metaDataCategoryName ).find( "option" ).each( function ()
+    {
+        $( this ).prop( "selected", false );
+    } );
+}
+
+// Move selected values by category
+function moveSelectedValuesByCategory( metaDataCategoryName )
+{
+    $( "#moveSelected" + metaDataCategoryName ).click();
+}
+
+// -----------------------------------------------------------------------------
+// Apply Filter
+// -----------------------------------------------------------------------------
+
+// Apply Filter
+function applyFilter()
+{
+    var jsonFilter = JSON.parse( $( "#jsonFilter" ).attr( "value" ) );
+
+    var category = "";
+
+    for ( var i = 0; i < metaDataArray.length; i++ )
+    {
+        category = lowercaseFirstLetter( metaDataArray[i] );
+
+        if ( jsonFilter.hasOwnProperty( category ) )
+        {
+            var uidValues = jsonFilter[category];
+
+            for ( var j = 0; j < uidValues.length; j++ )
+            {
+                $( "#available" + metaDataArray[i] + " option" ).each( function ()
+                {
+                    var availableUid = $( this ).val();
+                    if ( uidValues[j] == availableUid )
+                    {
+                        $( this ).prop( "selected", true );
+                        uidValues.splice( i, 1 );
+                    }
+                } );
+            }
+
+            moveSelectedValuesByCategory( metaDataArray[i] );
+        }
+    }
+}
+
+// -----------------------------------------------------------------------------
+// Save Filter
+// -----------------------------------------------------------------------------
+
+// Save a Filter
+function saveFilter()
+{
+    $( "#jsonFilter" ).attr( "value", JSON.stringify( getSelectedUidsJson() ) );
+
+    var json = JSON.stringify( new Filter() );
+
+    if ( validateFilter() )
+    {
+        $.ajax(
+            {
+                type: "POST",
+                url: "../api/filteredMetaData/saveFilter",
+                contentType: "application/json",
+                data: json,
+                success: function ()
+                {
+                    console.log( "Filter successfully saved." );
+                    window.location = "dxf2FilteredMetaDataExport.action";
+                },
+                error: function ( request, status, error )
+                {
+                    console.log( request.responseText );
+                    console.log( arguments );
+                    alert( "Save filter process failed." );
+                }
+            } );
+    } else
+    {
+        //TODO : Input validation
+    }
+}
+
+// -----------------------------------------------------------------------------
+// Update Filter
+// -----------------------------------------------------------------------------
+
+// Update a Filter
+function updateFilter()
+{
+    $( "#jsonFilter" ).attr( "value", JSON.stringify( getSelectedUidsJson() ) );
+
+    var json = JSON.stringify( new Filter() );
+
+    if ( validateFilter() )
+    {
+        $.ajax(
+            {
+                type: "POST",
+                url: "../api/filteredMetaData/updateFilter",
+                contentType: "application/json",
+                data: json,
+                success: function ()
+                {
+                    console.log( "Filter successfully saved." );
+                    window.location = "dxf2FilteredMetaDataExport.action";
+                },
+                error: function ( request, status, error )
+                {
+                    console.log( request.responseText );
+                    console.log( arguments );
+                    alert( "Update filter process failed." );
+                }
+            } );
+    } else
+    {
+        //TODO : Input validation
+    }
+}
+
+// -----------------------------------------------------------------------------
+// Export MetaData
+// -----------------------------------------------------------------------------
+
+// Start MetaData export
+function startExport()
+{
+    var jsonFilter = {};
+
+    for ( var i = 0; i < metaDataArray.length; i++ )
+    {
+        var values = [];
+        $( "#selected" + metaDataArray[i] + " option" ).each( function ()
+        {
+            values.push( $( this ).attr( "value" ) );
+        } );
+
+        if ( values.length > 0 )
+        {
+            jsonFilter[lowercaseFirstLetter( metaDataArray[i] )] = values;
+        }
+    }
+
+    $( "#exportJson" ).attr( "value", JSON.stringify( jsonFilter ) );
+
+    jQuery( "#exportDialog" ).dialog( {
+        title: i18n_export,
+        modal: true
+    } );
+}
+
+// Export MetaData
+function exportFilteredMetaData()
+{
+    var exportJson = {};
+    exportJson.exportDependencies = $( "#exportDependencies" ).is( ":checked" ).toString();
+    exportJson.jsonFilter = $( "#exportJson" ).val();
+
+    $( "#exportJsonValue" ).val( JSON.stringify( exportJson ) );
+
+    document.getElementById( 'exportForm' ).action = getURL();
+
+    $( "#exportForm" ).submit();
+    $( "#exportDialog" ).dialog( "close" );
+}
+
+// Generate Export URL
+function getURL()
+{
+    var url = "../api/filteredMetaData";
+    var format = $( "#format" ).val();
+    var compression = $( "#compression" ).val();
+    url += "." + format;
+
+    if(compression == "zip")
+    {
+        url += ".zip";
+    }
+    else if(compression == "gz")
+    {
+        url += ".gz";
+    }
+
+    return url;
+}
+
+// -----------------------------------------------------------------------------
+// Validate Filter
+// -----------------------------------------------------------------------------
+
+// Validate Filter
+function validateFilter()
+{
+    return ($( "#name" ).attr( "value" ) != "");
+}
+
+// -----------------------------------------------------------------------------
+// Utils
+// -----------------------------------------------------------------------------
+
+// Stop accordion collapse
+function preventAccordionCollapse( metaDataCategoryName )
+{
+    $( "#heading" + metaDataCategoryName ).find( "input" ).click( function ( e )
+    {
+        e.stopPropagation();
+    } );
+}

=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/utils.js'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/utils.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/utils.js	2013-09-08 10:19:03 +0000
@@ -0,0 +1,151 @@
+//@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+
+// -----------------------------------------------------------------------------
+// Utils
+// -----------------------------------------------------------------------------
+
+// Make the first letter lowercase
+function lowercaseFirstLetter( string )
+{
+    return string.charAt( 0 ).toLowerCase() + string.slice( 1 );
+}
+
+// Get Available Metadata category name
+function getI18nAvailableMetaData( metaDataCategoryName )
+{
+    switch ( metaDataCategoryName )
+    {
+        case "AttributeTypes":
+            return i18n_available_attributeTypes;
+        case "Dimensions":
+            return i18n_available_categories;
+        case "Charts":
+            return i18n_available_charts;
+        case "Concepts":
+            return i18n_available_concepts;
+        case "Constants":
+            return i18n_available_constants;
+        case "DataDictionaries":
+            return i18n_available_dataDictionaries;
+        case "DataElementGroupSets":
+            return i18n_available_dataElementGroupSets;
+        case "DataElementGroups":
+            return i18n_available_dataElementGroups;
+        case "DataElements":
+            return i18n_available_dataElements;
+        case "DataSets":
+            return i18n_available_dataSets;
+        case "Documents":
+            return i18n_available_documents;
+        case "IndicatorGroupSets":
+            return i18n_available_indicatorGroupSets;
+        case "IndicatorGroups":
+            return i18n_available_indicatorGroups;
+        case "Indicators":
+            return i18n_available_indicators;
+        case "IndicatorTypes":
+            return i18n_available_indicatorTypes;
+        case "MapLegendSets":
+            return i18n_available_mapLegendSets;
+        case "Maps":
+            return i18n_available_maps;
+        case "OptionSets":
+            return i18n_available_optionSets;
+        case "OrganisationUnitGroupSets":
+            return i18n_available_organisationUnitGroupSets;
+        case "OrganisationUnitGroups":
+            return i18n_available_organisationUnitGroups;
+        case "OrganisationUnitLevels":
+            return i18n_available_organisationUnitLevels;
+        case "OrganisationUnits":
+            return i18n_available_organisationUnits;
+        case "ReportTables":
+            return i18n_available_reportTables;
+        case "Reports":
+            return i18n_available_reports;
+        case "SqlViews":
+            return i18n_available_sqlViews;
+        case "UserGroups":
+            return i18n_available_userGroups;
+        case "UserRoles":
+            return i18n_available_userRoles;
+        case "Users":
+            return i18n_available_users;
+        case "ValidationRuleGroups":
+            return i18n_available_validationRuleGroups;
+        case "ValidationRules":
+            return i18n_available_validationRules;
+        default :
+            return "";
+    }
+}
+
+// Get Selected Metadata category name
+function getI18nSelectedMetaData( metaDataCategoryName )
+{
+    switch ( metaDataCategoryName )
+    {
+        case "AttributeTypes":
+            return i18n_selected_attributeTypes;
+        case "Dimensions":
+            return i18n_selected_categories;
+        case "Charts":
+            return i18n_selected_charts;
+        case "Concepts":
+            return i18n_selected_concepts;
+        case "Constants":
+            return i18n_selected_constants;
+        case "DataDictionaries":
+            return i18n_selected_dataDictionaries;
+        case "DataElementGroupSets":
+            return i18n_selected_dataElementGroupSets;
+        case "DataElementGroups":
+            return i18n_selected_dataElementGroups;
+        case "DataElements":
+            return i18n_selected_dataElements;
+        case "DataSets":
+            return i18n_selected_dataSets;
+        case "Documents":
+            return i18n_selected_documents;
+        case "IndicatorGroupSets":
+            return i18n_selected_indicatorGroupSets;
+        case "IndicatorGroups":
+            return i18n_selected_indicatorGroups;
+        case "Indicators":
+            return i18n_selected_indicators;
+        case "IndicatorTypes":
+            return i18n_selected_indicatorTypes;
+        case "MapLegendSets":
+            return i18n_selected_mapLegendSets;
+        case "Maps":
+            return i18n_selected_maps;
+        case "OptionSets":
+            return i18n_selected_optionSets;
+        case "OrganisationUnitGroupSets":
+            return i18n_selected_organisationUnitGroupSets;
+        case "OrganisationUnitGroups":
+            return i18n_selected_organisationUnitGroups;
+        case "OrganisationUnitLevels":
+            return i18n_selected_organisationUnitLevels;
+        case "OrganisationUnits":
+            return i18n_selected_organisationUnits;
+        case "ReportTables":
+            return i18n_selected_reportTables;
+        case "Reports":
+            return i18n_selected_reports;
+        case "SqlViews":
+            return i18n_selected_sqlViews;
+        case "UserGroups":
+            return i18n_selected_userGroups;
+        case "UserRoles":
+            return i18n_selected_userRoles;
+        case "Users":
+            return i18n_selected_users;
+        case "ValidationRuleGroups":
+            return i18n_selected_validationRuleGroups;
+        case "ValidationRules":
+            return i18n_selected_validationRules;
+        default :
+            return "";
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/mainMenu.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/mainMenu.vm	2013-10-01 13:16:44 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/mainMenu.vm	2013-10-30 12:51:03 +0000
@@ -15,6 +15,7 @@
 
 <ul>
   <li><a href="dxf2MetaDataExport.action">$i18n.getString( "metadata_export" )&nbsp;</a></li>
+  <li><a href="dxf2FilteredMetaDataExport.action">$i18n.getString( "filtered_metadata_export" )&nbsp;</a></li>
   <li><a href="displayDataValueExportForm.action">$i18n.getString( "data_export" )&nbsp;</a></li>
   <li><a href="displayEventExportForm.action">$i18n.getString( "event_data_export" )&nbsp;</a></li>
   <li><a href="displayExternalExportMenu.action">$i18n.getString( "export_to_other_systems" )&nbsp;</a></li>

=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/sortFilterForm.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/sortFilterForm.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/sortFilterForm.vm	2013-08-26 22:41:43 +0000
@@ -0,0 +1,35 @@
+<script type="text/javascript">
+    function submitForm()
+    {
+        selectAllById( "filters" );
+        document.getElementById( "sortOrderForm" ).submit();
+    }
+</script>
+
+##@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>
+
+<h3>$i18n.getString( "filter_sort_order" )</h3>
+
+<form id="sortOrderForm" action="saveFilterListSortOrder.action" method="post">
+
+    <p>
+        <input type="button" value="$i18n.getString( 'move_up' )" style="width:130px" onclick="moveUpSelectedOption( 'filters' )"/>
+        <input type="button" value="$i18n.getString( 'move_down' )" style="width:130px" onclick="moveDownSelectedOption( 'filters' )"/>
+        <input type="button" value="$i18n.getString( 'move_to_top' )" style="width:130px" onclick="moveSelectedOptionToTop( 'filters' )"/>
+        <input type="button" value="$i18n.getString( 'move_to_bottom' )" style="width:130px" onclick="moveSelectedOptionToBottom( 'filters' )"/>
+    </p>
+
+    <p>
+        <select multiple id="filters" name="filters" size="25" style="width:680px">
+            #foreach ( $filter in $filters )
+                <option value="$filter.id">$filter.name</option>
+            #end
+        </select>
+    </p>
+
+    <p>
+        <input type="button" value="$i18n.getString( 'save' )" style="width:130px" onclick="submitForm()"/>
+        <input type="button" value="$i18n.getString( 'cancel' )" style="width:130px" onclick="window.history.back();"/>
+    </p>
+
+</form>