package com.vci.client.uif.engine.common;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
import com.vci.client.bof.ClientBusinessObject;
|
import com.vci.client.bof.ClientBusinessObjectOperation;
|
import com.vci.client.bof.ClientLinkObject;
|
import com.vci.corba.common.VCIError;
|
|
public abstract class AbstractDataNode implements IDataNode {
|
|
protected Object masterObject = null;
|
protected Map<String, String> valueMap = new HashMap<String, String>();
|
protected boolean isForward = true;
|
private Object customObject = null;
|
|
@Override
|
public Object getMaterObject() {
|
return this.masterObject;
|
}
|
|
@Override
|
public Map<String, String> getValueMap() {
|
return this.valueMap;
|
}
|
|
@Override
|
public Object getCustomObject() {
|
return this.customObject;
|
}
|
|
@Override
|
public void setCustomObject(Object customObject) {
|
this.customObject = customObject;
|
}
|
|
@Override
|
public void setMasterObject(Object masterObject) {
|
this.masterObject = masterObject;
|
}
|
|
@Override
|
public void setValueMap(Map<String, String> valueMap) {
|
this.valueMap = valueMap;
|
}
|
|
@Override
|
public boolean isForward() {
|
return this.isForward;
|
}
|
|
@Override
|
public void setForward(boolean isForward) {
|
this.isForward = isForward;
|
}
|
|
|
/**
|
* 返回节点对应的ClientBusinessObject对象。
|
* @return
|
*/
|
@Override
|
public ClientBusinessObject getClientBusinessObject(){
|
if(cbo == null){
|
toString();
|
}
|
return cbo;
|
}
|
|
private boolean cboIsLoaded = false;
|
private ClientBusinessObject cbo = null;
|
@Override
|
public String toString(){
|
/**
|
* toString() 执行策略
|
* 如果 ${id} != ${name},则返回 ${id}+空格+${name}
|
* 否则 返回 ${id}+空格+${desc}
|
*/
|
String res = "";
|
if(getMaterObject() instanceof ClientBusinessObject){
|
cbo = (ClientBusinessObject)getMaterObject();
|
} else if(getMaterObject() instanceof ClientLinkObject){
|
ClientLinkObject clo = (ClientLinkObject)getMaterObject();
|
if(!cboIsLoaded){
|
cbo = getBOByLO(clo);
|
cboIsLoaded = true;
|
}
|
}
|
if(cbo != null){
|
String id = getBOAttrVal(cbo, "ID");
|
res = id;
|
|
String name = getBOAttrVal(cbo, "NAME");
|
if(!id.equals(name)){
|
res += " " + name;
|
} else{
|
String desc = getBOAttrVal(cbo, "DESCRIPTION");
|
res += " " + desc;
|
}
|
}
|
return res;
|
}
|
|
private ClientBusinessObject getBOByLO(ClientLinkObject clo){
|
ClientBusinessObjectOperation operation = new ClientBusinessObjectOperation();
|
String oid = CBOHelper.getBusinessObjectOid(this);
|
String type = CBOHelper.getBusinessObjectType(this);
|
try {
|
cbo = operation.readBusinessObjectById(oid, type);
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
return cbo;
|
}
|
|
private String getBOAttrVal(ClientBusinessObject cbo, String attrName){
|
return cbo.getAttributeValue(attrName);
|
}
|
}
|