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

import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.Table;

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

@Table("hmd_partition")
public class HmdPartition extends HmdGenericEntity {
    @Column("server_id")
    private Long serverId; // 所属服务器id，对应hmd_server表的id字段
    @Column("name")
    private String name; // 名称
    @Column("status")
    private String status; // 状态
    @Column("uuid")
    private String uuid; // 唯一标识
    @Column("partition_id")
    private Integer partitionId; // 分区id
    @Column("type")
    private String type; // 分区类型: [AIX/Linux][Virtual IO Server][OS400]
    @Column("assign_all_resources")
    private Boolean assignAllResources; // 使用系统所有资源
    @Column("code")
    private String code; // 状态码
    @Column("ip")
    private String ip; // IP地址
    @Column("os_version")
    private String osVersion; // 操作系统
    @Column("led_on")
    private Boolean ledOn; // 提醒指示灯状态
    @Column("rmc_state")
    private String rmcState; // rmc连接状态
    @Column("allow_performance_collection")
    private Boolean allowPerformanceCollection; // 允许性能收集
    @Column("conn_monitor_enabled")
    private Boolean connMonitorEnabled; // 开启连接监视
    @Column("error_path_report")
    private Boolean errorPathReport; // 开启冗余错误路径报告
    @Column("service_partition")
    private Boolean servicePartition; // 开启服务分区
    @Column("processor_compatibility_mode")
    private String processorCompatibilityMode; // 当前处理器兼容模式
    @Column("pending_processor_compatibility_mode")
    private String pendingProcessorCompatibilityMode; // 下一次处理器兼容模式
    @Column("current_max_virtual_io_slots")
    private Integer currentMaxVirtualIoSlots; // 最大虚拟插槽数
    @Column("key_lock_position")
    private String keyLockPosition; // 键锁位置
    @Column("current_profile_sync")
    private String currentProfileSync; // 开启同步的概要文件
    @Column("install_status")
    private String installStatus; // 系统安装状态
    @Column("install_percent")
    private Integer installPercent; // 系统安装进度
    @Column("sharing_mode")
    private String sharingMode; // 处理器共享模式
    @Column("pool_id")
    private Long poolId; // 共享处理器池id，关联hmd_server_shared_processor_pool表的id字段
    @Column("min_units")
    private Float minUnits; // 最小处理器单元数
    @Column("curr_units")
    private Float currUnits; // 当前处理器单元数
    @Column("max_units")
    private Float maxUnits; // 最大处理器单元数
    @Column("min_virtual_processors")
    private Integer minVirtualProcessors; // 最小虚拟处理器核数
    @Column("curr_virtual_processors")
    private Integer currVirtualProcessors; // 当前虚拟处理器核数
    @Column("max_virtual_processors")
    private Integer maxVirtualProcessors; // 最大虚拟处理器核数
    @Column("min_processors")
    private Integer minProcessors; // 最小专用处理器数
    @Column("curr_processors")
    private Integer currProcessors; // 当前专用处理器数
    @Column("max_processors")
    private Integer maxProcessors; // 最大专用处理器数
    @Column("min_memory")
    private Integer minMemory; // 最小内存mb
    @Column("curr_memory")
    private Integer currMemory; // 当前内存mb
    @Column("max_memory")
    private Integer maxMemory; // 最大内存mb
    @Column("min_page_count")
    private Integer minPageCount; // 最小内存页数
    @Column("curr_page_count")
    private Integer currPageCount; // 当前内存页数
    @Column("max_page_count")
    private Integer maxPageCount; // 最大内存页数
    @Column("bsr_arrays")
    private Integer bsrArrays; // 屏障同步寄存器

    private List<HmdProfile> profiles; // 概要文件
    private List<HmdVirtualIoAdapter> ioAdapters; // 虚拟io适配器
    private List<HmdVirtualNetworkAdapter> clientNetworkAdapters; // 虚拟网络适配器
    private List<HmdVirtualNetworkAdapter> trunkNetworkAdapters; // 桥接网络适配器
    private List<HmdVirtualScsiAdapter> scsiAdapters; // 虚拟scsi适配器
    private List<HmdVirtualFabricAdapter> fabricAdapters; // 虚拟光纤适配器
    private List<HmdViosPhysicalDisk> physicalDisks; // 物理磁盘
    private List<HmdViosVirtualCd> virtualCds; // 虚拟光学设备
    private List<HmdViosVolumeGroup> volumeGroups; // 存储池
    private List<HmdViosSea> seas; // 共享以太网适配器
    private List<HmdViosPhysicalEthernetAdapter> physicalEthernetAdapters; // 物理网卡
    private List<HmdViosPhysicalFabricAdapter> physicalFabricAdapters; // 物理光卡

    private HmdServer server; // 所属服务器
    private HmdServerSharedProcessorPool processorPool; // 使用的共享处理器池
    private HmdProfile associatedProfile; // 关联的概要文件

    public Long getServerId() {
        return serverId;
    }

    public void setServerId(Long serverId) {
        this.serverId = serverId;
    }

    public String getUuid() {
        return uuid;
    }

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

    public Integer getPartitionId() {
        return partitionId;
    }

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

    public String getType() {
        return type;
    }

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

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getOsVersion() {
        return osVersion;
    }

    public void setOsVersion(String osVersion) {
        this.osVersion = osVersion;
    }

    public Boolean getLedOn() {
        return ledOn;
    }

    public void setLedOn(Boolean ledOn) {
        this.ledOn = ledOn;
    }

    public String getRmcState() {
        return rmcState;
    }

    public void setRmcState(String rmcState) {
        this.rmcState = rmcState;
    }

    public Boolean getAllowPerformanceCollection() {
        return allowPerformanceCollection;
    }

    public void setAllowPerformanceCollection(Boolean allowPerformanceCollection) {
        this.allowPerformanceCollection = allowPerformanceCollection;
    }

    public Boolean getConnMonitorEnabled() {
        return connMonitorEnabled;
    }

    public void setConnMonitorEnabled(Boolean connMonitorEnabled) {
        this.connMonitorEnabled = connMonitorEnabled;
    }

    public Boolean getErrorPathReport() {
        return errorPathReport;
    }

    public void setErrorPathReport(Boolean errorPathReport) {
        this.errorPathReport = errorPathReport;
    }

    public Boolean getServicePartition() {
        return servicePartition;
    }

    public void setServicePartition(Boolean servicePartition) {
        this.servicePartition = servicePartition;
    }

    public String getProcessorCompatibilityMode() {
        return processorCompatibilityMode;
    }

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

    public String getPendingProcessorCompatibilityMode() {
        return pendingProcessorCompatibilityMode;
    }

    public void setPendingProcessorCompatibilityMode(String pendingProcessorCompatibilityMode) {
        this.pendingProcessorCompatibilityMode = pendingProcessorCompatibilityMode;
    }

    public Integer getCurrentMaxVirtualIoSlots() {
        return currentMaxVirtualIoSlots;
    }

    public void setCurrentMaxVirtualIoSlots(Integer currentMaxVirtualIoSlots) {
        this.currentMaxVirtualIoSlots = currentMaxVirtualIoSlots;
    }

    public String getKeyLockPosition() {
        return keyLockPosition;
    }

    public void setKeyLockPosition(String keyLockPosition) {
        this.keyLockPosition = keyLockPosition;
    }

    public String getCurrentProfileSync() {
        return currentProfileSync;
    }

    public void setCurrentProfileSync(String currentProfileSync) {
        this.currentProfileSync = currentProfileSync;
    }

    public String getInstallStatus() {
        return installStatus;
    }

    public void setInstallStatus(String installStatus) {
        this.installStatus = installStatus;
    }

    public Integer getInstallPercent() {
        return installPercent;
    }

    public void setInstallPercent(Integer installPercent) {
        this.installPercent = installPercent;
    }

    public String getSharingMode() {
        return sharingMode;
    }

    public void setSharingMode(String sharingMode) {
        this.sharingMode = sharingMode;
    }

    public Long getPoolId() {
        return poolId;
    }

    public void setPoolId(Long poolId) {
        this.poolId = poolId;
    }

    public Float getMinUnits() {
        return minUnits;
    }

    public void setMinUnits(Float minUnits) {
        this.minUnits = minUnits;
    }

    public Float getCurrUnits() {
        return currUnits;
    }

    public void setCurrUnits(Float currUnits) {
        this.currUnits = currUnits;
    }

    public Float getMaxUnits() {
        return maxUnits;
    }

    public void setMaxUnits(Float maxUnits) {
        this.maxUnits = maxUnits;
    }

    public Integer getMinVirtualProcessors() {
        return minVirtualProcessors;
    }

    public void setMinVirtualProcessors(Integer minVirtualProcessors) {
        this.minVirtualProcessors = minVirtualProcessors;
    }

    public Integer getCurrVirtualProcessors() {
        return currVirtualProcessors;
    }

    public void setCurrVirtualProcessors(Integer currVirtualProcessors) {
        this.currVirtualProcessors = currVirtualProcessors;
    }

    public Integer getMaxVirtualProcessors() {
        return maxVirtualProcessors;
    }

    public void setMaxVirtualProcessors(Integer maxVirtualProcessors) {
        this.maxVirtualProcessors = maxVirtualProcessors;
    }

    public Integer getMinProcessors() {
        return minProcessors;
    }

    public void setMinProcessors(Integer minProcessors) {
        this.minProcessors = minProcessors;
    }

    public Integer getCurrProcessors() {
        return currProcessors;
    }

    public void setCurrProcessors(Integer currProcessors) {
        this.currProcessors = currProcessors;
    }

    public Integer getMaxProcessors() {
        return maxProcessors;
    }

    public void setMaxProcessors(Integer maxProcessors) {
        this.maxProcessors = maxProcessors;
    }

    public Integer getMinMemory() {
        return minMemory;
    }

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

    public Integer getCurrMemory() {
        return currMemory;
    }

    public void setCurrMemory(Integer currMemory) {
        this.currMemory = currMemory;
    }

    public Integer getMaxMemory() {
        return maxMemory;
    }

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

    public Integer getMinPageCount() {
        return minPageCount;
    }

    public void setMinPageCount(Integer minPageCount) {
        this.minPageCount = minPageCount;
    }

    public Integer getCurrPageCount() {
        return currPageCount;
    }

    public void setCurrPageCount(Integer currPageCount) {
        this.currPageCount = currPageCount;
    }

    public Integer getMaxPageCount() {
        return maxPageCount;
    }

    public void setMaxPageCount(Integer maxPageCount) {
        this.maxPageCount = maxPageCount;
    }

    public Integer getBsrArrays() {
        return bsrArrays;
    }

    public void setBsrArrays(Integer bsrArrays) {
        this.bsrArrays = bsrArrays;
    }

    public String getName() {
        return name;
    }

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

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public List<HmdProfile> getProfiles() {
        return profiles;
    }

    public void setProfiles(List<HmdProfile> profiles) {
        this.profiles = profiles;
    }

    public void setProfileUrls(List<String> urls) {
        this.profiles = urls.stream().map(url -> {
            HmdProfile profile = new HmdProfile();
            profile.setUrl(url);
            return profile;
        }).collect(Collectors.toList());
    }

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

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

    public void setIoAdapterUrls(List<String> urls) {
        this.ioAdapters = urls.stream().map(url -> {
            HmdVirtualIoAdapter adapter = new HmdVirtualIoAdapter();
            adapter.setUrl(url);
            return adapter;
        }).collect(Collectors.toList());
    }

    public List<HmdVirtualNetworkAdapter> getClientNetworkAdapters() {
        return clientNetworkAdapters;
    }

    public void setClientNetworkAdapters(List<HmdVirtualNetworkAdapter> clientNetworkAdapters) {
        this.clientNetworkAdapters = clientNetworkAdapters;
    }

    public void setClientNetworkAdapterUrls(List<String> urls) {
        this.clientNetworkAdapters = urls.stream().map(url -> {
            HmdVirtualNetworkAdapter adapter = new HmdVirtualNetworkAdapter();
            adapter.setUrl(url);
            return adapter;
        }).collect(Collectors.toList());
    }

    public List<HmdVirtualNetworkAdapter> getTrunkNetworkAdapters() {
        return trunkNetworkAdapters;
    }

    public void setTrunkNetworkAdapters(List<HmdVirtualNetworkAdapter> trunkNetworkAdapters) {
        this.trunkNetworkAdapters = trunkNetworkAdapters;
    }

    public void setTrunkNetworkAdapterUrls(List<String> urls) {
        this.trunkNetworkAdapters = urls.stream().map(url -> {
            HmdVirtualNetworkAdapter adapter = new HmdVirtualNetworkAdapter();
            adapter.setUrl(url);
            return adapter;
        }).collect(Collectors.toList());
    }

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

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

    public void setScsiAdapterUrls(List<String> urls) {
        this.scsiAdapters = urls.stream().map(url -> {
            HmdVirtualScsiAdapter adapter = new HmdVirtualScsiAdapter();
            adapter.setUrl(url);
            return adapter;
        }).collect(Collectors.toList());
    }

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

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

    public void setFabricAdapterUrls(List<String> urls) {
        this.fabricAdapters = urls.stream().map(url -> {
            HmdVirtualFabricAdapter adapter = new HmdVirtualFabricAdapter();
            adapter.setUrl(url);
            return adapter;
        }).collect(Collectors.toList());
    }

    public List<HmdViosPhysicalDisk> getPhysicalDisks() {
        return physicalDisks;
    }

    public void setPhysicalDisks(List<HmdViosPhysicalDisk> physicalDisks) {
        this.physicalDisks = physicalDisks;
    }

    public void setPhysicalDiskUrls(List<String> urls) {
        this.physicalDisks = urls.stream().map(url -> {
            HmdViosPhysicalDisk disk = new HmdViosPhysicalDisk();
            disk.setUrl(url);
            return disk;
        }).collect(Collectors.toList());
    }

    public List<HmdViosVirtualCd> getVirtualCds() {
        return virtualCds;
    }

    public void setVirtualCds(List<HmdViosVirtualCd> virtualCds) {
        this.virtualCds = virtualCds;
    }

    public void setVirtualCdUrls(List<String> urls) {
        this.virtualCds = urls.stream().map(url -> {
            HmdViosVirtualCd disk = new HmdViosVirtualCd();
            disk.setUrl(url);
            return disk;
        }).collect(Collectors.toList());
    }

    public List<HmdViosVolumeGroup> getVolumeGroups() {
        return volumeGroups;
    }

    public void setVolumeGroups(List<HmdViosVolumeGroup> volumeGroups) {
        this.volumeGroups = volumeGroups;
    }

    public void setVolumeGroupUrls(List<String> urls) {
        this.volumeGroups = urls.stream().map(url -> {
            HmdViosVolumeGroup group = new HmdViosVolumeGroup();
            group.setUrl(url);
            return group;
        }).collect(Collectors.toList());
    }

    public List<HmdViosSea> getSeas() {
        return seas;
    }

    public void setSeas(List<HmdViosSea> seas) {
        this.seas = seas;
    }

    public void setSeaUrls(List<String> urls) {
        this.seas = urls.stream().map(url -> {
            HmdViosSea sea = new HmdViosSea();
            sea.setUrl(url);
            return sea;
        }).collect(Collectors.toList());
    }

    public List<HmdViosPhysicalEthernetAdapter> getPhysicalEthernetAdapters() {
        return physicalEthernetAdapters;
    }

    public void setPhysicalEthernetAdapters(List<HmdViosPhysicalEthernetAdapter> physicalEthernetAdapters) {
        this.physicalEthernetAdapters = physicalEthernetAdapters;
    }

    public void setPhysicalEthernetAdapterUrls(List<String> urls) {
        this.physicalEthernetAdapters = urls.stream().map(url -> {
            HmdViosPhysicalEthernetAdapter adapter = new HmdViosPhysicalEthernetAdapter();
            adapter.setUrl(url);
            return adapter;
        }).collect(Collectors.toList());
    }

    public List<HmdViosPhysicalFabricAdapter> getPhysicalFabricAdapters() {
        return physicalFabricAdapters;
    }

    public void setPhysicalFabricAdapters(List<HmdViosPhysicalFabricAdapter> physicalFabricAdapters) {
        this.physicalFabricAdapters = physicalFabricAdapters;
    }

    public void setPhysicalFabricAdapterUrls(List<String> urls) {
        this.physicalFabricAdapters = urls.stream().map(url -> {
            HmdViosPhysicalFabricAdapter adapter = new HmdViosPhysicalFabricAdapter();
            adapter.setUrl(url);
            return adapter;
        }).collect(Collectors.toList());
    }

    public HmdProfile newAssociatedProfile() {
        this.associatedProfile = new HmdProfile();
        return associatedProfile;
    }

    public HmdProfile getAssociatedProfile() {
        return associatedProfile;
    }

    public void setAssociatedProfile(HmdProfile associatedProfile) {
        this.associatedProfile = associatedProfile;
    }

    public HmdServerSharedProcessorPool getProcessorPool() {
        return processorPool;
    }

    public HmdServerSharedProcessorPool newProcessorPool() {
        processorPool = new HmdServerSharedProcessorPool();
        return processorPool;
    }

    public void setProcessorPool(HmdServerSharedProcessorPool processorPool) {
        this.processorPool = processorPool;
    }

    public HmdServer getServer() {
        return server;
    }

    public void setServer(HmdServer server) {
        this.server = server;
    }

    public HmdServer newServer() {
        this.server = new HmdServer();
        return server;
    }

    public Boolean getAssignAllResources() {
        return assignAllResources;
    }

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

    @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;
        }
        HmdPartition that = (HmdPartition) o;
        return Objects.equals(uuid, that.uuid);
    }

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

    @Override
    public String toString() {
        return String.format("%s[%s][%s]: status[%s], cpu[%f*%d/%d], memory[%s], ip[%s]",
            name, uuid, partitionId, status, currUnits, currVirtualProcessors, currProcessors, maxMemory, ip
        );
    }
}

