← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16276: add method to schemaService to get sorted schemas

 

------------------------------------------------------------
revno: 16276
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-07-30 14:56:37 +0700
message:
  add method to schemaService to get sorted schemas
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaService.java	2014-05-31 16:27:04 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaService.java	2014-07-30 07:56:37 +0000
@@ -72,6 +72,13 @@
     List<Schema> getSchemas();
 
     /**
+     * Get all available schemas (which are generated with a schema descriptor).
+     *
+     * @return List of all available schemas
+     */
+    List<Schema> getSortedSchemas();
+
+    /**
      * Get all available schemas which have the metadata property set to true.
      *
      * @return List of all available metadata schemas

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java	2014-06-15 13:36:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java	2014-07-30 07:56:37 +0000
@@ -38,6 +38,7 @@
 import org.springframework.util.StringUtils;
 
 import javax.annotation.PostConstruct;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
@@ -150,6 +151,15 @@
     }
 
     @Override
+    public List<Schema> getSortedSchemas()
+    {
+        List<Schema> schemas = Lists.newArrayList( classSchemaMap.values() );
+        Collections.sort( schemas, OrderComparator.INSTANCE );
+
+        return schemas;
+    }
+
+    @Override
     public List<Schema> getMetadataSchemas()
     {
         List<Schema> schemas = getSchemas();