Exemplo n.º 1
0
        /// <summary>
        /// Searches for the destination at the end of the processing path.
        /// </summary>
        /// <param name="path">The processing path to trace.</param>
        /// <returns>Material destination</returns>
        private MaterialDestination SearchForDestination(ProcessingPath path)
        {
            // Does the processing trace have any history to trace ?
            if (this.Root == null)
            {
                return(null);
            }

            // Is there a processing path to trace ? if not then create an empty path to trace.
            if (path == null)
            {
                path = new ProcessingPath();
            }
            if (path.Tag == null)
            {
                path.Tag = new ProcessingTag[0];
            }

            // Search the processing tree for the destination associated with the processing path
            SearchForPathDetails finalSearch = SearchForPath(new SearchForPathDetails(path, 0, this.Root, new List <Procedure>()));

            //Debug.Assert(finalSearch != null);
            //Debug.Assert(path.Tag != null);
            return(finalSearch == null || finalSearch.tagLevel != path.Tag.Length ? null : finalSearch.destination);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the processing history associated with a processing path.
        /// </summary>
        /// <param name="processingPath">The processing path.</param>
        /// <returns></returns>
        internal ADX4.Process GetProcessingHistory(ProcessingPath processingPath)
        {
            // Does this processing tree have a root ? if not then there is not history to return.
            if (this.Root == null)
            {
                return(null);
            }

            // If the processing path is null then create an empty processing path to trace.
            if (processingPath == null)
            {
                processingPath     = new ProcessingPath();
                processingPath.Tag = new ProcessingTag[0];
            }

            // Trace the processing path and build the list of procedures on it
            SearchForPathDetails finalSearch = SearchForPath(new SearchForPathDetails(processingPath, 0, this.Root, new List <Procedure>()));

            if (finalSearch == null || (finalSearch.tagLevel < processingPath.Tag.Length))
            {
                this.OnValidationEvent(new ValidationResult(ErrorCodes.SampleProcessingHistory, ErrorLevel.Error, String.Format(Languages.Strings.valResultPathNotFoundInProcessingHistory, processingPath.ToString(), this.SampleRefs[0].IdRef)));
                return(null);
            }

            // Return the list of procedures for this processing path
            Process history = new Process();

            history.Destination                  = new MaterialDestination();
            history.Destination.Target           = new MaterialTarget();
            history.Destination.Target.Procedure = finalSearch.procedures.ToArray();
            return(history);
        }
Exemplo n.º 3
0
 public SearchForPathDetails(ProcessingPath path, Int32 tagLevel, MaterialDestination destination, List <Procedure> procedures)
 {
     this.tagLevel    = tagLevel;
     this.destination = destination;
     this.path        = path;
     this.procedures  = procedures;
     this.endOfBranch = false;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the <see cref="ADX4.Tools.AssayRecord"/> associated with the specified processing path.
        /// </summary>
        /// <value>The requested assay record.</value>
        public AssayRecord this[ProcessingPath path]
        {
            get
            {
                // Search the Assay Records for the record with the requested processing path
                foreach (AssayRecord assayRecord in this)
                {
                    if (assayRecord.ProcessingPath == null)
                    {
                        if (path == null)
                        {
                            return(assayRecord);
                        }
                    }
                    else if (assayRecord.ProcessingPath.Equals(path))
                    {
                        return(assayRecord);
                    }
                }

                return(null);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Appends the processing history onto the end of the specified processing path.
        /// </summary>
        /// <param name="parentPath">The parent processing path to append onto.</param>
        /// <param name="processing">The processing history.</param>
        internal void AppendProcessingHistory(ProcessingPath parentPath, ADX4.Process processing)
        {
            // Any processing history to append ?
            if (processing == null || processing.Destination == null)
            {
                return;
            }

            // Expand the processing history into a procedures (i.e. replaces ProcessRef, ProcedureRef, etc... for the actual procedures).
            MaterialDestination clonedDestination = processing.Destination.Clone();

            Debug.Assert(clonedDestination != null);

            List <Procedure> expandedProcedures = ExpandToProcedures(clonedDestination, 0, new ProcessingTarget());

            Debug.Assert(expandedProcedures != null);

            // Any procedures to append ?
            if (expandedProcedures.Count == 0)
            {
                return;
            }

            // Do we have a root destination at the top of the process tree ?
            MaterialDestination leafDestination;

            if (this.Root == null)
            {
                this.Root       = new MaterialDestination();
                leafDestination = this.Root;
            }
            // Or do we trace the processing path through the current tree.
            else
            {
                leafDestination = SearchForDestination(parentPath); // Find the destination at the end of this processing path !
                if (leafDestination == null)
                {
                    this.OnValidationEvent(new ValidationResult(ErrorCodes.SampleProcessingHistory, ErrorLevel.Error, String.Format(Languages.Strings.valResultPathNotFoundInProcessingHistory, parentPath.ToString(), this.ToString())));
                    return;
                }
            }
            Debug.Assert(leafDestination != null);

            // Add a target to the destination at the end of the processing path (if not one there already)
            if (leafDestination.Target == null)
            {
                leafDestination.Target = new MaterialTarget();
            }

            // Add the procedures onto the target (if no procedures have been set on the target yet!)
            if (leafDestination.Target.Procedure == null)
            {
                leafDestination.Target.Procedure = expandedProcedures.ToArray();
            }

            // Otherwise extend the target's procedure list and append the processing history's procedures
            else
            {
                Procedure[] curProcedures = leafDestination.Target.Procedure;
                leafDestination.Target.Procedure = new Procedure[curProcedures.Length + expandedProcedures.Count];

                for (int i = 0; i < curProcedures.Length; i++)
                {
                    leafDestination.Target.Procedure[i] = curProcedures[i];
                }

                for (int i = 0; i < expandedProcedures.Count; i++)
                {
                    leafDestination.Target.Procedure[curProcedures.Length + i] = expandedProcedures[i];
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Substitutes the processing path with an alternative processing path.
        /// </summary>
        /// <param name="processingPath">The new processing path.</param>
        /// <returns></returns>
        public ProcessingPath MapProcessingPath(ProcessingPath processingPath)
        {
            // Any processing path lookups ?
            if (this.ProcessingPath == null || processingPath == null || processingPath.Tag == null)
            {
                return(processingPath);
            }

            // Map each processing tag
            List <ProcessingTag> mappedTags = new List <ProcessingTag>();

            for (Int32 i = 0; i < processingPath.Tag.Length; i++)
            {
                ProcessingTag mappedTag = new ProcessingTag();
                mappedTag.Type = processingPath.Tag[i].Type;
                mappedTag.Name = processingPath.Tag[i].Name;

                // Find the longest matching mapping
                Boolean mapped = false;
                for (Int32 j = processingPath.Tag.Length; j > i && !mapped; j--)
                {
                    // Append these processing tags together
                    StringBuilder appendedTags = new StringBuilder();
                    for (Int32 k = i; k < j; k++)
                    {
                        if (appendedTags.Length > 0)
                        {
                            appendedTags.Append(c_mappingSeparator);
                        }
                        if (!String.IsNullOrEmpty(processingPath.Tag[k].Type))
                        {
                            appendedTags.Append(processingPath.Tag[k].Type);
                        }
                    }

                    // Does this appended list of tags types match any mapping ?
                    foreach (Substitution substitution in this.ProcessingPath)
                    {
                        if (!String.IsNullOrEmpty(substitution.Name))
                        {
                            if (String.Equals(appendedTags.ToString(), substitution.Name))
                            {
                                mappedTag.Type = substitution.With;
                                mappedTag.Name = processingPath.Tag[j - 1].Name;
                                mapped         = true;
                                i = j;
                                break;
                            }
                        }
                    }
                }

                mappedTags.Add(mappedTag);
            }

            // Return the mapped processing path
            ProcessingPath mappedPath = new ProcessingPath();

            mappedPath.Id  = processingPath.Id;
            mappedPath.Tag = mappedTags.ToArray();
            return(mappedPath);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Substitutes the processing path with an alternative processing path.
        /// </summary>
        /// <param name="processingPath">The new processing path.</param>
        /// <returns></returns>
        public ProcessingPath MapProcessingPath(ProcessingPath processingPath)
        {
            // Any processing path lookups ? 
            if (this.ProcessingPath == null || processingPath == null || processingPath.Tag == null)
                return processingPath;

            // Map each processing tag
            List<ProcessingTag> mappedTags = new List<ProcessingTag>();
            for (Int32 i = 0; i < processingPath.Tag.Length; i++)
            {
                ProcessingTag mappedTag = new ProcessingTag();
                mappedTag.Type = processingPath.Tag[i].Type;
                mappedTag.Name = processingPath.Tag[i].Name;

                // Find the longest matching mapping
                Boolean mapped = false;
                for (Int32 j = processingPath.Tag.Length; j > i && !mapped; j--)
                {
                    // Append these processing tags together
                    StringBuilder appendedTags = new StringBuilder();
                    for (Int32 k = i; k < j; k++)
                    {
                        if (appendedTags.Length > 0)
                            appendedTags.Append(c_mappingSeparator);
                        if (!String.IsNullOrEmpty(processingPath.Tag[k].Type))
                            appendedTags.Append(processingPath.Tag[k].Type);
                    }

                    // Does this appended list of tags types match any mapping ?
                    foreach (Substitution substitution in this.ProcessingPath)
                        if (!String.IsNullOrEmpty(substitution.Name))
                        {
                            if (String.Equals(appendedTags.ToString(), substitution.Name))
                            {
                                mappedTag.Type = substitution.With;
                                mappedTag.Name = processingPath.Tag[j - 1].Name;
                                mapped = true;
                                i = j;
                                break;
                            }
                        }
                }

                mappedTags.Add(mappedTag);
            }

            // Return the mapped processing path
            ProcessingPath mappedPath = new ProcessingPath();
            mappedPath.Id = processingPath.Id;
            mappedPath.Tag = mappedTags.ToArray();
            return mappedPath;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssayRecord"/> class.
 /// </summary>
 /// <param name="processingTree">Sample processing tree</param>
 /// <param name="processingPath">Path through the processing tree to the assay analysis</param>
 public AssayRecord(ProcessingTree processingTree, ProcessingPath processingPath)
 {
     m_processingTree     = processingTree;
     m_fullProcessingPath = processingPath;
     m_processingHistory  = processingTree.GetProcessingHistory(processingPath);
 }