private void applyAssociationOperation(
     Association association,
     AssociationKey key,
     AssociationOperation operation,
     AssociationContext associationContext) {
   switch (operation.getType()) {
     case CLEAR:
       removeAssociation(key, associationContext);
       break;
     case PUT:
       putAssociationOperation(
           association,
           key,
           operation,
           associationContext.getAssociationTypeContext().getAssociatedEntityKeyMetadata());
       break;
     case REMOVE:
       removeAssociationOperation(
           association,
           key,
           operation,
           associationContext.getAssociationTypeContext().getAssociatedEntityKeyMetadata());
       break;
   }
 }
  private Map<RowKey, Tuple> createAssociationMap(
      AssociationKey associationKey, AssociationContext associationContext, EntityKey entityKey) {
    String relationshipType = associationContext.getAssociationTypeContext().getRoleOnMainSide();
    ResourceIterator<Relationship> relationships =
        entityQueries
            .get(entityKey.getMetadata())
            .findAssociation(dataBase, entityKey.getColumnValues(), relationshipType);

    Map<RowKey, Tuple> tuples = new HashMap<RowKey, Tuple>();
    try {
      while (relationships.hasNext()) {
        Relationship relationship = relationships.next();
        AssociatedEntityKeyMetadata associatedEntityKeyMetadata =
            associationContext.getAssociationTypeContext().getAssociatedEntityKeyMetadata();
        EmbeddedNeo4jTupleAssociationSnapshot snapshot =
            new EmbeddedNeo4jTupleAssociationSnapshot(
                relationship, associationKey, associatedEntityKeyMetadata);
        RowKey rowKey = convert(associationKey, snapshot);
        tuples.put(rowKey, new Tuple(snapshot, SnapshotType.UPDATE));
      }
      return tuples;
    } finally {
      relationships.close();
    }
  }