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);
}
}
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();
}
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();
}
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();
}
Aggregations