Search in sources :

Example 6 with Collection

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

the class ExhaustiveCollectionExecutor method findEvents.

public Collection<StreamEvent> findEvents(StateEvent matchingEvent, Collection<StreamEvent> preProcessedstoreEvents) {
    HashSet<StreamEvent> streamEvents = new HashSet<StreamEvent>();
    for (StreamEvent storeEvent : preProcessedstoreEvents) {
        matchingEvent.setEvent(storeEventIndex, storeEvent);
        if ((Boolean) expressionExecutor.execute(matchingEvent)) {
            streamEvents.add(storeEvent);
        }
        matchingEvent.setEvent(storeEventIndex, null);
    }
    return streamEvents;
}
Also used : StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent) HashSet(java.util.HashSet)

Example 7 with Collection

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

the class ExhaustiveCollectionExecutor method delete.

@Override
public void delete(StateEvent deletingEvent, IndexedEventHolder indexedEventHolder) {
    Collection<StreamEvent> storeEvents = indexedEventHolder.getAllEvents();
    Set<StreamEvent> toDeleteEvents = new HashSet<StreamEvent>();
    for (StreamEvent storeEvent : storeEvents) {
        deletingEvent.setEvent(storeEventIndex, storeEvent);
        if ((Boolean) expressionExecutor.execute(deletingEvent)) {
            toDeleteEvents.add(storeEvent);
        }
        deletingEvent.setEvent(storeEventIndex, null);
    }
    indexedEventHolder.deleteAll(toDeleteEvents);
}
Also used : StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent) HashSet(java.util.HashSet)

Example 8 with Collection

use of org.wso2.carbon.registry.core.Collection in project carbon-apimgt by wso2.

the class DynamicHtmlGenTestCase method testToApiName.

@Test
public void testToApiName() throws Exception {
    DynamicHtmlGen htmlGen = new DynamicHtmlGen();
    final String originalTag = "API (Collection)";
    String sanitised = htmlGen.sanitizeTag(originalTag);
    Assert.assertEquals(sanitised, "APICollection");
    String retrievedTag = htmlGen.toApiName(sanitised);
    Assert.assertEquals(retrievedTag, originalTag);
    sanitised = htmlGen.toApiFilename(originalTag);
    Assert.assertEquals(sanitised, "APICollection");
}
Also used : DynamicHtmlGen(org.wso2.carbon.apimgt.rest.api.common.codegen.DynamicHtmlGen) Test(org.testng.annotations.Test)

Example 9 with Collection

use of org.wso2.carbon.registry.core.Collection in project wso2-dss-connectors by wso2-attic.

the class MongoDBDataSource method decodeQuery.

private Object[] decodeQuery(String query) throws DataServiceFault {
    int i1 = query.indexOf('.');
    if (i1 == -1) {
        throw new DataServiceFault("The MongoDB Collection not specified in the query '" + query + "'");
    }
    String collection = query.substring(0, i1).trim();
    int i2 = query.indexOf('(', i1);
    if (i2 == -1 || i2 - i1 <= 1) {
        throw new DataServiceFault("Invalid MongoDB operation in the query '" + query + "'");
    }
    String operation = query.substring(i1 + 1, i2).trim();
    int i3 = query.lastIndexOf(')');
    if (i3 == -1) {
        throw new DataServiceFault("Invalid MongoDB operation in the query '" + query + "'");
    }
    String opQuery = null;
    if (i3 - i2 > 1) {
        opQuery = query.substring(i2 + 1, i3).trim();
    }
    MongoOperation mongoOp = this.convertToMongoOp(operation);
    if (mongoOp == MongoOperation.UPDATE) {
        List<Object> result = new ArrayList<Object>();
        result.add(collection);
        result.add(mongoOp);
        result.addAll(parseInsertQuery(opQuery));
        return result.toArray();
    } else {
        return new Object[] { collection, mongoOp, this.checkAndCleanOpQuery(opQuery) };
    }
}
Also used : MongoOperation(org.wso2.dss.connectors.mongodb.MongoDBDSConstants.MongoOperation) DataServiceFault(org.wso2.carbon.dataservices.core.DataServiceFault) ArrayList(java.util.ArrayList) DBObject(com.mongodb.DBObject)

Example 10 with Collection

use of org.wso2.carbon.registry.core.Collection in project carbon-business-process by wso2.

the class InstanceManagementServiceSkeleton method getFailedActivitiesForInstance.

/**
 * Get Failed Activities for give instance id.
 *
 * @param instanceID
 * @return
 * @throws InstanceManagementException
 */
@Override
public ActivityRecoveryInfoType[] getFailedActivitiesForInstance(final long instanceID) throws InstanceManagementException {
    try {
        isOperationIsValidForTheCurrentTenant(instanceID);
    } catch (IllegalAccessException ex) {
        handleError(ex);
    }
    ActivityRecoveryInfoType[] activityRecoveryInfoTypes = null;
    try {
        BpelDatabase bpelDb = bpelServer.getODEBPELServer().getBpelDb();
        Object result = bpelDb.exec(new BpelDatabase.Callable<Object>() {

            public Object run(BpelDAOConnection conn) throws InstanceManagementException {
                ProcessInstanceDAO instance = conn.getInstance(instanceID);
                Collection<ActivityRecoveryDAO> activityRecoveries = instance.getActivityRecoveries();
                return activityRecoveries;
            }
        });
        ArrayList<ActivityRecoveryDAO> activityRecoveryDAOs = (ArrayList<ActivityRecoveryDAO>) result;
        if (activityRecoveryDAOs != null) {
            activityRecoveryInfoTypes = new ActivityRecoveryInfoType[activityRecoveryDAOs.size()];
            for (int i = 0; i < activityRecoveryDAOs.size(); i++) {
                ActivityRecoveryDAO activityRecovery = activityRecoveryDAOs.get(i);
                ActivityRecoveryInfoType info = new ActivityRecoveryInfoType();
                info.setActions(activityRecovery.getActions());
                info.setActivityID(activityRecovery.getActivityId());
                info.setDateTime(String.valueOf(activityRecovery.getDateTime()));
                info.setInstanceID(instanceID);
                info.setReason(activityRecovery.getReason());
                info.setRetires(activityRecovery.getRetries());
                activityRecoveryInfoTypes[i] = info;
            }
        }
    } catch (Exception e) {
        String errMsg = "Error occurred while retrieving failed activity information for instance id " + instanceID;
        log.error(errMsg, e);
        throw new InstanceManagementException(errMsg, e);
    }
    return activityRecoveryInfoTypes;
}
Also used : BpelDatabase(org.apache.ode.bpel.engine.BpelDatabase) ArrayList(java.util.ArrayList) ActivityRecoveryInfoType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ActivityRecoveryInfoType) BpelDAOConnection(org.apache.ode.bpel.dao.BpelDAOConnection) ProcessNotFoundException(org.apache.ode.bpel.pmapi.ProcessNotFoundException) InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) ProcessingException(org.apache.ode.bpel.pmapi.ProcessingException) InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) ProcessInstanceDAO(org.apache.ode.bpel.dao.ProcessInstanceDAO) ActivityRecoveryDAO(org.apache.ode.bpel.dao.ActivityRecoveryDAO) Collection(java.util.Collection)

Aggregations

Collection (org.wso2.carbon.registry.core.Collection)45 Resource (org.wso2.carbon.registry.core.Resource)39 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)25 Test (org.junit.Test)24 UserRegistry (org.wso2.carbon.registry.core.session.UserRegistry)23 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)22 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)20 IOException (java.io.IOException)19 InputStream (java.io.InputStream)19 ArrayList (java.util.ArrayList)17 RegistryService (org.wso2.carbon.registry.core.service.RegistryService)17 ServiceReferenceHolder (org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder)16 FileInputStream (java.io.FileInputStream)14 OMElement (org.apache.axiom.om.OMElement)13 StreamEvent (org.wso2.siddhi.core.event.stream.StreamEvent)13 Collection (java.util.Collection)11 CollectionImpl (org.wso2.carbon.registry.core.CollectionImpl)11 ResourceImpl (org.wso2.carbon.registry.core.ResourceImpl)11 File (java.io.File)10