// Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/exceptions/NotCompatibleException.java
// public class NotCompatibleException extends Exception {
// 
//     public NotCompatibleException(String message) {
//         super(message);
//     }
// }
// 
// Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/exceptions/NotInstantiatedException.java
// public class NotInstantiatedException extends Exception {
// 
//     public NotInstantiatedException(String message) {
//         super(message);
//     }
// }


import br.ufes.inf.lprm.scene.exceptions.NotCompatibleException;
import br.ufes.inf.lprm.scene.exceptions.NotInstantiatedException;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import org.drools.compiler.kproject.models.KieModuleModelImpl;
import org.drools.core.ClockType;
import org.kie.api.KieServices;
import org.kie.api.builder.KieBuilder;
import org.kie.api.builder.KieFileSystem;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.ReleaseId;
import org.kie.api.builder.model.KieBaseModel;
import org.kie.api.builder.model.KieModuleModel;
import org.kie.api.builder.model.KieSessionModel;
import org.kie.api.definition.type.FactField;
import org.kie.api.definition.type.FactType;
import org.kie.api.io.Resource;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.conf.ClockTypeOption;
import org.kie.api.runtime.rule.FactHandle;
import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
package br.ufes.inf.lprm.scene.serialization;



/**
 * Created by hborjaille on 10/24/16.
 */
public class JsonContext {
    private Map<String, Map<Integer, FactHandle>> factHandleMap;
    private Map<String, Map<Integer, Object>> objectMap;
    private ArrayList<String> packages;
    private KieSession kSession;
    private String appname;
    private String description;

    public JsonContext() {
        factHandleMap = new HashMap<>();
        objectMap = new HashMap<>();
        packages = new ArrayList<>();
    }

    public void compileCodeJson(String content) throws NotCompatibleException {
        Gson gson = new Gson();
        Type jsonType = new TypeToken<Map<String, Object>>(){}.getType();

        Map<String, Object> myMap = gson.fromJson(content, jsonType);

        if(myMap.get("application") == null) {
// Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/exceptions/NotCompatibleException.java
// public class NotCompatibleException extends Exception {
// 
//     public NotCompatibleException(String message) {
//         super(message);
//     }
// }
// 
// Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/exceptions/NotInstantiatedException.java
// public class NotInstantiatedException extends Exception {
// 
//     public NotInstantiatedException(String message) {
//         super(message);
//     }
// }


// Path: scene-core/src/main/java/br/ufes/inf/lprm/scene/serialization/JsonContext.java
import br.ufes.inf.lprm.scene.exceptions.NotCompatibleException;
import br.ufes.inf.lprm.scene.exceptions.NotInstantiatedException;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import org.drools.compiler.kproject.models.KieModuleModelImpl;
import org.drools.core.ClockType;
import org.kie.api.KieServices;
import org.kie.api.builder.KieBuilder;
import org.kie.api.builder.KieFileSystem;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.ReleaseId;
import org.kie.api.builder.model.KieBaseModel;
import org.kie.api.builder.model.KieModuleModel;
import org.kie.api.builder.model.KieSessionModel;
import org.kie.api.definition.type.FactField;
import org.kie.api.definition.type.FactType;
import org.kie.api.io.Resource;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.conf.ClockTypeOption;
import org.kie.api.runtime.rule.FactHandle;
import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;

package br.ufes.inf.lprm.scene.serialization;



/**
 * Created by hborjaille on 10/24/16.
 */
public class JsonContext {
    private Map<String, Map<Integer, FactHandle>> factHandleMap;
    private Map<String, Map<Integer, Object>> objectMap;
    private ArrayList<String> packages;
    private KieSession kSession;
    private String appname;
    private String description;

    public JsonContext() {
        factHandleMap = new HashMap<>();
        objectMap = new HashMap<>();
        packages = new ArrayList<>();
    }

    public void compileCodeJson(String content) throws NotCompatibleException {
        Gson gson = new Gson();
        Type jsonType = new TypeToken<Map<String, Object>>(){}.getType();

        Map<String, Object> myMap = gson.fromJson(content, jsonType);

        if(myMap.get("application") == null) {
            throw new NotCompatibleException("Json format not compatible.");