}
private Map<String, Object> constructPropertyTypes(String eventTypeName, Map<String, Object> propertyTypesGiven, EventAdapterService eventAdapterService)
{
Map<String, Object> propertyTypes = new HashMap<String, Object>();
EventType eventType = eventAdapterService.getExistsTypeByName(eventTypeName);
if(eventType == null)
{
if(propertyTypesGiven != null)
{
eventAdapterService.addNestableMapType(eventTypeName, new HashMap<String, Object>(propertyTypesGiven), null, true, true, true, false, false);
}
return propertyTypesGiven;
}
if(!eventType.getUnderlyingType().equals(Map.class))
{
beanClass = eventType.getUnderlyingType();
}
if(propertyTypesGiven != null && eventType.getPropertyNames().length != propertyTypesGiven.size())
{
// allow this scenario for beans as we may want to bring in a subset of properties
if (beanClass != null) {
return propertyTypesGiven;
}
else {
throw new EPException("Event type " + eventTypeName + " has already been declared with a different number of parameters");
}
}
for(String property : eventType.getPropertyNames())
{
Class type;
try {
type = eventType.getPropertyType(property);
}
catch (PropertyAccessException e) {
// thrown if trying to access an invalid property on an EventBean
throw new EPException(e);
}
if(propertyTypesGiven != null && propertyTypesGiven.get(property) == null)
{
throw new EPException("Event type " + eventTypeName + "has already been declared with different parameters");
}
if(propertyTypesGiven != null && !propertyTypesGiven.get(property).equals(type))
{
throw new EPException("Event type " + eventTypeName + "has already been declared with a different type for property " + property);
}
// we can't set read-only properties for bean
if(!eventType.getUnderlyingType().equals(Map.class)) {
PropertyDescriptor[] pds = ReflectUtils.getBeanProperties(beanClass);
PropertyDescriptor pd = null;
for (PropertyDescriptor p :pds) {
if (p.getName().equals(property))
pd = p;