// determine whether create-named-window
boolean isCreateWindow = statementSpecCompiled.getCreateWindowDesc() != null;
if (!isCreateWindow) {
for (FilterSpecCompiled filtersSpec : filtersSpecs) {
ContextDetailPartitionItem foundPartition = null;
for (ContextDetailPartitionItem partitionItem : segmentedSpec.getItems()) {
boolean typeOrSubtype = EventTypeUtility.isTypeOrSubTypeOf(filtersSpec.getFilterForEventType(), partitionItem.getFilterSpecCompiled().getFilterForEventType());
if (typeOrSubtype) {
foundPartition = partitionItem;
}
}
if (foundPartition == null) {
continue;
}
List<FilterValueSetParam> addendumFilters = new ArrayList<FilterValueSetParam>(foundPartition.getPropertyNames().size());
if (foundPartition.getPropertyNames().size() == 1) {
String propertyName = foundPartition.getPropertyNames().get(0);
EventPropertyGetter getter = foundPartition.getFilterSpecCompiled().getFilterForEventType().getGetter(propertyName);
Class resultType = foundPartition.getFilterSpecCompiled().getFilterForEventType().getPropertyType(propertyName);
FilterSpecLookupable lookupable = new FilterSpecLookupable(propertyName, getter, resultType);
FilterValueSetParam filter = new FilterValueSetParamImpl(lookupable, FilterOperator.EQUAL, keyValue);
addendumFilters.add(filter);
}
else {
Object[] keys = ((MultiKeyUntyped) keyValue).getKeys();
for (int i = 0; i < foundPartition.getPropertyNames().size(); i++) {
String partitionPropertyName = foundPartition.getPropertyNames().get(i);
EventPropertyGetter getter = foundPartition.getFilterSpecCompiled().getFilterForEventType().getGetter(partitionPropertyName);
Class resultType = foundPartition.getFilterSpecCompiled().getFilterForEventType().getPropertyType(partitionPropertyName);
FilterSpecLookupable lookupable = new FilterSpecLookupable(partitionPropertyName, getter, resultType);
FilterValueSetParam filter = new FilterValueSetParamImpl(lookupable, FilterOperator.EQUAL, keys[i]);
addendumFilters.add(filter);
}
}
// add those predefined filter parameters, if any
addendumFilters.addAll(foundPartition.getParametersCompiled());
// add to existing if any are present
List<FilterValueSetParam> existing = addendums.get(filtersSpec);
if (existing != null) {
existing.addAll(addendumFilters);
}
else {
addendums.put(filtersSpec, addendumFilters);
}
}
}
// handle segmented context for create-window
else {
String declaredAsName = statementSpecCompiled.getCreateWindowDesc().getAsEventTypeName();
if (declaredAsName != null) {
for (FilterSpecCompiled filtersSpec : filtersSpecs) {
ContextDetailPartitionItem foundPartition = null;
for (ContextDetailPartitionItem partitionItem : segmentedSpec.getItems()) {
if (partitionItem.getFilterSpecCompiled().getFilterForEventType().getName().equals(declaredAsName)) {
foundPartition = partitionItem;
break;
}
}
if (foundPartition == null) {
continue;
}
List<FilterValueSetParam> addendumFilters = new ArrayList<FilterValueSetParam>(foundPartition.getPropertyNames().size());
for (String partitionPropertyName : foundPartition.getPropertyNames()) {
EventPropertyGetter getter = foundPartition.getFilterSpecCompiled().getFilterForEventType().getGetter(partitionPropertyName);
Class resultType = foundPartition.getFilterSpecCompiled().getFilterForEventType().getPropertyType(partitionPropertyName);
FilterSpecLookupable lookupable = new FilterSpecLookupable(partitionPropertyName, getter, resultType);
FilterValueSetParam filter = new FilterValueSetParamImpl(lookupable, FilterOperator.EQUAL, keyValue);
addendumFilters.add(filter);
}