package cn.ksource.beans;
|
|
import java.sql.ResultSet;
|
import java.sql.SQLException;
|
import java.util.HashMap;
|
import java.util.Iterator;
|
import java.util.List;
|
import java.util.Map;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import cn.ksource.core.dao.BaseBean;
|
import cn.ksource.core.util.ConvertUtil;
|
import cn.ksource.core.util.StringUtil;
|
|
/**
|
* 用户及设备涉及工单
|
*/
|
public class WORKFLOW_USER_CMDB extends BaseBean{
|
|
public final static Map<String, String> KEYS = new HashMap<String, String>();
|
private Map BEAN_VALUES = null;
|
|
static {
|
KEYS.put("id", "String");
|
KEYS.put("user_id", "String");
|
KEYS.put("ci_id", "String");
|
KEYS.put("wf_id", "String");
|
KEYS.put("type", "Integer");
|
}
|
public Map getColumnMap(){
|
return KEYS;
|
}
|
|
private String id;
|
private Boolean isSetted_id = false;;
|
|
private String user_id;
|
private Boolean isSetted_user_id = false;
|
private String ci_id;
|
private Boolean isSetted_ci_id = false;
|
private String wf_id;
|
private Boolean isSetted_wf_id = false;
|
private Integer type;
|
private Boolean isSetted_type = false;
|
|
private void initBeanValues(){
|
BEAN_VALUES = new HashMap<String, Object>();
|
BEAN_VALUES.put("id",id);
|
BEAN_VALUES.put("user_id", null);
|
BEAN_VALUES.put("ci_id", null);
|
BEAN_VALUES.put("wf_id", null);
|
BEAN_VALUES.put("type", null);
|
}
|
|
public WORKFLOW_USER_CMDB() {
|
initBeanValues();
|
}
|
|
public WORKFLOW_USER_CMDB(String id) {
|
super();
|
this.id = id;
|
initBeanValues();
|
BEAN_VALUES.put("id",id);
|
}
|
|
/**
|
* 获取ID
|
*/
|
public String getId() {
|
return this.id;
|
}
|
/**
|
* 设置ID
|
*/
|
public WORKFLOW_USER_CMDB setId(String id) {
|
this.id = id;
|
this.isSetted_id = true;
|
BEAN_VALUES.put("id",id);
|
return this;
|
}
|
|
@Override
|
public String getUpdateSql() {
|
StringBuffer sBuffer = new StringBuffer("update WORKFLOW_USER_CMDB set ");
|
if (isSetted_user_id) {
|
sBuffer.append("user_id=:user_id,");
|
}
|
if (isSetted_ci_id) {
|
sBuffer.append("ci_id=:ci_id,");
|
}
|
if (isSetted_wf_id) {
|
sBuffer.append("wf_id=:wf_id,");
|
}
|
if (isSetted_type) {
|
sBuffer.append("type=:type,");
|
}
|
String sql = sBuffer.toString();
|
return StringUtils.removeEnd(sql, ",") + " where id=:id";
|
}
|
|
|
@Override
|
public String getInsertSql() {
|
StringBuffer sBuffer = new StringBuffer("insert into WORKFLOW_USER_CMDB(");
|
StringBuffer fileds = new StringBuffer("id,");
|
StringBuffer values = new StringBuffer(":id,");
|
fileds.append("user_id,");
|
values.append(":user_id,");
|
fileds.append("ci_id,");
|
values.append(":ci_id,");
|
fileds.append("wf_id,");
|
values.append(":wf_id,");
|
fileds.append("type,");
|
values.append(":type,");
|
sBuffer.append(StringUtils.removeEnd(fileds.toString(), ",") + ") values("+StringUtils.removeEnd(values.toString(), ",")+")");
|
return sBuffer.toString();
|
}
|
|
|
/**
|
* 获取用户编号<BR/>
|
* 䣺2016-15-04 hh:07
|
*/
|
public String getUser_id() {
|
return user_id;
|
}
|
/**
|
* 设置用户编号<BR/>
|
* 2016-15-04 hh:07
|
*/
|
public WORKFLOW_USER_CMDB setUser_id(String user_id) {
|
this.user_id = user_id;
|
this.isSetted_user_id = true;
|
BEAN_VALUES.put("user_id",user_id);
|
return this;
|
}
|
/**
|
* 获取设备编号<BR/>
|
* 䣺2016-15-04 hh:07
|
*/
|
public String getCi_id() {
|
return ci_id;
|
}
|
/**
|
* 设置设备编号<BR/>
|
* 2016-15-04 hh:07
|
*/
|
public WORKFLOW_USER_CMDB setCi_id(String ci_id) {
|
this.ci_id = ci_id;
|
this.isSetted_ci_id = true;
|
BEAN_VALUES.put("ci_id",ci_id);
|
return this;
|
}
|
/**
|
* 获取流程编号<BR/>
|
* 䣺2016-15-04 hh:07
|
*/
|
public String getWf_id() {
|
return wf_id;
|
}
|
/**
|
* 设置流程编号<BR/>
|
* 2016-15-04 hh:07
|
*/
|
public WORKFLOW_USER_CMDB setWf_id(String wf_id) {
|
this.wf_id = wf_id;
|
this.isSetted_wf_id = true;
|
BEAN_VALUES.put("wf_id",wf_id);
|
return this;
|
}
|
/**
|
* 获取类型(1=用户工单;2=设备工单)<BR/>
|
* 䣺2016-15-04 hh:07
|
*/
|
public Integer getType() {
|
return type;
|
}
|
/**
|
* 设置类型(1=用户工单;2=设备工单)<BR/>
|
* 2016-15-04 hh:07
|
*/
|
public WORKFLOW_USER_CMDB setType(Integer type) {
|
this.type = type;
|
this.isSetted_type = true;
|
BEAN_VALUES.put("type",type);
|
return this;
|
}
|
|
/**
|
* 使用ID删除Bean<BR/>
|
*/
|
public void deleteById() {
|
if (StringUtils.isBlank(id)) {
|
throw new RuntimeException("删除bean时ID不能为空");
|
}
|
dao.execute("delete from " + getTableName() + " where id = :id", BEAN_VALUES);
|
}
|
|
@Override
|
public WORKFLOW_USER_CMDB getInstanceById() {
|
if (StringUtils.isBlank(id)) {
|
throw new RuntimeException("获取Bean时ID不能为空");
|
}
|
return dao.queryForBean("select * from " + getTableName() + " where id=:id", BEAN_VALUES, this);
|
}
|
|
|
|
@Override
|
public WORKFLOW_USER_CMDB queryForBean() {
|
StringBuffer sBuffer = new StringBuffer("select * from WORKFLOW_USER_CMDB where ");
|
if(isSetted_id){
|
sBuffer.append("id=:id and ");
|
}
|
if (isSetted_user_id) {
|
sBuffer.append("user_id=:user_id and ");
|
}
|
if (isSetted_ci_id) {
|
sBuffer.append("ci_id=:ci_id and ");
|
}
|
if (isSetted_wf_id) {
|
sBuffer.append("wf_id=:wf_id and ");
|
}
|
if (isSetted_type) {
|
sBuffer.append("type=:type and ");
|
}
|
String sql = sBuffer.toString();
|
sql = StringUtils.removeEnd(sql, " and ");
|
return dao.queryForBean(sql,this);
|
}
|
|
@Override
|
public String getTableName() {
|
return "WORKFLOW_USER_CMDB";
|
}
|
|
|
public Map getBeanValues(){
|
return this.BEAN_VALUES;
|
}
|
|
@Override
|
public WORKFLOW_USER_CMDB insert() {
|
if (StringUtils.isBlank(id)) {
|
this.setId(StringUtil.getUUID());
|
}
|
dao.execute(getInsertSql(),BEAN_VALUES);
|
return this;
|
}
|
|
@Override
|
public WORKFLOW_USER_CMDB update() {
|
if (StringUtils.isBlank(id)) {
|
throw new RuntimeException("更新Bean时ID不能为空");
|
}
|
dao.execute(getUpdateSql(),BEAN_VALUES);
|
return this;
|
}
|
|
public WORKFLOW_USER_CMDB insertOrUpdate(){
|
if (StringUtils.isNotBlank(id)) {
|
return update();
|
} else {
|
return insert();
|
}
|
}
|
|
/**
|
* 通过ID获取该条信息的Map结构
|
*/
|
public Map getBeanMapById() {
|
|
if (StringUtils.isBlank(id)) {
|
throw new RuntimeException("ID不能为空!");
|
}
|
|
return dao.queryForMap("select * from WORKFLOW_USER_CMDB where id=:id",BEAN_VALUES);
|
}
|
|
public Object mapRow(ResultSet rs, int rownum) throws SQLException {
|
Object id = rs.getObject("ID");
|
this.setId(ConvertUtil.obj2Str(id));
|
BEAN_VALUES.put("id",id);
|
Object obj = null;
|
obj = rs.getObject("USER_ID");
|
BEAN_VALUES.put("user_id",obj);
|
this.setUser_id(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("CI_ID");
|
BEAN_VALUES.put("ci_id",obj);
|
this.setCi_id(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("WF_ID");
|
BEAN_VALUES.put("wf_id",obj);
|
this.setWf_id(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("TYPE");
|
BEAN_VALUES.put("type",obj);
|
this.setType(ConvertUtil.obj2Integer(obj));
|
return this;
|
}
|
|
|
public String toString() {
|
StringBuffer sb = new StringBuffer("[");
|
for (Iterator iterator = KEYS.keySet().iterator(); iterator.hasNext();) {
|
String key = (String) iterator.next();
|
sb.append(key+"=" + BEAN_VALUES.get(key)+",");
|
}
|
sb.append("]");
|
return sb.toString();
|
}
|
|
public WORKFLOW_USER_CMDB newInstance(){
|
return new WORKFLOW_USER_CMDB();
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|