Skip to content

Commit

Permalink
OGM-904 Polishing
Browse files Browse the repository at this point in the history
- Add docs to commonly used methods
- Remove duplicated code by using common helpers
  • Loading branch information
mp911de committed Aug 31, 2015
1 parent ed9d06c commit 971781e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Expand Up @@ -133,6 +133,13 @@ private static MapStorageType getMapStorage(AssociationContext associationContex
return associationContext.getAssociationTypeContext().getOptionsContext().getUnique( MapStorageOption.class );
}

/**
* Returns the shared prefix with a trailing dot (.) of the association columns or {@literal null} if there is no shared prefix.
*
* @param associationKey the association key
*
* @return the shared prefix with a trailing dot (.) of the association columns or {@literal null}
*/
public static String getColumnSharedPrefixOfAssociatedEntityLink(AssociationKey associationKey) {
String[] associationKeyColumns = associationKey.getMetadata()
.getAssociatedEntityKeyMetadata()
Expand Down
Expand Up @@ -6,6 +6,7 @@
*/
package org.hibernate.ogm.datastore.mongodb;

import static org.hibernate.ogm.datastore.document.impl.DotPatternMapHelpers.getColumnSharedPrefixOfAssociatedEntityLink;
import static org.hibernate.ogm.datastore.mongodb.dialect.impl.MongoDBTupleSnapshot.SnapshotType.INSERT;
import static org.hibernate.ogm.datastore.mongodb.dialect.impl.MongoDBTupleSnapshot.SnapshotType.UPDATE;
import static org.hibernate.ogm.datastore.mongodb.dialect.impl.MongoHelpers.hasField;
Expand Down Expand Up @@ -591,17 +592,6 @@ private Object getAssociationRow(Tuple row, AssociationKey associationKey) {
}
}

private String getColumnSharedPrefixOfAssociatedEntityLink(AssociationKey associationKey) {
String[] associationKeyColumns = associationKey.getMetadata()
.getAssociatedEntityKeyMetadata()
.getAssociationKeyColumns();
// we used to check that columns are the same (in an ordered fashion)
// but to handle List and Map and store indexes / keys at the same level as the id columns
// this check is removed
String prefix = DocumentHelpers.getColumnSharedPrefix( associationKeyColumns );
return prefix == null ? "" : prefix + ".";
}

@Override
public void insertOrUpdateAssociation(AssociationKey key, Association association, AssociationContext associationContext) {
DBCollection collection;
Expand Down

0 comments on commit 971781e

Please sign in to comment.