package org.adaptlab.chpir.android.activerecordcloudsync;

import java.util.HashMap;
import java.util.Map;
import android.util.Log;

public class ActiveRecordCloudSync {
    private static final String TAG="ActiveRecordCloudSync";
    private static Map<String, Class<? extends ReceiveTable>> mReceiveTables =
            new HashMap<String, Class<? extends ReceiveTable>>();
    private static Map<String, Class<? extends SendTable>> mSendTables =
            new HashMap<String, Class<? extends SendTable>>();
    private static String mEndPoint;
    
    public static void addReceiveTable(String tableName, Class<? extends ReceiveTable> receiveTable) {
        mReceiveTables.put(tableName, receiveTable);
    }
    
    public static Map<String, Class<? extends ReceiveTable>> getReceiveTables() {
        return mReceiveTables;
    }
    
    public static void addSendTable(String tableName, Class<? extends SendTable> sendTable) {
        mSendTables.put(tableName, sendTable);
    }
    
    public static void setEndPoint(String endPoint) {
        mEndPoint = endPoint;
    }
    
    public static String getEndPoint() {
        return mEndPoint;
    }
    
    public static void syncReceiveTables() {
        for (Map.Entry<String, Class<? extends ReceiveTable>> entry : mReceiveTables.entrySet()) {
            Log.i(TAG, "Syncing " + entry.getValue() + " from remote table " + entry.getKey());
            HttpFetchr httpFetchr = new HttpFetchr(entry.getKey(), entry.getValue());
            httpFetchr.fetch();
        }
    }
    
    public static void syncSendTables() {
        for (Map.Entry<String, Class<? extends ReceiveTable>> entry : mReceiveTables.entrySet()) {
            Log.i(TAG, "Syncing " + entry.getValue() + " to remote table " + entry.getKey());
        }   
    }
}

@@ -1623,39 +1623,36 @@
 Class%3C? extends 
-Receive
+Send
 Table%3E%3E entry : 
@@ -1644,39 +1644,36 @@
 able%3E%3E entry : m
-Receive
+Send
 Tables.entrySet(
@@ -1763,32 +1763,145 @@
 ntry.getKey());%0A
+            HttpPushr httpPushr = new HttpPushr(entry.getKey(), entry.getValue());%0A            httpPushr.push();%0A
         %7D   %0A   

Add sync send table to activerecordcloudsync