private IdSourceKey(IdSourceKeyMetadata metadata, String columnValue) { this.metadata = metadata; this.columnName = metadata.getKeyColumnName(); this.columnValue = columnValue; this.hashCode = calculateHashCode(); }
private static boolean isEmbeddedAssociation(AssociationKey key) { return AssociationKind.EMBEDDED_COLLECTION == key.getMetadata().getAssociationKind(); }
private boolean isAJoinColumn(AssociationKey key) { AssociationKeyMetadata metadata = key.getMetadata(); if ( AssociationKind.EMBEDDED_COLLECTION.equals( metadata.getAssociationKind() ) ) { return false; } AssociatedEntityKeyMetadata entityKeyMetadata = metadata.getAssociatedEntityKeyMetadata(); return metadata.getTable().equals( entityKeyMetadata.getEntityKeyMetadata().getTable() ); }
@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 ); }
/** * Creates the row key of the given association row; columns present in the given association key will be obtained * from there, all other columns from the given native association row. */ private static <R> RowKey buildRowKey(AssociationKey associationKey, R row, AssociationRowAccessor<R> accessor) { String[] columnNames = associationKey.getMetadata().getRowKeyColumnNames(); Object[] columnValues = new Object[columnNames.length]; for ( int i = 0; i < columnNames.length; i++ ) { String columnName = columnNames[i]; columnValues[i] = associationKey.getMetadata().isKeyColumn( columnName ) ? associationKey.getColumnValue( columnName ) : accessor.get( row, columnName ); } return new RowKey( columnNames, columnValues ); }
/** * @param associationMetadata * @return true - is association through third table */ public static boolean isThirdTableAssociation(AssociationKeyMetadata associationMetadata) { return !associationMetadata.getTable().equals( associationMetadata.getAssociatedEntityKeyMetadata().getEntityKeyMetadata().getTable() ); } }
private boolean hasRowIndex(AssociationKey associationKey) { return associationKey.getMetadata().getRowKeyIndexColumnNames().length > 0; }
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 static boolean emptyNode(EntityKey entityKey) { for ( Object value : entityKey.getColumnValues() ) { if ( value != null ) { return false; } } return true; }
public static AssociationStorageStrategy getInstance(AssociationKeyMetadata keyMetadata, AssociationStorageType associationStorage, AssociationDocumentStorageType associationDocumentStorage) { if ( keyMetadata.getAssociationType() == AssociationType.ONE_TO_ONE || keyMetadata.getAssociationKind() == AssociationKind.EMBEDDED_COLLECTION || associationStorage == AssociationStorageType.IN_ENTITY ) { return IN_ENTITY; } else if ( associationDocumentStorage == AssociationDocumentStorageType.COLLECTION_PER_ASSOCIATION ) { return COLLECTION_PER_ASSOCIATION; } else { return GLOBAL_COLLECTION; } } }
/** * Get the table name of this key. * * @return the table name of this key */ public String getTable() { return keyMetadata.getTable(); }
/** * 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(); }
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 ); }
private static boolean isEmbeddedAssociation(AssociationKey key) { return AssociationKind.EMBEDDED_COLLECTION == key.getMetadata().getAssociationKind(); }
/** * 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(); }
private RowKey convert(AssociationKey associationKey, RemoteNeo4jTupleAssociationSnapshot 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 ); }
private static boolean isEmbeddedCollection(AssociationKey associationKey) { return associationKey.getMetadata().getAssociationKind() == AssociationKind.EMBEDDED_COLLECTION; }
/** * 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(); }
public RowKey asRowKey(AssociationKey key) { String[] columnNames = key.getMetadata().getRowKeyColumnNames(); Object[] columnValues = new Object[columnNames.length]; for ( int i = 0; i < columnNames.length; i++ ) { String columnName = columnNames[i]; columnValues[i] = getColumnValue( columnName ); } return new RowKey( columnNames, columnValues ); }