package uk.me.graphe.server.messages;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

public abstract class MessageFactory {
    private static final Map<String, ConversionFactory> sOpFactoryMap = null;
    

	public static List<Message> makeOperationsFromJson(List<JSONObject> jsos) throws JSONException {
		
		List<Message> result = new ArrayList<Message>();
		
		for (JSONObject o : jsos) {
			String messageVal = o.getString("message");
			Message op = MessageFactory.make(messageVal, o);
			result.add(op);
		}
		
		return result;
	}

	private static Message make(String messageVal, JSONObject o) {
		return sOpFactoryMap.get(messageVal).make(o);
	}
	
	
}

@@ -56,24 +56,50 @@
 .ArrayList;%0A
+import java.util.HashMap;%0A
 import java.
@@ -196,72 +196,754 @@
 t;%0A%0A
-public abstract class MessageFactory %7B%0A    private static final 
+import uk.me.graphe.server.messages.factories.AddEdgeFactory;%0Aimport uk.me.graphe.server.messages.factories.AddNodeFactory;%0Aimport uk.me.graphe.server.messages.factories.ConversionFactory;%0Aimport uk.me.graphe.server.messages.factories.DeleteEdgeFactory;%0Aimport uk.me.graphe.server.messages.factories.DeleteNodeFactory;%0Aimport uk.me.graphe.server.messages.factories.HeartbeatFactory;%0Aimport uk.me.graphe.server.messages.factories.MakeGraphFactory;%0Aimport uk.me.graphe.server.messages.factories.MoveNodeFactory;%0A%0Apublic abstract class MessageFactory %7B%0A    private static Map%3CString, ConversionFactory%3E sOpFactoryMap = null;%0A    %0A    static %7B%0A        //TODO: get the strings from the classes instead of hardcode them%0A        sOpFactoryMap = new Hash
 Map%3C
@@ -960,32 +960,43 @@
 nversionFactory%3E
+();%0A       
  sOpFactoryMap =
@@ -993,29 +993,435 @@
 ctoryMap
- = null;%0A    
+.put(%22addEdge%22, new AddEdgeFactory());%0A        sOpFactoryMap.put(%22delEdge%22, new DeleteEdgeFactory());%0A        sOpFactoryMap.put(%22addNode%22, new AddNodeFactory());%0A        sOpFactoryMap.put(%22delNode%22, new DeleteNodeFactory());%0A        sOpFactoryMap.put(%22movNode%22, new MoveNodeFactory());%0A        sOpFactoryMap.put(%22heartbeat%22, new HeartbeatFactory());%0A        sOpFactoryMap.put(%22makeGraph%22, new MakeGraphFactory());%0A    %7D
 %0A%0A%09publi

make the message factory actually do things.