Search in sources :

Example 1 with InvalidCollectionException

use of com.yahoo.elide.core.exceptions.InvalidCollectionException in project elide by yahoo.

the class StartState method entityRecord.

private PersistentResource<?> entityRecord(StateContext state, EntityContext entity) {
    String id = entity.id().getText();
    String entityName = entity.term().getText();
    EntityDictionary dictionary = state.getRequestScope().getDictionary();
    Type<?> entityClass = dictionary.getEntityClass(entityName, state.getRequestScope().getApiVersion());
    if (entityClass == null || !dictionary.isRoot(entityClass)) {
        throw new InvalidCollectionException(entityName);
    }
    return PersistentResource.loadRecord(state.getRequestScope().getEntityProjection(), id, state.getRequestScope());
}
Also used : InvalidCollectionException(com.yahoo.elide.core.exceptions.InvalidCollectionException) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary)

Example 2 with InvalidCollectionException

use of com.yahoo.elide.core.exceptions.InvalidCollectionException in project elide by yahoo.

the class MultiplexTransaction method getTransaction.

protected DataStoreTransaction getTransaction(Type<?> cls) {
    DataStore lookupDataStore = this.multiplexManager.getSubManager(cls);
    DataStoreTransaction transaction = transactions.get(lookupDataStore);
    if (transaction == null) {
        for (DataStore dataStore : multiplexManager.dataStores) {
            if (dataStore.equals(lookupDataStore)) {
                transaction = beginTransaction(dataStore);
                transactions.put(dataStore, transaction);
                break;
            }
        }
        if (transaction == null) {
            throw new InvalidCollectionException(cls.getName());
        }
    }
    return transaction;
}
Also used : DataStore(com.yahoo.elide.core.datastore.DataStore) DataStoreTransaction(com.yahoo.elide.core.datastore.DataStoreTransaction) InvalidCollectionException(com.yahoo.elide.core.exceptions.InvalidCollectionException)

Aggregations

InvalidCollectionException (com.yahoo.elide.core.exceptions.InvalidCollectionException)2 DataStore (com.yahoo.elide.core.datastore.DataStore)1 DataStoreTransaction (com.yahoo.elide.core.datastore.DataStoreTransaction)1 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)1