public ExtractableColumn ShallowClone() { var eds = DataExportRepository.GetObjectByID <ExtractableDataSet>(ExtractableDataSet_ID); var config = DataExportRepository.GetObjectByID <ExtractionConfiguration>(ExtractionConfiguration_ID); var clone = new ExtractableColumn(DataExportRepository, eds, config, CatalogueExtractionInformation, Order, SelectSQL); CopyShallowValuesTo(clone); return(clone); }
public void HackSQLTest_Normal() { if (_request.QueryBuilder == null) { _request.GenerateQueryBuilder(); } string expectedOutput = string.Format(@"/*The ID of the cohort in [tempdb]..[Cohort]*/ DECLARE @CohortDefinitionID AS int; SET @CohortDefinitionID=-599; /*The project number of project {0}ExtractionConfiguration*/ DECLARE @ProjectNumber AS int; SET @ProjectNumber=1; SELECT DISTINCT [tempdb]..[Cohort].[ReleaseID] AS ReleaseID, [{0}ScratchArea].dbo.[TestTable].[Name], [{0}ScratchArea].dbo.[TestTable].[DateOfBirth] FROM [{0}ScratchArea].dbo.[TestTable] INNER JOIN [tempdb]..[Cohort] ON [{0}ScratchArea].dbo.[TestTable].[PrivateID]=[tempdb]..[Cohort].[PrivateID] WHERE [tempdb]..[Cohort].[cohortDefinition_id]=-599 ", TestDatabaseNames.Prefix); //cross server is only used if cohort and dataset are on different servers so pretend the cohort is on bob server var ect = (ExternalCohortTable)_request.ExtractableCohort.ExternalCohortTable; ect.Server = "bob"; var e = DataExportRepository.GetObjectByID <ExternalCohortTable>(_request.ExtractableCohort.ExternalCohortTable_ID); string origValue = e.Database; e.Database = CohortDatabaseName; e.SaveToDatabase(); try { ExecuteCrossServerDatasetExtractionSource s = new ExecuteCrossServerDatasetExtractionSource(); s.TemporaryDatabaseName = "tempdb"; s.PreInitialize(_request, new ThrowImmediatelyDataLoadEventListener()); string hacked = s.HackExtractionSQL(_request.QueryBuilder.SQL, new ThrowImmediatelyDataLoadEventListener() { ThrowOnWarning = true }); Assert.AreEqual(expectedOutput.Trim(), hacked.Trim()); } finally { e.Database = origValue; e.SaveToDatabase(); } }
public void UpdateProjectDatabaseTable() { Project table = new Project(DataExportRepository, "unit_test_UpdateProjectDatabaseTable"); try { Assert.AreEqual(table.Name, "unit_test_UpdateProjectDatabaseTable"); table.Name = "unit_test_UpdateProjectDatabaseTable2"; table.SaveToDatabase(); //get fresh copy from database and ensure that all fields are the same var tableAfter = DataExportRepository.GetObjectByID <Project>(table.ID); PropertyValuesAreEquals(table, tableAfter); } finally { table.DeleteInDatabase(); } }