/// <summary>
        /// Initializes a new instance of the <see cref="MaintainableAnnotationRetrieverEngine"/> class.
        /// </summary>
        /// <param name="mappingStoreDb">The mapping store database.</param>
        /// <param name="tableInfo">The table information.</param>
        /// <exception cref="System.ArgumentNullException"><paramref name="tableInfo"/> is null -or- <paramref name="mappingStoreDb"/> is null.</exception>
        public MaintainableAnnotationRetrieverEngine(Database mappingStoreDb, TableInfo tableInfo)
        {
            if (mappingStoreDb == null)
            {
                throw new ArgumentNullException("mappingStoreDb");
            }

            if (tableInfo == null)
            {
                throw new ArgumentNullException("tableInfo");
            }

            this._mappingStoreDb = mappingStoreDb;

            ISqlQueryInfoBuilder<TableInfo> annotationQueryBuilder = new AnnotationQueryBuilder();
            this._annotationSqlQueryInfo = annotationQueryBuilder.Build(tableInfo);

            this._annotationCommandBuilder = new AnnotationCommandBuilder(this._mappingStoreDb);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PartialCodesSqlQuery"/> class.
 /// </summary>
 /// <param name="queryInfo">
 /// The query Info.
 /// </param>
 /// <param name="parentSysId">
 /// The parent ItemScheme parent Id.
 /// </param>
 public PartialCodesSqlQuery(SqlQueryInfo queryInfo, long parentSysId)
     : base(queryInfo, parentSysId)
 {
 }
        /// <summary>
        /// Build SQL command for retrieving Mapping Set for the dataflow with the specified <paramref name="maintainableRef"/> .
        /// </summary>
        /// <param name="maintainableRef">
        /// The maintainable ref.
        /// </param>
        /// <param name="mappingStoreDb">
        /// The mapping store DB.
        /// </param>
        /// <param name="allowedDataflows">
        /// The allowed dataflows.
        /// </param>
        /// <returns>
        /// The <see cref="StringBuilder"/>.
        /// </returns>
        private static DbCommand BuildSqlCommand(IMaintainableRefObject maintainableRef, Database mappingStoreDb, IList<IMaintainableRefObject> allowedDataflows)
        {
            var builder = new DataflowCommandBuilder(mappingStoreDb, ProductionDataflowOnly ? DataflowFilter.Production : (InUsageDataflowOnly ? DataflowFilter.Usage :  DataflowFilter.Any));
            var sqlCommand = new StringBuilder(MappingStoreSqlStatements.MappingSetDataflow);
            
            // get a specific version of the dataflow
            if (!maintainableRef.HasVersion())
            {
                // or else get the latest
                SqlHelper.AddWhereClause(
                    sqlCommand,
                    WhereState.And,
                    " (SELECT COUNT(*) FROM ARTEFACT A2 INNER JOIN DATAFLOW T2 ON A2.ART_ID = T2.DF_ID where A2.ID=A.ID AND A2.AGENCY=A.AGENCY AND dbo.isGreaterVersion(A2.VERSION1, A2.VERSION2, A2.VERSION3, A.VERSION1, A.VERSION2, A.VERSION3)=1 {0} ) = 0 ",
                    ProductionDataflowOnly ? DataflowConstant.ProductionWhereLatestClause : (InUsageDataflowOnly ? DataflowConstant.InUsageWhereLatestClause : string.Empty));
            }

            var sqlQueryInfo = new SqlQueryInfo { QueryFormat = sqlCommand.ToString(), WhereStatus = WhereState.And };
            return builder.Build(new ArtefactSqlQuery(sqlQueryInfo, maintainableRef), allowedDataflows);
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PartialCodesSqlQuery"/> class.
 /// </summary>
 /// <param name="queryInfo">
 /// The query Info.
 /// </param>
 /// <param name="parentSysId">
 /// The parent ItemScheme parent Id.
 /// </param>
 public PartialCodesSqlQuery(SqlQueryInfo queryInfo, long parentSysId)
     : base(queryInfo, parentSysId)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ArtefactSqlQuery"/> class.
 /// </summary>
 /// <param name="queryInfo">
 /// The query info.
 /// </param>
 /// <param name="maintainableRef">
 /// The maintainable reference which may contain ID, AGENCY ID and/or VERSION
 /// </param>
 public ArtefactSqlQuery(SqlQueryInfo queryInfo, IMaintainableRefObject maintainableRef)
     : base(queryInfo)
 {
     this._maintainableRef = maintainableRef ?? new MaintainableRefObjectImpl();
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ArtefactSqlQuery"/> class.
 /// </summary>
 /// <param name="queryInfo">
 /// The query info.
 /// </param>
 /// <param name="maintainableRef">
 /// The maintainable reference which may contain ID, AGENCY ID and/or VERSION
 /// </param>
 public ArtefactSqlQuery(SqlQueryInfo queryInfo, IMaintainableRefObject maintainableRef)
     : base(queryInfo)
 {
     this._maintainableRef = maintainableRef ?? new MaintainableRefObjectImpl();
 }