public void TestInvalidConfig() { // supertype not found TryInvalidConfigure( config => { ConfigurationCommonEventTypeMap map = new ConfigurationCommonEventTypeMap(); map.SuperTypes = Collections.SingletonSet("NONE"); config.Common.AddEventType("InvalidMap", Collections.EmptyDataMap, map); }, "Supertype by name 'NONE' could not be found"); // invalid property TryInvalidConfigure( config => { config.Common.AddEventType("InvalidMap", Collections.SingletonDataMap("key", "XXX")); }, "Nestable type configuration encountered an unexpected property type name 'XXX' for property 'key', expected Type or Dictionary or the name of a previously-declared event type"); // invalid key #if NOT_VALID IDictionary<string, object> invalid = EventMapCore.MakeMap( new object[][] { new object[] {new int?(5), null} }); TryInvalidConfigure( config => { config.Common.AddEventType("InvalidMap", invalid); }, GetCastMessage(typeof(int?), typeof(string))); #endif IDictionary<string, object> invalidTwo = EventMapCore.MakeMap( new object[][] { new object[] {"abc", new SupportBean()} }); TryInvalidConfigure( config => { config.Common.AddEventType("InvalidMap", invalidTwo); }, "Nestable type configuration encountered an unexpected property type name 'SupportBean(null, 0)' for property 'abc', expected Type or Dictionary or the name of a previously-declared event type"); }
private static void HandleMap( string name, ConfigurationCommon configuration, XmlElement eventTypeElement) { ConfigurationCommonEventTypeMap config; var startTimestampProp = GetOptionalAttribute(eventTypeElement, "start-timestamp-property-name"); var endTimestampProp = GetOptionalAttribute(eventTypeElement, "end-timestamp-property-name"); var superTypesList = eventTypeElement.Attributes.GetNamedItem("supertype-names"); if (superTypesList != null || startTimestampProp != null || endTimestampProp != null) { config = new ConfigurationCommonEventTypeMap(); if (superTypesList != null) { var value = superTypesList.InnerText; var names = value.SplitCsv(); foreach (var superTypeName in names) { config.SuperTypes.Add(superTypeName.Trim()); } } config.EndTimestampPropertyName = endTimestampProp; config.StartTimestampPropertyName = startTimestampProp; configuration.AddMapConfiguration(name, config); } var propertyTypeNames = new Properties(); var propertyList = eventTypeElement.GetElementsByTagName("map-property"); for (var i = 0; i < propertyList.Count; i++) { var nameProperty = GetRequiredAttribute(propertyList.Item(i), "name"); var clazz = GetRequiredAttribute(propertyList.Item(i), "class"); propertyTypeNames.Put(nameProperty, clazz); } configuration.AddEventType(name, propertyTypeNames); }
private static void AddNestableMapType( string eventTypeName, IDictionary<string, object> propertyTypesMayHavePrimitive, ConfigurationCommonEventTypeMap optionalConfig, EventTypeRepositoryImpl repo, BeanEventTypeFactory beanEventTypeFactory, EventTypeNameResolver eventTypeNameResolver) { var metadata = new EventTypeMetadata( eventTypeName, null, EventTypeTypeClass.APPLICATION, EventTypeApplicationType.MAP, NameAccessModifier.PRECONFIGURED, EventTypeBusModifier.NONBUS, false, new EventTypeIdPair(CRC32Util.ComputeCRC32(eventTypeName), -1)); var propertyTypes = EventTypeUtility.GetPropertyTypesNonPrimitive(propertyTypesMayHavePrimitive); string[] superTypes = null; if (optionalConfig != null && optionalConfig.SuperTypes != null && !optionalConfig.SuperTypes.IsEmpty()) { superTypes = optionalConfig.SuperTypes.ToArray(); } var newEventType = beanEventTypeFactory.EventTypeFactory.CreateMap( metadata, propertyTypes, superTypes, optionalConfig?.StartTimestampPropertyName, optionalConfig?.EndTimestampPropertyName, beanEventTypeFactory, eventTypeNameResolver); 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); } return; } repo.AddType(newEventType); }