use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class EditCobarPage method handleRequestInternal.
@SuppressWarnings("unchecked")
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
long cobarId = 0;
try {
cobarId = Long.parseLong(request.getParameter("cobarId").trim());
} catch (Exception e) {
throw new IllegalArgumentException("parameter 'cobarId' is invalid:" + request.getParameter("cobarId"));
}
CobarDO cobar = xmlAccesser.getCobarDAO().getCobarById(cobarId);
Map<String, Object> cobarMap = new PropertyUtilsBean().describe(cobar);
cobarMap.remove("class");
cobarMap.remove("name");
cobarMap.put("name", CobarStringUtil.htmlEscapedString(cobar.getName()));
List<ClusterDO> cList = xmlAccesser.getClusterDAO().listAllCluster();
List<Map<String, Object>> clusterList = new ArrayList<Map<String, Object>>();
for (ClusterDO e : cList) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", e.getId());
map.put("name", CobarStringUtil.htmlEscapedString(e.getName()));
clusterList.add(map);
}
return new ModelAndView("m_editCobar", new FluenceHashMap<String, Object>().putKeyValue("cluList", clusterList).putKeyValue("cobar", cobarMap));
}
use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class Index method handleRequestInternal.
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
List<ClusterDO> list = xmlAccesser.getClusterDAO().listAllCluster();
List<Map<String, Object>> clusterList = new ArrayList<Map<String, Object>>();
ListSortUtil.sortClusterBySortId(list);
for (ClusterDO e : list) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", e.getId());
map.put("name", CobarStringUtil.htmlEscapedString(e.getName()));
map.put("maintContact", e.getMaintContact());
map.put("onlineTime", e.getOnlineTime());
clusterList.add(map);
}
String result = null;
try {
result = request.getParameter("result").trim();
} catch (NullPointerException e) {
result = "null";
}
if (result == null) {
result = "null";
}
//remove attributes for login
if (null != request.getSession(false)) {
request.getSession().removeAttribute("click");
request.getSession().removeAttribute("lastRequest");
}
return new ModelAndView("index", new FluenceHashMap<String, Object>().putKeyValue("clusterList", clusterList).putKeyValue("result", result));
}
use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class MClusterListScreen method handleRequestInternal.
@SuppressWarnings("unchecked")
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
UserDO user = (UserDO) request.getSession().getAttribute("user");
List<ClusterDO> list = xmlAccesser.getClusterDAO().listAllCluster();
List<Map<String, Object>> clusterList = new ArrayList<Map<String, Object>>();
ListSortUtil.sortClusterBySortId(list);
PropertyUtilsBean util = new PropertyUtilsBean();
for (ClusterDO e : list) {
int count = xmlAccesser.getCobarDAO().getCobarList(e.getId(), ConstantDefine.ACTIVE).size();
count += xmlAccesser.getCobarDAO().getCobarList(e.getId(), ConstantDefine.IN_ACTIVE).size();
Map<String, Object> map;
try {
map = util.describe(e);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
map.remove("class");
map.remove("name");
map.remove("deployDesc");
map.put("name", CobarStringUtil.htmlEscapedString(e.getName()));
map.put("deployContact", CobarStringUtil.htmlEscapedString(e.getDeployContact()));
map.put("cobarNum", count);
clusterList.add(map);
}
return new ModelAndView("m_clusterList", new FluenceHashMap<String, Object>().putKeyValue("clusterList", clusterList).putKeyValue("user", user));
}
use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class ClusterDaoTest method testAddFristCluster.
@Test
public void testAddFristCluster() {
long testId = 1L;
ClusterDO clusterTemp = clusterDao.getClusterById(testId);
Assert.assertNull(clusterTemp);
ClusterDO cluster = DOFactory.getCluster();
clusterDao.addCluster(cluster);
Assert.assertNotNull(clusterDao.getClusterById(testId));
Assert.assertSame(cluster, clusterDao.getClusterById(testId));
read();
Assert.assertNotNull(clusterDao.getClusterById(testId));
}
use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class ClusterDaoTest method testAddManyCluster.
@Test
public void testAddManyCluster() {
int insertClusterNum = 3;
for (int i = 0; i < insertClusterNum; i++) {
ClusterDO cluster = DOFactory.getCluster();
cluster.setName("test" + i);
clusterDao.addCluster(cluster);
}
read();
List<ClusterDO> activeClusterList = clusterDao.listAllCluster();
Assert.assertEquals(insertClusterNum, activeClusterList.size());
}
Aggregations