public void TestInvalidConfig()
        {
            // invalid multiple supertypes
            var invalidOAConfig = new ConfigurationCommonEventTypeObjectArray();
            invalidOAConfig.SuperTypes = Collections.Set("A", "B");
            string[] invalidOANames = {"P00"};
            object[] invalidOATypes = {typeof(int)};
            try {
                var configuration = SupportConfigFactory.GetConfiguration();
                configuration.Common.AddEventType("MyInvalidEventTwo", invalidOANames, invalidOATypes, invalidOAConfig);
                Assert.Fail();
            }
            catch (ConfigurationException ex) {
                Assert.AreEqual("Object-array event types only allow a single supertype", ex.Message);
            }

            // mismatched property number
            try {
                var configuration = SupportConfigFactory.GetConfiguration();
                configuration.Common.AddEventType(
                    "MyInvalidEvent",
                    new[] {"P00"},
                    new object[] {typeof(int), typeof(string)});
                Assert.Fail();
            }
            catch (ConfigurationException ex) {
                Assert.AreEqual(
                    "Number of property names and property types do not match, found 1 property names and 2 property types",
                    ex.Message);
            }
        }
        private static void AddNestableObjectArrayType(
            string eventTypeName,
            IDictionary<string, object> propertyTypesMayHavePrimitive,
            ConfigurationCommonEventTypeObjectArray optionalConfig,
            BeanEventTypeFactory beanEventTypeFactory,
            EventTypeRepositoryImpl repo)
        {
            if (optionalConfig != null && optionalConfig.SuperTypes.Count > 1) {
                throw new EventAdapterException(ConfigurationCommonEventTypeObjectArray.SINGLE_SUPERTYPE_MSG);
            }

            var propertyTypes =
                EventTypeUtility.GetPropertyTypesNonPrimitive(propertyTypesMayHavePrimitive);
            var metadata = new EventTypeMetadata(
                eventTypeName,
                null,
                EventTypeTypeClass.APPLICATION,
                EventTypeApplicationType.OBJECTARR,
                NameAccessModifier.PRECONFIGURED,
                EventTypeBusModifier.NONBUS,
                false,
                new EventTypeIdPair(CRC32Util.ComputeCRC32(eventTypeName), -1));
            string[] superTypes = null;
            if (optionalConfig != null && optionalConfig.SuperTypes != null && !optionalConfig.SuperTypes.IsEmpty()) {
                superTypes = optionalConfig.SuperTypes.ToArray();
            }

            var newEventType = beanEventTypeFactory.EventTypeFactory.CreateObjectArray(
                metadata,
                propertyTypes,
                superTypes,
                optionalConfig != null ? optionalConfig.StartTimestampPropertyName : null,
                optionalConfig != null ? optionalConfig.EndTimestampPropertyName : null,
                beanEventTypeFactory,
                repo);

            var existingType = repo.GetTypeByName(eventTypeName);
            if (existingType != null) {
                // The existing type must be the same as the type createdStatement
                if (newEventType.EqualsCompareType(existingType) != null) {
                    var message = newEventType.CompareEquals(existingType);
                    throw new EPException(
                        "Event type named '" +
                        eventTypeName +
                        "' has already been declared with differing column name or type information: " +
                        message.Message,
                        message);
                }

                // Since it's the same, return the existing type
                return;
            }

            repo.AddType(newEventType);
        }
Exemplo n.º 3
0
 internal static void AddIdStsEtsEvent(Configuration configuration)
 {
     var oa = new ConfigurationCommonEventTypeObjectArray();
     oa.StartTimestampPropertyName = "Sts";
     oa.EndTimestampPropertyName = "Ets";
     configuration.Common.AddEventType(
         "MyEvent",
         new[] {"Id", "Sts", "Ets"},
         new object[] {typeof(string), typeof(long), typeof(long)},
         oa);
 }
Exemplo n.º 4
0
        private static void Configure(Configuration configuration)
        {
            configuration.Common.AddImportType(typeof(DateTimeParsingFunctions));

            foreach (var clazz in new[] {
                typeof(SupportDateTime),
                typeof(SupportTimeStartEndA),
                typeof(SupportBean),
                typeof(SupportEventWithJustGet),
                typeof(SupportBean_ST0_Container)
            }) {
                configuration.Common.AddEventType(clazz);
            }

            IDictionary<string, object> meta = new Dictionary<string, object>();
            meta.Put("timeTaken", typeof(DateTimeEx));
            configuration.Common.AddEventType("RFIDEvent", meta);

            var common = configuration.Common;
            common.AddVariable("V_START", typeof(long), -1);
            common.AddVariable("V_END", typeof(long), -1);

            var leg = new ConfigurationCommonEventTypeBean();
            leg.StartTimestampPropertyName = "LongdateStart";
            configuration.Common.AddEventType("A", typeof(SupportTimeStartEndA), leg);
            configuration.Common.AddEventType("B", typeof(SupportTimeStartEndB), leg);

            var configBean = new ConfigurationCommonEventTypeBean();
            configBean.StartTimestampPropertyName = "LongdateStart";
            configBean.EndTimestampPropertyName = "LongdateEnd";
            configuration.Common.AddEventType("SupportTimeStartEndA", typeof(SupportTimeStartEndA), configBean);
            configuration.Common.AddEventType("SupportTimeStartEndB", typeof(SupportTimeStartEndB), configBean);

            configuration.Common.AddImportType(typeof(DateTime));
            configuration.Common.AddImportType(typeof(SupportBean_ST0_Container));
            configuration.Compiler.AddPlugInSingleRowFunction(
                "makeTest",
                typeof(SupportBean_ST0_Container),
                "MakeTest");

            foreach (var fieldType in EnumHelper.GetValues<SupportDateTimeFieldType>()) {
                var oa = new ConfigurationCommonEventTypeObjectArray();
                oa.StartTimestampPropertyName = "startTS";
                oa.EndTimestampPropertyName = "endTS";
                configuration.Common.AddEventType(
                    "A_" + fieldType.GetName(),
                    new[] {"startTS", "endTS"},
                    new object[] {
                        fieldType.GetFieldType(),
                        fieldType.GetFieldType()
                    },
                    oa);
                configuration.Common.AddEventType(
                    "B_" + fieldType.GetName(),
                    new[] {"startTS", "endTS"},
                    new object[] {
                        fieldType.GetFieldType(),
                        fieldType.GetFieldType()
                    },
                    oa);
            }

            AddIdStsEtsEvent(configuration);
        }