package com.bocloud.ims.entity.resource.hmc;

import com.bocloud.cmp.model.hmc.enums.VirtualNetworkAdapterType;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.Table;

import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Table("hmd_profile")
public class HmdProfile extends HmdGenericEntity {
    @Column("name")
    private String name; // 名称
    @Column("partition_id")
    private Long partitionId; // 所属逻辑分区id,对应hmd_partition表的id字段
    @Column("uuid")
    private String uuid; // 唯一标识
    @Column("type")
    private String type; // 类型
    @Column("assign_all_resources")
    private Boolean assignAllResources; // 使用系统所有资源
    @Column("shared_processor")
    private Boolean sharedProcessor; // 使用共享处理器
    @Column("dedicated_processor")
    private Boolean dedicatedProcessor; // 使用专用处理器
    @Column("min_pro_units")
    private Double minProUnits; // 最小处理单元数
    @Column("des_pro_units")
    private Double desProUnits; // 期望处理单元数
    @Column("max_pro_units")
    private Double maxProUnits; // 最大处理单元数
    @Column("min_pro_virt")
    private Integer minProVirt; // 最小共享虚拟处理器数
    @Column("des_pro_virt")
    private Integer desProVirt; // 期望共享虚拟处理器数
    @Column("max_pro_virt")
    private Integer maxProVirt; // 最大共享虚拟处理器数
    @Column("min_pro")
    private Integer minPro; // 最小专用虚拟处理器数
    @Column("des_pro")
    private Integer desPro; // 期望专用虚拟处理器数
    @Column("max_pro")
    private Integer maxPro; // 最大专用虚拟处理器数
    @Column("shared_pro_pool_id")
    private Long sharedProPoolId; // 共享处理器池id，取自hmd_server_shared_processor_pool的id
    @Column("pro_sharing_mode")
    private String proSharingMode; // 处理器共享模式，受限capped、不受限uncapped
    @Column("uncapped_weight")
    private Integer uncappedWeight; // 处理器共享模式为uncapped时，权重
    @Column("max_memory")
    private Integer maxMemory; // 最小内存
    @Column("min_memory")
    private Integer minMemory; // 期望内存
    @Column("des_memory")
    private Integer desMemory; // 最大内存
    @Column("memory_bsr_count")
    private Integer memoryBsrCount; // BSR阵列数
    @Column("memory_page_ratio")
    private Integer memoryPageRatio; // 可配置页数
    @Column("memory_min_page_count")
    private Integer memoryMinPageCount; // 最小页数
    @Column("memory_des_page_count")
    private Integer memoryDesPageCount; // 期望页数:
    @Column("memory_max_page_count")
    private Integer memoryMaxPageCount; // 最大页数
    @Column("boot_mode")
    private String bootMode; // 引导方式
    @Column("auto_start")
    private Boolean autoStart; // 随受管系统一起自动启动
    @Column("conn_monitor")
    private Boolean connMonitor; // 启用连接监视
    @Column("redundant_error_path_report")
    private Boolean redundantErrorPathReport; // 启用冗余错误路径报告
    @Column("processor_compatibility_mode")
    private String processorCompatibilityMode; // 处理器兼容模式
    @Column("max_virtual_ioslots")
    private Integer maxVirtualIoslots; // 最大虚拟插槽数
    @Column("is_default_profile")
    private Boolean isDefaultProfile; // 是否默认概要文件
    @Column("is_active_profile")
    private Boolean isActiveProfile; // 是否活动概要文件
    @Column("is_last_activated")
    private Boolean isLastActivated; // 是否最后激活概要文件
    @Column("last_activated")
    private Date lastActivated; // 最后激活时间

    private List<HmdVirtualIoAdapter> ioAdapters; // 虚拟io适配器
    private List<HmdVirtualNetworkAdapter> networkAdapters; // 虚拟网络适配器
    private List<HmdVirtualScsiAdapter> scsiAdapters; // 虚拟scsi适配器
    private List<HmdVirtualFabricAdapter> fabricAdapters; // 虚拟光纤适配器
    private List<HmdProfileHea> heas; // 逻辑主机以太网适配器

    private HmdPartition partition; // 所属逻辑分区
    private HmdServerSharedProcessorPool sharedProPool; // 使用的虚拟处理器池

    public Long getPartitionId() {
        return partitionId;
    }

    public void setPartitionId(Long partitionId) {
        this.partitionId = partitionId;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Boolean getAssignAllResources() {
        return assignAllResources;
    }

    public void setAssignAllResources(Boolean assignAllResources) {
        this.assignAllResources = assignAllResources;
    }

    public Boolean getSharedProcessor() {
        return sharedProcessor;
    }

    public void setSharedProcessor(Boolean sharedProcessor) {
        this.sharedProcessor = sharedProcessor;
    }

    public Double getMinProUnits() {
        return minProUnits;
    }

    public void setMinProUnits(Double minProUnits) {
        this.minProUnits = minProUnits;
    }

    public Double getDesProUnits() {
        return desProUnits;
    }

    public void setDesProUnits(Double desProUnits) {
        this.desProUnits = desProUnits;
    }

    public Double getMaxProUnits() {
        return maxProUnits;
    }

    public void setMaxProUnits(Double maxProUnits) {
        this.maxProUnits = maxProUnits;
    }

    public Integer getMinProVirt() {
        return minProVirt;
    }

    public void setMinProVirt(Integer minProVirt) {
        this.minProVirt = minProVirt;
    }

    public Integer getDesProVirt() {
        return desProVirt;
    }

    public void setDesProVirt(Integer desProVirt) {
        this.desProVirt = desProVirt;
    }

    public Integer getMaxProVirt() {
        return maxProVirt;
    }

    public void setMaxProVirt(Integer maxProVirt) {
        this.maxProVirt = maxProVirt;
    }

    public Integer getMinPro() {
        return minPro;
    }

    public void setMinPro(Integer minPro) {
        this.minPro = minPro;
    }

    public Integer getDesPro() {
        return desPro;
    }

    public void setDesPro(Integer desPro) {
        this.desPro = desPro;
    }

    public Integer getMaxPro() {
        return maxPro;
    }

    public void setMaxPro(Integer maxPro) {
        this.maxPro = maxPro;
    }

    public Long getSharedProPoolId() {
        return sharedProPoolId;
    }

    public void setSharedProPoolId(Long sharedProPoolId) {
        this.sharedProPoolId = sharedProPoolId;
    }

    public Boolean getDedicatedProcessor() {
        return dedicatedProcessor;
    }

    public void setDedicatedProcessor(Boolean dedicatedProcessor) {
        this.dedicatedProcessor = dedicatedProcessor;
    }

    public Integer getUncappedWeight() {
        return uncappedWeight;
    }

    public void setUncappedWeight(Integer uncappedWeight) {
        this.uncappedWeight = uncappedWeight;
    }

    public String getProSharingMode() {
        return proSharingMode;
    }

    public void setProSharingMode(String proSharingMode) {
        this.proSharingMode = proSharingMode;
    }

    public Integer getMaxMemory() {
        return maxMemory;
    }

    public void setMaxMemory(Integer maxMemory) {
        this.maxMemory = maxMemory;
    }

    public Integer getMinMemory() {
        return minMemory;
    }

    public void setMinMemory(Integer minMemory) {
        this.minMemory = minMemory;
    }

    public Integer getDesMemory() {
        return desMemory;
    }

    public void setDesMemory(Integer desMemory) {
        this.desMemory = desMemory;
    }

    public Integer getMemoryBsrCount() {
        return memoryBsrCount;
    }

    public void setMemoryBsrCount(Integer memoryBsrCount) {
        this.memoryBsrCount = memoryBsrCount;
    }

    public Integer getMemoryPageRatio() {
        return memoryPageRatio;
    }

    public void setMemoryPageRatio(Integer memoryPageRatio) {
        this.memoryPageRatio = memoryPageRatio;
    }

    public Integer getMemoryMinPageCount() {
        return memoryMinPageCount;
    }

    public void setMemoryMinPageCount(Integer memoryMinPageCount) {
        this.memoryMinPageCount = memoryMinPageCount;
    }

    public Integer getMemoryDesPageCount() {
        return memoryDesPageCount;
    }

    public void setMemoryDesPageCount(Integer memoryDesPageCount) {
        this.memoryDesPageCount = memoryDesPageCount;
    }

    public Integer getMemoryMaxPageCount() {
        return memoryMaxPageCount;
    }

    public void setMemoryMaxPageCount(Integer memoryMaxPageCount) {
        this.memoryMaxPageCount = memoryMaxPageCount;
    }

    public String getBootMode() {
        return bootMode;
    }

    public void setBootMode(String bootMode) {
        this.bootMode = bootMode;
    }

    public Boolean getAutoStart() {
        return autoStart;
    }

    public void setAutoStart(Boolean autoStart) {
        this.autoStart = autoStart;
    }

    public Boolean getConnMonitor() {
        return connMonitor;
    }

    public void setConnMonitor(Boolean connMonitor) {
        this.connMonitor = connMonitor;
    }

    public Boolean getRedundantErrorPathReport() {
        return redundantErrorPathReport;
    }

    public void setRedundantErrorPathReport(Boolean redundantErrorPathReport) {
        this.redundantErrorPathReport = redundantErrorPathReport;
    }

    public String getProcessorCompatibilityMode() {
        return processorCompatibilityMode;
    }

    public void setProcessorCompatibilityMode(String processorCompatibilityMode) {
        this.processorCompatibilityMode = processorCompatibilityMode;
    }

    public Integer getMaxVirtualIoslots() {
        return maxVirtualIoslots;
    }

    public void setMaxVirtualIoslots(Integer maxVirtualIoslots) {
        this.maxVirtualIoslots = maxVirtualIoslots;
    }

    public Boolean getIsDefaultProfile() {
        return isDefaultProfile;
    }

    public void setIsDefaultProfile(Boolean isDefaultProfile) {
        this.isDefaultProfile = isDefaultProfile;
    }

    public Boolean getIsActiveProfile() {
        return isActiveProfile;
    }

    public void setIsActiveProfile(Boolean isActiveProfile) {
        this.isActiveProfile = isActiveProfile;
    }

    public Boolean getIsLastActivated() {
        return isLastActivated;
    }

    public void setIsLastActivated(Boolean isLastActivated) {
        this.isLastActivated = isLastActivated;
    }

    public Date getLastActivated() {
        return lastActivated;
    }

    public void setLastActivated(Date lastActivated) {
        this.lastActivated = lastActivated;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<HmdVirtualIoAdapter> getIoAdapters() {
        return ioAdapters;
    }

    public void setIoAdapters(List<HmdVirtualIoAdapter> ioAdapters) {
        this.ioAdapters = ioAdapters;
    }

    public List<HmdVirtualScsiAdapter> getScsiAdapters() {
        return scsiAdapters;
    }

    public void setScsiAdapters(List<HmdVirtualScsiAdapter> scsiAdapters) {
        this.scsiAdapters = scsiAdapters;
    }

    public List<HmdVirtualFabricAdapter> getFabricAdapters() {
        return fabricAdapters;
    }

    public void setFabricAdapters(List<HmdVirtualFabricAdapter> fabricAdapters) {
        this.fabricAdapters = fabricAdapters;
    }

    public List<HmdVirtualNetworkAdapter> getNetworkAdapters() {
        return networkAdapters;
    }

    public List<HmdVirtualNetworkAdapter> getClientNetworkAdapters() {
        if (networkAdapters == null) {
            return null;
        }
        return networkAdapters.stream().filter(adapter -> VirtualNetworkAdapterType.CLIENT.name().equals(adapter.getType())).collect(Collectors.toList());
    }

    public List<HmdVirtualNetworkAdapter> getTrunkNetworkAdapters() {
        if (networkAdapters == null) {
            return null;
        }
        return networkAdapters.stream().filter(adapter -> VirtualNetworkAdapterType.TRUNK.name().equals(adapter.getType())).collect(Collectors.toList());
    }

    public void setNetworkAdapters(List<HmdVirtualNetworkAdapter> networkAdapters) {
        this.networkAdapters = networkAdapters;
    }

    public HmdPartition getPartition() {
        return partition;
    }

    public void setPartition(HmdPartition partition) {
        this.partition = partition;
    }

    public HmdServerSharedProcessorPool getSharedProPool() {
        return sharedProPool;
    }

    public HmdServerSharedProcessorPool newSharedProPool() {
        this.sharedProPool = new HmdServerSharedProcessorPool();
        return sharedProPool;
    }

    public void setSharedProPool(HmdServerSharedProcessorPool sharedProPool) {
        this.sharedProPool = sharedProPool;
    }

    public List<HmdProfileHea> getHeas() {
        return heas;
    }

    public void setHeas(List<HmdProfileHea> heas) {
        this.heas = heas;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        HmdProfile that = (HmdProfile) o;
        return Objects.equals(uuid, that.uuid);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), uuid);
    }
}

