@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( getClass().getSimpleName() ); sb.append( "[" ); sb.append( getEntityKey() ); sb.append( ", collectionRole=" ); sb.append( getAssociationKey().getMetadata().getCollectionRole() ); sb.append( "]" ); return sb.toString(); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( getClass().getSimpleName() ); sb.append( "[" ); sb.append( getEntityKey() ); sb.append( ", collectionRole=" ); sb.append( getAssociationKey().getMetadata().getCollectionRole() ); sb.append( "]" ); return sb.toString(); }
@Override public void removeAssociation(AssociationKey key, AssociationContext associationContext) { // If this is the inverse side of a bi-directional association, we don't manage the relationship from this side if ( key.getMetadata().isInverse() ) { return; } getAssociationQueries( key.getMetadata() ).removeAssociation( dataBase, key ); }
private Object[] relationshipProperties(AssociationKey associationKey, AssociationOperation action) { Object[] relationshipProperties = new Object[associationKey.getMetadata().getRowKeyIndexColumnNames().length]; String[] indexColumns = associationKey.getMetadata().getRowKeyIndexColumnNames(); for ( int i = 0; i < indexColumns.length; i++ ) { relationshipProperties[i] = action.getValue().get( indexColumns[i] ); } return relationshipProperties; }
@Override public void removeAssociation(AssociationKey key, AssociationContext associationContext) { // If this is the inverse side of a bi-directional association, we don't manage the relationship from this side if ( key.getMetadata().isInverse() ) { return; } Transaction tx = transaction( associationContext ); getAssociationQueries( key.getMetadata() ).removeAssociation( tx, key ); }
private static Document getProjection(AssociationKey key, boolean embedded) { if ( embedded ) { return getProjection( Collections.singletonList( key.getMetadata().getCollectionRole() ) ); } else { return getProjection( ROWS_FIELDNAME_LIST ); } }
private static Document getProjection(AssociationKey key, boolean embedded) { if ( embedded ) { return getProjection( Collections.singletonList( key.getMetadata().getCollectionRole() ) ); } else { return getProjection( ROWS_FIELDNAME_LIST ); } }
@Override public void removeAssociation(AssociationKey key, AssociationContext associationContext) { // If this is the inverse side of a bi-directional association, we don't manage the relationship from this side if ( key.getMetadata().isInverse() ) { return; } Long txId = transactionId( associationContext.getTransactionContext() ); getAssociationQueries( key.getMetadata() ).removeAssociation( client, txId, key ); }
protected RowKey convert(AssociationKey associationKey, TupleSnapshot snapshot) { String[] columnNames = associationKey.getMetadata().getRowKeyColumnNames(); Object[] values = new Object[columnNames.length]; for ( int i = 0; i < columnNames.length; i++ ) { values[i] = snapshot.get( columnNames[i] ); } return new RowKey( columnNames, values ); }
@Override protected RowKey convert(AssociationKey associationKey, TupleSnapshot snapshot) { String[] columnNames = associationKey.getMetadata().getRowKeyColumnNames(); Object[] values = new Object[columnNames.length]; for ( int i = 0; i < columnNames.length; i++ ) { values[i] = snapshot.get( columnNames[i] ); } return new RowKey( columnNames, values ); }
@Override public Association createAssociation(AssociationKey key, AssociationContext associationContext) { if ( key.getMetadata().getAssociationKind() == AssociationKind.ASSOCIATION ) { return new Association( new IgniteAssociationSnapshot( key ) ); } else if ( key.getMetadata().getAssociationKind() == AssociationKind.EMBEDDED_COLLECTION ) { return new Association( new IgniteEmbeddedAssociationSnapshot( key, associationContext.getEntityTuplePointer().getTuple() ) ); } else { throw new UnsupportedOperationException( "Unknown association kind " + key.getMetadata().getAssociationKind() ); } }
private static Node findOwnerNode(Relationship relationship, AssociationKey associationKey) { if ( isEmbeddedCollection( associationKey ) ) { String collectionRole = associationKey.getMetadata().getCollectionRole(); return embeddedAssociationOwner( relationship, collectionRole ); } else { return ownerNodeFromAssociation( associationKey, relationship ); } }
private Relationship createRelationshipWithEmbeddedNode(AssociationKey associationKey, Tuple associationRow, AssociatedEntityKeyMetadata associatedEntityKeyMetadata) { EntityKey embeddedKey = getEntityKey( associationRow, associatedEntityKeyMetadata ); Relationship relationship = getAssociationQueries( associationKey.getMetadata() ) .createRelationshipForEmbeddedAssociation( dataBase, associationKey, embeddedKey ); applyProperties( associationKey, associationRow, relationship ); return relationship; }
@Override public Association createAssociation(AssociationKey key, AssociationContext associationContext) { final Cache<AK> associationCache = getCacheManager().getAssociationCache( key.getMetadata() ); Map<SerializableRowKey, Map<String, Object>> association = new HashMap<SerializableRowKey, Map<String, Object>>(); associationCache.put( new Element( getKeyProvider().getAssociationCacheKey( key ), association ) ); return new Association( new SerializableMapAssociationSnapshot( association ) ); }
@Override public void removeAssociation(AssociationKey key, AssociationContext associationContext) { Cache<AK, Map<RowKey, Map<String, Object>>> cache = getCacheManager().getAssociationCache( key.getMetadata() ); AK cacheKey = getKeyProvider().getAssociationCacheKey( key ); AtomicMapLookup.removeAtomicMap( cache, cacheKey ); }
@Override public void removeAssociation(AssociationKey key, AssociationContext associationContext) { Cache<AK, Map<RowKey, Map<String, Object>>> cache = getCacheManager().getAssociationCache( key.getMetadata() ); AK cacheKey = getKeyProvider().getAssociationCacheKey( key ); AtomicMapLookup.removeAtomicMap( cache, cacheKey ); }
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 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 void createRelationshipWithEmbeddedNode(AssociationKey associationKey, AssociationContext associationContext, AssociationOperation action) { AssociatedEntityKeyMetadata associatedEntityKeyMetadata = associationContext.getAssociationTypeContext().getAssociatedEntityKeyMetadata(); Transaction tx = transaction( associationContext ); Tuple associationRow = action.getValue(); EntityKey embeddedKey = getEntityKey( associationRow, associatedEntityKeyMetadata ); if ( !emptyNode( embeddedKey ) ) { Object[] relationshipProperties = relationshipProperties( associationKey, action ); getAssociationQueries( associationKey.getMetadata() ) .createRelationshipForEmbeddedAssociation( tx, associationKey, embeddedKey, relationshipProperties ); } }
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 ); }