Exemple #1
0
        /// <summary>
        /// Creates the event type fields.
        /// </summary>
        /// <param name="databaseStreamSpec">The database stream spec.</param>
        /// <param name="columnTypeConversionHook">The column type conversion hook.</param>
        /// <param name="queryMetaData">The query meta data.</param>
        /// <returns></returns>
        private static IDictionary<string, object> CreateEventTypeFields(
            DBStatementStreamSpec databaseStreamSpec,
            SQLColumnTypeConversion columnTypeConversionHook,
            QueryMetaData queryMetaData)
        {
            IDictionary<string, object> eventTypeFields = new Dictionary<string, object>();
            var columnNum = 1;
            foreach (var entry in queryMetaData.OutputParameters) {
                var name = entry.Key;
                var dbOutputDesc = entry.Value;

                Type clazz;
                if (dbOutputDesc.OptionalBinding != null) {
                    clazz = dbOutputDesc.OptionalBinding.DataType;
                }
                else {
                    clazz = dbOutputDesc.DataType;
                }

                if (columnTypeConversionHook != null) {
                    var newValue = columnTypeConversionHook.GetColumnType(
                        new SQLColumnTypeContext(
                            databaseStreamSpec.DatabaseName,
                            databaseStreamSpec.SqlWithSubsParams,
                            name,
                            clazz,
                            dbOutputDesc.SqlType,
                            columnNum));

                    if (newValue != null) {
                        clazz = newValue;
                    }
                }

                eventTypeFields.Put(name, clazz);
                columnNum++;
            }

            return eventTypeFields;
        }
Exemple #2
0
        /// <summary>
        /// Creates an event type from the query meta data.
        /// </summary>
        /// <param name="streamNum"></param>
        /// <param name="queryMetaData">The query meta data.</param>
        /// <param name="services"></param>
        /// <param name="databaseStreamSpec">The database stream spec.</param>
        /// <param name="columnTypeConversionHook">The column type conversion hook.</param>
        /// <param name="outputRowConversionHook">The output row conversion hook.</param>
        /// <param name="base"></param>
        private static EventType CreateEventType(
            int streamNum,
            QueryMetaData queryMetaData,
            StatementCompileTimeServices services,
            DBStatementStreamSpec databaseStreamSpec,
            SQLColumnTypeConversion columnTypeConversionHook,
            SQLOutputRowConversion outputRowConversionHook,
            StatementBaseInfo @base)
        {
            var eventTypeFields = CreateEventTypeFields(
                databaseStreamSpec,
                columnTypeConversionHook,
                queryMetaData);

            var eventTypeName = services.EventTypeNameGeneratorStatement.GetAnonymousDBHistorical(streamNum);

            EventType eventType;
            Func<EventTypeApplicationType, EventTypeMetadata> metadata = appType => new EventTypeMetadata(
                eventTypeName,
                @base.ModuleName,
                EventTypeTypeClass.DBDERIVED,
                appType,
                NameAccessModifier.TRANSIENT,
                EventTypeBusModifier.NONBUS,
                false,
                EventTypeIdPair.Unassigned());
            if (outputRowConversionHook == null) {
                eventType = BaseNestableEventUtil.MakeMapTypeCompileTime(
                    metadata.Invoke(EventTypeApplicationType.MAP),
                    eventTypeFields,
                    null,
                    null,
                    null,
                    null,
                    services.BeanEventTypeFactoryPrivate,
                    services.EventTypeCompileTimeResolver);
            }
            else {
                var carrierClass = outputRowConversionHook.GetOutputRowType(
                    new SQLOutputRowTypeContext(
                        databaseStreamSpec.DatabaseName,
                        databaseStreamSpec.SqlWithSubsParams,
                        eventTypeFields));
                if (carrierClass == null) {
                    throw new ExprValidationException("Output row conversion hook returned no type");
                }

                var stem = services.BeanEventTypeStemService.GetCreateStem(carrierClass, null);
                eventType = new BeanEventType(
                    services.Container,
                    stem,
                    metadata.Invoke(EventTypeApplicationType.CLASS),
                    services.BeanEventTypeFactoryPrivate,
                    null,
                    null,
                    null,
                    null);
            }

            return eventType;
        }