lang::catalog::import_messages (private)

 lang::catalog::import_messages -file_messages_list file_messages_list \
    -package_key package_key -locale locale

Defined in packages/acs-lang/tcl/lang-catalog-procs.tcl

Import a given set of messages from a catalog file to the database for a certain package and locale. If we already have messages in the db for the given package and locale then a merge between the database messages and the file messages will be performed.

Foreach message to import, the base messages for the merge is the messages in the db from the last time db and catalog file were in sync for the corresponding message key. The first such sync point is the initial import of a message. After that, any export of messages to the filesystem will be a sync point. Also, after an upgrade, a large number of the resulting messages in the db will be identical to those in the file (the file messages take precedence on conflict) and those messages will also be sync points. A message being in sync between db and file is indicated by the lang_message.sync_time column being set to a not null value.

This proc is idempotent which means that it can be executed multiple times and after the first time it's been executed it won't have any effect on the db. See the corresponding acs-automated-testing test case called upgrade.

What follows below is a description of the logic of the proc in terms of its input, the cases considered, and the logical actions taken for each case.

There are three sets of keys, file, db, and base keys. For each key in the union of these keys there are three messages that can exist: the file message, the db message, and the base message. The base message serves as the base for the merge. We will distinguish all the different permutations of each of the three messages existing or not, and all permutations of the messages being different from each other. We don't distinguish how two messages are different, only whether they are different or not. In total that gives us 14 cases (permutations) to consider.

    *** Exactly one of messages exists (3 cases):

    1. base message (deleted in file and db). upgrade_action=none, conflict_p=f

    2. db message (added in db). upgrade_action=none, conflict_p=f

    3. file message (added in file). upgrade_action=add, conflict_p=f

    *** Exactly two of the messages exist (6 cases):

    - Base and file message (db message deleted):
      4. Differ (conflicting change). upgrade_action=resurrect, conflict_p=t
      5. No difference (no conflicting change). upgrade_action=none, conflict_p=f

    - Base and db message (file message deleted):
      6. Differ (conflicting change): upgrade_action=delete, conflict_p=t
      7. No difference (no conflicting change): upgrade_action=delete, conflict_p=f

    - File and db message (message added in both db and file):
      8. Differ (conflicting change). upgrade_action=update, conflict_p=t
      9. No difference (identical changes). upgrade_action=none, conflict_p=f

    *** All three messages exist (5 cases):

    10. All the same. upgrade_action=none, conflict_p=f

    11. File and base the same. upgrade_action=none, conflict_p=f

    12. DB and base the same. upgrade_action=update, conflict_p=f

    13. File and DB the same. upgrade_action=none, conflict_p=f

    14. All different. upgrade_action=update, conflict_p=t
    

Switches:
-file_messages_list
(required)
An array list with message keys as keys and the message of those keys as values, i.e. (key, value, key, value, ...)
-package_key
(required)
The package_key for the messages.
-locale
(required)
The locale of the messages.
Returns:
An array list containing the number of messages processed, number of messages added, number of messages updated, number of messages deleted by the import, and a list of errors produced. The keys of the array list are processed, added, updated, and deleted, and errors.
Authors:
Peter Marklund
Lars Pind

Partial Call Graph (max 5 caller/called nodes):
%3 lang::catalog::import_from_file lang::catalog::import_from_file (private) lang::catalog::import_messages lang::catalog::import_messages lang::catalog::import_from_file->lang::catalog::import_messages ad_try ad_try (public) lang::catalog::import_messages->ad_try lang::catalog::last_sync_messages lang::catalog::last_sync_messages (private) lang::catalog::import_messages->lang::catalog::last_sync_messages lang::catalog::messages_in_db lang::catalog::messages_in_db (private) lang::catalog::import_messages->lang::catalog::messages_in_db lang::message::edit lang::message::edit (private) lang::catalog::import_messages->lang::message::edit lang::message::register lang::message::register (public) lang::catalog::import_messages->lang::message::register

Testcases:
No testcase defined.
[ show source ]
Show another procedure: