Search in sources :

Example 1 with EntityStoreException

use of jetbrains.exodus.entitystore.EntityStoreException in project xodus by JetBrains.

the class PropertyTypes method registerCustomPropertyType.

public void registerCustomPropertyType(int typeId, @NotNull final Class<? extends Comparable> clazz, @NotNull final ComparableBinding binding) {
    typeId += ComparableValueType.PREDEFINED_COMPARABLE_VALUE_TYPES.length;
    final ComparableValueType propType = new ComparableValueType(typeId, binding, clazz);
    if (typesById.put(typeId, propType) != null) {
        throw new EntityStoreException("Already registered property type id " + typeId);
    }
    if (typesByClass.put(clazz, propType) != null) {
        throw new EntityStoreException("Already registered property type " + clazz);
    }
}
Also used : EntityStoreException(jetbrains.exodus.entitystore.EntityStoreException) ComparableValueType(jetbrains.exodus.bindings.ComparableValueType)

Example 2 with EntityStoreException

use of jetbrains.exodus.entitystore.EntityStoreException in project meghanada-server by mopemope.

the class ProjectDatabase method putObject.

@SuppressWarnings("rawtypes")
private static long putObject(Storable s, boolean allowUpdate, StoreTransaction txn) {
    String entityType = s.getEntityType();
    EntityId entityId = s.getEntityId();
    String id = s.getStoreId();
    Entity entity = null;
    if (nonNull(entityId)) {
        try {
            entity = txn.getEntity(entityId);
        } catch (EntityStoreException e) {
        // re-create
        }
    } else {
        EntityIterable it = txn.find(entityType, ID, id);
        entity = it.getFirst();
    }
    if (!allowUpdate && nonNull(entity)) {
        // find update entry
        s.onSuccess(entity);
        return entity.getId().getLocalId();
    }
    if (isNull(entity)) {
        entity = txn.newEntity(entityType);
        entity.setProperty(ID, id);
    }
    s.store(txn, entity);
    if (s instanceof Serializable) {
        try {
            setSerializeBlobData(entity, SERIALIZE_KEY, s);
        } catch (IOException e) {
            log.catching(e);
            txn.abort();
            return -1;
        }
    }
    // txn.saveEntity(entity);
    s.onSuccess(entity);
    return entity.getId().getLocalId();
}
Also used : EntityId(jetbrains.exodus.entitystore.EntityId) Entity(jetbrains.exodus.entitystore.Entity) Serializable(java.io.Serializable) EntityIterable(jetbrains.exodus.entitystore.EntityIterable) EntityStoreException(jetbrains.exodus.entitystore.EntityStoreException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 3 with EntityStoreException

use of jetbrains.exodus.entitystore.EntityStoreException in project xodus by JetBrains.

the class And method instantiateCustom.

private static Iterable<Entity> instantiateCustom(@NotNull final String entityType, @NotNull final QueryEngine queryEngine, @NotNull final ModelMetaData metaData, @NotNull final NodeBase self, @NotNull final LinksEqualDecorator decorator, @NotNull final Instantiatable directClosure) {
    final Iterable<Entity> selfInstance = self.instantiate(entityType, queryEngine, metaData);
    if (selfInstance instanceof EntityIterableBase) {
        final EntityIterable result = ((EntityIterableBase) selfInstance).findLinks(((EntityIterableBase) decorator.instantiateDecorated(decorator.getLinkEntityType(), queryEngine, metaData)).getSource(), decorator.getLinkName());
        if (traceFindLinks) {
            final Iterator<Entity> directIt = directClosure.instantiate().iterator();
            final EntityIterator it = result.iterator();
            while (true) {
                final boolean directHasNext = directIt.hasNext();
                final boolean hasNext = it.hasNext();
                if (directHasNext != hasNext) {
                    throw new EntityStoreException("Invalid custom findLinks() result: different sizes");
                }
                if (!hasNext) {
                    break;
                }
                if (!directIt.next().getId().equals(it.nextId())) {
                    throw new EntityStoreException("Invalid custom findLinks() result");
                }
            }
        }
        return result;
    }
    return directClosure.instantiate();
}
Also used : Entity(jetbrains.exodus.entitystore.Entity) EntityIterable(jetbrains.exodus.entitystore.EntityIterable) EntityIterator(jetbrains.exodus.entitystore.EntityIterator) EntityIterableBase(jetbrains.exodus.entitystore.iterate.EntityIterableBase) EntityStoreException(jetbrains.exodus.entitystore.EntityStoreException)

Example 4 with EntityStoreException

use of jetbrains.exodus.entitystore.EntityStoreException in project xodus by JetBrains.

the class And method instantiateCustom.

private static Iterable<Entity> instantiateCustom(@NotNull final String entityType, @NotNull final QueryEngine queryEngine, @NotNull final ModelMetaData metaData, @NotNull final InstantiateContext context, @NotNull final NodeBase self, @NotNull final LinksEqualDecorator decorator, @NotNull final Instantiatable directClosure) {
    final Iterable<Entity> selfInstance = self.instantiate(entityType, queryEngine, metaData, context);
    if (selfInstance instanceof EntityIterableBase) {
        final EntityIterable result = ((EntityIterableBase) selfInstance).findLinks(((EntityIterableBase) decorator.instantiateDecorated(decorator.getLinkEntityType(), queryEngine, metaData, context)).getSource(), decorator.getLinkName());
        if (traceFindLinks) {
            final Iterator<Entity> directIt = directClosure.instantiate().iterator();
            final EntityIterator it = result.iterator();
            while (true) {
                final boolean directHasNext = directIt.hasNext();
                final boolean hasNext = it.hasNext();
                if (directHasNext != hasNext) {
                    throw new EntityStoreException("Invalid custom findLinks() result: different sizes");
                }
                if (!hasNext) {
                    break;
                }
                if (!directIt.next().getId().equals(it.nextId())) {
                    throw new EntityStoreException("Invalid custom findLinks() result");
                }
            }
        }
        return result;
    }
    return directClosure.instantiate();
}
Also used : Entity(jetbrains.exodus.entitystore.Entity) EntityIterable(jetbrains.exodus.entitystore.EntityIterable) EntityIterator(jetbrains.exodus.entitystore.EntityIterator) EntityIterableBase(jetbrains.exodus.entitystore.iterate.EntityIterableBase) EntityStoreException(jetbrains.exodus.entitystore.EntityStoreException)

Aggregations

EntityStoreException (jetbrains.exodus.entitystore.EntityStoreException)4 Entity (jetbrains.exodus.entitystore.Entity)3 EntityIterable (jetbrains.exodus.entitystore.EntityIterable)3 EntityIterator (jetbrains.exodus.entitystore.EntityIterator)2 EntityIterableBase (jetbrains.exodus.entitystore.iterate.EntityIterableBase)2 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 UncheckedIOException (java.io.UncheckedIOException)1 ComparableValueType (jetbrains.exodus.bindings.ComparableValueType)1 EntityId (jetbrains.exodus.entitystore.EntityId)1