package org.etsi.mts.tdl.json2tdl;

import java.io.File;

import org.eclipse.emf.ecore.resource.Resource;
import org.etsi.mts.tdl.helper.TDLHelper;

public class JSONConverter {
	public static String processToString(String inputPath, String outputPath) {
		return processToString(inputPath, outputPath, "SOURCE_MAPPING", "TARGET_MAPPING");
	}
	
	public static String processToString(String inputPath, String outputPath, String sourceMapping, String targetMapping) {
		System.out.println("Exporting: "+outputPath+ " : "+ new File(outputPath).getAbsolutePath());
		JSON2TDLTranslator translator = new JSON2TDLTranslator();
		String content = "Package imported {}";
		try {
			Resource tr = TDLHelper.create(outputPath);
			translator.setTargetResource(tr);
			translator.initTargetResource(translator.cleanName(new File(inputPath).getName()));
			translator.translate(inputPath);
			content = TDLHelper.getText(tr);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return content;
	}

}

