Ejemplo n.º 1
0
        /// <summary>
        /// Extracts the components/types assemblies from the given vertex.
        /// </summary>
        /// <param name="pVertex">Vertex from the experiment graph.</param>
        private void ExtractFilesFromNode(ExperimentNode pVertex)
        {
            if (pVertex is ComponentNode) // Regular component
            {
                ComponentMetadata metaData = (ComponentMetadata)pVertex.Data.Metadata;
                if (metaData != null)
                {
                    ComponentMetadataDefinition metaDataDef = metaData.ComponentMetadataDefinition;
                    if (metaDataDef != null)
                    {
                        bool include;
                        if (m_config.IncludeOtherPackagesAssemblies)
                        {
                            include = true;
                        }
                        else
                        {
                            //determine if component is independent or is coming from another package
                            include = !IsAssemblyInAnotherPackage(metaDataDef.Assembly);
                        }

                        if (include)
                        {
                            // Component assembly
                            this.m_componentAssemblies.Add(Path.GetFullPath(metaDataDef.Assembly));

                            // Extracting types from IOSpec
                            ExtractTypesFromIOSpec(metaDataDef.IOSpecDefinition);
                        }
                    }

                    ConfigWrapper config = metaData.ConfigWrapper;
                    if (config != null)
                    {
                        // Extracting paths for files/directories from components' configuration
                        foreach (ConfigPropertyObject configValue in config.ConfigValues.Values)
                        {
                            // Files
                            if (configValue.Type == "TraceLabSDK.Component.Config.FilePath" && configValue.Value != null)
                            {
                                // Independent files
                                if (configValue.Value is TraceLab.Core.Components.TraceLabFilePath == false)
                                {
                                    if (this.m_config.IncludeIndependentFilesDirs)
                                    {
                                        var filePath = (TraceLabSDK.Component.Config.FilePath)configValue.Value;
                                        if (File.Exists(filePath.Absolute))
                                        {
                                            PackageFileInfo packageFileInfo = new PackageFileInfo(filePath);
                                            m_files.Add(packageFileInfo);

                                            //Change config value relative path -> this path is saved within experiment (note, we operate on the experiment clone)
                                            //so that relative path is in the subfolder of Experiment folder
                                            filePath.Relative = packageFileInfo.RelativeLocation;
                                        }
                                    }
                                }
                                // Files contained in a package
                                else
                                {
                                    if (this.m_config.IncludeOtherPackagesFilesDirs)
                                    {
                                        //TraceLabFilePath represents the file reference located in the package
                                        var packageFilePath = (TraceLabFilePath)configValue.Value;
                                        if (File.Exists(packageFilePath.Absolute))
                                        {
                                            PackageFileInfo packageFileInfo = new PackageFileInfo(packageFilePath);
                                            m_files.Add(packageFileInfo);

                                            //change the configValue to basic FilePath, (not TraceLabFilePath in the package), with updated Relative Path
                                            //so that relative path is in the subfolder of Experiment folder
                                            TraceLabSDK.Component.Config.FilePath basicFilePath = new TraceLabSDK.Component.Config.FilePath();
                                            basicFilePath.Init(packageFilePath.Absolute, packageFilePath.DataRoot);
                                            basicFilePath.Relative = packageFileInfo.RelativeLocation;
                                            configValue.Value      = basicFilePath;
                                        }
                                    }
                                }
                            }
                            // Directories
                            else if (configValue.Type == "TraceLabSDK.Component.Config.DirectoryPath" && configValue.Value != null)
                            {
                                // Independent directories
                                if (configValue.Value is TraceLab.Core.Components.TraceLabDirectoryPath == false)
                                {
                                    if (this.m_config.IncludeIndependentFilesDirs)
                                    {
                                        var dirPath = (TraceLabSDK.Component.Config.DirectoryPath)configValue.Value;
                                        if (Directory.Exists(dirPath.Absolute))
                                        {
                                            PackageFileInfo packageDirectoryInfo = new PackageFileInfo(dirPath);
                                            m_directories.Add(packageDirectoryInfo);

                                            //Change config value relative path -> this path is saved within experiment (note, we operate on the experiment clone)
                                            //so that relative path is in the subfolder of Experiment folder
                                            dirPath.Relative = packageDirectoryInfo.RelativeLocation;
                                        }
                                    }
                                }
                                // Directories contained in a package
                                else
                                {
                                    if (this.m_config.IncludeOtherPackagesFilesDirs)
                                    {
                                        var packageDirPath = (TraceLabDirectoryPath)configValue.Value;
                                        if (Directory.Exists(packageDirPath.Absolute))
                                        {
                                            PackageFileInfo packageDirInfo = new PackageFileInfo(packageDirPath);
                                            m_directories.Add(packageDirInfo);

                                            //change the configValue to basic FilePath, (not TraceLabFilePath in the package), with updated Relative Path
                                            //so that relative path is in the subfolder of Experiment folder
                                            TraceLabSDK.Component.Config.DirectoryPath basicFilePath = new TraceLabSDK.Component.Config.DirectoryPath();
                                            basicFilePath.Init(packageDirPath.Absolute, packageDirPath.DataRoot);
                                            basicFilePath.Relative = packageDirInfo.RelativeLocation;
                                            configValue.Value      = basicFilePath;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (pVertex is CompositeComponentNode) // Composite Components, Loops & Scopes
            {
                CompositeComponentBaseMetadata metaData = (CompositeComponentBaseMetadata)pVertex.Data.Metadata;
                if (metaData != null)
                {
                    foreach (var vertex in metaData.ComponentGraph.Vertices)
                    {
                        ExtractFilesFromNode(vertex);
                    }

                    // Only composite components have MetadataDefinition
                    if (pVertex.Data.Metadata is CompositeComponentMetadata)
                    {
                        CompositeComponentMetadataDefinition metaDataDefinition = ((CompositeComponentMetadata)pVertex.Data.Metadata).ComponentMetadataDefinition;

                        this.m_componentAssemblies.Add(Path.GetFullPath(metaDataDefinition.Assembly));

                        // Extracting types from IOSpec
                        ExtractTypesFromIOSpec(metaDataDefinition.IOSpecDefinition);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private PackageHeirarchyItem CreateRelativeFolders(PackageHeirarchyItem experimentFolder, PackageFileInfo file)
 {
     PackageHeirarchyItem lastFolder = experimentFolder;
     foreach (string folder in file.FoldersPath)
     {
         PackageHeirarchyItem folderInfo;
         if (ContainsFolder(lastFolder, folder, out folderInfo))
         {
             lastFolder = folderInfo;
         }
         else
         {
             lastFolder = CreateFolder(lastFolder, folder);
         }
     }
     return lastFolder;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Extracts the components/types assemblies from the given vertex.
        /// </summary>
        /// <param name="pVertex">Vertex from the experiment graph.</param>
        private void ExtractFilesFromNode(ExperimentNode pVertex)
        {
            if (pVertex is ComponentNode) // Regular component
            {
                ComponentMetadata metaData = (ComponentMetadata)pVertex.Data.Metadata;
                if (metaData != null)
                {
                    ComponentMetadataDefinition metaDataDef = metaData.ComponentMetadataDefinition;
                    if (metaDataDef != null)
                    {
                        bool include;
                        if (m_config.IncludeOtherPackagesAssemblies)
                        {
                            include = true;
                        }
                        else
                        {
                            //determine if component is independent or is coming from another package
                            include = !IsAssemblyInAnotherPackage(metaDataDef.Assembly);
                        }

                        if (include)
                        {
                            // Component assembly
                            this.m_componentAssemblies.Add(Path.GetFullPath(metaDataDef.Assembly));

                            // Extracting types from IOSpec
                            ExtractTypesFromIOSpec(metaDataDef.IOSpecDefinition);
                        }
                    }

                    ConfigWrapper config = metaData.ConfigWrapper;
                    if (config != null)
                    {
                        // Extracting paths for files/directories from components' configuration
                        foreach (ConfigPropertyObject configValue in config.ConfigValues.Values)
                        {
                            // Files
                            if (configValue.Type == "TraceLabSDK.Component.Config.FilePath" && configValue.Value != null)
                            {
                                // Independent files
                                if (configValue.Value is TraceLab.Core.Components.TraceLabFilePath == false)
                                {
                                    if (this.m_config.IncludeIndependentFilesDirs)
                                    {
                                        var filePath = (TraceLabSDK.Component.Config.FilePath)configValue.Value;
                                        if (File.Exists(filePath.Absolute))
                                        {
                                            PackageFileInfo packageFileInfo = new PackageFileInfo(filePath);
                                            m_files.Add(packageFileInfo);

                                            //Change config value relative path -> this path is saved within experiment (note, we operate on the experiment clone)
                                            //so that relative path is in the subfolder of Experiment folder
                                            filePath.Relative = packageFileInfo.RelativeLocation;
                                        }
                                    }
                                }
                                // Files contained in a package
                                else
                                {
                                    if (this.m_config.IncludeOtherPackagesFilesDirs)
                                    {
                                        //TraceLabFilePath represents the file reference located in the package
                                        var packageFilePath = (TraceLabFilePath)configValue.Value;
                                        if (File.Exists(packageFilePath.Absolute))
                                        {
                                            PackageFileInfo packageFileInfo = new PackageFileInfo(packageFilePath);
                                            m_files.Add(packageFileInfo);

                                            //change the configValue to basic FilePath, (not TraceLabFilePath in the package), with updated Relative Path
                                            //so that relative path is in the subfolder of Experiment folder
                                            TraceLabSDK.Component.Config.FilePath basicFilePath = new TraceLabSDK.Component.Config.FilePath();
                                            basicFilePath.Init(packageFilePath.Absolute, packageFilePath.DataRoot);
                                            basicFilePath.Relative = packageFileInfo.RelativeLocation;
                                            configValue.Value = basicFilePath;
                                        }
                                    }
                                }
                            }
                            // Directories
                            else if (configValue.Type == "TraceLabSDK.Component.Config.DirectoryPath" && configValue.Value != null)
                            {
                                // Independent directories
                                if (configValue.Value is TraceLab.Core.Components.TraceLabDirectoryPath == false)
                                {
                                    if (this.m_config.IncludeIndependentFilesDirs)
                                    {
                                        var dirPath = (TraceLabSDK.Component.Config.DirectoryPath)configValue.Value;
                                        if (Directory.Exists(dirPath.Absolute))
                                        {
                                            PackageFileInfo packageDirectoryInfo = new PackageFileInfo(dirPath);
                                            m_directories.Add(packageDirectoryInfo);

                                            // HERZUM SPRINT 3.0: TLAB-82
                                            if (dirPath.Relative!=null)
                                            // END HERZUM SPRINT 3.0: TLAB-82
                                            //Change config value relative path -> this path is saved within experiment (note, we operate on the experiment clone)
                                            //so that relative path is in the subfolder of Experiment folder
                                            dirPath.Relative = packageDirectoryInfo.RelativeLocation;
                                        }
                                    }
                                }
                                // Directories contained in a package
                                else
                                {
                                    if (this.m_config.IncludeOtherPackagesFilesDirs)
                                    {
                                        var packageDirPath = (TraceLabDirectoryPath)configValue.Value;
                                        if (Directory.Exists(packageDirPath.Absolute))
                                        {
                                            PackageFileInfo packageDirInfo = new PackageFileInfo(packageDirPath);
                                            m_directories.Add(packageDirInfo);

                                            //change the configValue to basic FilePath, (not TraceLabFilePath in the package), with updated Relative Path
                                            //so that relative path is in the subfolder of Experiment folder
                                            TraceLabSDK.Component.Config.DirectoryPath basicFilePath = new TraceLabSDK.Component.Config.DirectoryPath();
                                            basicFilePath.Init(packageDirPath.Absolute, packageDirPath.DataRoot);
                                            basicFilePath.Relative = packageDirInfo.RelativeLocation;
                                            configValue.Value = basicFilePath;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (pVertex is CompositeComponentNode) // Composite Components, Loops & Scopes
            {
                CompositeComponentBaseMetadata metaData = (CompositeComponentBaseMetadata)pVertex.Data.Metadata;
                if (metaData != null)
                {
                    foreach (var vertex in metaData.ComponentGraph.Vertices)
                    {
                        ExtractFilesFromNode(vertex);
                    }

                    // Only composite components have MetadataDefinition
                    if (pVertex.Data.Metadata is CompositeComponentMetadata)
                    {
                        CompositeComponentMetadataDefinition metaDataDefinition = ((CompositeComponentMetadata)pVertex.Data.Metadata).ComponentMetadataDefinition;

                        this.m_componentAssemblies.Add(Path.GetFullPath(metaDataDefinition.Assembly));

                        // Extracting types from IOSpec
                        ExtractTypesFromIOSpec(metaDataDefinition.IOSpecDefinition);
                    }
                }
            }
        }