package com.vci.client.bof;
|
|
import java.util.Date;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import com.vci.corba.common.data.VCIInvocationInfo;
|
import com.vci.client.LogonApplication;
|
import com.vci.client.omd.linktype.itf.LinkTypeInterface;
|
import com.vci.client.omd.linktype.itf.LinkTypeInterfaceImpl;
|
import com.vci.common.annotaion.MethodTypeAnnotation;
|
import com.vci.common.utility.ObjectUtility;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.omd.atm.AttribItem;
|
import com.vci.corba.omd.data.BusinessObject;
|
import com.vci.corba.omd.data.LinkObject;
|
import com.vci.mw.ClientContextVariable;
|
import com.vci.mw.LaunchModeEnum;
|
|
public class ClientLinkObjectOperation {
|
|
|
private String getUserName() {
|
String username = "";
|
if(ClientContextVariable.getClientLanuchMode().equals(LaunchModeEnum.WebApp)){
|
VCIInvocationInfo vcii = ClientContextVariable.getInvocationInfo();
|
if(vcii !=null){
|
username = ClientContextVariable.getInvocationInfo().userName;
|
}
|
}
|
if(StringUtils.isEmpty(username)){
|
username = LogonApplication.getUserEntityObject().getUserName();
|
}
|
return username;
|
}
|
public ClientLinkObject createLinkObject(String loName) throws VCIError {
|
return createLinkObject(loName, getUserName() );
|
}
|
|
/**
|
* 构建空的链接对象
|
* @param loName, 链接类型名称
|
* @param userName, 创建者
|
* @return 空的链接对象
|
* @throws VCIError
|
*/
|
public ClientLinkObject createLinkObject(String loName, String userName) throws VCIError {
|
ClientLinkObject clo = new ClientLinkObject();
|
clo.setOid(ObjectUtility.getNewObjectID36());
|
clo.setCreator(userName);
|
clo.setCreateTime(System.currentTimeMillis());
|
clo.setLastModifier(userName);
|
clo.setLastModifyTime(System.currentTimeMillis());
|
clo.setFromOid("");
|
clo.setFromRevisionOid("");
|
clo.setFromNameOid("");
|
clo.setFromBTMName("");
|
clo.setToOid("");
|
clo.setToRevisionOid("");
|
clo.setToNameOid("");
|
clo.setToBTMName("");
|
clo.setLoName(loName);
|
//属性初始值设置
|
initLinkTypeAttributeValue(clo, loName);
|
return clo;
|
}
|
|
private void initLinkTypeAttributeValue(ClientLinkObject clo, String linkTypeName) throws VCIError {
|
LinkTypeInterface ltws = new LinkTypeInterfaceImpl();
|
AttribItem[] items = ltws.getNonSystemAttributesByLinkTypeName(linkTypeName);
|
for (AttribItem item : items) {
|
clo.setAttributeValue(item.name, item.defValue);
|
}
|
}
|
|
/**
|
* 保持link对象以及link对象关联的BO对象
|
* @param cbos, 业务对象数组
|
* @param clo, 链接对象
|
* @return 操作成功返回true,操作失败返回false
|
* @throws VCIError
|
*/
|
public boolean saveLinkObject(ClientBusinessObject[] cbos, ClientLinkObject clo) throws VCIError {
|
BusinessObject[] bos = new BusinessObject[cbos.length];
|
for (int i = 0; i < cbos.length; i++) {
|
cbos[i].dealBusinessObjectNullValue();
|
bos[i] = cbos[i].getBusinessObject();
|
}
|
|
clo.dealLinkObjectNullValue();
|
boolean rs = BOFactoryClient.getBOFactoryService().createBusinessObjectWithLink(bos, clo.getLinkObject());
|
return rs;
|
}
|
|
/**
|
* 更改LO对象的属性信息
|
* @param clo, 链接对象
|
* @return 操作成功返回true,操作失败返回false
|
* @throws VCIError
|
*/
|
public boolean updateLinkObject(ClientLinkObject clo) throws VCIError {
|
clo.dealLinkObjectNullValue();
|
|
boolean rs = BOFactoryClient.getBOFactoryService().updateLinkObject(clo.getLinkObject());
|
return rs;
|
}
|
|
/**
|
* 批量更改LO对象的属性信息
|
* @param clos, 链接对象数组
|
* @return 操作成功返回true,操作失败返回false
|
* @throws VCIError
|
*/
|
@MethodTypeAnnotation(getMethodType="batch")
|
public boolean batchUpdateLinkObject(ClientLinkObject[] clos) throws VCIError {
|
LinkObject[] los = new LinkObject[clos.length];
|
for (int i = 0; i < clos.length; i++) {
|
clos[i].dealLinkObjectNullValue();
|
los[i] = clos[i].getLinkObject();
|
}
|
|
boolean rs = BOFactoryClient.getBOFactoryService().batchUpdateLinkObject(los);
|
return rs;
|
}
|
|
/**
|
* 删除LO对象
|
* @param clo, 链接对象
|
* @return 操作成功返回true,操作失败返回false
|
* @throws VCIError
|
*/
|
public boolean deleteLinkObject(ClientLinkObject clo) throws VCIError {
|
clo.dealLinkObjectNullValue();
|
boolean rs = BOFactoryClient.getBOFactoryService().deleteLinkObject(clo.getLinkObject());
|
return rs;
|
}
|
|
/**
|
* 批量删除LO对象
|
* @param clos, 链接对象数组
|
* @return 操作成功返回true,操作失败返回false
|
* @throws VCIError
|
*/
|
@MethodTypeAnnotation(getMethodType="batch")
|
public boolean batchdDeleteLinkObject(ClientLinkObject[] clos) throws VCIError {
|
LinkObject[] los = new LinkObject[clos.length];
|
for (int i = 0; i < clos.length; i++) {
|
clos[i].dealLinkObjectNullValue();
|
los[i] = clos[i].getLinkObject();
|
}
|
|
boolean rs = BOFactoryClient.getBOFactoryService().batchDeleteLinkObject(los);
|
return rs;
|
}
|
|
/**
|
* 根据from端业务对象以及链接类型获取其to端的业务对象
|
* @param cbo, from端业务对象
|
* @param loName, 链接类型名称
|
* @return to端业务对象数组
|
* @throws VCIError
|
*/
|
public ClientLinkObject[] readLinkObjectByFromBO(ClientBusinessObject cbo, String loName) throws VCIError {
|
cbo.dealBusinessObjectNullValue();
|
LinkObject[] rslinkObjects = BOFactoryClient.getBOFactoryService().readLinkObjectByFromBO(cbo.getBusinessObject(), loName);
|
int len = rslinkObjects.length;
|
ClientLinkObject[] clos = new ClientLinkObject[len];
|
for (int i = 0; i < clos.length; i++) {
|
clos[i] = new ClientLinkObject();
|
clos[i].setLinkObject(rslinkObjects[i]);
|
}
|
return clos;
|
}
|
|
/**
|
* 根据link oid 和 type获取对应链接对象的详细信息
|
* @param oid, 业务对象oid
|
* @param loName, 链接类型名称
|
* @return 链接对象
|
* @throws VCIError
|
*/
|
public ClientLinkObject readLinkObjectById(String oid, String loName) throws VCIError {
|
LinkObject linkObject = BOFactoryClient.getBOFactoryService().readLinkObjectById(oid, loName);
|
ClientLinkObject clo = new ClientLinkObject();
|
clo.setLinkObject(linkObject);
|
return clo;
|
}
|
}
|