package com.vci.web.pageModel; import org.springframework.util.CollectionUtils; import com.vci.client.bof.ClientBusinessObject; import com.vci.client.bof.ClientLinkObject; import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; /** * 操作的业务类型和链接类型的数据 * @author weidy * @date 2021-12-2 */ public class BatchCBO { /** * 空的业务类型数组 */ private ClientBusinessObject[] nullCboArray = new ClientBusinessObject[0]; /** * 空的链接类型数组 */ private ClientLinkObject[] nullCloArray = new ClientLinkObject[0]; /** * 创建的业务类型 */ private Set createCbos = new HashSet(); /** * 创建的链接类型 */ private Set createClos = new HashSet(); /** * 更新的业务类型 */ private Set updateCbos = new HashSet(); /** * 更新的链接类型 */ private Set updateClos = new HashSet(); /** * 删除业务类型 */ private Set deleteCbos = new HashSet(); /** * 删除的链接类型 */ private Set deleteClos = new HashSet(); /** * 来源数据集合 */ private Set sourceObjectList = new HashSet(); /** * 来源数据 */ private Object sourceObject = new HashSet(); /** * 从其他的拷贝 * @param otherCBO 其他的信息 */ public void copyFromOther(BatchCBO otherCBO){ if(otherCBO!=null){ if(!CollectionUtils.isEmpty(otherCBO.getCreateCbos())){ getCreateCbos().addAll(otherCBO.getCreateCbos()); } if(!CollectionUtils.isEmpty(otherCBO.getUpdateCbos())){ getUpdateCbos().addAll(otherCBO.getUpdateCbos()); } if(!CollectionUtils.isEmpty(otherCBO.getDeleteCbos())){ getDeleteCbos().addAll(otherCBO.getDeleteCbos()); } if(!CollectionUtils.isEmpty(otherCBO.getCreateClos())){ getCreateClos().addAll(otherCBO.getCreateClos()); } if(!CollectionUtils.isEmpty(otherCBO.getUpdateClos())){ getUpdateClos().addAll(otherCBO.getUpdateClos()); } if(!CollectionUtils.isEmpty(otherCBO.getDeleteClos())){ getDeleteClos().addAll(otherCBO.getDeleteClos()); } } } public void addCreateCbo(ClientBusinessObject cbo){ this.createCbos.add(cbo); } public void addCreateClo(ClientLinkObject clo){ this.createClos.add(clo); } public void addUpdateCbo(ClientBusinessObject cbo){ this.updateCbos.add(cbo); } public void addUpdateClo(ClientLinkObject clo){ this.updateClos.add(clo); } public void addDeleteCbo(ClientBusinessObject cbo){ this.deleteCbos.add(cbo); } public void addDeleteClo(ClientLinkObject clo){ this.deleteClos.add(clo); } public ClientBusinessObject[] getCreateCboArray(){ if( this.createCbos == null){ this.createCbos = new HashSet(); } return this.createCbos.stream().sorted(((o1, o2) -> Math.toIntExact(o1.getCreateTime() - o2.getCreateTime()))).collect(Collectors.toList()).toArray(nullCboArray); } public ClientLinkObject[] getCreateCloArray(){ if( this.createClos == null){ this.createClos = new HashSet(); } return this.createClos.stream().sorted(((o1, o2) -> Math.toIntExact(o1.getCreateTime() - o2.getCreateTime()))).collect(Collectors.toList()).toArray(nullCloArray); } public ClientBusinessObject[] getUpdateCboArray(){ if( this.updateCbos == null){ this.updateCbos = new HashSet(); } return this.updateCbos.stream().sorted(((o1, o2) -> Math.toIntExact(o1.getCreateTime() - o2.getCreateTime()))).collect(Collectors.toList()).toArray(nullCboArray); } public ClientLinkObject[] getUpdateCloArray(){ if( this.updateClos == null){ this.updateClos = new HashSet(); } return this.updateClos.stream().sorted(((o1, o2) -> Math.toIntExact(o1.getCreateTime() - o2.getCreateTime()))).collect(Collectors.toList()).toArray(nullCloArray); } public ClientBusinessObject[] getDeleteCboArray(){ if( this.deleteCbos == null){ this.deleteCbos = new HashSet(); } return this.deleteCbos.toArray(nullCboArray); } public ClientLinkObject[] getDeleteCloArray(){ if( this.deleteClos == null){ this.deleteClos = new HashSet(); } return this.deleteClos.toArray(nullCloArray); } public Set getCreateCbos() { return createCbos; } public void setCreateCbos(Set createCbos) { this.createCbos = createCbos; } public Set getCreateClos() { return createClos; } public void setCreateClos(Set createClos) { this.createClos = createClos; } public Set getUpdateCbos() { return updateCbos; } public void setUpdateCbos(Set updateCbos) { this.updateCbos = updateCbos; } public Set getUpdateClos() { return updateClos; } public void setUpdateClos(Set updateClos) { this.updateClos = updateClos; } public Set getDeleteCbos() { return deleteCbos; } public void setDeleteCbos(Set deleteCbos) { this.deleteCbos = deleteCbos; } public Set getDeleteClos() { return deleteClos; } public void setDeleteClos(Set deleteClos) { this.deleteClos = deleteClos; } public Set getSourceObjectList() { return sourceObjectList; } public void setSourceObjectList(Set sourceObjectList) { this.sourceObjectList = sourceObjectList; } public Object getSourceObject() { return sourceObject; } public void setSourceObject(Object sourceObject) { this.sourceObject = sourceObject; } }