private ExtractionConfiguration ShallowClone() { var clone = new ExtractionConfiguration(DataExportRepository, Project); CopyShallowValuesTo(clone); return(clone); }
private ExtractionConfiguration ShallowClone() { var clone = new ExtractionConfiguration(DataExportRepository, Project); CopyShallowValuesTo(clone); clone.Name = "Clone of " + Name; clone.SaveToDatabase(); return(clone); }
/// <summary> /// Creates a new parameter into the <paramref name="repository"/> database acting as a global parameter for all <see cref="ISelectedDataSets"/> in the <paramref name="configuration"/> /// </summary> /// <param name="repository"></param> /// <param name="configuration"></param> /// <param name="parameterSQL"></param> public GlobalExtractionFilterParameter(IDataExportRepository repository, ExtractionConfiguration configuration, string parameterSQL) { Repository = repository; Repository.InsertAndHydrate(this, new Dictionary <string, object> { { "ParameterSQL", parameterSQL }, { "ExtractionConfiguration_ID", configuration.ID } }); }
/// <summary> /// Declares in the <paramref name="repository"/> database that the given <paramref name="dataSet"/> should be extracted as part of the given <paramref name="configuration"/>. /// </summary> /// <param name="repository"></param> /// <param name="configuration"></param> /// <param name="dataSet"></param> /// <param name="rootContainerIfAny">Adds the restriction that the extraction SQL should include the WHERE logic in this container</param> public SelectedDataSets(IDataExportRepository repository, ExtractionConfiguration configuration, IExtractableDataSet dataSet, FilterContainer rootContainerIfAny) { repository.InsertAndHydrate(this, new Dictionary <string, object>() { { "ExtractionConfiguration_ID", configuration.ID }, { "ExtractableDataSet_ID", dataSet.ID }, { "RootFilterContainer_ID", rootContainerIfAny != null?(object)rootContainerIfAny.ID:DBNull.Value } }); ClearAllInjections(); InjectKnown(dataSet); }
/// <summary> /// Creates a new line of SELECT Sql for the given <paramref name="dataset"/> as it is extracted in the provided <paramref name="configuration"/>. The new object will /// be created in the <paramref name="repository"/> database. /// </summary> /// <param name="repository"></param> /// <param name="dataset"></param> /// <param name="configuration"></param> /// <param name="extractionInformation"></param> /// <param name="order"></param> /// <param name="selectSQL"></param> public ExtractableColumn(IDataExportRepository repository, IExtractableDataSet dataset, ExtractionConfiguration configuration, ExtractionInformation extractionInformation, int order, string selectSQL) { Repository = repository; Repository.InsertAndHydrate(this, new Dictionary <string, object> { { "ExtractableDataSet_ID", dataset.ID }, { "ExtractionConfiguration_ID", configuration.ID }, { "CatalogueExtractionInformation_ID", extractionInformation == null ? DBNull.Value : (object)extractionInformation.ID }, { "Order", order }, { "SelectSQL", string.IsNullOrWhiteSpace(selectSQL) ? DBNull.Value : (object)selectSQL } }); ClearAllInjections(); }
/// <summary> /// Creates a complete copy of the <see cref="IExtractionConfiguration"/>, all selected datasets, filters etc. The copy is created directly into /// the <see cref="DatabaseEntity.Repository"/> database using a transaction (to prevent a half succesful clone being generated). /// </summary> /// <returns></returns> public ExtractionConfiguration DeepCloneWithNewIDs() { var repo = (DataExportRepository)Repository; using (repo.BeginNewTransactedConnection()) { try { //clone the root object (the configuration) - this includes cloning the link to the correct project and cohort ExtractionConfiguration clone = this.ShallowClone(); //find each of the selected datasets for ourselves and clone those too foreach (SelectedDataSets selected in SelectedDataSets) { //clone the link meaning that the dataset is now selected for the clone configuration too var newSelectedDataSet = new SelectedDataSets(repo, clone, selected.ExtractableDataSet, null); // now clone each of the columns for each of the datasets that we just created links to (make them the same as the old configuration foreach (IColumn extractableColumn in GetAllExtractableColumnsFor(selected.ExtractableDataSet)) { ExtractableColumn cloneExtractableColumn = ((ExtractableColumn)extractableColumn).ShallowClone(); cloneExtractableColumn.ExtractionConfiguration_ID = clone.ID; cloneExtractableColumn.SaveToDatabase(); } //clone should copy accross the forced joins (if any) foreach (SelectedDataSetsForcedJoin oldForcedJoin in Repository.GetAllObjectsWithParent <SelectedDataSetsForcedJoin>(selected)) { new SelectedDataSetsForcedJoin((IDataExportRepository)Repository, newSelectedDataSet, oldForcedJoin.TableInfo); } try { //clone the root filter container var rootContainer = (FilterContainer)GetFilterContainerFor(selected.ExtractableDataSet); //turns out there wasn't one to clone at all if (rootContainer == null) { continue; } //there was one to clone so clone it recursively (all subcontainers) including filters then set the root filter to the new clone FilterContainer cloneRootContainer = rootContainer.DeepCloneEntireTreeRecursivelyIncludingFilters(); newSelectedDataSet.RootFilterContainer_ID = cloneRootContainer.ID; newSelectedDataSet.SaveToDatabase(); } catch (Exception e) { clone.DeleteInDatabase(); throw new Exception("Problem occurred during cloning filters, problem was " + e.Message + " deleted the clone configuration successfully", e); } } clone.dtCreated = DateTime.Now; clone.IsReleased = false; clone.Username = Environment.UserName; clone.Description = "TO" + "DO:Populate change log here"; clone.ReleaseTicket = null; //wire up some changes clone.ClonedFrom_ID = this.ID; clone.SaveToDatabase(); repo.EndTransactedConnection(true); return(clone); } catch (Exception) { repo.EndTransactedConnection(false); throw; } } }
public bool ShouldBeReadOnly(out string reason) { return(ExtractionConfiguration.ShouldBeReadOnly(out reason)); }