Package com.espertech.esper.client

Examples of com.espertech.esper.client.EventPropertyGetter


        try {
            DatabaseConnectionFactory connectionFactory = databaseConfigSvc.getConnectionFactory(dmlQuery.getConnection());

            Map<Integer, BindingEntry> bindings = new HashMap<Integer, BindingEntry>();
            for (BindingParameter params : dmlQuery.getBindings()) {
                EventPropertyGetter valueGetter = eventType.getGetter(params.getPropertyName());
                bindings.put(params.getPosition(), new BindingEntry(valueGetter));
            }

            StoreExceptionHandler handler = new StoreExceptionHandler() {
                public void handle(String message, SQLException ex)
View Full Code Here


* Method to getSelectListEvents events in collections to other collections or other event types.
*/
public class EventBeanUtility
{
    public static EventPropertyGetter getAssertPropertyGetter(EventType type, String propertyName) {
        EventPropertyGetter getter = type.getGetter(propertyName);
        if (getter == null) {
            throw new IllegalStateException("Property " + propertyName + " not found in type " + type.getName());
        }
        return getter;
    }
View Full Code Here

            }

            // try to resolve as property if the last method returned a type
            if (currentInputType.getSingleEventEventType() != null) {
                Class type = currentInputType.getSingleEventEventType().getPropertyType(chainElement.getName());
                EventPropertyGetter getter = currentInputType.getSingleEventEventType().getGetter(chainElement.getName());
                if (type != null && getter != null) {
                    ExprDotEvalProperty noduck = new ExprDotEvalProperty(getter, ExpressionReturnType.singleValue(JavaClassHelper.getBoxedType(type)));
                    methodEvals.add(noduck);
                    currentInputType = ExpressionReturnType.singleValue(noduck.getTypeInfo().getSingleValueType());
                    continue;
View Full Code Here

                }
            }
            throw new IllegalArgumentException("Invalid input type '" + inputType + "'");
        }

        EventPropertyGetter getter = inputEventType.getGetter(inputEventType.getStartTimestampPropertyName());
        Class getterResultType = inputEventType.getPropertyType(inputEventType.getStartTimestampPropertyName());

        if (reformatOp != null) {
            DTLocalEvaluator inner = getEvaluator(calendarOps, getterResultType, null, reformatOp, null);
            return new DTLocalEvaluatorBeanReformat(getter, inner);
        }
        if (intervalOp == null) {   // only calendar ops
            DTLocalEvaluator inner = getEvaluator(calendarOps, getterResultType, null, null, null);
            return new DTLocalEvaluatorBeanCalOps(getter, inner);
        }

        // have interval ops but no end timestamp
        if (inputEventType.getEndTimestampPropertyName() == null) {
            DTLocalEvaluator inner = getEvaluator(calendarOps, getterResultType, null, null, intervalOp);
            return new DTLocalEvaluatorBeanIntervalNoEndTS(getter, inner);
        }

        // interval ops and have end timestamp
        EventPropertyGetter getterEndTimestamp = inputEventType.getGetter(inputEventType.getEndTimestampPropertyName());
        DTLocalEvaluatorIntervalComp inner = (DTLocalEvaluatorIntervalComp) getEvaluator(calendarOps, getterResultType, null, null, intervalOp);
        return new DTLocalEvaluatorBeanIntervalWithEnd(getter, getterEndTimestamp, inner);
    }
View Full Code Here

            // when selecting a single property in the select clause that provides a fragment
            if (parent.subselectMultirowType == null) {
                Collection<EventBean> events = new ArrayDeque<EventBean>(matchingEvents.size());
                ExprIdentNodeEvaluator eval = (ExprIdentNodeEvaluator) parent.selectClauseEvaluator[0];
                EventPropertyGetter getter = eval.getGetter();
                for (EventBean subselectEvent : matchingEvents) {
                    Object fragment = getter.getFragment(subselectEvent);
                    if (fragment == null) {
                        continue;
                    }
                    events.add((EventBean) fragment);
                }
View Full Code Here

            }

            // try to resolve as property if the last method returned a type
            if (currentInputType.getSingleEventEventType() != null) {
                Class type = currentInputType.getSingleEventEventType().getPropertyType(chainElement.getName());
                EventPropertyGetter getter = currentInputType.getSingleEventEventType().getGetter(chainElement.getName());
                if (type != null && getter != null) {
                    ExprDotEvalProperty noduck = new ExprDotEvalProperty(getter, ExpressionReturnType.singleValue(JavaClassHelper.getBoxedType(type)));
                    methodEvals.add(noduck);
                    currentInputType = ExpressionReturnType.singleValue(noduck.getTypeInfo().getSingleValueType());
                    continue;
View Full Code Here

            FragmentEventType fragmentEventType = currentEventType.getFragmentType(propertyName);
            if (fragmentEventType == null)
            {
                throw new ExprValidationException("Property expression '" + propertyName + "' against type '" + currentEventType.getName() + "' does not return a fragmentable property value");
            }
            EventPropertyGetter getter = currentEventType.getGetter(propertyName);
            if (getter == null)
            {
                throw new ExprValidationException("Property expression '" + propertyName + "' against type '" + currentEventType.getName() + "' does not return a fragmentable property value");
            }
View Full Code Here

        Map<String, RevisionPropertyTypeDesc> propertyDesc = new HashMap<String, RevisionPropertyTypeDesc>();
        int count = 0;

        for (String property : spec.getChangesetPropertyNames())
        {
            EventPropertyGetter fullGetter = spec.getBaseEventType().getGetter(property);
            int propertyNumber = count;
            int[] propGroupsProperty = propsPerGroup.get(property);
            final RevisionGetterParameters params = new RevisionGetterParameters(property, propertyNumber, fullGetter, propGroupsProperty);

            // if there are no groups (full event property only), then simply use the full event getter
            EventPropertyGetter revisionGetter = new EventPropertyGetter() {
                    public Object get(EventBean eventBean) throws PropertyAccessException
                    {
                        RevisionEventBeanDeclared riv = (RevisionEventBeanDeclared) eventBean;
                        return riv.getVersionedValue(params);
                    }

                    public boolean isExistsProperty(EventBean eventBean)
                    {
                        return true;
                    }

                    public Object getFragment(EventBean eventBean)
                    {
                        return null; // fragments no provided by revision events
                    }
                };

            Class type = spec.getBaseEventType().getPropertyType(property);
            RevisionPropertyTypeDesc propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, params, type);
            propertyDesc.put(property, propertyTypeDesc);
            count++;
        }

        for (String property : spec.getBaseEventOnlyPropertyNames())
        {
            final EventPropertyGetter fullGetter = spec.getBaseEventType().getGetter(property);

            // if there are no groups (full event property only), then simply use the full event getter
            EventPropertyGetter revisionGetter =  new EventPropertyGetter() {
                public Object get(EventBean eventBean) throws PropertyAccessException
                {
                    RevisionEventBeanDeclared riv = (RevisionEventBeanDeclared) eventBean;
                    return fullGetter.get(riv.getLastBaseEvent());
                }

                public boolean isExistsProperty(EventBean eventBean)
                {
                    return true;
                }

                public Object getFragment(EventBean eventBean)
                {
                    return null; // fragments no provided by revision events
                }
            };

            Class type = spec.getBaseEventType().getPropertyType(property);
            RevisionPropertyTypeDesc propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, null, type);
            propertyDesc.put(property, propertyTypeDesc);
            count++;
        }

        count = 0;
        for (String property : spec.getKeyPropertyNames())
        {
            final int keyPropertyNumber = count;

            EventPropertyGetter revisionGetter = new EventPropertyGetter() {
                public Object get(EventBean eventBean) throws PropertyAccessException
                {
                    RevisionEventBeanDeclared riv = (RevisionEventBeanDeclared) eventBean;
                    return riv.getKey().getKeys()[keyPropertyNumber];
                }
View Full Code Here

        {
            String propertyName = desc.getPropertyName();

            if ((!desc.isIndexed()) && (!desc.isMapped()) && (!desc.isFragment()))
            {
                EventPropertyGetter getter = eventType.getGetter(propertyName);
                if (getter == null)
                {
                    log.warn("No getter returned for event type '" + eventType.getName() + "' and property '" + propertyName + "'");
                    continue;
                }
                gettersSimple.add(new GetterPair(getter, propertyName, OutputValueRendererFactory.getOutputValueRenderer(desc.getPropertyType(), options)));
            }

            if (desc.isIndexed() && !desc.isRequiresIndex() && (!desc.isFragment()))
            {
                EventPropertyGetter getter = eventType.getGetter(propertyName);
                if (getter == null)
                {
                    log.warn("No getter returned for event type '" + eventType.getName() + "' and property '" + propertyName + "'");
                    continue;
                }
                gettersIndexed.add(new GetterPair(getter, propertyName, OutputValueRendererFactory.getOutputValueRenderer(desc.getPropertyType(), options)));
            }

            if (desc.isMapped() && !desc.isRequiresMapkey() && (!desc.isFragment()))
            {
                EventPropertyGetter getter = eventType.getGetter(propertyName);
                if (getter == null)
                {
                    log.warn("No getter returned for event type '" + eventType.getName() + "' and property '" + propertyName + "'");
                    continue;
                }
                gettersMapped.add(new GetterPair(getter, propertyName, OutputValueRendererFactory.getOutputValueRenderer(desc.getPropertyType(), options)));
            }

            if (desc.isFragment())
            {
                EventPropertyGetter getter = eventType.getGetter(propertyName);
                FragmentEventType fragmentType = eventType.getFragmentType(propertyName);
                if (getter == null)
                {
                    log.warn("No getter returned for event type '" + eventType.getName() + "' and property '" + propertyName + "'");
                    continue;
View Full Code Here

                ((targetFragment == null) || (targetFragment != null && targetFragment.isNative())) )
            {
                ExprEvaluator evaluatorFragment;

                // A match was found, we replace the expression
                final EventPropertyGetter getter = eventTypeStream.getGetter(propertyName);
                final Class returnType = eventTypeStream.getPropertyType(propertyName);
                evaluatorFragment = new ExprEvaluator() {
                    public Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext)
                    {
                        EventBean streamEvent = eventsPerStream[streamNum];
                        if (streamEvent == null)
                        {
                            return null;
                        }
                        return getter.get(streamEvent);
                    }
                    public Class getType()
                    {
                        return returnType;
                    }
                    @Override
                    public Map<String, Object> getEventType() {
                        return null;
                    }
                };
                exprEvaluators[i] = evaluatorFragment;
            }
            else
            {
                ExprEvaluator evaluatorFragment;
                final EventPropertyGetter getter =  eventTypeStream.getGetter(propertyName);
                final Class returnType = eventTypeStream.getFragmentType(propertyName).getFragmentType().getUnderlyingType();

                // A match was found, we replace the expression
                evaluatorFragment = new ExprEvaluator() {

                    public Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext)
                    {
                        EventBean streamEvent = eventsPerStream[streamNum];
                        if (streamEvent == null)
                        {
                            return null;
                        }
                        return getter.getFragment(streamEvent);
                    }

                    public Class getType()
                    {
                        return returnType;
                    }

                    public Map<String, Object> getEventType() {
                        return null;
                    }
                };

                exprEvaluators[i] = evaluatorFragment;
                if (!fragmentType.isIndexed())
                {
                    expressionReturnTypes[i] = fragmentType.getFragmentType();
                }
                else
                {
                    expressionReturnTypes[i] = new EventType[] {fragmentType.getFragmentType()};
                }
            }
        }

        // Find if there is any stream expression (ExprStreamNode) :
        // This is a special case for stream selection: select a, b from A as a, B as b
        // We'd like to maintain 'A' and 'B' EventType in the Map type, and 'a' and 'b' EventBeans in the event bean
        for (int i = 0; i < selectionList.size(); i++)
        {
            if (!(exprEvaluators[i] instanceof ExprStreamUnderlyingNode))
            {
                continue;
            }

            ExprStreamUnderlyingNode undNode = (ExprStreamUnderlyingNode) exprEvaluators[i];
            final int streamNum = undNode.getStreamId();
            final Class returnType = undNode.getExprEvaluator().getType();
            EventType eventTypeStream = typeService.getEventTypes()[streamNum];

            // A match was found, we replace the expression
            ExprEvaluator evaluator = new ExprEvaluator() {

                public Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext)
                {
                    return eventsPerStream[streamNum];
                }

                public Class getType()
                {
                    return returnType;
                }

                public Map<String, Object> getEventType() {
                    return null;
                }
            };

            exprEvaluators[i] = evaluator;
            expressionReturnTypes[i] = eventTypeStream;
        }

        // Build event type that reflects all selected properties
        Map<String, Object> selPropertyTypes = new LinkedHashMap<String, Object>();
        int count = 0;
        for (ExprEvaluator expressionNode : exprEvaluators)
        {
            Object expressionReturnType = expressionReturnTypes[count];
            selPropertyTypes.put(columnNames[count], expressionReturnType);
            count++;
        }
        if (!selectedStreams.isEmpty()) {
            for (SelectClauseStreamCompiledSpec element : namedStreams)
            {
                EventType eventTypeStream = typeService.getEventTypes()[element.getStreamNumber()];
                selPropertyTypes.put(columnNames[count], eventTypeStream);
                count++;
            }
            if (isUsingWildcard && typeService.getEventTypes().length > 1)
            {
                for (int i = 0; i < typeService.getEventTypes().length; i++)
                {
                    EventType eventTypeStream = typeService.getEventTypes()[i];
                    selPropertyTypes.put(columnNames[count], eventTypeStream);
                    count++;
                }
            }
        }

        // Handle stream selection
        EventType underlyingEventType = null;
        int underlyingStreamNumber = 0;
        boolean underlyingIsFragmentEvent = false;
        EventPropertyGetter underlyingPropertyEventGetter = null;

        if (!selectedStreams.isEmpty()) {
            // Resolve underlying event type in the case of wildcard or non-named stream select.
            // Determine if the we are considering a tagged event or a stream name.
            if((isUsingWildcard) || (!unnamedStreams.isEmpty()))
View Full Code Here

TOP

Related Classes of com.espertech.esper.client.EventPropertyGetter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.