package com.ecep.contract.controller.project;

import java.util.Map;

import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
import com.ecep.contract.model.IdentityEntity;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.IdentityViewModel;
import com.ecep.contract.vm.ProjectBasedViewModel;
import com.ecep.contract.vm.ProjectViewModel;
import com.ecep.contract.vo.ProjectVo;

public abstract class AbstProjectTableTabSkin<T extends IdentityEntity, TV extends IdentityViewModel<T>>
        extends AbstEntityTableTabSkin<ProjectWindowController, ProjectVo, ProjectViewModel, T, TV>
        implements TabSkin {

    public AbstProjectTableTabSkin(ProjectWindowController controller) {
        super(controller);
    }

    public ProjectService getProjectService() {
        return controller.projectService;
    }

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

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