List of usage examples for java.util Hashtable containsKey
public synchronized boolean containsKey(Object key)
From source file:org.sakaiproject.site.tool.SiteAction.java
private void importToolIntoSiteMigrate(List toolIds, Hashtable importTools, Site site) { if (importTools != null) { //if add missing tools is enabled, add the tools ito the site before importing content if (isAddMissingToolsOnImportEnabled()) { //add the toolId lists into a set to remove dupes Set<String> toolsToProcess = new HashSet<String>(toolIds); toolsToProcess.addAll(importTools.keySet()); //now compare what we have to what we need to add final List<String> selectedTools = new ArrayList<String>(toolsToProcess); M_log.debug("selectedTools: " + selectedTools); List<String> missingToolIds = new ArrayList<String>(selectedTools); missingToolIds.removeAll(toolIds); M_log.debug("missingToolIds: " + missingToolIds); //and add for (String missingToolId : missingToolIds) { site = addToolToSiteIfMissing(site, missingToolId); commitSite(site);//from w w w. ja v a2s.c o m } } Map transversalMap = new HashMap(); // import resources first boolean resourcesImported = false; for (int i = 0; i < toolIds.size() && !resourcesImported; i++) { String toolId = (String) toolIds.get(i); if (toolId.equalsIgnoreCase("sakai.resources") && importTools.containsKey(toolId)) { List importSiteIds = (List) importTools.get(toolId); for (int k = 0; k < importSiteIds.size(); k++) { String fromSiteId = (String) importSiteIds.get(k); String toSiteId = site.getId(); String fromSiteCollectionId = m_contentHostingService.getSiteCollection(fromSiteId); String toSiteCollectionId = m_contentHostingService.getSiteCollection(toSiteId); Map<String, String> entityMap = transferCopyEntitiesMigrate(toolId, fromSiteCollectionId, toSiteCollectionId); if (entityMap != null) { transversalMap.putAll(entityMap); } resourcesImported = true; } } } // import other tools then for (int i = 0; i < toolIds.size(); i++) { String toolId = (String) toolIds.get(i); if (!toolId.equalsIgnoreCase("sakai.resources") && importTools.containsKey(toolId)) { List importSiteIds = (List) importTools.get(toolId); for (int k = 0; k < importSiteIds.size(); k++) { String fromSiteId = (String) importSiteIds.get(k); String toSiteId = site.getId(); if (SITE_INFO_TOOL_ID.equals(toolId)) { copySiteInformation(fromSiteId, site); } else { Map<String, String> entityMap = transferCopyEntitiesMigrate(toolId, fromSiteId, toSiteId); if (entityMap != null) { transversalMap.putAll(entityMap); } } } } } //update entity references for (int i = 0; i < toolIds.size(); i++) { String toolId = (String) toolIds.get(i); if (importTools.containsKey(toolId)) { List importSiteIds = (List) importTools.get(toolId); for (int k = 0; k < importSiteIds.size(); k++) { String toSiteId = site.getId(); updateEntityReferences(toolId, toSiteId, transversalMap, site); } } } } }
From source file:org.sakaiproject.site.tool.SiteAction.java
/** * Import tools and content into the site * /*from www .j av a 2s.com*/ * If the isAddMissingToolsOnImportEnabled setting is true, tools that are selected for import and don't already exist in the target site will be added automatically. * * @param toolIds list of tools already in the site * @param importTools list of tools that were selected for import * @param site the site to import content into */ private void importToolIntoSite(List toolIds, Hashtable importTools, Site site) { if (importTools != null) { //if add missing tools is enabled, add the tools ito the site before importing content if (isAddMissingToolsOnImportEnabled()) { //add the toolId lists into a set to remove dupes Set<String> toolsToProcess = new HashSet<String>(toolIds); toolsToProcess.addAll(importTools.keySet()); //now compare what we have to what we need to add final List<String> selectedTools = new ArrayList<String>(toolsToProcess); M_log.debug("selectedTools: " + selectedTools); List<String> missingToolIds = new ArrayList<String>(selectedTools); missingToolIds.removeAll(toolIds); M_log.debug("missingToolIds: " + missingToolIds); //and add for (String missingToolId : missingToolIds) { site = addToolToSiteIfMissing(site, missingToolId); commitSite(site); } //now update toolIds to match importTools so that the content is imported toolIds.clear(); toolIds.addAll(importTools.keySet()); } Map transversalMap = new HashMap(); // import resources first boolean resourcesImported = false; for (int i = 0; i < toolIds.size() && !resourcesImported; i++) { String toolId = (String) toolIds.get(i); if (toolId.equalsIgnoreCase("sakai.resources") && importTools.containsKey(toolId)) { List importSiteIds = (List) importTools.get(toolId); for (int k = 0; k < importSiteIds.size(); k++) { String fromSiteId = (String) importSiteIds.get(k); String toSiteId = site.getId(); String fromSiteCollectionId = m_contentHostingService.getSiteCollection(fromSiteId); String toSiteCollectionId = m_contentHostingService.getSiteCollection(toSiteId); Map<String, String> entityMap = transferCopyEntities(toolId, fromSiteCollectionId, toSiteCollectionId); if (entityMap != null) { transversalMap.putAll(entityMap); } resourcesImported = true; } } } // import other tools then for (int i = 0; i < toolIds.size(); i++) { String toolId = (String) toolIds.get(i); if (!toolId.equalsIgnoreCase("sakai.resources") && importTools.containsKey(toolId)) { List importSiteIds = (List) importTools.get(toolId); for (int k = 0; k < importSiteIds.size(); k++) { String fromSiteId = (String) importSiteIds.get(k); String toSiteId = site.getId(); if (SITE_INFO_TOOL_ID.equals(toolId)) { copySiteInformation(fromSiteId, site); } else { Map<String, String> entityMap = transferCopyEntities(toolId, fromSiteId, toSiteId); if (entityMap != null) { transversalMap.putAll(entityMap); } resourcesImported = true; } } } } //update entity references for (int i = 0; i < toolIds.size(); i++) { String toolId = (String) toolIds.get(i); if (importTools.containsKey(toolId)) { List importSiteIds = (List) importTools.get(toolId); for (int k = 0; k < importSiteIds.size(); k++) { String toSiteId = site.getId(); updateEntityReferences(toolId, toSiteId, transversalMap, site); } } } } }
From source file:sos.settings.SOSSettingsDialog.java
/** * Alle Eintrge einer Sektion anzeigen/*from w w w. j a v a 2s . com*/ * * @param entriesTitle * Titel * @param entries * Werte(siehe getDialogEntries) * @return boolean Fehlerzustand * @throws Exception * @see #showDialogEntries(String, Vector) */ private boolean showDialogEntries(String entriesTitle, Vector entries) throws Exception { this.debug(3, "showDialogEntries : entriesTitle = " + entriesTitle + " entries = " + entries); // Fleck fr showDialogValues() this.isShowEntries = true; if (entriesTitle != null) { this.dialogEntriesTitle = entriesTitle; } if (entries != null) { this.dialogEntries = entries; } String imgLink = "<img src=\"" + this.imgDir + this.imgAction + "\" border=\"0\" hspace=\"4\" vspace=\"1\">"; String thisCon = (this.site.indexOf('?') != -1) ? "&" : "?"; String querySession = "?"; if (!this.sessionUseTransSID && !this.sessionVAR.equals("")) { querySession = thisCon + this.sessionVAR + "=" + this.sessionID + "&"; } else { querySession = thisCon; } this.showTableBegin(); int columnCount = this.enableEntryNames ? 3 : 2; try { this.showNavigation(new Integer(columnCount), this.dialogApplicationIndex, this.dialogSectionIndex, null); } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } this.aclRange = "section"; try { this.getRights(this.settings.application, this.settings.section, null); } catch (Exception e) { this.setError("ACL : " + e.getMessage(), SOSClassUtil.getMethodName()); } if (this.applicationType == 1) { if (this.hasCreateRight) { this.hasWriteRight = true; this.disabled = ""; } } // JS Code schreiben this.openHelpWin(); if (this.enableEntryValues == true) { this.out.println("<form name=\"" + this.form + "\" action=\"" + this.site + "\" method=\"post\" onSubmit=\"return " + this.form + "_check_onSubmit()\">"); } if (this.dialogSectionIndex.intValue() >= 0 && this.enableEntryManager == true) { boolean showNew = false; if (this.applicationType == 1) { if (this.settings.section.equals(this.settings.entrySchemaSection)) { if (this.hasCreateRight == true) { showNew = true; } } } else { if (this.hasCreateRight == true) { showNew = true; } } if (showNew == true) { this.out.println(" <tr class=\"" + this.styleTr + "\">"); String link = "<a class=\"" + this.styleLinkNavigation + "\" href=\"" + this.site + querySession + "action=new&range=entry&application=" + this.response.encodeURL(this.settings.application) + "§ion=" + this.response.encodeURL(this.settings.section) + "&application_type=" + this.applicationType; if (this.sectionType > 0) { link += "§ion_type=" + this.sectionType; } link += "\">"; this.out.println(" <td class=\"" + this.styleTd + "\">" + link + imgLink + this.dialogEntriesNewTitle + "</a> </td>"); if (this.enableEntryNames == true) { this.out.println(" <td class=\"" + this.styleTd + "\"> </td>"); } this.out.println(" <td class=\"" + this.styleTd + "\"> </td>"); this.out.println(" </tr>"); } } String linkEntry = "<a href=\"" + this.site + querySession + "action=show"; String linkSchema = (this.enableEntryManager == true) ? "<a href=\"" + this.site + querySession + "action=schema" : linkEntry; int cnt = 0; String lastApplication = ""; String lastSection = ""; boolean hasTitle = false; if (this.action.equals("query") || this.action.equals("duplicate")) { hasTitle = true; } HashMap application = new HashMap(); HashMap section = new HashMap(); application.put("entry_type", new Integer(this.applicationType)); section.put("entry_type", new Integer(this.sectionType)); String aclApplication = ""; StringBuffer sql = new StringBuffer(); StringBuffer sqlHelp = new StringBuffer(); StringBuffer sqlBinary = new StringBuffer(); if (this.sectionType > 0 || this.applicationType > 0) { // aus der // Schema sql.append(" select s.\"" + this.settings.entryApplication + "\",s.\"" + this.settings.entrySection + "\", s.\"" + this.settings.entryName + "\" "); sql.append(" from " + this.settings.source + " s "); sql.append(" where s.\"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and "); sql.append(" s.\"" + this.settings.entrySection + "\" = '" + this.settings.entrySchemaSection + "' and "); sql.append(" s.\"" + this.settings.entrySection + "\" <> s.\"" + this.settings.entryName + "\" and "); sqlBinary.append(" select s.\"" + this.settings.entryApplication + "\",s.\"" + this.settings.entrySection + "\", s.\"" + this.settings.entryName + "\" "); sqlBinary.append(" from " + this.settings.source + " s "); sqlBinary.append(" where s.\"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and "); sqlBinary.append(" s.\"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.settings.section) + " and "); sqlBinary.append(" s.\"" + this.settings.entrySection + "\" <> s.\"" + this.settings.entryName + "\" and "); } else { sql.append(" select s.\"" + this.settings.entryApplication + "\",s.\"" + this.settings.entrySection + "\", s.\"" + this.settings.entryName + "\" "); sql.append(" from " + this.settings.source + " s "); sql.append(" where s.\"" + this.settings.entryApplication + "\" = " + this.dbQuoted(this.settings.application) + " and "); sql.append(" s.\"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.settings.section) + " and "); sql.append(" s.\"" + this.settings.entrySection + "\" <> s.\"" + this.settings.entryName + "\" and "); sqlBinary = new StringBuffer(sql.toString()); } sqlBinary.append(" s.\"LONG_VALUE\" is not null"); sqlHelp = sql.append(" s.\"DOCUMENTATION\" is not null"); Hashtable helpTexts = new Hashtable(); try { Vector helpText = this.connection.getArrayAsVector(sqlHelp.toString()); if (helpText.size() > 0) { for (Enumeration el = helpText.elements(); el.hasMoreElements();) { HashMap hm = (HashMap) el.nextElement(); helpTexts.put(hm.get("application").toString() + hm.get("section").toString() + hm.get("name").toString(), "Help"); } this.hasHelps = true; } } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } this.hasBinaryValue = new Hashtable(); try { Vector binaryValues = this.connection.getArrayAsVector(sqlBinary.toString()); if (binaryValues.size() > 0) { for (Enumeration el = binaryValues.elements(); el.hasMoreElements();) { HashMap hm = (HashMap) el.nextElement(); this.hasBinaryValue.put(hm.get("application").toString() + hm.get("section").toString() + hm.get("name").toString(), "1"); } } } catch (Exception e) { this.setError(e.getMessage(), SOSClassUtil.getMethodName()); } Vector checkEntries = new Vector(); int ce = 0; int index = 0; boolean isNotAllDisabled = false; String[] display_type_entries = this.rb.getMessage("sos.settings.dialog.listbox_display_type_entries") .split(";"); if (display_type_entries.length != 5) { this.setError("\"sos.settings.dialog.listbox_display_type_entries\" expected 5 values, given : " + display_type_entries.length, SOSClassUtil.getMethodName()); return false; } String[] input_type_entries = this.rb.getMessage("sos.settings.dialog.listbox_input_type_entries") .split(";"); if (input_type_entries.length != 7) { this.setError("\"sos.settings.dialog.listbox_input_type_entries\" expected 7 values, given : " + input_type_entries.length, SOSClassUtil.getMethodName()); return false; } for (Enumeration el = this.dialogEntries.elements(); el.hasMoreElements();) { HashMap entry = (HashMap) el.nextElement(); this.aclRange = "entry"; try { this.getRights(entry.get("application").toString(), entry.get("section").toString(), entry.get("name").toString()); if (this.hasReadRight == false && this.hasCreateRight == false) { continue; } } catch (Exception e) { this.out.println(" <tr class=\"" + this.styleTr + "\">"); this.out.println(" <td valign=\"middle\" class=\"" + this.styleTd + "\" colspan=\"3\">"); this.out.println(" <table width=\"100%\" border =\"0\" cellspacing=\"0\" cellpadding=\"0\">"); this.out.println(" <tr>"); this.out.println(" <td>"); this.out.println( " " + entry.get(this.settings.entryTitle.toLowerCase()).toString() + " "); this.out.println(" </td>"); this.out.println(" <td align=\"right\" nowrap>"); this.showError("ACL : " + e.getMessage()); this.out.println(" </td>"); this.out.println(" </tr>"); this.out.println(" </table>"); this.out.println(" </td>"); this.out.println(" </tr>"); continue; } // Acls end cnt++; String link = ""; if ((hasTitle == true) && (!entry.get(this.settings.entryApplication.toLowerCase()).toString() .equals(lastApplication))) { try { application = this.connection.getSingle("select \"NAME\",\"TITLE\",\"ENTRY_TYPE\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(entry.get(this.settings.entryApplication.toLowerCase()).toString()) + " and \"" + this.settings.entryApplication + "\"= \"" + this.settings.entrySection + "\" and \"" + this.settings.entrySection + "\"= \"" + this.settings.entryName + "\""); if (application.size() == 0) { continue; } } catch (Exception e) { continue; } try { section = this.connection.getSingle("select \"NAME\",\"TITLE\",\"ENTRY_TYPE\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(entry.get(this.settings.entryApplication.toLowerCase()).toString()) + " and \"" + this.settings.entrySection + "\"= " + this.dbQuoted(entry.get(this.settings.entrySection.toLowerCase()).toString()) + " and \"" + this.settings.entrySection + "\"= \"" + this.settings.entryName + "\""); if (section.size() == 0) { continue; } } catch (Exception e) { continue; } lastApplication = entry.get(this.settings.entryApplication.toLowerCase()).toString(); lastSection = entry.get(this.settings.entrySection.toLowerCase()).toString(); this.out.println(" <tr class=\"" + this.styleTr + "\">"); link = linkEntry + "&range=sections&application=" + this.response.encodeURL(lastApplication) + "\" class=\"" + this.styleLinkNavigation + "\">"; this.out.println(" <th class=\"" + this.styleTh + "\" align=\"left\">" + link + imgLink + application.get("title").toString() + "</a></th>"); link = linkEntry + "&range=entries&application=" + this.response.encodeURL(lastApplication) + "§ion=" + this.response.encodeURL(lastSection) + "&application_type=" + application.get("entry_type").toString() + "§ion_type=" + section.get("entry_type").toString() + "\" class=\"" + this.styleLinkNavigation + "\">"; this.out.println(" <th class=\"" + this.styleTh + "\" align=\"left\" colspan=\"" + (columnCount - 1) + "\">" + link + imgLink + section.get("title").toString() + "</th>"); this.out.println(" </tr>"); } if ((hasTitle == true) && (!entry.get(this.settings.entrySection.toLowerCase()).toString().equals(lastSection))) { section = this.connection.getSingle("select \"NAME\",\"TITLE\",\"ENTRY_TYPE\" from " + this.settings.source + " where \"" + this.settings.entryApplication + "\" = " + this.dbQuoted(entry.get(this.settings.entryApplication.toLowerCase()).toString()) + " and \"" + this.settings.entrySection + "\"= " + this.dbQuoted(entry.get(this.settings.entrySection.toLowerCase()).toString()) + " and \"" + this.settings.entrySection + "\"= \"" + this.settings.entryName + "\""); lastSection = entry.get(this.settings.entrySection.toLowerCase()).toString(); this.out.println(" <tr class=\"" + this.styleTr + "\">"); this.out.println(" <th class=\"" + this.styleTh + "\" align=\"left\"> </th>"); link = linkEntry + "&range=entries&application=" + this.response.encodeURL(lastApplication) + "§ion=" + this.response.encodeURL(lastSection) + "&application_type=" + application.get("entry_type").toString() + "§ion_type=" + section.get("entry_type").toString() + "\" class=\"" + this.styleLinkNavigation + "\">"; this.out.println(" <th class=\"" + this.styleTh + "\" align=\"left\" colspan=\"" + (columnCount - 1) + "\">" + link + imgLink + section.get("title").toString() + "</th>"); this.out.println(" </tr>"); } String linkHelp = ""; ///////////// this.out.println(" <tr class=\"" + this.styleTr + "\">"); if (entry.get(this.settings.entrySection.toLowerCase()).toString() .equals(this.settings.entrySchemaSection)) { linkHelp = " "; String k = entry.get(this.settings.entryApplication.toLowerCase()).toString() + this.settings.entrySchemaSection + entry.get(this.settings.entryName.toLowerCase()).toString(); if (helpTexts.containsKey(k)) { String session = "''"; if (!this.sessionID.equals("")) { session = "'" + this.sessionID + "'"; } String helpHref = "source=" + this.settings.source + "&application=" + this.response .encodeURL(entry.get(this.settings.entryApplication.toLowerCase()).toString()) + "§ion=" + this.response.encodeURL(this.settings.entrySchemaSection) + "&entry=" + this.response.encodeURL(entry.get(this.settings.entryName.toLowerCase()).toString()); linkHelp = "<a href=\"javascript:openHelpWin('" + helpHref + "'," + session + ");\"><img src=\"" + this.imgDir + this.imgHelp + "\" border=\"0\" title=\"" + this.rb.getMessage("sos.settings.dialog.label_help") + "\"></a>"; } String linkQuery = "&range=entry&application=" + this.response.encodeURL( entry.get(this.settings.entryApplication.toLowerCase()).toString()) + "§ion=" + this.response.encodeURL(entry.get(this.settings.entrySection.toLowerCase()).toString()) + "&entry=" + this.response.encodeURL(entry.get(this.settings.entryName.toLowerCase()).toString()) + "&application_type=" + application.get("entry_type").toString() + "\">"; this.out.println(" <td valign=\"middle\" class=\"" + this.styleTd + "\">"); this.out.println(" <table width=\"100%\" border =\"0\" cellspacing=\"0\" cellpadding=\"0\">"); this.out.println(" <tr>"); this.out.println(" <td>"); this.out.println(" " + linkSchema + linkQuery + imgLink + "</a>"); link = (entry.get(this.settings.entrySection.toLowerCase()).toString() .equals(this.settings.entrySchemaSection)) ? linkSchema : linkEntry; this.out.println(" " + link + linkQuery + entry.get(this.settings.entryTitle.toLowerCase()).toString() + "</a> "); this.out.println(" </td>"); this.out.println(" <td align=\"right\" nowrap>"); this.out.println(" " + linkHelp); this.out.println(" </td>"); this.out.println(" </tr>"); this.out.println(" </table>"); this.out.println(" </td>"); } else if (this.sectionType > 0 || this.applicationType > 0) { // schema linkHelp = " "; if (this.hasCreateRight) { // bei Schema reicht CREATE Recht this.hasWriteRight = true; this.disabled = ""; } String k = entry.get(this.settings.entryApplication.toLowerCase()).toString() + this.settings.entrySchemaSection + entry.get(this.settings.entryName.toLowerCase()).toString(); if (helpTexts.containsKey(k)) { String session = "''"; if (!this.sessionID.equals("")) { session = "'" + this.sessionID + "'"; } String helpHref = "source=" + this.settings.source + "&application=" + this.response .encodeURL(entry.get(this.settings.entryApplication.toLowerCase()).toString()) + "§ion=" + this.response.encodeURL(this.settings.entrySchemaSection) + "&entry=" + this.response.encodeURL(entry.get(this.settings.entryName.toLowerCase()).toString()); linkHelp = "<a href=\"javascript:openHelpWin('" + helpHref + "'," + session + ");\"><img src=\"" + this.imgDir + this.imgHelp + "\" border=\"0\" title=\"" + this.rb.getMessage("sos.settings.dialog.label_help") + "\"></a>"; } String linkQuery = "&range=entry&application=" + this.response.encodeURL( entry.get(this.settings.entryApplication.toLowerCase()).toString()) + "§ion=" + this.response.encodeURL(entry.get(this.settings.entrySection.toLowerCase()).toString()) + "&entry=" + this.response.encodeURL(entry.get(this.settings.entryName.toLowerCase()).toString()) + "&application_type=" + application.get("entry_type").toString() + "§ion_type=" + section.get("entry_type").toString() + "\">"; this.out.println(" <td valign=\"middle\" class=\"" + this.styleTd + "\">"); this.out.println(" <table width=\"100%\" border =\"0\" cellspacing=\"0\" cellpadding=\"0\">"); this.out.println(" <tr>"); this.out.println(" <td nowrap>"); if (this.enableEntryValues == true) { this.out.println(" " + linkEntry + linkQuery + imgLink + "</a>" + linkEntry + linkQuery + entry.get(this.settings.entryTitle.toLowerCase()).toString() + "</a> "); } else { this.out.println( " " + entry.get(this.settings.entryTitle.toLowerCase()).toString() + " "); } this.out.println(" </td>"); this.out.println(" <td align=\"right\" nowrap>"); this.out.println(" " + linkHelp); this.out.println(" </td>"); this.out.println(" </tr>"); this.out.println(" </table>"); this.out.println(" </td>"); } else { linkHelp = " "; String k = entry.get(this.settings.entryApplication.toLowerCase()).toString() + entry.get(this.settings.entrySection.toLowerCase()).toString() + entry.get(this.settings.entryName.toLowerCase()).toString(); if (helpTexts.containsKey(k)) { String session = "''"; if (!this.sessionID.equals("")) { session = "'" + this.sessionID + "'"; } String helpHref = "source=" + this.settings.source + "&application=" + this.response .encodeURL(entry.get(this.settings.entryApplication.toLowerCase()).toString()) + "§ion=" + this.response.encodeURL( entry.get(this.settings.entrySection.toLowerCase()).toString()) + "&entry=" + this.response.encodeURL(entry.get(this.settings.entryName.toLowerCase()).toString()); linkHelp = "<a href=\"javascript:openHelpWin('" + helpHref + "'," + session + ");\"><img src=\"" + this.imgDir + this.imgHelp + "\" border=\"0\" title=\"" + this.rb.getMessage("sos.settings.dialog.label_help") + "\"></a>"; } String linkQuery = "&range=entry&application=" + this.response.encodeURL( entry.get(this.settings.entryApplication.toLowerCase()).toString()) + "§ion=" + this.response.encodeURL(entry.get(this.settings.entrySection.toLowerCase()).toString()) + "&entry=" + this.response.encodeURL(entry.get(this.settings.entryName.toLowerCase()).toString()) + "&application_type=" + application.get("entry_type").toString() + "\">"; this.out.println(" <td valign=\"middle\" class=\"" + this.styleTd + "\" nowrap>"); this.out.println(" <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"); this.out.println(" <tr>"); this.out.println(" <td>"); if (this.enableEntryValues == true) { this.out.println(" " + linkSchema + linkQuery + imgLink + "</a>"); link = (entry.get(this.settings.entrySection.toLowerCase()).toString() .equals(this.settings.entrySchemaSection)) ? linkSchema : linkEntry; this.out.println(" " + link + linkQuery + entry.get(this.settings.entryTitle.toLowerCase()) + "</a> "); } else { this.out.println(" " + entry.get(this.settings.entryTitle.toLowerCase()) + " "); } this.out.println(" </td>"); this.out.println(" <td align=\"right\" nowrap>"); this.out.println(" " + linkHelp); this.out.println(" </td>"); this.out.println(" </tr>"); this.out.println(" </table>"); this.out.println(" </td>"); } if (this.enableEntryNames == true) { this.out.println(" <td valign=\"top\" class=\"" + this.styleTd + "\">" + entry.get(this.settings.entryName.toLowerCase()) + " </td>"); } if ((this.enableEntryValues == true) && (!entry.get(this.settings.entrySection.toLowerCase()).toString() .equals(this.settings.entrySchemaSection))) { if (this.disabled.equals("")) { isNotAllDisabled = true; } this.out.println(" <td valign=\"top\" class=\"" + this.styleTd + "\">"); /* * if (entry.get("input_type").toString().equals("5")) { * this.out.println("[ " + this.rb * .getMessage("sos.settings.dialog.dialog_long_value_title") + " * ]"); } else { this.showDialogValue(entry, 1, index); if * (!entry.get("forced").toString().equals("0") && * !entry.get("forced").toString().equals("") && * entry.get("display_type").toString().equals("0")) { * checkEntries.add(ce, "value_" + index); ce++; } } * this.out.println(" </td> "); */ this.out.println("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); this.out.println(" <tr>"); String hbv = ""; if (this.hasBinaryValue.containsKey(entry.get("application").toString() + entry.get("section").toString() + entry.get("name").toString())) { hbv = this.hasBinaryValue.get(entry.get("application").toString() + entry.get("section").toString() + entry.get("name").toString()).toString(); } if ((hbv != null && hbv.length() > 0 && !hbv.equals("0")) || (entry.get("input_type").toString().equals("5") || entry.get("input_type").toString().equals("6"))) { if (entry.get("input_type").toString().equals("5")) { // Dokument this.out.println(" <td>"); this.out.println("[ " + this.rb.getMessage("sos.settings.dialog.dialog_long_value_title") + " ] "); if (entry.get("display_type").toString().equals("4")) { // versteckt this.out.println(display_type_entries[4] + "</td>"); this.out.println(" <td align=\"right\">"); this.showDialogValue(entry, 1, index); this.out.println(" </td>"); } else { this.out.println(" </td>"); this.out.println(" <td align=\"right\"> </td>"); } } else { // Dokument binr oder wir machen zum Dokument // binr this.out.println(" <td>"); this.out.println("[ " + input_type_entries[6] + " ]"); this.out.println(" </td>"); entry.put("input_type", "6"); entry.put("display_type", "4"); this.out.println(" <td align=\"right\">"); this.showDialogValue(entry, 1, index); this.out.println(" </td>"); } } else { this.out.println(" <td colspan=\"2\">"); this.showDialogValue(entry, 1, index); this.out.println(" </td>"); if (!entry.get("forced").toString().equals("0") && !entry.get("forced").toString().equals("") && entry.get("display_type").toString().equals("0")) { checkEntries.add(ce, "value_" + index); ce++; } } this.out.println("</tr>"); this.out.println("</table>"); this.out.println("</td>"); } else { this.out.println(" <td valign=\"middle\" class=\"" + this.styleTd + "\">" + entry.get(this.settings.entryValue.toLowerCase()).toString() + " </td>"); } this.out.println(" </tr>"); index++; } // foreach this.out.println("<script language=\"JavaScript\" type=\"text/javascript\">"); this.out.println(" function " + this.form + "_check_onSubmit() {"); this.out.println(" "); this.out.print(" var entries = Array("); for (int i = 0; i < checkEntries.size(); i++) { if (i > 0) { this.out.print(","); } this.out.print("\"" + checkEntries.get(i) + "\""); } this.out.println(" );"); this.out.println(" for(var i=0; i<entries.length; i++) {"); this.out.println(" if ( document." + this.form + ".elements[entries[i]].value == null || document." + this.form + ".elements[entries[i]].value == \"\" ) {"); this.out.println( " alert( \"" + this.rb.getMessage("sos.settings.dialog.alert_entry_empty") + "\");"); this.out.println(" document." + this.form + ".elements[entries[i]].focus();"); this.out.println(" return false;"); this.out.println(" }"); this.out.println(" }"); this.out.println(" return true;"); this.out.println(" }"); this.out.println("</script>"); if (this.enableEntryValues == true) { this.out.println(" <tr class=\"" + this.styleTr + "\">"); this.out.println(" <td valign=\"middle\" colspan=\"" + columnCount + "\" class=\"" + this.styleTd + "\"> "); if (isNotAllDisabled) { this.out.println(" <input type=\"image\" name=\"btn_store\" src=\"" + this.imgDir + this.sosLang + "/btn_store.gif\" alt=\"" + this.rb.getMessage("sos.settings.dialog.btn_store_alt") + "\" onClick=\"document.sos_settings.button.value=\'store\';\"> "); this.out.println(" <input type=\"image\" name=\"btn_cancel\" src=\"" + this.imgDir + this.sosLang + "/btn_cancel.gif\" alt=\"" + this.rb.getMessage("sos.settings.dialog.btn_cancel_alt") + "\" onClick=\"document.sos_settings.button.value=\'cancel\';\"> "); this.out.println(" <input type=\"image\" name=\"btn_reset\" src=\"" + this.imgDir + this.sosLang + "/btn_reset.gif\" alt=\"" + this.rb.getMessage("sos.settings.dialog.btn_reset_alt") + "\" onClick=\"document.sos_settings.reset(); return false;\"> "); } else { this.out.println(" <input type=\"image\" name=\"btn_cancel\" src=\"" + this.imgDir + this.sosLang + "/btn_cancel.gif\" alt=\"" + this.rb.getMessage("sos.settings.dialog.btn_cancel_alt") + "\" onClick=\"document.sos_settings.button.value=\'cancel\';\"> "); } this.out.println("<input type=\"hidden\" name=\"button\">"); this.out.println( "<input type=\"hidden\" name=\"application\" value=\"" + this.settings.application + "\">"); this.out.println( "<input type=\"hidden\" name=\"section\" value=\"" + this.settings.section + "\">"); this.out.println("<input type=\"hidden\" name=\"entry\" value=\"\">"); this.out.println("<input type=\"hidden\" name=\"range\" value=\"list\">"); this.out.println("<input type=\"hidden\" name=\"section_type\" value=\"" + this.sectionType + "\">"); this.out.println( "<input type=\"hidden\" name=\"application_type\" value=\"" + this.applicationType + "\">"); this.out.println("<input type=\"hidden\" name=\"num_of_entries\" value=\"" + cnt + "\">"); this.out.println(" </td>"); this.out.println(" </tr>"); this.out.println(" </form>"); } this.showActions(new Integer(columnCount), this.dialogApplicationIndex, this.dialogSectionIndex, null); this.showTableEnd(); return true; }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI oracleexcel//from www .ja va2s. c om * @param filename * @throws DocumentException * @throws IOException */ public void createReportOracleCldExcel(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" }; String[] sysItemch1 = { "", "", "", "Java" }; String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated" }; String[] sysItemch2 = { "PGA", "PGA", "PGA" }; String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String buffercache = "0";// String dictionarycache = "0";// String librarycache = "0";// String pctmemorysorts = "0";// String pctbufgets = "0";// 10 String opencurstr = "0";// Hashtable memPerfValue = (Hashtable) reportHash.get("memPerfValue"); Hashtable memValue = (Hashtable) reportHash.get("memValue"); Hashtable cursors = (Hashtable) reportHash.get("cursors"); if (cursors == null) { cursors = new Hashtable(); } if (memPerfValue == null) memPerfValue = new Hashtable(); if (memPerfValue != null) { if (memPerfValue.containsKey("buffercache") && memPerfValue.get("buffercache") != null) { buffercache = (String) memPerfValue.get("buffercache") + "%"; } if (memPerfValue.containsKey("dictionarycache") && memPerfValue.get("dictionarycache") != null) { dictionarycache = (String) memPerfValue.get("dictionarycache") + "%"; } if (memPerfValue.containsKey("librarycache") && memPerfValue.get("librarycache") != null) { librarycache = (String) memPerfValue.get("librarycache") + "%"; } if (memPerfValue.containsKey("pctmemorysorts") && memPerfValue.get("pctmemorysorts") != null) { pctmemorysorts = (String) memPerfValue.get("pctmemorysorts") + "%"; } if (memPerfValue.containsKey("pctbufgets") && memPerfValue.get("pctbufgets") != null) { pctbufgets = (String) memPerfValue.get("pctbufgets") + "%"; } if (cursors.containsKey("opencur") && cursors.get("opencur") != null) { opencurstr = (String) cursors.get("opencur"); } } Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(0, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp(), labelFormat1); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime, labelFormat1); sheet.addCell(tmpLabel); sheet.mergeCells(0, 0, 10, 0); sheet.mergeCells(0, 1, 10, 1); sheet.mergeCells(0, 2, 10, 2); // ip tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "IP", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 4, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 4, 1, 4); sheet.mergeCells(2, 4, 3, 4); sheet.mergeCells(4, 4, 5, 4); sheet.mergeCells(6, 4, 7, 4); sheet.mergeCells(8, 4, 10, 4); tmpLabel = new Label(0, 5, vo.getDbName(), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, ip, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, typename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 5, runstr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 5, grade, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 5, 1, 5); sheet.mergeCells(2, 5, 3, 5); sheet.mergeCells(4, 5, 5, 5); sheet.mergeCells(6, 5, 7, 5); sheet.mergeCells(8, 5, 10, 5); // tmpLabel = new Label(0, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 7, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 7, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 7, 2, 7); sheet.mergeCells(3, 7, 5, 7); sheet.mergeCells(6, 7, 10, 7); tmpLabel = new Label(0, 8, pingnow + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 8, pingmin + "%", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 8, pingconavg + "%", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 8, 2, 8); sheet.mergeCells(3, 8, 5, 8); sheet.mergeCells(6, 8, 10, 8); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(0, 9, 11, 8, file)); // allRow = allRow+7; int row = 17; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "10", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; tmpLabel = new Label(0, row, buffercache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, dictionarycache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, librarycache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, pctmemorysorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, pctbufgets, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, opencurstr, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); // row = row + 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, sysItemch2[0], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, sysItemch2[1], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, sysItemch2[2], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sysItemch1[0], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, sysItemch1[1], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, sysItemch1[2], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, sysItemch1[3], b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; tmpLabel = new Label(0, row, memValue.get(sysItem2[0]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, memValue.get(sysItem2[1]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, memValue.get(sysItem2[2]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, memValue.get(sysItem1[0]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, memValue.get(sysItem1[1]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, memValue.get(sysItem1[2]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, memValue.get(sysItem1[3]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); // row = row + 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START1 tmpLabel = new Label(6, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "", b_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END1 // HONGLI MODIFY START1 tmpLabel = new Label(10, row, "", b_labelFormat); // HONGLI MODIFY END1 sheet.addCell(tmpLabel); // row = row++; Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 for (int i = 0; i < tableinfo_v.size(); i++) { p_labelFormat = super.colorChange(i); Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 tmpLabel = new Label(0, row, String.valueOf(i + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, _filename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tablespace, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, free, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, percent, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START4 tmpLabel = new Label(6, row, pyr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, pbr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, pyw, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, pbw, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END4 tmpLabel = new Label(10, row, status, p_labelFormat); sheet.addCell(tmpLabel); row++; } // row = row + 2; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 4, row); sheet.mergeCells(5, row, 10, row); row++; tmpLabel = new Label(0, row, (String) reportHash.get("downnum"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, reportHash.get("count") + "", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 4, row); sheet.mergeCells(5, row, 10, row); // addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("Error in ExcelReport.createReport()", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_oraall2(String filename) { if (impReport.getTable() == null) { fileName = null;/*from w w w . j av a2s.c o m*/ return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreport_has = new Hashtable(); allreport_has = reportHash; if (allreport_has != null && allreport_has.size() > 0) { Iterator keys = allreport_has.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreport_has.get(ip); reportHash = report_has; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" }; String[] sysItemch1 = { "", "", "", "Java" }; String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated" }; String[] sysItemch2 = { "PGA", "PGA", "PGA" }; String hostname = (String) reportHash.get("dbname"); // String ip = (String) reportHash.get("ip"); // String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String buffercache = "0";// String dictionarycache = "0";// String librarycache = "0";// String pctmemorysorts = "0";// String pctbufgets = "0";// 10 String opencurstr = "0";// Hashtable memPerfValue = (Hashtable) reportHash.get("memPerfValue"); Hashtable memValue = (Hashtable) reportHash.get("memValue"); Hashtable cursors = (Hashtable) reportHash.get("cursors"); if (cursors == null) { cursors = new Hashtable(); } if (memPerfValue == null) memPerfValue = new Hashtable(); if (memPerfValue != null) { if (memPerfValue.containsKey("buffercache") && memPerfValue.get("buffercache") != null) { buffercache = (String) memPerfValue.get("buffercache") + "%"; } if (memPerfValue.containsKey("dictionarycache") && memPerfValue.get("dictionarycache") != null) { dictionarycache = (String) memPerfValue.get("dictionarycache") + "%"; } if (memPerfValue.containsKey("librarycache") && memPerfValue.get("librarycache") != null) { librarycache = (String) memPerfValue.get("librarycache") + "%"; } if (memPerfValue.containsKey("pctmemorysorts") && memPerfValue.get("pctmemorysorts") != null) { pctmemorysorts = (String) memPerfValue.get("pctmemorysorts") + "%"; } if (memPerfValue.containsKey("pctbufgets") && memPerfValue.get("pctbufgets") != null) { pctbufgets = (String) memPerfValue.get("pctbufgets") + "%"; } if (cursors.containsKey("opencur") && cursors.get("opencur") != null) { opencurstr = (String) cursors.get("opencur"); } } Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new // WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new // WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new // WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; // ip this.dbTitlePing(sheet, ip, reportHash); int row = 18; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "10", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; tmpLabel = new Label(0, row, buffercache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, dictionarycache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, librarycache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, pctmemorysorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, pctbufgets, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, opencurstr, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); // row += 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, sysItemch2[0], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, sysItemch2[1], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, sysItemch2[2], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sysItemch1[0], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, sysItemch1[1], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, sysItemch1[2], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, sysItemch1[3], b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; tmpLabel = new Label(0, row, memValue.get(sysItem2[0]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, memValue.get(sysItem2[1]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, memValue.get(sysItem2[2]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, memValue.get(sysItem1[0]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, memValue.get(sysItem1[1]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, memValue.get(sysItem1[2]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, memValue.get(sysItem1[3]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); // row += 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START1 tmpLabel = new Label(6, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "", b_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END1 // HONGLI MODIFY START1 tmpLabel = new Label(10, row, "", b_labelFormat); // HONGLI MODIFY END1 sheet.addCell(tmpLabel); // row = row++; Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 for (int i = 0; i < tableinfo_v.size(); i++) { p_labelFormat = super.colorChange(i); Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 tmpLabel = new Label(0, row, String.valueOf(i + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, _filename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tablespace, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, free, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, percent, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START4 tmpLabel = new Label(6, row, pyr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, pbr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, pyw, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, pbw, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END4 tmpLabel = new Label(10, row, status, p_labelFormat); sheet.addCell(tmpLabel); row++; } // row++; this.addEventReport(sheet, report_has, row); row += 2; // addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { SysLogger.error("", ioe); } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } sheetNum++; } wb.write(); } } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI oraclepdf//from w w w .ja va 2 s . c om * @param filename * @throws DocumentException * @throws IOException */ public void createReportOracleCldPdf(String filename, String type) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { RtfWriter2.getInstance(document, new FileOutputStream(filename)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // Table dbTable = new Table(5); this.setTableFormat(dbTable); Cell dbCell = null; dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(vo.getDbName(), contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(ip, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(typename, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(runstr, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(grade, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); Table aTable = new Table(3); this.setTableFormat(aTable); // float[] widths = { 220f, 220f, 220f }; // aTable.setWidths(widths); // aTable.setWidthPercentage(100); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(pingnow + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(pingmin + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(pingconavg + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // img.setAbsolutePosition(0, 0); img.scalePercent(76); img.setAlignment(Image.MIDDLE);// document.add(dbTable); document.add(new Paragraph("\n")); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // Table dbInfoTable = new Table(6); this.setTableFormat(dbInfoTable); // float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; // dbInfoTable.setWidths(dbInfoWidths); // dbInfoTable.setWidthPercentage(100); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); cell.setColspan(6); dbInfoTable.addCell(cell); String buffercache = "0";// String dictionarycache = "0";// String librarycache = "0";// String pctmemorysorts = "0";// String pctbufgets = "0";// 10 String opencurstr = "0";// Hashtable memPerfValue = (Hashtable) reportHash.get("memPerfValue"); Hashtable memValue = (Hashtable) reportHash.get("memValue"); Hashtable cursors = (Hashtable) reportHash.get("cursors"); if (cursors == null) { cursors = new Hashtable(); } if (memPerfValue == null) memPerfValue = new Hashtable(); if (memPerfValue != null) { if (memPerfValue.containsKey("buffercache") && memPerfValue.get("buffercache") != null) { buffercache = (String) memPerfValue.get("buffercache") + "%"; } if (memPerfValue.containsKey("dictionarycache") && memPerfValue.get("dictionarycache") != null) { dictionarycache = (String) memPerfValue.get("dictionarycache") + "%"; } if (memPerfValue.containsKey("librarycache") && memPerfValue.get("librarycache") != null) { librarycache = (String) memPerfValue.get("librarycache") + "%"; } if (memPerfValue.containsKey("pctmemorysorts") && memPerfValue.get("pctmemorysorts") != null) { pctmemorysorts = (String) memPerfValue.get("pctmemorysorts") + "%"; } if (memPerfValue.containsKey("pctbufgets") && memPerfValue.get("pctbufgets") != null) { pctbufgets = (String) memPerfValue.get("pctbufgets") + "%"; } if (cursors.containsKey("opencur") && cursors.get("opencur") != null) { opencurstr = (String) cursors.get("opencur"); } } cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("10", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(buffercache, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(dictionarycache, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(librarycache, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(pctmemorysorts, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(pctbufgets, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(opencurstr, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); document.add(dbInfoTable); document.add(new Paragraph("\n")); // String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" }; String[] sysItemch1 = { "", "", "", "Java" }; String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated" }; String[] sysItemch2 = { "PGA", "PGA", "PGA" }; Table ncTable = new Table(7); this.setTableFormat(ncTable); // float[] ncWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 // ncTable.setWidths(ncWidths); // ncTable.setWidthPercentage(100); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(7); this.setCellFormat(cell, true); ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[0], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[1], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[2], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[0], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[1], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[2], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[3], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[0]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[1]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[2]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[0]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[1]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[2]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[3]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); document.add(ncTable); document.add(new Paragraph("\n")); // HONGLI MODIFY START1 Table aTable1 = new Table(11); float[] arg0 = { 10f, 20f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f }; aTable1.setWidths(arg0); this.setTableFormat(aTable1); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(11); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // HONGLI ADD START1 cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // HONGLI ADD END1 cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // aTable1.endHeaders(); // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 int row = 0; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 row = i + 1; String rowStr = "" + row; cell = new Cell(new Phrase(rowStr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(_filename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(tablespace, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(size, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(free, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(percent, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START4 cell = new Cell(new Phrase(pyr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pyw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END4 cell = new Cell(new Phrase(status, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } document.add(aTable1); // document.add(new Paragraph("\n")); Table eventTable = new Table(2); this.setTableFormat(eventTable); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase((String) reportHash.get("downnum"), contextFont)); this.setCellFormat(cell, false); eventTable.addCell(cell); cell = new Cell(new Phrase(reportHash.get("count") + "", contextFont)); this.setCellFormat(cell, false); eventTable.addCell(cell); document.add(eventTable); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(new Paragraph("\n")); // addEventLisToPdf(document); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * modify HONG 2010-10-27/*from w ww. j ava 2 s. c om*/ */ public void createReport_ora(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, (String) maxping.get("pingnow"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 14, "", _labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START1 tmpLabel = new Label(7, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 14, "", _labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END1 // HONGLI MODIFY START1 tmpLabel = new Label(11, 14, "", _labelFormat); // HONGLI MODIFY END1 sheet.addCell(tmpLabel); int row = 14; // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 row = row + (i); tmpLabel = new Label(1, 15 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15 + i, _filename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15 + i, tablespace, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 15 + i, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 15 + i, free, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 15 + i, percent, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START4 tmpLabel = new Label(7, 15 + i, pyr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 15 + i, pbr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 15 + i, pyw, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 15 + i, pbw, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END4 tmpLabel = new Label(11, 15 + i, status, p_labelFormat); sheet.addCell(tmpLabel); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI oracleword//from w ww. j a v a 2 s. c o m * @param filename * @throws DocumentException * @throws IOException */ public void createReportOracleCldDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // Table dbTable = new Table(5); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidth(100); // 90% dbTable.setAlignment(Element.ALIGN_CENTER);// dbTable.setAutoFillEmptyCells(true); // dbTable.setBorderWidth(1); // dbTable.setBorderColor(new Color(0, 125, 255)); // dbTable.setPadding(2);// dbTable.setSpacing(0);// dbTable.setBorder(2);// dbTable.endHeaders(); Cell dbCell = null; dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("IP", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(vo.getDbName(), contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(ip, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(typename, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(runstr, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(grade, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingnow + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingmin + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingconavg + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(dbTable); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // Table dbInfoTable = new Table(6); float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; dbInfoTable.setWidths(dbInfoWidths); dbInfoTable.setWidth(100); // 90% dbInfoTable.setAlignment(Element.ALIGN_CENTER);// dbInfoTable.setAutoFillEmptyCells(true); // dbInfoTable.setBorderWidth(1); // dbInfoTable.setBorderColor(new Color(0, 125, 255)); // dbInfoTable.setPadding(2);// dbInfoTable.setSpacing(0);// dbInfoTable.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); String buffercache = "0";// String dictionarycache = "0";// String librarycache = "0";// String pctmemorysorts = "0";// String pctbufgets = "0";// 10 String opencurstr = "0";// Hashtable memPerfValue = (Hashtable) reportHash.get("memPerfValue"); Hashtable memValue = (Hashtable) reportHash.get("memValue"); Hashtable cursors = (Hashtable) reportHash.get("cursors"); if (cursors == null) { cursors = new Hashtable(); } if (memPerfValue == null) memPerfValue = new Hashtable(); if (memPerfValue != null) { if (memPerfValue.containsKey("buffercache") && memPerfValue.get("buffercache") != null) { buffercache = (String) memPerfValue.get("buffercache") + "%"; } if (memPerfValue.containsKey("dictionarycache") && memPerfValue.get("dictionarycache") != null) { dictionarycache = (String) memPerfValue.get("dictionarycache") + "%"; } if (memPerfValue.containsKey("librarycache") && memPerfValue.get("librarycache") != null) { librarycache = (String) memPerfValue.get("librarycache") + "%"; } if (memPerfValue.containsKey("pctmemorysorts") && memPerfValue.get("pctmemorysorts") != null) { pctmemorysorts = (String) memPerfValue.get("pctmemorysorts") + "%"; } if (memPerfValue.containsKey("pctbufgets") && memPerfValue.get("pctbufgets") != null) { pctbufgets = (String) memPerfValue.get("pctbufgets") + "%"; } if (cursors.containsKey("opencur") && cursors.get("opencur") != null) { opencurstr = (String) cursors.get("opencur"); } } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase("10", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(buffercache, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(dictionarycache, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(librarycache, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(pctmemorysorts, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(pctbufgets, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(opencurstr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); document.add(dbInfoTable); // String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" }; String[] sysItemch1 = { "", "", "", "Java" }; String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated" }; String[] sysItemch2 = { "PGA", "PGA", "PGA" }; Table ncTable = new Table(7); float[] ncWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 ncTable.setWidths(ncWidths); ncTable.setWidth(100); // 90% ncTable.setAlignment(Element.ALIGN_CENTER);// ncTable.setAutoFillEmptyCells(true); // ncTable.setBorderWidth(1); // ncTable.setBorderColor(new Color(0, 125, 255)); // ncTable.setPadding(2);// ncTable.setSpacing(0);// ncTable.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[0], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[1], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[2], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[0], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[1], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[2], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[3], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[0]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[1]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[2]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[0]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[1]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[2]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[3]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); document.add(ncTable); // HONGLI MODIFY START1 Table aTable1 = new Table(11); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setColspan(11); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START1 cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END1 cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 int row = 0; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 row = i + 1; String rowStr = "" + row; cell = new Cell(new Phrase(rowStr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(_filename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(tablespace, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(size, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(free, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(percent, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START4 cell = new Cell(new Phrase(pyr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pyw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END4 cell = new Cell(new Phrase(status, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } document.add(aTable1); // Table evenInfoTable = new Table(2); float[] evenInfoWidths = { 220f, 220f }; evenInfoTable.setWidths(evenInfoWidths); evenInfoTable.setWidth(100); // 90% evenInfoTable.setAlignment(Element.ALIGN_CENTER);// evenInfoTable.setAutoFillEmptyCells(true); // evenInfoTable.setBorderWidth(1); // evenInfoTable.setBorderColor(new Color(0, 125, 255)); // evenInfoTable.setPadding(2);// evenInfoTable.setSpacing(0);// evenInfoTable.setBorder(2);// String downnum = (String) reportHash.get("downnum"); String count = String.valueOf(reportHash.get("count")); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase(downnum, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase(count, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); document.add(evenInfoTable); addEventListToDoc(document, titleFont, contextFont); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * MODIFY HONGLI 2010-10-27/*from ww w . j a v a2 s . c om*/ */ public void createReport_oraPDF(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font contextFont1 = new Font(bfChinese, 11, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont1); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingnow"))); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); this.setCellFormat(cell, false); aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.MIDDLE);// img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // HONGLI MODIFY START1 PdfPTable aTable1 = new PdfPTable(12); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 aTable1.setWidths(width); aTable1.setWidthPercentage(100); aTable1.setHeaderRows(1); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // HONGLI ADD START1 cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // HONGLI ADD END1 cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // aTable1.endHeaders(); // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 int row = 0; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 aTable1.addCell(new Phrase("")); row = i + 1; String rowStr = "" + row; cell = new PdfPCell(new Phrase(rowStr)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(_filename)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(tablespace)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(size)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(free)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(percent)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START4 cell = new PdfPCell(new Phrase(pyr)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(pbr)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(pyw)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(pbw)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END4 cell = new PdfPCell(new Phrase(status)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_oraDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;//from ww w . j av a 2s . c o m return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // HONGLI MODIFY START1 Table aTable1 = new Table(12); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START1 cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END1 cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 int row = 0; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 aTable1.addCell(""); row = i + 1; String rowStr = "" + row; cell = new Cell(new Phrase(rowStr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(_filename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(tablespace, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(size, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(free, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(percent, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START4 cell = new Cell(new Phrase(pyr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pyw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END4 cell = new Cell(new Phrase(status, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } }