List of usage examples for java.util Vector indexOf
public int indexOf(Object o)
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetAttribute1Listener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub Vector<String> values = this.setAttribute1UI.getValues(); Vector<String> samples = this.setAttribute1UI.getSamples(); File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); File stsmf = ((GeneExpressionData) this.dataType).getStsmf(); if (stsmf == null) { this.setAttribute1UI.displayMessage("Error: no subject to sample mapping file"); }//from w w w . j av a2 s .c o m try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n"); try { BufferedReader br = new BufferedReader(new FileReader(stsmf)); String line = br.readLine(); while ((line = br.readLine()) != null) { String[] fields = line.split("\t", -1); String sample = fields[3]; String attribute; if (samples.contains(sample)) { attribute = values.get(samples.indexOf(sample)); } else { br.close(); return; } out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + fields[4] + "\t" + fields[5] + "\t" + attribute + "\t" + fields[7] + "\t" + fields[8] + "\n"); } br.close(); } catch (Exception e) { setAttribute1UI.displayMessage("File error: " + e.getLocalizedMessage()); out.close(); e.printStackTrace(); } out.close(); try { File fileDest; if (stsmf != null) { String fileName = stsmf.getName(); stsmf.delete(); fileDest = new File(this.dataType.getPath() + File.separator + fileName); } else { fileDest = new File(this.dataType.getPath() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping"); } FileUtils.moveFile(file, fileDest); ((GeneExpressionData) this.dataType).setSTSMF(fileDest); } catch (IOException ioe) { this.setAttribute1UI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setAttribute1UI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setAttribute1UI.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetAttribute2Listener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub Vector<String> values = this.setAttribute2UI.getValues(); Vector<String> samples = this.setAttribute2UI.getSamples(); File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); File stsmf = ((GeneExpressionData) this.dataType).getStsmf(); if (stsmf == null) { this.setAttribute2UI.displayMessage("Error: no subject to sample mapping file"); }/* w ww .ja v a 2 s. c o m*/ try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n"); try { BufferedReader br = new BufferedReader(new FileReader(stsmf)); String line = br.readLine(); while ((line = br.readLine()) != null) { String[] fields = line.split("\t", -1); String sample = fields[3]; String attribute; if (samples.contains(sample)) { attribute = values.get(samples.indexOf(sample)); } else { br.close(); return; } out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + fields[4] + "\t" + fields[5] + "\t" + fields[6] + "\t" + attribute + "\t" + fields[8] + "\n"); } br.close(); } catch (Exception e) { this.setAttribute2UI.displayMessage("File error: " + e.getLocalizedMessage()); out.close(); e.printStackTrace(); } out.close(); try { File fileDest; if (stsmf != null) { String fileName = stsmf.getName(); stsmf.delete(); fileDest = new File(this.dataType.getPath() + File.separator + fileName); } else { fileDest = new File(this.dataType.getPath() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping"); } FileUtils.moveFile(file, fileDest); ((GeneExpressionData) this.dataType).setSTSMF(fileDest); } catch (IOException ioe) { this.setAttribute2UI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setAttribute2UI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setAttribute2UI.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SetTissueTypeListener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub Vector<String> values = this.setTissueTypeUI.getValues(); Vector<String> samples = this.setTissueTypeUI.getSamples(); File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping.tmp"); File stsmf = ((GeneExpressionData) this.dataType).getStsmf(); if (stsmf == null) { this.setTissueTypeUI.displayMessage("Error: no subject to sample mapping file"); }/*from ww w .ja v a 2 s. co m*/ try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n"); try { BufferedReader br = new BufferedReader(new FileReader(stsmf)); String line = br.readLine(); while ((line = br.readLine()) != null) { String[] fields = line.split("\t", -1); String sample = fields[3]; String tissueType; if (samples.contains(sample)) { tissueType = values.get(samples.indexOf(sample)); } else { br.close(); return; } out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + fields[4] + "\t" + tissueType + "\t" + fields[6] + "\t" + fields[7] + "\t" + fields[8] + "\n"); } br.close(); } catch (Exception e) { this.setTissueTypeUI.displayMessage("File error: " + e.getLocalizedMessage()); out.close(); e.printStackTrace(); } out.close(); try { File fileDest; if (stsmf != null) { String fileName = stsmf.getName(); stsmf.delete(); fileDest = new File(this.dataType.getPath() + File.separator + fileName); } else { fileDest = new File(this.dataType.getPath() + File.separator + this.dataType.getStudy().toString() + ".subject_mapping"); } FileUtils.moveFile(file, fileDest); ((GeneExpressionData) this.dataType).setSTSMF(fileDest); } catch (IOException ioe) { this.setTissueTypeUI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setTissueTypeUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setTissueTypeUI.displayMessage("Subject to sample mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:keel.GraphInterKeel.datacf.visualizeData.VisualizePanelCharts2D.java
private void ViewChartjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ViewChartjButtonActionPerformed // Show comparing chart if ((this.attribute1jComboBox.getSelectedIndex() == -1) || (this.attribute2jComboBox.getSelectedIndex() == -1)) { JOptionPane.showMessageDialog(this, "There are no attributes selected", "Error", 2); } else if (((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeTypeIndex(this.attribute1jComboBox.getSelectedIndex()).equals("nominal") && ((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeTypeIndex(this.attribute2jComboBox.getSelectedIndex()).equals("nominal")) { // Error message JOptionPane.showMessageDialog(this, "Only one attribute can be nominal", "Error", 2); } else if (((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeTypeIndex(this.attribute1jComboBox.getSelectedIndex()).equals("nominal")) { // Nominal in x axis --> vertical DefaultCategoryDataset dataset = new DefaultCategoryDataset(); boolean legend = false; for (int i = 0; i < ((VisualizePanel) (this.getParent()).getParent()).getData().getNData(); i++) { String column = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute1jComboBox.getSelectedIndex()); String row = ""; if (((VisualizePanel) (this.getParent()).getParent()).getOutAttribute() != -1 && this.attribute1jComboBox .getSelectedIndex() != ((VisualizePanel) (this.getParent()).getParent()) .getOutAttribute()) { row = "Class " + ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, ((VisualizePanel) (this.getParent()).getParent()).getOutAttribute()); legend = true;/* w ww . j av a 2 s.c om*/ } String valor = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute2jComboBox.getSelectedIndex()); if (valor != null && column != null) { if (dataset.getColumnIndex(column) == -1 || dataset.getRowIndex(row) == -1) { dataset.addValue(Double.valueOf(valor).doubleValue(), row, column); } else { dataset.incrementValue(Double.valueOf(valor).doubleValue(), row, column); } } } this.chart2 = ChartFactory.createBarChart3D("", ((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeIndex(this.attribute1jComboBox.getSelectedIndex()), ((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeIndex(this.attribute2jComboBox.getSelectedIndex()), dataset, PlotOrientation.VERTICAL, legend, false, false); this.chart2.setTitle(this.attribute1jComboBox.getSelectedItem().toString() + " vs " + this.attribute2jComboBox.getSelectedItem().toString()); this.chart2.setBackgroundPaint(new Color(0xFFFFFF)); BufferedImage image = this.chart2.createBufferedImage(600, 450); this.imagejLabel.setIcon(new ImageIcon(image)); this.topdfjButton.setEnabled(true); this.topngjButton.setEnabled(true); } else if (((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeTypeIndex(this.attribute2jComboBox.getSelectedIndex()).equals("nominal")) { // Nominal in y axis --> horizontal DefaultCategoryDataset dataset = new DefaultCategoryDataset(); boolean legend = false; try { for (int i = 0; i < ((VisualizePanel) (this.getParent()).getParent()).getData().getNData(); i++) { String column = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute2jComboBox.getSelectedIndex()); String row = ""; if (((VisualizePanel) (this.getParent()).getParent()).getOutAttribute() != -1 && this.attribute2jComboBox .getSelectedIndex() != ((VisualizePanel) (this.getParent()).getParent()) .getOutAttribute()) { row = "Class " + ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, ((VisualizePanel) (this.getParent()).getParent()).getOutAttribute()); legend = true; } String valor = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute1jComboBox.getSelectedIndex()); if (valor != null) { if (dataset.getColumnIndex(column) == -1 || dataset.getRowIndex(row) == -1) { dataset.addValue(Double.valueOf(valor).doubleValue(), row, column); } else { dataset.incrementValue(Double.valueOf(valor).doubleValue(), row, column); } } } } catch (ArrayIndexOutOfBoundsException exp) { JOptionPane.showMessageDialog(this, "The data set contains some errors. This attribute can not be visualized", "Error", 2); } this.chart2 = ChartFactory.createBarChart3D("", ((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeIndex(this.attribute2jComboBox.getSelectedIndex()), ((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeIndex(this.attribute1jComboBox.getSelectedIndex()), dataset, PlotOrientation.HORIZONTAL, legend, false, false); this.chart2.setTitle(this.attribute1jComboBox.getSelectedItem().toString() + " vs " + this.attribute2jComboBox.getSelectedItem().toString()); this.chart2.setBackgroundPaint(new Color(0xFFFFFF)); BufferedImage image = this.chart2.createBufferedImage(579, 330); this.imagejLabel.setIcon(new ImageIcon(image)); this.topdfjButton.setEnabled(true); this.topngjButton.setEnabled(true); } else { XYSeriesCollection juegoDatos = new XYSeriesCollection(); boolean legend = false; if (((VisualizePanel) (this.getParent()).getParent()).getOutAttribute() != -1) { legend = true; Vector outputRang = ((VisualizePanel) (this.getParent()).getParent()).getData() .getRange(((VisualizePanel) (this.getParent()).getParent()).getOutAttribute()); XYSeries series[] = new XYSeries[outputRang.size()]; for (int i = 0; i < outputRang.size(); i++) { series[i] = new XYSeries("Class " + outputRang.elementAt(i)); juegoDatos.addSeries(series[i]); } for (int i = 0; i < ((VisualizePanel) (this.getParent()).getParent()).getData().getNData(); i++) { int clase = outputRang.indexOf(((VisualizePanel) (this.getParent()).getParent()).getData() .getDataIndex(i, ((VisualizePanel) (this.getParent()).getParent()).getOutAttribute())); String valor1 = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute1jComboBox.getSelectedIndex()); String valor2 = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute2jComboBox.getSelectedIndex()); if (valor1 != null) { series[clase].add(Double.valueOf(valor1).doubleValue(), Double.valueOf(valor2).doubleValue()); } } } else { XYSeries series = new XYSeries("Regresin"); juegoDatos.addSeries(series); for (int i = 0; i < ((VisualizePanel) (this.getParent()).getParent()).getData().getNData(); i++) { String valor1 = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute1jComboBox.getSelectedIndex()); String valor2 = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute2jComboBox.getSelectedIndex()); if (valor1 != null) { series.add(Double.valueOf(valor1).doubleValue(), Double.valueOf(valor2).doubleValue()); } } } // Numeric values this.chart2 = ChartFactory.createScatterPlot("", ((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeIndex(this.attribute1jComboBox.getSelectedIndex()), ((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeIndex(this.attribute2jComboBox.getSelectedIndex()), juegoDatos, PlotOrientation.VERTICAL, legend, false, false); this.chart2.setTitle(this.attribute1jComboBox.getSelectedItem().toString() + " vs " + this.attribute2jComboBox.getSelectedItem().toString()); this.chart2.setBackgroundPaint(new Color(0xFFFFFF)); BufferedImage image = this.chart2.createBufferedImage(579, 330); this.imagejLabel.setIcon(new ImageIcon(image)); this.topdfjButton.setEnabled(true); this.topngjButton.setEnabled(true); } }
From source file:keel.GraphInterKeel.datacf.visualizeData.VisualizePanelAttribute.java
private void infoAttribute() { this.enabledTable(true); // Extended info about selected attribute if (((VisualizePanel) this.getParent().getParent()).getData() .getAttributeTypeIndex(this.tableInfojTable.getSelectedRow()).equals("nominal")) { this.valuesjScrollPane.setEnabled(true); this.valuesjScrollPane.setVisible(true); this.valuesjTextPane.setEnabled(true); this.valuesjTextPane.setVisible(true); Vector r = ((VisualizePanel) this.getParent().getParent()).getData() .getRangesVar(((VisualizePanel) this.getParent().getParent()).getData() .getAttributeIndex(this.tableInfojTable.getSelectedRow())); this.valuesjTextPane.setText(""); this.valueAveragejLabel.setText(""); this.valueVariancejLabel.setText(""); this.valueRankjLabelIzdo.setText(" "); this.valueRankjLabelDcho.setText(" "); String cadena = new String(); for (int i = 0; i < r.size(); i++) { if (i == 0) { cadena = r.elementAt(i).toString() + ""; this.valuesjTextPane.setText(cadena); } else { cadena = this.valuesjTextPane.getText() + "\n" + r.elementAt(i).toString(); }// w w w . j a v a 2 s . c o m this.valuesjTextPane.setText(cadena); } boolean legend = false; // Draw bar chart DefaultCategoryDataset dataset = new DefaultCategoryDataset(); try { for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) { String column = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i, this.tableInfojTable.getSelectedRow()); String row = ""; if (((VisualizePanel) this.getParent().getParent()).getOutAttribute() != -1 && this.tableInfojTable .getSelectedRow() != ((VisualizePanel) this.getParent().getParent()) .getOutAttribute()) { row = "Class " + ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i, ((VisualizePanel) this.getParent().getParent()).getOutAttribute()); legend = true; } if (column != null) { if (dataset.getRowIndex(row) == -1 || ((dataset.getColumnIndex(column) == -1))) { dataset.addValue(1.0, row, column); } else { dataset.incrementValue(1.0, row, column); } } } } catch (ArrayIndexOutOfBoundsException exp) { JOptionPane.showMessageDialog(this, "The data set contains some errors. This attribute can not be visualized", "Error", 2); } this.chart = ChartFactory.createBarChart3D("", "", "", dataset, PlotOrientation.VERTICAL, legend, false, false); this.chart.setBackgroundPaint(new Color(0xFFFFFF)); //BufferedImage image = this.chart.createBufferedImage(210, 140); BufferedImage image = this.chart.createBufferedImage(400, 240); this.imagejLabel.setIcon(new ImageIcon(image)); this.clickToExpandjLabel.setVisible(true); } else { this.valuesjScrollPane.setEnabled(false); this.valuesjScrollPane.setVisible(false); this.valuesjTextPane.setEnabled(false); this.valuesjTextPane.setVisible(false); Vector r = ((VisualizePanel) this.getParent().getParent()).getData() .getRangesVar(((VisualizePanel) this.getParent().getParent()).getData() .getAttributeIndex(this.tableInfojTable.getSelectedRow())); this.valueRankjLabelIzdo.setText(r.elementAt(0).toString()); this.valueRankjLabelDcho.setText(r.elementAt(1).toString()); // Average double m = 0.0; for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) { String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i, this.tableInfojTable.getSelectedRow()); if (valor != null) { m += Double.valueOf(valor).doubleValue(); } } m = m / ((VisualizePanel) this.getParent().getParent()).getData().getNData(); DecimalFormat df = new DecimalFormat(); df.setMaximumFractionDigits(3); this.valueAveragejLabel.setText(df.format(m)); // Variance double v = 0.0; for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) { String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i, this.tableInfojTable.getSelectedRow()); if (valor != null) { v += Math.pow(Double.valueOf(valor).doubleValue() - m, 2); } } v = v / (((VisualizePanel) this.getParent().getParent()).getData().getNData() - 1); this.valueVariancejLabel.setText(df.format(v)); // Draw scatter plot XYSeriesCollection juegoDatos = new XYSeriesCollection(); boolean legend = false; if (((VisualizePanel) this.getParent().getParent()).getOutAttribute() != -1) { Vector outputRang = ((VisualizePanel) this.getParent().getParent()).getData() .getRange(((VisualizePanel) this.getParent().getParent()).getOutAttribute()); XYSeries series[] = new XYSeries[outputRang.size()]; for (int i = 0; i < outputRang.size(); i++) { series[i] = new XYSeries("Class " + outputRang.elementAt(i)); juegoDatos.addSeries(series[i]); } for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) { int clase = outputRang.indexOf(((VisualizePanel) this.getParent().getParent()).getData() .getDataIndex(i, ((VisualizePanel) this.getParent().getParent()).getOutAttribute())); String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i, this.tableInfojTable.getSelectedRow()); if (valor != null) { series[clase].add(Double.parseDouble(Integer.toString(i)), Double.valueOf(valor).doubleValue()); } } legend = true; } else { XYSeries series = new XYSeries("Regresin"); juegoDatos.addSeries(series); for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) { String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i, this.tableInfojTable.getSelectedRow()); if (valor != null) { series.add(Double.parseDouble(Integer.toString(i)), Double.valueOf(valor).doubleValue()); } } } chart = ChartFactory.createScatterPlot("", "", "", juegoDatos, PlotOrientation.VERTICAL, legend, false, false); chart.setBackgroundPaint(new Color(0xFFFFFF)); //BufferedImage image = chart.createBufferedImage(210, 140); BufferedImage image = chart.createBufferedImage(400, 240); this.imagejLabel.setIcon(new ImageIcon(image)); this.clickToExpandjLabel.setVisible(true); } }
From source file:es.pode.administracion.presentacion.adminusuarios.altaUsuario.AltaUsuarioControllerImpl.java
private boolean validarRolesDocenteYCatalogador(GrupoVO[] grupos) { boolean resultado = false; Vector roles = new Vector(); RolVO[] rolParcial = null;// w ww . j av a2 s .com int h = 0; for (int i = 0; i < grupos.length; i++) { rolParcial = grupos[i].getRols(); for (int j = 0; j < rolParcial.length; j++) { roles.add(rolParcial[j].getDescripcion()); } } String rol_catalogador = AgregaPropertiesImpl.getInstance().getProperty(AgregaProperties.ROL_CATALOGADOR); String rol_empaquetador = AgregaPropertiesImpl.getInstance().getProperty(AgregaProperties.ROL_EMPAQUETADOR); String rol_publicador = AgregaPropertiesImpl.getInstance().getProperty(AgregaProperties.ROL_PUBLICADOR); if (log.isDebugEnabled()) log.debug("recogemos los roles -> " + rol_catalogador + rol_empaquetador); if (roles.indexOf(rol_catalogador) >= 0 || roles.indexOf(rol_empaquetador) >= 0 || roles.indexOf(rol_publicador) >= 0) resultado = true; return resultado; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.UploadTableTree.java
@Override public Vector<InvalidStructure> verifyUploadability() throws UploaderException, ClassNotFoundException { Vector<InvalidStructure> result = super.verifyUploadability(); if (getTreeDefItem() == null) { String msg = getResourceString("WB_UPLOAD_NO_DEFITEM") + " (" + wbLevelName + ")"; result.add(new InvalidStructure(msg, this)); }/*from w ww. j a v a 2 s . c om*/ //check for duplicate mappings. This happens if user manages to include both Division and Phylum levels //in the workbench, because they have identical numeric ranks. if (getTreeDefItem() != null) { for (Vector<UploadField> flds : uploadFields) { Vector<Field> fields = new Vector<Field>(); Vector<UploadField> uploadFields = new Vector<UploadField>(); for (UploadField fld : flds) { if (fld.getIndex() != -1) { int idx = fields.indexOf(fld.getField()); if (idx != -1) { String msg = String.format(getResourceString("WB_UPLOAD_EQUIV_RANKS"), fld.getWbFldName(), uploadFields.get(idx).getWbFldName(), getTreeDefItem().getName()); result.add(new InvalidStructure(msg, this)); } else { fields.add(fld.getField()); uploadFields.add(fld); } } } } } if (parent == null) { Vector<TreeDefItemIface<?, ?, ?>> missingDefs = getMissingRequiredDefs(); for (TreeDefItemIface<?, ?, ?> defItem : missingDefs) { String msg = getResourceString("WB_UPLOAD_MISSING_TREE_LEVEL") + " (" + defItem.getName() + ")"; result.add(new InvalidStructure(msg, this)); } } return result; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.ConfigureXLS.java
@Override protected void nonInteractiveConfig() { try {/*from w w w . ja v a 2 s . c o m*/ InputStream input = new FileInputStream(externalFile); POIFSFileSystem fs = new POIFSFileSystem(input); HSSFWorkbook workBook = new HSSFWorkbook(fs); HSSFSheet sheet = workBook.getSheetAt(0); // Calculate the number of rows and columns colInfo = new Vector<ImportColumnInfo>(16); Hashtable<Integer, Boolean> colTracker = new Hashtable<Integer, Boolean>(); boolean firstRow = true; int col = 0; colTracker.clear(); Vector<Integer> badHeads = new Vector<Integer>(); Vector<Integer> emptyCols = new Vector<Integer>(); checkHeadsAndCols(sheet, badHeads, emptyCols); if (firstRowHasHeaders && badHeads.size() > 0) { status = ConfigureExternalDataIFace.Status.Error; showBadHeadingsMsg(badHeads, null, getResourceString("Error")); return; } // Iterate over each row in the sheet @SuppressWarnings("unchecked") Iterator<HSSFRow> rows = sheet.rowIterator(); while (rows.hasNext()) { HSSFRow row = rows.next(); if (firstRow || numRows == 1) { // Iterate over each cell in the row and print out the cell's content int colNum = 0; int maxSize = Math.max(row.getPhysicalNumberOfCells(), row.getLastCellNum()); while (colNum < maxSize) { if (emptyCols.indexOf(new Integer(colNum)) == -1) { ImportColumnInfo.ColumnType disciplinee = ImportColumnInfo.ColumnType.Integer; String value = null; boolean skip = false; HSSFCell cell = row.getCell(colNum); if (cell == null) { //assuming numRows == 1 or not firstRowHasHeaders. //the call to checkHeadsAndCols would have already blank headers. value = ""; disciplinee = ImportColumnInfo.ColumnType.String; } else switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_NUMERIC: double numeric = cell.getNumericCellValue(); value = Double.toString(numeric); disciplinee = ImportColumnInfo.ColumnType.Double; break; case HSSFCell.CELL_TYPE_STRING: HSSFRichTextString richVal = cell.getRichStringCellValue(); value = richVal.getString().trim(); disciplinee = ImportColumnInfo.ColumnType.String; break; case HSSFCell.CELL_TYPE_BLANK: value = ""; disciplinee = ImportColumnInfo.ColumnType.String; break; case HSSFCell.CELL_TYPE_BOOLEAN: boolean bool = cell.getBooleanCellValue(); value = Boolean.toString(bool); disciplinee = ImportColumnInfo.ColumnType.Boolean; break; default: skip = true; break; } if (numRows == 1 && !skip) { colInfo.get(col).setData(value); col++; } else if (!skip) { if (firstRowHasHeaders) { colInfo.add(new ImportColumnInfo(colNum, disciplinee, value, value, null, null, null)); colTracker.put(col, true); } else { String colName = getResourceString("DEFAULT_COLUMN_NAME") + " " + (colNum + 1); colInfo.add(new ImportColumnInfo(colNum, disciplinee, colName, colName, null, null, null)); colTracker.put(colNum, true); } numCols++; } } colNum++; } firstRow = false; } numRows++; } Collections.sort(colInfo); readMappings(fs); status = Status.Valid; } catch (IOException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ConfigureXLS.class, ex); status = Status.Error; } }
From source file:es.pode.administracion.presentacion.adminusuarios.modificarUsuario.ModificarUsuarioControllerImpl.java
/** * metodo que comprueba si el usuario tiene rol catalogador o empaquetador para poder tener grupos de trabajo o no *//*from w w w . j a va 2 s .c om*/ public final java.lang.String rolParaGrupoTrabajo(org.apache.struts.action.ActionMapping mapping, es.pode.administracion.presentacion.adminusuarios.modificarUsuario.RolParaGrupoTrabajoForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception { ModificarUsuarioBSession modificarUsuarioBSession = this.getModificarUsuarioBSession(request); UsuarioVO usuarioSesion = modificarUsuarioBSession.getUsuario(); String resultado = "FALLO"; try { //recogemos los grupos que se han asigando al usuario y vemos que roles contienen GrupoVO[] grupos = usuarioSesion.getGrupos(); Vector roles = new Vector(); RolVO[] rolParcial = null; int h = 0; for (int i = 0; i < grupos.length; i++) { rolParcial = grupos[i].getRols(); for (int j = 0; j < rolParcial.length; j++) { roles.add(rolParcial[j].getDescripcion()); } } String rol_catalogador = AgregaPropertiesImpl.getInstance() .getProperty(AgregaProperties.ROL_CATALOGADOR); String rol_empaquetador = AgregaPropertiesImpl.getInstance() .getProperty(AgregaProperties.ROL_EMPAQUETADOR); String rol_publicador = AgregaPropertiesImpl.getInstance().getProperty(AgregaProperties.ROL_PUBLICADOR); if (roles.indexOf(rol_catalogador) >= 0 || roles.indexOf(rol_empaquetador) >= 0 || roles.indexOf(rol_publicador) >= 0) resultado = "OK"; } catch (Exception e) { log.error("Error al obtener los roles del usuario ", e); throw new ValidatorException("{modificarUsuario.error}"); } finally { form.setResultado(resultado); } return resultado; }
From source file:edu.ku.brc.specify.dbsupport.cleanuptools.GeographyAssignISOs.java
private int getUnitedStatesIndex(final Object[] titles) { Vector<Object> list = new Vector<Object>(); Collections.addAll(list, titles); String[] names = { "United States", "USA", "U.S.A.", "United States of America" }; for (String nm : names) { int index = list.indexOf(nm); if (index > -1) { return index; }//from ww w. j a v a 2s . c o m } return -1; }