Commit 7d82b9f8 authored by Paff's avatar Paff
Browse files

Wrapper tool

parent ae3d1bc5
package secarc;
import static mc.umlp.arcd.ToolConstants.ARG_ANALYSIS;
import static mc.umlp.arcd.ToolConstants.ARG_CONF;
import static mc.umlp.arcd.ToolConstants.ARG_MODELPATH;
import static mc.umlp.arcd.ToolConstants.ARG_OUT;
import static mc.umlp.arcd.ToolConstants.ARG_SYMTABDIR;
import static mc.umlp.arcd.ToolConstants.ARG_SYNTHESIS;
import static mc.umlp.arcd.ToolConstants.WF_CREATE_SYMTAB;
import static mc.umlp.arcd.ToolConstants.WF_INIT_CHECK;
import static mc.umlp.arcd.ToolConstants.WF_INIT_SYMTAB;
import static mc.umlp.arcd.ToolConstants.WF_PARSE;
import static mc.umlp.arcd.ToolConstants.WF_PRE_CHECK_TRAFO;
import static mc.umlp.arcd.ToolConstants.WF_RUN_CHECK;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Constructor;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import mc.MCG;
import mc.Parameters;
import mc.ProblemReport.Type;
/**
* Tool for {@link MontiSecArcAnalysis}.
* For terminal controlled session
*
* @author (last commit) $Author$
* @version $Revision$, $Date$
*
*/
public class WrapperMontiSecArcAnalysisTool extends MontiSecArcAnalysisTool {
/**
* Class of the dsl tool that is used.
*/
protected static Class<WrapperMontiSecArcAnalysisTool> toolClass = WrapperMontiSecArcAnalysisTool.class;
/**
* Generate test output to this folder.
*/
public static final String OUTPUT_TEST_FOLDER = "target/testOut";
/**
* Test symbol table directory.
*/
public static final String SYMTAB_FOLDER = "target/symtab";
public WrapperMontiSecArcAnalysisTool(String[] arguments) {
super(cleanArgumentList(arguments), getAnalysisParameter(arguments), getAnalysisConfPath(arguments));
}
/**
* The main method of this tool. Creates, initializes and starts
* {@link MontiSecArcAnalysisTool}. Takes a list of {@link DSLTool} arguments.
*
* @param a list of {@link DSLTool} arguments.
*/
public static void main(String[] arguments) {
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Start analysis...");
String line = "";
try {
while((line = console.readLine()) != null) {
MCG.initMonticoreGlobals();
MontiSecArcAnalysisTool tool = createTestToolWithoutJava(line.split("\\s"));
tool.init();
tool.run();
}
} catch (IOException e) {
MCG.getLogger().info(e.getMessage());
}
}
/**
* Terminal comands
*
* -analsisconfpath path/../..
* -synthesis secarc secAnalysisBeginners | secAnalysisAdvanced
* -synthesis secarc secFilterCriticalPort
* -synthesis secarc secFilterTrustlevel
* files
*
*
* @param files
* @param analysisParameter
* @param analysisConfPath
* @return
*/
protected static WrapperMontiSecArcAnalysisTool createTestToolWithoutJava(String[] arguments) {
String[] args = new String[] {
ARG_MODELPATH, "/home/user/workspace/MA-Paff/03.Implementierung/montiSecArcAnalysis/src/main/java",
ARG_CONF, "mc-test.cfg",
ARG_OUT, OUTPUT_TEST_FOLDER,
ARG_SYMTABDIR, SYMTAB_FOLDER,
ARG_ANALYSIS, Parameters.ALL, WF_PARSE,
ARG_ANALYSIS, Parameters.ALL, WF_INIT_SYMTAB,
ARG_ANALYSIS, Parameters.ALL, WF_CREATE_SYMTAB,
ARG_SYNTHESIS, Parameters.ALL, WF_INIT_CHECK,
ARG_SYNTHESIS, "arcd", WF_PRE_CHECK_TRAFO,
ARG_SYNTHESIS, Parameters.ALL, WF_RUN_CHECK,
//Uses analysis workflow
};
WrapperMontiSecArcAnalysisTool tool = null;
List<String> argsAsList = new LinkedList<String>();
argsAsList.addAll(Arrays.asList(args));
for (String mp : arguments) {
argsAsList.add(mp);
}
try {
Constructor<WrapperMontiSecArcAnalysisTool> constructor = toolClass.getConstructor(String[].class);
args = argsAsList.toArray(new String[argsAsList.size()]);
tool = constructor.newInstance((Object) args);
tool.setErrorLevel(Type.WARNING);
}
catch (Exception e) {
e.printStackTrace();
}
return tool;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment