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.util.ParamUtils;
import com.ecep.contract.vm.EmployeeBasedViewModel;
import com.ecep.contract.vm.EmployeeViewModel;
import com.ecep.contract.vm.IdentityViewModel;
import com.ecep.contract.vo.EmployeeVo;

public abstract class AbstEmployeeTableTabSkin<T extends IdentityEntity, TV extends IdentityViewModel<T>>
        extends AbstEntityTableTabSkin<EmployeeWindowController, EmployeeVo, 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().getId());
        }
        return model;
    }


    @Override
    public ParamUtils.Builder getSpecification(EmployeeVo parent) {
        ParamUtils.Builder params = getSpecification();
        params.equals("employee", parent.getId());
        return params;
    }
}
