// Path: ServiceLayer/src/main/java/org/servicelayer/models/PersistPlanetDomain.java
// public class PersistPlanetDomain {
// 	private Integer hashKey;
// 	private String setup;
// 	private String lastRefreshDate; //no idea what to do with this
// 	private Integer version;
// 	
// 	public Integer calculateHashKey(){
// 		if(setup == null){
// 			return null;
// 		}
// 		hashKey = setup.hashCode();
// 		return getHashKey();
// 	}
// 	public Integer getHashKey() {
// 		return hashKey;
// 	}
// 	public void setHashKey(Integer hashKey) {
// 		this.hashKey = hashKey;
// 	}
// 	public String getSetup() {
// 		return setup;
// 	}
// 	public void setSetup(String setup) {
// 		this.setup = setup;
// 	}
// 	public String getLastRefreshDate() {
// 		return lastRefreshDate;
// 	}
// 	public void setLastRefreshDate(String lastRefreshDate) {
// 		this.lastRefreshDate = lastRefreshDate;
// 	}
// 	public Integer getVersion() {
// 		return version;
// 	}
// 	public void setVersion(Integer version) {
// 		this.version = version;
// 	}
// }
// 
// Path: planetary/src/main/java/org/planetary/persist/SavePlanetService.java
// public enum ResponseCodes{
// 	//no, I don't know why I'm doing this. Doesn't matter had success 
// 	SUCCESS(0, "Success"),
// 	FAILURE(1, "Unqualified Failure"),
// 	EXISTS(2, "Setup Hash Exists"),
// 	COLLISION(3, "Hash Collision, please kill the developer");
// 		
// 	private int code;
// 	private String message;
// 	private ResponseCodes(int code, String message){
// 		this.code = code;
// 		this.message = message;
// 	}
// 	public int getCode(){
// 		return code;
// 	}
// 	public String getMessage(){
// 		return message;
// 	}
// }


import java.io.IOException;
import org.servicelayer.models.PersistPlanetDomain;
import org.springframework.ui.ModelMap;
import org.planetary.persist.SavePlanetService.ResponseCodes;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
//			System.out.println("SaveSetupDAO | persistSetupAndGetURL | Setup String: " 
//				+ saveString); 
			PersistPlanetDomain planetSetup = new PersistPlanetDomain();
			planetSetup.setSetup(saveString);
			if(planetSetup.calculateHashKey() == null){
				System.out.println("Failed to calculate hashKey at SaveSetupDAO.persistSetupAndGetUrl");
				return null; //calculateHashKey is the calculation here
			}
//			System.out.println("Save planet service Call");
			ModelMap response = SavePlanetService.savePlanetSetup(planetSetup);
//			System.out.println("After save planet service Call: "+ response.toString());
			if(response.get("key") != null){
				return ((Integer)response.get("key")).toString();
			}
			else{
				System.out.println("Failed save planet service call" + response.get("status"));
				return null;
			}
		} catch (JsonProcessingException e) {
			System.out.println("JsonProcessingException in SaveSetupDAO.persistSetupAndGetUrl");
			return null;
		}
	}
	
	public static CompleteSetupContainer getSetupFromKey(int urlKey){
		ModelMap response = SavePlanetService.getSetup(urlKey);
		if(response.containsKey("ERROR")){
			return null; //TODO:
		}
		if(response.containsKey("setup")){
// Path: ServiceLayer/src/main/java/org/servicelayer/models/PersistPlanetDomain.java
// public class PersistPlanetDomain {
// 	private Integer hashKey;
// 	private String setup;
// 	private String lastRefreshDate; //no idea what to do with this
// 	private Integer version;
// 	
// 	public Integer calculateHashKey(){
// 		if(setup == null){
// 			return null;
// 		}
// 		hashKey = setup.hashCode();
// 		return getHashKey();
// 	}
// 	public Integer getHashKey() {
// 		return hashKey;
// 	}
// 	public void setHashKey(Integer hashKey) {
// 		this.hashKey = hashKey;
// 	}
// 	public String getSetup() {
// 		return setup;
// 	}
// 	public void setSetup(String setup) {
// 		this.setup = setup;
// 	}
// 	public String getLastRefreshDate() {
// 		return lastRefreshDate;
// 	}
// 	public void setLastRefreshDate(String lastRefreshDate) {
// 		this.lastRefreshDate = lastRefreshDate;
// 	}
// 	public Integer getVersion() {
// 		return version;
// 	}
// 	public void setVersion(Integer version) {
// 		this.version = version;
// 	}
// }
// 
// Path: planetary/src/main/java/org/planetary/persist/SavePlanetService.java
// public enum ResponseCodes{
// 	//no, I don't know why I'm doing this. Doesn't matter had success 
// 	SUCCESS(0, "Success"),
// 	FAILURE(1, "Unqualified Failure"),
// 	EXISTS(2, "Setup Hash Exists"),
// 	COLLISION(3, "Hash Collision, please kill the developer");
// 		
// 	private int code;
// 	private String message;
// 	private ResponseCodes(int code, String message){
// 		this.code = code;
// 		this.message = message;
// 	}
// 	public int getCode(){
// 		return code;
// 	}
// 	public String getMessage(){
// 		return message;
// 	}
// }


// Path: planetary/src/main/java/org/planetary/persist/SaveSetupDAO.java
import java.io.IOException;
import org.servicelayer.models.PersistPlanetDomain;
import org.springframework.ui.ModelMap;
import org.planetary.persist.SavePlanetService.ResponseCodes;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;

//			System.out.println("SaveSetupDAO | persistSetupAndGetURL | Setup String: " 
//				+ saveString); 
			PersistPlanetDomain planetSetup = new PersistPlanetDomain();
			planetSetup.setSetup(saveString);
			if(planetSetup.calculateHashKey() == null){
				System.out.println("Failed to calculate hashKey at SaveSetupDAO.persistSetupAndGetUrl");
				return null; //calculateHashKey is the calculation here
			}
//			System.out.println("Save planet service Call");
			ModelMap response = SavePlanetService.savePlanetSetup(planetSetup);
//			System.out.println("After save planet service Call: "+ response.toString());
			if(response.get("key") != null){
				return ((Integer)response.get("key")).toString();
			}
			else{
				System.out.println("Failed save planet service call" + response.get("status"));
				return null;
			}
		} catch (JsonProcessingException e) {
			System.out.println("JsonProcessingException in SaveSetupDAO.persistSetupAndGetUrl");
			return null;
		}
	}
	
	public static CompleteSetupContainer getSetupFromKey(int urlKey){
		ModelMap response = SavePlanetService.getSetup(urlKey);
		if(response.containsKey("ERROR")){
			return null; //TODO:
		}
		if(response.containsKey("setup")){
			PersistPlanetDomain reply = (PersistPlanetDomain) response.get("setup");