List of usage examples for java.util Hashtable values
Collection values
To view the source code for java.util Hashtable values.
Click Source Link
From source file:gov.nih.nci.cabig.caaers.service.synchronizer.TreatmentAssignmentSynchronizer.java
public void migrate(Study dbStudy, Study xmlStudy, DomainObjectImportOutcome<Study> outcome) { //create an Index of existing ones (available in DB) Hashtable<String, TreatmentAssignment> dbTacIndexMap = new Hashtable<String, TreatmentAssignment>(); Hashtable<String, TreatmentAssignment> dbCtepIndexMap = new Hashtable<String, TreatmentAssignment>(); for (TreatmentAssignment ta : dbStudy.getActiveTreatmentAssignments()) { String ctepDbId = StringUtils.upperCase(ta.getCtepDbIdentifier()); String tac = StringUtils.upperCase(ta.getCode()); dbTacIndexMap.put(tac, ta);/*from w w w. j a va2s. c o m*/ if (StringUtils.isNotEmpty(ctepDbId)) dbCtepIndexMap.put(ctepDbId, ta); } //Identify New TreatmentAssignments and also update existing ones. for (TreatmentAssignment xmlTreatmentAssignment : xmlStudy.getTreatmentAssignments()) { // //CAAERS-7367 - /REFACTORED - always prefer the tac that is available. String ctepDbId = StringUtils.upperCase(xmlTreatmentAssignment.getCtepDbIdentifier()); String tac = StringUtils.upperCase(xmlTreatmentAssignment.getCode()); if (StringUtils.isEmpty(tac) && StringUtils.isEmpty(ctepDbId)) continue; //no I cannot process this record TreatmentAssignment ta = null; //try to identify the TA by ctep-id if (StringUtils.isNotEmpty(ctepDbId)) { ta = dbCtepIndexMap.get(ctepDbId); } //TA not found : try to find by tac if (ta == null) ta = dbTacIndexMap.get(tac); //still tac null -- create a new one. if (ta == null) { ta = xmlTreatmentAssignment; dbStudy.addTreatmentAssignment(xmlTreatmentAssignment); continue; } //it is an existing TA, so lets sync up the attributes ta.setCtepDbIdentifier(xmlTreatmentAssignment.getCtepDbIdentifier()); ta.setCode(xmlTreatmentAssignment.getCode()); ta.setDescription(xmlTreatmentAssignment.getDescription()); ta.setComments(xmlTreatmentAssignment.getComments()); ta.setDoseLevelOrder(xmlTreatmentAssignment.getDoseLevelOrder()); //marking the TA as processed by removing it from index dbTacIndexMap.remove(tac); } //soft delete - all the TAs that were not present in XML Study AbstractMutableRetireableDomainObject.retire(dbTacIndexMap.values()); }
From source file:edu.ku.brc.specify.tasks.ExpressSearchTask.java
/** * Traverses through the results and adds to the panel to be displayed. * @param resultsMap the primary result tables * @param resultsForJoinsMap the related results table *//*from w w w .jav a2 s. c o m*/ protected void displayResults(final ExpressSearchResultsPaneIFace esrPane, final QueryForIdResultsIFace queryResults, final Hashtable<String, QueryForIdResultsSQL> resultsForJoinsMap) { // For Debug Only if (false && resultsForJoinsMap != null) { for (Enumeration<QueryForIdResultsSQL> e = resultsForJoinsMap.elements(); e.hasMoreElements();) { QueryForIdResultsSQL qfirsql = e.nextElement(); if (qfirsql.getRecIds().size() > 0) { log.debug("\n\n------------------------------------"); log.debug("------------------------------------"); log.debug("Search Id " + qfirsql.getTableInfo().getId() + " Table Id " + qfirsql.getTableInfo().getTableId() + " Column Name " + qfirsql.getJoinColTableId()); log.debug("------------------------------------"); for (Integer l : qfirsql.getRecIds()) { log.debug(l + " "); } } } } if (queryResults.size() > 0) { esrPane.addSearchResults(queryResults); } if (resultsForJoinsMap != null) { for (QueryForIdResultsSQL rs : resultsForJoinsMap.values()) { if (rs.getRecIds().size() > 0) { esrPane.addSearchResults(rs); } } resultsForJoinsMap.clear(); } }
From source file:de.juwimm.cms.remote.UserServiceSpringImpl.java
/** * Returns all groups users of this unit are member of.<br> * //from w w w. jav a 2 s .co m * @return Returns all GroupValue Objects in an Array. Is empty if nobody * was found. * * @see de.juwimm.cms.remote.UserServiceSpring#getAllGroupsUsedInUnit(java.lang.Integer) */ @Override protected GroupValue[] handleGetAllGroupsUsedInUnit(Integer unitId) throws Exception { if (log.isDebugEnabled()) { log.debug("begin getAllGroupsUsedInUnit"); } Hashtable<Integer, GroupValue> groupsTable = new Hashtable<Integer, GroupValue>(); try { UnitHbm unit = super.getUnitHbmDao().load(unitId); Iterator<UserHbm> usIt = unit.getUsers().iterator(); UserHbm principal = super.getUserHbmDao().load(AuthenticationHelper.getUserName()); if (log.isDebugEnabled()) { log.debug("Principal: " + principal); } UserHbm user = null; while (usIt.hasNext()) { user = usIt.next(); Iterator<GroupHbm> grpIt = super.getUserHbmDao().getGroups4ActiveSite(user).iterator(); GroupHbm grp = null; GroupValue gv = null; while (grpIt.hasNext()) { grp = grpIt.next(); gv = grp.getGroupValue(); if (gv != null) { groupsTable.put(gv.getGroupId(), gv); } } } } catch (Exception e) { log.error("Error while getting groups for unit", e); throw new UserException(e.getMessage()); } return groupsTable.values().toArray(new GroupValue[groupsTable.size()]); }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java
protected Vector<FormCellLabel> getAvailableLabels() { Vector<FormCellLabel> list = new Vector<FormCellLabel>(); Hashtable<String, FormCellLabel> labelHash = new Hashtable<String, FormCellLabel>(); //Hashtable<String, FormCellLabel> labelForHash = new Hashtable<String, FormCellLabel>(); // Add all the labels for (FormRowIFace row : formViewDef.getRows()) { for (FormCellIFace cell : row.getCells()) { if (cell instanceof FormCellLabel) { //labelForHash.put(((FormCellLabel)cell).getLabelFor(), (FormCellLabel)cell); labelHash.put(cell.getIdent(), (FormCellLabel) cell); }// w w w. j a v a 2 s.c om } } // remove the ones in use for (FormRowIFace row : formViewDef.getRows()) { for (FormCellIFace cell : row.getCells()) { if (cell instanceof FormCellField) { FormCellField fcf = (FormCellField) cell; FormCellLabel label = labelHash.get(fcf.getIdent()); if (label != null) { labelHash.remove(label.getIdent()); } } } } list.addAll(labelHash.values()); return list; }
From source file:edu.ku.brc.specify.utilapps.RegisterApp.java
/** * @param dateType//from w ww . ja v a 2s .c o m * @param srcList * @return */ private Vector<Pair<String, Integer>> getDateValuesFromList(final DateType dateType) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); System.out.println(rp.getRegNumHash().values().size()); Hashtable<String, Pair<String, Integer>> hash = new Hashtable<String, Pair<String, Integer>>(); for (RegProcEntry entry : rp.getRoot(INCL_ANON).getKids()) { if (entry.get("reg_type").equals("Institution")) { String desc = null; Timestamp ts = entry.getTimestampCreated(); cal.setTime(ts); switch (dateType) { case Time: desc = Integer.toString(cal.get(Calendar.HOUR_OF_DAY)); break; case Monthly: desc = Integer.toString(cal.get(Calendar.MONTH)); break; case Yearly: desc = Integer.toString(cal.get(Calendar.YEAR)); break; case Date: desc = sdf.format(ts); break; case None: break; } Pair<String, Integer> pair = hash.get(desc); if (pair == null) { pair = new Pair<String, Integer>(desc, 1); hash.put(desc, pair); } else { pair.second++; } } } Vector<Pair<String, Integer>> values = new Vector<Pair<String, Integer>>(hash.values()); int total = 0; for (Pair<String, Integer> p : values) { total += p.second; } System.err.println("Total: " + total); return values; }
From source file:net.java.sip.communicator.impl.protocol.jabber.ChatRoomJabberImpl.java
/** * Leave this chat room.//from w w w .j a v a2s . c om */ private void leave(String reason, String alternateAddress) { OperationSetBasicTelephonyJabberImpl basicTelephony = (OperationSetBasicTelephonyJabberImpl) provider .getOperationSet(OperationSetBasicTelephony.class); if (basicTelephony != null && this.publishedConference != null) { ActiveCallsRepositoryJabberGTalkImpl<CallJabberImpl, CallPeerJabberImpl> activeRepository = basicTelephony .getActiveCallsRepository(); String callid = publishedConference.getCallId(); if (callid != null) { CallJabberImpl call = activeRepository.findCallId(callid); for (CallPeerJabberImpl peer : call.getCallPeerList()) { peer.hangup(false, null, null); } } } List<CallJabberImpl> tmpConferenceCalls; synchronized (chatRoomConferenceCalls) { tmpConferenceCalls = new ArrayList<CallJabberImpl>(chatRoomConferenceCalls); chatRoomConferenceCalls.clear(); } for (CallJabberImpl call : tmpConferenceCalls) { for (CallPeerJabberImpl peer : call.getCallPeerList()) peer.hangup(false, null, null); } clearCachedConferenceDescriptionList(); XMPPConnection connection = this.provider.getConnection(); try { // if we are already disconnected // leave maybe called from gui when closing chat window if (connection != null) multiUserChat.leave(); } catch (Throwable e) { logger.warn("Error occured while leaving, maybe just " + "disconnected before leaving", e); } // FIXME Do we have to do the following when we leave the room? Hashtable<String, ChatRoomMemberJabberImpl> membersCopy; synchronized (members) { membersCopy = new Hashtable<String, ChatRoomMemberJabberImpl>(members); // Delete the list of members members.clear(); } for (ChatRoomMember member : membersCopy.values()) fireMemberPresenceEvent(member, ChatRoomMemberPresenceChangeEvent.MEMBER_LEFT, "Local user has left the chat room."); // connection can be null if we are leaving cause connection failed if (connection != null) { connection.removePacketListener(invitationRejectionListeners); if (presenceListener != null) { connection.removePacketListener(presenceListener); presenceListener = null; } } opSetMuc.fireLocalUserPresenceEvent(this, LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_LEFT, reason, alternateAddress); }
From source file:net.sourceforge.squirrel_sql.fw.dialects.DialectUtils.java
/** * Get a list of statements needed to create indexes for the specified table * //from w w w. java 2 s . c om * @param ti * @param md * @param primaryKeys * can be null * @param prefs * @return */ public static List<String> createIndexes(ITableInfo ti, String destSimpleTableName, String destSchema, ISQLDatabaseMetaData md, List<PrimaryKeyInfo> primaryKeys, CreateScriptPreferences prefs) { if (ti == null) { throw new IllegalArgumentException("ti cannot be null"); } if (md == null) { throw new IllegalArgumentException("md cannot be null"); } final List<String> result = new ArrayList<String>(); if (ti.getDatabaseObjectType() == DatabaseObjectType.VIEW) { return result; } final List<IndexColInfo> pkCols = new ArrayList<IndexColInfo>(); if (primaryKeys != null) { for (final PrimaryKeyInfo pkInfo : primaryKeys) { pkCols.add(new IndexColInfo(pkInfo.getColumnName())); } Collections.sort(pkCols, IndexColInfo.NAME_COMPARATOR); } List<IndexInfo> indexInfos = null; try { indexInfos = md.getIndexInfo(ti); } catch (final SQLException e) { // i18n[DialectUtils.error.getprimarykey=Unable to get primary key // info for table {0}] final String msg = s_stringMgr.getString("DialectUtils.error.getprimarykey", ti.getSimpleName()); log.error(msg, e); return result; } // Group all columns by index final Hashtable<String, TableIndexInfo> buf = new Hashtable<String, TableIndexInfo>(); for (final IndexInfo indexInfo : indexInfos) { final String indexName = indexInfo.getSimpleName(); if (StringUtils.isEmpty(indexName)) { continue; } final String columnName = indexInfo.getColumnName(); if (StringUtils.isEmpty(columnName)) { continue; } final TableIndexInfo ixi = buf.get(indexName); if (null == ixi) { final List<IndexColInfo> ixCols = new ArrayList<IndexColInfo>(); ixCols.add(new IndexColInfo(columnName, indexInfo.getOrdinalPosition())); buf.put(indexName, new TableIndexInfo(indexInfo.getTableName(), indexInfo.getSchemaName(), indexName, ixCols, !indexInfo.isNonUnique())); } else { ixi.cols.add(new IndexColInfo(indexInfo.getColumnName(), indexInfo.getOrdinalPosition())); } } final TableIndexInfo[] ixs = buf.values().toArray(new TableIndexInfo[buf.size()]); for (final TableIndexInfo ix : ixs) { Collections.sort(ix.cols, IndexColInfo.NAME_COMPARATOR); if (pkCols.equals(ix.cols)) { // Serveral DBs automatically create an index for primary key // fields // and return this index in getIndexInfo(). We remove this index // from the script // because it would break the script with an index already // exists error. continue; } Collections.sort(ix.cols, IndexColInfo.ORDINAL_POSITION_COMPARATOR); final StringBuilder indexSQL = new StringBuilder(); indexSQL.append("CREATE"); indexSQL.append(ix.unique ? " UNIQUE " : " "); indexSQL.append("INDEX "); indexSQL.append(ix.ixName); indexSQL.append(" ON "); indexSQL.append(formatQualifIntern(destSimpleTableName, destSchema, prefs)); if (ix.cols.size() == 1) { indexSQL.append("(").append(ix.cols.get(0)); for (int j = 1; j < ix.cols.size(); j++) { indexSQL.append(",").append(ix.cols.get(j)); } } else { indexSQL.append("\n(\n"); for (int j = 0; j < ix.cols.size(); j++) { indexSQL.append(" "); indexSQL.append(ix.cols.get(j)); if (j < ix.cols.size() - 1) { indexSQL.append(",\n"); } else { indexSQL.append("\n"); } } } indexSQL.append(")"); result.add(indexSQL.toString()); } return result; }
From source file:org.apache.flink.runtime.operators.sort.CombiningUnilateralSortMergerITCase.java
@Test public void testSortAndValidate() throws Exception { final Hashtable<TestData.Key, Integer> countTable = new Hashtable<TestData.Key, Integer>(KEY_MAX); for (int i = 1; i <= KEY_MAX; i++) { countTable.put(new TestData.Key(i), new Integer(0)); }// w w w.j a v a 2 s.co m // comparator final Comparator<TestData.Key> keyComparator = new TestData.KeyComparator(); // reader MockRecordReader reader = new MockRecordReader(); // merge iterator LOG.debug("initializing sortmerger"); TestCountCombiner2 comb = new TestCountCombiner2(); Sorter<Record> merger = new CombiningUnilateralSortMerger<Record>(comb, this.memoryManager, this.ioManager, reader, this.parentTask, this.serializerFactory, this.comparator, 0.25, 2, 0.7f); // emit data LOG.debug("emitting data"); TestData.Generator generator = new TestData.Generator(SEED, KEY_MAX, VALUE_LENGTH, KeyMode.RANDOM, ValueMode.FIX_LENGTH); Record rec = new Record(); final TestData.Value value = new TestData.Value("1"); for (int i = 0; i < NUM_PAIRS; i++) { Assert.assertTrue((rec = generator.next(rec)) != null); final TestData.Key key = rec.getField(0, TestData.Key.class); rec.setField(1, value); reader.emit(rec); countTable.put(new TestData.Key(key.getKey()), countTable.get(key) + 1); } reader.close(); rec = null; // check order MutableObjectIterator<Record> iterator = merger.getIterator(); LOG.debug("checking results"); Record rec1 = new Record(); Record rec2 = new Record(); Assert.assertTrue((rec1 = iterator.next(rec1)) != null); countTable.put(new TestData.Key(rec1.getField(0, TestData.Key.class).getKey()), countTable.get(rec1.getField(0, TestData.Key.class)) - (Integer.parseInt(rec1.getField(1, TestData.Value.class).toString()))); while ((rec2 = iterator.next(rec2)) != null) { final Key k1 = rec1.getField(0, TestData.Key.class); final Key k2 = rec2.getField(0, TestData.Key.class); Assert.assertTrue(keyComparator.compare(k1, k2) <= 0); countTable.put(new TestData.Key(k2.getKey()), countTable.get(k2) - (Integer.parseInt(rec2.getField(1, TestData.Value.class).toString()))); Record tmp = rec1; rec1 = rec2; k1.setKey(k2.getKey()); rec2 = tmp; } for (Integer cnt : countTable.values()) { Assert.assertTrue(cnt == 0); } merger.close(); // if the combiner was opened, it must have been closed Assert.assertTrue(comb.opened == comb.closed); }
From source file:eu.stratosphere.pact.runtime.sort.CombiningUnilateralSortMergerITCase.java
@Test public void testSortAndValidate() throws Exception { final Hashtable<TestData.Key, Integer> countTable = new Hashtable<TestData.Key, Integer>(KEY_MAX); for (int i = 1; i <= KEY_MAX; i++) { countTable.put(new TestData.Key(i), new Integer(0)); }// w w w. j a v a2s .c o m // comparator final Comparator<TestData.Key> keyComparator = new TestData.KeyComparator(); // reader MockRecordReader reader = new MockRecordReader(); // merge iterator LOG.debug("initializing sortmerger"); TestCountCombiner2 comb = new TestCountCombiner2(); Sorter<Record> merger = new CombiningUnilateralSortMerger<Record>(comb, this.memoryManager, this.ioManager, reader, this.parentTask, this.serializerFactory, this.comparator, 64 * 1024 * 1024, 2, 0.7f); // emit data LOG.debug("emitting data"); TestData.Generator generator = new TestData.Generator(SEED, KEY_MAX, VALUE_LENGTH, KeyMode.RANDOM, ValueMode.FIX_LENGTH); Record rec = new Record(); final TestData.Value value = new TestData.Value("1"); for (int i = 0; i < NUM_PAIRS; i++) { Assert.assertTrue((rec = generator.next(rec)) != null); final TestData.Key key = rec.getField(0, TestData.Key.class); rec.setField(1, value); reader.emit(rec); countTable.put(new TestData.Key(key.getKey()), countTable.get(key) + 1); } reader.close(); rec = null; // check order MutableObjectIterator<Record> iterator = merger.getIterator(); LOG.debug("checking results"); Record rec1 = new Record(); Record rec2 = new Record(); Assert.assertTrue((rec1 = iterator.next(rec1)) != null); countTable.put(new TestData.Key(rec1.getField(0, TestData.Key.class).getKey()), countTable.get(rec1.getField(0, TestData.Key.class)) - (Integer.parseInt(rec1.getField(1, TestData.Value.class).toString()))); while ((rec2 = iterator.next(rec2)) != null) { final Key k1 = rec1.getField(0, TestData.Key.class); final Key k2 = rec2.getField(0, TestData.Key.class); Assert.assertTrue(keyComparator.compare(k1, k2) <= 0); countTable.put(new TestData.Key(k2.getKey()), countTable.get(k2) - (Integer.parseInt(rec2.getField(1, TestData.Value.class).toString()))); Record tmp = rec1; rec1 = rec2; k1.setKey(k2.getKey()); rec2 = tmp; } for (Integer cnt : countTable.values()) { Assert.assertTrue(cnt == 0); } merger.close(); // if the combiner was opened, it must have been closed Assert.assertTrue(comb.opened == comb.closed); }
From source file:axiom.objectmodel.db.NodeManager.java
/** * Updates a modified node in the embedded db or an external relational database, depending * on its database mapping.//from ww w . j a v a 2s .c o m * * @return true if the DbMapping of the updated Node is to be marked as updated via * DbMapping.setLastDataChange */ public boolean updateNode(IDatabase db, ITransaction txn, Node node) throws IOException, SQLException, ClassNotFoundException { // Transactor tx = (Transactor) Thread.currentThread (); // tx.timer.beginEvent ("updateNode "+node); invokeOnPersist(node); DbMapping dbm = node.getDbMapping(); boolean markMappingAsUpdated = false; if ((dbm == null) || !dbm.isRelational()) { String className = dbm.getClassName(); IDatabase idb = null; if (className != null) { idb = (IDatabase) this.dbs.get(className); } if (idb == null) { idb = db; } idb.updateNode(txn, node.getID(), node); } else { Hashtable propMap = node.getPropMap(); Property[] props; if (propMap == null) { props = new Property[0]; } else { props = new Property[propMap.size()]; propMap.values().toArray(props); } // make sure table meta info is loaded by dbmapping dbm.getColumns(); StringBuffer b = dbm.getUpdate(); // comma flag set after the first dirty column, also tells as // if there are dirty columns at all boolean comma = false; for (int i = 0; i < props.length; i++) { // skip clean properties if ((props[i] == null) || !props[i].dirty) { // null out clean property so we don't consider it later props[i] = null; continue; } Relation rel = dbm.propertyToRelation(props[i].getName()); // skip readonly, virtual and collection relations if ((rel == null) || rel.readonly || rel.virtual || ((rel.reftype != Relation.REFERENCE) && (rel.reftype != Relation.PRIMITIVE))) { // null out property so we don't consider it later props[i] = null; continue; } if (comma) { b.append(", "); } else { comma = true; } b.append(rel.getDbField()); b.append(" = ?"); } // if no columns were updated, return false if (!comma) { return false; } b.append(" WHERE "); //b.append(dbm.getTableName(0)); //b.append("."); b.append(dbm.getIDField()); b.append(" = "); if (dbm.needsQuotes(dbm.getIDField())) { b.append("'"); b.append(escape(node.getID())); b.append("'"); } else { b.append(node.getID()); } b.append(dbm.getTableJoinClause(0)); Connection con = dbm.getConnection(); // set connection to write mode if (con.isReadOnly()) con.setReadOnly(false); PreparedStatement stmt = con.prepareStatement(b.toString()); int stmtNumber = 0; long logTimeStart = logSql ? System.currentTimeMillis() : 0; try { for (int i = 0; i < props.length; i++) { Property p = props[i]; if (p == null) { continue; } Relation rel = dbm.propertyToRelation(p.getName()); stmtNumber++; this.setStatementValues(stmt, stmtNumber, p, rel.getColumnType()); p.dirty = false; if (!rel.isPrivate()) { markMappingAsUpdated = true; } } stmt.executeUpdate(); } finally { if (logSql) { long logTimeStop = System.currentTimeMillis(); logSqlStatement("SQL UPDATE", dbm.getTableName(), logTimeStart, logTimeStop, b.toString()); } if (stmt != null) { try { stmt.close(); } catch (Exception ignore) { app.logEvent(ignore.getMessage()); } } } } // update may cause changes in the node's parent subnode array // TODO: is this really needed anymore? if (markMappingAsUpdated && node.isAnonymous()) { Node parent = node.getCachedParent(); if (parent != null) { parent.setLastSubnodeChange(System.currentTimeMillis()); } } return markMappingAsUpdated; }