package be.uantwerpen.msdl.vafl.docgen.main;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.resource.Resource;
import io.opencaesar.oml.RelationEntity;
import io.opencaesar.oml.Vocabulary;
import io.opencaesar.oml.VocabularyBundle;

public class Utils {

	public static List<VocabularyBundle> getAllVocabularyBundles (VocabularyBundle bundle) {
		List<VocabularyBundle> returnList = new ArrayList<VocabularyBundle>();
		for (Resource resource : bundle.eResource().getResourceSet().getResources()) {
			if (resource.getContents().get(0).eClass().getName().matches("VocabularyBundle")) {
				returnList.add((VocabularyBundle) resource.getContents().get(0));
			}
		}
		return returnList;
	}
	
	public static List<Vocabulary> getAllVocabularies (VocabularyBundle bundle) {
		List<Vocabulary> returnList = new ArrayList<Vocabulary>();
		for (Resource resource : bundle.eResource().getResourceSet().getResources()) {
			if (resource.getContents().get(0).eClass().getName().matches("Vocabulary")) {
				returnList.add((Vocabulary) resource.getContents().get(0));
			}
		}
		return returnList;
	}
	
	public static String escapeLatexSpecialChars (String string) {
		string = string.replaceAll("#","\\\\#");
		return string;
	}
	
	public static List<String> getRelationAxioms (RelationEntity relation) {
		List<String> returnList = new ArrayList<String>();
		if (relation.isAsymmetric()) {returnList.add("asymmetric");}
		if (relation.isFunctional()) {returnList.add("asymmetric");}
		if (relation.isInverseFunctional()) {returnList.add("inverse functional");}
		if (relation.isIrreflexive()) {returnList.add("irreflexive");}
		if (relation.isReflexive()) {returnList.add("reflexive");}
		if (relation.isSymmetric()) {returnList.add("symmetric");}
		if (relation.isTransitive()) {returnList.add("transitive");}
		return returnList;
	}
}
