Skip to content
Snippets Groups Projects
Commit df1cf762 authored by Serafim Simonov's avatar Serafim Simonov
Browse files

fix eternal loop

parent edf90997
Branches
Tags
No related merge requests found
...@@ -31,7 +31,7 @@ public class Settings { // NOPMD data class ...@@ -31,7 +31,7 @@ public class Settings { // NOPMD data class
@Parameter(names = { "-i", @Parameter(names = { "-i",
"--input" }, required = true, variableArity = true, converter = PathConverter.class, description = "Input architecture model directories") "--input" }, required = true, variableArity = true, converter = PathConverter.class, description = "Input architecture model directories")
private List<Path> inputModelPaths; private Path inputModelPaths;
@Parameter(names = { "-o", @Parameter(names = { "-o",
"--output" }, required = true, converter = PathConverter.class, description = "Output architecture model directory") "--output" }, required = true, converter = PathConverter.class, description = "Output architecture model directory")
...@@ -40,7 +40,7 @@ public class Settings { // NOPMD data class ...@@ -40,7 +40,7 @@ public class Settings { // NOPMD data class
@Parameter(names = { "-e", "--experiment" }, required = true, description = "Experiment name") @Parameter(names = { "-e", "--experiment" }, required = true, description = "Experiment name")
private String experimentName; private String experimentName;
public List<Path> getInputModelPaths() { public Path getInputModelPaths() {
return this.inputModelPaths; return this.inputModelPaths;
} }
......
...@@ -25,23 +25,29 @@ import org.xml.sax.InputSource; ...@@ -25,23 +25,29 @@ import org.xml.sax.InputSource;
import kieker.analysis.generic.graph.mtree.utils.Pair; import kieker.analysis.generic.graph.mtree.utils.Pair;
import teetime.framework.AbstractConsumerStage; import teetime.framework.AbstractConsumerStage;
import teetime.framework.OutputPort;
import teetime.stage.basic.AbstractTransformation; import teetime.stage.basic.AbstractTransformation;
public class EsmDataFlowAnalysisStage extends AbstractTransformation<List<File>, Output> { public class EsmDataFlowAnalysisStage extends AbstractConsumerStage<List<File>> {
private List<String> dataflow = new ArrayList<String>(); private List<String> dataflow = new ArrayList<String>();
private List<String> contentFile = new ArrayList<String>(); private List<String> contentFile = new ArrayList<String>();
protected final OutputPort<Output> outputPort = this.createOutputPort();
public OutputPort<Output> getOutputPort(){
return this.outputPort;
}
@Override @Override
protected void execute(List<File> files) throws Exception { protected void execute(List<File> files) throws Exception {
//System.out.println("Files:"+ files.size());
Output out = new Output(); Output out = new Output();
for(File file : files) { for(File file : files) {
//Extract xml //Extract xml
System.out.println("File:"+ file.getAbsolutePath()); // System.out.println("File:"+ file.getAbsolutePath());
String xml = new String(Files.readAllBytes(Paths.get(file.getAbsolutePath()))); String xml = new String(Files.readAllBytes(Paths.get(file.getAbsolutePath())));
// Get main structures // Get main structures
List<List<Node>> subRoutineBodies = XPathParser.getSubroutineContents(xml); List<List<Node>> subRoutineBodies = XPathParser.getSubroutineContents(xml);
...@@ -58,13 +64,15 @@ public class EsmDataFlowAnalysisStage extends AbstractTransformation<List<File>, ...@@ -58,13 +64,15 @@ public class EsmDataFlowAnalysisStage extends AbstractTransformation<List<File>,
dataflow.addAll(dfInMain); dataflow.addAll(dfInMain);
out.setDataflow(dataflow);
out.setFileContent(contentFile);
} }
out.setDataflow(dataflow);
out.setFileContent(contentFile);
System.out.println("Done");
this.outputPort.send(out); this.outputPort.send(out);
} }
...@@ -79,7 +87,7 @@ public class EsmDataFlowAnalysisStage extends AbstractTransformation<List<File>, ...@@ -79,7 +87,7 @@ public class EsmDataFlowAnalysisStage extends AbstractTransformation<List<File>,
String contentLine = "{"+fileId+"};{"+name+"};SUBROUTINE"; String contentLine = "{"+fileId+"};{"+name+"};SUBROUTINE";
this.contentFile.add(contentLine); this.contentFile.add(contentLine);
String dataFlowLine = "{"+fileId+"};"+name+"};"; String dataFlowLine = "{"+fileId+"};{"+name+"};";
dataflowInSub = analyzeExecutionPart(body,commonBlocks, blackList, dataFlowLine); dataflowInSub = analyzeExecutionPart(body,commonBlocks, blackList, dataFlowLine);
} }
return dataflowInSub; return dataflowInSub;
...@@ -95,7 +103,7 @@ public class EsmDataFlowAnalysisStage extends AbstractTransformation<List<File>, ...@@ -95,7 +103,7 @@ public class EsmDataFlowAnalysisStage extends AbstractTransformation<List<File>,
String contentLine = "{"+fileId+"};{"+name+"};FUNCTION"; String contentLine = "{"+fileId+"};{"+name+"};FUNCTION";
this.contentFile.add(contentLine); this.contentFile.add(contentLine);
String dataFlowLine = "{"+fileId+"};"+name+"};"; String dataFlowLine = "{"+fileId+"};{"+name+"};";
dataflowInFunc = analyzeExecutionPart(body, commonBlocks, blackList, dataFlowLine); dataflowInFunc = analyzeExecutionPart(body, commonBlocks, blackList, dataFlowLine);
} }
return dataflowInFunc; return dataflowInFunc;
......
...@@ -31,12 +31,13 @@ public class OutputStage extends AbstractConsumerStage<Output>{ ...@@ -31,12 +31,13 @@ public class OutputStage extends AbstractConsumerStage<Output>{
for (String line : element.getDataflow()) { for (String line : element.getDataflow()) {
writerdf.write(line + System.lineSeparator()); writerdf.write(line + System.lineSeparator());
} }
writerdf.close(); // writerdf.close();
for (String line : element.getFileContent()) { for (String line : element.getFileContent()) {
writerfc.write(line + System.lineSeparator()); writerfc.write(line + System.lineSeparator());
} }
// writerdf.close(); writerdf.close();
writerfc.close(); writerfc.close();
System.out.println("Successfully wrote lines to files."); System.out.println("Successfully wrote lines to files.");
} catch (IOException e) { } catch (IOException e) {
System.out.println("An error occurred while writing to the file."); System.out.println("An error occurred while writing to the file.");
......
...@@ -12,21 +12,22 @@ import teetime.framework.AbstractProducerStage; ...@@ -12,21 +12,22 @@ import teetime.framework.AbstractProducerStage;
public class ReadStage extends AbstractProducerStage<List<File>> { public class ReadStage extends AbstractProducerStage<List<File>> {
private final List<Path> rootPath; private final Path rootPath;
public ReadStage(List<Path> list) { public ReadStage(Path list) {
this.rootPath = list; this.rootPath = list;
} }
@Override @Override
protected void execute() throws Exception { protected void execute() throws Exception {
for(Path path: rootPath) {
File folder = new File(path.toAbsolutePath().toString()); File folder = new File(this.rootPath.toAbsolutePath().toString());
List<File> files =Arrays.asList(folder.listFiles()); List<File> files =Arrays.asList(folder.listFiles());
System.out.println("Files sent: "+ files.size()); // System.out.println("Files sent: "+ files.size());
this.outputPort.send(files); this.outputPort.send(files);
this.workCompleted();
}
} }
......
...@@ -228,11 +228,11 @@ public class XPathParser { ...@@ -228,11 +228,11 @@ public class XPathParser {
for(int i = 0; i<args.getLength();i++) { for(int i = 0; i<args.getLength();i++) {
Element arg = (Element)args.item(i); Element arg = (Element)args.item(i);
System.out.println(arg.getElementsByTagName("n").getLength()); // System.out.println(arg.getElementsByTagName("n").getLength());
NodeList ns =arg.getElementsByTagName("n"); NodeList ns =arg.getElementsByTagName("n");
for(int j = 0;j<ns.getLength();j++) { for(int j = 0;j<ns.getLength();j++) {
Element n = (Element)ns.item(j); Element n = (Element)ns.item(j);
System.out.println(n.getTextContent()); // System.out.println(n.getTextContent());
result.add(n.getTextContent()); result.add(n.getTextContent());
} }
} }
...@@ -247,7 +247,7 @@ public class XPathParser { ...@@ -247,7 +247,7 @@ public class XPathParser {
NodeList nameElems = e.getElementsByTagName("n"); NodeList nameElems = e.getElementsByTagName("n");
for(int i=0;i<nameElems.getLength();i++) { for(int i=0;i<nameElems.getLength();i++) {
result.add(nameElems.item(i).getNodeValue()); result.add(nameElems.item(i).getTextContent());
} }
...@@ -322,57 +322,60 @@ public class XPathParser { ...@@ -322,57 +322,60 @@ public class XPathParser {
public static String getsubroutineId(List<Node> body) { public static String getsubroutineId(List<Node> body) {
List<String> result = new ArrayList<String>(); //List<String> result = new ArrayList<String>();
Element e = (Element)body.get(0); Element e = (Element)body.get(0);
// System.out.println("name" +e.getNodeName().equals("subroutine-stmt"));
NodeList nameElems = e.getElementsByTagName("n"); NodeList nameElems = e.getElementsByTagName("n");
// System.out.println("size: "+ nameElems.getLength());
//for(int i=0;i<nameElems.getLength();i++) {
for(int i=0;i<nameElems.getLength();i++) { // result.add(nameElems.item(0).getTextContent());
result.add(nameElems.item(i).getNodeValue()); //}
}
return result.get(0); return nameElems.item(0).getTextContent();
//return result.get(0);
} }
public static String getFunctionId(List<Node> body) { public static String getFunctionId(List<Node> body) {
List<String> result = new ArrayList<String>(); //List<String> result = new ArrayList<String>();
Element e = (Element)body.get(0); Element e = (Element)body.get(0);
NodeList nameElems = e.getElementsByTagName("n"); NodeList nameElems = e.getElementsByTagName("n");
for(int i=0;i<nameElems.getLength();i++) { //for(int i=0;i<nameElems.getLength();i++) {
result.add(nameElems.item(i).getNodeValue()); // result.add(nameElems.item(i).getNodeValue());
} //}
return result.get(0); return nameElems.item(0).getTextContent();
//return result.get(0);
} }
public static String getCallStmtId(Node callStmt) { public static String getCallStmtId(Node callStmt) {
List<String> result = new ArrayList<String>(); //List<String> result = new ArrayList<String>();
Element e = (Element)callStmt; Element e = (Element)callStmt;
NodeList nameElems = e.getElementsByTagName("n"); NodeList nameElems = e.getElementsByTagName("n");
for(int i=0;i<nameElems.getLength();i++) { // for(int i=0;i<nameElems.getLength();i++) {
result.add(nameElems.item(i).getNodeValue()); //**/ result.add(nameElems.item(i).getNodeValue());
} // }
return result.get(0); return nameElems.item(0).getTextContent();
} }
public static String getCommonBlockId(Node commonBlock) { public static String getCommonBlockId(Node commonBlock) {
List<String> result = new ArrayList<String>(); //List<String> result = new ArrayList<String>();
Element e = (Element)commonBlock; Element e = (Element)commonBlock;
NodeList nameElems = e.getElementsByTagName("n"); NodeList nameElems = e.getElementsByTagName("n");
for(int i=0;i<nameElems.getLength();i++) { // for(int i=0;i<nameElems.getLength();i++) {
result.add(nameElems.item(i).getNodeValue()); // result.add(nameElems.item(i).getNodeValue());
} // }
return result.get(0); //return result.get(0);
return nameElems.item(0).getTextContent();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment