view · edit · sidebar · attach · print · history

20131030-swissindex-update-sequence-00

<< | Index | >>


Summary

  • composition for sequence 00 not removed when running update_swissmedic

Commits

Index

--

composition for sequence 00 not removed when running update_swissmedic

As I found various cases where packages were placed in a wrong sequence or that a sequence has to be dropped I must find a way to

  1. Move a package to the correct sequence
  2. Delete the sequence if it does not contain any package

For the first point I must distinguish introduce a new method move_package(ikscd, old_seq_nr, new_seq_nr) in registration.rb. Create test-case and implemented the procedure.

Reimporting the db-dump to restore the same situation as on thinpower. Running the import again. Import finishes, as I don't handle correctly the following situation

/var/www/oddb.org/src/plugin/swissmedic.rb: 835 2013-10-30 11:08:10 +0100: iksnr 52376 pack 027 move_package 027 oldSeqnr 04 -> 03
/var/www/oddb.org/src/plugin/swissmedic.rb: 802 2013-10-30 11:08:10 +0100: update_registrations iksnr '52376' seqnr 04 pack 026
/var/www/oddb.org/src/plugin/swissmedic.rb: 835 2013-10-30 11:08:10 +0100: iksnr 52376 pack 026 move_package 026 oldSeqnr 03 -> 04

Also when looking at http://oddb-ci.dyndns.org/de/gcc/drug/reg/41352/seq/04 I see that the Packung does not show up. Maybe this stems from the fact, that the index was not rebuilt. Will correct the first error assuming, that we never want to delete an used sequence (except the '00').

My log reports for 41352

/var/www/oddb.org/src/plugin/swissmedic.rb: 802 2013-10-30 11:40:08 +0100: update_registrations iksnr '41352' seqnr 04 pack 035
/var/www/oddb.org/src/plugin/swissmedic.rb: 835 2013-10-30 11:40:08 +0100: iksnr 41352 pack 035 move_package 035 oldSeqnr 01 -> 04
/var/www/oddb.org/src/plugin/swissmedic.rb: 802 2013-10-30 11:40:08 +0100: update_registrations iksnr '41352' seqnr 05 pack 036
/var/www/oddb.org/src/plugin/swissmedic.rb: 802 2013-10-30 11:46:40 +0100: update_registrations iksnr '41352' seqnr 04 pack 035
/var/www/oddb.org/src/plugin/swissmedic.rb: 802 2013-10-30 11:46:40 +0100: update_registrations iksnr '41352' seqnr 05 pack 036

Using bin/oddb

ch.oddb> registration('41352').sequence('01').package('035').sequence.seqnr
-> 04
ch.oddb> registration('41352').package('035').sequence.seqnr
-> 04

But when looking at http://oddb-ci.dyndns.org/de/gcc/drug/reg/41352/seq/01 the package is still there and not at http://oddb-ci.dyndns.org/de/gcc/drug/reg/41352/seq/04. Waiting for index rebuild to complete. But probably I did not call odba_isolated_store for the old_sequence in move_package (and my unit test does not catch this error!)

Looking a similar code in package.rb and sequence.rb I found out that I will probably have to call fix_pointers for each sequence. Adding this to my changed, reimporting the DB and rerunning the Packungen import.

In any case I cannot use the method sequence.seqnr= as this would move all packages to the new sequence!

Always having problems. Now I try to fix the problem of 62785 in bin/admin (all in one long line!)

cd = '004'; pack = registration('62785').sequence('01').package(cd); \
oldSeq = registration('62785').sequence('01'); oldSeq.packages.delete(cd); \
newSeq = registration('62785').sequence('02'); newSeq.packages[cd] = pack; \
pack.sequence = newSeq; newSeq.odba_store;  oldSeq.odba_store

When I go now at http://oddb-ci.dyndns.org/de/gcc/drug/reg/62785/seq/01, the package 004 cannot be found anymore as it is now in sequence 02. But after restarting all oddb-services (and apache2). The fix has gone. Okay, something was not properly written back to the datastore. Must have another look whether fix_pointers is necessary or not.

Tried another variant

$reg = registration('62785'); $ikscd = '003'; $pack = $reg.sequence('01').package($ikscd); \
$oldSeq = $reg.sequence('01'); $oldPacks=$oldSeq.packages; $oldPacks.delete($ikscd); $oldSeq.odba_store;\
$stdout.puts "$pack ist #{$pack}";$newSeq = $reg.sequence('02'); $newSeq.packages[$ikscd] = $pack; \
$newSeq.packages[$ikscd].sequence = $newSeq; $newSeq.odba_store; $newSeq.packages[$ikscd].odba_store 
ch.oddb> registration('62785').sequence('02').packages.first
-> ["003", #<ODBA::Stub:69995152941560#30482789 @odba_class= @odba_container=69995152931200#30482783>]

But after restarting all oddb-services I get

ch.oddb> registration('62785').sequence('02').packages.size
-> 0
ch.oddb> registration('62785').sequence('01').packages.size
-> 4
ch.oddb> registration('62785').sequence('01').package('004')
-> #<ODDB::Package:0x00000004156298>
ch.oddb> registration('62785').sequence('01').package('004').sequence.seqnr
-> 02

Somehow I just cannot yet figure out how the trick with the delegate_method works! Or should I just delete/add? Trying to set the package.sequence=nil did not work neither. Used $reg = registration('62785'); $ikscd = '003'; $pack = $reg.sequence('01').package($ikscd); $pack.sequence=nil; $oldSeq = $reg.sequence('01'); $oldPacks=$oldSeq.packages; $oldPacks.delete($ikscd); $newSeq = $reg.sequence('02'); $newSeq.packages[$ikscd] = $pack; $newSeq.packages[$ikscd].sequence = $newSeq; $oldSeq.odba_isolated_store; $newSeq.odba_isolated_store; $newSeq.packages[$ikscd].odba_isolated_store; $reg.odba_isolated_store;

Tried using delete/create. Now after calling $reg = registration('62785'); $ikscd = '003'; $pack = $reg.sequence('01').package($ikscd);$reg.sequence('01').delete_package($ikscd);$reg.sequence('02').create_package($ikscd);$reg.sequence('02').packages.store($ikscd, $pack); $reg.sequence('02').odba_isolated_store; I see in bin/admin

ch.oddb> $pack = registration('62785').sequence('02').packages.size
-> 0
ch.oddb> $pack = registration('62785').sequence('01').packages.size
-> 3

Which means that deleting worked, but not creation. Creation did probably not work, because I did not create a part.

I don't yet understand why the actual state is not correctly written into the database.

Making minimal adjustments for src/plugin/swissmedic.rb to make it remove the sequence '00 and just adding an output to tell that we were unable to move a package from one sequence to another.

Remove registrations of form 'xxx.0'

Creating a jobs/remove_registration_with_point which finds all registration having a '.' in their name. For each of this registartion do

  1. delete all packages
  2. delete all sequence
  3. delete the registration.pointer

We don't delete the fachinfo if is not present or contains more iksnr than the actual one. Tested the job. Improved the regular expression to exclude all registration which have at least one non digit character in their iksnr.

Deleted 184 registrations. See Attach:remove_log.txt. Pushed commit Added job to remove bad registrations

view · edit · sidebar · attach · print · history
Page last modified on October 30, 2013, at 10:36 PM