private void ToOATS(XmlDocument xmiDoc) { String toTestRegex = "{click},{setText;[data1.username]},{pressTab}"; Boolean testedRegex = RegexTest(toTestRegex); UmlModel model = new UmlModel(""); XmiImporter importer = new XmiImporter(); String name = ""; model = importer.FromXmi(xmiDoc, ref name); string[] parts = xmiDoc.BaseURI.Split(new char[] { '/' }); string fName = parts[parts.Length - 1]; fName = fName.Substring(0, fName.IndexOf('.')); filterToActDiagOnly(ref model); try { foreach (UmlActivityDiagram actDiag in model.Diagrams) { tabs = 0; UmlToGraphOATS umlToGraphOATS = new UmlToGraphOATS(); //sw = new StreamWriter(Configuration.getInstance().getConfiguration(Configuration.Fields.workspacepath) + fname + "_OATS.java"); //sw = new StreamWriter(Configuration.getInstance().getConfiguration(Configuration.Fields.workspacepath) + actDiag.Name + "_OATS.java"); sw = new StreamWriter(".//TestOutput//script.java"); dg = umlToGraphOATS.ActivityDiagramToGraph(actDiag, model); OrderEdges(dg); OrderActDiagramTransitions(actDiag); currState = dg.RootNode; curActDiag = actDiag; S(); sw.Close(); // break; } } catch (Exception e) { String message = e.Message; if (sw != null) { sw.Close(); } throw; } }
public void ParseXmiToOATS(string XmiPath, string OATSPath) { UmlModel model = new UmlModel(""); XmlDocument xmiDoc = new XmlDocument(); xmiDoc.Load(XmiPath); XmiImporter importer = new XmiImporter(); String name = ""; model = importer.FromXmi(xmiDoc, ref name); if (model.Diagrams.Count(X => X is UmlActivityDiagram) > 1) { throw new Exception("Only one Activity diagram allowed! (For now)"); } try { UmlToFsm umlToFsm = new UmlToFsm(); foreach (UmlActivityDiagram actDiag in model.Diagrams) { tabs = 0; sw = new StreamWriter(OATSPath + "\\script.java"); fsm = umlToFsm.ActivityDiagramToFsm(actDiag, model); //fsm. currState = fsm.InitialState; curActDiag = actDiag; S(); sw.Close(); break;//only one } } catch (Exception ex) { if (sw != null) { sw.Close(); } throw ex; } }