/// <summary> /// Overrides the config values of the given metadata with values from the this CompositeComponent config values. /// </summary> /// <param name="id">The id.</param> /// <param name="metadata">The metadata.</param> private void OverrideConfigValues(String id, IConfigurableAndIOSpecifiable metadata) { foreach (string configParameter in metadata.ConfigWrapper.ConfigValues.Keys) { string extendedParameterName = String.Format("{0}:{1}", id, configParameter); ConfigPropertyObject overridePropertyObject = m_compositeComponentMetadata.ConfigWrapper.ConfigValues[extendedParameterName]; metadata.ConfigWrapper.ConfigValues[configParameter] = overridePropertyObject; } }
/// <summary> /// Retrieves the config values from component's config wrapper. /// </summary> /// <param name="currentNode">The current node.</param> private void RetrieveConfigValuesFromComponent(string nodeIdentifier, IConfigurableAndIOSpecifiable metadata) { foreach (ConfigPropertyObject configParameter in metadata.ConfigWrapper.ConfigValues.Values) { string displayParameterName = String.Format("{0} {1}", metadata.Label, configParameter.DisplayName); string extendedParameterName = String.Format("{0}:{1}", nodeIdentifier, configParameter.Name); //create property object based on the component's property object ConfigPropertyObject propertyObject = new ConfigPropertyObject(configParameter); //but change the name - it will be resolved in Nodes factory based on extended parameter name which retNode config parameter is supposed to be overridden propertyObject.DisplayName = displayParameterName; propertyObject.Name = extendedParameterName; //add it to the compound configWrapperDefinition displayParameterName = GetUniqueDisplayName(displayParameterName); ConfigSettings.Add(displayParameterName, new ConfigItemSetting(displayParameterName, configParameter.Type, propertyObject)); } }
public void DefineCompositeComponentBasicTestSelectAllNodes() { // load the experiment to be exported string experimentFilename = System.IO.Path.Combine(AppContext.BaseTestDirectory, "experiment_define_composite_component_basic_test.teml"); Experiment experiment = ExperimentManager.Load(experimentFilename, AppContext.Components); experiment.Settings = AppContext.Settings; //assure that we apply global settings //in first basic test select all nodes foreach (ExperimentNode node in experiment.Vertices) { node.IsSelected = true; } DefiningCompositeComponentSetup setup = new DefiningCompositeComponentSetup(experiment); Assert.IsNotNull(setup); Assert.AreEqual(1, setup.InputSettings.Count); Assert.AreEqual(2, setup.OutputSettings.Count); Assert.AreEqual(1, setup.ConfigSettings.Count); Assert.IsTrue(setup.InputSettings["test1"].Include); Assert.IsTrue(setup.OutputSettings["test1"].Include); Assert.IsTrue(setup.OutputSettings["test2"].Include); //note, if there are two components with the same label and same config name, the expected behaviour is to add Assert.IsTrue(setup.ConfigSettings["Test writer Value"].Include); //get real names of the config values string configName1 = setup.ConfigSettings["Test writer Value"].PropertyObject.Name; //change settings to sth different values setup.Name = "Test Composite Component"; setup.Author = "Author XYZ"; setup.Description = "Composite Component to test export"; //don't include following in the export setup.InputSettings["test1"].Include = false; setup.OutputSettings["test1"].Include = false; //rescan library to be sure it is fresh scan int numberOfComponentsInLibrary = GetCountOfComponentsInLibrary(); //set file path to composite component setup.CompositeComponentLocationFilePath = exportFile; Assert.IsFalse(File.Exists(setup.CompositeComponentLocationFilePath)); setup.DefineComponent(); Assert.IsTrue(File.Exists(exportFile)); //rescan the library int updatedNumberOfComponents = GetCountOfComponentsInLibrary(); //after rescan there should be one more component in the library Assert.AreEqual(numberOfComponentsInLibrary + 1, updatedNumberOfComponents); //iterate through all components until find new composite component CompositeComponentMetadataDefinition compositeComponentDefinition = FindCompositeComponent(exportFile); //assure that composite component definition has been found Assert.IsNotNull(compositeComponentDefinition); //if fails, composite component has not been found Assert.AreEqual(setup.Name, compositeComponentDefinition.Label); Assert.AreEqual(setup.Description, compositeComponentDefinition.Description); Assert.AreEqual(setup.Author, compositeComponentDefinition.Author); Assert.IsNotNull(compositeComponentDefinition.ComponentGraph); //the number of configuration properties should be the same Assert.AreEqual(setup.ConfigSettings.Count, compositeComponentDefinition.ConfigurationWrapperDefinition.Properties.Count); ConfigPropertyObject config1 = compositeComponentDefinition.ConfigurationWrapperDefinition.Properties[configName1]; Assert.AreEqual("Test writer Value", config1.DisplayName); Assert.IsTrue(config1.Visible); //config1 should be visible, because Include was set to false Assert.AreEqual(0, compositeComponentDefinition.IOSpecDefinition.Input.Count); //no input was included Assert.AreEqual(1, compositeComponentDefinition.IOSpecDefinition.Output.Count); //only one output was included }
public void DefineCompositeComponentFromExperimentWithAnotherCompositeComponentTest() { // load the experiment to be exported string experimentFilename = System.IO.Path.Combine(AppContext.BaseTestDirectory, "experiment_with_composite_component.teml"); Experiment experiment = ExperimentManager.Load(experimentFilename, AppContext.Components); experiment.Settings = AppContext.Settings; //applying these settings was causing the bug #74 //select all nodes foreach (ExperimentNode node in experiment.Vertices) { node.IsSelected = true; } DefiningCompositeComponentSetup setup = new DefiningCompositeComponentSetup(experiment); Assert.IsNotNull(experiment); Assert.AreEqual(3, experiment.VertexCount); Assert.IsNotNull(setup); Assert.AreEqual(0, setup.InputSettings.Count); Assert.AreEqual(2, setup.OutputSettings.Count); Assert.AreEqual(2, setup.ConfigSettings.Count); //check if default name is the same as experiment info Assert.IsTrue(setup.OutputSettings["test_x"].Include); Assert.IsTrue(setup.OutputSettings["test_y"].Include); Assert.IsTrue(setup.ConfigSettings["Composite Component Test writer Value"].Include); Assert.IsTrue(setup.ConfigSettings["Composite Component Test writer Value 2"].Include); //get real names of the config values string configName1 = setup.ConfigSettings["Composite Component Test writer Value"].PropertyObject.Name; string configName2 = setup.ConfigSettings["Composite Component Test writer Value 2"].PropertyObject.Name; //change settings to sth different values setup.Name = "Complex Composite Component"; setup.Author = "Author XYZ"; setup.Description = "Complex Composite Component to test export"; //don't include following in the export setup.OutputSettings["test_y"].Include = false; //change alias setup.ConfigSettings["Composite Component Test writer Value"].Alias = "Config 1"; setup.ConfigSettings["Composite Component Test writer Value 2"].Alias = "Config 2"; setup.ConfigSettings["Composite Component Test writer Value 2"].Include = false; //rescan library to be sure it is fresh scan int numberOfComponentsInLibrary = GetCountOfComponentsInLibrary(); //let's export the experiment as composite component Assert.IsFalse(File.Exists(exportFile)); setup.CompositeComponentLocationFilePath = exportFile; setup.DefineComponent(); Assert.IsTrue(File.Exists(exportFile)); //rescan the library int updatedNumberOfComponents = GetCountOfComponentsInLibrary(); //after rescan there should be one more component in the library Assert.AreEqual(numberOfComponentsInLibrary + 1, updatedNumberOfComponents); //iterate through all components until find new composite component CompositeComponentMetadataDefinition compositeComponentDefinition = FindCompositeComponent(exportFile); //assure that composite component definition has been found Assert.IsNotNull(compositeComponentDefinition); //if fails, composite component has not been found Assert.AreEqual(setup.Name, compositeComponentDefinition.Label); Assert.AreEqual(setup.Description, compositeComponentDefinition.Description); Assert.AreEqual(setup.Author, compositeComponentDefinition.Author); Assert.IsNotNull(compositeComponentDefinition.ComponentGraph); //the number of configuration properties should be the same Assert.AreEqual(setup.ConfigSettings.Count, compositeComponentDefinition.ConfigurationWrapperDefinition.Properties.Count); ConfigPropertyObject config1 = compositeComponentDefinition.ConfigurationWrapperDefinition.Properties[configName1]; ConfigPropertyObject config2 = compositeComponentDefinition.ConfigurationWrapperDefinition.Properties[configName2]; Assert.AreEqual("Config 1", config1.DisplayName); Assert.AreEqual("Config 2", config2.DisplayName); Assert.IsTrue(config1.Visible); Assert.IsFalse(config2.Visible); //config1 should not be visible, because Include was set to false Assert.AreEqual(0, compositeComponentDefinition.IOSpecDefinition.Input.Count); //none input value were included Assert.AreEqual(1, compositeComponentDefinition.IOSpecDefinition.Output.Count); //one output value was included }
public ConfigItemSetting(string alias, string type, ConfigPropertyObject propertyObject) : base(alias, type) { PropertyObject = propertyObject; Alias = alias; }