# -*- coding: latin-1 -*-
from ppms.migration.packet import *


class ChangeDT152HyperlinkDefinition(ChangeDTPPacket):
    ''' Change Definition of Hyperlink DI from DT152 (DI059192)'''
    wi_number = 9211
    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY

    def fix(self, runner):
        values = [['059192','db_typ','N2','N4'],
                  ['059192','ppms_type','N2','N4'],
                  ['059192','db_length',2,20],
                  ['059192','df_length',4,20]]

        for di_id, df_name, old_value, new_value in values:
            record = self.get_record(412, [di_id], [253, 3141, 254, 246, 41246])
            if not self.change_value(record, df_name, old_value, new_value):
                return self.fail()     

        return self.success()