List of usage examples for org.apache.commons.collections15.map ListOrderedMap ListOrderedMap
public ListOrderedMap()
ListOrderedMap
that decorates a HashMap
. From source file:edu.brown.hstore.PartitionExecutor.java
/** * Execute the given fragment tasks on this site's underlying EE * /*from w w w . j ava2s . c o m*/ * @param ts * @param undoToken * @param batchSize * @param fragmentIds * @param parameterSets * @param output_depIds * @param input_depIds * @return */ private DependencySet executePlanFragments(AbstractTransaction ts, long undoToken, int batchSize, long fragmentIds[], ParameterSet parameterSets[], int output_depIds[], int input_depIds[], Map<Integer, List<VoltTable>> input_deps) { assert (this.ee != null) : "The EE object is null. This is bad!"; Long txn_id = ts.getTransactionId(); // *********************************** DEBUG // *********************************** if (d) { StringBuilder sb = new StringBuilder(); sb.append(String.format("%s - Executing %d fragments [lastTxnId=%d, undoToken=%d]", ts, batchSize, this.lastCommittedTxnId, undoToken)); if (t) { Map<String, Object> m = new ListOrderedMap<String, Object>(); m.put("Fragments", Arrays.toString(fragmentIds)); Map<Integer, Object> inner = new ListOrderedMap<Integer, Object>(); for (int i = 0; i < batchSize; i++) inner.put(i, parameterSets[i].toString()); m.put("Parameters", inner); if (batchSize > 0 && input_depIds[0] != HStoreConstants.NULL_DEPENDENCY_ID) { inner = new ListOrderedMap<Integer, Object>(); for (int i = 0; i < batchSize; i++) { List<VoltTable> deps = input_deps.get(input_depIds[i]); inner.put(input_depIds[i], (deps != null ? StringUtil.join("\n", deps) : "???")); } // FOR m.put("Input Dependencies", inner); } m.put("Output Dependencies", Arrays.toString(output_depIds)); sb.append("\n" + StringUtil.formatMaps(m)); } LOG.debug(sb.toString()); } // *********************************** DEBUG // *********************************** // pass attached dependencies to the EE (for non-sysproc work). if (input_deps != null && input_deps.isEmpty() == false) { if (d) LOG.debug(String.format("%s - Stashing %d InputDependencies at partition %d", ts, input_deps.size(), this.partitionId)); ee.stashWorkUnitDependencies(input_deps); } // Check whether this fragments are read-only if (ts.isExecReadOnly(this.partitionId)) { boolean readonly = PlanFragmentIdGenerator.areFragmentsReadOnly(this.database, fragmentIds, batchSize); if (readonly == false) { if (d) LOG.debug(String.format("%s - Marking txn as not read-only %s", ts, Arrays.toString(fragmentIds))); ts.markExecNotReadOnly(this.partitionId); } // We can do this here because the only way that we're not read-only // is if // we actually modify data at this partition ts.setSubmittedEE(this.partitionId); } DependencySet result = null; boolean needs_profiling = (hstore_conf.site.txn_profiling && ts.isExecLocal(this.partitionId)); if (needs_profiling) ((LocalTransaction) ts).profiler.startExecEE(); Throwable error = null; try { if (d) LOG.debug(String.format("%s - Executing fragments %s at partition %d", ts, Arrays.toString(fragmentIds), this.partitionId)); result = this.ee.executeQueryPlanFragmentsAndGetDependencySet(fragmentIds, batchSize, input_depIds, output_depIds, parameterSets, batchSize, txn_id.longValue(), this.lastCommittedTxnId, undoToken); } catch (SerializableException ex) { if (d) LOG.error(String.format("%s - Unexpected error in the ExecutionEngine on partition %d", ts, this.partitionId), ex); error = ex; throw ex; } catch (Throwable ex) { error = ex; new ServerFaultException( String.format("%s - Failed to execute PlanFragments: %s", ts, Arrays.toString(fragmentIds)), ex); } finally { if (needs_profiling) ((LocalTransaction) ts).profiler.stopExecEE(); if (error == null && result == null) { LOG.warn(String.format( "%s - Finished executing fragments but got back null results [fragmentIds=%s]", ts, Arrays.toString(fragmentIds))); } } // *********************************** DEBUG // *********************************** if (d) { if (result != null) { LOG.debug(String.format("%s - Finished executing fragments and got back %d results", ts, result.depIds.length)); } else { LOG.warn(String.format( "%s - Finished executing fragments but got back null results? That seems bad...", ts)); } } // *********************************** DEBUG // *********************************** return (result); }
From source file:org.isatools.gui.datamanager.exportisa.ExportISAGUI.java
private void processStudies(Collection<Study> studies) { availableStudies = new ListOrderedMap<String, List<String>>(); for (Study study : studies) { // System.out.println("study investigation is : " + study.getInvestigations().size()); if (study.getInvestigations().size() > 0) { for (Investigation inv : study.getInvestigations()) { if (!availableStudies.containsKey(inv.getAcc())) { availableStudies.put(inv.getAcc(), new ArrayList<String>()); }/* ww w.ja v a2s . c o m*/ availableStudies.get(inv.getAcc()).add(study.getAcc()); } } else { availableStudies.put(study.getAcc(), null); } } }
From source file:org.isatools.gui.datamanager.studyaccess.StudyAccessionGUI.java
private void processStudies(Collection<Study> studies) { availableStudies = new ListOrderedMap<String, List<String>>(); for (Study study : studies) { if (study.getInvestigations().size() > 0) { for (Investigation inv : study.getInvestigations()) { if (!availableStudies.containsKey(inv.getAcc())) { availableStudies.put(inv.getAcc(), new ArrayList<String>()); }//from w w w .ja v a 2 s . co m availableStudies.get(inv.getAcc()).add(study.getAcc()); } } else { availableStudies.put(study.getAcc(), null); } } }
From source file:org.isatools.gui.optionselector.OptionGroup.java
/** * OptionGroup contains a number of items which you can either select one or many of depending on the single selection parameter * * @param alignment - e.g. OptionGroup.HORIZONTAL_ALIGNMENT to align the options in a horizontal arrangement. * @param singleSelection - whether or not this group should allow singular selection (true) or multiple option selection (false) *//* w w w . j ava 2 s. c o m*/ public OptionGroup(int alignment, boolean singleSelection) { this.singleSelection = singleSelection; this.alignment = alignment; availableOptions = new ListOrderedMap<T, OptionItem>(); setLayout( new BoxLayout(this, alignment == HORIZONTAL_ALIGNMENT ? BoxLayout.LINE_AXIS : BoxLayout.PAGE_AXIS)); setOpaque(false); }
From source file:org.isatools.isacreator.api.utils.SpreadsheetUtils.java
/** * @param targetSheet - Spreadsheet to 'look at' for extraction of desired column names * @param toIgnore - Set<String> containing the columns to be ignored. * @return Map containing all the desired columns along with their index. *//*from www . j a v a 2s . c o m*/ public static Map<String, Integer> getColumnNames(Spreadsheet targetSheet, Set<String> toIgnore) { Map<String, Integer> columnNamesToIndex = new ListOrderedMap<String, Integer>(); Map<Integer, String> columnIndexToName = getColumns(targetSheet, toIgnore); for (Integer columnIndex : columnIndexToName.keySet()) { columnNamesToIndex.put(columnIndexToName.get(columnIndex), columnIndex); } return columnNamesToIndex; }
From source file:org.isatools.isacreator.api.utils.SpreadsheetUtils.java
public static Map<Integer, String> getColumns(Spreadsheet targetSheet, Set<String> toIgnore) { int columnCount = targetSheet.getTable().getColumnCount(); Map<Integer, String> columnNames = new ListOrderedMap<Integer, String>(); for (int column = 1; column < columnCount; column++) { String colName = targetSheet.getTable().getColumnName(column); if (toIgnore != null) { boolean isIgnored = false; for (String ignoredFields : toIgnore) { if (colName.contains(ignoredFields)) { isIgnored = true;/*from w ww . j a va2 s .co m*/ break; } } if (!isIgnored) { columnNames.put(column, colName); } } else { columnNames.put(column, colName); } } return columnNames; }
From source file:org.isatools.isacreator.api.utils.SpreadsheetUtils.java
/** * Pulls out all values of a particular column and associates the other metadata with it as well * * @param primaryColumnName - e.g. Sample Name to pull out all the unique sample names available. * @param targetSheet - Spreadsheet to 'look at' for extraction of desired column names * @return Map<String, Map<String, String>> -> primary Column values mapped to the key/value pairs describing the particular group */// ww w. j ava 2 s. c om public static Map<String, SampleInformation> getGroupInformation(String primaryColumnName, Spreadsheet targetSheet) { Map<String, SampleInformation> groupInformation = new HashMap<String, SampleInformation>(); Map<Integer, String> columnIndicesToName = getColumns(targetSheet, new HashSet<String>()); for (int rowNo = 0; rowNo < targetSheet.getTable().getRowCount(); rowNo++) { String primaryColumnValue = ""; if (!groupInformation.containsKey(primaryColumnName)) { Map<String, String> keyValues = new ListOrderedMap<String, String>(); Map<String, Integer> columnNameToIndex = new HashMap<String, Integer>(); for (int column = 1; column < targetSheet.getColumnCount(); column++) { Object dataVal = targetSheet.getTable().getValueAt(rowNo, column); String columnName = columnIndicesToName.get(column); if (columnName.equalsIgnoreCase(primaryColumnName)) { primaryColumnValue = dataVal == null ? "" : dataVal.toString(); } else { keyValues.put(columnName, dataVal == null ? "" : dataVal.toString()); columnNameToIndex.put(columnName, column); } } groupInformation.put(primaryColumnValue, new SampleInformation(rowNo, primaryColumnValue, keyValues, columnNameToIndex)); } } return groupInformation; }
From source file:org.isatools.isacreator.common.filterableTree.TreeFilterModel.java
public TreeFilterModel(TreeNode treeNode, FilterableJTree targetJTree) { super(treeNode); this.targetJTree = targetJTree; items = new ListOrderedMap<T, Set<V>>(); filterItems = new ListOrderedMap<T, Set<V>>(); }
From source file:org.isatools.isacreator.formatmappingutility.loader.CSVFileLoader.java
/** * File should be checked to determine whether or not it is a directory. if not, then just load the single file * * @param f - Either a file or pointer to a directory! * @return Map<String, String[]> where key is the file name and the String[] is the list of column names *///from w ww . j a va 2 s .co m public Map<String, String[]> processFile(File f) { Map<String, String[]> result = new ListOrderedMap<String, String[]>(); try { File[] files; if (f.isDirectory()) { files = f.listFiles(); } else { files = new File[] { f }; } for (File file : files) { if (!file.isHidden()) { String[] firstLine; CSVReader reader = new CSVReader(new FileReader(file), delimiter); if (delimiter == FileLoader.COMMA_DELIM) { readerUsed = FileLoader.CSV_READER_CSV; } else { readerUsed = FileLoader.CSV_READER_TXT; } int rowOffSet; try { rowOffSet = Integer.parseInt(ISAcreatorProperties.getProperty("isacreator.rowOffset")) - 1; } catch (NumberFormatException nfe) { rowOffSet = 0; } for (int skipCount = 0; skipCount < rowOffSet; skipCount++) { reader.readNext(); } firstLine = reader.readNext(); // clean up for (int i = 0; i < firstLine.length; i++) { firstLine[i] = firstLine[i].trim(); } result.put(file.getPath(), firstLine); } } } catch (FileNotFoundException e) { log.error("file not found: " + e.getMessage()); } catch (IOException e) { log.error("io exception occurred " + e.getMessage()); } catch (Exception e) { log.error( "problem with incoming file. We were unable to process it for this reason: " + e.getMessage()); } return result; }
From source file:org.isatools.isacreator.formatmappingutility.loader.ExcelFileLoader.java
public Map<String, String[]> processFile(File f) { Map<String, String[]> columnHeaders = new ListOrderedMap<String, String[]>(); Workbook w;// w w w .ja v a 2 s . com try { if (!f.isHidden()) { w = Workbook.getWorkbook(f); // Get the first sheet for (Sheet s : w.getSheets()) { int rowStart; try { rowStart = Integer.parseInt(ISAcreatorProperties.getProperty("isacreator.rowOffset")) - 1; System.out.println("Row offset is: " + rowStart); } catch (NumberFormatException nfe) { System.out.println(nfe.getMessage()); rowStart = 0; } if (s.getRows() > 0) { List<String> headersForSheet = new ArrayList<String>(); for (int j = 0; j < s.getColumns(); j++) { String cellContents = s.getCell(j, rowStart).getContents(); if (!cellContents.trim().equals("")) { headersForSheet.add(cellContents); } } columnHeaders.put(s.getName(), headersForSheet.toArray(new String[headersForSheet.size()])); } } } } catch (BiffException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return columnHeaders; }