package com.vci.client.bof;
|
|
import java.util.ArrayList;
|
import java.util.Locale;
|
|
import com.vci.common.exception.LocaleCommonDisplay;
|
import com.vci.common.exception.VciException;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.omd.data.AttributeValue;
|
import com.vci.corba.omd.data.BusinessObject;
|
import com.vci.corba.omd.data.LinkObject;
|
import com.vci.omd.constants.BusinessConstants;
|
|
|
public class ClientBusinessObject {
|
|
private BusinessObject _bo = null;
|
|
public BusinessObject getBusinessObject() {
|
return _bo;
|
}
|
|
public void setBusinessObject(BusinessObject bo) {
|
this._bo = bo;
|
}
|
|
public ClientBusinessObject() {
|
_bo = new BusinessObject();
|
_bo.newAttrValList = new AttributeValue[0];
|
_bo.hisAttrValList = new AttributeValue[0];
|
}
|
|
public String getOid() {
|
return _bo.oid;
|
}
|
public String getRevisionid() {
|
return _bo.revisionid;
|
}
|
public String getNameoid() {
|
return _bo.nameoid;
|
}
|
public String getBtmName() {
|
return _bo.btName;
|
}
|
public boolean getIsLastR() {
|
return _bo.isLastR;
|
}
|
public boolean getIsFirstR() {
|
return _bo.isFirstR;
|
}
|
public boolean getIsLastV() {
|
return _bo.isLastV;
|
}
|
public boolean getIsFirstV() {
|
return _bo.isFirstV;
|
}
|
public String getCreator() {
|
return _bo.creator;
|
}
|
public long getCreateTime() {
|
return _bo.createTime;
|
}
|
public String getLastModifier() {
|
return _bo.modifier;
|
}
|
public long getLastModifyTime() {
|
return _bo.modifyTime;
|
}
|
public String getRevisionRule() {
|
return _bo.revisionRule;
|
}
|
public String getVersionRule() {
|
return _bo.versionRule;
|
}
|
public short getRevisionSeq() {
|
return _bo.revisionSeq;
|
}
|
public String getRevisionValue() {
|
return _bo.revisionValue;
|
}
|
public short getVersionSeq() {
|
return _bo.versionSeq;
|
}
|
public String getVersionValue() {
|
return _bo.versionValue;
|
}
|
public String getLctId() {
|
return _bo.lctId;
|
}
|
public String getLcStatus() {
|
return _bo.lcStatus;
|
}
|
public long getTs() {
|
return _bo.ts;
|
}
|
public void setOid(String oid) {
|
this._bo.oid = oid;
|
}
|
public void setRevisionid(String revisionid) {
|
this._bo.revisionid = revisionid;
|
}
|
public void setNameoid(String nameoid) {
|
this._bo.nameoid = nameoid;
|
}
|
public void setBtmName(String btmName) {
|
this._bo.btName = btmName;
|
}
|
public void setIsLastR(boolean isLastR) {
|
this._bo.isLastR = isLastR;
|
}
|
public void setIsFirstR(boolean isFirstR) {
|
this._bo.isFirstR = isFirstR;
|
}
|
public void setIsLastV(boolean isLastV) {
|
this._bo.isLastV = isLastV;
|
}
|
public void setIsFirstV(boolean isFirstV) {
|
this._bo.isFirstV = isFirstV;
|
}
|
public void setCreator(String creator) {
|
this._bo.creator = creator;
|
}
|
public void setCreateTime(long createTime) {
|
this._bo.createTime = createTime;
|
}
|
public void setLastModifier(String lastModifier) {
|
this._bo.modifier = lastModifier;
|
}
|
public void setLastModifyTime(long lastModifyTime) {
|
this._bo.modifyTime = lastModifyTime;
|
}
|
public void setRevisionRule(String revisionRule) {
|
this._bo.revisionRule = revisionRule;
|
}
|
public void setVersionRule(String versionRule) {
|
this._bo.versionRule = versionRule;
|
}
|
public void setRevisionSeq(short revisionSeq) {
|
this._bo.revisionSeq = revisionSeq;
|
}
|
public void setRevisionValue(String revisionValue) {
|
this._bo.revisionValue = revisionValue;
|
}
|
public void setVersionSeq(short versionSeq) {
|
this._bo.versionSeq = versionSeq;
|
}
|
public void setVersionValue(String versionValue) {
|
this._bo.versionValue = versionValue;
|
}
|
public void setLctId(String lctId) {
|
this._bo.lctId = lctId;
|
}
|
public void setLcStatus(String lcStatus) {
|
this._bo.lcStatus = lcStatus;
|
}
|
public void setTs(long ts) {
|
this._bo.ts = ts;
|
}
|
|
public String getId() {
|
return _bo.id;
|
}
|
|
public String getName() {
|
return _bo.name;
|
}
|
|
public String getDescription() {
|
return _bo.description;
|
}
|
|
public String getOwner() {
|
return _bo.owner;
|
}
|
|
// public String getCheckinBy() {
|
// return _bo.checkinBy;
|
// }
|
//
|
// public String getCheckinTime() {
|
// return _bo.checkinTime;
|
// }
|
//
|
// public String getCheckoutBy() {
|
// return _bo.checkoutBy;
|
// }
|
//
|
// public String getCheckoutTime() {
|
// return _bo.checkoutTime;
|
// }
|
|
public String getCopyFromVersion() {
|
return _bo.fromVersion;
|
}
|
|
public void setId(String id) {
|
this._bo.id = id;
|
}
|
|
public void setName(String name) {
|
this._bo.name = name;
|
}
|
|
public void setDescription(String description) {
|
this._bo.description = description;
|
}
|
|
public void setOwner(String owner) {
|
this._bo.owner = owner;
|
}
|
|
// public void setCheckinBy(String checkinBy) {
|
// this._bo.checkinBy = checkinBy;
|
// }
|
//
|
// public void setCheckinTime(String checkinTime) {
|
// this._bo.checkinTime = checkinTime;
|
// }
|
//
|
// public void setCheckoutBy(String checkoutBy) {
|
// this._bo.checkoutBy = checkoutBy;
|
// }
|
//
|
// public void setCheckoutTime(String checkoutTime) {
|
// this._bo.checkoutTime = checkoutTime;
|
// }
|
|
public void setCopyFromVersion(String copyFromVersion) {
|
this._bo.fromVersion = copyFromVersion;
|
}
|
|
/**
|
* 根据属性名称设置属性值,执行此方法中的属性均为自定义属性
|
* @param attributeName
|
* @param attributeValue
|
* @throws VCIError
|
*/
|
public void setAttributeValue(String attributeName, String attributeValue) throws VCIError {
|
this.setAttributeValue(attributeName, attributeValue, false);
|
}
|
|
/**
|
* 根据属性名称设定属性值,如果isCreate=true时,则需要判断传入的参数是否为系统默认的属性,
|
* 如果是默认属性,需要设定默认值,主要用于创建BO。
|
* @param attributeName
|
* @param attributeValue
|
* @param isCreate
|
* @throws VCIError
|
*/
|
public void setAttributeValue(String attributeName, String attributeValue, boolean isCreate) throws VCIError {
|
int isValid = new AttributeChecker().isAttrValValid(attributeName, attributeValue);
|
if (isValid == 1) {
|
throw getLocalError(new VCIError("P0010SOF-00017", new String[]{attributeName,attributeValue}), "PLMBOFactory");
|
} else if (isValid == 2) {
|
throw getLocalError(new VCIError("P0010SOF-00018", new String[]{attributeName,attributeValue}), "PLMBOFactory");
|
} else if (isValid == 3) {
|
throw getLocalError(new VCIError("P0010SOF-00019", new String[]{attributeName,attributeValue}), "PLMBOFactory");
|
}
|
setAttributeValueWithNoCheck(attributeName, attributeValue, isCreate);
|
}
|
|
/**
|
* 设置bo的属性,不对属性是否属于已经定义属性进行判断
|
* @param attributeName
|
* @param attributeValue
|
* @throws VCIError
|
*/
|
public void setAttributeValueWithNoCheck(String attributeName, String attributeValue) throws VCIError {
|
setAttributeValueWithNoCheck(attributeName, attributeValue, false);
|
}
|
|
/**
|
* 设置bo的属性,不对属性是否属于已经定义属性进行判断
|
* @param attributeName
|
* @param attributeValue
|
* @param isCreate
|
* @throws VCIError
|
*/
|
public void setAttributeValueWithNoCheck(String attributeName, String attributeValue, boolean isCreate) throws VCIError {
|
if (isCreate && BusinessConstants.BO_CONSTANTS.containsKey(attributeName.toUpperCase())) {
|
setConstantsAttrVal(attributeName, attributeValue);
|
return;
|
}
|
AttributeValue[] attrValues = _bo.newAttrValList;
|
ArrayList<AttributeValue> attrValList = new ArrayList<AttributeValue>();
|
if (attrValues != null && attrValues.length > 0) {
|
for (AttributeValue attrVal: attrValues) {
|
attrValList.add(attrVal);
|
}
|
}
|
AttributeValue attrVal = null;
|
boolean isExist = false;
|
for (int i = 0; i < attrValList.size(); i++) {
|
attrVal = attrValList.get(i);
|
if (attrVal.attrName.toUpperCase().equals(attributeName.toUpperCase())) {
|
attrVal.attrVal = attributeValue;
|
isExist = true;
|
break;
|
}
|
}
|
if (!isExist) {
|
attrVal = new AttributeValue();
|
attrVal.attrName = attributeName.toUpperCase();
|
attrVal.attrVal = attributeValue;
|
attrValList.add(attrVal);
|
}
|
_bo.newAttrValList = attrValList.toArray(new AttributeValue[attrValList.size()]);
|
}
|
|
/**
|
* 设置系统默认属性的属性值
|
* @param attributeName
|
* @param attributeValue
|
*/
|
private void setConstantsAttrVal(String attributeName, String attributeValue) {
|
if (attributeName.equalsIgnoreCase(BusinessConstants.SELECT_NAME)) {
|
this.setName(attributeValue);
|
} else if (attributeName.equalsIgnoreCase(BusinessConstants.SELECT_ID)) {
|
this.setId(attributeValue);
|
} else if (attributeName.equalsIgnoreCase(BusinessConstants.SELECT_DESCRIPTION)) {
|
this.setDescription(attributeValue);
|
}
|
}
|
|
public String getAttributeValue(String attrName) {
|
String res = "";
|
boolean existInNewAttr = false;
|
if (_bo.newAttrValList != null) {
|
for (int i = 0; i < _bo.newAttrValList.length; i++) {
|
if (_bo.newAttrValList[i].attrName.toUpperCase().equals(attrName.toUpperCase())) {
|
existInNewAttr = true;
|
res = _bo.newAttrValList[i].attrVal;
|
}
|
}
|
}
|
if(existInNewAttr){
|
return res;
|
}
|
if (_bo.hisAttrValList == null) {
|
return "";
|
}
|
for (int i = 0; i < _bo.hisAttrValList.length; i++) {
|
if (_bo.hisAttrValList[i].attrName.toUpperCase().equals(attrName.toUpperCase())) {
|
res = _bo.hisAttrValList[i].attrVal;
|
}
|
}
|
return res;
|
}
|
|
public void dealBusinessObjectNullValue() {
|
_bo.newAttrValList = _bo.newAttrValList == null ? new AttributeValue[0] : _bo.newAttrValList;
|
_bo.hisAttrValList = _bo.hisAttrValList == null ? new AttributeValue[0] : _bo.hisAttrValList;
|
}
|
|
public void dealLinkObjectNullValue(LinkObject lo) {
|
lo.newAttrValList = lo.newAttrValList == null ? new AttributeValue[0] : lo.newAttrValList;
|
lo.hisAttrValList = lo.hisAttrValList == null ? new AttributeValue[0] : lo.hisAttrValList;
|
}
|
|
public void dealArrayNullValue(String[] array) {
|
if (array == null) {
|
array = new String[0];
|
}
|
for (int i = 0; i < array.length; i++) {
|
if (array[i] == null) {
|
array[i] = "";
|
}
|
}
|
}
|
|
public VCIError getLocalError(VCIError vciError, String fileName) {
|
String str = LocaleCommonDisplay.getI18nString(new VciException(vciError.code, vciError.messages), fileName, Locale.getDefault());
|
return new VCIError(str, vciError.messages);
|
}
|
}
|