/** * Creates a new {@code TupleAlreadyExistsException}. * * @param entityKey An {@link EntityKey} containing the id of the affected entity */ public TupleAlreadyExistsException(EntityKey entityKey) { super( (Throwable) null ); this.entityKey = entityKey; this.entityKeyMetadata = entityKey.getMetadata(); }
/** * Creates a new {@code TupleAlreadyExistsException}. * * @param entityKeyMetadata Key metadata for the affected entity */ public TupleAlreadyExistsException(EntityKeyMetadata entityKeyMetadata) { super( (Throwable) null ); this.entityKey = null; this.entityKeyMetadata = entityKey.getMetadata(); }
/** * Creates a new {@code TupleAlreadyExistsException}. * * @param entityKey An {@link EntityKey} containing the id of the affected entity * @param message a message explaining the cause of the error */ public TupleAlreadyExistsException(EntityKey entityKey, String message) { super( message ); this.entityKey = entityKey; this.entityKeyMetadata = entityKey.getMetadata(); }
/** * Creates a new {@code TupleAlreadyExistsException}. * * @param entityKeyMetadata Key metadata for the affected entity * @param message a message explaining the cause of the error */ public TupleAlreadyExistsException(EntityKeyMetadata entityKeyMetadata, String message) { super( message ); this.entityKey = null; this.entityKeyMetadata = entityKey.getMetadata(); }
private void updateTuple(EntityKey key, List<Statement> statements, Map<String, Object> properties, TupleContext tupleContext) { if ( !properties.isEmpty() ) { Statement statement = getEntityQueries( key.getMetadata(), tupleContext ).getUpdateEntityPropertiesStatement( key.getColumnValues(), properties ); statements.add( statement ); } }
private void saveToOneAssociations(List<Statement> statements, EntityKey key, final Map<String, EntityKey> toOneAssociations, TupleContext tupleContext) { for ( Map.Entry<String, EntityKey> entry : toOneAssociations.entrySet() ) { Statement statement = getEntityQueries( key.getMetadata(), tupleContext ).getUpdateOneToOneAssociationStatement( entry.getKey(), key.getColumnValues(), entry.getValue().getColumnValues() ); statements.add( statement ); } }
@Override public void removeTuple(EntityKey key, TupleContext tupleContext) { IgniteCache<Object, BinaryObject> entityCache = provider.getEntityCache( key.getMetadata() ); entityCache.remove( provider.createKeyObject( key ) ); }
@Override public Tuple createTuple(EntityKey key, OperationContext OperationContext) { Document toSave = prepareIdObject( key ); return new Tuple( new MongoDBTupleSnapshot( toSave, key.getMetadata() ), SnapshotType.INSERT ); }
private static Tuple createTuple(EntityKey key, OperationContext operationContext, Document found) { if ( found != null ) { return new Tuple( new MongoDBTupleSnapshot( found, key.getMetadata() ), SnapshotType.UPDATE ); } else if ( isInTheInsertionQueue( key, operationContext ) ) { // The key has not been inserted in the db but it is in the queue return new Tuple( new MongoDBTupleSnapshot( prepareIdObject( key ), key.getMetadata() ), SnapshotType.INSERT ); } else { return null; } }
@Override public void removeTuple(EntityKey key, TupleContext tupleContext) { Cache<EK, Map<String, Object>> cache = getCacheManager().getEntityCache( key.getMetadata() ); EK cacheKey = getKeyProvider().getEntityCacheKey( key ); AtomicMapLookup.removeAtomicMap( cache, cacheKey ); }
private Relationship findOrCreateRelationshipWithEntityNode(AssociationKey associationKey, Tuple associationRow, AssociatedEntityKeyMetadata associatedEntityKeyMetadata, TupleTypeContext tupleTypeContext) { EntityKey targetEntityKey = getEntityKey( associationRow, associatedEntityKeyMetadata ); Node targetNode = getEntityQueries( targetEntityKey.getMetadata(), (TupleTypeContext) null ).findEntity( dataBase, targetEntityKey.getColumnValues() ); return createRelationshipWithTargetNode( associationKey, associationRow, tupleTypeContext, targetNode ); }
@Override public void removeTuple(EntityKey key, TupleContext tupleContext) { Cache<EK, Map<String, Object>> cache = getCacheManager().getEntityCache( key.getMetadata() ); EK cacheKey = getKeyProvider().getEntityCacheKey( key ); AtomicMapLookup.removeAtomicMap( cache, cacheKey ); }
@Override public Tuple getTuple(EntityKey key, OperationContext operationContext) { EK cacheKey = getKeyProvider().getEntityCacheKey( key ); Cache<EK, Map<String, Object>> cache = getCacheManager().getEntityCache( key.getMetadata() ); return getTupleFromCacheKey( cacheKey, cache ); }
@Override public Tuple getTuple(EntityKey key, OperationContext operationContext) { final Cache<EK> entityCache = getCacheManager().getEntityCache( key.getMetadata() ); final Element element = entityCache.get( getKeyProvider().getEntityCacheKey( key ) ); if ( element != null ) { return createTuple( element ); } else { return null; } }
@Override public void removeTuple(EntityKey key, TupleContext tupleContext) { Long txId = transactionId( tupleContext.getTransactionContext() ); getEntityQueries( key.getMetadata(), tupleContext.getTupleTypeContext() ).removeEntity( client, txId, key.getColumnValues() ); }
@Override public void removeTuple(EntityKey key, TupleContext tupleContext) { Document toDelete = prepareIdObject( key ); WriteConcern writeConcern = getWriteConcern( tupleContext ); MongoCollection<Document> collection = getCollection( key ).withWriteConcern( writeConcern ); Document deleted = collection.findOneAndDelete( toDelete ); if ( deleted != null ) { provider.getBinaryStorageManager().removeEntityFromBinaryStorage( deleted, key.getMetadata() ); } }
@Override public Tuple createTuple(EntityKey key, OperationContext operationContext) { //TODO we don't verify that it does not yet exist assuming that this has been done before by the calling code //should we improve? Cache<EK, Map<String, Object>> cache = getCacheManager().getEntityCache( key.getMetadata() ); EK cacheKey = getKeyProvider().getEntityCacheKey( key ); FineGrainedAtomicMap<String,Object> atomicMap = AtomicMapLookup.getFineGrainedAtomicMap( cache, cacheKey, true ); return new Tuple( new InfinispanTupleSnapshot( atomicMap ), SnapshotType.INSERT ); }
private Relationship createRelationshipWithTargetNode(AssociationKey associationKey, Tuple associationRow, TupleTypeContext tupleTypeContext, Node targetNode) { EntityKey entityKey = associationKey.getEntityKey(); Node ownerNode = getEntityQueries( entityKey.getMetadata(), tupleTypeContext ).findEntity( dataBase, entityKey.getColumnValues() ); Relationship relationship = ownerNode.createRelationshipTo( targetNode, withName( associationKey.getMetadata().getCollectionRole() ) ); applyProperties( associationKey, associationRow, relationship ); return relationship; }
private Document getObject(EntityKey key, OperationContext operationContext) { MongoCollection<Document> collection = getCollection( key, operationContext.getTupleTypeContext().getOptionsContext() ); Document searchObject = prepareIdObject( key ); Document projection = getProjection( operationContext ); FindIterable<Document> fi = collection.find( searchObject ); Document targetDocument = fi != null ? fi.projection( projection ).first() : null; provider.getBinaryStorageManager().loadContentFromBinaryStorage( targetDocument, key.getMetadata() ); return targetDocument; }
@Override public Association getAssociation(AssociationKey associationKey, AssociationContext associationContext) { EntityKey entityKey = associationKey.getEntityKey(); Long transactionId = transactionId( associationContext.getTransactionContext() ); NodeWithEmbeddedNodes node = getEntityQueries( entityKey.getMetadata(), associationContext.getTupleTypeContext() ).findEntity( client, transactionId, entityKey.getColumnValues() ); if ( node == null ) { return null; } Map<RowKey, Tuple> tuples = createAssociationMap( associationKey, associationContext, entityKey, associationContext.getTransactionContext() ); return new Association( new RemoteNeo4jAssociationSnapshot( tuples ) ); }