List of usage examples for java.text NumberFormat setMaximumFractionDigits
public void setMaximumFractionDigits(int newValue)
From source file:com.afunms.system.manage.equipManager.java
public void getHome() { User vo = (User) session.getAttribute(SessionConstant.CURRENT_USER); // Date d = new Date(); // SimpleDateFormat sdf0 = new SimpleDateFormat("yyyy-MM-dd"); // String startdate = sdf0.format(d); // String todate = sdf0.format(d); ///* w ww.j ava 2s . c o m*/ // String starttime = startdate + " 00:00:00"; // String totime = todate + " 23:59:59"; // int info = 0; // int one = 0; // int two = 0; // int three = 0; // List networkCPUList = new ArrayList(); // List allinutillist = new ArrayList(); // List alloututillist = new ArrayList(); // List allhostcpulist = new ArrayList(); // List allhostmemorylist = new ArrayList(); // List allhostdisklist = new ArrayList(); List rpceventlist = new ArrayList(); // HostNodeDao nodedao = new HostNodeDao(); List networklist = new ArrayList(); List routelist = new ArrayList(); List switchlist = new ArrayList(); // List hostlist = new ArrayList(); // List dblist = new ArrayList(); // List seculist = new ArrayList(); // List storagelist = new ArrayList(); // int servicesize = 0; // int midsize = 0; int routesize = 0; int switchsize = 0; Hashtable lineHash = new Hashtable(); EventListDao eventdao = new EventListDao(); // try { servicesize = getServiceNum(vo); midsize = getMiddleService(vo); String bids = vo.getBusinessids(); if (vo.getRole() == 0 || vo.getRole() == 1) { bids = "-1"; } // try { rpceventlist = getEventList(bids); } catch (Exception e) { e.printStackTrace(); } finally { eventdao.close(); } try { networklist = nodedao.loadNetworkByBid(1, bids); // nodedao = new HostNodeDao(); seculist = nodedao.loadNetworkByBid(8, bids); // nodedao = new HostNodeDao(); routelist = nodedao.loadNetworkByBidAndCategory(1, bids); // nodedao = new HostNodeDao(); switchlist = nodedao.loadNetworkByBidAndCategory(2, bids); // nodedao = new HostNodeDao(); hostlist = nodedao.loadNetworkByBid(4, bids); } catch (Exception e) { e.printStackTrace(); } finally { nodedao.close(); } DBDao dbDao = new DBDao(); try { dblist = dbDao.getDbByMonFlag(1); } catch (Exception e) { e.printStackTrace(); } // this.removeFlexSession(); ManageXmlDao manageXmlDao = new ManageXmlDao(); List xmlList = new ArrayList(); try { xmlList = manageXmlDao.loadByPerAll(bids); } catch (Exception e) { e.printStackTrace(); } finally { manageXmlDao.close(); } try { if (xmlList != null && xmlList.size() > 0) { this.createBussTree(xmlList);// yangjun // this.createxmlfile(xmlList); } } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } finally { if (eventdao != null) { eventdao.close(); } nodedao.close(); } List monitornodelist = getMonitorListByCategory("net_server"); List hostcpusortlist = new ArrayList(); List hostmemorysortlist = new ArrayList(); NumberFormat numberFormat = new DecimalFormat(); numberFormat.setMaximumFractionDigits(0); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String date = simpleDateFormat.format(new Date()); if (monitornodelist != null) { for (int i = 0; i < monitornodelist.size(); i++) { HostNode hostNode = (HostNode) monitornodelist.get(i); MonitorNodeDTO monitorNodeDTO = getMonitorNodeDTOByHostNode(hostNode); hostcpusortlist.add(monitorNodeDTO); hostmemorysortlist.add(monitorNodeDTO); } } String field = "cpu"; ; String sorttype = "asc"; monitorListSort(hostcpusortlist, "net", "cpu", "desc"); monitorListSort(hostmemorysortlist, "net", "memory", "desc"); request.setAttribute("hostcpusortlist", hostcpusortlist); request.setAttribute("hostmemorysortlist", hostmemorysortlist); List monitornetlist = getMonitorListByCategory("net"); List netcpusortlist = new ArrayList(); List netoutsortlist = new ArrayList(); List netinsortlist = new ArrayList(); numberFormat.setMaximumFractionDigits(0); if (monitornetlist != null) { for (int i = 0; i < monitornetlist.size(); i++) { HostNode hostNode = (HostNode) monitornetlist.get(i); MonitorNodeDTO monitorNodeDTO = getMonitorNodeDTOByHostNode(hostNode); netcpusortlist.add(monitorNodeDTO); netoutsortlist.add(monitorNodeDTO); netinsortlist.add(monitorNodeDTO); } } field = getParaValue("field"); sorttype = getParaValue("sorttype"); field = "cpu"; sorttype = "asc"; monitorListSort(netcpusortlist, "net", "cpu", "desc"); monitorListSort(netoutsortlist, "net", "oututilhdx", "desc"); monitorListSort(netinsortlist, "net", "inutilhdx", "desc"); if (routelist != null) routesize = routelist.size(); if (switchlist != null) switchsize = switchlist.size(); Hashtable deviceHash = new Hashtable(); deviceHash.put("routelist", routelist); deviceHash.put("hostlist", hostlist); deviceHash.put("switchlist", switchlist); deviceHash.put("dblist", dblist); deviceHash.put("seculist", seculist); // listsession.. // listsession.. Hashtable treeBidHash = getTreeBidHash(vo, deviceHash); // System.out.println(treeBidHash); request.setAttribute("treeBidHash", treeBidHash); session.setAttribute("rpceventlist", rpceventlist); session.setAttribute("networklist", networklist); session.setAttribute("hostlist", hostlist); session.setAttribute("midsize", midsize + ""); session.setAttribute("servicesize", servicesize + ""); session.setAttribute("securesize", seculist.size() + ""); session.setAttribute("dbsize", dblist.size() + ""); session.setAttribute("routesize", routesize + ""); session.setAttribute("switchsize", switchsize + ""); session.setAttribute("hostcpusortlist", hostcpusortlist); session.setAttribute("hostmemorysortlist", hostmemorysortlist); session.setAttribute("netcpusortlist", netcpusortlist); session.setAttribute("netoutsortlist", netoutsortlist); session.setAttribute("netinsortlist", netinsortlist); }
From source file:com.brick.sms.email.MailTest.java
public void findAllApplyCompany() { Map context = new HashMap(); Map outputMap = new HashMap(); List dw = null;//from w w w. j a v a2s . co m // ? //Add by Michael 2012 02/07 ?? ? double lianbao = 0d; double huigou = 0d; Map tempSuplTrue = null; int guihutype = 0; context.put("C", ""); NumberFormat nfFSNum = new DecimalFormat("###,###,###,##0.00"); nfFSNum.setGroupingUsed(true); nfFSNum.setMaximumFractionDigits(2); try { //??????sql, if (guihutype == 0) { dw = (List) DataAccessor.query("applyCompanyManage.findAllApplyCompany", context, DataAccessor.RS_TYPE.LIST); if (dw != null) { for (int i = 0; i < dw.size(); i++) { Map temp = (Map) dw.get(i); //Modify by Michael 2012 08-06 //??? // Double lienLastPrice =(Double) (SelectReportInfo.selectApplyLienLastPrice(Integer.parseInt(temp.get("ID").toString()))==null ? 0.0 :SelectReportInfo.selectApplyLienLastPrice(Integer.parseInt(temp.get("ID").toString()))); // Double repurchLastPrice=(Double) (SelectReportInfo.selectApplyRepurchLastPrice(Integer.parseInt(temp.get("ID").toString()))==null ? 0.0 :SelectReportInfo.selectApplyRepurchLastPrice(Integer.parseInt(temp.get("ID").toString()))); //??? if (temp.get("GRANT_PRICE") != null) { //temp.put("LAST_PRICE",(lienLastPrice>0?lienLastPrice:0.0)+(repurchLastPrice>0?repurchLastPrice:0.0)); temp.put("LAST_PRICE", SelectReportInfo.selectApplyLastPrice( Integer.parseInt(temp.get("ID").toString())) == null ? 0.0 : SelectReportInfo.selectApplyLastPrice( Integer.parseInt(temp.get("ID").toString()))); } Map LastPrice = (Map) DataAccessor.query( "beforeMakeContract.selectApplySumIrrMonthAndLastPrice", temp, DataAccessor.RS_TYPE.MAP); if (LastPrice != null) { temp.put("SUMLASTPRICE", LastPrice.get("SHENGYUBENJIN")); } //Add by Michael 2012 02/07 ?? ?-------------- Map allLastPriceMap = SelectReportInfo .selectApplyAllLastPrice(Integer.parseInt(temp.get("ID").toString())); if (allLastPriceMap != null) { lianbao = DataUtil.doubleUtil(allLastPriceMap.get("shouxinjianshaoe_lien")); temp.put("LIANBAO", lianbao); huigou = DataUtil.doubleUtil(allLastPriceMap.get("shouxinjianshaoe_repurch")); temp.put("HUIGOU", huigou); } //------------------------------------------------------------------- } } } if (dw.size() > 0) { StringBuffer mailContent = new StringBuffer(); mailContent.append("<html><head></head>"); mailContent.append("<style>.rhead { background-color: #006699}" + ".Body2 { font-family: Arial, Helvetica, sans-serif; font-weight: normal; color: #000000; font-size: 9pt; text-decoration: none}" + ".Body2BoldWhite2 { font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #FFFFFF; font-size: 11pt; text-decoration: none }" + ".Body2Bold { font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #000000; font-size: 8pt; text-decoration: none }" + ".r11 { background-color: #C4E2EC}" + ".r12 { background-color: #D2EFF0}</style><body>"); mailContent.append("<font size='3'><b>??:<b><br></font>" + "<font size='2'>????~</font><br><br>"); mailContent.append( "<table border='1' cellspacing='0' width='1050px;' cellpadding='0'>" + "<tr class='rhead'>" + "<td class='Body2BoldWhite2' style='width:40px;' align='center'>??</td>" + "<td class='Body2BoldWhite2' style='width:100px;' align='center'></td>" + "<td class='Body2BoldWhite2' align='center'>??</td>" + "<td class='Body2BoldWhite2' align='center'>?</td>" + "<td class='Body2BoldWhite2' align='center'>??</td>" + "<td class='Body2BoldWhite2' align='center'>?</td></tr>"); int num = 0; for (int i = 0; i < dw.size(); i++) { num++; mailContent.append("<tr class='r12'>" + "<td class=body2 >" + num + "</td>" + "<td class=body2 >" + ((Map) dw.get(i)).get("NAME") + "</td>" + "<td class=body2 >" + ((Map) dw.get(i)).get("LIEN_GRANT_PRICE") + "</td>" + "<td class=body2 >" + ((Map) dw.get(i)).get("REPURCH_GRANT_PRICE") + "</td>" + "<td class=body2 >" + ((Map) dw.get(i)).get("LIANBAO") + "</td>" + "<td class=body2>" + ((Map) dw.get(i)).get("HUIGOU") + "</td></tr>"); } mailContent.append("</table>"); mailContent.append("</body></html>"); MailSettingTo mailSettingTo = new MailSettingTo(); mailSettingTo.setEmailTo("michael@tacleasing.cn"); mailSettingTo.setEmailSubject(""); mailSettingTo.setEmailContent(mailContent.toString()); mailUtilService.sendMail(mailSettingTo); } } catch (Exception e) { // TODO: handle exception } }
From source file:com.brick.sms.email.MailTest.java
public void sendAllSupplierGrantPriceExpireeList() throws MessagingException { try {//from w w w . ja v a2 s . co m Map tempMap = new HashMap(); List<Map<String, Object>> supplierGrantPriceExpireeList = null; supplierGrantPriceExpireeList = (List<Map<String, Object>>) DataAccessor .query("applyCompanyManage.getSupplierGrantPriceExpire", tempMap, DataAccessor.RS_TYPE.LIST); //?????Mail if (supplierGrantPriceExpireeList == null || supplierGrantPriceExpireeList.size() == 0) { return; } NumberFormat nfFSNum = new DecimalFormat("#,###,###,##0.00"); nfFSNum.setGroupingUsed(true); nfFSNum.setMaximumFractionDigits(2); StringBuffer mailContent = new StringBuffer(); mailContent.append("<html><head></head>"); mailContent.append("<body>"); mailContent.append("<font size='3'><b>??:<b><br></font>" + "<font size='2'>???List?~</font><br><br>"); mailContent.append( "<table cellspacing='1' width='1050px;' cellpadding='2' style=\"background-color: black;\">" + "<tr>" + "<th style=\"background-color: #FFFFFF; width:30px;\">??</th>" + "<th style=\"background-color: #FFFFFF; width:100px;\">()</th>" + "<th align='center' style=\"background-color: #FFFF99\">?</th>" + "<th align='center' style=\"background-color: #FFFF99\">??</th>" + "<th align='center' style=\"background-color: #FFFF99\">??</th>" + "<th align='center' style=\"background-color: #99CCFF\"></th>" + "<th align='center' style=\"background-color: #99CCFF\">?</th>" + "<th align='center' style=\"background-color: #99CCFF\">?</th>" + "<th align='center' style=\"background-color: #33CCCC\">?</th>" + "<th align='center' style=\"background-color: #33CCCC\">??</th>" + "<th align='center' style=\"background-color: #33CCCC\">??</th>" + "<th align='center' style=\"background-color: #8080C0\">?</th>" + "<th align='center' style=\"background-color: #8080C0\">??</th>" + "<th align='center' style=\"background-color: #8080C0\">??</th>" + "</tr>"); for (int i = 0; i < supplierGrantPriceExpireeList.size(); i++) { tempMap = (Map) supplierGrantPriceExpireeList.get(i); mailContent.append("<tr>" + "<td style=\"background-color: #FFFFFF\">" + (i + 1) + "</td>" + "<td style=\"background-color: #FFFFFF\">" + supplierGrantPriceExpireeList.get(i).get("NAME") + "(" + supplierGrantPriceExpireeList.get(i).get("SUPP_LEVEL") + ")" + "</td>" + "<td style=\"background-color: #FFFF99\">" + supplierGrantPriceExpireeList.get(i).get("LIEN_START_DATE") + "</td>" + "<td style=\"background-color: #FFFF99\">" + supplierGrantPriceExpireeList.get(i).get("LIEN_END_DATE") + "</td>" + "<td align='right' style=\"background-color: #FFFF99\">" + updateMoney( DataUtil.doubleUtil(supplierGrantPriceExpireeList.get(i).get("LIEN_GRANT_PRICE")), nfFSNum) + "</td>" + "<td style=\"background-color: #99CCFF\">" + supplierGrantPriceExpireeList.get(i).get("REPURCH_START_DATE") + "</td>" + "<td style=\"background-color: #99CCFF\">" + supplierGrantPriceExpireeList.get(i).get("REPURCH_END_DATE") + "</td>" + "<td align='right' style=\"background-color: #99CCFF\">" + updateMoney(DataUtil.doubleUtil( supplierGrantPriceExpireeList.get(i).get("REPURCH_GRANT_PRICE")), nfFSNum) + "</td>" + "<td style=\"background-color: #33CCCC\">" + supplierGrantPriceExpireeList.get(i).get("ADVANCE_START_DATE") + "</td>" + "<td style=\"background-color: #33CCCC\">" + supplierGrantPriceExpireeList.get(i).get("ADVANCE_END_DATE") + "</td>" + "<td align='right' style=\"background-color: #33CCCC\">" + updateMoney( DataUtil.doubleUtil( supplierGrantPriceExpireeList.get(i).get("ADVANCEMACHINE_GRANT_PRICE")), nfFSNum) + "</td>" + "<td style=\"background-color: #8080C0\">" + supplierGrantPriceExpireeList.get(i).get("VOICE_START_DATE") + "</td>" + "<td style=\"background-color: #8080C0\">" + supplierGrantPriceExpireeList.get(i).get("VOICE_END_DATE") + "</td>" + "<td align='right' style=\"background-color: #8080C0\">" + updateMoney(DataUtil.doubleUtil(supplierGrantPriceExpireeList.get(i).get("VOICE_CREDIT")), nfFSNum) + "</td>" + "</tr>"); } mailContent.append("</table>"); mailContent.append("</body></html>"); MailSettingTo mailSettingTo = new MailSettingTo(); mailSettingTo.setEmailContent(mailContent.toString()); mailUtilService.sendMail(226, mailSettingTo); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.afunms.system.manage.equipManager.java
/** * hostNode MonitorNodeDTO// w w w . ja v a 2s .co m * * @param hostNode * @return */ public MonitorNodeDTO getMonitorNodeDTOByHostNode(HostNode hostNode) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String date = simpleDateFormat.format(new Date()); String starttime = date + " 00:00:00"; String totime = date + " 23:59:59"; NumberFormat numberFormat = new DecimalFormat(); numberFormat.setMaximumFractionDigits(0); MonitorNodeDTO monitorNodeDTO = null; String ipAddress = hostNode.getIpAddress(); int nodeId = hostNode.getId(); String alias = hostNode.getAlias(); int category = hostNode.getCategory(); if (category == 1) { monitorNodeDTO = new MonitorNetDTO(); monitorNodeDTO.setCategory(""); } else if (category == 4) { monitorNodeDTO = new MonitorHostDTO(); monitorNodeDTO.setCategory(""); } else { monitorNodeDTO = new MonitorNetDTO(); monitorNodeDTO.setCategory(""); } // id monitorNodeDTO.setId(nodeId); // ip monitorNodeDTO.setIpAddress(ipAddress); // monitorNodeDTO.setAlias(alias); Host node = (Host) PollingEngine.getInstance().getNodeByID(nodeId); // if (node != null) { monitorNodeDTO.setStatus(node.getStatus() + ""); } else { monitorNodeDTO.setStatus("0"); } // monitorNodeDTO.setStatus(node.getAlarmlevel() + ""); String cpuValue = "0"; // cpu 0 String memoryValue = "0"; // memory 0 String inutilhdxValue = "0"; // inutilhdx 0 String oututilhdxValue = "0"; // oututilhdx 0 String pingValue = "0"; // ping 0 String eventListCount = ""; // eventListCount 0 String collectType = ""; // String cpuValueColor = "green"; // cpu String memoryValueColor = "green"; // memory String generalAlarm = "0"; // 0 String urgentAlarm = "0"; // 0 String seriousAlarm = "0"; // 0 double cpuValueDouble = 0; double memeryValueDouble = 0; Hashtable eventListSummary = new Hashtable(); Hashtable sharedata = ShareData.getSharedata(); Hashtable ipAllData = (Hashtable) sharedata.get(ipAddress); Hashtable allpingdata = ShareData.getPingdata(); if (ipAllData != null) { Vector cpuV = (Vector) ipAllData.get("cpu"); if (cpuV != null && cpuV.size() > 0) { CPUcollectdata cpu = (CPUcollectdata) cpuV.get(0); if (cpu != null && cpu.getThevalue() != null) { cpuValueDouble = Double.valueOf(cpu.getThevalue()); cpuValue = numberFormat.format(cpuValueDouble); } } Vector memoryVector = (Vector) ipAllData.get("memory"); int allmemoryvalue = 0; if (memoryVector != null && memoryVector.size() > 0) { for (int si = 0; si < memoryVector.size(); si++) { Memorycollectdata memorydata = (Memorycollectdata) memoryVector.elementAt(si); if (memorydata.getEntity().equalsIgnoreCase("Utilization")) { // // if // (memorydata.getSubentity().equalsIgnoreCase("PhysicalMemory")) // { // memeryValueDouble = memeryValueDouble + // Double.valueOf(memorydata.getThevalue()); // } if (category == 4 && memorydata.getSubentity().equalsIgnoreCase("PhysicalMemory")) {// memeryValueDouble = Double.valueOf(memorydata.getThevalue()); } if (category == 1 || category == 2 || category == 3) {// allmemoryvalue = allmemoryvalue + Integer.parseInt(memorydata.getThevalue()); if (si == memoryVector.size() - 1) { memeryValueDouble = allmemoryvalue / memoryVector.size(); } } } } memoryValue = numberFormat.format(memeryValueDouble); } Vector allutil = (Vector) ipAllData.get("allutilhdx"); if (allutil != null && allutil.size() == 3) { AllUtilHdx inutilhdx = (AllUtilHdx) allutil.get(0); inutilhdxValue = inutilhdx.getThevalue(); AllUtilHdx oututilhdx = (AllUtilHdx) allutil.get(1); oututilhdxValue = oututilhdx.getThevalue(); } } if (allpingdata != null) { Vector pingData = (Vector) allpingdata.get(ipAddress); if (pingData != null && pingData.size() > 0) { Pingcollectdata pingcollectdata = (Pingcollectdata) pingData.get(0); pingValue = pingcollectdata.getThevalue(); } } String count = ""; EventListDao eventListDao = new EventListDao(); try { if ("mysql".equalsIgnoreCase(SystemConstant.DBType)) { generalAlarm = eventListDao.getCountByWhere(" where nodeid='" + hostNode.getId() + "'" + " and level1='1' and recordtime>='" + starttime + "' and recordtime<='" + totime + "'"); urgentAlarm = eventListDao.getCountByWhere(" where nodeid='" + hostNode.getId() + "'" + " and level1='2' and recordtime>='" + starttime + "' and recordtime<='" + totime + "'"); seriousAlarm = eventListDao.getCountByWhere(" where nodeid='" + hostNode.getId() + "'" + " and level1='3' and recordtime>='" + starttime + "' and recordtime<='" + totime + "'"); } else if ("oracle".equalsIgnoreCase(SystemConstant.DBType)) { generalAlarm = eventListDao.getCountByWhere( " where nodeid=" + hostNode.getId() + "" + " and level1=1 and recordtime>=to_date('" + starttime + "','YYYY-MM-DD HH24:MI:SS') and recordtime<=to_date('" + totime + "','YYYY-MM-DD HH24:MI:SS')"); urgentAlarm = eventListDao.getCountByWhere( " where nodeid=" + hostNode.getId() + "" + " and level1=2 and recordtime>=to_date('" + starttime + "','YYYY-MM-DD HH24:MI:SS') and recordtime<=to_date('" + totime + "','YYYY-MM-DD HH24:MI:SS')"); seriousAlarm = eventListDao.getCountByWhere( " where nodeid=" + hostNode.getId() + "" + " and level1=3 and recordtime>=to_date('" + starttime + "','YYYY-MM-DD HH24:MI:SS') and recordtime<=to_date('" + totime + "','YYYY-MM-DD HH24:MI:SS')"); } } catch (Exception e) { e.printStackTrace(); } finally { eventListDao.close(); } eventListCount = count; eventListSummary.put("generalAlarm", generalAlarm); eventListSummary.put("urgentAlarm", urgentAlarm); eventListSummary.put("seriousAlarm", seriousAlarm); monitorNodeDTO.setEventListSummary(eventListSummary); if (SystemConstant.COLLECTTYPE_SNMP == hostNode.getCollecttype()) { collectType = "SNMP"; } else if (SystemConstant.COLLECTTYPE_PING == hostNode.getCollecttype()) { collectType = "PING"; } else if (SystemConstant.COLLECTTYPE_REMOTEPING == hostNode.getCollecttype()) { collectType = "REMOTEPING"; } else if (SystemConstant.COLLECTTYPE_SHELL == hostNode.getCollecttype()) { collectType = "SHELL"; } else if (SystemConstant.COLLECTTYPE_SSH == hostNode.getCollecttype()) { collectType = "SSH"; } else if (SystemConstant.COLLECTTYPE_TELNET == hostNode.getCollecttype()) { collectType = "TELNET"; } else if (SystemConstant.COLLECTTYPE_WMI == hostNode.getCollecttype()) { collectType = "WMI"; } NodeMonitorDao nodeMonitorDao = new NodeMonitorDao(); List nodeMonitorList = null; try { nodeMonitorList = nodeMonitorDao.loadByNodeID(nodeId); } catch (RuntimeException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { nodeMonitorDao.close(); } if (nodeMonitorList != null) { for (int j = 0; j < nodeMonitorList.size(); j++) { NodeMonitor nodeMonitor = (NodeMonitor) nodeMonitorList.get(j); if ("cpu".equals(nodeMonitor.getCategory())) { if (cpuValueDouble > nodeMonitor.getLimenvalue2()) { cpuValueColor = "red"; } else if (cpuValueDouble > nodeMonitor.getLimenvalue1()) { cpuValueColor = "orange"; } else if (cpuValueDouble > nodeMonitor.getLimenvalue0()) { cpuValueColor = "yellow"; } else { cpuValueColor = "green"; } } if ("memory".equals(nodeMonitor.getCategory())) { if (memeryValueDouble > nodeMonitor.getLimenvalue2()) { memoryValueColor = "red"; } else if (memeryValueDouble > nodeMonitor.getLimenvalue1()) { memoryValueColor = "orange"; } else if (memeryValueDouble > nodeMonitor.getLimenvalue0()) { memoryValueColor = "yellow"; } else { memoryValueColor = "green"; } } } } monitorNodeDTO.setCpuValue(cpuValue); monitorNodeDTO.setMemoryValue(memoryValue); monitorNodeDTO.setInutilhdxValue(inutilhdxValue); monitorNodeDTO.setOututilhdxValue(oututilhdxValue); monitorNodeDTO.setPingValue(pingValue); monitorNodeDTO.setEventListCount(eventListCount); monitorNodeDTO.setCollectType(collectType); monitorNodeDTO.setCpuValueColor(cpuValueColor); monitorNodeDTO.setMemoryValueColor(memoryValueColor); return monitorNodeDTO; }
From source file:org.sakaiproject.content.tool.ListItem.java
public ListItem(ResourceToolActionPipe pipe, ListItem parent, Time defaultRetractTime) { this.constructor = 3; if (contentService == null) { contentService = (org.sakaiproject.content.api.ContentHostingService) ComponentManager .get(org.sakaiproject.content.api.ContentHostingService.class); }//from ww w .ja v a2s . c o m this.entity = null; this.containingCollectionId = parent.getId(); ResourceTypeRegistry registry = (ResourceTypeRegistry) ComponentManager .get("org.sakaiproject.content.api.ResourceTypeRegistry"); this.resourceType = pipe.getAction().getTypeId(); this.resourceTypeDef = registry.getType(resourceType); this.hoverText = this.name; if (resourceTypeDef != null) { this.hoverText = resourceTypeDef.getLocalizedHoverText(null); this.iconLocation = resourceTypeDef.getIconLocation(this.entity); String[] args = { resourceTypeDef.getLabel() }; this.otherActionsLabel = trb.getFormattedMessage("action.other", args); // NOTE: Don't do this at home kids, this is hackery of the worst order! // Resources of type HTML & Text take on default file names: String nameValue = null; if (getResourceType().endsWith("HtmlDocumentType")) { nameValue = trb.getString("new.type.html"); } else if (getResourceType().endsWith("TextDocumentType")) { nameValue = trb.getString("new.type.text"); } else { nameValue = trb.getFormattedMessage("create.unknown", args); } this.name = nameValue; } this.collection = ResourceType.TYPE_FOLDER.equals(resourceType); this.id = ""; this.parent = parent; this.permissions = parent.getPermissions(); this.selected = false; if (this.collection) { int collection_size = 0; String[] args = { Integer.toString(0) }; setSize(rb.getFormattedMessage("size.items", args)); setIsEmpty(true); setSortable(false); setIsTooBig(false); setIsTooBigNav(false); } else { this.mimetype = pipe.getMimeType(); if (this.mimetype == null) { } else if (this.iconLocation == null) { this.iconLocation = ContentTypeImageService.getContentTypeImage(this.mimetype); } String size = ""; if (pipe.getContent() != null) { long size_long = pipe.getContent().length; NumberFormat formatter = NumberFormat.getInstance(rb.getLocale()); formatter.setMaximumFractionDigits(1); if (size_long > 700000000L) { String[] args = { formatter.format(1.0 * size_long / (1024L * 1024L * 1024L)) }; size = rb.getFormattedMessage("size.gb", args); } else if (size_long > 700000L) { String[] args = { formatter.format(1.0 * size_long / (1024L * 1024L)) }; size = rb.getFormattedMessage("size.mb", args); } else if (size_long > 700L) { String[] args = { formatter.format(1.0 * size_long / 1024L) }; size = rb.getFormattedMessage("size.kb", args); } else { String[] args = { formatter.format(size_long) }; size = rb.getFormattedMessage("size.bytes", args); } } setSize(size); } if (this.id != null && !this.id.trim().equals("")) { this.isDropbox = contentService.isInDropbox(id); } else if (this.containingCollectionId != null) { this.isDropbox = contentService.isInDropbox(this.containingCollectionId); } else { this.isDropbox = parent.isDropbox; } this.isCourseSite = parent.isCourseSite(); Time now = TimeService.newTime(); User creator = UserDirectoryService.getCurrentUser(); if (creator != null) { String createdBy = creator.getDisplayName(); setCreatedBy(createdBy); setModifiedBy(createdBy); } // setCreatedBy(props.getProperty(ResourceProperties.PROP_CREATOR)); this.setModifiedTime(now.getDisplay()); this.setCreatedTime(now.getDisplay()); this.setSiteGroups(parent.siteGroupsMap.values()); this.accessMode = AccessMode.INHERITED; this.inheritedAccessMode = parent.getEffectiveAccess(); //this.effectiveAccess = parent.getEffectiveAccess(); this.groups.clear(); //this.groups.addAll(); this.inheritedGroups.clear(); if (parent.getAccessMode() == AccessMode.GROUPED) { this.inheritedGroups.addAll(parent.getGroups()); this.setPossibleGroups(parent.getGroups()); } else { this.inheritedGroups.addAll(parent.getInheritedGroups()); this.setPossibleGroups(parent.getPossibleGroups()); } this.inheritedRoleIds.addAll(parent.inheritedRoleIds); this.inheritedRoleIds.addAll(parent.roleIds); if (this.inheritsRoles()) { this.roleIds.clear(); } else { this.setPubview(contentService.isPubView(id)); } this.hidden = false; this.useReleaseDate = false; this.useRetractDate = false; this.isAvailable = parent.isAvailable(); String refstr = contentService.getReference(id); this.isSiteCollection = this.siteCollection(refstr); boolean isUserSite = isInWorkspace(parent, refstr); setUserSite(isUserSite); }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
private XYPlot getXYPlot(List<cfCHARTSERIESData> series, String xAxisTitle, String yAxisTitle, String labelFormat, boolean bShowMarkers, int markerSize, boolean bShow3D, String tipStyle, String drillDownUrl, int xOffset, int yOffset, int yAxisUnits, String seriesPlacement, int height, int gridLines) throws cfmRunTimeException { // Create an XY plot XYPlot plot = new XYPlot(); ValueAxis domainAxis;/*from w ww . j ava 2 s. co m*/ if (series.get(0).getSeriesDataType() == cfCHARTSERIESData.XY_NUMERIC_SERIES) { if (bShow3D) domainAxis = new NumberAxis3D(xAxisTitle); else domainAxis = new NumberAxis(xAxisTitle); } else { domainAxis = new DateAxis(xAxisTitle); } plot.setDomainAxis(domainAxis); ValueAxis valueAxis; DateFormat dateFormat = null; NumberFormat numberFormat = null; if (labelFormat.equals("date")) { valueAxis = new DateAxis(yAxisTitle); dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); ((DateAxis) valueAxis).setDateFormatOverride(dateFormat); } else { if (bShow3D) valueAxis = new NumberAxis3D(yAxisTitle); else valueAxis = new NumberAxis(yAxisTitle); if (labelFormat.equals("currency")) { ((NumberAxis) valueAxis).setNumberFormatOverride(NumberFormat.getCurrencyInstance()); numberFormat = NumberFormat.getCurrencyInstance(); } else if (labelFormat.equals("percent")) { numberFormat = NumberFormat.getPercentInstance(); numberFormat.setMaximumFractionDigits(3); // without this change .11443 // would be displayed as 11% // instead of 11.443% ((NumberAxis) valueAxis).setNumberFormatOverride(numberFormat); } else { numberFormat = NumberFormat.getInstance(); } if (yAxisUnits != 0) ((NumberAxis) valueAxis).setTickUnit(new NumberTickUnit(yAxisUnits)); } plot.setRangeAxis(valueAxis); // Add a dataset and renderer for each series int barChartDatasetIndex = -1; int hBarChartDatasetIndex = -1; int num = 0; MinMaxData minMax = new MinMaxData(); for (int i = 0; i < series.size(); i++) { cfCHARTSERIESData seriesData = series.get(i); XYSeriesCollection dataset; if ((barChartDatasetIndex != -1) && (seriesData.getType().equals("bar"))) { dataset = (XYSeriesCollection) plot.getDataset(barChartDatasetIndex); addSeriesDataToDataset(seriesData, dataset, minMax); // Set the paint style for this series setPaintStyle(seriesData.getPaintStyle(), plot.getRenderer(barChartDatasetIndex), dataset.getSeriesCount() - 1, height); // Add the color list for this series to the custom color renderer CustomColorRenderer cr = (CustomColorRenderer) plot.getRenderer(barChartDatasetIndex); cr.addColors(getColorList(seriesData)); continue; } else if ((hBarChartDatasetIndex != -1) && (seriesData.getType().equals("horizontalbar"))) { dataset = (XYSeriesCollection) plot.getDataset(hBarChartDatasetIndex); addSeriesDataToDataset(seriesData, dataset, minMax); // Set the paint style for this series setPaintStyle(seriesData.getPaintStyle(), plot.getRenderer(hBarChartDatasetIndex), dataset.getSeriesCount() - 1, height); // Add the color list for this series to the custom color renderer CustomColorRenderer cr = (CustomColorRenderer) plot.getRenderer(hBarChartDatasetIndex); cr.addColors(getColorList(seriesData)); continue; } else { dataset = new XYSeriesCollection(); addSeriesDataToDataset(seriesData, dataset, minMax); } plot.setDataset(num, dataset); XYItemRenderer renderer = null; if (seriesData.getType().equals("bar")) { plot.setOrientation(PlotOrientation.VERTICAL); renderer = getXYBarRenderer(seriesPlacement, bShow3D, xOffset, yOffset, getColorList(seriesData)); ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); renderer.setPositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); renderer.setNegativeItemLabelPosition(position2); ((XYBarRenderer) renderer).setMargin(0.2); // The margin between each // category barChartDatasetIndex = num; } else if (seriesData.getType().equals("horizontalbar")) { plot.setOrientation(PlotOrientation.HORIZONTAL); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); renderer = getXYBarRenderer(seriesPlacement, bShow3D, xOffset, yOffset, getColorList(seriesData)); ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT); renderer.setNegativeItemLabelPosition(position2); ((XYBarRenderer) renderer).setMargin(0.2); // The margin between each // category hBarChartDatasetIndex = num; } else if (seriesData.getType().equals("line")) { renderer = new XYLineAndShapeRenderer(true, false); // Enable/Disable displaying of markers ((XYLineAndShapeRenderer) renderer).setShapesVisible(bShowMarkers); // Set the shape of the markers based on the markerSize value ((XYLineAndShapeRenderer) renderer).setShape(getMarker(seriesData.getMarkerStyle(), markerSize)); } else if (seriesData.getType().equals("area")) { renderer = new CustomXYAreaRenderer(); } else if (seriesData.getType().equals("step")) { renderer = new CustomXYStepRenderer(); } else if (seriesData.getType().equals("scatter")) { renderer = new XYLineAndShapeRenderer(false, true); // Set the shape of the markers based on the markerSize value ((XYLineAndShapeRenderer) renderer).setShape(getMarker(seriesData.getMarkerStyle(), markerSize)); } if (!tipStyle.equals("none")) { if (series.get(0).getSeriesDataType() == cfCHARTSERIESData.XY_DATE_SERIES) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: {1}", DateFormat.getInstance(), DateFormat.getInstance())); } else { if (dateFormat != null) renderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator("{0}: {2}", dateFormat, dateFormat)); else renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})", numberFormat, NumberFormat.getInstance())); } } if (drillDownUrl != null) { if (dateFormat != null) renderer.setURLGenerator( new com.newatlanta.bluedragon.XYURLGenerator(drillDownUrl, dateFormat)); else renderer.setURLGenerator( new com.newatlanta.bluedragon.XYURLGenerator(drillDownUrl, numberFormat)); } if (seriesData.getSeriesColor() != null) renderer.setSeriesPaint(0, convertStringToColor(seriesData.getSeriesColor())); String dataLabelStyle = seriesData.getDataLabelStyle(); if (labelFormat.equals("date")) { if (dataLabelStyle.equals("none")) { renderer.setItemLabelsVisible(false); } else { setXYItemLabelsData(renderer, seriesData); if (dataLabelStyle.equals("value")) renderer.setItemLabelGenerator( new StandardXYItemLabelGenerator("{2}", dateFormat, dateFormat)); else if (dataLabelStyle.equals("rowlabel")) renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator("{0}", NumberFormat.getInstance(), NumberFormat.getInstance())); else if (dataLabelStyle.equals("columnlabel")) renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator("{1}", NumberFormat.getInstance(), NumberFormat.getInstance())); else if (dataLabelStyle.equals("pattern")) renderer.setItemLabelGenerator(new XYItemLabelGenerator("{2}", dateFormat, dateFormat)); else renderer.setItemLabelGenerator( new XYItemLabelGenerator(dataLabelStyle, dateFormat, dateFormat)); } } else { if (dataLabelStyle.equals("none")) { renderer.setItemLabelsVisible(false); } else { setXYItemLabelsData(renderer, seriesData); if (dataLabelStyle.equals("value")) { renderer.setItemLabelGenerator( new StandardXYItemLabelGenerator("{2}", numberFormat, numberFormat)); } else if (dataLabelStyle.equals("rowlabel")) { renderer.setItemLabelGenerator( new StandardXYItemLabelGenerator("{0}", numberFormat, numberFormat)); } else if (dataLabelStyle.equals("columnlabel")) { if (series.get(0).getSeriesDataType() == cfCHARTSERIESData.XY_DATE_SERIES) { renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator("{1}", SimpleDateFormat.getInstance(), NumberFormat.getInstance())); } else { renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator("{1}", NumberFormat.getInstance(), NumberFormat.getInstance())); } } else if (dataLabelStyle.equals("pattern")) { if (series.get(0).getSeriesDataType() == cfCHARTSERIESData.XY_DATE_SERIES) { renderer.setItemLabelGenerator(new XYItemLabelGenerator("{1} {2} ({3} of {4})", SimpleDateFormat.getInstance(), numberFormat)); } else { renderer.setItemLabelGenerator(new XYItemLabelGenerator("{1} {2} ({3} of {4})", NumberFormat.getInstance(), numberFormat)); } } else { renderer.setItemLabelGenerator( new XYItemLabelGenerator(dataLabelStyle, NumberFormat.getInstance(), numberFormat)); } } } // Add the renderer to the plot. // NOTE: this must be done before the setPaintStyle() call so the // DrawingSupplier object // will be set up properly for the generation of default colors. plot.setRenderer(num, renderer); // Set the paint style for this series (series 0) if (seriesData.getType().equals("bar") || seriesData.getType().equals("horizontalbar") || seriesData.getType().equals("area")) setPaintStyle(seriesData.getPaintStyle(), renderer, 0, height); num++; } // If gridLines was specified then we need to calculate the yAxisUnits if ((gridLines != -1) && (valueAxis instanceof NumberAxis)) { // Calculate the yAxisUnits we need to use to create the number of // gridLines yAxisUnits = calculateYAxisUnits(gridLines, minMax); // Set the yAxisUnits ((NumberAxis) valueAxis).setTickUnit(new NumberTickUnit(yAxisUnits)); } return plot; }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
private CategoryPlot getCategoryPlot(List<cfCHARTSERIESData> series, String xAxisTitle, String yAxisTitle, String labelFormat, boolean bShowMarkers, int markerSize, boolean bShow3D, String tipStyle, String drillDownUrl, int xOffset, int yOffset, int yAxisUnits, String seriesPlacement, boolean bSortXAxis, int height, String[] yAxisSymbols, int gridLines) throws cfmRunTimeException { // Create a category plot CategoryPlot plot = new CategoryPlot(); // Set the domain axis (the x-axis) org.jfree.chart.axis.CategoryAxis categoryAxis; if (bShow3D)/*w w w . java 2 s.c o m*/ categoryAxis = new CategoryAxis3D(xAxisTitle); else categoryAxis = new CategoryAxis(xAxisTitle); plot.setDomainAxis(categoryAxis); // Set the range axis (the y-axis) ValueAxis valueAxis; DateFormat dateFormat = null; NumberFormat numberFormat = null; // Ignore a label format of date if the y-axis is using symbols if (labelFormat.equals("date") && (yAxisSymbols == null)) { valueAxis = new DateAxis(yAxisTitle); dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); ((DateAxis) valueAxis).setDateFormatOverride(dateFormat); } else { if (yAxisSymbols != null) { valueAxis = new SymbolAxis(yAxisTitle, yAxisSymbols); ((SymbolAxis) valueAxis).setGridBandsVisible(false); ((SymbolAxis) valueAxis).setAutoRangeStickyZero(true); } else if (bShow3D) { valueAxis = new NumberAxis3D(yAxisTitle); } else { valueAxis = new NumberAxis(yAxisTitle); } if (labelFormat.equals("currency")) { ((NumberAxis) valueAxis).setNumberFormatOverride(NumberFormat.getCurrencyInstance()); numberFormat = NumberFormat.getCurrencyInstance(); } else if (labelFormat.equals("percent")) { numberFormat = NumberFormat.getPercentInstance(); numberFormat.setMaximumFractionDigits(3); // without this change .11443 // would be displayed as 11% // instead of 11.443% ((NumberAxis) valueAxis).setNumberFormatOverride(numberFormat); } else { numberFormat = NumberFormat.getInstance(); } if (yAxisUnits != 0) ((NumberAxis) valueAxis).setTickUnit(new NumberTickUnit(yAxisUnits)); } plot.setRangeAxis(valueAxis); // Add a dataset and renderer for each series int barChartDatasetIndex = -1; int hBarChartDatasetIndex = -1; int num = 0; MinMaxData minMax = new MinMaxData(); for (int i = 0; i < series.size(); i++) { cfCHARTSERIESData seriesData = series.get(i); // If the sortXAxis attribute was set to "yes" then sort the data. // NOTE: this attribute is only used with category charts. if (bSortXAxis) seriesData.sort(); DefaultCategoryDataset dataset; if ((barChartDatasetIndex != -1) && (seriesData.getType().equals("bar"))) { dataset = (DefaultCategoryDataset) plot.getDataset(barChartDatasetIndex); addSeriesDataToDataset(seriesData, dataset, minMax); // Set the paint style for this series setPaintStyle(seriesData.getPaintStyle(), plot.getRenderer(barChartDatasetIndex), dataset.getRowCount() - 1, height); // Add the color list for this series to the custom color renderer CustomColorRenderer cr = (CustomColorRenderer) plot.getRenderer(barChartDatasetIndex); cr.addColors(getColorList(seriesData)); continue; } else if ((hBarChartDatasetIndex != -1) && (seriesData.getType().equals("horizontalbar"))) { dataset = (DefaultCategoryDataset) plot.getDataset(hBarChartDatasetIndex); addSeriesDataToDataset(seriesData, dataset, minMax); // Set the paint style for this series setPaintStyle(seriesData.getPaintStyle(), plot.getRenderer(hBarChartDatasetIndex), dataset.getRowCount() - 1, height); // Add the color list for this series to the custom color renderer CustomColorRenderer cr = (CustomColorRenderer) plot.getRenderer(hBarChartDatasetIndex); cr.addColors(getColorList(seriesData)); continue; } else { dataset = new DefaultCategoryDataset(); addSeriesDataToDataset(seriesData, dataset, minMax); } plot.setDataset(num, dataset); AbstractCategoryItemRenderer renderer = null; if (seriesData.getType().equals("bar")) { plot.setOrientation(PlotOrientation.VERTICAL); renderer = getBarRenderer(seriesPlacement, bShow3D, xOffset, yOffset, getColorList(seriesData)); ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); renderer.setPositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); renderer.setNegativeItemLabelPosition(position2); ((BarRenderer) renderer).setItemMargin(0.0); // The margin between items // in the same category categoryAxis.setCategoryMargin(0.2); // The margin between each category barChartDatasetIndex = num; } else if (seriesData.getType().equals("horizontalbar")) { plot.setOrientation(PlotOrientation.HORIZONTAL); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); renderer = getBarRenderer(seriesPlacement, bShow3D, xOffset, yOffset, getColorList(seriesData)); if (bShow3D) { // change rendering order to ensure that bar overlapping is the // right way around plot.setRowRenderingOrder(org.jfree.util.SortOrder.DESCENDING); plot.setColumnRenderingOrder(org.jfree.util.SortOrder.DESCENDING); } ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT); renderer.setNegativeItemLabelPosition(position2); ((BarRenderer) renderer).setItemMargin(0.0); // The margin between items // in the same category categoryAxis.setCategoryMargin(0.2); // The margin between each category hBarChartDatasetIndex = num; } else if (seriesData.getType().equals("line")) { if (bShow3D) { renderer = new LineRenderer3D(); ((LineRenderer3D) renderer).setXOffset(xOffset); ((LineRenderer3D) renderer).setYOffset(yOffset); } else { renderer = new LineAndShapeRenderer(true, false); } // Enable/Disable displaying of markers ((LineAndShapeRenderer) renderer).setShapesVisible(bShowMarkers); // Set the shape of the markers based on the markerSize value ((LineAndShapeRenderer) renderer).setShape(getMarker(seriesData.getMarkerStyle(), markerSize)); } else if (seriesData.getType().equals("area")) { if (seriesPlacement.equals("stacked")) renderer = new StackedAreaRenderer(); // this doesn't work for some // reason else renderer = new AreaRenderer(); // Truncate the first and last values to match CFMX 7 ((AreaRenderer) renderer).setEndType(AreaRendererEndType.TRUNCATE); categoryAxis.setCategoryMargin(0.0); } else if (seriesData.getType().equals("step")) { renderer = new CategoryStepRenderer(true); } else if (seriesData.getType().equals("scatter")) { renderer = new LineAndShapeRenderer(false, true); // Set the shape of the markers based on the markerSize value ((LineAndShapeRenderer) renderer).setShape(getMarker(seriesData.getMarkerStyle(), markerSize)); } if (!tipStyle.equals("none")) { if (dateFormat != null) renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("({0}, {1}) = {2}", dateFormat)); else renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("({0}, {1}) = {2}", numberFormat)); } if (drillDownUrl != null) { if (dateFormat != null) renderer.setBaseItemURLGenerator( new com.newatlanta.bluedragon.CategoryURLGenerator(drillDownUrl, dateFormat)); else renderer.setBaseItemURLGenerator( new com.newatlanta.bluedragon.CategoryURLGenerator(drillDownUrl, numberFormat)); } if (seriesData.getSeriesColor() != null) renderer.setSeriesPaint(0, convertStringToColor(seriesData.getSeriesColor())); String dataLabelStyle = seriesData.getDataLabelStyle(); if (labelFormat.equals("date")) { if (dataLabelStyle.equals("none")) { renderer.setItemLabelsVisible(false); } else { setCategoryItemLabelsData(renderer, seriesData); if (dataLabelStyle.equals("value")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{2}", dateFormat, yAxisSymbols)); else if (dataLabelStyle.equals("rowlabel")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{0}", dateFormat, yAxisSymbols)); else if (dataLabelStyle.equals("columnlabel")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{1}", dateFormat, yAxisSymbols)); else if (dataLabelStyle.equals("pattern")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{1} {2}", dateFormat, yAxisSymbols)); else renderer.setItemLabelGenerator( new CategoryItemLabelGenerator(dataLabelStyle, dateFormat, yAxisSymbols)); } } else { if (dataLabelStyle.equals("none")) { renderer.setItemLabelsVisible(false); } else { setCategoryItemLabelsData(renderer, seriesData); if (dataLabelStyle.equals("value")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{2}", numberFormat, yAxisSymbols)); else if (dataLabelStyle.equals("rowlabel")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{0}", numberFormat, yAxisSymbols)); else if (dataLabelStyle.equals("columnlabel")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{1}", numberFormat, yAxisSymbols)); else if (dataLabelStyle.equals("pattern")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{1} {2} ({3} of {4})", numberFormat, yAxisSymbols)); else renderer.setItemLabelGenerator( new CategoryItemLabelGenerator(dataLabelStyle, numberFormat, yAxisSymbols)); } } // Add the renderer to the plot. // NOTE: this must be done before the setPaintStyle() call so the // DrawingSupplier object // will be set up properly for the generation of default colors. plot.setRenderer(num, renderer); // Set the paint style for this series (series 0) if (seriesData.getType().equals("bar") || seriesData.getType().equals("horizontalbar") || seriesData.getType().equals("area")) setPaintStyle(seriesData.getPaintStyle(), renderer, 0, height); num++; } // If gridLines was specified then we need to calculate the yAxisUnits if ((gridLines != -1) && (valueAxis instanceof NumberAxis)) { // Calculate the yAxisUnits we need to use to create the number of // gridLines yAxisUnits = calculateYAxisUnits(gridLines, minMax); // Set the yAxisUnits ((NumberAxis) valueAxis).setTickUnit(new NumberTickUnit(yAxisUnits)); } return plot; }
From source file:com.afunms.system.manage.UserManager.java
public void getHome() { Subject subject = SecurityUtils.getSubject(); User vo = (User) subject.getPrincipal(); List rpceventlist = new ArrayList(); // /*from w w w. j a v a2s . com*/ HostNodeDao nodedao = new HostNodeDao(); List networklist = new ArrayList(); List routelist = new ArrayList(); List switchlist = new ArrayList(); // List hostlist = new ArrayList(); // List dblist = new ArrayList(); // List seculist = new ArrayList(); // List storagelist = new ArrayList(); // int servicesize = 0; // int midsize = 0; int routesize = 0; int switchsize = 0; Hashtable lineHash = new Hashtable(); EventListDao eventdao = new EventListDao(); // try { servicesize = getServiceNum(vo); midsize = getMiddleService(vo); String bids = vo.getBusinessids(); if (vo.getRole() == 0 || vo.getRole() == 1) { bids = "-1"; } // try { rpceventlist = getEventList(bids); } catch (Exception e) { e.printStackTrace(); } finally { eventdao.close(); } try { networklist = nodedao.loadNetworkByBid(1, bids); // nodedao = new HostNodeDao(); seculist = nodedao.loadNetworkByBid(8, bids); // nodedao = new HostNodeDao(); routelist = nodedao.loadNetworkByBidAndCategory(1, bids); // nodedao = new HostNodeDao(); switchlist = nodedao.loadNetworkByBidAndCategory(2, bids); // nodedao = new HostNodeDao(); hostlist = nodedao.loadNetworkByBid(4, bids); } catch (Exception e) { e.printStackTrace(); } finally { nodedao.close(); } DBDao dbDao = new DBDao(); try { dblist = dbDao.getDbByMonFlag(1); } catch (Exception e) { e.printStackTrace(); } this.removeFlexSession(); // yangjun add ManageXmlDao manageXmlDao = new ManageXmlDao(); List xmlList = new ArrayList(); try { xmlList = manageXmlDao.loadByPerAll(bids); } catch (Exception e) { e.printStackTrace(); } finally { manageXmlDao.close(); } try { if (xmlList != null && xmlList.size() > 0) { this.createBussTree(xmlList);// yangjun // this.createxmlfile(xmlList); } } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } finally { if (eventdao != null) { eventdao.close(); } nodedao.close(); } List monitornodelist = getMonitorListByCategory("net_server"); List hostcpusortlist = new ArrayList(); List hostmemorysortlist = new ArrayList(); NumberFormat numberFormat = new DecimalFormat(); numberFormat.setMaximumFractionDigits(0); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String date = simpleDateFormat.format(new Date()); if (monitornodelist != null) { for (int i = 0; i < monitornodelist.size(); i++) { HostNode hostNode = (HostNode) monitornodelist.get(i); MonitorNodeDTO monitorNodeDTO = getMonitorNodeDTOByHostNode(hostNode); System.out.println("===================server========================="); System.out.println("nodeMonitor==" + monitorNodeDTO.getId()); System.out.println("nodeMonitor==nodeMonitor.getNodetype()=" + monitorNodeDTO.getIpAddress()); System.out.println("nodeMonitor==nodeMonitor.id=" + monitorNodeDTO.getCpuValueColor()); System.out.println("cpuValueColor=" + monitorNodeDTO.getMemoryValueColor()); System.out.println("===================server========================="); hostcpusortlist.add(monitorNodeDTO); hostmemorysortlist.add(monitorNodeDTO); } } String field = "cpu"; ; String sorttype = "asc"; monitorListSort(hostcpusortlist, "net", "cpu", "desc"); monitorListSort(hostmemorysortlist, "net", "memory", "desc"); request.setAttribute("hostcpusortlist", hostcpusortlist); request.setAttribute("hostmemorysortlist", hostmemorysortlist); List monitornetlist = getMonitorListByCategory("net"); List netcpusortlist = new ArrayList(); List netoutsortlist = new ArrayList(); List netinsortlist = new ArrayList(); numberFormat.setMaximumFractionDigits(0); if (monitornetlist != null) { for (int i = 0; i < monitornetlist.size(); i++) { HostNode hostNode = (HostNode) monitornetlist.get(i); MonitorNodeDTO monitorNodeDTO = getMonitorNodeDTOByHostNode(hostNode); System.out.println("===================net========================="); System.out.println("nodeMonitor==" + monitorNodeDTO.getId()); System.out.println("nodeMonitor==nodeMonitor.getNodetype()=" + monitorNodeDTO.getIpAddress()); System.out.println("nodeMonitor==nodeMonitor.id=" + monitorNodeDTO.getCpuValueColor()); System.out.println("cpuValueColor=" + monitorNodeDTO.getMemoryValueColor()); System.out.println("===================net========================="); netcpusortlist.add(monitorNodeDTO); netoutsortlist.add(monitorNodeDTO); netinsortlist.add(monitorNodeDTO); } } field = getParaValue("field"); sorttype = getParaValue("sorttype"); field = "cpu"; sorttype = "asc"; monitorListSort(netcpusortlist, "net", "cpu", "desc"); monitorListSort(netoutsortlist, "net", "oututilhdx", "desc"); monitorListSort(netinsortlist, "net", "inutilhdx", "desc"); if (routelist != null) routesize = routelist.size(); if (switchlist != null) switchsize = switchlist.size(); Hashtable deviceHash = new Hashtable(); deviceHash.put("routelist", routelist); deviceHash.put("hostlist", hostlist); deviceHash.put("switchlist", switchlist); deviceHash.put("dblist", dblist); deviceHash.put("seculist", seculist); // listsession.. // listsession.. Hashtable treeBidHash = getTreeBidHash(vo, deviceHash); // System.out.println(treeBidHash); request.setAttribute("treeBidHash", treeBidHash); session.setAttribute("rpceventlist", rpceventlist); session.setAttribute("networklist", networklist); session.setAttribute("hostlist", hostlist); session.setAttribute("midsize", midsize + ""); session.setAttribute("servicesize", servicesize + ""); session.setAttribute("securesize", seculist.size() + ""); session.setAttribute("dbsize", dblist.size() + ""); session.setAttribute("routesize", routesize + ""); session.setAttribute("switchsize", switchsize + ""); session.setAttribute("hostcpusortlist", hostcpusortlist); session.setAttribute("hostmemorysortlist", hostmemorysortlist); session.setAttribute("netcpusortlist", netcpusortlist); session.setAttribute("netoutsortlist", netoutsortlist); session.setAttribute("netinsortlist", netinsortlist); }
From source file:com.afunms.system.manage.UserManager.java
/** * hostNode MonitorNodeDTO/* w w w .j a va 2 s . c o m*/ * * @param hostNode * @return */ public MonitorNodeDTO getMonitorNodeDTOByHostNode(HostNode hostNode) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String date = simpleDateFormat.format(new Date()); String starttime = date + " 00:00:00"; String totime = date + " 23:59:59"; NumberFormat numberFormat = new DecimalFormat(); numberFormat.setMaximumFractionDigits(0); MonitorNodeDTO monitorNodeDTO = null; String ipAddress = hostNode.getIpAddress(); int nodeId = hostNode.getId(); String alias = hostNode.getAlias(); int category = hostNode.getCategory(); if (category == 1) { monitorNodeDTO = new MonitorNetDTO(); monitorNodeDTO.setCategory(""); } else if (category == 4) { monitorNodeDTO = new MonitorHostDTO(); monitorNodeDTO.setCategory(""); } else { monitorNodeDTO = new MonitorNetDTO(); monitorNodeDTO.setCategory(""); } // id monitorNodeDTO.setId(nodeId); // ip monitorNodeDTO.setIpAddress(ipAddress); // monitorNodeDTO.setAlias(alias); Host node = (Host) PollingEngine.getInstance().getNodeByID(nodeId); // if (node != null) { monitorNodeDTO.setStatus(node.getStatus() + ""); } else { monitorNodeDTO.setStatus("0"); } // monitorNodeDTO.setStatus(node.getAlarmlevel() + ""); String cpuValue = "0"; // cpu 0 String memoryValue = "0"; // memory 0 String inutilhdxValue = "0"; // inutilhdx 0 String oututilhdxValue = "0"; // oututilhdx 0 String pingValue = "0"; // ping 0 String eventListCount = ""; // eventListCount 0 String collectType = ""; // String cpuValueColor = "green"; // cpu String memoryValueColor = "green"; // memory String generalAlarm = "0"; // 0 String urgentAlarm = "0"; // 0 String seriousAlarm = "0"; // 0 double cpuValueDouble = 0; double memeryValueDouble = 0; Hashtable eventListSummary = new Hashtable(); Hashtable sharedata = ShareData.getSharedata(); Hashtable ipAllData = (Hashtable) sharedata.get(ipAddress); Hashtable allpingdata = ShareData.getPingdata(); if (ipAllData != null) { Vector cpuV = (Vector) ipAllData.get("cpu"); if (cpuV != null && cpuV.size() > 0) { CPUcollectdata cpu = (CPUcollectdata) cpuV.get(0); if (cpu != null && cpu.getThevalue() != null) { cpuValueDouble = Double.valueOf(cpu.getThevalue()); cpuValue = numberFormat.format(cpuValueDouble); } } Vector memoryVector = (Vector) ipAllData.get("memory"); int allmemoryvalue = 0; if (memoryVector != null && memoryVector.size() > 0) { for (int si = 0; si < memoryVector.size(); si++) { Memorycollectdata memorydata = (Memorycollectdata) memoryVector.elementAt(si); if (memorydata.getEntity().equalsIgnoreCase("Utilization")) { // // if // (memorydata.getSubentity().equalsIgnoreCase("PhysicalMemory")) // { // memeryValueDouble = memeryValueDouble + // Double.valueOf(memorydata.getThevalue()); // } if (category == 4 && memorydata.getSubentity().equalsIgnoreCase("PhysicalMemory")) {// memeryValueDouble = Double.valueOf(memorydata.getThevalue()); } if (category == 1 || category == 2 || category == 3) {// allmemoryvalue = allmemoryvalue + Integer.parseInt(memorydata.getThevalue()); if (si == memoryVector.size() - 1) { memeryValueDouble = allmemoryvalue / memoryVector.size(); } } } } memoryValue = numberFormat.format(memeryValueDouble); } Vector allutil = (Vector) ipAllData.get("allutilhdx"); if (allutil != null && allutil.size() == 3) { AllUtilHdx inutilhdx = (AllUtilHdx) allutil.get(0); inutilhdxValue = inutilhdx.getThevalue(); AllUtilHdx oututilhdx = (AllUtilHdx) allutil.get(1); oututilhdxValue = oututilhdx.getThevalue(); } } if (allpingdata != null) { Vector pingData = (Vector) allpingdata.get(ipAddress); if (pingData != null && pingData.size() > 0) { Pingcollectdata pingcollectdata = (Pingcollectdata) pingData.get(0); pingValue = pingcollectdata.getThevalue(); } } String count = ""; EventListDao eventListDao = new EventListDao(); try { if ("mysql".equalsIgnoreCase(SystemConstant.DBType)) { generalAlarm = eventListDao.getCountByWhere(" where nodeid='" + hostNode.getId() + "'" + " and level1='1' and recordtime>='" + starttime + "' and recordtime<='" + totime + "'"); urgentAlarm = eventListDao.getCountByWhere(" where nodeid='" + hostNode.getId() + "'" + " and level1='2' and recordtime>='" + starttime + "' and recordtime<='" + totime + "'"); seriousAlarm = eventListDao.getCountByWhere(" where nodeid='" + hostNode.getId() + "'" + " and level1='3' and recordtime>='" + starttime + "' and recordtime<='" + totime + "'"); } else if ("oracle".equalsIgnoreCase(SystemConstant.DBType)) { generalAlarm = eventListDao.getCountByWhere( " where nodeid=" + hostNode.getId() + "" + " and level1=1 and recordtime>=to_date('" + starttime + "','YYYY-MM-DD HH24:MI:SS') and recordtime<=to_date('" + totime + "','YYYY-MM-DD HH24:MI:SS')"); urgentAlarm = eventListDao.getCountByWhere( " where nodeid=" + hostNode.getId() + "" + " and level1=2 and recordtime>=to_date('" + starttime + "','YYYY-MM-DD HH24:MI:SS') and recordtime<=to_date('" + totime + "','YYYY-MM-DD HH24:MI:SS')"); seriousAlarm = eventListDao.getCountByWhere( " where nodeid=" + hostNode.getId() + "" + " and level1=3 and recordtime>=to_date('" + starttime + "','YYYY-MM-DD HH24:MI:SS') and recordtime<=to_date('" + totime + "','YYYY-MM-DD HH24:MI:SS')"); } } catch (Exception e) { e.printStackTrace(); } finally { eventListDao.close(); } eventListCount = count; eventListSummary.put("generalAlarm", generalAlarm); eventListSummary.put("urgentAlarm", urgentAlarm); eventListSummary.put("seriousAlarm", seriousAlarm); monitorNodeDTO.setEventListSummary(eventListSummary); if (SystemConstant.COLLECTTYPE_SNMP == hostNode.getCollecttype()) { collectType = "SNMP"; } else if (SystemConstant.COLLECTTYPE_PING == hostNode.getCollecttype()) { collectType = "PING"; } else if (SystemConstant.COLLECTTYPE_REMOTEPING == hostNode.getCollecttype()) { collectType = "REMOTEPING"; } else if (SystemConstant.COLLECTTYPE_SHELL == hostNode.getCollecttype()) { collectType = "SHELL"; } else if (SystemConstant.COLLECTTYPE_SSH == hostNode.getCollecttype()) { collectType = "SSH"; } else if (SystemConstant.COLLECTTYPE_TELNET == hostNode.getCollecttype()) { collectType = "TELNET"; } else if (SystemConstant.COLLECTTYPE_WMI == hostNode.getCollecttype()) { collectType = "WMI"; } // NodeMonitorDao nodeMonitorDao = new NodeMonitorDao(); // // List nodeMonitorList = null; // try { // nodeMonitorList = nodeMonitorDao.loadByNodeID(nodeId); // } catch (RuntimeException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } finally { // nodeMonitorDao.close(); // } // NodeUtil nodeutil = new NodeUtil(); NodeDTO dto = nodeutil.conversionToNodeDTO(node); cpuValueColor = this.computeColor( AgentalarmControlutil.GetAlarmlevel(monitorNodeDTO.getId() + "", dto.getType(), "cpu", "")); memoryValueColor = this.computeColor(AgentalarmControlutil.GetAlarmlevel(monitorNodeDTO.getId() + "", dto.getType(), "physicalmemory", "")); // if (nodeMonitorList != null) { // for (int j = 0; j < nodeMonitorList.size(); j++) { // NodeMonitor nodeMonitor = (NodeMonitor) nodeMonitorList.get(j); // // // // if ("cpu".equals(nodeMonitor.getCategory())) { // //cpuValueColor = this.computeColor(AgentalarmControlutil.GetAlarmlevel(monitorNodeDTO.getId()+"", "host", "cpu", "")); // // // } // // if ("memory".equals(nodeMonitor.getCategory())) { // // // // // } // //cpuValueColor="red"; // //memoryValueColor="red"; // // } // } monitorNodeDTO.setCpuValue(cpuValue); monitorNodeDTO.setMemoryValue(memoryValue); monitorNodeDTO.setInutilhdxValue(inutilhdxValue); monitorNodeDTO.setOututilhdxValue(oututilhdxValue); monitorNodeDTO.setPingValue(pingValue); monitorNodeDTO.setEventListCount(eventListCount); monitorNodeDTO.setCollectType(collectType); monitorNodeDTO.setCpuValueColor(cpuValueColor); monitorNodeDTO.setMemoryValueColor(memoryValueColor); return monitorNodeDTO; }
From source file:it.prato.comune.sit.LayerTerritorio.java
/** * @param store/*ww w .j ava 2s.co m*/ * @param query * @param tempdirpath * @return File * @throws SITException */ public File csvExport(DataStore store, Query query, String tempdirpath) throws SITException { File csvFile = null; try { SimpleFeatureSource featureSource = store.getFeatureSource(this.getTypeName()); SimpleFeatureType ft = featureSource.getSchema(); String fileName = ft.getTypeName(); csvFile = new File(tempdirpath, fileName + ".csv"); // ////////////////////////////////////////////////// // Creazione del writer da usare per il CSV finale // ////////////////////////////////////////////////// BufferedWriter w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(csvFile, false))); SimpleFeatureCollection collection = featureSource.getFeatures(query); if (collection.getSchema() instanceof SimpleFeatureType) { // Scrittura dell'intestazione SimpleFeatureType featureType = (SimpleFeatureType) collection.getSchema(); w.write("FID,"); for (int i = 0; i < ft.getAttributeCount(); i++) { AttributeDescriptor ad = featureType.getDescriptor(i); w.write(prepCSVField(ad.getLocalName())); if (i < ft.getAttributeCount() - 1) { w.write(","); } } } else { // Features complesse w.write("gml:id,"); int i = 0; for (PropertyDescriptor att : collection.getSchema().getDescriptors()) { // Escludere attributi temporanei if (!att.getName().getLocalPart().startsWith("FEATURE_LINK")) { if (i > 0) { w.write(","); } String elName = att.getName().toString(); Object xsd = att.getUserData().get(XSDElementDeclaration.class); if (xsd != null && xsd instanceof XSDElementDeclarationImpl) { // //////////////////////////////////////////////////////////////////////// // Ottenere il nome del prefisso, se possibile, altrimenti il default // il nome completo dello spazio dei nomi con URI // //////////////////////////////////////////////////////////////////////// XSDElementDeclarationImpl xsdEl = (XSDElementDeclarationImpl) xsd; elName = xsdEl.getQName(); } w.write(prepCSVField(elName)); i++; } } } w.write("\r\n"); // // Preparare il formatter per i campi numerici // NumberFormat coordFormatter = NumberFormat.getInstance(Locale.US); coordFormatter.setMaximumFractionDigits(3); coordFormatter.setGroupingUsed(false); // // Scrivere le features per compilare il file CSV finale // FeatureIterator<?> i = collection.features(); try { while (i.hasNext()) { Feature f = i.next(); // Recupero del fid w.write(prepCSVField(f.getIdentifier().getID())); w.write(","); if (f instanceof SimpleFeature) { // Resupero degli attributi for (int j = 0; j < ((SimpleFeature) f).getAttributeCount(); j++) { Object att = ((SimpleFeature) f).getAttribute(j); if (att != null) { String value = formatToString(att, coordFormatter); w.write(prepCSVField(value)); } if (j < ((SimpleFeature) f).getAttributeCount() - 1) { w.write(","); } } } else { // Features complesse Iterator<PropertyDescriptor> descriptors = collection.getSchema().getDescriptors() .iterator(); // Resupero degli attributi int j = 0; while (descriptors.hasNext()) { PropertyDescriptor desc = descriptors.next(); if (desc.getName().getLocalPart().startsWith("FEATURE_LINK")) { // Saltare attributi temporanei continue; } if (j > 0) { w.write(","); } j++; // Propriet multivalore non sono supportate, solamente per SF0 per adesso Collection<Property> values = f.getProperties(desc.getName()); if (values.size() > 1) { throw new UnsupportedOperationException( "Propriet multivalore non sono supportate per il formato CSV!"); } Object att = null; if (!values.isEmpty()) { att = values.iterator().next().getValue(); } if (att != null) { String value = formatToString(att, coordFormatter); w.write(prepCSVField(value)); } } } w.write("\r\n"); } } finally { i.close(); } w.flush(); } catch (Exception e) { String errMsg = "Errore durante la ricerca del filtro"; logger.error(errMsg, e); throw new SITException(errMsg, e); } filtroTotale.ResetFiltro(); return csvFile; }