# File lib/tapkit/access/database_context.rb, line 163
                def prepare_for_save( coordinator, editing_context )
                        @coordinatior    = coordinator
                        @editing_context = editing_context
                        @snapshot_store  = SnapshotStore.new
                        @inserted_objects.clear
                        @deleted_objects.clear
                        @updated_objects.clear
                        @database_operations.clear
                        @temp2key = {}

                        db_channel = available_channel
                        @adapter_channel = db_channel.adapter_channel

                        @editing_context.inserted_objects.each do |object|
                                entity       = object.class_description.entity
                                gid          = @editing_context.gid object
                                primary_keys = @adapter_channel.primary_keys_for_new_row(1, entity)

                                # compound key
                                if primary_keys.nil? then
                                        values = {}
                                        entity.primary_key_attribute_names.each do |name|
                                                values[name] = object[name]
                                        end
                                        @pk_values[gid] = values
                                else
                                        @pk_values[gid] = primary_keys.first
                                end

                                new_gid         = KeyGlobalID.new(entity.name, @pk_values[gid])
                                @temp2key[gid]  = new_gid
                        end

                        @editing_context.updated_objects.each do |object|
                                gid = @editing_context.gid object
                                unless own? gid then
                                        next
                                end

                                entity   = object.class_description.entity
                                snapshot = @database.snapshot gid
                                values   = {}

                                # sets or updates values for primary keys
                                entity.primary_key_attribute_names.each do |name|
                                        if entity.class_property? name then
                                                values[name] = object[name]
                                        else
                                                values[name] = snapshot[name]
                                        end
                                end

                                @pk_values[gid] = values
                        end
                end