public static void BuildOATypes( EventTypeRepositoryImpl repo, IDictionary<string, ConfigurationCommonEventTypeObjectArray> objectArrayTypeConfigurations, IDictionary<string, IDictionary<string, object>> nestableObjectArrayNames, BeanEventTypeFactory beanEventTypeFactory, ImportService importService) { var creationOrder = EventTypeRepositoryUtil.GetCreationOrder( EmptySet<string>.Instance, nestableObjectArrayNames.Keys, objectArrayTypeConfigurations); foreach (var objectArrayName in creationOrder) { if (repo.GetTypeByName(objectArrayName) != null) { continue; } var objectArrayConfig = objectArrayTypeConfigurations.Get(objectArrayName); var propertyTypes = nestableObjectArrayNames.Get(objectArrayName); propertyTypes = ResolveClassesForStringPropertyTypes(propertyTypes, importService); var propertyTypesCompiled = EventTypeUtility.CompileMapTypeProperties(propertyTypes, repo); AddNestableObjectArrayType(objectArrayName, propertyTypesCompiled, objectArrayConfig, beanEventTypeFactory, repo); } }
/// <summary> /// Validate the variant stream definition. /// </summary> /// <param name="variantStreamname">the stream name</param> /// <param name="variantStreamConfig">the configuration information</param> /// <param name="repo">the event types</param> /// <returns>specification for variant streams</returns> private static VariantSpec ValidateVariantStream( string variantStreamname, ConfigurationCommonVariantStream variantStreamConfig, EventTypeRepositoryImpl repo) { if (variantStreamConfig.TypeVariance == TypeVariance.PREDEFINED) { if (variantStreamConfig.VariantTypeNames.IsEmpty()) { throw new ConfigurationException( "Invalid variant stream configuration, no event type name has been added and default type variance requires at least one type, for name '" + variantStreamname + "'"); } } ISet<EventType> types = new LinkedHashSet<EventType>(); foreach (var typeName in variantStreamConfig.VariantTypeNames) { var type = repo.GetTypeByName(typeName); if (type == null) { throw new ConfigurationException( "Event type by name '" + typeName + "' could not be found for use in variant stream configuration by name '" + variantStreamname + "'"); } types.Add(type); } var eventTypes = types.ToArray(); return new VariantSpec(eventTypes, variantStreamConfig.TypeVariance); }
public static void BuildMapTypes( EventTypeRepositoryImpl repo, IDictionary<string, ConfigurationCommonEventTypeMap> mapTypeConfigurations, IDictionary<string, Properties> mapTypes, IDictionary<string, IDictionary<string, object>> nestableMapEvents, BeanEventTypeFactory beanEventTypeFactory, ImportService importService) { var creationOrder = EventTypeRepositoryUtil.GetCreationOrder(mapTypes.Keys, nestableMapEvents.Keys, mapTypeConfigurations); foreach (var mapName in creationOrder) { if (repo.GetTypeByName(mapName) != null) { continue; } var mapConfig = mapTypeConfigurations.Get(mapName); if (mapTypes.TryGetValue(mapName, out var propertiesUnnested)) { var propertyTypes = CreatePropertyTypes(propertiesUnnested, importService); var propertyTypesCompiled = EventTypeUtility.CompileMapTypeProperties(propertyTypes, repo); AddNestableMapType(mapName, propertyTypesCompiled, mapConfig, repo, beanEventTypeFactory, repo); } if (nestableMapEvents.TryGetValue(mapName, out var propertiesNestable)) { var propertiesNestableCompiled = EventTypeUtility.CompileMapTypeProperties(propertiesNestable, repo); AddNestableMapType(mapName, propertiesNestableCompiled, mapConfig, repo, beanEventTypeFactory, repo); } } }
private static void BuildAvroType( EventTypeRepositoryImpl eventTypeRepositoryPreconfigured, string eventTypeName, ConfigurationCommonEventTypeAvro config, EventTypeAvroHandler eventTypeAvroHandler, EventBeanTypedEventFactory eventBeanTypedEventFactory) { var metadata = new EventTypeMetadata( eventTypeName, null, EventTypeTypeClass.APPLICATION, EventTypeApplicationType.AVRO, NameAccessModifier.PRECONFIGURED, EventTypeBusModifier.NONBUS, false, new EventTypeIdPair(CRC32Util.ComputeCRC32(eventTypeName), -1)); var avroSuperTypes = EventTypeUtility.GetSuperTypesDepthFirst( config.SuperTypes, EventUnderlyingType.AVRO, eventTypeRepositoryPreconfigured); var newEventType = eventTypeAvroHandler.NewEventTypeFromSchema( metadata, eventBeanTypedEventFactory, config, avroSuperTypes.First, avroSuperTypes.Second); eventTypeRepositoryPreconfigured.AddType(newEventType); }
public void MergeFrom(EventTypeRepositoryImpl other) { foreach (var entry in other.NameToTypeMap) { if (NameToTypeMap.ContainsKey(entry.Key)) { continue; } AddType(entry.Value); } }
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); }
public static void BuildVariantStreams( EventTypeRepositoryImpl repo, IDictionary<string, ConfigurationCommonVariantStream> variantStreams, EventTypeFactory eventTypeFactory) { foreach (var entry in variantStreams) { if (repo.GetTypeByName(entry.Key) == null) { AddVariantStream(entry.Key, entry.Value, repo, eventTypeFactory); } } }
private static void AddXMLDOMType( EventTypeRepositoryImpl repo, string eventTypeName, ConfigurationCommonEventTypeXMLDOM detail, SchemaModel schemaModel, BeanEventTypeFactory beanEventTypeFactory, XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory) { if (detail.RootElementName == null) { throw new EventAdapterException("Required root element name has not been supplied"); } var existingType = repo.GetTypeByName(eventTypeName); if (existingType != null) { var message = "Event type named '" + eventTypeName + "' has already been declared with differing column name or type information"; throw new ConfigurationException(message); } var propertyAgnostic = detail.SchemaResource == null && detail.SchemaText == null; var metadata = new EventTypeMetadata( eventTypeName, null, EventTypeTypeClass.STREAM, EventTypeApplicationType.XML, NameAccessModifier.PRECONFIGURED, EventTypeBusModifier.BUS, propertyAgnostic, new EventTypeIdPair(CRC32Util.ComputeCRC32(eventTypeName), -1)); var type = beanEventTypeFactory.EventTypeFactory.CreateXMLType( metadata, detail, schemaModel, null, metadata.Name, beanEventTypeFactory, xmlFragmentEventTypeFactory, repo); repo.AddType(type); if (type is SchemaXMLEventType) { xmlFragmentEventTypeFactory.AddRootType((SchemaXMLEventType) type); } }
private static void AddVariantStream( string name, ConfigurationCommonVariantStream config, EventTypeRepositoryImpl repo, EventTypeFactory eventTypeFactory) { var variantSpec = ValidateVariantStream(name, config, repo); var metadata = new EventTypeMetadata( name, null, EventTypeTypeClass.VARIANT, EventTypeApplicationType.VARIANT, NameAccessModifier.PRECONFIGURED, EventTypeBusModifier.BUS, false, new EventTypeIdPair(CRC32Util.ComputeCRC32(name), -1)); var variantEventType = eventTypeFactory.CreateVariant(metadata, variantSpec); repo.AddType(variantEventType); }
public static void BuildAvroTypes( EventTypeRepositoryImpl repo, IDictionary<string, ConfigurationCommonEventTypeAvro> eventTypesAvro, EventTypeAvroHandler eventTypeAvroHandler, EventBeanTypedEventFactory eventBeanTypedEventFactory) { foreach (var entry in eventTypesAvro) { if (repo.GetTypeByName(entry.Key) != null) { continue; } BuildAvroType( repo, entry.Key, entry.Value, eventTypeAvroHandler, eventBeanTypedEventFactory); } }
public static void BuildXMLTypes( EventTypeRepositoryImpl repo, IDictionary<string, ConfigurationCommonEventTypeXMLDOM> eventTypesXMLDOM, BeanEventTypeFactory beanEventTypeFactory, XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory, IResourceManager resourceManager) { // Add from the configuration the XML DOM names and type def foreach (var entry in eventTypesXMLDOM) { if (repo.GetTypeByName(entry.Key) != null) { continue; } SchemaModel schemaModel = null; if (entry.Value.SchemaResource != null || entry.Value.SchemaText != null) { try { schemaModel = XSDSchemaMapper.LoadAndMap( entry.Value.SchemaResource, entry.Value.SchemaText, resourceManager); } catch (Exception ex) { throw new ConfigurationException(ex.Message, ex); } } try { AddXMLDOMType( repo, entry.Key, entry.Value, schemaModel, beanEventTypeFactory, xmlFragmentEventTypeFactory); } catch (Exception ex) { throw new ConfigurationException(ex.Message, ex); } } }