@Override public EntityKey getEntityKey() { return getAssociationKey().getEntityKey(); }
@Override public EntityKey getEntityKey() { return getAssociationKey().getEntityKey(); }
protected Object[] createRelationshipForEmbeddedQueryValues(AssociationKey associationKey, EntityKey embeddedKey, Object[] relationshipProperties) { Object[] columnValues = associationKey.getEntityKey().getColumnValues(); return ArrayHelper.concat( Arrays.asList( columnValues, relationshipProperties, embeddedKey.getColumnValues() ) ); }
/** * Removes the relationship(s) representing the given association. If the association refers to an embedded entity * (collection), the referenced entities are removed as well. * * @param executionEngine the {@link GraphDatabaseService} used to run the query * @param associationKey represents the association */ public void removeAssociation(GraphDatabaseService executionEngine, AssociationKey associationKey) { executionEngine.execute( removeAssociationQuery, params( associationKey.getEntityKey().getColumnValues() ) ); }
/** * Removes the relationship(s) representing the given association. If the association refers to an embedded entity * (collection), the referenced entities are removed as well. * * @param executionEngine the {@link GraphDatabaseService} used to run the query * @param associationKey represents the association */ @Override public void removeAssociation(GraphDatabaseService executionEngine, AssociationKey associationKey) { executionEngine.execute( removeAssociationQuery, params( associationKey.getEntityKey().getColumnValues() ) ); }
private static TuplePointer getEmbeddingEntityTuplePointer(InfinispanRemoteDatastoreProvider provider, AssociationKey key, AssociationContext associationContext) { TuplePointer tuplePointer = associationContext.getEntityTuplePointer(); if ( tuplePointer.getTuple() == null ) { tuplePointer.setTuple( getTuple( provider, key.getEntityKey() ) ); } return tuplePointer; }
public Relationship findRelationship(HttpNeo4jClient dataBase, Long txId, AssociationKey associationKey, RowKey rowKey) { Object[] relationshipValues = relationshipValues( associationKey, rowKey ); Object[] queryValues = ArrayHelper.concat( associationKey.getEntityKey().getColumnValues(), relationshipValues ); Graph result = executeQuery( dataBase, txId, findRelationshipQuery, params( queryValues ) ); if ( result != null ) { if ( result.getRelationships().size() > 0 ) { return result.getRelationships().get( 0 ); } } return null; }
private TuplePointer getEmbeddingEntityTuplePointer(AssociationKey key, AssociationContext associationContext) { TuplePointer tuplePointer = associationContext.getEntityTuplePointer(); if ( tuplePointer.getTuple() == null ) { tuplePointer.setTuple( getTuple( key.getEntityKey(), associationContext ) ); } return tuplePointer; }
public void removeAssociationRow(HttpNeo4jClient database, Long txId, AssociationKey associationKey, RowKey rowKey) { Object[] relationshipValues = relationshipValues( associationKey, rowKey ); Object[] queryValues = ArrayHelper.concat( associationKey.getEntityKey().getColumnValues(), relationshipValues ); executeQuery( database, txId, removeAssociationRowQuery, params( queryValues ) ); }
/** * Remove an association row * * @param executionEngine the {@link GraphDatabaseService} used to run the query * @param associationKey represents the association * @param rowKey represents a row in an association */ public void removeAssociationRow(GraphDatabaseService executionEngine, AssociationKey associationKey, RowKey rowKey) { Object[] relationshipValues = relationshipValues( associationKey, rowKey ); Object[] queryValues = ArrayHelper.concat( associationKey.getEntityKey().getColumnValues(), relationshipValues ); executionEngine.execute( removeAssociationRowQuery, params( queryValues ) ); }
public void removeAssociationRow(Transaction tx, AssociationKey associationKey, RowKey rowKey) { Object[] relationshipValues = relationshipValues( associationKey, rowKey ); Object[] queryValues = ArrayHelper.concat( associationKey.getEntityKey().getColumnValues(), relationshipValues ); tx.run( removeAssociationRowQuery, params( queryValues ) ); } }
public Relationship findRelationship(Transaction tx, AssociationKey associationKey, RowKey rowKey) { Object[] relationshipValues = relationshipValues( associationKey, rowKey ); Object[] queryValues = ArrayHelper.concat( associationKey.getEntityKey().getColumnValues(), relationshipValues ); StatementResult result = tx.run( findRelationshipQuery, params( queryValues ) ); return relationship( result ); }
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; }
@Override public Association getAssociation(AssociationKey associationKey, AssociationContext associationContext) { EntityKey entityKey = associationKey.getEntityKey(); Node entityNode = getEntityQueries( entityKey.getMetadata(), associationContext ).findEntity( dataBase, entityKey.getColumnValues() ); GraphLogger.log( "Found owner node: %1$s", entityNode ); if ( entityNode == null ) { return null; } Map<RowKey, Tuple> tuples = createAssociationMap( associationKey, associationContext, entityKey ); return new Association( new EmbeddedNeo4jAssociationSnapshot( tuples ) ); }
@Override public Association getAssociation(AssociationKey associationKey, AssociationContext associationContext) { EntityKey entityKey = associationKey.getEntityKey(); Transaction tx = transaction( associationContext ); NodeWithEmbeddedNodes node = getEntityQueries( entityKey.getMetadata(), associationContext ).findEntity( tx, entityKey.getColumnValues() ); if ( node == null ) { return null; } Map<RowKey, Tuple> tuples = createAssociationMap( associationKey, associationContext, entityKey ); return new Association( new RemoteNeo4jAssociationSnapshot( tuples ) ); }
protected Object[] createRelationshipForEmbeddedQueryValues(AssociationKey associationKey, EntityKey embeddedKey) { String collectionRole = associationKey.getMetadata().getCollectionRole(); Object[] columnValues = associationKey.getEntityKey().getColumnValues(); if ( isCollectionOfPrimitives( collectionRole, embeddedKey.getColumnNames() ) ) { return ArrayHelper.concat( columnValues, embeddedKey.getColumnValues()[0] ); } else { return ArrayHelper.concat( columnValues, embeddedKey.getColumnValues() ); } }
private Relationship findOrCreateRelationshipWithEntityNode(AssociationKey associationKey, AssociationContext associationContext, AssociationOperation action) { Tuple associationRow = action.getValue(); EntityKey ownerKey = associationKey.getEntityKey(); AssociatedEntityKeyMetadata associatedEntityKeyMetadata = associationContext.getAssociationTypeContext().getAssociatedEntityKeyMetadata(); EntityKey targetKey = getEntityKey( associationRow, associatedEntityKeyMetadata ); Object[] relationshipProperties = relationshipProperties( associationKey, associationRow ); Transaction txId = transaction( associationContext ); return getAssociationQueries( associationKey.getMetadata() ) .createRelationship( txId, ownerKey.getColumnValues(), targetKey.getColumnValues(), relationshipProperties ); }
@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 ) ); }
private Relationship findOrCreateRelationshipWithEntityNode(AssociationKey associationKey, AssociationContext associationContext, AssociationOperation action) { Tuple associationRow = action.getValue(); EntityKey ownerKey = associationKey.getEntityKey(); AssociatedEntityKeyMetadata associatedEntityKeyMetadata = associationContext.getAssociationTypeContext().getAssociatedEntityKeyMetadata(); EntityKey targetKey = getEntityKey( associationRow, associatedEntityKeyMetadata ); Object[] relationshipProperties = relationshipProperties( associationKey, associationRow ); Long txId = transactionId( associationContext.getTransactionContext() ); return getAssociationQueries( associationKey.getMetadata() ) .createRelationship( client, txId, ownerKey.getColumnValues(), targetKey.getColumnValues(), relationshipProperties ); }
private void addNavigationalInformationForInverseSide(int propertyIndex, AssociationKeyMetadata associationKeyMetadata, Object[] newColumnValue) { RowKey rowKey = getInverseRowKey( associationKeyMetadata, newColumnValue ); Tuple associationRow = new Tuple(); for ( String column : rowKey.getColumnNames() ) { associationRow.put( column, rowKey.getColumnValue( column ) ); } AssociationPersister associationPersister = createInverseAssociationPersister( propertyIndex, associationKeyMetadata, newColumnValue ); associationPersister.getAssociation().put( rowKey, associationRow ); if ( associationPersister.getAssociationContext().getEntityTuplePointer().getTuple() == null ) { throw log.entityTupleNotFound( associationKeyMetadata.getCollectionRole(), associationPersister.getAssociationKey().getEntityKey() ); } associationPersister.flushToDatastore(); }