Search in sources :

Example 36 with Collection

use of org.wso2.carbon.registry.api.Collection in project siddhi by wso2.

the class AndMultiPrimaryKeyCollectionExecutor method find.

public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
    ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
    Collection<StreamEvent> storeEventSet = findEvents(matchingEvent, indexedEventHolder);
    if (storeEventSet == null) {
        return returnEventChunk.getFirst();
    } else {
        for (StreamEvent storeEvent : storeEventSet) {
            if (storeEventCloner != null) {
                returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
            } else {
                returnEventChunk.add(storeEvent);
            }
        }
        return returnEventChunk.getFirst();
    }
}
Also used : ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Example 37 with Collection

use of org.wso2.carbon.registry.api.Collection in project siddhi by wso2.

the class CompareCollectionExecutor method find.

public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
    ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
    Collection<StreamEvent> storeEventSet = findEvents(matchingEvent, indexedEventHolder);
    if (storeEventSet == null) {
        // triggering sequential scan
        Collection<StreamEvent> storeEvents = indexedEventHolder.getAllEvents();
        for (StreamEvent storeEvent : storeEvents) {
            matchingEvent.setEvent(storeEventIndex, storeEvent);
            if ((Boolean) expressionExecutor.execute(matchingEvent)) {
                if (storeEventCloner != null) {
                    returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
                } else {
                    returnEventChunk.add(storeEvent);
                }
            }
            matchingEvent.setEvent(storeEventIndex, null);
        }
        return returnEventChunk.getFirst();
    } else {
        for (StreamEvent storeEvent : storeEventSet) {
            if (storeEventCloner != null) {
                returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
            } else {
                returnEventChunk.add(storeEvent);
            }
        }
        return returnEventChunk.getFirst();
    }
}
Also used : ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Example 38 with Collection

use of org.wso2.carbon.registry.api.Collection in project siddhi by wso2.

the class NonCollectionExecutor method find.

public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
    if ((Boolean) expressionExecutor.execute(matchingEvent)) {
        ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
        Collection<StreamEvent> storeEvents = indexedEventHolder.getAllEvents();
        for (StreamEvent storeEvent : storeEvents) {
            if (storeEventCloner != null) {
                returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
            } else {
                returnEventChunk.add(storeEvent);
            }
        }
        return returnEventChunk.getFirst();
    } else {
        return null;
    }
}
Also used : ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Example 39 with Collection

use of org.wso2.carbon.registry.api.Collection in project siddhi by wso2.

the class NotCollectionExecutor method delete.

@Override
public void delete(StateEvent deletingEvent, IndexedEventHolder indexedEventHolder) {
    Collection<StreamEvent> notStreamEvents = notCollectionExecutor.findEvents(deletingEvent, indexedEventHolder);
    if (notStreamEvents == null) {
        exhaustiveCollectionExecutor.delete(deletingEvent, indexedEventHolder);
    } else if (notStreamEvents.size() == 0) {
        indexedEventHolder.deleteAll();
    } else if (notStreamEvents.size() != indexedEventHolder.getAllEvents().size()) {
        Collection<StreamEvent> allEvents = indexedEventHolder.getAllEvents();
        Set<StreamEvent> returnSet = new HashSet<StreamEvent>();
        for (StreamEvent aEvent : allEvents) {
            if (!notStreamEvents.contains(aEvent)) {
                returnSet.add(aEvent);
            }
        }
        indexedEventHolder.deleteAll(returnSet);
    }
}
Also used : StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent) HashSet(java.util.HashSet)

Example 40 with Collection

use of org.wso2.carbon.registry.api.Collection in project wso2-synapse by wso2.

the class EventSourceSerializer method serializeEventSource.

public static OMElement serializeEventSource(OMElement elem, SynapseEventSource eventSource) {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace nullNS = fac.createOMNamespace(XMLConfigConstants.NULL_NAMESPACE, "");
    OMElement evenSourceElem = fac.createOMElement("eventSource", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
    if (eventSource.getName() != null) {
        evenSourceElem.addAttribute(fac.createOMAttribute("name", nullNS, eventSource.getName()));
    }
    if (eventSource.getSubscriptionManager() != null) {
        OMElement subManagerElem = fac.createOMElement("subscriptionManager", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
        subManagerElem.addAttribute(fac.createOMAttribute("class", nullNS, eventSource.getSubscriptionManager().getClass().getName()));
        Collection<String> names = (Collection<String>) eventSource.getSubscriptionManager().getPropertyNames();
        for (String name : names) {
            String value;
            if (eventSource.isContainsConfigurationProperty(name)) {
                value = eventSource.getConfigurationProperty(name);
            } else {
                value = eventSource.getSubscriptionManager().getPropertyValue(name);
            }
            OMElement propElem = fac.createOMElement("property", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
            propElem.addAttribute(fac.createOMAttribute("name", nullNS, name));
            propElem.addAttribute(fac.createOMAttribute("value", nullNS, value));
            subManagerElem.addChild(propElem);
        }
        evenSourceElem.addChild(subManagerElem);
        // Adding static subscriptions
        List<Subscription> staticSubscriptionList = eventSource.getSubscriptionManager().getStaticSubscriptions();
        for (Iterator<Subscription> iterator = staticSubscriptionList.iterator(); iterator.hasNext(); ) {
            Subscription staticSubscription = iterator.next();
            OMElement staticSubElem = fac.createOMElement("subscription", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
            staticSubElem.addAttribute(fac.createOMAttribute("id", nullNS, staticSubscription.getId()));
            OMElement filterElem = fac.createOMElement("filter", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
            filterElem.addAttribute(fac.createOMAttribute("source", nullNS, (String) staticSubscription.getFilterValue()));
            filterElem.addAttribute(fac.createOMAttribute("dialect", nullNS, (String) staticSubscription.getFilterDialect()));
            staticSubElem.addChild(filterElem);
            OMElement endpointElem = fac.createOMElement("endpoint", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
            OMElement addressElem = fac.createOMElement("address", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
            addressElem.addAttribute(fac.createOMAttribute("uri", nullNS, staticSubscription.getEndpointUrl()));
            endpointElem.addChild(addressElem);
            staticSubElem.addChild(endpointElem);
            if (staticSubscription.getExpires() != null) {
                OMElement expiresElem = fac.createOMElement("expires", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                fac.createOMText(expiresElem, ConverterUtil.convertToString(staticSubscription.getExpires()));
                staticSubElem.addChild(expiresElem);
            }
            evenSourceElem.addChild(staticSubElem);
        }
    }
    if (elem != null) {
        elem.addChild(evenSourceElem);
    }
    return evenSourceElem;
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace) Collection(java.util.Collection) OMElement(org.apache.axiom.om.OMElement) Subscription(org.wso2.eventing.Subscription)

Aggregations

StreamEvent (org.wso2.siddhi.core.event.stream.StreamEvent)13 Collection (java.util.Collection)9 ArrayList (java.util.ArrayList)8 ComplexEventChunk (org.wso2.siddhi.core.event.ComplexEventChunk)8 IOException (java.io.IOException)7 Collection (org.wso2.carbon.registry.core.Collection)7 Map (java.util.Map)6 HashSet (java.util.HashSet)5 File (java.io.File)4 InstanceFilter (org.apache.ode.bpel.common.InstanceFilter)4 BpelDAOConnection (org.apache.ode.bpel.dao.BpelDAOConnection)4 ProcessInstanceDAO (org.apache.ode.bpel.dao.ProcessInstanceDAO)4 BpelDatabase (org.apache.ode.bpel.engine.BpelDatabase)4 Test (org.testng.annotations.Test)4 TenantProcessStoreImpl (org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)4 InstanceManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 HashMap (java.util.HashMap)3 Response (javax.ws.rs.core.Response)3 JAXBContext (javax.xml.bind.JAXBContext)3