MOSTDaoImpl

package com.inspur.pmv5.dao.impl.momgt;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.inspur.pmv5.dao.api.momgt.MOSTDao;
import com.inspur.pmv5.dao.impl.BaseDao;
import com.inspur.pmv5.pojo.momgt.KeyValueVO;
import com.inspur.pmv5.pojo.momgt.MOAttribute;
import com.inspur.pmv5.pojo.momgt.MOEntity;
import com.inspur.pmv5.pojo.momgt.MOType;
import com.inspur.pmv5.pojo.momgt.Othersys;
import com.inspur.pmv5.pojo.momgt.OthersysAttribute;

/**
* MOSTDao接口的实现类
*
* @author user
*
*/
public class MOSTDaoImpl extends BaseDao implements MOSTDao {

private static String MOSTDAO_NAMESPACE = "com.inspur.pmv5.dao.api.momgt.MOSTDao";

@Override
public List<Othersys> getEnableOthersys(String othersysId) {
List<Othersys> list = null;
try {
openMO();
list = sqlMO().selectList(MOSTDAO_NAMESPACE + ".getEnableOthersys",
othersysId);
} finally {
closeMO();
}

return list;
}

@Override
public List<Othersys> getOthersysModel(String othersysId) {
List<Othersys> list = null;
try {
openMO();
list = sqlMO().selectList(
"com.inspur.pmv5.dao.api.momgt.MOSTDao.getOthersysModel",
othersysId);
} finally {
closeMO();
}
return list;
}

@Override
public List<OthersysAttribute> getPMAttribute(String moTypeId, String isPMRelation) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("moTypeId", moTypeId);
paramMap.put("isPMRelation", isPMRelation);
List<OthersysAttribute> list = null;
try {
openMO();
list = sqlMO().selectList(
"com.inspur.pmv5.dao.api.momgt.MOSTDao.getPMAttribute",
paramMap);
} finally {
closeMO();
}
return list;
}

@Override
public List<Othersys> checkOthersysExist(String othersysId,
String otherMotypeCode, String isRelation) {
List<Othersys> list = null;
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("othersysId", othersysId);
map.put("otherMotypeCode", otherMotypeCode);
map.put("isRelation", new Integer(isRelation));
try {
openMO();
list = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".checkOthersysExist", map);
} finally {
closeMO();
}

return list;
}

@Override
public List<Othersys> getOthersysByCode(String othersysId,
String otherMotypeCode) {
List<Othersys> list = null;
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("othersysId", othersysId);
map.put("otherMotypeCode", otherMotypeCode);
try {
openMO();
list = sqlMO().selectList(MOSTDAO_NAMESPACE + ".getOthersysByCode",
map);
} finally {
closeMO();
}
return list;
}

@Override
public int updateOthersys(Othersys othersys) {
int num = 0;
try {
this.openMO();
num = (Integer) sqlMO().update(
MOSTDAO_NAMESPACE + ".updateOthersys", othersys);
} finally {
this.closeMO();
}

return num;
}

@Override
public int updateOthersysAttr(OthersysAttribute attr) {
int num = 0;
try {
this.openMO();
num = (Integer) sqlMO().update(
MOSTDAO_NAMESPACE + ".updateOthersysAttr", attr);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}

return num;
}

@Override
public int updateOthersysKeyAttributeId(Othersys othersys) {
int num = 0;
try {
this.openMO();
num = (Integer) sqlMO().update(
MOSTDAO_NAMESPACE + ".updateOthersysKeyAttributeId",
othersys);
} finally {
this.closeMO();
}

return num;
}

@Override
public int addOthersys(Othersys othersys) {
int num = 0;
try {
this.openMO();
num = (Integer) sqlMO().insert(MOSTDAO_NAMESPACE + ".addOthersys",
othersys);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}

return num;
}

@Override
public List<OthersysAttribute> checkOthersysAttributeExist(
String othersysId, String otherMotypeId, String othersysAttributeId) {
List<OthersysAttribute> list = null;
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("othersysId", othersysId);
map.put("otherMotypeId", otherMotypeId);
map.put("othersysAttributeId", othersysAttributeId);
try {
this.openMO();
list = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".checkOthersysAttributeExist", map);
} finally {
this.closeMO();
}

return list;
}

@Override
public int addOthersysAttr(OthersysAttribute attr) {
int num = 0;
try {
this.openMO();
num = (Integer) sqlMO().insert(
MOSTDAO_NAMESPACE + ".addOthersysAttr", attr);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}

return num;
}

@Override
public List<OthersysAttribute> checkOthersysAttrRelationExist(
String otherMotypeId, String othersysAttributeId,
String othersysLabelName, String othersysId) {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("otherMotypeId", otherMotypeId);
map.put("othersysAttributeId", othersysAttributeId);
map.put("othersysLabelName", othersysLabelName);
map.put("othersysId", othersysId);
List<OthersysAttribute> list = null;
try {
this.openMO();
list = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".checkOthersysAttrRelationExist", map);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return list;
}

@Override
public int addRelation(OthersysAttribute oa) {
int num = 0;
try {
this.openMO();
num = (Integer) sqlMO().insert(MOSTDAO_NAMESPACE + ".addRelation",
oa);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}

return num;
}

@Override
public int updateOthersysAttrRelation(OthersysAttribute oa) {
int num = 0;
try {
this.openMO();
num = (Integer) sqlMO().update(
MOSTDAO_NAMESPACE + ".updateOthersysAttrRelation", oa);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}

return num;
}

@Override
public List<Othersys> getOthersysByDomainId(String domainId) {
this.openMO();
List<Othersys> resultList = null;
try {
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("domainId", domainId);
resultList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getOthersysByDomainId", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return resultList;
}

@Override
public List<OthersysAttribute> getMostAttributeByModelId(String mostModelId) {
List<OthersysAttribute> attrList = null;
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("mostModelId", mostModelId);
try {
this.openMO();
attrList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getMostAttributeByModelId", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return attrList;
}

@Override
public List<Othersys> getOthersysByDomainIdFuzzy(String domainId,
String name) {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("domainId", domainId);
map.put("name", name);
List<Othersys> list = null;
try {
this.openMO();
list = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getOthersysByDomainIdFuzzy", map);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return list;
}

@Override
public int setAttributeEnableToZero(String othersysId,
String otherMotypeId, List<String> attrIds) {
int num = 0;
HashMap<String, Object> hashmap = new HashMap<String, Object>();
hashmap.put("othersysId", othersysId);
hashmap.put("otherMotypeId", otherMotypeId);
hashmap.put("attrIds", attrIds);
try {
this.openMO();
num = (Integer) sqlMO().update(
MOSTDAO_NAMESPACE + ".setAttributeEnableToZero", hashmap);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return num;
}

@Override
public int setRelationEnableToZero(List<String> pathList, String moTypeId,
String othersysId) {
int num = 0;
HashMap<String, Object> hashmap = new HashMap<String, Object>();
hashmap.put("pathList", pathList);
hashmap.put("moTypeId", moTypeId);
hashmap.put("othersysId", othersysId);
try {
this.openMO();
num = (Integer) sqlMO().update(
MOSTDAO_NAMESPACE + ".setRelationEnableToZero", hashmap);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return num;
}

@Override
public int setOthersysEnableToZero(String othersysId,
List<String> othersysIds) {
int num = 0;
HashMap<String, Object> hashmap = new HashMap<String, Object>();
hashmap.put("othersysId", othersysId);
hashmap.put("othersysIds", othersysIds);
try {
this.openMO();
num = (Integer) sqlMO().update(
MOSTDAO_NAMESPACE + ".setOthersysEnableToZero", hashmap);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return num;
}

@Override
public int deleteOthersysModelMapping(String mappingId) {
int num = 0;
HashMap<String, Object> hashmap = new HashMap<String, Object>();
hashmap.put("mappingId", mappingId);

try {
this.openMO();
num = (Integer) sqlMO().delete(
MOSTDAO_NAMESPACE + ".deleteOthersysModelMapping", hashmap);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}

return num;
}

@Override
public int updateOthersysMapping(Othersys othersys) {
int num = 0;

try {
this.openMO();
num = (Integer) sqlMO().update(
MOSTDAO_NAMESPACE + ".updateOthersysMapping", othersys);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return num;
}

@Override
public int addOthersysModelMapping(Othersys othersys) {
int num = 0;

try {
this.openMO();
num = (Integer) sqlMO().insert(
MOSTDAO_NAMESPACE + ".addOthersysModelMapping", othersys);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return num;
}

@Override
public int addOthersysAttrMapping(OthersysAttribute oa) {
int num = 0;

try {
this.openMO();
num = (Integer) sqlMO().insert(
MOSTDAO_NAMESPACE + ".addOthersysAttrMapping", oa);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return num;
}

@Override
public int deleteOthersysAttrMapping(String attrMappingId) {
int num = 0;

try {
this.openMO();
num = (Integer) sqlMO().delete(
MOSTDAO_NAMESPACE + ".deleteOthersysAttrMapping",
attrMappingId);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return num;
}

@Override
public int updateAttrMapping(OthersysAttribute oa) {
int num = 0;

try {
this.openMO();
num = (Integer) sqlMO().update(
MOSTDAO_NAMESPACE + ".updateAttrMapping", oa);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return num;
}

@Override
public void changeDeleteModelEnable() {
try {
this.openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".changeDeleteModelEnable");
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
}

@Override
public void changeModelEnable() {
try {
this.openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".changeModelEnable");
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
}

@Override
public void updateDeleteAttrEnable() {
try {
this.openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".updateDeleteAttrEnable");
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
}

@Override
public void updateAttrEnable() {
try {
this.openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".updateAttrEnable");
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
}

@Override
public List<Othersys> getMOSTMOTypeByCIName(String ciName) {
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("CIName", ciName);
List<Othersys> othersysList = null;
try {
this.openMO();
othersysList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getMOSTMOTypeByCIName", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return othersysList;
}

@Override
public List<Othersys> getAllEnableModel(String othersysId) {
List<Othersys> list = null;
try {
openMO();
list = sqlMO().selectList(MOSTDAO_NAMESPACE + ".getAllEnableModel",
othersysId);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return list;
}

@Override
public List<OthersysAttribute> getMOSTAttributeByMostMOTypeId(
String othersysMOTypeId) {
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("othersysMOTypeId", othersysMOTypeId);
List<OthersysAttribute> attrList = null;
try {
openMO();
attrList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getMOSTAttributeByMostMOTypeId",
paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return attrList;
}

@Override
public List<Othersys> getOthersysModelMappings(String otherModelId) {
List<Othersys> list = null;
try {
openMO();
list = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getOthersysModelMappings",
otherModelId);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}

return list;
}

@Override
public List<OthersysAttribute> getAttrMapping(List<String> attrIds,
List<String> otherAttrIds) {
List<OthersysAttribute> list = null;
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("attrIds", attrIds);
map.put("otherAttrIds", otherAttrIds);

try {
openMO();
list = sqlMO().selectList(MOSTDAO_NAMESPACE + ".getAttrMapping",
map);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}

return list;
}

@Override
public List<String> getAttrByModelId(String otherModelId, String othersysId) {
List<String> list = null;
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("otherModelId", otherModelId);
map.put("othersysId", othersysId);

try {
openMO();
list = sqlMO().selectList(MOSTDAO_NAMESPACE + ".getAttrByModelId",
map);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}

return list;
}

@Override
public int getMOCount(String tableName, String columnName, String value) {
int count = 0;
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("tableName", tableName);
map.put("columnName", columnName);
map.put("value", value);
try {
openMO();
count = (Integer) sqlMO().selectOne(
MOSTDAO_NAMESPACE + ".getMOCount", map);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}

return count;
}

@Override
public String getMOAttrName(String attrID) {
String name = null;
try {
openMO();
name = (String) sqlMO().selectOne(
MOSTDAO_NAMESPACE + ".getMOAttrName", attrID);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return name;
}

@Override
public String getMOSTAttrName(String mostAttrID) {
String name = null;
try {
openMO();
name = (String) sqlMO().selectOne(
MOSTDAO_NAMESPACE + ".getMOSTAttrName", mostAttrID);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return name;
}

@Override
public void updateEntity(String sql) {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("sql", sql);
try {
openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".updateEntity", map);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
}

@Override
public void addEntity(String sql) {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("sql", sql);
try {
openMO();
sqlMO().insert(MOSTDAO_NAMESPACE + ".addEntity", map);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
}

@Override
public List<OthersysAttribute> checkBasicAttributeExist(String othersysId,
String otherModelId, String basicAttrName) {
List<OthersysAttribute> oas = null;
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("othersysId", othersysId);
map.put("otherModelId", otherModelId);
map.put("basicAttrName", basicAttrName);

try {
openMO();
oas = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".checkBasicAttributeExist", map);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}

return oas;
}

@Override
public int setOthersysEnableToZeroByMoTypeId(String othersysId,
List<String> othersysIds) {
int num = 0;
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("othersysId", othersysId);
map.put("othersysIds", othersysIds);

try {
openMO();
num = (Integer) sqlMO().update(
MOSTDAO_NAMESPACE + ".setOthersysEnableToZeroByMoTypeId",
map);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}

return num;
}

@Override
public int changeOthersysUpdateDate(Othersys othersys) {
int num = 0;

try {
openMO();
num = (Integer) sqlMO().update(
MOSTDAO_NAMESPACE + ".changeOthersysUpdateDate", othersys);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}

return num;
}

@Override
public List<Othersys> getAllEnableRelation(String othersyId) {
List<Othersys> list = null;

try {
openMO();
list = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getAllEnableRelation", othersyId);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}

return list;
}

@Override
public void updateMOSTSynDate(String otherModelId) {
try {
openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".updateMOSTSynDate",
otherModelId);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
}

@Override
public void updateMOSTSynDateByCiName (String ciName){
try {
openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".updateMOSTSynDateByCiName",
ciName);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
}

@Override
public List<Othersys> getRelationMappings(String otherModelId) {
List<Othersys> list = null;
try {
openMO();
list = sqlMO().selectList(MOSTDAO_NAMESPACE + ".getRelationMappings",
otherModelId);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}

return list;
}

@Override
public boolean checkEntityExist(String objId, String tableName, String keyAttrColumnName) {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("objId", objId);
map.put("tableName", tableName);
map.put("columnName", keyAttrColumnName);

String s = "";
try {
openMO();
s = sqlMO().selectOne(MOSTDAO_NAMESPACE + ".checkEntityExist",
map);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
if("1".equals(s)){
return true;
}
return false;
}

@Override
public void addOrUpdateMOSTEntity(MOEntity moEntity) throws Exception{
try {
openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".addOrUpdateMOSTEntity",
moEntity);
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
closeMO();
}
}

@Override
public void updateEntityRelation(String objId, String tableName,
String columnName, String columnValue) {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("objId", objId);
map.put("tableName", tableName);
map.put("columnValue", columnValue);
map.put("columnName", columnName);

try {
openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".updateEntityRelation",
map);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}

}

@Override
public boolean checkMappingExist(String pmModelId, String mostCIName) {
boolean flag = false;
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("pmModelId", pmModelId);
paramMap.put("mostCIName", mostCIName);
String s = "";
try {
openMO();
s = sqlMO().selectOne(
MOSTDAO_NAMESPACE + ".checkMappingExist", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
if ("1".equals(s)) {
flag = true;
}
return flag;
}

@Override
public String getObjIdByCIID(String tableName, String ciID, String columnName) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("tableName", tableName);
paramMap.put("CIID", ciID);
paramMap.put("columnName", columnName);
String objId = "";
try {
openMO();
objId = sqlMO().selectOne(MOSTDAO_NAMESPACE + ".getObjIdByCIID",
paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return objId;
}

@Override
public List<MOEntity> getMOEntityByMOSTId(String tableName,
String columnName, String primaryValue) {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("tableName", tableName);
map.put("columnName", columnName);
map.put("primaryValue", primaryValue);
List<MOEntity> list = null;

try {
openMO();
list = sqlMO().selectList(MOSTDAO_NAMESPACE + ".getMOEntityByMOSTId", map);
} finally {
closeMO();
}
return list;
}

@Override
public List<String> getBasicAttributeId(String motypeId) {
List<String> list = null;
try {
openMO();
list = sqlMO().selectList(MOSTDAO_NAMESPACE + ".getBasicAttributeId", motypeId);
} finally {
closeMO();
}

return list;
}

@Override
public String getSimpleMOAttrName(String attributeId) {
String columnName = null;
try {
openMO();
columnName = sqlMO().selectOne(MOSTDAO_NAMESPACE + ".getSimpleMOAttrName", attributeId);
}finally {
closeMO();
}

return columnName;
}

@Override
public List<MOAttribute> getMetaModelAttribute(String moTypeId) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("moTypeId", moTypeId);
List<MOAttribute> attrList = null;
try {
openMO();
attrList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getMetaModelAttribute", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return attrList;
}

@Override
public String getIDColumnNameByMOSTMOType(String mostCIName,
String pmModelId) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("mostCIName", mostCIName);
paramMap.put("pmModelId", pmModelId);
String columnName = "";
try {
openMO();
columnName = sqlMO().selectOne(
MOSTDAO_NAMESPACE + ".getIDColumnNameByMOSTMOType",
paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return columnName;
}

@Override
public Othersys getOthersysByCIName(String ciName) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("CIName", ciName);
Othersys othersys = null;
try {
openMO();
othersys = sqlMO().selectOne(
MOSTDAO_NAMESPACE + ".getOthersysByCIName", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return othersys;
}

@Override
public List<MOType> getPMParamModel(String modelId) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("modelId", modelId);
List<MOType> moTypeList = null;
try {
openMO();
moTypeList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getPMParamModel", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return moTypeList;
}

@Override
public int checkOthersysAttrHasOne(OthersysAttribute oa) {
int num = 0;
try {
openMO();
num = (Integer)sqlMO().selectOne(MOSTDAO_NAMESPACE + ".checkOthersysAttrHasOne", oa);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return num;
}

@Override
public List<Othersys> getAllOthersysModelAttrMapping(String modelId) {
List<Othersys> list = null;
try {
openMO();
list = sqlMO().selectList(MOSTDAO_NAMESPACE + ".getModelAttrMappings",
modelId);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}

return list;
}

@Override
public int deleteAllOthersModelAttrMapping(String modelId) {
int num = 0;
Map<String,String> map = new HashMap<String,String>();
map.put("modelId", modelId);
map.put("enable", "-1");
try {
this.openMO();
num = (Integer) sqlMO().delete(
MOSTDAO_NAMESPACE + ".deleteModelAttrMappings", modelId);

sqlMO().update(MOSTDAO_NAMESPACE + ".updateOtherModelAttrEnable", map);
//删除模型映射
sqlMO().delete(MOSTDAO_NAMESPACE + ".deleteModelMappings", modelId);
sqlMO().update(MOSTDAO_NAMESPACE + ".updateOtherModelEnable", map);

} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}

return num;

}

@Override
public boolean addAllOthersModelAttrMapping(List<Othersys> otherSysList) {
boolean result = false;
try {
openMO();

for (Othersys otherSys : otherSysList) {
if(otherSys.getOthersAttributeId() == null) {
continue;
}
sqlMO().insert(MOSTDAO_NAMESPACE + ".addModelAttrMappings",otherSys);
Map<String,String> map = new HashMap<String,String>();
map.put("othersAttributeId", otherSys.getOthersAttributeId());
map.put("enable", "1");
sqlMO().update(MOSTDAO_NAMESPACE + ".updateOtherModelAttrEnable1",map);
}
if (otherSysList != null && otherSysList.size() > 0) {
String modelId = otherSysList.get(0).getModelId();
//插入模型映射
sqlMO().insert(MOSTDAO_NAMESPACE + ".addModelMappings",modelId
);
Map<String,String> map = new HashMap<String,String>();
map.put("modelId", modelId);
map.put("enable", "1");
sqlMO().update(MOSTDAO_NAMESPACE + ".updateOtherModelEnable",map
);
result = true;
}

} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return result;
}

// @Override
// public List<Othersys> getMOSTParamModel(String modelId) {
// // TODO Auto-generated method stub
// return null;
// }

@Override
public List<Othersys> getMOSTParamModel() {
List<Othersys> othersysList = null;
try {
openMO();
othersysList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getMOSTParamModel");
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return othersysList;
}

@Override
public List<OthersysAttribute> getParamAttrByMOTypeId(String modelId) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("modelId", modelId);
List<OthersysAttribute> attrList = null;
try {
openMO();
attrList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getParamAttrByMOTypeId", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return attrList;
}

@Override
public List<Othersys> getMappedModel(String modelId) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("modelId", modelId);
List<Othersys> othersysList = null;
try {
openMO();
othersysList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getMappedModel", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return othersysList;
}

@Override
public List<OthersysAttribute> getMOSTParamAttribute(String otherModelId) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("otherModelId", otherModelId);
List<OthersysAttribute> attrList = null;
try {
openMO();
attrList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getMOSTParamAttribute", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return attrList;
}

@Override
public Othersys getModelAndAttributeByMOST(Othersys othersys) {
Othersys result = null;
try {
openMO();
List<Othersys> resultList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getModelAndAttributeByMOST", othersys);
if (resultList.size() > 0) {
result = resultList.get(0);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return result;
}

@Override
public List<Othersys> getIndexKeyAttributeIdList(String othersysMotypeId) {
List<Othersys> result = null;
try {
openMO();
result = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getIndexKeyAttributeIdByMOSTMotypeId", othersysMotypeId);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return result;
}
@Override
public List<Map<String,String>> getMOSTModelEnityIdByModelIdObjId(String othersysMotypeId,
String moId,String objId) {
Map<String,String> map = null;
Map<String,String> result = new HashMap<String,String>();
List<Map<String,String>> resultList = new ArrayList<Map<String,String>>();
//根据most模型id获取obj表名和对应的采集列名

try {
openMO();
map = sqlMO().selectOne(
MOSTDAO_NAMESPACE + ".getTableNameAndColumnNameByMOST", othersysMotypeId);
result.put("modelId", map.get("MODELID"));

Map<String,String> parameterMap = new HashMap<String,String>();
parameterMap.put("tableName", map.get("TABLENAME"));
String columnName = map.get("COLUMNNAME");
parameterMap.put("columnName", columnName);

if (moId != null) {
parameterMap.put("moId", moId);
List<Map<String,String>> rList = sqlMO().selectList(MOSTDAO_NAMESPACE+".getMoentity",
parameterMap);
for (Map<String,String> m : rList) {
m.put("modelId", map.get("MODELID"));
}
return rList;
} else if (objId != null){
parameterMap.put("objId", objId);
Map<String,String> m2 = (Map)sqlMO().selectOne(MOSTDAO_NAMESPACE+".getMo",
parameterMap);
String rMoId = m2.get(columnName.toUpperCase());
result.put("moId", rMoId);
resultList.add(result);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return resultList;

}

@Override
public String getUpperNEModelIdByLowerNEModelId(String lowerNEModelId) {
String result = "";
try {
openMO();
Map<String,String> map = sqlMO().selectMap(MOSTDAO_NAMESPACE + ".getUpperNEModelIdByLowerNEModelId",
lowerNEModelId);
result = map.get("MODELID");
} catch (Exception e) {

} finally {
this.closeMO();
}
return result;
}

@Override
public int deleteMappingAttributesByMappingId(String mappingId) {
int num = 0;
try {
this.openMO();
//删除模型映射
num = sqlMO().delete(MOSTDAO_NAMESPACE + ".deleteModelAttrMappingById", mappingId);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return num;
}

@Override
public void deleteModelAttrMappingByOtherAttrId(String otherAttrId) {
try {
this.openMO();
//删除模型映射
sqlMO().delete(MOSTDAO_NAMESPACE + ".deleteModelAttrMappingByOtherAttrId", otherAttrId);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}

}

@Override
public void addModelMappingByModelIdAndOtherModelId(Othersys othersys) {
try {
this.openMO();
//新增模型映射
sqlMO().insert(MOSTDAO_NAMESPACE + ".addModelMappingByModelIdAndOtherModelId", othersys);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}

}

@Override
public int updateOtherModelAttrMapping(OthersysAttribute othersys) {
int num = 0;
try {
this.openMO();
if (!"".endsWith(othersys.getOthersysAttributeName() )) {
//更新模型属性映射
num = sqlMO().update(MOSTDAO_NAMESPACE + ".updateOtherModelAttrMapping", othersys);

//将othersysAttr表中的enable字段置为1
Map<String,String> map = new HashMap<String,String>();
map.put("othersAttributeId", othersys.getOthersysAttributeId());
map.put("enable", "1");
sqlMO().update(MOSTDAO_NAMESPACE + ".updateOtherModelAttrEnable1",map);
} else if(othersys.getMappingId() != null){
sqlMO().delete(MOSTDAO_NAMESPACE + ".deleteModelAttrMappingByAttrMappingId", othersys.getMappingId());
}


} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return num;
}

@Override
public int addOtherModelAttrMapping(OthersysAttribute othersysAttr) {
// addOtherModelAttrMapping
int num = 0;
try {
this.openMO();
//删除模型映射
num = sqlMO().insert(MOSTDAO_NAMESPACE + ".addOtherModelAttrMapping", othersysAttr);
//将othersysAttr表中的enable字段置为1
Map<String,String> map = new HashMap<String,String>();
map.put("othersAttributeId", othersysAttr.getOthersysAttributeName());
map.put("enable", "1");
sqlMO().update(MOSTDAO_NAMESPACE + ".updateOtherModelAttrEnable1",map);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return num;
}

@Override
public int updateModelMappingById(Othersys othersys) {
int num = 0;
try {
this.openMO();
//更新模型映射
num = sqlMO().update(MOSTDAO_NAMESPACE + ".updateModelMappingById", othersys);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return num;
}

@Override
public int deleteModelAttrMappingByAttrMappingId(String mappingId) {
int num = 0;
try {
this.openMO();
//删除模型属性映射
num = sqlMO().delete(MOSTDAO_NAMESPACE + ".deleteModelAttrMappingByAttrMappingId", mappingId);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return num;
}

@Override
public List<Map<String, String>> validateAttrMappingByOtherAttrId(
String otherAttributeId) {
List<Map<String, String>> result = null;
try {
this.openMO();
//删除模型属性映射
result = sqlMO().selectList(MOSTDAO_NAMESPACE + ".validateAttrMappingByOtherAttrId", otherAttributeId);
} catch (Exception e) {
e.printStackTrace();
} finally {
this.closeMO();
}
return result;
}

@Override
public List<OthersysAttribute> getMappedInstanceSelectAttribute(
String ciName) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("ciName", ciName);
List<OthersysAttribute> attrList = null;
try {
openMO();
attrList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getMappedInstanceSelectAttribute",
paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return attrList;
}

@Override
public Othersys getMappingOthersysByCIName(String ciName) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("ciName", ciName);
Othersys othersys = null;
try {
openMO();
othersys = sqlMO()
.selectOne(
MOSTDAO_NAMESPACE + ".getMappingOthersysByCIName",
paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return othersys;
}

@Override
public String getColumnNameByOthersysAttributeId(String attrId, String ciName) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("attrId", attrId);
paramMap.put("ciName", ciName);
String columnName = "";
try {
openMO();
columnName = sqlMO()
.selectOne(
MOSTDAO_NAMESPACE + ".getColumnNameByOthersysAttributeId",
paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return columnName;
}

@Override
public List<String> getDistinctedValue(String tableName, String columnName) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("tableName", tableName);
paramMap.put("columnName", columnName);
List<String> valueList = null;
try {
openMO();
valueList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getDistinctedValue", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return valueList;
}

@Override
public void updateToObjId(String tableName, String columnName,
String oldValue, String objId) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("tableName", tableName);
paramMap.put("columnName", columnName);
paramMap.put("oldValue", oldValue);
paramMap.put("objId", objId);

try {
openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".updateToObjId", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
}

@Override
public List<Map<String, String>> getPrimaryKeyAttributeMapping(
String otherMOTypeId) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("otherMOTypeId", otherMOTypeId);
List<Map<String,String>> result = null;
try {
openMO();
result = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getPrimaryKeyAttributeMapping",
paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return result;
}

@Override
public List<MOEntity> getMOEntityByPrimaryKey(String tableName,
List<KeyValueVO> keyValueList) {
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("tableName", tableName);
paramMap.put("keyValueList", keyValueList);
List<MOEntity> result = null;
try {
openMO();
result = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getMOEntityByPrimaryKey",
paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return result;
}

@Override
public String getRelationColumnByOthersysAttributeName(
String otherMOTypeCode, String otherAttributeCode) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("otherMOTypeCode", otherMOTypeCode);
paramMap.put("otherAttributeCode", otherAttributeCode);
String result = "";
try {
openMO();
result = sqlMO().selectOne(
MOSTDAO_NAMESPACE
+ "getRelationColumnByOthersysAttributeName",
paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return result;
}

@Override
public String getLabelNameRelatedTabelName(String otherMOTypeCode,
String otherAttributeCode) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("otherMOTypeCode", otherMOTypeCode);
paramMap.put("otherAttributeCode", otherAttributeCode);
String result = "";
try {
openMO();
result = sqlMO().selectOne(
MOSTDAO_NAMESPACE
+ "getLabelNameRelatedTabelName",
paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return result;
}

@Override
public String getLabelName(String otherMOTypeCode, String otherAttributeCode) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("otherMOTypeCode", otherMOTypeCode);
paramMap.put("otherAttributeCode", otherAttributeCode);
String result = "";
try {
openMO();
result = sqlMO().selectOne(
MOSTDAO_NAMESPACE
+ "getLabelName",
paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return result;
}

@Override
public boolean isExistN2NRelation(String objAId, String objBId,
String tableName) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("objAId", objAId);
paramMap.put("objBId", objBId);
paramMap.put("tableName", tableName);
List<String> result = null;
try {
openMO();
result = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".isExistN2NRelation", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
if(result == null || result.size() == 0){
return false;
} else {
return true;
}
}

@Override
public void insertN2NRelation(String objAId, String objBId, String tableName) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("objAId", objAId);
paramMap.put("objBId", objBId);
paramMap.put("tableName", tableName);
try {
openMO();
sqlMO().insert(MOSTDAO_NAMESPACE + ".insertN2NRelation", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
}

@Override
public void updateCurSyncDate(String ciName, Long systemTime) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("ciName", ciName);
paramMap.put("systemTime", String.valueOf(systemTime));

try {
openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".updateCurSyncDate", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
}

@Override
public void updateCurTotalPage(String ciName, int totalPage) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("ciName", ciName);
paramMap.put("totalPage", String.valueOf(totalPage));

try {
openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".updateCurTotalPage", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
}

@Override
public void updateCurPage(String ciName, int currentPage) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("ciName", ciName);
paramMap.put("currentPage", String.valueOf(currentPage));

try {
openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".updateCurPage", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
}

@Override
public void updateTwoDate(String ciName, Long totalMaxDate) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("ciName", ciName);
paramMap.put("totalMaxDate", String.valueOf(totalMaxDate));

try {
openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".updateTwoDate", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
}

@Override
public void updateCurPageAndTotalPageToNull(String ciName) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("ciName", ciName);

try {
openMO();
sqlMO().update(MOSTDAO_NAMESPACE + ".updateCurPageAndTotalPageToNull", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
}

@Override
public Othersys getOthersysMappingByPMModelId(String modelId) {
Map<String,String> paramMap = new HashMap<String, String>();
paramMap.put("modelId", modelId);
Othersys othersys = null;
try {
openMO();
othersys = sqlMO().selectOne(
MOSTDAO_NAMESPACE + ".getOthersysMappingByPMModelId",
paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return othersys;
}

@Override
public List<Othersys> getAllOthersysParamMappingFor12n(String ciName) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("ciName", ciName);
List<Othersys> othersysList = null;
try {
openMO();
othersysList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getAllOthersysParamMappingFor12n", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return othersysList;
}

@Override
public List<OthersysAttribute> getAllOthersysAttrParamMappingFor12n(
String ciName) {
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("ciName", ciName);
List<OthersysAttribute> othersysList = null;
try {
openMO();
othersysList = sqlMO().selectList(
MOSTDAO_NAMESPACE + ".getAllOthersysAttrParamMappingFor12n", paramMap);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeMO();
}
return othersysList;
}

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值