Пример #1
0
        public static DataModels.SpecIF ReadDataFromSpecIfFile(string path)
        {
            DataModels.SpecIF result = null;

            StreamReader file = null;

            try
            {
                file = new StreamReader(path);

                JsonSerializer serializer = new JsonSerializer();

                result = (DataModels.SpecIF)serializer.Deserialize(file, typeof(DataModels.SpecIF));
            }
            catch (Exception exception)
            {
                Debug.WriteLine(path);
                Debug.WriteLine(exception);
            }
            finally
            {
                if (file != null)
                {
                    file.Close();
                }
            }

            return(result);
        }
Пример #2
0
        public override List <Node> GetAllHierarchyRootNodes(string projectID = null)
        {
            List <Node> result = new List <Node>();

            foreach (KeyValuePair <string, DataModels.SpecIF> keyValuePair in SpecIfData)
            {
                DataModels.SpecIF specIF = keyValuePair.Value;

                if (projectID != null)
                {
                    if (specIF.ID == projectID)
                    {
                        result.AddRange(specIF.Hierarchies);
                        break;
                    }
                }
                else
                {
                    result.AddRange(specIF.Hierarchies);
                }
            }

            // delete child nodes in result
            //foreach(Node rootNode in result)
            //{
            //    rootNode.Nodes = new List<Node>();
            //}

            return(result);
        }
Пример #3
0
        public override DataModels.SpecIF GetProject(ISpecIfMetadataReader metadataReader, string projectID,
                                                     List <Key> hierarchyFilter = null, bool includeMetadata = true)
        {
            DataModels.SpecIF result = null;

            foreach (KeyValuePair <string, DataModels.SpecIF> keyValuePair in SpecIfData)
            {
                if (keyValuePair.Value.ID == projectID)
                {
                    result = keyValuePair.Value;
                    break;
                }
            }

            return(result);
        }
Пример #4
0
        public static void SaveSpecIfToFile(DataModels.SpecIF data, string path)
        {
            StreamWriter sw     = new StreamWriter(path);
            JsonWriter   writer = new JsonTextWriter(sw)
            {
                Formatting = Formatting.Indented
            };

            JsonSerializer serializer = new JsonSerializer()
            {
                NullValueHandling = NullValueHandling.Ignore
            };

            serializer.Serialize(writer, data);

            writer.Flush();
            writer.Close();
        }
Пример #5
0
        public override Node GetParentNode(Key childNode)
        {
            Node result = null;

            foreach (KeyValuePair <string, DataModels.SpecIF> keyValuePair in SpecIfData)
            {
                DataModels.SpecIF specif = keyValuePair.Value;

                foreach (Node hierarchy in specif.Hierarchies)
                {
                    FindParentNodeRecusrsively(hierarchy, childNode, ref result);
                    if (result != null)
                    {
                        break;
                    }
                }
            }

            return(result);
        }
Пример #6
0
        private void InitializeDataRecusrsively(string currentPath)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(currentPath);

            FileInfo[] specifFiles = directoryInfo.GetFiles("*.specif");

            foreach (FileInfo fileInfo in specifFiles)
            {
                DataModels.SpecIF currentSepcIF = SpecIfFileReaderWriter.ReadDataFromSpecIfFile(fileInfo.FullName);

                if (!SpecIfData.ContainsKey(fileInfo.FullName))
                {
                    SpecIfData.Add(fileInfo.FullName, currentSepcIF);
                }
            }

            foreach (DirectoryInfo subDirectoryInfo in directoryInfo.GetDirectories())
            {
                InitializeDataRecusrsively(subDirectoryInfo.FullName);
            }
        }
Пример #7
0
        public override Node GetNodeByKey(Key key)
        {
            Node result = null;

            foreach (KeyValuePair <string, DataModels.SpecIF> keyValuePair in SpecIfData)
            {
                DataModels.SpecIF specif = keyValuePair.Value;

                foreach (Node hierarchy in specif.Hierarchies)
                {
                    Node parentNode = null;
                    FindNodeRecusrsively(hierarchy, key, ref parentNode);

                    if (parentNode != null)
                    {
                        result = parentNode;
                        break;
                    }
                }
            }

            return(result);
        }
Пример #8
0
        public override List <Node> GetChildNodes(Key parentNodeKey)
        {
            List <Node> result = new List <Node>();

            foreach (KeyValuePair <string, DataModels.SpecIF> keyValuePair in SpecIfData)
            {
                DataModels.SpecIF specif = keyValuePair.Value;

                foreach (Node hierarchy in specif.Hierarchies)
                {
                    Node parentNode = null;
                    FindNodeRecusrsively(hierarchy, parentNodeKey, ref parentNode);

                    if (parentNode != null)
                    {
                        result.AddRange(parentNode.Nodes);
                        break;
                    }
                }
            }

            return(result);
        }
        private void ExecuteExportToSpecIfCommand()
        {
            if (_repository != null)
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();

                saveFileDialog.Filter = "SpecIF files|*.specif";

                DialogResult dialogResult = saveFileDialog.ShowDialog();

                if (dialogResult == DialogResult.OK)
                {
                    try
                    {
                        EAAPI.Package selectedPackage = _repository.GetTreeSelectedPackage();

                        DataModels.SpecIF specIF = null;

                        //EaUmlToSpecIfConverter converter;

                        //converter = new EaUmlToSpecIfConverter(_repository);

                        //specIF = converter.ConvertModelToSpecIF(selectedPackage);

                        SpecIfFileReaderWriter.SaveSpecIfToFile(specIF, saveFileDialog.FileName);

                        MessageBox.Show("SpecIF export successfully finished!", "Information",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Пример #10
0
        private void InitializeMetadataRecusrsively(string currentPath)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(currentPath);

            FileInfo[] specifFiles = directoryInfo.GetFiles("*.specif");

            foreach (FileInfo fileInfo in specifFiles)
            {
                DataModels.SpecIF currentSepcIF = SpecIfFileReaderWriter.ReadDataFromSpecIfFile(fileInfo.FullName);

                _metaData.DataTypes.AddRange(currentSepcIF.DataTypes);

                _metaData.PropertyClasses.AddRange(currentSepcIF.PropertyClasses);

                _metaData.ResourceClasses.AddRange(currentSepcIF.ResourceClasses);

                _metaData.StatementClasses.AddRange(currentSepcIF.StatementClasses);
            }

            foreach (DirectoryInfo subDirectoryInfo in directoryInfo.GetDirectories())
            {
                InitializeMetadataRecusrsively(subDirectoryInfo.FullName);
            }
        }
Пример #11
0
        private void InitializeMetadata()
        {
            _metaData = new DataModels.SpecIF();

            InitializeMetadataRecusrsively(_metadataRootPath);
        }
Пример #12
0
 public SpecIfFileMetadataReader(DataModels.SpecIF metaData)
 {
     _metaData = metaData;
 }
Пример #13
0
 public SpecIfFileMetadataReader()
 {
     _metaData = SpecIfFileReaderWriter.ReadDataFromSpecIfFile(@"c:\specif\metadata.specif");
 }
 public override void UpdateProject(ISpecIfMetadataWriter metadataWriter, DataModels.SpecIF project)
 {
     throw new NotImplementedException();
 }
 public override void AddProject(ISpecIfMetadataWriter metadataWriter, DataModels.SpecIF project, string integrationID = null)
 {
     throw new NotImplementedException();
 }