Skip to content

Commit

Permalink
wrap save in a single transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
ethansr committed Feb 20, 2012
1 parent e8c47f3 commit db0e57f
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions lib/elan_parser/xml/xml_save.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@ module ElanParser
module XML
class Save
def initialize(parsed_annotation_document, file_name)
annotation_document = create_annotation_document(parsed_annotation_document, file_name)

create_linguistic_type(parsed_annotation_document, annotation_document)
create_locale(parsed_annotation_document, annotation_document)
create_constraint(parsed_annotation_document, annotation_document)

header = create_header(parsed_annotation_document, annotation_document)
media_descriptors = create_media_descriptors(parsed_annotation_document)
join_header_media_descriptors(header, media_descriptors)

properties = create_properties(parsed_annotation_document)
join_header_properties(header, properties)

#Create any new time slots, then assign them to the time order in this document.
time_slots = create_time_slots(parsed_annotation_document)
create_time_orders(parsed_annotation_document, time_slots, annotation_document)
create_annotations(parsed_annotation_document, time_slots, annotation_document)

ElanParser::DB::AnnotationDocument.transaction do
annotation_document = create_annotation_document(parsed_annotation_document, file_name)

create_linguistic_type(parsed_annotation_document, annotation_document)
create_locale(parsed_annotation_document, annotation_document)
create_constraint(parsed_annotation_document, annotation_document)

header = create_header(parsed_annotation_document, annotation_document)
media_descriptors = create_media_descriptors(parsed_annotation_document)
join_header_media_descriptors(header, media_descriptors)

properties = create_properties(parsed_annotation_document)
join_header_properties(header, properties)

#Create any new time slots, then assign them to the time order in this document.
time_slots = create_time_slots(parsed_annotation_document)
create_time_orders(parsed_annotation_document, time_slots, annotation_document)
create_annotations(parsed_annotation_document, time_slots, annotation_document)
end
end

def create_annotations(doc, time_slots, annotation_document)
Expand Down

0 comments on commit db0e57f

Please sign in to comment.