package org.hisp.dhis.android.core.category;


import org.hisp.dhis.android.core.calls.factories.ListCallFactory;
import org.hisp.dhis.android.core.calls.factories.ListCallFactoryImpl;
import org.hisp.dhis.android.core.calls.fetchers.CallFetcher;
import org.hisp.dhis.android.core.calls.fetchers.PayloadNoResourceCallFetcher;
import org.hisp.dhis.android.core.calls.processors.CallProcessor;
import org.hisp.dhis.android.core.calls.processors.TransactionalNoResourceSyncCallProcessor;
import org.hisp.dhis.android.core.common.GenericCallData;
import org.hisp.dhis.android.core.common.Payload;

import retrofit2.Retrofit;

public final class CategoryEndpointCall {

    private CategoryEndpointCall() {
    }

    public static ListCallFactory<Category> factory(Retrofit retrofit) {

        final CategoryService service = retrofit.create(CategoryService.class);

        return new ListCallFactoryImpl<Category>() {

            @Override
            protected CallFetcher<Category> fetcher(GenericCallData data) {
                return new PayloadNoResourceCallFetcher<Category>() {

                    @Override
                    protected retrofit2.Call<Payload<Category>> getCall() {
                        return service.getCategory(CategoryFields.allFields, Boolean.FALSE);
                    }
                };
            }

            @Override
            protected CallProcessor<Category> processor(GenericCallData data) {
                return new TransactionalNoResourceSyncCallProcessor<>(
                        data.databaseAdapter(),
                        CategoryHandler.create(data.databaseAdapter()));
            }
        };
    }
}

@@ -82,36 +82,36 @@
 calls.factories.
-List
+Uids
 CallFactory;%0Aimp
@@ -157,20 +157,20 @@
 ctories.
-List
+Uids
 CallFact
@@ -289,23 +289,20 @@
 etchers.
-Payload
+Uids
 NoResour
@@ -587,33 +587,80 @@
 ad;%0A
-%0A
 import 
-retrofit2.Retrofi
+org.hisp.dhis.android.core.common.UidsQuery;%0A%0Aimport java.util.Se
 t;%0A%0A
@@ -764,20 +764,26 @@
  static 
-List
+final Uids
 CallFact
@@ -800,142 +800,26 @@
 ry%3E 
-factory(Retrofit retrofit) %7B%0A%0A        final CategoryService service = retrofit.create(CategoryService.class);%0A%0A        return new List
+FACTORY = new Uids
 Call
@@ -844,29 +844,83 @@
 ry%3E() %7B%0A
-%0A
+   
      
+private static final int MAX_UID_LIST_SIZE = 100;%0A%0A
        
+ 
 @Overrid
@@ -913,36 +913,32 @@
       @Override%0A
-    
         protecte
@@ -985,32 +985,138 @@
 allData data
-) %7B%0A    
+, Set%3CString%3E uids) %7B%0A            final CategoryService service = data.retrofit().create(CategoryService.class);%0A%0A
             
@@ -1126,23 +1126,20 @@
 urn new 
-Payload
+Uids
 NoResour
@@ -1166,17 +1166,36 @@
 ry%3E(
+uids, MAX_UID_LIST_SIZE
 ) %7B%0A%0A
-    
     
@@ -1208,36 +1208,32 @@
       @Override%0A
-    
                 
@@ -1284,24 +1284,35 @@
 getCall(
+UidsQuery query
 ) %7B%0A
-    
         
@@ -1354,71 +1354,171 @@
 ory(
-CategoryFields.allFields, Boolean.FALSE);%0A                    %7D
+%0A                            CategoryFields.allFields,%0A                            CategoryFields.uid.in(query.uids()),%0A                            Boolean.FALSE);
 %0A   
@@ -1527,25 +1527,24 @@
            %7D
-;
 %0A           
@@ -1545,22 +1545,29 @@
        %7D
-%0A%0A    
+;%0A        %7D%0A%0A
         
@@ -1568,36 +1568,32 @@
       @Override%0A
-    
         protecte
@@ -1648,28 +1648,24 @@
 ata data) %7B%0A
-    
             
@@ -1739,20 +1739,16 @@
         
-    
 data.dat
@@ -1763,20 +1763,16 @@
 pter(),%0A
-    
         
@@ -1829,18 +1829,16 @@
 apter())
-);
 %0A       
@@ -1834,33 +1834,34 @@
 ())%0A            
-%7D
+);
 %0A        %7D;%0A    
@@ -1858,14 +1858,13 @@
    %7D
-;
 %0A    %7D
+;
 %0A%7D
-%0A

Add CategoryEndpointCall