List of usage examples for java.util Vector contains
public boolean contains(Object o)
From source file:edu.ku.brc.ui.UIHelper.java
/** * Helper method for returning data if it is of a particular Class. * Meaning is this data implementing an interface or is it derived from some other class. * @param data the generic data//ww w . j ava 2s . co m * @param classObj the class in questions * @return the data if it is derived from or implements, can it be cast to */ public static Object getDataForClass(final Object data, Class<?> classObj) { // Short circut if all they are interested in is the generic "Object" if (classObj == Object.class) { return data; } // Check to see if it supports the aggrgation interface if (data instanceof GhostDataAggregatable) { Object newData = ((GhostDataAggregatable) data).getDataForClass(classObj); if (newData != null) { return newData; } } Vector<Class<?>> classes = new Vector<Class<?>>(); // First Check interfaces Class<?>[] theInterfaces = data.getClass().getInterfaces(); for (Class<?> co : theInterfaces) { classes.add(co); } if (classes.contains(classObj)) { return data; } classes.clear(); // Now Check super classes Class<?> superclass = data.getClass().getSuperclass(); while (superclass != null) { classes.addElement(superclass); superclass = superclass.getSuperclass(); } // Wow, it doesn't support anything return null; }
From source file:eu.planets_project.tb.gui.backing.exp.NewExpWizardController.java
/** * /*from www .j a va2s .co m*/ * @param valueChangedEvent */ public void handleObsSelectChangeListener(ValueChangeEvent valueChangedEvent) { log.info("Handling event in handleObsSelectChangeListener."); MeasurementImpl targetBean = (MeasurementImpl) this.getObsTable().getRowData(); ExperimentBean expBean = (ExperimentBean) JSFUtil.getManagedObject("ExperimentBean"); Vector<String> props = expBean.getExperiment().getExperimentExecutable().getProperties(); if (props.contains(targetBean.getIdentifier().toString())) { props.remove(targetBean.getIdentifier().toString()); log.info("Removed: " + targetBean.getIdentifier()); } else { props.add(targetBean.getIdentifier().toString()); log.info("Added: " + targetBean.getIdentifier()); } }
From source file:ro.finsiel.eunis.factsheet.species.SpeciesFactsheet.java
/** * Returns the legal status information for this species. * * @return An vector of LegalStatusWrapper objects one for each legal status. *///ww w.ja v a 2 s .c om public Vector getLegalStatus() { Vector<LegalStatusWrapper> results = new Vector<LegalStatusWrapper>(); try { // List list = new Chm62edtReportsDomain().findWhere("LOOKUP_TYPE='legal_status' AND ID_NATURE_OBJECT='" + // getSpeciesNatureObject().getIdNatureObject() + "'"); // here we are findind also the synonyms.... Integer IdNatureObjectSpecie = getSpeciesNatureObject().getIdNatureObject(); Integer IdSpecie = getSpeciesNatureObject().getIdSpecies(); List<Chm62edtReportsPersist> list = new Chm62edtReportsDomain().findWhere( "LOOKUP_TYPE='LEGAL_STATUS' AND ID_NATURE_OBJECT IN (" + IdNatureObjectSpecie.toString() + ")"); for (Chm62edtReportsPersist report : list) { LegalStatusWrapper legalStatus = new LegalStatusWrapper(); populateLegalStatusWrapper(legalStatus, report); if (!results.contains(legalStatus)) { results.add(legalStatus); } } } catch (Exception _ex) { _ex.printStackTrace(System.err); } return results; }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SelectSTSMFListener.java
public boolean checkFormat(File file) { try {// ww w. ja v a 2 s. co m BufferedReader br = new BufferedReader(new FileReader(file)); String line = br.readLine(); Vector<String> samples = FileHandler.getSamplesId(((GeneExpressionData) this.dataType).getRawFile()); Vector<String> samplesSTSMF = new Vector<String>(); String category = ""; while ((line = br.readLine()) != null) { if (line.compareTo("") != 0) { String[] fields = line.split("\t", -1); //check columns number if (fields.length != 9) { this.selectSTSMFUI.displayMessage("Error:\nLines have not the right number of columns"); br.close(); return false; } //check that study id is set if (fields[0].compareTo("") == 0) { this.selectSTSMFUI.displayMessage("Error:\nStudy identifiers have to be set"); br.close(); return false; } //check that subject id is set if (fields[3].compareTo("") == 0) { this.selectSTSMFUI.displayMessage("Error:\nSubjects identifiers have to be set"); br.close(); return false; } //check that samples id is set if (fields[4].compareTo("") == 0) { this.selectSTSMFUI.displayMessage("Error:\nSamples identifiers have to be set"); br.close(); return false; } //check that platform is set if (fields[5].compareTo("") == 0) { this.selectSTSMFUI.displayMessage("Error:\nPlatform has to be set"); br.close(); return false; } //check that tissue type is set if (fields[5].compareTo("") == 0) { this.selectSTSMFUI.displayMessage("Error:\nTissue type has to be set"); br.close(); return false; } //check that category codes are set if (fields[8].compareTo("") == 0) { this.selectSTSMFUI.displayMessage("Error:\nCategory codes have to be set"); br.close(); return false; } if (category.compareTo("") == 0) { category = fields[8]; } else { if (fields[8].compareTo(category) != 0) { this.selectSTSMFUI.displayMessage("Category code has to be always the same"); br.close(); return false; } } if (!samplesSTSMF.contains(fields[3])) { if (samples.contains(fields[3])) { samplesSTSMF.add(fields[3]); } } } } if (samplesSTSMF.size() != samples.size()) { this.selectSTSMFUI .displayMessage("Error:\nSample identifiers are not the same than in raw data file"); br.close(); return false; } br.close(); } catch (Exception e) { selectSTSMFUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); return false; } return true; }
From source file:eu.planets_project.tb.gui.backing.exp.NewExpWizardController.java
/** * //from w w w .jav a 2 s . c o m * @param valueChangedEvent */ public void handleManualObsSelectChangeListener(ValueChangeEvent valueChangedEvent) { log.info("Handling event in handleManualObsSelectChangeListener."); //the measurement we're operating upon MeasurementBean targetBean = (MeasurementBean) this.getManualObsTable().getRowData(); //the experiment bean ExperimentBean expBean = (ExperimentBean) JSFUtil.getManagedObject("ExperimentBean"); String etype = expBean.getEtype(); //the experiment type backing bean ExpTypeBackingBean exptype = ExpTypeBackingBean.getExpTypeBean(etype); //the model element Vector<String> props = expBean.getExperiment().getExperimentExecutable() .getManualProperties(targetBean.getStage()); // Use the stage to narrow the list: String stageName = expBean.getSelectedStage().getName(); if (props.contains(targetBean.getIdentifier().toString())) { //remove from the model expBean.getExperiment().getExperimentExecutable().removeManualProperty(stageName, targetBean.getIdentifier().toString()); //remove from the bean exptype.getManualObservables().get(stageName); MeasurementImpl removeMeasurement = null; for (MeasurementImpl m : exptype.getManualObservables().get(stageName)) { if (m.getIdentifier().toString().equals(targetBean.getIdentifier().toString())) { removeMeasurement = m; } } if (removeMeasurement != null) { exptype.getManualObservables().get(stageName).remove(removeMeasurement); } TestbedManager testbedMan = (TestbedManager) JSFUtil.getManagedObject("TestbedManager"); testbedMan.updateExperiment(expBean.getExperiment()); log.info("Removed: " + targetBean.getIdentifier()); } else { /*props.add(targetBean.getIdentifier().toString()); log.info("Added: "+targetBean.getIdentifier());*/ } }
From source file:eu.planets_project.tb.gui.backing.ExperimentBean.java
/** * Gathers all records that are used for evaluation for a given measurement property and a selected inputDigitalObject * and groups them according to the experiment type's evaluation rules in a EvaluationPropertyResultsBean which contains the table line's information * TODO AL: split this method up into sub-methodds and share common parts with getAllManualExecutionRecordsHelper * TODO AL: Implementation for manualProps = false : automatically measured properties still missing * @param//from ww w .jav a 2 s.c o m * @return */ @SuppressWarnings("unchecked") private List<EvaluationPropertyResultsBean> getEvaluationPropertyResultsBeansHelper(String inputDigoRef, String[] comparedStageNames, boolean manualProps) { List<EvaluationPropertyResultsBean> ret = new ArrayList<EvaluationPropertyResultsBean>(); //1. get all measurement property IDs Vector<String>[] lpropertyIDs = new Vector[comparedStageNames.length]; if (manualProps) { //fetch the manual properties int count = 0; for (String stageName : comparedStageNames) { lpropertyIDs[count] = this.getExperiment().getExperimentExecutable().getManualProperties(stageName); count++; } } else { //fetch the automatically measured properties //FIXME: not correct: still need to find out stage information for automatically measured properties //propertyIDs = expBean.getExperiment().getExperimentExecutable().getProperties(); int count = 0; for (String stageName : comparedStageNames) { lpropertyIDs[count] = helperBuildAutoPropertyPerStage().get(stageName); count++; } } //1b) determine a common set of property IDs that are available in all requested stages List<String> commonPropIDs = new ArrayList<String>(); for (int i = 0; i < lpropertyIDs.length; i++) { Vector<String> propertyIDs = lpropertyIDs[i]; if (i == 0) { if (propertyIDs != null) { commonPropIDs = propertyIDs; } } else { List<String> propsForRemoval = new ArrayList<String>(); for (String propID : commonPropIDs) { if (propertyIDs != null && !propertyIDs.contains(propID)) { //property not contained in all requested stages - remove propsForRemoval.add(propID); } } commonPropIDs.removeAll(propsForRemoval); } } //2. build the results on a per property basis if (commonPropIDs != null) { for (String propertyID : commonPropIDs) { EvaluationPropertyResultsBean evalPropResBean = new EvaluationPropertyResultsBean(inputDigoRef, propertyID, this.getAllRunDates(), comparedStageNames); List<String> lStageNames = Arrays.asList(comparedStageNames); //2a. now iterate over the results and filter out the relevant ones for this property for (BatchExecutionRecordImpl batchr : this.getExperiment().getExperimentExecutable() .getBatchExecutionRecords()) { Calendar runDate = batchr.getEndDate(); for (ExecutionRecordImpl execRec : batchr.getRuns()) { //filter out by the selected inputDigitalObject if (execRec.getDigitalObjectReferenceCopy().equals(inputDigoRef)) { for (ExecutionStageRecordImpl execStageRec : execRec.getStages()) { //filter out the selected stage if (lStageNames.contains(execStageRec.getStage())) { /* * FIXME: change this code - as a MeasurementImpl m * from execStageRec.getMeasuredObservables() * already has the value contained - accessible through m.getValue */ List<MeasurementImpl> mRecords = null; if (manualProps) { //fetch the manual properties mRecords = execStageRec.getManualMeasurements(); } else { //fetch the automatically measured properties mRecords = execStageRec.getMeasurements(); } for (MeasurementImpl mr : mRecords) { if (mr.getIdentifier().equals(propertyID)) { //found the measurementRecord for this property in this run evalPropResBean.addMeasurementResult(runDate, execStageRec.getStage(), mr); } } } } } } } //2b. now iterate over the evaluation results and filter out the relevant ones List<PropertyEvaluationRecordImpl> propEvalRecordords = this.getExperiment() .getExperimentEvaluation().getPropertyEvaluation(inputDigoRef); if (propEvalRecordords != null) { for (PropertyEvaluationRecordImpl propEvalRecordImpl : propEvalRecordords) { //filter by the propertyID we're looking for if (propEvalRecordImpl.getPropertyID().equals(evalPropResBean.getMeasurementPropertyID())) { //set the line evaluation value evalPropResBean.setPropertyEvalValue(propEvalRecordImpl.getPropertyEvalValue()); for (Calendar runDate : this.getAllRunDates()) { PropertyRunEvaluationRecordImpl propRunEvalRecImpl = propEvalRecordImpl .getPropertyRunEvalRecord(runDate); if (propRunEvalRecImpl != null) { //set the per run evaluation value evalPropResBean.setEvalResultValue(runDate, comparedStageNames, propRunEvalRecImpl.getRunEvalValue()); } } } } } //3.finally add the MeasurementInfo data (name, description, for the propertyID etc. if (manualProps) { OntologyProperty ontop = OntologyHandlerImpl.getInstance().getProperty(propertyID); //create a MeasurementImpl from the OntologyProperty try { MeasurementImpl measurementinfo = OntoPropertyUtil .createMeasurementFromOntologyProperty(ontop); evalPropResBean.setMeasurementInfo(measurementinfo); } catch (Exception e) { log.debug("Could not retrieve Ontology Property information for propertyID: " + propertyID); } } else { //TODO: still need to request this information from the workflow authority MeasurementImpl measurementinfo = helperQueryAutoMeasurementAuthority(propertyID); evalPropResBean.setMeasurementInfo(measurementinfo); } //Finally: check requirements if to add this evalProp item //if(checkIfToAddEvaluationPropertyBean(evalPropResBean,comparedStageNames)){ ret.add(evalPropResBean); //} } } return ret; }
From source file:eu.planets_project.tb.gui.backing.exp.NewExpWizardController.java
/** * Returns a list of MeasurementBeans for a given experimentType and experiment instance and experiment stage * @param etype//from www. jav a 2 s . c om * @param exp * @param stage * @param manualObs flag if manual or automatically measurable properties are retrieved * @return */ private List<MeasurementBean> getObservablesForEtype(String etype, Experiment exp, String stage, boolean manualObs) { List<MeasurementBean> ret = new ArrayList<MeasurementBean>(); ExpTypeBackingBean exptype = ExpTypeBackingBean.getExpTypeBean(etype); if (exptype != null) { if (manualObs) { ret = this.createMeasurementBeans(exptype.getManualObservables(), stage); } else { ret = this.createMeasurementBeans(exptype.getObservables(), stage); } } else { // For unrecognised experiment types return empty list: return ret; } // Determine 'selected' state for this observable: Vector<String> props = null; if (manualObs) { props = exp.getExperimentExecutable().getManualProperties(stage); } else { props = exp.getExperimentExecutable().getProperties(); } for (MeasurementBean m : ret) { if (props != null && m.getIdentifier() != null && props.contains(m.getIdentifier().toString())) { m.setSelected(true); } else { // FIXME This should remember properly, and set to false if necessary. //m.setSelected(false); m.setSelected(true); } } return ret; }
From source file:csiro.pidsvc.mappingstore.Manager.java
public boolean checkNonCyclicInheritance(int mappingId) throws SQLException { Vector<Integer> ret = new Vector<Integer>(1); PreparedStatement pst = null; ResultSet rs = null;//from w ww . j ava 2 s . c o m int parentId; String parentPath = null; try { pst = _connection.prepareStatement( "SELECT parent FROM vw_active_mapping WHERE mapping_id = ? AND mapping_path IS NOT NULL"); pst.setInt(1, mappingId); // Get initial mapping. if (pst.execute()) { rs = pst.getResultSet(); if (rs.next()) { parentPath = rs.getString(1); ret.add(mappingId); } } rs.close(); pst.close(); rs = null; pst = null; // Get parents. while (parentPath != null) { pst = _connection.prepareStatement( "SELECT mapping_id, parent FROM vw_active_mapping WHERE mapping_path = ? AND type = 'Regex'"); pst.setString(1, parentPath); parentPath = null; if (pst.execute()) { rs = pst.getResultSet(); if (rs.next()) { parentId = rs.getInt(1); parentPath = rs.getString(2); // Cyclic inheritance encountered. if (ret.contains(parentId)) return false; // Add new parent to the list. ret.add(parentId); } } } } finally { if (rs != null) rs.close(); if (pst != null) pst.close(); } return true; }
From source file:com.yaniv.online.MainActivity.java
@Override public void onRealTimeMessageReceived(RealTimeMessage rtm) { byte[] buf = rtm.getMessageData(); String sender = rtm.getSenderParticipantId(); Log.d(TAG, "[onRealTimeMessageReceived] - Got message from Participant " + sender + ",msg: " + Arrays.toString(buf)); // Another player finished his turn if (buf[0] == 20) { turn = buf[1];/* www . ja va 2 s .co m*/ Card newCard; TextView lastPlayerPick = (TextView) (findViewById(R.id.lastPlayerPick)); if (buf[2] == 5) { // if the last player took from the deck, remove the first card lastPlayerPick.setText("Last player picked from the deck"); newCard = cardDeck.jp.remove(0); } else { lastPlayerPick.setText("Last player picked: " + primaryDeck.peek().get(buf[2]).toString()); ArrayList<Card> lastDrop = primaryDeck.peek(); newCard = lastDrop.get(buf[2]); } lastDropType = buf[3]; ArrayList<Card> droppedCards = fromGson(buf, 5, buf.length, DATA_TYPE_CARDS); Log.d(TAG, "Player dropped cards: " + droppedCards.toString()); primaryDeck.push(droppedCards); Log.d(TAG, "Player cards before: " + mParticipantCards.get(sender)); Vector<Card> playerCards = mParticipantCards.get(sender); for (Card c : droppedCards) { Log.d(TAG, "Deleting card: " + c.toString()); boolean contains = playerCards.contains(c); boolean b = playerCards.remove(c); Log.d(TAG, "Delete worked: " + b + " card exist? " + contains); } playerCards.add(newCard); Log.d(TAG, "Player cards changed: " + playerCards); mParticipantCards.put(sender, playerCards); Log.d(TAG, "Player cards after: " + mParticipantCards.get(sender)); updateParticipantUI(sender); updatePrimaryDeckUI(); } //Game is started, owner send the cardsDeck, any participant needs to reload the cards into cardDeck or shuffle cards. else if ((int) buf[0] == 0) { // Checking shuffle if ((int) buf[1] == 1) { displayToastForLimitTime("Shuffling Card Deck...", 3000); } cardDeck = fromGson(buf, 5, buf.length, DATA_TYPE_CARD_DECK); Log.d(TAG, "[onRealTimeMessageReceived] - cardDeck " + cardDeck.jp); if (cardDeck != null) { } } // Owner create the cards for all participant. needs to save it on Mycards. else if ((int) buf[0] == 1) { // starting highscores array if null if (highscores == null) { highscores = new int[mParticipants.size()]; } mParticipantCards = fromGson(buf, 5, buf.length, DATA_TYPE_M_PARTICIPANT_CARDS); myCards = mParticipantCards.containsKey(mMyId) ? mParticipantCards.get(mMyId) : null; calculateSum(); setPlayerPositonUI(); Log.d(TAG, "[onRealTimeMessageReceived] -mycards after" + myCards); updateTurnUi(); updateParticipantsNamesAndUI(); } // When participant played a turn else if ((int) buf[0] == 2) { mParticipantCards.put(sender, (Vector<Card>) fromGson(buf, 5, buf.length, DATA_TYPE_MY_CARDS)); Log.d(TAG, "[onRealTimeMessageReceived] -participant " + sender + " finished his turn, his new cards: " + mParticipantCards.get(sender)); updateParticipantUI(sender); } // take from 0-primary 1-deck take from the primary or deck (and update in each screen) // Cards he take (only if 0) else if ((int) buf[0] == 5) { primaryDeck = fromGson(buf, 5, buf.length, DATA_TYPE_PRIMARY_DECK); Log.d(TAG, "[onRealTimeMessageReceived] - primaryDeck " + primaryDeck); if (primaryDeck != null) { updatePrimaryDeckUI(); } } //when player declare yaniv else if ((int) buf[0] == 7) { yanivCalled(buf); } else if ((int) buf[0] == 8) { readyToPlayPlayers.put(sender, true); checkReadyList(); } else if ((int) buf[0] == 10) { } // Regular messages to change the turn. else { turn = buf[3]; updateTurnUi(); Log.d(TAG, "[onRealTimeMessageReceived] - regular message "); if (buf[1] == 'F' || buf[1] == 'U') { turn = buf[3]; lastDropType = (int) buf[4]; } } }
From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java
/** * Creates all the UI form the Form. /*from ww w. j a v a 2s . com*/ */ protected void buildUI() { headers.addAll(workbench.getWorkbenchTemplate().getWorkbenchTemplateMappingItems()); Collections.sort(headers); MouseAdapter clickable = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { selectControl(e.getSource()); } @Override public void mouseClicked(MouseEvent e) { selectedInputPanel = getInputPanel(e.getSource()); controlPropsBtn.setEnabled(true); if (controlPropsDlg != null) { controlPropsDlg.setControl(selectedInputPanel); } if (e.getClickCount() == 2 && (controlPropsDlg == null || !controlPropsDlg.isVisible())) { UsageTracker.incrUsageCount("WB.FormPropsTool"); showControlProps(); } } }; Point topLeftPnt = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE); final int LAYOUT_SPACING = 4; short maxY = 0; Vector<InputPanel> delayedLayout = new Vector<InputPanel>(); int maxWidthOffset = 0; for (WorkbenchTemplateMappingItem wbtmi : headers) { // Create the InputPanel and make it draggable InputPanel panel = new InputPanel(wbtmi, wbtmi.getCaption(), createUIComp(wbtmi), this, clickable); Dimension size = panel.getPreferredSize(); panel.setSize(size); panel.setPreferredSize(size); // Finds the largest label maxWidthOffset = Math.max(panel.getTextFieldOffset(), maxWidthOffset); int x = wbtmi.getXCoord(); int y = wbtmi.getYCoord(); if (y < topLeftPnt.y || (y == topLeftPnt.y && x < topLeftPnt.x)) { firstComp = panel.getComp(); topLeftPnt.setLocation(x, y); } // Add it to the Form (drag canvas) uiComps.add(panel); add(panel); // NOTE: that the constructor sets the x,y storage from WorkbenchTemplateMappingItem object // so the ones with XCoord and YCoord set do not need to be positioned if (wbtmi.getXCoord() == null || wbtmi.getYCoord() == null || wbtmi.getXCoord() == -1 || wbtmi.getYCoord() == -1) { delayedLayout.add(panel); // remember this for later once we know the Max Y } else { maxY = (short) Math.max(wbtmi.getYCoord() + size.height, maxY); } } // Now align the control by their text fields and skips the ones that have actual positions defined. // NOTE: We set the X,Y into the Mapping so that each item knows where it is, then if the user // drags and drop anything or save the template everyone knows where they are suppose to be // int inx = 0; int maxX = 0; int y = maxY + LAYOUT_SPACING; for (InputPanel panel : uiComps) { WorkbenchTemplateMappingItem wbtmi = headers.get(inx); if (delayedLayout.contains(panel)) { int x = maxWidthOffset - panel.getTextFieldOffset(); panel.setLocation(x, y); wbtmi.setXCoord((short) x); wbtmi.setYCoord((short) y); Dimension size = panel.getPreferredSize(); y += size.height + LAYOUT_SPACING; } Rectangle r = panel.getBounds(); maxX = Math.max(maxX, r.x + r.width); inx++; } initialSize = new Dimension(maxX, y); controlPropsBtn = createIconBtn("ControlEdit", IconManager.IconSize.NonStd, "WB_EDIT_CONTROL", false, new ActionListener() { public void actionPerformed(ActionEvent ae) { UsageTracker.getUsageCount("WBFormPropsTool"); showControlProps(); } }); addArrowTraversalKeys(); }