package com.vci.server.bof.objects;
|
|
import java.lang.reflect.Field;
|
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.Method;
|
import java.util.ArrayList;
|
|
import com.vci.corba.omd.data.AttributeValue;
|
import com.vci.corba.omd.data.BusinessObject;
|
import com.vci.omd.constants.BusinessConstants;
|
import com.vci.server.bof.utils.ServerObjectUtil;
|
|
public class ServerBusinessObject {
|
|
public String oid = "";
|
public String revisionOid = "";
|
public String nameoid = "";
|
public String btmName = "";
|
public String isLastR;
|
public String isFirstR;
|
public String isLastV;
|
public String isFirstV;
|
public String creator = "";
|
public long createTime = 0;
|
public String lastModifier = "";
|
public long lastModifyTime = 0;
|
public String revisionRule = "";
|
public String versionRule = "";
|
public String revisionSeq;
|
public String revisionValue = "";
|
public String versionSeq;
|
public String versionValue = "";
|
public String lctId = "";
|
public String lcStatus = "";
|
public long ts = 0;
|
public String id = "";
|
public String name = "";
|
public String description = "";
|
public String owner = "";
|
// public String checkinBy = "";
|
// public String checkinTime = "";
|
// public String checkoutBy = "";
|
// public String checkoutTime = "";
|
public String copyFromVersion = "";
|
|
private BusinessObject businessObject;
|
|
public BusinessObject getBusinessObject() {
|
dealBusinessObjectNullValue();
|
return businessObject;
|
}
|
|
public void setBusinessObject(BusinessObject businessObject) {
|
this.businessObject = businessObject;
|
}
|
|
public ServerBusinessObject() {
|
businessObject = new BusinessObject();
|
}
|
|
public String getOid() {
|
return oid;
|
}
|
public String getRevisionOid() {
|
return this.revisionOid;
|
}
|
public String getNameoid() {
|
return nameoid;
|
}
|
public String getBtmName() {
|
return btmName;
|
}
|
public String getIsLastR() {
|
return isLastR;
|
}
|
public String getIsFirstR() {
|
return isFirstR;
|
}
|
public String getIsLastV() {
|
return isLastV;
|
}
|
public String getIsFirstV() {
|
return isFirstV;
|
}
|
public String getCreator() {
|
return creator;
|
}
|
public long getCreateTime() {
|
return createTime;
|
}
|
public String getLastModifier() {
|
return lastModifier;
|
}
|
public long getLastModifyTime() {
|
return lastModifyTime;
|
}
|
public String getRevisionRule() {
|
return revisionRule;
|
}
|
public String getVersionRule() {
|
return versionRule;
|
}
|
public String getRevisionSeq() {
|
return revisionSeq;
|
}
|
public String getRevisionValue() {
|
return revisionValue;
|
}
|
public String getVersionSeq() {
|
return versionSeq;
|
}
|
public String getVersionValue() {
|
return versionValue;
|
}
|
public String getLctId() {
|
return lctId;
|
}
|
public String getLcStatus() {
|
return lcStatus;
|
}
|
public long getTs() {
|
return ts;
|
}
|
public String getId() {
|
return id;
|
}
|
public String getName() {
|
return name;
|
}
|
public String getDescription() {
|
return description;
|
}
|
public String getOwner() {
|
return owner;
|
}
|
// public String getCheckinBy() {
|
// return checkinBy;
|
// }
|
// public String getCheckinTime() {
|
// return checkinTime;
|
// }
|
// public String getCheckoutBy() {
|
// return checkoutBy;
|
// }
|
// public String getCheckoutTime() {
|
// return checkoutTime;
|
// }
|
public String getCopyFromVersion() {
|
return copyFromVersion;
|
}
|
public void setOid(String oid) {
|
this.oid = oid;
|
this.businessObject.oid = oid;
|
}
|
public void setRevisionOid(String revisionOid) {
|
this.revisionOid = revisionOid;
|
this.businessObject.revisionid = revisionOid;
|
}
|
public void setNameoid(String nameoid) {
|
this.nameoid = nameoid;
|
this.businessObject.nameoid = nameoid;
|
}
|
public void setBtmName(String btmName) {
|
this.btmName = btmName;
|
this.businessObject.btName = btmName;
|
}
|
public void setIsLastR(String isLastR) {
|
this.isLastR = isLastR;
|
this.businessObject.isLastR = Short.valueOf(isLastR) != 0;
|
}
|
public void setIsFirstR(String isFirstR) {
|
this.isFirstR = isFirstR;
|
this.businessObject.isFirstR = Short.valueOf(isFirstR) != 0;
|
}
|
public void setIsLastV(String isLastV) {
|
this.isLastV = isLastV;
|
this.businessObject.isLastV = Short.valueOf(isLastV) != 0;
|
}
|
public void setIsFirstV(String isFirstV) {
|
this.isFirstV = isFirstV;
|
this.businessObject.isFirstV = Short.valueOf(isFirstV) != 0;
|
}
|
public void setCreator(String creator) {
|
this.creator = creator;
|
this.businessObject.creator = creator;
|
}
|
public void setCreateTime(long createTime) {
|
this.createTime = createTime;
|
this.businessObject.createTime = createTime;
|
}
|
public void setLastModifier(String lastModifier) {
|
this.lastModifier = lastModifier;
|
this.businessObject.modifier = lastModifier;
|
}
|
public void setLastModifyTime(long lastModifyTime) {
|
this.lastModifyTime = lastModifyTime;
|
this.businessObject.modifyTime = lastModifyTime;
|
}
|
public void setRevisionRule(String revisionRule) {
|
this.revisionRule = revisionRule;
|
this.businessObject.revisionRule = revisionRule;
|
}
|
public void setVersionRule(String versionRule) {
|
this.versionRule = versionRule;
|
this.businessObject.versionRule = versionRule;
|
}
|
public void setRevisionSeq(String revisionSeq) {
|
this.revisionSeq = revisionSeq;
|
this.businessObject.revisionSeq = Short.valueOf(revisionSeq);
|
}
|
public void setRevisionValue(String revisionValue) {
|
this.revisionValue = revisionValue;
|
this.businessObject.revisionValue = revisionValue;
|
}
|
public void setVersionSeq(String versionSeq) {
|
this.versionSeq = versionSeq;
|
this.businessObject.versionSeq = Short.valueOf(versionSeq);
|
}
|
public void setVersionValue(String versionValue) {
|
this.versionValue = versionValue;
|
this.businessObject.versionValue = versionValue;
|
}
|
public void setLctId(String lctId) {
|
this.lctId = lctId;
|
this.businessObject.lctId = lctId;
|
}
|
public void setLcStatus(String lcStatus) {
|
this.lcStatus = lcStatus;
|
this.businessObject.lcStatus = lcStatus;
|
}
|
public void setTs(long ts) {
|
this.ts = ts;
|
this.businessObject.ts = ts;
|
}
|
public void setId(String id) {
|
this.id = id;
|
this.businessObject.id = id;
|
}
|
public void setName(String name) {
|
this.name = name;
|
this.businessObject.name = name;
|
}
|
public void setDescription(String description) {
|
this.description = description;
|
this.businessObject.description = description;
|
}
|
public void setOwner(String owner) {
|
this.owner = owner;
|
this.businessObject.owner = owner;
|
}
|
// public void setCheckinBy(String checkinBy) {
|
// this.checkinBy = checkinBy;
|
// this.businessObject.checkinBy = checkinBy;
|
// }
|
// public void setCheckinTime(String checkinTime) {
|
// this.checkinTime = checkinTime;
|
// this.businessObject.checkinTime = checkinTime;
|
// }
|
// public void setCheckoutBy(String checkoutBy) {
|
// this.checkoutBy = checkoutBy;
|
// this.businessObject.checkoutBy = checkoutBy;
|
// }
|
// public void setCheckoutTime(String checkoutTime) {
|
// this.checkoutTime = checkoutTime;
|
// this.businessObject.checkoutTime = checkoutTime;
|
// }
|
public void setCopyFromVersion(String copyFromVersion) {
|
this.copyFromVersion = copyFromVersion;
|
this.businessObject.fromVersion = copyFromVersion;
|
}
|
|
public void setAttributeValue(String attributeName, String attrType, Object attributeValue) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
if (BusinessConstants.BO_CONSTANTS.containsKey(attributeName)) {
|
dealWithSystemAttributeValue(attributeName, attributeValue);
|
attrType = BusinessConstants.BO_CONSTANTS.get(attributeName);
|
}
|
dealWithBOAttributeValue(attributeName, attrType, attributeValue);
|
}
|
|
private void dealWithSystemAttributeValue(String attributeName, Object attributeValue) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
String name = attributeName.toUpperCase();
|
if (name.equals("CREATETIME") || name.equals("LASTMODIFYTIME") || name.equals("TS")) {
|
long time = 0;
|
if (attributeValue instanceof java.sql.Date) {
|
time = ((java.sql.Date)attributeValue).getTime();
|
} else if (attributeValue instanceof java.sql.Timestamp){
|
time = ((java.sql.Timestamp)attributeValue).getTime();
|
}
|
|
if (name.equals("CREATETIME")) {
|
this.setCreateTime(time);
|
} else if (name.equals("LASTMODIFYTIME")) {
|
this.setLastModifyTime(time);
|
} else if (name.equals("TS")) {
|
this.setTs(time);
|
}
|
return;
|
}
|
|
String changeValue = ServerObjectUtil.getInstance().tansferSystemDBDateToString(BusinessConstants.BO_CONSTANTS, attributeName, attributeValue);
|
|
Field[] fields=ServerBusinessObject.class.getDeclaredFields();
|
for (Field field : fields) {
|
String fieldName = field.getName();
|
if (!fieldName.toUpperCase().equals(attributeName.toUpperCase())) {
|
continue;
|
}
|
//将属性名首字母转换成大写字母
|
String firstLetter = fieldName.substring(0, 1).toUpperCase();
|
String setMethodName = "set" + firstLetter + fieldName.substring(1);
|
Method setMethod = ServerBusinessObject.class.getMethod(setMethodName, new Class[]{changeValue.getClass()});
|
setMethod.invoke(this, new Object[]{changeValue});
|
break;
|
}
|
}
|
|
private void dealWithBOAttributeValue(String attributeName, String attrType, Object attributeValue) {
|
String changeValue = ServerObjectUtil.getInstance().tansferTypeDBDateToString(attrType, attributeValue);
|
AttributeValue[] attrValues = businessObject.hisAttrValList;
|
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 = changeValue;
|
isExist = true;
|
break;
|
}
|
}
|
if (!isExist) {
|
attrVal = new AttributeValue();
|
attrVal.attrName = attributeName.toUpperCase();
|
attrVal.attrVal = changeValue;
|
attrValList.add(attrVal);
|
}
|
businessObject.hisAttrValList = attrValList.toArray(new AttributeValue[attrValList.size()]);
|
}
|
|
public String[] getQueryColumnAccordingToSQL(String sql, String start, String end) {
|
sql = sql.toUpperCase();
|
sql = sql.substring(start.length());
|
sql = sql.substring(0, sql.indexOf(end));
|
sql = sql.replaceAll(" ", "");
|
return sql.split(",");
|
}
|
|
public void dealBusinessObjectNullValue() {
|
businessObject.newAttrValList = businessObject.newAttrValList == null ? new AttributeValue[0] : businessObject.newAttrValList;
|
businessObject.hisAttrValList = businessObject.hisAttrValList == null ? new AttributeValue[0] : businessObject.hisAttrValList;
|
}
|
}
|