public void mergeFrom(EventTypeRepositoryImpl other) { for (Map.Entry<String, EventType> entry : other.getNameToTypeMap().entrySet()) { if (nameToTypeMap.containsKey(entry.getKey())) { continue; } addType(entry.getValue()); } }
private static void addVariantStream(String name, ConfigurationCommonVariantStream config, EventTypeRepositoryImpl repo, EventTypeFactory eventTypeFactory) { VariantSpec variantSpec = validateVariantStream(name, config, repo); EventTypeMetadata metadata = new EventTypeMetadata(name, null, EventTypeTypeClass.VARIANT, EventTypeApplicationType.VARIANT, NameAccessModifier.PRECONFIGURED, EventTypeBusModifier.BUS, false, new EventTypeIdPair(CRC32Util.computeCRC32(name), -1)); VariantEventType variantEventType = eventTypeFactory.createVariant(metadata, variantSpec); repo.addType(variantEventType); } }
public EPCompilerPathable getRuntimePath() { EPServicesContext services = runtimeEnvironment.getServices(); VariableRepositoryPreconfigured variables = new VariableRepositoryPreconfigured(); for (Map.Entry<String, VariableDeployment> entry : services.getVariableManagementService().getDeploymentsWithVariables().entrySet()) { for (Map.Entry<String, Variable> variableEntry : entry.getValue().getVariables().entrySet()) { if (variableEntry.getValue().getMetaData().isPreconfigured()) { variables.addVariable(variableEntry.getKey(), variableEntry.getValue().getMetaData()); } } } EventTypeRepositoryImpl eventTypes = new EventTypeRepositoryImpl(true); for (Map.Entry<String, EventType> entry : services.getEventTypeRepositoryBus().getNameToTypeMap().entrySet()) { if (entry.getValue().getMetadata().getAccessModifier() == NameAccessModifier.PRECONFIGURED) { eventTypes.addType(entry.getValue()); } } return new EPCompilerPathableImpl( services.getVariablePathRegistry().copy(), services.getEventTypePathRegistry().copy(), services.getExprDeclaredPathRegistry().copy(), services.getNamedWindowPathRegistry().copy(), services.getTablePathRegistry().copy(), services.getContextPathRegistry().copy(), services.getScriptPathRegistry().copy(), eventTypes, variables); }
private static void buildAvroType(EventTypeRepositoryImpl eventTypeRepositoryPreconfigured, String eventTypeName, ConfigurationCommonEventTypeAvro config, EventTypeAvroHandler eventTypeAvroHandler, EventBeanTypedEventFactory eventBeanTypedEventFactory) { EventTypeMetadata metadata = new EventTypeMetadata(eventTypeName, null, EventTypeTypeClass.APPLICATION, EventTypeApplicationType.AVRO, NameAccessModifier.PRECONFIGURED, EventTypeBusModifier.BUS, false, new EventTypeIdPair(CRC32Util.computeCRC32(eventTypeName), -1)); Pair<EventType[], Set<EventType>> avroSuperTypes = EventTypeUtility.getSuperTypesDepthFirst(config.getSuperTypes(), EventUnderlyingType.AVRO, eventTypeRepositoryPreconfigured); AvroSchemaEventType newEventType = eventTypeAvroHandler.newEventTypeFromSchema(metadata, eventBeanTypedEventFactory, config, avroSuperTypes.getFirst(), avroSuperTypes.getSecond()); eventTypeRepositoryPreconfigured.addType(newEventType); } }
private static void addNestableObjectArrayType(String eventTypeName, LinkedHashMap<String, Object> propertyTypesMayHavePrimitive, ConfigurationCommonEventTypeObjectArray optionalConfig, BeanEventTypeFactory beanEventTypeFactory, EventTypeRepositoryImpl repo) { if (optionalConfig != null && optionalConfig.getSuperTypes().size() > 1) { throw new EventAdapterException(ConfigurationCommonEventTypeObjectArray.SINGLE_SUPERTYPE_MSG); } LinkedHashMap<String, Object> propertyTypes = EventTypeUtility.getPropertyTypesNonPrimitive(propertyTypesMayHavePrimitive); EventTypeMetadata metadata = new EventTypeMetadata(eventTypeName, null, EventTypeTypeClass.APPLICATION, EventTypeApplicationType.OBJECTARR, NameAccessModifier.PRECONFIGURED, EventTypeBusModifier.BUS, false, new EventTypeIdPair(CRC32Util.computeCRC32(eventTypeName), -1)); String[] superTypes = null; if (optionalConfig != null && optionalConfig.getSuperTypes() != null && !optionalConfig.getSuperTypes().isEmpty()) { superTypes = optionalConfig.getSuperTypes().toArray(new String[optionalConfig.getSuperTypes().size()]); } ObjectArrayEventType newEventType = beanEventTypeFactory.getEventTypeFactory().createObjectArray(metadata, propertyTypes, superTypes, optionalConfig != null ? optionalConfig.getStartTimestampPropertyName() : null, optionalConfig != null ? optionalConfig.getEndTimestampPropertyName() : null, beanEventTypeFactory, repo); EventType existingType = repo.getTypeByName(eventTypeName); if (existingType != null) { // The existing type must be the same as the type createdStatement if (newEventType.equalsCompareType(existingType) != null) { ExprValidationException message = newEventType.compareEquals(existingType); throw new EPException("Event type named '" + eventTypeName + "' has already been declared with differing column name or type information: " + message.getMessage(), message); } // Since it's the same, return the existing type return; } repo.addType(newEventType); }
private static void addNestableMapType(String eventTypeName, LinkedHashMap<String, Object> propertyTypesMayHavePrimitive, ConfigurationCommonEventTypeMap optionalConfig, EventTypeRepositoryImpl repo, BeanEventTypeFactory beanEventTypeFactory, EventTypeNameResolver eventTypeNameResolver) throws EventAdapterException { EventTypeMetadata metadata = new EventTypeMetadata(eventTypeName, null, EventTypeTypeClass.APPLICATION, EventTypeApplicationType.MAP, NameAccessModifier.PRECONFIGURED, EventTypeBusModifier.BUS, false, new EventTypeIdPair(CRC32Util.computeCRC32(eventTypeName), -1)); LinkedHashMap<String, Object> propertyTypes = EventTypeUtility.getPropertyTypesNonPrimitive(propertyTypesMayHavePrimitive); String[] superTypes = null; if (optionalConfig != null && optionalConfig.getSuperTypes() != null && !optionalConfig.getSuperTypes().isEmpty()) { superTypes = optionalConfig.getSuperTypes().toArray(new String[optionalConfig.getSuperTypes().size()]); } MapEventType newEventType = beanEventTypeFactory.getEventTypeFactory().createMap(metadata, propertyTypes, superTypes, optionalConfig != null ? optionalConfig.getStartTimestampPropertyName() : null, optionalConfig != null ? optionalConfig.getEndTimestampPropertyName() : null, beanEventTypeFactory, eventTypeNameResolver); EventType existingType = repo.getTypeByName(eventTypeName); if (existingType != null) { // The existing type must be the same as the type createdStatement if (newEventType.equalsCompareType(existingType) != null) { ExprValidationException message = newEventType.compareEquals(existingType); throw new EPException("Event type named '" + eventTypeName + "' has already been declared with differing column name or type information: " + message.getMessage(), message); } return; } repo.addType(newEventType); }
if (eventTypeMetadata.getBusModifier() == EventTypeBusModifier.BUS) { eventTypeSPI.setMetadataId(nameTypeId, -1); services.getEventTypeRepositoryBus().addType(eventTypeSPI); } else { eventTypeSPI.setMetadataId(deploymentIdCrc32, nameTypeId);
private static void addXMLDOMType(EventTypeRepositoryImpl repo, String eventTypeName, ConfigurationCommonEventTypeXMLDOM detail, SchemaModel schemaModel, BeanEventTypeFactory beanEventTypeFactory, XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory) { if (detail.getRootElementName() == null) { throw new EventAdapterException("Required root element name has not been supplied"); } EventType existingType = repo.getTypeByName(eventTypeName); if (existingType != null) { String message = "Event type named '" + eventTypeName + "' has already been declared with differing column name or type information"; throw new ConfigurationException(message); } boolean propertyAgnostic = detail.getSchemaResource() == null && detail.getSchemaText() == null; EventTypeMetadata metadata = new EventTypeMetadata(eventTypeName, null, EventTypeTypeClass.STREAM, EventTypeApplicationType.XML, NameAccessModifier.PRECONFIGURED, EventTypeBusModifier.BUS, propertyAgnostic, new EventTypeIdPair(CRC32Util.computeCRC32(eventTypeName), -1)); EventType type = beanEventTypeFactory.getEventTypeFactory().createXMLType(metadata, detail, schemaModel, null, metadata.getName(), beanEventTypeFactory, xmlFragmentEventTypeFactory, repo); repo.addType(type); if (type instanceof SchemaXMLEventType) { xmlFragmentEventTypeFactory.addRootType((SchemaXMLEventType) type); } } }