コード例 #1
0
        /// <summary>
        /// Validates the entire experiment.
        /// It validates the structure of the experimental graph,
        /// validates all inputs and outputs,
        /// checks if all components are in the component library.
        /// </summary>
        /// <param name="experiment">The experiment.</param>
        /// <param name="vertices">The vertices, that has been parsed from the start node. Nodes that are not connected to the start are being skipped.</param>
        /// <param name="edges">The edges, that has been parsed from the start node.</param>
        /// <returns>
        /// true if there is no errors, false, if errors has been detected
        /// </returns>
        public static bool ValidateExperiment(IExperiment experiment, out List <ExperimentNode> vertices, out List <ExperimentNodeConnection> edges,
                                              List <string> workspaceTypesDirectories, bool validateInputMapping, LoggerNameRoot loggerNameRoot)
        {
            bool noErrors = GraphValidator.Validate(experiment, out vertices, out edges);

            if (noErrors)
            {
                var availableInputMappingsPerNode = new TraceLab.Core.Utilities.InputMappings(experiment);
                if (validateInputMapping)
                {
                    noErrors = InputMappingValidator.Validate(experiment, availableInputMappingsPerNode);
                }

                if (noErrors)
                {
                    //recompile all decisions
                    noErrors = TraceLab.Core.Decisions.DecisionCompilationRunner.CompileAllDecisionNodes(experiment, availableInputMappingsPerNode,
                                                                                                         workspaceTypesDirectories, loggerNameRoot);
                }
            }

            if (noErrors)
            {
                noErrors = ValidComponents(vertices);
            }

            return(noErrors);
        }
コード例 #2
0
        /// <summary>
        /// Validates if the list of outputs from incoming vertices satisfies all the inputs for the current node
        /// </summary>
        /// <param name="node">Node to be validated</param>
        /// <param name="incomingOutputs">List of incoming outputs from the previous nodes</param>
        /// <param name="noErrors">assigns false if error has been detected, otherwise keep it as it was</param>
        private static bool ValidateInputMapping(ExperimentNode node, Dictionary <string, string> incomingOutputs)
        {
            bool noErrors = true;
            IConfigurableAndIOSpecifiable ioSpecMetadata = node.Data.Metadata as IConfigurableAndIOSpecifiable;

            if (ioSpecMetadata != null)
            {
                //check if the list of outputs from incoming vertices satisfies all the inputs for the current node
                foreach (IOItem inputItem in ioSpecMetadata.IOSpec.Input.Values)
                {
                    if (incomingOutputs.ContainsKey(inputItem.MappedTo) == false)
                    {
                        noErrors = false;
                        GraphValidator.SetErrorOnNode(node, String.Format(CultureInfo.CurrentCulture, "The component attempts to load '{0}' from the Workspace. However, none of the previous components outputs '{1}' to the Workspace.", inputItem.MappedTo, inputItem.MappedTo));
                    }
                }
            }
            return(noErrors);
        }