public static List <ConstantParameter> GetConstantParameters(IQuerySyntaxHelper syntaxHelper, IExtractionConfiguration configuration, IExtractableCohort extractableCohort) { List <ConstantParameter> toReturn = new List <ConstantParameter>(); if (syntaxHelper.DatabaseType == FAnsi.DatabaseType.Oracle) { return(toReturn); } IProject project = configuration.Project; if (project.ProjectNumber == null) { throw new ProjectNumberException("Project number has not been entered, cannot create constant paramaters"); } if (extractableCohort == null) { throw new Exception("Cohort has not been selected, cannot create constant parameters"); } IExternalCohortTable externalCohortTable = extractableCohort.ExternalCohortTable; var declarationSqlCohortId = syntaxHelper.GetParameterDeclaration("@CohortDefinitionID", new DatabaseTypeRequest(typeof(int))); var declarationSqlProjectNumber = syntaxHelper.GetParameterDeclaration("@ProjectNumber", new DatabaseTypeRequest(typeof(int))); toReturn.Add(new ConstantParameter(declarationSqlCohortId, extractableCohort.OriginID.ToString(), "The ID of the cohort in " + externalCohortTable.TableName, syntaxHelper)); toReturn.Add(new ConstantParameter(declarationSqlProjectNumber, project.ProjectNumber.ToString(), "The project number of project " + project.Name, syntaxHelper)); return(toReturn); }
/// <summary> /// Sets up a new row for inserting (or reporting) from an <see cref="ExternalCohortTable"/>. /// </summary> /// <param name="id">The ID row read from the table (this is not an RDMP ID, it is an <see cref="IExtractableCohort.OriginID"/>). Pass null if you /// are trying to insert a new row and expect the database to allocate the ID itself as an autonum</param> /// <param name="description">Unique string identifying the cohort, this should be the same for all cohorts that are versions of one another</param> /// <param name="version">The version number where there are multiple revisions to a cohort over time (these must share the same <paramref name="description"/>)</param> /// <param name="projectNumber">The <see cref="IProject.ProjectNumber"/> that the cohort can be used with</param> /// <param name="locationOfCohort">The database where the row will be written to (or read from)</param> public CohortDefinition(int?id, string description, int version, int projectNumber, IExternalCohortTable locationOfCohort) { ID = id; Description = description; Version = version; ProjectNumber = projectNumber; LocationOfCohort = locationOfCohort; if (string.IsNullOrWhiteSpace(description)) { if (id == null) { throw new ArgumentNullException("Cohorts must have a description"); } else { throw new NullReferenceException("There is a cohort (with ID " + id + ") in " + locationOfCohort.DefinitionTableName + " which has a blank/null description. You must fix this."); } } }
public CohortCreationRequestUI(IActivateItems activator, IExternalCohortTable target, IProject project = null) : base(activator) { _target = target; InitializeComponent(); if (_target == null) { return; } _repository = (DataExportRepository)_target.Repository; lblExternalCohortTable.Text = _target.ToString(); SetProject(project); pbProject.Image = CatalogueIcons.Project; pbCohortSource.Image = CatalogueIcons.ExternalCohortTable; }
private void GenerateSQLPreview() { if (VisualStudioDesignMode) { return; } QueryPreview.ReadOnly = false; try { string toShow = ""; DiscoveredDatabase location = _extractableCohort.GetDatabaseServer(); //tell user about connection string (currently we don't support usernames/passwords so it's fine toShow += "/*Cohort is stored in Server " + location.Server.Name + " Database " + location.GetRuntimeName() + "*/" + Environment.NewLine; toShow += Environment.NewLine; IExternalCohortTable externalCohortTable = _extractableCohort.ExternalCohortTable; string sql = "SELECT * FROM " + externalCohortTable.TableName + Environment.NewLine + " WHERE " + _extractableCohort.WhereSQL(); toShow += Environment.NewLine; toShow += Environment.NewLine + "/*SQL to view cohort:*/" + Environment.NewLine; toShow += sql; QueryPreview.Text = toShow; } catch (Exception ex) { QueryPreview.Text = ExceptionHelper.ExceptionToListOfInnerMessages(ex, true); } finally { QueryPreview.ReadOnly = true; } }