Authored by zhangmingm

添加物理设备。

package com.sitech.snmptrap;
import com.sitech.database.dao.BaseDao;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* @author frank zmm@honggroup.com.cn
* @Description: 物理设备类对应dao。
* @Package com.sitech.snmptrap
* @ClassName: com.sitech.snmptrap.TbTopoPhysicalDeviceDao
* @date 2017年03月03日 10:20
*/
public class TbTopoPhysicalDeviceDao extends BaseDao {
/**
* 添加物理设备,如果该设备已经存在,则修改。
* @param physicalDevice
*/
public void addTbTopoPhysicalDevice(TbTopoPhysicalDeviceBean physicalDevice){
try {
int updateSum = sqlmapClient.update("updateTbTopoPhysicalDevice",physicalDevice);
if(updateSum == 0){
sqlmapClient.insert("addTbTopoPhysicalDevice", physicalDevice);
}
} catch (Exception e) {
error.error("Exception while addTbTopoPhysicalDevice.", e);
}
}
/**
* 按照设备ID删除设备。
* @param deviceId
*/
public int deleteTbTopoPhysicalDevice(String deviceId){
int result=0;
try {
result=sqlmapClient.delete("deleteTbTopoPhysicalDevice", deviceId);
} catch (Exception e) {
error.error("Exception while deleteTbTopoPhysicalDevice.", e);
}
return result;
}
public int deletePhysicalDeviceByIp(String ip){
try {
return sqlmapClient.delete("deletePhysicalDeviceByIp", ip);
} catch (Exception e) {
error.error("Exception while deletePhysicalDeviceByIp.", e);
}
return -1;
}
public List<TbTopoPhysicalDeviceBean> getPhysicalDeviceByIp(String deviceIp){
HashMap<String,String> param=new HashMap<String, String>();
param.put("DEVICE_IP",deviceIp);
List<TbTopoPhysicalDeviceBean> beanList=new ArrayList<TbTopoPhysicalDeviceBean>();
try {
beanList=sqlmapClient.queryForList("queryTbTopoPhysicalDevice", param);
} catch (SQLException e) {
e.printStackTrace();
}
return beanList;
}
}
... ...
package com.sitech.snmptrap;
import com.sitech.ismp.coll.basic.TblATO_KPIDETAIL;
import java.util.HashMap;
import java.util.Vector;
/**
* @author frank zmm@honggroup.com.cn
* @Description: 物理设备操作MBean。
* @Package com.sitech.snmptrap
* @ClassName: com.sitech.snmptrap.TbTopoPhysicalDeviceMBean
* @date 2017年03月03日 11:42
*/
public interface TbTopoPhysicalDeviceMBean {
/**
* 添加(修改)物理设备
* @param params
* @return
*/
Vector<TblATO_KPIDETAIL> addDevice(HashMap params);
/**
* 删除物理设备
* @param deviceId 设备ID。
* @return
*/
String deleteDevice(String deviceId);
}
... ...