Exemple #1
0
        public void GetGraphIdPath(CompositeComponentNode topOwnerCompositeComponentNode, ref string fullGraphIdPath)
        {
            if (topOwnerCompositeComponentNode == null)
            {
                if (topOwnerCompositeComponentNode.Owner == null)
                {
                    throw new InvalidOperationException("Application is at invalid state. Sublevel experiment always need to have an owner.");
                }

                var ownerGraph = topOwnerCompositeComponentNode.Owner as CompositeComponentGraph;

                //check if node is in the subgraph, and also check if
                //ownerGraph.OwnerNode as it the top graph might be a composite component - if it is during the process of creating
                //the composite component
                bool isNodeInSubgraph = (ownerGraph != null && ownerGraph.OwnerNode != null);

                if (isNodeInSubgraph)
                {
                    //recursive to graph above this graph, until it finds top level experiment
                    CompositeComponentNode topCompositeComponentNode = ownerGraph.OwnerNode;
                    GetGraphIdPath(topOwnerCompositeComponentNode, ref fullGraphIdPath);

                    if (String.IsNullOrEmpty(fullGraphIdPath))
                    {
                        fullGraphIdPath = ownerGraph.OwnerNode.ID;
                    }
                    else
                    {
                        //otherwise add to already existing path
                        fullGraphIdPath += ":" + ownerGraph.OwnerNode.ID;
                    }
                }
            }
        }
        private void AddSubLevels(string parentNodeId, BaseLevelExperimentViewModel experiment)
        {
            if (experiment == null)
            {
                throw new ArgumentNullException("experiment");
            }

            foreach (ExperimentNode node in experiment.Vertices)
            {
                CompositeComponentNode compositeNode = node as CompositeComponentNode;
                if (compositeNode != null)
                {
                    CompositeComponentBaseMetadata data = compositeNode.Data.Metadata as CompositeComponentBaseMetadata;

                    string subLevelId;
                    if (String.IsNullOrEmpty(parentNodeId) == false)
                    {
                        subLevelId = parentNodeId + ":" + compositeNode.ID;
                    }
                    else
                    {
                        subLevelId = compositeNode.ID;
                    }

                    CreateSubLevelViewModel(data.ComponentGraph, subLevelId, experiment);
                }
            }
        }
        public void OpenComponentGraphFunc(object param)
        {
            CompositeComponentGraph     componentGraph   = param as CompositeComponentGraph;
            SubLevelExperimentViewModel componentGraphVM = param as SubLevelExperimentViewModel;
            CompositeComponentNode      node             = param as CompositeComponentNode;
            TopLevelExperimentViewModel topLevel         = param as TopLevelExperimentViewModel;

            if (node != null)
            {
                componentGraph = node.CompositeComponentMetadata.ComponentGraph;
            }
            else if (componentGraphVM != null)
            {
                componentGraph = (CompositeComponentGraph)componentGraphVM.GetExperiment();
            }

            BaseLevelExperimentViewModel view = null;

            if (componentGraph != null)
            {
                view = FindSubLevel(componentGraph.GraphIdPath);
            }
            else if (topLevel != null)
            {
                view = topLevel;
            }

            CurrentView = view;
        }
Exemple #4
0
        public void OpenExperimentWithNonExistingCompositeComponentTest()
        {
            // load the experiment to be exported
            string     experimentFilename = System.IO.Path.Combine(AppContext.BaseTestDirectory, "experiment_with_non_existing_composite_component_bug_75.gml");
            Experiment experiment         = ExperimentManager.Load(experimentFilename, AppContext.Components);

            experiment.Settings = AppContext.Settings;

            Assert.IsNotNull(experiment);
            Assert.AreEqual(3, experiment.VertexCount);

            //find the composite component node
            CompositeComponentNode compositeComponentNode = null;

            foreach (ExperimentNode node in experiment.Vertices)
            {
                compositeComponentNode = node as CompositeComponentNode;
                if (compositeComponentNode != null)
                {
                    break;
                }
            }

            Assert.IsNotNull(compositeComponentNode); //if fails composite component node has not been found
            //once found check if it has error
            Assert.IsTrue(compositeComponentNode.HasError);

            //Also try to create ExperimentViewModel for the experiment. Assure that it does not crash
            var experimentViewModel = new TraceLab.UI.WPF.ViewModels.ExperimentViewModel_Accessor(experiment);
        }
Exemple #5
0
        /// <summary>
        /// Finds the owner node in the top level experiment, (at the top of the subgraphs hierarchy) of this sublevel component graph.
        /// Also it sets the node id full path. It contains the id of all the owners node of the subgraphs all the way to the top.
        /// </summary>
        private CompositeComponentNode GetTopOwnerNode()
        {
            //if the top owner node has not yet been discovered
            if (m_topOwnerCompositeComponentNode == null)
            {
                if (Owner == null)
                {
                    throw new InvalidOperationException("Application is at invalid state. Sublevel experiment always need to have an owner.");
                }

                // if the owner of this sublevel experiment is the top level experiment
                TopLevelExperimentViewModel topLevel = Owner as TopLevelExperimentViewModel;
                if (topLevel != null)
                {
                    // then return this component graph owner node (which is a part of the top level experiment)
                    CompositeComponentGraph componentGraph = (CompositeComponentGraph)GetExperiment();
                    m_topOwnerCompositeComponentNode = componentGraph.OwnerNode;
                }
                else
                {
                    //otherwise recursive to subgraph above this graph, until it finds top level experiment
                    SubLevelExperimentViewModel levelAbove = (SubLevelExperimentViewModel)Owner;
                    m_topOwnerCompositeComponentNode = levelAbove.GetTopOwnerNode();

                    //in addition, set this component graph node if path.
                    CompositeComponentGraph componentGraph = (CompositeComponentGraph)GetExperiment();
                    GraphIdPath = componentGraph.OwnerNode.ID;
                }
            }

            return(m_topOwnerCompositeComponentNode);
        }
Exemple #6
0
        /// <summary>
        /// The converter method returns the ConfigWrapper object for the calling node info.
        /// If the node belongs to sub level experiment it will replace the config wrapper with references to
        /// the ConfigPropertyObjects for the given node in the CompositeComponentNode in the top experiment view.
        /// If the node is already in the top experiment view, it simply returns original config wrapper.
        /// </summary>
        /// <param name="value">The value produced by the binding source.</param>
        /// <param name="targetType">type ConfigWrapper</param>
        /// <param name="parameter">not used</param>
        /// <param name="culture">not used</param>
        /// <returns>
        /// ConfigWrapper for the calling node info
        /// </returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            ExperimentNode node = value as ExperimentNode;

            if (node == null)
            {
                throw new InvalidOperationException("Converter cannot accept value that is not of the ExperimentNode type");
            }

            var metadata = (IConfigurableAndIOSpecifiable)node.Data.Metadata;

            //the default return value is config wrapper itself
            ConfigWrapper defaultConfigWrapper = metadata.ConfigWrapper;

            // the config wrapper that is going to be returned
            ConfigWrapper retConfigWrapper = defaultConfigWrapper;

            CompositeComponentGraph ownerGraph = node.Owner as CompositeComponentEditableGraph;
            bool isNodeInScope = (ownerGraph != null);

            //if node is not in scope (the check is needed, as scope extends composite component, but unlike composite component, it does not need to override config values)
            if (isNodeInScope == false)
            {
                //check if node is in composite component instead
                ownerGraph = node.Owner as CompositeComponentGraph;

                //check if node is in the subgraph, and also check if
                //ownerGraph.OwnerNode as it the top graph might be a composite component - if it is during the process of creating
                //the composite component
                bool isNodeInSubgraph = (ownerGraph != null && ownerGraph.OwnerNode != null);

                if (isNodeInSubgraph)
                {
                    CompositeComponentNode topCompositeComponentNode = ownerGraph.OwnerNode;

                    string fullNodeId = String.Empty;
                    GetGraphIdPath(topCompositeComponentNode, ref fullNodeId);

                    if (String.IsNullOrEmpty(fullNodeId))
                    {
                        fullNodeId = node.ID;
                    }
                    else
                    {
                        //otherwise add to already existing path
                        fullNodeId += ":" + node.ID;
                    }

                    CompositeComponentMetadata compositeComponentMetadata = (CompositeComponentMetadata)topCompositeComponentNode.Data.Metadata;
                    ConfigWrapper topConfig = compositeComponentMetadata.ConfigWrapper;

                    //replace the config wrapper
                    retConfigWrapper = topConfig.CreateViewForId(fullNodeId, true);
                }
            }

            return(retConfigWrapper);
        }
        private bool CanOpenComponentGraph(object param)
        {
            bool canOpen = true;

            CompositeComponentNode node = param as CompositeComponentNode;

            if (node != null)
            {
                //in case component graph has not been loaded because of error, then don't allow to open sub level component graph
                if (node.CompositeComponentMetadata.ComponentGraph == null)
                {
                    canOpen = false;
                }
            }

            return(canOpen);
        }
        private void RemoveSubLevels(IExperiment experiment)
        {
            if (experiment == null)
            {
                throw new ArgumentNullException("experiment");
            }

            foreach (ExperimentNode node in experiment.Vertices)
            {
                CompositeComponentNode compositeNode = node as CompositeComponentNode;
                if (compositeNode != null && m_subLevels.ContainsKey(compositeNode.ID))
                {
                    CompositeComponentMetadata data = compositeNode.Data.Metadata as CompositeComponentMetadata;
                    var subLevel = m_subLevels[compositeNode.ID];

                    if (subLevel != null)
                    {
                        RemoveSubLevels(subLevel);
                    }

                    m_subLevels.Remove(compositeNode.ID);
                }
            }
        }
Exemple #9
0
 /// <summary>
 /// Initializes the component graph.
 /// </summary>
 /// <param name="node">The node.</param>
 /// <param name="settings">The settings.</param>
 public override void InitializeComponentGraph(CompositeComponentNode node, Settings.Settings settings)
 {
     //scope node just assigns itself to component graph
     ComponentGraph.OwnerNode = node;
     ComponentGraph.Settings  = settings;
 }
Exemple #10
0
 /// <summary>
 /// Initializes the component graph from ComponentMetadataDefinition graph
 /// </summary>
 /// <param name="node">The node.</param>
 /// <param name="settings">The settings.</param>
 public override void InitializeComponentGraph(CompositeComponentNode node, TraceLab.Core.Settings.Settings settings)
 {
     //each composite node gets its own copy of ComponentMetadataDefinition.ComponentGraph
     m_compositeComponentGraph          = new CompositeComponentGraph(node, ComponentMetadataDefinition.ComponentGraph);
     m_compositeComponentGraph.Settings = settings;
 }
 public abstract void InitializeComponentGraph(CompositeComponentNode node, TraceLab.Core.Settings.Settings settings);