/** * A regular embedded is an element that it is embedded but it is not a key or a collection. * * @param keyColumnNames the column names representing the identifier of the entity * @param column the column we want to check * @return {@code true} if the column represent an attribute of a regular embedded element, {@code false} otherwise */ public static boolean isPartOfRegularEmbedded(String[] keyColumnNames, String column) { return isPartOfEmbedded( column ) && !ArrayHelper.contains( keyColumnNames, column ); }
List<String> selectableColumns = tupleTypeContext.getSelectableColumns(); for ( String column : selectableColumns ) { if ( isPartOfEmbedded( column ) ) { String embeddedPath = column.substring( 0, column.lastIndexOf( "." ) ); if ( !queries.containsKey( column ) ) {
private void createRelationshipForCollectionOfPrimitivesOrMap(AssociationKey associationKey, String collectionRole, String[] columnNames, StringBuilder queryBuilder) { String relationshipType = collectionRole; if ( isPartOfEmbedded( collectionRole ) ) { queryBuilder.append( " MERGE (owner) " ); String[] pathToEmbedded = appendEmbeddedNodes( collectionRole, queryBuilder ); relationshipType = pathToEmbedded[pathToEmbedded.length - 1]; queryBuilder.append( " CREATE (e) -[r:" ); } else { queryBuilder.append( " CREATE (owner) -[r:" ); } escapeIdentifier( queryBuilder, relationshipType ); queryBuilder.append( "]->(new:" ); queryBuilder.append( EMBEDDED ); queryBuilder.append( ":" ); escapeIdentifier( queryBuilder, associationKey.getTable() ); queryBuilder.append( " {" ); // THe name of the property is the same as the relationship type escapeIdentifier( queryBuilder, relationshipType ); queryBuilder.append( ": {" ); queryBuilder.append( columnNames.length ); queryBuilder.append( "}" ); queryBuilder.append( "}" ); queryBuilder.append( ")" ); queryBuilder.append( " RETURN r" ); }
if ( EmbeddedHelper.isPartOfEmbedded( column ) ) { if ( !removeColumn.containsKey( column ) ) { StringBuilder queryBuilder = new StringBuilder();
private StringBuilder findAssociationPartialQuery(String relationshipType, AssociationKeyMetadata associationKeyMetadata) { StringBuilder queryBuilder = new StringBuilder( findAssociationPartialQuery ); if ( isPartOfEmbedded( relationshipType ) ) { String[] path = split( relationshipType ); int index = 0;
private void createRelationshipForCollectionOfPrimitivesOrMap(AssociationKey associationKey, String collectionRole, String[] columnNames, StringBuilder queryBuilder) { String relationshipType = collectionRole; if ( isPartOfEmbedded( collectionRole ) ) { queryBuilder.append( " MERGE (owner) " ); String[] pathToEmbedded = appendEmbeddedNodes( collectionRole, queryBuilder ); relationshipType = pathToEmbedded[pathToEmbedded.length - 1]; queryBuilder.append( " CREATE (e) -[r:" ); } else { queryBuilder.append( " CREATE (owner) -[r:" ); } escapeIdentifier( queryBuilder, relationshipType ); int offset = ownerEntityKeyMetadata.getColumnNames().length; appendProperties( queryBuilder, associationKey.getMetadata().getRowKeyIndexColumnNames(), offset ); queryBuilder.append( "]-> (new:" ); queryBuilder.append( EMBEDDED ); queryBuilder.append( ":" ); escapeIdentifier( queryBuilder, associationKey.getTable() ); queryBuilder.append( " {" ); // THe name of the property is the same as the relationship type escapeIdentifier( queryBuilder, relationshipType ); queryBuilder.append( ": {" ); offset += associationKey.getMetadata().getRowKeyIndexColumnNames().length; queryBuilder.append( offset ); queryBuilder.append( "}" ); queryBuilder.append( "}" ); queryBuilder.append( ")" ); queryBuilder.append( " RETURN r" ); }
private static Node embeddedAssociationOwner(Relationship relationship, String collectionRole) { if ( isPartOfEmbedded( collectionRole ) ) { String[] split = EmbeddedHelper.split( collectionRole ); Node ownerNode = relationship.getStartNode(); for ( int i = 1; i < split.length; i++ ) { String type = split[split.length - i - 1]; Relationship next = ownerNode.getRelationships( Direction.INCOMING, withName( type ) ).iterator().next(); ownerNode = next.getStartNode(); } return ownerNode; } else { return relationship.getStartNode(); } }
if ( isPartOfEmbedded( targetColumnName ) ) { fetchEmbeddedProperties( associationKey, properties, targetNode, associationColumn, targetColumnName );
private void appendSubTree(EmbeddedNodesTree tree, String currentProperty, String relationshipType, int index) { EmbeddedNodesTree subTree = tree.getChild( relationshipType ); if ( subTree == null ) { subTree = new EmbeddedNodesTree(); tree.addChild( relationshipType, subTree ); } if ( isPartOfEmbedded( currentProperty ) ) { int firstDot = currentProperty.indexOf( "." ); String relType = currentProperty.substring( 0, firstDot ); String subProperty = currentProperty.substring( firstDot + 1 ); appendSubTree( tree, subProperty, relType, index ); } else { EmbeddedNodeProperty property = new EmbeddedNodeProperty(); property.setColumn( currentProperty ); property.setParam( index ); subTree.addProperty( property ); } }
private void appendSubTree(EmbeddedNodesTree tree, String currentProperty, String relationshipType, int index) { EmbeddedNodesTree subTree = tree.getChild( relationshipType ); if ( subTree == null ) { subTree = new EmbeddedNodesTree(); tree.addChild( relationshipType, subTree ); } if ( isPartOfEmbedded( currentProperty ) ) { int firstDot = currentProperty.indexOf( "." ); String relType = currentProperty.substring( 0, firstDot ); String subProperty = currentProperty.substring( firstDot + 1 ); appendSubTree( tree, subProperty, relType, index ); } else { EmbeddedNodeProperty property = new EmbeddedNodeProperty(); property.setColumn( currentProperty ); property.setParam( index ); subTree.addProperty( property ); } }
private void createRelationshipforCollectionOfComponents(AssociationKey associationKey, String collectionRole, String[] embeddedColumnNames, Object[] embeddedColumnValues, StringBuilder queryBuilder) { int offset = associationKey.getEntityKey().getColumnNames().length; EmbeddedNodesTree tree = createEmbeddedTree( collectionRole, embeddedColumnNames, embeddedColumnValues, offset ); if ( isPartOfEmbedded( collectionRole ) ) { String[] pathToEmbedded = appendEmbeddedNodes( collectionRole, queryBuilder ); queryBuilder.append( " CREATE (e) -[r:" );
private void createRelationshipforCollectionOfComponents(AssociationKey associationKey, String collectionRole, String[] embeddedColumnNames, Object[] embeddedColumnValues, StringBuilder queryBuilder) { int offset = associationKey.getEntityKey().getColumnNames().length; if ( isPartOfEmbedded( collectionRole ) ) { String[] pathToEmbedded = appendEmbeddedNodes( collectionRole, queryBuilder ); queryBuilder.append( " MERGE (e) -[r:" );
if ( isPartOfEmbedded( targetColumnName ) ) {