package com.vci.client.uif.engine.client.compare.dialog.treenode;
|
|
import java.util.ArrayList;
|
import java.util.HashSet;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Set;
|
import java.util.Vector;
|
|
import javax.swing.tree.DefaultMutableTreeNode;
|
|
import com.vci.client.bof.ClientBusinessObject;
|
import com.vci.client.bof.ClientLinkObject;
|
import com.vci.client.uif.engine.client.compare.enumeration.CompareState;
|
import com.vci.client.uif.engine.common.CBOHelper;
|
|
/**
|
* 系统业务对象节点
|
*
|
* 对于系统的业务对象,存在不同的链接关系下使用同一个业务对象的情况
|
* 所以在创建的时候确定不同的TreeNodeObject使用相同的业务对象时,对象
|
* 所引用的主对象是同一个对象,这样就可以保证一个节点修改时,所有使用
|
* 该对象的节点都得到了修改。
|
* @author VCI-STGK006
|
*
|
*/
|
public class BusinessTreeNodeObject implements TreeNodeObject {
|
|
/**
|
* 存储使用当前节点的树节点对象
|
* 当树中创建新的节点时已存储的对象可能被释放
|
*/
|
private Set<DefaultMutableTreeNode> ownedNodes = new HashSet<DefaultMutableTreeNode>();
|
|
/**
|
* 当前节点所有子节点对象列表
|
*/
|
private List<TreeNodeObject> childList = new ArrayList<TreeNodeObject>();
|
|
/**
|
* 当前节点相对节点
|
*/
|
private TreeNodeObject relativeNode = null;
|
|
/**
|
* 节点主对象
|
*/
|
private MainObject mo = null;
|
|
/**
|
* 节点关系对象
|
*/
|
private RelationObject ro = null;
|
|
/**
|
* 是否是根节点
|
*/
|
private boolean isRoot = false;
|
|
/**
|
* 节点比较状态
|
*/
|
private CompareState cs = CompareState.SAME;
|
|
/**
|
* 构造器
|
*/
|
public BusinessTreeNodeObject() {
|
this.mo = new MainObject();
|
this.ro = new RelationObject();
|
}
|
|
/**
|
* 构造器
|
* @param mo 主对象
|
* @param ro 关系对象
|
*/
|
public BusinessTreeNodeObject(MainObject mo, RelationObject ro) {
|
this.mo = mo;
|
this.ro = ro;
|
}
|
|
@Override
|
public boolean isRoot() {
|
return this.isRoot;
|
}
|
|
/**
|
* 得到主对象或关系对象所有属性<br>
|
* <br>
|
* 此方法总是返回关系或业务对象中hisAttrValList中的属性<br>
|
*
|
* @return 当执行类型对象属性不存时返回""
|
*/
|
@Override
|
public Map<String, String> attributes(int type) {
|
if(type == TreeNodeObject.MAINOBJECT) {
|
if(this.getMo().getCbo() == null) {
|
return null;
|
}
|
return CBOHelper.getBOValueMap(
|
this.getMo().getCbo().getBusinessObject());
|
} else {
|
if(this.getRo().getClo() == null) {
|
return null;
|
}
|
return CBOHelper.getLOValueMap(this.getRo().getClo().getLinkObject());
|
}
|
}
|
|
/**
|
* 得到主对象或关系对象属性<br>
|
* <br>
|
* 方法首先在newAttrValList中查找属性是否存在,如果不存在则到hisAttrValList中查找
|
*
|
* @return 当执行类型对象属性不存时返回""
|
*/
|
@Override
|
public String getAttribute(String key, int type) {
|
if(type == TreeNodeObject.MAINOBJECT) {
|
if(this.getMo().getCbo() == null) {
|
return null;
|
}
|
return this.getMo().getCbo().getAttributeValue(key);
|
} else {
|
if(this.getRo().getClo() == null) {
|
return null;
|
}
|
return this.getRo().getClo().getAttributeValue(key);
|
}
|
}
|
|
@Override
|
public String getKey() {
|
return this.ro.getKey() + "##" + this.mo.getKey();
|
}
|
|
@Override
|
public ClientBusinessObject getMainObject() {
|
return this.getMo().getCbo();
|
}
|
|
@Override
|
public String getMainObjectKey() {
|
return this.mo.getKey();
|
}
|
|
@Override
|
public ClientLinkObject getRelationObject() {
|
return this.getRo().getClo();
|
}
|
|
@Override
|
public String getRelationObjectKey() {
|
return this.ro.getKey();
|
}
|
|
@Override
|
public CompareState getCompareState() {
|
return this.cs;
|
}
|
|
@Override
|
public void setCompareState(CompareState cs) {
|
this.cs = cs;
|
}
|
|
@Override
|
public void setOwnedTreeNode(DefaultMutableTreeNode dmtn) {
|
this.ownedNodes.add(dmtn);
|
}
|
|
@Override
|
public void removeOwnedTreeNode(DefaultMutableTreeNode dmtn) {
|
this.ownedNodes.remove(dmtn);
|
}
|
|
@Override
|
public Set<DefaultMutableTreeNode> getOwnedTreeNode() {
|
return this.ownedNodes;
|
}
|
|
@Override
|
public void setRelativeTreeNodeObject(TreeNodeObject relativeNode) {
|
this.relativeNode = relativeNode;
|
}
|
|
@Override
|
public void setChildNodeList(TreeNodeObject tno) {
|
if(!this.childList.contains(tno)) {
|
this.childList.add(tno);
|
}
|
}
|
|
@Override
|
public void removeChildNode(TreeNodeObject tno) {
|
this.childList.remove(tno);
|
}
|
|
@Override
|
public List<TreeNodeObject> getChildNodeList() {
|
return this.childList;
|
}
|
|
public void setMo(MainObject mo) {
|
this.mo = mo;
|
}
|
|
public MainObject getMo() {
|
return this.mo;
|
}
|
|
public void setRo(RelationObject ro) {
|
this.ro = ro;
|
}
|
|
public RelationObject getRo() {
|
return this.ro;
|
}
|
|
public void setRelationKey(String key) {
|
this.ro.setKey(key);
|
}
|
|
public void setRelationClo(ClientLinkObject clo) {
|
this.ro.setClo(clo);
|
}
|
|
public void setMainKey(String key) {
|
this.mo.setKey(key);
|
}
|
|
public void setMainCbo(ClientBusinessObject cbo) {
|
this.mo.setCbo(cbo);
|
}
|
|
/**
|
* 设置是否为根节点
|
* @param isRoot
|
*/
|
public void setIsRoot(boolean isRoot) {
|
this.isRoot = isRoot;
|
}
|
|
@Override
|
public String toString() {
|
if(this.cs != CompareState.ISNULL) {
|
return this.mo.getCbo().getId()
|
+ " " + this.mo.getCbo().getName()
|
+ " " + this.mo.getCbo().getRevisionValue();
|
}
|
if(this.relativeNode.getCompareState() != CompareState.ISNULL) {
|
return this.relativeNode.toString();
|
}
|
return " ";
|
}
|
|
/**
|
* 主对象
|
* @author VCI-STGK006
|
*
|
*/
|
public class MainObject {
|
|
/**
|
* 主对象标识
|
*/
|
private String key;
|
|
/**
|
* 主对象
|
*/
|
private ClientBusinessObject cbo;
|
|
/**
|
* 使用当前对象的所有TreeNodeObject
|
*/
|
private Vector<BusinessTreeNodeObject> ownedNodeObject = new Vector<BusinessTreeNodeObject>();
|
|
/**
|
* 构造器
|
*/
|
public MainObject() {}
|
/**
|
* 构造器
|
* @param key 主对象标识
|
* @param cbo 主对象
|
*/
|
public MainObject(String key, ClientBusinessObject cbo) {
|
this.key = key;
|
this.cbo = cbo;
|
}
|
|
public Vector<BusinessTreeNodeObject> getOwnedNodeObject() {
|
return ownedNodeObject;
|
}
|
|
public void setOwnedNodeObject(BusinessTreeNodeObject ownedNodeObject) {
|
this.ownedNodeObject.add(ownedNodeObject);
|
}
|
|
public String getKey() {
|
return key;
|
}
|
|
public void setKey(String key) {
|
this.key = key;
|
}
|
|
public ClientBusinessObject getCbo() {
|
return cbo;
|
}
|
|
public void setCbo(ClientBusinessObject cbo) {
|
this.cbo = cbo;
|
}
|
}
|
|
/**
|
* 关系对象
|
* @author VCI-STGK006
|
*
|
*/
|
public class RelationObject {
|
|
/**
|
* 所属父节点主对象标识
|
*/
|
private String key;
|
|
/**
|
* 关系对象
|
*/
|
private ClientLinkObject clo;
|
|
/**
|
* 构造器
|
*/
|
public RelationObject(){}
|
|
/**
|
* 构造器
|
* @param parentKey 所属父节点主对象标识
|
* @param clo 关系对象
|
*/
|
public RelationObject(String parentKey, ClientLinkObject clo) {
|
this.key = parentKey;
|
this.clo = clo;
|
}
|
|
public String getKey() {
|
return key;
|
}
|
|
public void setKey(String key) {
|
this.key = key;
|
}
|
|
public ClientLinkObject getClo() {
|
return clo;
|
}
|
|
public void setClo(ClientLinkObject clo) {
|
this.clo = clo;
|
}
|
}
|
}
|