List of usage examples for java.util Vector addAll
public boolean addAll(Collection<? extends E> c)
From source file:edu.ku.brc.specify.tasks.WorkbenchTask.java
/** * Creates a BarChart or PieChart./*from w w w .ja v a2s .c om*/ * @param cmdAction the action that invoked it * @param doBarChart show bar chart */ protected void doChart(final CommandAction cmdAction, final boolean doBarChart) { Workbench workbench = selectWorkbench(cmdAction, "WorkbenchChart"); // XXX ADD HELP if (workbench == null) { return; } DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession(); session.attach(workbench); WorkbenchTemplate workbenchTemplate = workbench.getWorkbenchTemplate(); Set<WorkbenchTemplateMappingItem> mappings = workbenchTemplate.getWorkbenchTemplateMappingItems(); Vector<WorkbenchTemplateMappingItem> items = new Vector<WorkbenchTemplateMappingItem>(); items.addAll(mappings); session.close(); WorkbenchTemplateMappingItem selectMappingItem = selectMappingItem(items); if (selectMappingItem != null) { final Vector<Object> data = new Vector<Object>(); try { if (true) { String sql = "SELECT CellData as Name, count(CellData) as Cnt FROM workbenchdataitem di inner join workbenchrow rw on " + "di.WorkbenchRowId = rw.WorkbenchRowId where rw.WorkBenchId = " + workbench.getWorkbenchId() + " and WorkbenchTemplateMappingItemId = " + selectMappingItem.getWorkbenchTemplateMappingItemId() + " group by CellData order by Cnt desc, Name asc"; Connection conn = DBConnection.getInstance().createConnection(); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sql); int count = 0; while (rs.next() && (doBarChart || count < 10)) { data.add(rs.getString(1)); data.add(rs.getInt(2)); count++; } } else { Session hibSession = null; try { String hql = "SELECT item.cellData as Name, count(item.cellData) as Cnt FROM WorkbenchDataItem as item inner join item.workbenchRow as row join item.workbenchTemplateMappingItem as mapitem where mapitem.workbenchTemplateMappingItemId = " + selectMappingItem.getWorkbenchTemplateMappingItemId() + " group by item.cellData order by count(item.cellData) desc"; hibSession = HibernateUtil.getNewSession(); List<?> list = hibSession.createQuery(hql).list(); int count = 0; int returnCnt = list.size(); while (count < returnCnt && (doBarChart || count < 10)) { Object dataRow = list.get(count); if (dataRow instanceof Object[]) { for (Object o : (Object[]) dataRow) { data.add(o); } } count++; } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(WorkbenchTask.class, ex); log.error(ex); } finally { if (hibSession != null) { try { hibSession.close(); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(WorkbenchTask.class, ex); log.error(ex); } } } } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(WorkbenchTask.class, ex); log.error(ex); } QueryResultsHandlerIFace qrhi = new QueryResultsHandlerIFace() { public void init(final QueryResultsListener listener, final java.util.List<QueryResultsContainerIFace> list) { //nothing to do. } public void init(final QueryResultsListener listener, final QueryResultsContainerIFace qrc) { //nothing to do. } public void startUp() { //nothing to do } public void cleanUp() { //nothing to do } public java.util.List<Object> getDataObjects() { return data; } public boolean isPairs() { return true; } }; String chartTitle = String.format(getResourceString("WB_CHART_TITLE"), new Object[] { selectMappingItem.getCaption() }); ChartPane chart = doBarChart ? new BarChartPane(chartTitle, this) : new PieChartPane(chartTitle, this); chart.setTitle(chartTitle); chart.setHandler(qrhi); chart.allResultsBack(null); addSubPaneToMgr(chart); } }
From source file:sos.net.SOSFTP.java
/** * return a listing of the contents of a directory in short format on * the remote machine (without subdirectory) * /*from ww w . j av a 2s .c o m*/ * @param pstrPathName on remote machine * @return a listing of the contents of a directory on the remote machine * @throws IOException * * @exception Exception * @see #dir() */ private Vector<String> getFilenames(final String pstrPathName, final boolean flgRecurseSubFolders) throws IOException { Vector<String> vecListFileItems = new Vector<String>(); // setListHiddenFiles(true); String[] fileList = null; String strCurrentDirectoryName = DoPWD(); String lstrPathName = pstrPathName.trim(); if (lstrPathName.length() <= 0) { lstrPathName = "."; } if (lstrPathName.equals(".")) { lstrPathName = strCurrentDirectoryName; } objLogger.debug("nlist with " + lstrPathName); if (1 == 1) { fileList = listNames(lstrPathName); } else { FTPFile[] objFtpFiles = listFiles(lstrPathName); if (objFtpFiles != null) { int i = 0; for (FTPFile ftpFile : objFtpFiles) { fileList[i++] = ftpFile.getName(); } } } if (fileList == null) { return vecListFileItems; } for (String strCurrentFileName : fileList) { if (isNotHiddenFile(strCurrentFileName)) { DoCD(strCurrentFileName); // is this file-entry a subfolder? if (isNegativeCommandCompletion()) { /** * kb 2011-04-27 add Directory-name if flgRecurseSubFolders == true */ if (flgRecurseSubFolders && strCurrentFileName.startsWith(strCurrentDirectoryName) == false) { if (strCurrentDirectoryName.length() > 0) { strCurrentFileName = strCurrentDirectoryName + "/" + strCurrentFileName; } } /** * \change * kb: 2011-06-17 * bei sBroker gibt der FTP-Server (oder wer auch immer) einen backslash vor dem * Dateinamen an, der Pfad selbst ist mit "/" maskiert. * beispiel: /a/b/c\dateiname.pdf * siehe auch http://www.mail-archive.com/gnu-arch-users@gnu.org/msg02884.html * * wird ein solcher Pfad an den Server gesendet, um die Datei zu holen, so gibt * es die Meldung, da eine solche Datei nicht vorhanden ist. Das scheint eine konfig-sache * zu sein. 8of9 - liefert auch den backslash - erlaubt die angabe beider Pfadtrenner und zickt nicht rum. * * Um dies zu vermeiden wird hier ein eventueller backslash in einen normalen * Schrgstrich umgewandelt. */ strCurrentFileName = strCurrentFileName.replaceAll(conRegExpBackslash, "/"); vecListFileItems.add(strCurrentFileName); } else { // yes, it's a subfolder. undo the cd now // String[] strSubFolders = strCurrentFile.split("/"); // get number of subfolders in path // for (int s = 0; s < strSubFolders.length; s++) { // DoCDUP(); // } DoCDUP(); if (flgRecurseSubFolders) { Vector<String> vecNames = getFilenames(strCurrentFileName); if (vecNames != null) { vecListFileItems.addAll(vecNames); } } } } } objLogger.debug("strCurrentDirectory = " + strCurrentDirectoryName); DoCD(strCurrentDirectoryName); DoPWD(); return vecListFileItems; }
From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java
/** * @return//from w w w. jav a2 s. c om */ public static Vector<QueryFieldPanel> getQueryFieldPanelsForMapping( final QueryFieldPanelContainerIFace container, Set<SpQueryField> fields, final TableTree tblTree, final Hashtable<String, TableTree> ttHash, final Component saveBtn, SpExportSchemaMapping schemaMapping, List<String> missingFlds, Map<String, Vector<MappedFieldInfo>> autoMaps) { Vector<QueryFieldPanel> result = new Vector<QueryFieldPanel>(); //Need to change columnDefStr if mapMode... //result.add(bldQueryFieldPanel(this, null, null, getColumnDefStr(), saveBtn)); result.add(new QueryFieldPanel(container, null, container.getColumnDefStr(), saveBtn, null, schemaMapping, null)); Vector<SpExportSchemaItem> sis = new Vector<SpExportSchemaItem>(); if (schemaMapping.getSpExportSchema() != null) { sis.addAll(schemaMapping.getSpExportSchema().getSpExportSchemaItems()); } Collections.sort(sis, new Comparator<SpExportSchemaItem>() { /* (non-Javadoc) * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ @Override public int compare(SpExportSchemaItem o1, SpExportSchemaItem o2) { return o1.getFieldName().compareTo(o2.getFieldName()); } }); for (SpExportSchemaItem schemaItem : sis) { //System.out.println("SchemaItem: " + schemaItem.getFieldName()); boolean autoMapped = false; SpQueryField fld = getQueryFieldMapping(schemaMapping, schemaItem); FieldQRI fieldQRI = null; if (fld == null && autoMaps != null) { Vector<MappedFieldInfo> mappedTos = autoMaps.get(schemaItem.getFieldName().toLowerCase()); if (mappedTos != null) { for (MappedFieldInfo mappedTo : mappedTos) { fieldQRI = getFieldQRI(tblTree, mappedTo.getFieldName(), mappedTo.isRel(), mappedTo.getStringId(), getTableIds(mappedTo.getTableIds()), 0, ttHash); if (fieldQRI != null) { if (!fieldQRI.isFieldHidden()) { autoMapped = true; } else { fieldQRI = null; } break; } } } //result.add(new QueryFieldPanel(container, null, // container.getColumnDefStr(), saveBtn, fld, schemaMapping, schemaItem)); } else if (fld != null) { fieldQRI = getFieldQRI(tblTree, fld.getFieldName(), fld.getIsRelFld() != null && fld.getIsRelFld(), fld.getStringId(), getTableIds(fld.getTableList()), 0, ttHash); } if (fieldQRI != null) { QueryFieldPanel newPanel = new QueryFieldPanel(container, fieldQRI, container.getColumnDefStr(), saveBtn, fld, schemaMapping, schemaItem); newPanel.setAutoMapped(autoMapped); result.add(newPanel); fieldQRI.setIsInUse(true); if (fieldQRI.isFieldHidden() && !container.isPromptMode() && !container.isForSchemaExport()) { UIRegistry.showLocalizedMsg("QB_FIELD_HIDDEN_TITLE", "QB_FIELD_HIDDEN_SHOULD_REMOVE", fieldQRI.getTitle()); } } else if (fld != null) { log.error("Couldn't find [" + fld.getFieldName() + "] [" + fld.getTableList() + "]"); if (!container.isForSchemaExport() && !container.isPromptMode()) { for (SpQueryField field : fields) { //ain't superstitious but checking ids in case //fld and field are different java objects if (field.getId().equals(fld.getId())) { SpExportSchemaItemMapping mappingForField = null; for (SpExportSchemaItemMapping m : schemaMapping.getMappings()) { if (m.getQueryField() != null && field.getId().equals(m.getQueryField().getId())) { mappingForField = m; break; } } if (mappingForField != null) { schemaMapping.getMappings().remove(mappingForField); mappingForField.setExportSchemaItem(null); mappingForField.setExportSchemaMapping(null); mappingForField.setQueryField(null); } fields.remove(field); field.setQuery(null); fld.setQuery(null); break; } } } if (missingFlds != null) { String fldText = fld.getColumnAlias() != null ? fld.getColumnAlias() : fld.getFieldName(); missingFlds.add(fldText); } } } List<SpQueryField> toRemove = new ArrayList<SpQueryField>(); //add 'auto-mapped' fields not mapped to a concept if (autoMaps != null && fields.size() == 0 /* a new mapping */) { int cnt = 0; for (Map.Entry<String, Vector<MappedFieldInfo>> me : autoMaps.entrySet()) { if (me.getKey().startsWith("Unmapped:")) { MappedFieldInfo fi = me.getValue().get(0); SpQueryField fld = new SpQueryField(); fld.initialize(); fld.setIsNot(false); fld.setAlwaysFilter(false); fld.setIsPrompt(true); fld.setIsRelFld(false); fld.setSortType(Byte.valueOf("0")); fld.setPosition(Short.valueOf(String.valueOf(result.size() - 1 + cnt++))); fld.setSpQueryFieldId(-1); fld.setIsDisplay(false); fld.setOperStart(fi.getOperator()); fld.setFieldName(fi.getFieldName()); fld.setStringId(fi.getStringId()); fld.setTableList(fi.getTableIds()); fld.setContextTableIdent(fi.getContextTableId()); fields.add(fld); toRemove.add(fld); } } } //now add un-mapped fields for (SpQueryField fld : fields) { //int insertAt = 0; if (fld.getMapping() == null || fld.getMapping().getExportSchemaItem() == null) { FieldQRI fieldQRI = getFieldQRI(tblTree, fld.getFieldName(), fld.getIsRelFld() != null && fld.getIsRelFld(), fld.getStringId(), getTableIds(fld.getTableList()), 0, ttHash); if (fieldQRI != null) { // result.insertElementAt(new QueryFieldPanel(container, fieldQRI, // container.getColumnDefStr(), saveBtn, fld, null, true), insertAt++); QueryFieldPanel newQfp = new QueryFieldPanel(container, fieldQRI, container.getColumnDefStr(), saveBtn, fld, schemaMapping, null); result.add(newQfp); fieldQRI.setIsInUse(true); if (fld.getSpQueryFieldId() == -1) { newQfp.setAutoMapped(true); newQfp.setQueryFieldForAutomapping(null); } if (fieldQRI.isFieldHidden() && !container.isPromptMode() && !container.isForSchemaExport()) { UIRegistry.showLocalizedMsg("QB_FIELD_HIDDEN_TITLE", "QB_FIELD_HIDDEN_SHOULD_REMOVE", fieldQRI.getTitle()); } } else { log.error("Couldn't find [" + fld.getFieldName() + "] [" + fld.getTableList() + "]"); if (!container.isForSchemaExport() && !container.isPromptMode()) { for (SpQueryField field : fields) { //ain't superstitious but checking ids in case //fld and field are different java objects if (field.getId().equals(fld.getId())) { SpExportSchemaItemMapping mappingForField = null; for (SpExportSchemaItemMapping m : schemaMapping.getMappings()) { if (m.getQueryField() != null && field.getId().equals(m.getQueryField().getId())) { mappingForField = m; break; } } if (mappingForField != null) { schemaMapping.getMappings().remove(mappingForField); mappingForField.setExportSchemaItem(null); mappingForField.setExportSchemaMapping(null); mappingForField.setQueryField(null); } toRemove.add(field); field.setQuery(null); fld.setQuery(null); break; } } } if (missingFlds != null) { missingFlds.add(fld.getColumnAlias()); } } } } for (SpQueryField f : toRemove) { fields.remove(f); } // now add placeHolder panel for adding new condition //result.add(new QueryFieldPanel(container, null, // container.getColumnDefStr(), saveBtn, null, null, null, true)); //now sort on queryfield position Collections.sort(result, new Comparator<QueryFieldPanel>() { /* (non-Javadoc) * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ @Override public int compare(QueryFieldPanel o1, QueryFieldPanel o2) { SpQueryField f1 = o1.getQueryField(); SpQueryField f2 = o2.getQueryField(); if (f1 != null && f2 != null) { return f1.getPosition().compareTo(f2.getPosition()); } else if (f1 != null) { return 1; } else if (f2 != null) { return -1; } else return 0; } }); return result; }
From source file:edu.ku.brc.specify.tools.LocalizerSearchHelper.java
/** * @param baseDir//from w w w.jav a 2 s . com * @return */ public Vector<Pair<String, String>> findOldL10NKeys(final String[] fileNames) { initLucene(true); //if (srcCodeFilesDir == null) { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (srcCodeFilesDir != null) { chooser.setSelectedFile(new File(FilenameUtils.getName(srcCodeFilesDir.getAbsolutePath()))); chooser.setSelectedFile(new File(srcCodeFilesDir.getParent())); } if (chooser.showOpenDialog(UIRegistry.getMostRecentWindow()) == JFileChooser.APPROVE_OPTION) { srcCodeFilesDir = new File(chooser.getSelectedFile().getAbsolutePath()); } else { return null; } } indexSourceFiles(); Vector<Pair<String, String>> fullNotFoundList = new Vector<Pair<String, String>>(); try { ConversionLogger convLogger = new ConversionLogger(); convLogger.initialize("resources", "Resources"); for (String fileName : fileNames) { Vector<Pair<String, String>> notFoundList = new Vector<Pair<String, String>>(); Vector<String> terms = new Vector<String>(); String propFileName = baseDir.getAbsolutePath() + "/" + fileName; File resFile = new File(propFileName + ".properties"); if (resFile.exists()) { List<?> lines = FileUtils.readLines(resFile); for (String line : (List<String>) lines) { if (!line.startsWith("#")) { int inx = line.indexOf("="); if (inx > -1) { String[] toks = StringUtils.split(line, "="); if (toks.length > 1) { terms.add(toks[0]); } } } } } else { System.err.println("Doesn't exist: " + resFile.getAbsolutePath()); } String field = "contents"; QueryParser parser = new QueryParser(Version.LUCENE_36, field, analyzer); for (String term : terms) { Query query; try { if (term.equals("AND") || term.equals("OR")) continue; query = parser.parse(term); String subTerm = null; int hits = getTotalHits(query, 10); if (hits == 0) { int inx = term.indexOf('.'); if (inx > -1) { subTerm = term.substring(inx + 1); hits = getTotalHits(parser.parse(subTerm), 10); if (hits == 0) { int lastInx = term.lastIndexOf('.'); if (lastInx > -1 && lastInx != inx) { subTerm = term.substring(lastInx + 1); hits = getTotalHits(parser.parse(subTerm), 10); } } } } if (hits == 0 && !term.endsWith("_desc")) { notFoundList.add(new Pair<String, String>(term, subTerm)); log.debug("'" + term + "' was not found " + (subTerm != null ? ("SubTerm[" + subTerm + "]") : "")); } } catch (ParseException e) { e.printStackTrace(); } } String fullName = propFileName + ".html"; TableWriter tblWriter = convLogger.getWriter(FilenameUtils.getName(fullName), propFileName); tblWriter.startTable(); tblWriter.logHdr("Id", "Full Key", "Sub Key"); int cnt = 1; for (Pair<String, String> pair : notFoundList) { tblWriter.log(Integer.toString(cnt++), pair.first, pair.second != null ? pair.second : " "); } tblWriter.endTable(); fullNotFoundList.addAll(notFoundList); if (notFoundList.size() > 0 && resFile.exists()) { List<String> lines = (List<String>) FileUtils.readLines(resFile); Vector<String> linesCache = new Vector<String>(); for (Pair<String, String> p : notFoundList) { linesCache.clear(); linesCache.addAll(lines); int lineInx = 0; for (String line : linesCache) { if (!line.startsWith("#")) { int inx = line.indexOf("="); if (inx > -1) { String[] toks = StringUtils.split(line, "="); if (toks.length > 1) { if (toks[0].equals(p.first)) { lines.remove(lineInx); break; } } } } lineInx++; } } FileUtils.writeLines(resFile, linesCache); } } convLogger.closeAll(); } catch (IOException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(LocalizerSearchHelper.class, ex); ex.printStackTrace(); } return fullNotFoundList; }
From source file:hudson.plugins.project_inheritance.projects.InheritanceProject.java
/** * Creates a list of temporary {@link Action}s as they are contributed * by the various Builders, Publishers, etc. from the correct version and * with the the correct inheritance./*from www .java 2 s . c o m*/ */ protected List<Action> createVersionAwareTransientActions() { Vector<Action> ta = new Vector<Action>(); // START Implementation from AbstractProject for (JobProperty<? super InheritanceProject> p : this.getAllProperties()) { ta.addAll(p.getJobActions(this)); } for (TransientProjectActionFactory tpaf : TransientProjectActionFactory.all()) { ta.addAll(Util.fixNull(tpaf.createFor(this))); // be defensive against null } // END Implementation from AbstractProject // START Implementation from Project for (BuildStep step : this.getBuildersList()) ta.addAll(step.getProjectActions(this)); for (BuildStep step : this.getPublishersList()) ta.addAll(step.getProjectActions(this)); for (BuildWrapper step : this.getBuildWrappersList()) ta.addAll(step.getProjectActions(this)); //FIXME: Triggers are not yet versioned! Correct this! for (Trigger trigger : this.getTriggers().values()) ta.addAll(trigger.getProjectActions()); // END Implementation from Project return ta; }
From source file:org.openbravo.erpCommon.modules.ImportModule.java
/** * Installs or updates the modules in the obx file * /*from ww w.j av a 2 s. c o m*/ * @param obx * @param moduleID * The ID for the current module to install * @throws Exception */ private void installModule(InputStream obx, String moduleID, Vector<DynaBean> dModulesToInstall, Vector<DynaBean> dDependencies, Vector<DynaBean> dDBprefix) throws Exception { // For local installations modules are temporary unzipped in tmp/localInstall directory, because // it is possible this version in obx is not going to be installed, in any case it must be // unzipped looking for other obx files inside it. String fileDestination = installLocally && !"0".equals(moduleID) ? obDir + "/tmp/localInstall" : obDir; if (!(new File(fileDestination + "/modules").canWrite())) { addLog("@CannotWriteDirectory@ " + fileDestination + "/modules. ", MSG_ERROR); throw new PermissionException("Cannot write on directory: " + fileDestination + "/modules"); } final ZipInputStream obxInputStream = new ZipInputStream(obx); ZipEntry entry = null; while ((entry = obxInputStream.getNextEntry()) != null) { if (entry.getName().endsWith(".obx")) { // If it is a new module // install it if (installLocally) { final ByteArrayInputStream ba = new ByteArrayInputStream( getBytesCurrentEntryStream(obxInputStream)); installModule(ba, moduleID, dModulesToInstall, dDependencies, dDBprefix); } // If install remotely it is no necessary to install the .obx // because it will be get from CR obxInputStream.closeEntry(); } else { // Unzip the contents final String fileName = fileDestination + (moduleID.equals("0") ? "/" : "/modules/") + entry.getName().replace("\\", "/"); final File entryFile = new File(fileName); // Check whether the directory exists, if not create File dir = null; if (entryFile.getParent() != null) dir = new File(entryFile.getParent()); if (entry.isDirectory()) dir = entryFile; if (entry.isDirectory() || entryFile.getParent() != null) { if (!dir.exists()) { log4j.debug("Created dir: " + dir.getAbsolutePath()); dir.mkdirs(); } } if (!entry.isDirectory()) { // It is a file byte[] entryBytes = null; boolean found = false; // Read the xml file to obtain module info if (entry.getName().replace("\\", "/").endsWith("src-db/database/sourcedata/AD_MODULE.xml")) { entryBytes = getBytesCurrentEntryStream(obxInputStream); final Vector<DynaBean> module = getEntryDynaBeans(entryBytes); moduleID = (String) module.get(0).get("AD_MODULE_ID"); if (installingModule(moduleID)) { dModulesToInstall.addAll(module); } obxInputStream.closeEntry(); found = true; } else if (entry.getName().replace("\\", "/") .endsWith("src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml")) { entryBytes = getBytesCurrentEntryStream(obxInputStream); final Vector<DynaBean> dep = getEntryDynaBeans(entryBytes); if (installingModule((String) dep.get(0).get("AD_MODULE_ID"))) { dDependencies.addAll(dep); } obxInputStream.closeEntry(); found = true; } else if (entry.getName().replace("\\", "/") .endsWith("src-db/database/sourcedata/AD_MODULE_DBPREFIX.xml")) { entryBytes = getBytesCurrentEntryStream(obxInputStream); final Vector<DynaBean> dbp = getEntryDynaBeans(entryBytes); if (installingModule((String) dbp.get(0).get("AD_MODULE_ID"))) { dDBprefix.addAll(dbp); } obxInputStream.closeEntry(); found = true; } // Unzip the file log4j.debug("Installing " + fileName); final FileOutputStream fout = new FileOutputStream(entryFile); if (found) { // the entry is already read as a byte[] fout.write(entryBytes); } else { final byte[] buf = new byte[4096]; int len; while ((len = obxInputStream.read(buf)) > 0) { fout.write(buf, 0, len); } } fout.close(); } obxInputStream.closeEntry(); } } obxInputStream.close(); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
/** * @param solutions// w ww. j a va2 s . c o m * @return a copy of solutions with only duplicate solutions (i.e same tables, different order) removed. */ protected Vector<Vector<Table>> removeDuplicateSolutions(Vector<Vector<Table>> solutions) { SortedSet<Vector<Table>> sorted = new TreeSet<Vector<Table>>(new Comparator<Vector<Table>>() { /* * (non-Javadoc) * * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(Vector<Table> o1, Vector<Table> o2) { int size1 = o1 == null ? 0 : o1.size(); int size2 = o2 == null ? 0 : o2.size(); if (o1 != null && o2 != null && size1 == size2) { if (o1.containsAll(o2)) { return 0; } // else if (o1.size() == 0) return 0; int id1 = o1.get(0).getTableInfo().getTableId(); int id2 = o2.get(0).getTableInfo().getTableId(); return id1 < id2 ? -1 : (id1 == id2 ? 0 : 1); } return size1 < size2 ? -1 : 1; } }); for (Vector<Table> solution : solutions) { sorted.add(solution); } Vector<Vector<Table>> result = new Vector<Vector<Table>>(); result.addAll(sorted); return result; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
public Vector<UploadField> checkChangedData(int row) throws Exception { getRootTable().loadExportedRecord(/*row, */theWb.getRow(row).getRecordId()); Vector<UploadField> result = new Vector<UploadField>(); for (UploadTable ut : uploadTables) { result.addAll(ut.getChangedFields(row)); }/*from w w w.java 2 s. c om*/ if (result.size() > 0) { //for (UploadField fld : result) //{ //System.out.println(fld.getWbFldName()); //} } return result; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
/** * @return groups tables that, if added to the dataset, will probably make the dataset * structurally sufficient for upload. *//*from w w w .j av a 2s. c o m*/ protected Vector<Vector<Table>> getMissingTbls() throws DirectedGraphException { Vector<Vector<Table>> result = new Vector<Vector<Table>>(); int depth = 1; while (result.size() == 0 && depth < 4) { result.addAll(connectUploadGraph(depth++)); } if (result.size() == 0) { result.add(null); } //It would make more sense to fix connectUploadGraph to not generate duplicate solutions, //but that would be hard. return removeDuplicateSolutions(result); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
/** * @param row/*from w w w .jav a 2 s. c o m*/ * @param col * @return list of invalid values */ public Vector<UploadTableInvalidValue> validateData(int row, int col) { Vector<UploadTableInvalidValue> result = new Vector<UploadTableInvalidValue>(); //XXX figure out which table is associated with col. for (UploadTable tbl : uploadTables) { tbl.clearBlankness(); } for (UploadTable tbl : uploadTables) { result.addAll(validateLengths(tbl, row, col)); tbl.validateRowValues(row, uploadData, result); } //XXX not the right place!!!!!!!! // try // { // checkChangedData(row); // } catch (Exception ex) // { // ex.printStackTrace(); // } return result; }