from production.model import ProductionOrder
from typing import Dict

from ._ProductionCommand import ProductionCommand


class TagLinesCommand(ProductionCommand):
    def __init__(self, order_id, view, line_ids, tag, command_order):
        super(TagLinesCommand, self).__init__(order_id, view)
        self.line_ids = line_ids
        self.tag = tag
        self.line_ids_jit_lines = self.get_line_ids_jit_lines(command_order)

    def get_hash_extra_value(self):
        # type: () -> str

        raise NotImplementedError()

    def get_line_ids_jit_lines(self, command_order):
        # type: (ProductionOrder) -> Dict

        items_jit_lines = {}
        for line_id in self.line_ids:
            item = command_order.get_item_by_line_id(line_id)
            if item:
                items_jit_lines[line_id] = item.displayed_jit
                for joined_item in item.joined_items:
                    items_jit_lines[joined_item.get_line_id()] = item.displayed_jit

        return items_jit_lines
