package com.ecep.contract.controller.employee;

import java.util.Map;

import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.IdentityEntity;
import com.ecep.contract.service.EmployeeService;
import com.ecep.contract.vm.EmployeeBasedViewModel;
import com.ecep.contract.vm.EmployeeViewModel;
import com.ecep.contract.vm.IdentityViewModel;

public abstract class AbstEmployeeTableTabSkin<T extends IdentityEntity, TV extends IdentityViewModel<T>>
        extends AbstEntityTableTabSkin<EmployeeWindowController, Employee, EmployeeViewModel, T, TV>
        implements TabSkin {

    public AbstEmployeeTableTabSkin(EmployeeWindowController controller) {
        super(controller);
    }

    public EmployeeService getEmployeeService() {
        return controller.employeeService;
    }

    @Override
    protected TV createNewViewModel() {
        TV model = super.createNewViewModel();
        if (model instanceof EmployeeBasedViewModel m) {
            m.getEmployee().set(getEntity());
        }
        return model;
    }


    @Override
    public Map<String, Object> getSpecification(Employee parent) {
        Map<String, Object> params = getSpecification();
        params.put("employee", parent.getId());
        return params;
    }
}
