List of usage examples for java.util Vector iterator
public synchronized Iterator<E> iterator()
From source file:com.globalsight.everest.webapp.pagehandler.administration.users.UserMainHandler.java
private void filtrateSuperAdmin(HttpSession p_session, UserSearchParams params, Vector users) throws RemoteException, NamingException { String userId = (String) p_session.getAttribute(WebAppConstants.USER_NAME); boolean isSuperAdmin = false; boolean isSuperPM = false; try {//w w w .j a v a 2 s .c om isSuperAdmin = UserUtil.isSuperAdmin(userId); if (!isSuperAdmin) { isSuperPM = UserUtil.isSuperPM(userId); } } catch (Exception e) { throw new EnvoyServletException(e); } if (!isSuperAdmin) { String companyName = null; if (isSuperPM) { companyName = CompanyWrapper.getCompanyNameById(CompanyThreadLocal.getInstance().getValue()); } else { companyName = params.getCompanyOfSearcher(); } for (Iterator iter = users.iterator(); iter.hasNext();) { User user = (User) iter.next(); if (!companyName.equals(user.getCompanyName())) { iter.remove(); } } } }
From source file:org.apache.jetspeed.modules.actions.portlets.PsmlManagerAction.java
/** * File Import All Action for Psml./* ww w .ja v a 2 s. c o m*/ * * @param rundata The turbine rundata context for this request. * @param context The velocity context for this request. * @exception Exception */ public void doImportall(RunData rundata, Context context) throws Exception { String copyFrom = null; try { copyFrom = rundata.getParameters().getString("CopyFrom"); // // Collect all .psml files from the root specified // Vector files = new Vector(); this.collectPsml(files, copyFrom); // // Process each file // for (Iterator it = files.iterator(); it.hasNext();) { // If error occurs processing one entry, continue on with the others String path = null; try { String psml = ((File) it.next()).getPath(); path = psml.substring(copyFrom.length() + 1); ProfileLocator locator = this.mapFileToLocator(path); PSMLDocument doc = this.loadDocument(psml); // // create a new profile // if (doc != null) { Portlets portlets = doc.getPortlets(); // // Profiler does not provide update capability - must remove before replacing // if (PsmlManager.getDocument(locator) != null) { Profiler.removeProfile(locator); } Portlets clonedPortlets = (Portlets) SerializationUtils.clone(portlets); org.apache.jetspeed.util.PortletUtils.regenerateIds(clonedPortlets); Profiler.createProfile(locator, clonedPortlets); } else { throw new Exception("Failed to load PSML document [" + psml + "] from disk"); } rundata.addMessage("Profile for [" + locator.getPath() + "] has been imported from file [" + psml + "]<br>"); setRefreshPsmlFlag(rundata, TRUE); } catch (Exception ouch) { logger.error("Exception", ouch); rundata.addMessage("ERROR importing file [" + path + "]: " + ouch.toString() + "<br>"); } } } catch (Exception e) { // log the error msg logger.error("Exception", e); // // dup key found - display error message - bring back to same screen // JetspeedLink link = JetspeedLinkFactory.getInstance(rundata); DynamicURI duri = link.addPathInfo(SecurityConstants.PARAM_MODE, "import_all") .addPathInfo(SecurityConstants.PARAM_MSGID, SecurityConstants.MID_UPDATE_FAILED); JetspeedLinkFactory.putInstance(link); rundata.setRedirectURI(duri.toString()); } // save values that user just entered so they don't have to re-enter if (copyFrom != null) { rundata.getUser().setTemp(COPY_FROM, copyFrom); } }
From source file:br.org.indt.ndg.client.Service.java
/** * @param username//from w w w . j a v a2 s .c om * @param surveyId * @param resultId * @return * @throws NDGServerException */ public ArrayList<SPreview> getPreview(String username, String surveyId, String resultId) throws NDGServerException { SSurvey survey = this.getSSurvey(username, surveyId, resultId); String finalString = ""; ArrayList<SPreview> list = new ArrayList<SPreview>(); Set categoryKeys = ((SResult) survey.getResults().get(0)).getCategories().keySet(); Iterator iCategory = categoryKeys.iterator(); while (iCategory.hasNext()) { SCategory sc = (SCategory) ((SResult) survey.getResults().get(0)).getCategories().get(iCategory.next()); finalString = "<span id='txt-list-top'><b>" + sc.getId() + " - " + sc.getName().toUpperCase() + "</b></span><br>"; list.add(new SPreview(finalString, false)); String[] sortedKeys = new String[sc.getSubCategories().keySet().size()]; sc.getSubCategories().keySet().toArray(sortedKeys); java.util.Arrays.sort(sortedKeys, String.CASE_INSENSITIVE_ORDER); for (int i = 0; i < sortedKeys.length; i++) { String subCatId = sortedKeys[i]; log.info("SubCategory" + subCatId); Vector<SField> fields = sc.getSubCategories().get(subCatId); if (sc.getSubCategories().keySet().size() > 1) { finalString = "<span id='txt-list-down'><b>" + sc.getId() + "." + subCatId + "</b></span><br>"; list.add(new SPreview(finalString, false)); } Iterator<SField> iFields = fields.iterator();//sc.getFields().iterator(); while (iFields.hasNext()) { SField sf = (SField) iFields.next(); if (sc.getSubCategories().keySet().size() > 1) { finalString = "<span id='txt-list-down'><b>" + sc.getId() + "." + subCatId + "." + sf.getId() + " " + sf.getDescription() + "</b></span><br>"; } else { finalString = "<span id='txt-list-down'><b>" + sc.getId() + "." + sf.getId() + " " + sf.getDescription() + "</b></span><br>"; } list.add(new SPreview(finalString, false)); if (survey.getResultsSize() > 0) { SResult r = (SResult) survey.getResults().get(0); SCategory rc = (SCategory) r.getCategories().get(sc.getId()); SField rf = rc.getField(subCatId, sf.getId()); String value = "----"; if (rf.getValue() != null && !rf.getValue().trim().equals("")) { value = rf.getValue(); } if (sf.getElementName() != null) { if (!sf.getElementName().equals("img_data")) { value = value.trim().replaceAll("\n", ""); finalString = "<span id = 'txt-list-answer'><i>" + value + "</i></span><br>"; list.add(new SPreview(finalString, false)); } else { for (TaggedImage taggedImage : rf.getImages()) { // TODO add GeoTagging preview String imageString = taggedImage.getImageData(); finalString = imageString.trim(); list.add(new SPreview(finalString, true)); } } } } } finalString = "<br>"; list.add(new SPreview(finalString, false)); } finalString = "<br>"; list.add(new SPreview(finalString, false)); } return list; }
From source file:musite.ui.MusiteResultPanel.java
private void exportComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportComboBoxActionPerformed String name = panelName.replaceAll("[\\\\/:\\*\\?\"<>\\|]+", "-"); String defaultFile = MusiteInit.defaultPath + File.separator + name; if (sliderTitleComboBox.getSelectedItem().equals(SPECIFICITY)) { defaultFile += String.format("-Sp_%.2f", specificity); } else {/*from www. ja va 2 s . c o m*/ defaultFile += String.format("-Score_%.3f", threshold); } defaultFile += ".result"; switch (exportComboBox.getSelectedIndex()) { case 1: // tab-delimited text file { JFileChooser fc = new JFileChooser(MusiteInit.defaultPath); fc.setSelectedFile(new File(defaultFile)); ArrayList<String> exts = new ArrayList<String>(1); String fasta = "txt"; exts.add(fasta); FileExtensionsFilter fastaFilter = new FileExtensionsFilter(exts, "Tab-delimited file (.txt)"); fc.addChoosableFileFilter(fastaFilter); //fc.setAcceptAllFileFilterUsed(true); fc.setDialogTitle("Save the the result to..."); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); MusiteInit.defaultPath = file.getParent(); String filePath = MusiteInit.defaultPath + File.separator + file.getName(); String ext = FilePathParser.getExt(filePath); if (ext == null || !ext.equalsIgnoreCase("txt")) { filePath += ".txt"; } if (IOUtil.fileExist(filePath)) { int ret = JOptionPane.showConfirmDialog(this, "Are you sure to replace the existing file?", "Relace the existing file?", JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.NO_OPTION) break; } Vector<Vector> data = formatData(proteinList, false, true); int n = data.size(); ArrayList<String> dataOut = new ArrayList(n + 1); dataOut.add(StringUtils.join(header.iterator(), '\t')); for (Vector vec : data) { dataOut.add(StringUtils.join(vec.iterator(), '\t')); } try { IOUtil.writeCollectionAscii(dataOut, filePath); } catch (IOException e) { e.printStackTrace(); JOptionPane.showMessageDialog(this, "Error: failed to write the file."); break; } JOptionPane.showMessageDialog(this, "Successfully exported."); } break; } // case 2: // fasta // { // JFileChooser fc = new JFileChooser(MusiteInit.defaultPath); // fc.setSelectedFile(new File(defaultFile)); // // ArrayList<String> exts = new ArrayList<String>(1); // String fasta = "fasta"; // exts.add(fasta); // FileExtensionsFilter fastaFilter = new FileExtensionsFilter(exts,"Fasta file (.fasta)"); // fc.addChoosableFileFilter(fastaFilter); // // //fc.setAcceptAllFileFilterUsed(true); // fc.setDialogTitle("Save the the result to..."); // int returnVal = fc.showSaveDialog(this); // if (returnVal == JFileChooser.APPROVE_OPTION) { // File file = fc.getSelectedFile(); // MusiteInit.defaultPath = file.getParent(); // // String filePath = MusiteInit.defaultPath + File.separator + file.getName(); // // String ext = FilePathParser.getExt(filePath); // if (ext==null||!ext.equalsIgnoreCase("fasta")) { // filePath += ".fasta"; // } // // if (IOUtil.fileExist(filePath)) { // int ret = JOptionPane.showConfirmDialog(this, "Are you sure to replace the existing file?", "Relace the existing file?", JOptionPane.YES_NO_OPTION); // if (ret==JOptionPane.NO_OPTION) // break; // } // // ProteinsWriter writer = new ModifiedProteinsFastaWriter(); // WriteTask writeTask = new WriteTask(resultDisplay, writer, filePath); // TaskUtil.execute(writeTask); // if (!writeTask.success()) { // JOptionPane.showMessageDialog(this, "Failed to export."); // break; // } // // JOptionPane.showMessageDialog(this, "Successfully exported."); // } // // break; // } // case 3: // xml // { // JFileChooser fc = new JFileChooser(MusiteInit.defaultPath); // fc.setSelectedFile(new File(defaultFile)); // // ArrayList<String> exts = new ArrayList<String>(1); // String xml = "xml"; // exts.add(xml); // FileExtensionsFilter xmlFilter = new FileExtensionsFilter(exts,"XML file (.xml)"); // fc.addChoosableFileFilter(xmlFilter); // // //fc.setAcceptAllFileFilterUsed(true); // fc.setDialogTitle("Save the the result to..."); // int returnVal = fc.showSaveDialog(this); // if (returnVal == JFileChooser.APPROVE_OPTION) { // File file = fc.getSelectedFile(); // MusiteInit.defaultPath = file.getParent(); // // String filePath = MusiteInit.defaultPath + File.separator + file.getName(); // // String ext = FilePathParser.getExt(filePath); // if (ext==null||!ext.equalsIgnoreCase("xml")) { // filePath += ".xml"; // } // // if (IOUtil.fileExist(filePath)) { // int ret = JOptionPane.showConfirmDialog(this, "Are you sure to replace the existing file?", "Relace the existing file?", JOptionPane.YES_NO_OPTION); // if (ret==JOptionPane.NO_OPTION) // break; // } // // ProteinsXMLWriter writer = ProteinsXMLWriter.createWriter(); // WriteTask xmlWriteTask = new WriteTask(resultDisplay, writer, filePath); // TaskUtil.execute(xmlWriteTask); // if (!xmlWriteTask.success()) { // JOptionPane.showMessageDialog(this, "Failed to export."); // break; // } // // JOptionPane.showMessageDialog(this, "Successfully exported."); // } // // break; // } } exportComboBox.setSelectedIndex(0); }
From source file:org.unitime.timetable.model.Solution.java
public void export(CSVFile file, String instructorFormat) { file.setSeparator(","); file.setQuotationMark("\""); if (isCommited().booleanValue()) { file.setHeader(new CSVField[] { new CSVField("COURSE"), new CSVField("ITYPE"), new CSVField("SECTION"), new CSVField("SUFFIX"), new CSVField("EXTERNAL_ID"), new CSVField("DATE_PATTERN"), new CSVField("DAY"), new CSVField("START_TIME"), new CSVField("END_TIME"), new CSVField("ROOM"), new CSVField("INSTRUCTOR"), new CSVField("SCHEDULE_NOTE") }); } else {/*from www . jav a2 s .co m*/ file.setHeader(new CSVField[] { new CSVField("COURSE"), new CSVField("ITYPE"), new CSVField("SECTION"), new CSVField("SUFFIX"), new CSVField("DATE_PATTERN"), new CSVField("DAY"), new CSVField("START_TIME"), new CSVField("END_TIME"), new CSVField("ROOM"), new CSVField("INSTRUCTOR"), new CSVField("SCHEDULE_NOTE") }); } Vector assignments = new Vector(getAssignments()); assignments.addAll(getOwner().getNotAssignedClasses(this)); Collections.sort(assignments, new ClassOrAssignmentComparator()); for (Iterator i = assignments.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof Assignment) { Assignment assignment = (Assignment) o; Class_ clazz = assignment.getClazz(); List<DepartmentalInstructor> leads = clazz.getLeadInstructors(); StringBuffer leadsSb = new StringBuffer(); for (Iterator<DepartmentalInstructor> e = leads.iterator(); e.hasNext();) { DepartmentalInstructor instructor = (DepartmentalInstructor) e.next(); leadsSb.append(instructor.getName(instructorFormat)); if (e.hasNext()) leadsSb.append(";"); } Placement placement = assignment.getPlacement(); if (isCommited().booleanValue()) { file.addLine(new CSVField[] { new CSVField(clazz.getCourseName()), new CSVField(clazz.getItypeDesc()), new CSVField(clazz.getSectionNumber()), new CSVField(clazz.getSchedulingSubpart().getSchedulingSubpartSuffix()), new CSVField(clazz.getDivSecNumber()), new CSVField(clazz.effectiveDatePattern().getName()), new CSVField(placement.getTimeLocation().getDayHeader()), new CSVField(placement.getTimeLocation().getStartTimeHeader(CONSTANTS.useAmPm())), new CSVField(placement.getTimeLocation().getEndTimeHeader(CONSTANTS.useAmPm())), new CSVField(placement.getRoomName(",")), new CSVField(leadsSb), new CSVField( clazz.getSchedulePrintNote() == null ? "" : clazz.getSchedulePrintNote()) }); } else { file.addLine(new CSVField[] { new CSVField(clazz.getCourseName()), new CSVField(clazz.getItypeDesc()), new CSVField(clazz.getSectionNumber()), new CSVField(clazz.getSchedulingSubpart().getSchedulingSubpartSuffix()), new CSVField(clazz.effectiveDatePattern().getName()), new CSVField(placement.getTimeLocation().getDayHeader()), new CSVField(placement.getTimeLocation().getStartTimeHeader(CONSTANTS.useAmPm())), new CSVField(placement.getTimeLocation().getEndTimeHeader(CONSTANTS.useAmPm())), new CSVField(placement.getRoomName(",")), new CSVField(leadsSb), new CSVField( clazz.getSchedulePrintNote() == null ? "" : clazz.getSchedulePrintNote()) }); } } else { Class_ clazz = (Class_) o; List<DepartmentalInstructor> leads = clazz.getLeadInstructors(); StringBuffer leadsSb = new StringBuffer(); for (Iterator<DepartmentalInstructor> e = leads.iterator(); e.hasNext();) { DepartmentalInstructor instructor = (DepartmentalInstructor) e.next(); leadsSb.append(instructor.getName(instructorFormat)); if (e.hasNext()) leadsSb.append(";"); } if (isCommited().booleanValue()) { file.addLine(new CSVField[] { new CSVField(clazz.getCourseName()), new CSVField(clazz.getItypeDesc()), new CSVField(clazz.getSectionNumber()), new CSVField(clazz.getSchedulingSubpart().getSchedulingSubpartSuffix()), new CSVField(clazz.getDivSecNumber()), new CSVField(clazz.effectiveDatePattern().getName()), new CSVField(""), new CSVField(""), new CSVField(""), new CSVField(""), new CSVField(leadsSb), new CSVField( clazz.getSchedulePrintNote() == null ? "" : clazz.getSchedulePrintNote()) }); } else { file.addLine(new CSVField[] { new CSVField(clazz.getCourseName()), new CSVField(clazz.getItypeDesc()), new CSVField(clazz.getSectionNumber()), new CSVField(clazz.getSchedulingSubpart().getSchedulingSubpartSuffix()), new CSVField(clazz.effectiveDatePattern().getName()), new CSVField(""), new CSVField(""), new CSVField(""), new CSVField(""), new CSVField(leadsSb), new CSVField( clazz.getSchedulePrintNote() == null ? "" : clazz.getSchedulePrintNote()) }); } } } }
From source file:com.sshtools.common.ui.SshToolsApplicationPanel.java
/** * Rebuild all the action components such as toobar, context menu *///from w ww .ja v a 2s .c o m public void rebuildActionComponents() { // Clear the current state of the component log.debug("Rebuild action components"); toolBar.removeAll(); // Vector enabledActions = new Vector(); for (Iterator i = actions.iterator(); i.hasNext();) { StandardAction a = (StandardAction) i.next(); String n = (String) a.getValue(Action.NAME); Boolean s = (Boolean) actionsVisible.get(n); if (s == null) { s = Boolean.TRUE; } if (Boolean.TRUE.equals(s)) { log.debug("Action " + n + " is enabled."); enabledActions.add(a); } else { log.debug("Action " + n + " not enabled."); } } // Build the tool bar, grouping the actions Vector v = new Vector(); for (Iterator i = enabledActions.iterator(); i.hasNext();) { StandardAction a = (StandardAction) i.next(); if (Boolean.TRUE.equals((Boolean) a.getValue(StandardAction.ON_TOOLBAR))) { v.addElement(a); } } Collections.sort(v, new ToolBarActionComparator()); Integer grp = null; for (Iterator i = v.iterator(); i.hasNext();) { StandardAction z = (StandardAction) i.next(); if ((grp != null) && !grp.equals((Integer) z.getValue(StandardAction.TOOLBAR_GROUP))) { toolBar.add(new ToolBarSeparator()); } if (Boolean.TRUE.equals((Boolean) z.getValue(StandardAction.IS_TOGGLE_BUTTON))) { ToolToggleButton tBtn = new ToolToggleButton(z); toolBar.add(tBtn); } else { ToolButton btn = new ToolButton(z); toolBar.add(btn); } grp = (Integer) z.getValue(StandardAction.TOOLBAR_GROUP); } toolBar.revalidate(); toolBar.repaint(); // Build the context menu, grouping the actions Vector c = new Vector(); contextMenu.removeAll(); for (Iterator i = enabledActions.iterator(); i.hasNext();) { StandardAction a = (StandardAction) i.next(); if (Boolean.TRUE.equals((Boolean) a.getValue(StandardAction.ON_CONTEXT_MENU))) { c.addElement(a); } } Collections.sort(c, new ContextActionComparator()); grp = null; for (Iterator i = c.iterator(); i.hasNext();) { StandardAction z = (StandardAction) i.next(); if ((grp != null) && !grp.equals((Integer) z.getValue(StandardAction.CONTEXT_MENU_GROUP))) { contextMenu.addSeparator(); } contextMenu.add(z); grp = (Integer) z.getValue(StandardAction.CONTEXT_MENU_GROUP); } contextMenu.revalidate(); // Build the menu bar menuBar.removeAll(); v.removeAllElements(); for (Enumeration e = enabledActions.elements(); e.hasMoreElements();) { StandardAction a = (StandardAction) e.nextElement(); if (Boolean.TRUE.equals((Boolean) a.getValue(StandardAction.ON_MENUBAR))) { v.addElement(a); } } Vector menus = (Vector) actionMenus.clone(); Collections.sort(menus); HashMap map = new HashMap(); for (Iterator i = v.iterator(); i.hasNext();) { StandardAction z = (StandardAction) i.next(); String menuName = (String) z.getValue(StandardAction.MENU_NAME); if (menuName == null) { log.error("Action " + z.getName() + " doesnt specify a value for " + StandardAction.MENU_NAME); } else { String m = (String) z.getValue(StandardAction.MENU_NAME); ActionMenu menu = getActionMenu(menus.iterator(), m); if (menu == null) { log.error("Action menu " + z.getName() + " does not exist"); } else { Vector x = (Vector) map.get(menu.name); if (x == null) { x = new Vector(); map.put(menu.name, x); } x.addElement(z); } } } for (Iterator i = menus.iterator(); i.hasNext();) { ActionMenu m = (ActionMenu) i.next(); Vector x = (Vector) map.get(m.name); if (x != null) { Collections.sort(x, new MenuItemActionComparator()); JMenu menu = new JMenu(m.displayName); menu.setMnemonic(m.mnemonic); grp = null; for (Iterator j = x.iterator(); j.hasNext();) { StandardAction a = (StandardAction) j.next(); Integer g = (Integer) a.getValue(StandardAction.MENU_ITEM_GROUP); if ((grp != null) && !g.equals(grp)) { menu.addSeparator(); } grp = g; if (a instanceof MenuAction) { JMenu mnu = (JMenu) a.getValue(MenuAction.MENU); menu.add(mnu); } else { JMenuItem item = new JMenuItem(a); menu.add(item); } } menuBar.add(menu); } else { log.error("Can't find menu " + m.name); } } menuBar.validate(); menuBar.repaint(); }
From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java
/** * Generate a stacked bar graph representing test counts for each product area. * * @param builds List of builds// w w w . j av a 2s.c om * @param suites List of test suites * @param areas List of product areas * * @return Pie graph representing build execution times across all builds */ public static final JFreeChart getAreaTestCountChart(Vector<CMnDbBuildData> builds, Vector<CMnDbTestSuite> suites, Vector<CMnDbFeatureOwnerData> areas) { JFreeChart chart = null; // Collect the total times for each build, organized by area // This hashtable maps a build to the area/time information for that build Hashtable<Integer, Hashtable> buildTotals = new Hashtable<Integer, Hashtable>(); // Generate placeholders for each build so the chart maintains a // format consistent with the other charts that display build information if (builds != null) { Enumeration buildList = builds.elements(); while (buildList.hasMoreElements()) { CMnDbBuildData build = (CMnDbBuildData) buildList.nextElement(); // Create the empty area list buildTotals.put(new Integer(build.getId()), new Hashtable<String, Integer>()); } } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); if ((suites != null) && (suites.size() > 0)) { // Collect build test numbers for each of the builds in the list Enumeration suiteList = suites.elements(); while (suiteList.hasMoreElements()) { // Process the test summary for the current build CMnDbTestSuite suite = (CMnDbTestSuite) suiteList.nextElement(); Integer buildId = new Integer(suite.getParentId()); Integer testCount = new Integer(suite.getTestCount()); // Parse the build information so we can track the time by build Hashtable<String, Integer> areaCount = null; if (buildTotals.containsKey(buildId)) { areaCount = (Hashtable) buildTotals.get(buildId); } else { areaCount = new Hashtable<String, Integer>(); buildTotals.put(buildId, areaCount); } // Iterate through each product area to determine who owns this suite CMnDbFeatureOwnerData area = null; Iterator iter = areas.iterator(); while (iter.hasNext()) { CMnDbFeatureOwnerData currentArea = (CMnDbFeatureOwnerData) iter.next(); if (currentArea.hasFeature(suite.getGroupName())) { area = currentArea; } } // Add the elapsed time for the current suite to the area total Integer totalValue = null; String areaName = area.getDisplayName(); if (areaCount.containsKey(areaName)) { Integer oldTotal = (Integer) areaCount.get(areaName); totalValue = oldTotal + testCount; } else { totalValue = testCount; } areaCount.put(areaName, totalValue); } // while list has elements // Make sure every area is represented in the build totals Enumeration bt = buildTotals.keys(); while (bt.hasMoreElements()) { // Get the build ID for the current build Integer bid = (Integer) bt.nextElement(); // Get the list of area totals for the current build Hashtable<String, Integer> ac = (Hashtable<String, Integer>) buildTotals.get(bid); Iterator a = areas.iterator(); while (a.hasNext()) { // Add a value of zero if no total was found for the current area CMnDbFeatureOwnerData area = (CMnDbFeatureOwnerData) a.next(); if (!ac.containsKey(area.getDisplayName())) { ac.put(area.getDisplayName(), new Integer(0)); } } } // Populate the data set with the area times for each build Collections.sort(builds, new CMnBuildIdComparator()); Enumeration bList = builds.elements(); while (bList.hasMoreElements()) { CMnDbBuildData build = (CMnDbBuildData) bList.nextElement(); Integer buildId = new Integer(build.getId()); Hashtable areaCount = (Hashtable) buildTotals.get(buildId); Enumeration areaKeys = areaCount.keys(); while (areaKeys.hasMoreElements()) { String area = (String) areaKeys.nextElement(); Integer count = (Integer) areaCount.get(area); dataset.addValue(count, area, buildId); } } } // if list has elements // API: ChartFactory.createStackedBarChart(title, domainAxisLabel, rangeAxisLabel, dataset, orientation, legend, tooltips, urls) chart = ChartFactory.createStackedBarChart("Automated Tests by Area", "Builds", "Test Count", dataset, PlotOrientation.VERTICAL, true, true, false); // get a reference to the plot for further customization... CategoryPlot plot = (CategoryPlot) chart.getPlot(); chartFormatter.formatAreaChart(plot, dataset); return chart; }
From source file:org.kepler.dataproxy.datasource.opendap.OpendapDataSource.java
/** * Configure the output ports to expose all of the variables at the top * level of the (potentially constrained) DDS. * //ww w. j ava2 s. c o m * @param dds * The DDS * @throws IllegalActionException * When bad things happen. */ private void configureOutputPorts(DDS dds) throws IllegalActionException { Vector<Type> types = new Vector<Type>(); Vector<String> names = new Vector<String>(); if (useSeparateMetadataPort) { log.debug("Adding " + separateMetadataPortName + " port to port list."); names.add(separateMetadataPortName); types.add(AttTypeMapper.buildMetaDataTypes(dds)); log.debug("Added " + separateMetadataPortName + " port to port list."); } if (imbedMetadata) { log.debug("Adding " + globalMetadataPortName + " port to port list."); names.add(globalMetadataPortName); types.add(AttTypeMapper.convertAttributeToType(dds.getAttribute())); log.debug("Added " + globalMetadataPortName + " port."); } Enumeration e = dds.getVariables(); while (e.hasMoreElements()) { opendap.dap.BaseType bt = (opendap.dap.BaseType) e.nextElement(); types.add(TypeMapper.mapDapObjectToType(bt, imbedMetadata)); names.add(TypeMapper.replacePeriods(bt.getName())); } removeOtherOutputPorts(names); Iterator ti = types.iterator(); Iterator ni = names.iterator(); while (ti.hasNext() && ni.hasNext()) { Type type = (Type) ti.next(); String name = (String) ni.next(); initializePort(name, type); } }
From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java
/** * Generate a stacked bar graph representing test execution time for each * product area. /*from ww w . j a va 2s . c om*/ * * @param builds List of builds * @param suites List of test suites * @param areas List of product areas * * @return Stacked bar chart representing test execution times across all builds */ public static final JFreeChart getAreaTestTimeChart(Vector<CMnDbBuildData> builds, Vector<CMnDbTestSuite> suites, Vector<CMnDbFeatureOwnerData> areas) { JFreeChart chart = null; // Collect the total times for each build, organized by area // This hashtable maps a build to the area/time information for that build Hashtable<Integer, Hashtable> buildTotals = new Hashtable<Integer, Hashtable>(); // Generate placeholders for each build so the chart maintains a // format consistent with the other charts that display build information HashSet areaNames = new HashSet(); if (builds != null) { Enumeration buildList = builds.elements(); while (buildList.hasMoreElements()) { CMnDbBuildData build = (CMnDbBuildData) buildList.nextElement(); // Create the empty area list buildTotals.put(new Integer(build.getId()), new Hashtable<String, Long>()); } } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); if ((suites != null) && (suites.size() > 0)) { // Collect build test numbers for each of the builds in the list Enumeration suiteList = suites.elements(); while (suiteList.hasMoreElements()) { // Process the test summary for the current build CMnDbTestSuite suite = (CMnDbTestSuite) suiteList.nextElement(); Integer buildId = new Integer(suite.getParentId()); Long elapsedTime = new Long(suite.getElapsedTime()); // Parse the build information so we can track the time by build Hashtable<String, Long> areaTime = null; if (buildTotals.containsKey(buildId)) { areaTime = (Hashtable) buildTotals.get(buildId); } else { areaTime = new Hashtable<String, Long>(); buildTotals.put(buildId, areaTime); } // Iterate through each product area to determine who owns this suite CMnDbFeatureOwnerData area = null; Iterator iter = areas.iterator(); while (iter.hasNext()) { CMnDbFeatureOwnerData currentArea = (CMnDbFeatureOwnerData) iter.next(); if (currentArea.hasFeature(suite.getGroupName())) { area = currentArea; } } // Add the elapsed time for the current suite to the area total Long totalValue = null; String areaName = area.getDisplayName(); areaNames.add(areaName); if (areaTime.containsKey(areaName)) { Long oldTotal = (Long) areaTime.get(areaName); totalValue = oldTotal + elapsedTime; } else { totalValue = elapsedTime; } areaTime.put(areaName, totalValue); } // while list has elements // Populate the data set with the area times for each build Collections.sort(builds, new CMnBuildIdComparator()); Iterator buildIter = builds.iterator(); while (buildIter.hasNext()) { CMnDbBuildData build = (CMnDbBuildData) buildIter.next(); Integer buildId = new Integer(build.getId()); Hashtable areaTime = (Hashtable) buildTotals.get(buildId); Iterator areaKeys = areaNames.iterator(); while (areaKeys.hasNext()) { String area = (String) areaKeys.next(); Long time = (Long) areaTime.get(area); if (time != null) { // Convert the time from milliseconds to minutes time = time / (1000 * 60); } else { time = new Long(0); } dataset.addValue(time, area, buildId); } } } // if list has elements // API: ChartFactory.createStackedBarChart(title, domainAxisLabel, rangeAxisLabel, dataset, orientation, legend, tooltips, urls) chart = ChartFactory.createStackedBarChart("Automated Tests by Area", "Builds", "Execution Time (min)", dataset, PlotOrientation.VERTICAL, true, true, false); // get a reference to the plot for further customization... CategoryPlot plot = (CategoryPlot) chart.getPlot(); chartFormatter.formatAreaChart(plot, dataset); return chart; }
From source file:org.sakaiproject.tool.assessment.facade.QuestionPoolFacadeQueries.java
public List getAllItemFacadesOrderByItemText(final Long questionPoolId, final String orderBy, final String ascending) { // Fixed for bug 3559 log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: orderBy=" + orderBy); List list = getAllItems(questionPoolId); log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: size = " + list.size()); HashMap hp = new HashMap(); Vector origValueV;/*from ww w .j a va 2s. co m*/ ItemData itemData; ItemFacade itemFacade; Vector facadeVector = new Vector(); String text; for (int i = 0; i < list.size(); i++) { log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: i = " + i); itemData = (ItemData) list.get(i); itemFacade = new ItemFacade(itemData); facadeVector.add(itemFacade); log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: getItemId = " + itemData.getItemId()); log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: getText = " + itemData.getText()); // SAM-2499 text = formattedText.stripHtmlFromText(itemFacade.getText(), false, true).trim(); log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: getTextHtmlStrippedAll = '" + text + "'"); origValueV = (Vector) hp.get(text); if (origValueV == null) { log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: origValueV is null "); origValueV = new Vector(); } origValueV.add(Integer.valueOf(i)); hp.put(text, origValueV); } Vector v = new Vector(hp.keySet()); Collections.sort(v, String.CASE_INSENSITIVE_ORDER); ArrayList itemList = new ArrayList(); Iterator it = v.iterator(); Vector orderdValueV; Integer value; String key; if ((ascending != null) && ("false").equals(ascending)) {//sort descending for (int l = v.size() - 1; l >= 0; l--) { key = (String) v.get(l); orderdValueV = (Vector) hp.get(key); Iterator iter = orderdValueV.iterator(); while (iter.hasNext()) { value = (Integer) iter.next(); ItemData itemdata = (ItemData) list.get(value.intValue()); ItemFacade f = new ItemFacade(itemdata); itemList.add(f); } } } else {//sort ascending while (it.hasNext()) { key = (String) it.next(); orderdValueV = (Vector) hp.get(key); Iterator iter = orderdValueV.iterator(); while (iter.hasNext()) { value = (Integer) iter.next(); log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: sorted (value) = " + value); itemFacade = (ItemFacade) facadeVector.get(value.intValue()); itemList.add(itemFacade); } } } return itemList; }