Exemplo n.º 1
0
        public ProcessTaskArgument ShallowClone(ProcessTask into)
        {
            ProcessTaskArgument clone = new ProcessTaskArgument(CatalogueRepository, into);

            CopyShallowValuesTo(clone, true);

            return(clone);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Stores a new argument value for the class hosted by <see cref="ProcessTask"/>. Use
 /// <see cref="ArgumentFactory"/> if you want to do this in a more structured manner.
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="parent"></param>
 public ProcessTaskArgument(ICatalogueRepository repository, ProcessTask parent)
 {
     repository.InsertAndHydrate(this, new Dictionary <string, object>
     {
         { "ProcessTask_ID", parent.ID },
         { "Name", "Parameter" + Guid.NewGuid() },
         { "Type", typeof(string).ToString() }
     });
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new copy of the processTask and all it's arguments in the database, this clone is then hooked up to the
        /// new LoadMetadata at the specified stage
        /// </summary>
        /// <param name="loadMetadata">The new LoadMetadata parent for the clone</param>
        /// <param name="loadStage">The new load stage to put the clone in </param>
        /// <returns>the new ProcessTask (the clone has a different ID to the parent)</returns>
        public ProcessTask CloneToNewLoadMetadataStage(LoadMetadata loadMetadata, LoadStage loadStage)
        {
            var cataRepository = ((CatalogueRepository)Repository);

            //clone only accepts sql connections so make sure we aren't in mysql land or something
            using (cataRepository.BeginNewTransactedConnection())
            {
                try
                {
                    //get list of arguments to also clone (will happen outside of transaction
                    ProcessTaskArgument[] toCloneArguments = ProcessTaskArguments.ToArray();

                    //create a new transaction for all the cloning - note that once all objects are cloned the transaction is committed then all the objects are adjusted outside the transaction
                    ProcessTask clone = new ProcessTask(CatalogueRepository, LoadMetadata, loadStage);
                    CopyShallowValuesTo(clone);

                    //foreach of our child arguments
                    foreach (ProcessTaskArgument argument in toCloneArguments)
                    {
                        //clone it but rewire it to the proper ProcessTask parent (the clone)
                        argument.ShallowClone(clone);
                    }

                    //the values passed into parameter
                    clone.LoadMetadata_ID = loadMetadata.ID;
                    clone.LoadStage       = loadStage;
                    clone.SaveToDatabase();

                    //it worked
                    cataRepository.EndTransactedConnection(true);

                    //return the clone
                    return(clone);
                }
                catch (Exception)
                {
                    cataRepository.EndTransactedConnection(false);
                    throw;
                }
            }
        }