public void CreateFile() { UMLProject project = null; project = UMLProject.GetInstance(); List<IUMLElement> elements = project.GetOwnedElements(); if (elements.Count > 0) { UMLFile file = new UMLFile(); file.Owner = elements[0]; file.Name = "Test"; file.Dets = 2; file.Rets = 3; file.Save(); Assert.AreNotEqual(null, file); Assert.AreNotEqual(String.Empty, file.Guid); Assert.AreNotEqual(null, file.Guid); Assert.AreEqual("Test", file.Name); Assert.AreNotEqual(String.Empty, file.Name); Assert.AreNotEqual(null, file.Name); Assert.AreNotEqual(String.Empty, file.PathName); Assert.AreNotEqual(null, file.PathName); Assert.AreEqual(2, file.Dets); Assert.AreEqual(3, file.Rets); } }
public void CreateFile() { UMLProject project = null; project = UMLProject.GetInstance(); List <IUMLElement> elements = project.GetOwnedElements(); if (elements.Count > 0) { UMLFile file = new UMLFile(); file.Owner = elements[0]; file.Name = "Test"; file.Dets = 2; file.Rets = 3; file.Save(); Assert.AreNotEqual(null, file); Assert.AreNotEqual(String.Empty, file.Guid); Assert.AreNotEqual(null, file.Guid); Assert.AreEqual("Test", file.Name); Assert.AreNotEqual(String.Empty, file.Name); Assert.AreNotEqual(null, file.Name); Assert.AreNotEqual(String.Empty, file.PathName); Assert.AreNotEqual(null, file.PathName); Assert.AreEqual(2, file.Dets); Assert.AreEqual(3, file.Rets); } }
public void LoadTreeViewAttributes(TreeNode fileNode) { UMLFile file = (UMLFile)fileNode.Tag; bool checkFile = false; file.LoadCollections(); UMLAttributeCollection attributes = file.Attributes; foreach (UMLAttribute fileAttribute in attributes) { TreeNode node = new TreeNode(); node.Text = fileAttribute.Name; node.Tag = fileAttribute; foreach (UMLAttribute collaborationAttribute in Collaboration.Dets) { if (collaborationAttribute.Guid == fileAttribute.Guid) { node.Checked = true; checkFile = true; break; } } fileNode.Nodes.Add(node); } fileNode.Checked = checkFile; }
private void LoadTreeViewAux() { fileAux = Collaboration.GetFileAux(); TreeNode node = new TreeNode(); node.Text = fileAux.Name; node.Tag = fileAux; LoadTreeViewAttributes(node); treeViewAux.Nodes.Add(node); treeViewAux.ExpandAll(); }
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e) { if (treeViewAux.Nodes.Count > 0) { AttributeName getName = new AttributeName(); if (getName.ShowDialog() == DialogResult.OK) { TreeNode fileNode = treeViewAux.Nodes[0]; UMLFile file = (UMLFile)fileNode.Tag; UMLAttribute attribute = new UMLAttribute(); attribute.Owner = file; attribute.Name = getName.NameAttribute; file.Attributes.Add(attribute); TreeNode newNode = new TreeNode(); newNode.Tag = attribute; newNode.Text = getName.NameAttribute; fileNode.Nodes.Add(newNode); fileNode.ExpandAll(); } } }
public List <UMLFile> CreateFiles(IDictionary relationships) { List <PreFile> prefiles = new List <PreFile>(); List <PreRET> retsToDelete; List <UMLFile> files = new List <UMLFile>(); IDictionary <String, String> tnamemap; IDictionary <String, UMLClass> tclasses; UMLFile tfile; String tname; int tdets; UMLAttribute tattrib; //0. Pre-Pre-Processing (set dependencies in relationships) foreach (DictionaryEntry entry in relationships) { UMLRelationship r = (UMLRelationship)entry.Value; if (r is UMLDependency) { foreach (DictionaryEntry entry2 in relationships) { UMLRelationship q = (UMLRelationship)entry2.Value; if (q is UMLAssociation) { if ((((UMLDependency)r).Client.Guid.Equals(((UMLAssociation)q).End1.Participant.Guid)) && (((UMLDependency)r).Supplier.Guid.Equals(((UMLAssociation)q).End2.Participant.Guid)) || (((UMLDependency)r).Client.Guid.Equals(((UMLAssociation)q).End2.Participant.Guid)) && (((UMLDependency)r).Supplier.Guid.Equals(((UMLAssociation)q).End1.Participant.Guid))) { ((UMLAssociation)q).DependencyType = "D"; } } } } } //1. PreFile Generation (Pre-Processing) foreach (DictionaryEntry entry in relationships) { UMLRelationship r = (UMLRelationship)entry.Value; if (!(r is UMLDependency)) { ActionKey key = new ActionKey(r); AbstractAction action = map.GetAction(key); if (action != null) { action.Execute(r, map, prefiles); } else { throw new ArgumentException("There is no defined action for the actionKey given."); } } } //2. File Generation (Processing) if (prefiles.Count == 0) { return(null); } else { //2.1 Clean-up (eliminate parents in PreFiles - Generalization cases) foreach (PreFile prefile in prefiles) { retsToDelete = new List <PreRET>(); foreach (PreRET preret in prefile.Rets) { foreach (PreRET parent in preret.Parents) { //2.1.1 Merge preret.Merge(parent); //mark parent ret for deletion if (!retsToDelete.Contains(parent)) { retsToDelete.Add(parent); } } } //2.1.2 Deletion (optimized since rets are only in one file) foreach (PreRET retToDelete in retsToDelete) { prefile.Rets.Remove(retToDelete); } //2.1.3 File generation tfile = new UMLFile(); //Rets tfile.Rets = prefile.Rets.Count; //Dets & Name tdets = 0; tname = ""; tnamemap = new Dictionary <String, String>(); tclasses = new Dictionary <String, UMLClass>(); foreach (PreRET ret in prefile.Rets) { UMLFile.RET tret = new UMLFile.RET(); foreach (UMLClass c in ret.Classes) { tnamemap[c.Name] = c.Name; tret.Classes.Add(c); if (!(tclasses.ContainsKey(c.Name))) { tclasses[c.Name] = c; c.LoadAttributes(); tdets += c.Attributes.Count; foreach (UMLAttribute attrib in c.Attributes) { tattrib = new UMLAttribute(); tattrib.Name = c.Name + "." + attrib.Name; tfile.Attributes.Add(tattrib); } } } tfile.RetsCollection.Add(tret); } foreach (KeyValuePair <String, String> kvp in tnamemap) { tname += kvp.Value + "_"; } tfile.Dets = tdets; tfile.Dets += prefile.DefaultDets; tname = tname.Remove(tname.Length - 1, 1); //limit File name size to 50 chars (could cause name collisions) tfile.Name = tname.Length > 50 ? tname.Substring(1, 50) : tname; files.Add(tfile); } return(files); } }
public FileEdit(UMLFile file) { InitializeComponent(); File = file; }
/// <summary> /// Loads the files /// </summary> public void LoadFilesExcel() { DataTable dtResult = new DataTable(); dtResult = GetDataTable(_fileName, FILE_SHEET, "Name <> '' AND AttributesList <> ''"); UMLPackage pack = new UMLPackage(); pack.Name = "FileImport"; pack.Owner = _designModel; Packages.Add(pack); foreach (DataRow dr in dtResult.Rows) { UMLFile file = new UMLFile(); file.Name = dr["Name"].ToString().Trim(); string test = file.Name.GetType().Name; file.Dets = Convert.ToInt32(dr["Dets"].ToString()); file.Rets = Convert.ToInt32(dr["Rets"].ToString()); file.Type = dr["Type"].ToString(); file.Owner = pack; string[] attributes = dr["AttributesList"].ToString().Split(','); foreach (string a in attributes) { UMLAttribute attri = new UMLAttribute(); attri.Name = a.Trim(); attri.Owner = file; file.Attributes.Add(attri); } AddFile(file); } }
/// <summary> /// Loads the use cases and collaborations /// </summary> public void LoadUseCasesCollaborationsExcel() { DataTable dtResult = new DataTable(); dtResult = GetDataTable(_fileName, COLLABORATION_SHEET, "Name <> ''"); UMLPackage pack = new UMLPackage(); pack.Name = "UseCaseImport"; pack.Owner = _scenariosModel; Packages.Add(pack); foreach (DataRow dr in dtResult.Rows) { UMLUseCase useCase = new UMLUseCase(); useCase.Name = dr["UseCase"].ToString().Trim(); useCase.Owner = pack; useCase = AddUseCase(useCase); UMLCollaboration collaboration = new UMLCollaboration(); collaboration.Name = dr["Name"].ToString().Trim(); collaboration.Type = dr["Type"].ToString(); if (dr["SendMessage"].ToString() == "X") { collaboration.SendMessage = true; } if (dr["GenerateAction"].ToString() == "X") { collaboration.GenerateAction = true; } string[] filesName = dr["FilesList"].ToString().Split(','); foreach (string fName in filesName) { UMLFile file = new UMLFile(); file.Name = fName.Trim(); file = AddFile(file); collaboration.Files.Add(file); } collaboration.Owner = useCase; collaboration = AddCollaboration(collaboration); useCase.Collaborations.Add(collaboration); } }
/// <summary> /// Adds a new file /// </summary> /// <param name="file"></param> /// <returns></returns> private UMLFile AddFile(UMLFile file) { file.Stereotype = Constants.UMLFile.STEREOTYPE; foreach (UMLFile f in Files) { if (file.Name == f.Name) { f.Dets = file.Dets; f.Rets = file.Rets; f.Type = file.Type; f.Attributes = file.Attributes; f.Owner = file.Owner; f.Stereotype = file.Stereotype; return f; } } Files.Add(file); return file; }
public List<UMLFile> CreateFiles(IDictionary relationships) { List<PreFile> prefiles = new List<PreFile>(); List<PreRET> retsToDelete; List<UMLFile> files = new List<UMLFile>(); IDictionary<String, String> tnamemap; IDictionary<String, UMLClass> tclasses; UMLFile tfile; String tname; int tdets; UMLAttribute tattrib; //0. Pre-Pre-Processing (set dependencies in relationships) foreach (DictionaryEntry entry in relationships) { UMLRelationship r = (UMLRelationship)entry.Value; if (r is UMLDependency) { foreach (DictionaryEntry entry2 in relationships) { UMLRelationship q = (UMLRelationship)entry2.Value; if (q is UMLAssociation) { if ((((UMLDependency)r).Client.Guid.Equals(((UMLAssociation)q).End1.Participant.Guid)) && (((UMLDependency)r).Supplier.Guid.Equals(((UMLAssociation)q).End2.Participant.Guid)) || (((UMLDependency)r).Client.Guid.Equals(((UMLAssociation)q).End2.Participant.Guid)) && (((UMLDependency)r).Supplier.Guid.Equals(((UMLAssociation)q).End1.Participant.Guid))) { ((UMLAssociation)q).DependencyType = "D"; } } } } } //1. PreFile Generation (Pre-Processing) foreach (DictionaryEntry entry in relationships) { UMLRelationship r = (UMLRelationship)entry.Value; if (!(r is UMLDependency)) { ActionKey key = new ActionKey(r); AbstractAction action = map.GetAction(key); if (action != null) { action.Execute(r, map, prefiles); } else { throw new ArgumentException("There is no defined action for the actionKey given."); } } } //2. File Generation (Processing) if (prefiles.Count == 0) { return null; } else { //2.1 Clean-up (eliminate parents in PreFiles - Generalization cases) foreach (PreFile prefile in prefiles) { retsToDelete = new List<PreRET>(); foreach (PreRET preret in prefile.Rets) { foreach (PreRET parent in preret.Parents) { //2.1.1 Merge preret.Merge(parent); //mark parent ret for deletion if (!retsToDelete.Contains(parent)) { retsToDelete.Add(parent); } } } //2.1.2 Deletion (optimized since rets are only in one file) foreach (PreRET retToDelete in retsToDelete) { prefile.Rets.Remove(retToDelete); } //2.1.3 File generation tfile = new UMLFile(); //Rets tfile.Rets = prefile.Rets.Count; //Dets & Name tdets = 0; tname = ""; tnamemap = new Dictionary<String, String>(); tclasses = new Dictionary<String, UMLClass>(); foreach (PreRET ret in prefile.Rets) { UMLFile.RET tret = new UMLFile.RET(); foreach (UMLClass c in ret.Classes) { tnamemap[c.Name] = c.Name; tret.Classes.Add(c); if (!(tclasses.ContainsKey(c.Name))) { tclasses[c.Name] = c; c.LoadAttributes(); tdets += c.Attributes.Count; foreach (UMLAttribute attrib in c.Attributes) { tattrib = new UMLAttribute(); tattrib.Name = c.Name + "." + attrib.Name; tfile.Attributes.Add(tattrib); } } } tfile.RetsCollection.Add(tret); } foreach (KeyValuePair<String,String> kvp in tnamemap) { tname += kvp.Value + "_"; } tfile.Dets = tdets; tfile.Dets += prefile.DefaultDets; tname = tname.Remove(tname.Length - 1, 1); //limit File name size to 50 chars (could cause name collisions) tfile.Name = tname.Length > 50 ? tname.Substring(1, 50) : tname; files.Add(tfile); } return files; } }