package tools;

import java.io.File;
import java.io.FilenameFilter;
import CDLite.XML2CD;
import CDLite.CD2ALS;

public class VIOLET2ALLOY {
	public static void violet2alloy(boolean exactlyClass, int classNumber, boolean exactlyInterface, int interfaceNumber, boolean exactlyAssociation, int associationNumber, boolean checker, boolean counter) {
		File ALS4FSM = new File("ALLOY4CD");
		if (!ALS4FSM.exists()) {
			ALS4FSM.mkdirs();
		}
		File fsmTestsFolder = new File("TEST4CD");
		File[] fsmFiles = fsmTestsFolder.listFiles(new FilenameFilter() {
			@Override
			public boolean accept(File dir, String name) {
				return name.endsWith("class.violet");
			}
		});
		for (File fsm : fsmFiles) {
			String xmlFile = fsm.getName();
			String alsFile = xmlFile.split("\\.")[0] + ".als";
			new CD2ALS(ALS4FSM + "/" + alsFile, new XML2CD(fsmTestsFolder.getName() + "/" + xmlFile).returnClassDiagram(), exactlyClass, classNumber, exactlyInterface, interfaceNumber, exactlyAssociation, associationNumber, checker, counter).createALS();
		}
	}
}
