List of usage examples for java.util HashMap remove
public V remove(Object key)
From source file:de.hybris.platform.mpintgordermanagement.interceptor.OrderEntryPrepareInterceptor.java
@Override public void onPrepare(OrderEntryModel orderEntrymodel, InterceptorContext ctx) throws InterceptorException { String threadLocalKey = "entriedOnce-" + orderEntrymodel.getEntryNumber(); HashMap<String, String> contextThreadLocalMap = contextThreadLocal.get(); if (contextThreadLocalMap.containsKey(threadLocalKey)) { return;/*from w w w. ja v a 2 s .c o m*/ } contextThreadLocalMap.put(threadLocalKey, "true"); if (orderEntrymodel instanceof TmallOrderEntryModel) { final TmallOrderEntryModel tmallOrderEntryModel = (TmallOrderEntryModel) orderEntrymodel; try { onPrepareTmallOrderEntry(tmallOrderEntryModel); } catch (Exception e) { log.error("Handle order entry status mapping service failed for " + orderEntrymodel, e); logMessage(Boolean.FALSE, "Sync status to hybris", tmallOrderEntryModel, "Sync status to hybris failed due to unknown reason:" + e.getMessage()); } } contextThreadLocalMap.remove(threadLocalKey); }
From source file:org.kuali.kra.irb.personnel.ProtocolPersonnelServiceImpl.java
/** * This method is to set the total count for each affiliation type * @param protocolPerson//from www.j a va2 s .com * @param investigatorAffiliation */ protected void updateAffiliationCount(ProtocolPerson protocolPerson, HashMap<Integer, Integer> investigatorAffiliation) { Integer totalCountForAffiliation = 0; totalCountForAffiliation = investigatorAffiliation.get(protocolPerson.getAffiliationTypeCode()); if (totalCountForAffiliation == null) { investigatorAffiliation.put(protocolPerson.getAffiliationTypeCode(), 1); } else { investigatorAffiliation.remove(protocolPerson.getAffiliationTypeCode()); investigatorAffiliation.put(protocolPerson.getAffiliationTypeCode(), totalCountForAffiliation++); } }
From source file:org.sbs.goodcrawler.plugin.storage.ElasticSearchStorage.java
@SuppressWarnings({ "unchecked" }) @Override/*w ww . j a va 2s .co m*/ public StoreResult onStore(ExtractedPage page) { StoreResult storeResult = null; if (null != plugin) { page = plugin.process(page); } try { storeResult = new StoreResult(); // ?Result if (null == page || page.getMessages() == null) { storeResult.setStatus(Status.ignored); return storeResult; } HashMap<String, Object> data = page.getMessages(); HashMap<String, Object> content = (HashMap<String, Object>) data.get(config.indexName); content.put("url", page.getUrl().getURL()); // ??url--? String update = (String) content.get("update"); if (null != update) { if (update.contains("")) { // ??update url index HashMap<String, Object> m = Maps.newHashMap(); m.put("url", page.getUrl().getURL()); m.put("domain", page.getUrl().getDomain()); m.put("time", new Date()); m.put("indexName", config.indexName); m.put("jobName", config.jobName); EsClient.index("update", "0", m); System.err.println("####################################"); } } content.remove("update"); // ? GetResponse get = null; try { String id = config.genId(content); System.out.println("id = " + id); get = client.prepareGet(config.indexName, "0", config.genId(content)).execute().actionGet(); } catch (Exception e) { e.printStackTrace(); // index? EsClient.index(config.indexName, "0", config.genId(content), content); } if (null != get && get.isExists()) { Map<String, Object> m = get.getSource(); m = MapUtils.mager((HashMap<String, Object>) m, content); log.info("mrege"); EsClient.index(config.indexName, "0", config.genId(content), m); } else { EsClient.index(config.indexName, "0", config.genId(content), content); } data.clear(); storeResult.setStatus(Status.success); return storeResult; } catch (Exception e) { e.printStackTrace(); log.info(e.getMessage()); storeResult.setStatus(Status.failed); return storeResult; } }
From source file:org.apache.nutch.net.URLNormalizers.java
/** * searches a list of suitable url normalizer plugins for the given scope. * // w w w . j a v a 2 s. c om * @param scope * Scope for which we seek a url normalizer plugin. * @return List - List of extensions to be used for this scope. If none, * returns null. * @throws PluginRuntimeException */ private List<Extension> findExtensions(String scope) { String[] orders = null; String orderlist = conf.get("urlnormalizer.order." + scope); if (orderlist == null) orderlist = conf.get("urlnormalizer.order"); if (orderlist != null && !orderlist.trim().equals("")) { orders = orderlist.split("\\s+"); } String scopelist = conf.get("urlnormalizer.scope." + scope); Set<String> impls = null; if (scopelist != null && !scopelist.trim().equals("")) { String[] names = scopelist.split("\\s+"); impls = new HashSet<String>(Arrays.asList(names)); } Extension[] extensions = this.extensionPoint.getExtensions(); HashMap<String, Extension> normalizerExtensions = new HashMap<String, Extension>(); for (int i = 0; i < extensions.length; i++) { Extension extension = extensions[i]; if (impls != null && !impls.contains(extension.getClazz())) continue; normalizerExtensions.put(extension.getClazz(), extension); } List<Extension> res = new ArrayList<Extension>(); if (orders == null) { res.addAll(normalizerExtensions.values()); } else { // first add those explicitly named in correct order for (int i = 0; i < orders.length; i++) { Extension e = normalizerExtensions.get(orders[i]); if (e != null) { res.add(e); normalizerExtensions.remove(orders[i]); } } // then add all others in random order res.addAll(normalizerExtensions.values()); } return res; }
From source file:org.wso2.andes.kernel.slot.SlotManager.java
/** * Re-assign the slot when there are no local subscribers in the node * * @param nodeId node ID of the node without subscribers * @param queueName name of the queue whose slots to be reassigned *//* ww w. j a va 2 s. co m*/ public void reAssignSlotWhenNoSubscribers(String nodeId, String queueName) { TreeSet<Slot> assignedSlotList = null; String lockKeyForNodeId = nodeId + SlotManager.class; synchronized (lockKeyForNodeId.intern()) { //Get assigned slots from Hazelcast, delete all belonging to queue //and set back HashmapStringTreeSetWrapper wrapper = slotAssignmentMap.get(nodeId); HashMap<String, TreeSet<Slot>> queueToSlotMap = null; if (wrapper != null) { queueToSlotMap = wrapper.getStringListHashMap(); } if (queueToSlotMap != null) { assignedSlotList = queueToSlotMap.remove(queueName); wrapper.setStringListHashMap(queueToSlotMap); slotAssignmentMap.set(nodeId, wrapper); } if (log.isDebugEnabled()) { log.debug("Cleared assigned slots of queue " + queueName + " Assigned to node " + nodeId); } //Get overlapped slots from Hazelcast, delete all belonging to queue and //set back HashmapStringTreeSetWrapper overlappedSlotWrapper = overLappedSlotMap.get(nodeId); HashMap<String, TreeSet<Slot>> queueToOverlappedSlotMap = null; if (overlappedSlotWrapper != null) { queueToOverlappedSlotMap = overlappedSlotWrapper.getStringListHashMap(); } if (queueToOverlappedSlotMap != null) { assignedSlotList = queueToOverlappedSlotMap.remove(queueName); overlappedSlotWrapper.setStringListHashMap(queueToOverlappedSlotMap); overLappedSlotMap.set(nodeId, overlappedSlotWrapper); } if (log.isDebugEnabled()) { log.debug("Cleared overlapped slots of queue " + queueName + " to be assigned to " + "node " + nodeId); } } //add the deleted slots to un-assigned slot map, so that they can be assigned again. if (assignedSlotList != null && !assignedSlotList.isEmpty()) { String lockKeyForQueueName = queueName + SlotManager.class; synchronized (lockKeyForQueueName.intern()) { TreeSetSlotWrapper treeSetStringWrapper = unAssignedSlotMap.get(queueName); TreeSet<Slot> unAssignedSlotSet = new TreeSet<Slot>(); if (treeSetStringWrapper != null) { unAssignedSlotSet = treeSetStringWrapper.getSlotTreeSet(); } else { treeSetStringWrapper = new TreeSetSlotWrapper(); } if (unAssignedSlotSet == null) { unAssignedSlotSet = new TreeSet<Slot>(); } for (Slot slotToBeReAssigned : assignedSlotList) { //Reassign only if the slot is not empty if (!SlotUtils.checkSlotEmptyFromMessageStore(slotToBeReAssigned)) { if (slotToBeReAssigned.addState(SlotState.RETURNED)) { unAssignedSlotSet.add(slotToBeReAssigned); if (log.isDebugEnabled()) { log.debug("Slot is returned by node " + nodeId + " slot = " + slotToBeReAssigned); } } } } treeSetStringWrapper.setSlotTreeSet(unAssignedSlotSet); unAssignedSlotMap.set(queueName, treeSetStringWrapper); } } }
From source file:org.wso2.andes.kernel.slot.SlotManager.java
/** * Delete all slot associations with a given queue. This is required to handle a queue purge event. * * @param queueName name of destination queue *///from w w w.j ava 2 s .c o m public void clearAllActiveSlotRelationsToQueue(String queueName) { if (log.isDebugEnabled()) { log.debug("Clearing all slots for queue " + queueName); } if (null != unAssignedSlotMap) { unAssignedSlotMap.remove(queueName); } if (null != slotIDMap) { slotIDMap.remove(queueName); } // Clear slots assigned to the queue along with overlapped slots if (AndesContext.getInstance().isClusteringEnabled()) { String nodeId = HazelcastAgent.getInstance().getNodeId(); // The requirement here is to clear slot associations for the queue on all nodes. List<String> nodeIDs = HazelcastAgent.getInstance().getMembersNodeIDs(); for (String nodeID : nodeIDs) { String lockKey = nodeID + SlotManager.class; synchronized (lockKey.intern()) { //clear slot assignment map HashmapStringTreeSetWrapper wrapper = slotAssignmentMap.get(nodeId); HashMap<String, TreeSet<Slot>> queueToSlotMap = null; if (wrapper != null) { queueToSlotMap = wrapper.getStringListHashMap(); } if (queueToSlotMap != null) { queueToSlotMap.remove(queueName); wrapper.setStringListHashMap(queueToSlotMap); slotAssignmentMap.set(nodeId, wrapper); } //clear overlapped slot map HashmapStringTreeSetWrapper overlappedSlotsWrapper = overLappedSlotMap.get(nodeId); if (null != overlappedSlotsWrapper) { HashMap<String, TreeSet<Slot>> queueToOverlappedSlotMap = null; if (wrapper != null) { queueToOverlappedSlotMap = overlappedSlotsWrapper.getStringListHashMap(); } if (queueToSlotMap != null) { queueToOverlappedSlotMap.remove(queueName); overlappedSlotsWrapper.setStringListHashMap(queueToOverlappedSlotMap); overLappedSlotMap.set(nodeId, overlappedSlotsWrapper); } } } } } }
From source file:com.google.gwt.emultest.java.util.HashMapTest.java
public void testIsEmpty() { HashMap<String, String> srcMap = new HashMap<String, String>(); checkEmptyHashMapAssumptions(srcMap); HashMap<String, String> dstMap = new HashMap<String, String>(); checkEmptyHashMapAssumptions(dstMap); dstMap.putAll(srcMap);/*from w ww. j a v a 2s. c o m*/ assertTrue(dstMap.isEmpty()); dstMap.put(KEY_KEY, VALUE_VAL); assertFalse(dstMap.isEmpty()); dstMap.remove(KEY_KEY); assertTrue(dstMap.isEmpty()); assertEquals(dstMap.size(), 0); }
From source file:org.kuali.kra.s2s.polling.S2SPollingTask.java
/** * /*w w w. j a va 2 s . com*/ * This method sends mail for all submission status records that have changed relative to database * * @param htMails * @throws InvalidAddressException * @throws Exception */ private void sendMail(HashMap<String, Vector<SubmissionData>> htMails) throws InvalidAddressException { MailService mailService = KNSServiceLocator.getMailService(); if (htMails.isEmpty()) { return; } List<MailInfo> mailList = getMailInfoList(); for (MailInfo mailInfo : mailList) { String dunsNum = mailInfo.getDunsNumber(); Vector<SubmissionData> propList = htMails.get(dunsNum); if (propList == null) { continue; } htMails.remove(dunsNum); MailMessage mailMessage = parseNGetMailAttr(propList, mailInfo); if (mailMessage != null) { mailService.sendMessage(mailMessage); } } if (mailList.size() > 0 && !htMails.isEmpty()) { Iterator<String> it = htMails.keySet().iterator(); while (it.hasNext()) { Vector<SubmissionData> nonDunsPropList = htMails.get(it.next()); MailInfo mailInfo = mailList.get(0); MailMessage mailMessage = parseNGetMailAttr(nonDunsPropList, mailInfo); if (mailMessage != null) { mailService.sendMessage(mailMessage); LOG.debug("Sent mail with default duns to " + mailMessage.getToAddresses() + " Subject as " + mailMessage.getSubject() + " Message as " + mailMessage.getMessage()); } } } }
From source file:org.freebxml.omar.server.lcm.LifeCycleManagerImpl.java
/** * Processes Associations looking for Associations that already exist and are being * submitted by source or target owner and are identical in state to existing * Association in registry. /*w w w .j a v a2 s. co m*/ * * ebXML Registry 3.0 hasber discarded association confirmation in favour of * Role Based access control. However, freebXML Registry supports it in an * impl specific manner as this is required by JAXR 1.0 API. * This SHOULD be removed once JAXR 2.0 no longer requires it for ebXML Registry * in future. * * The processing updates the Association to add a special Impl specific slot to * remember the confirmation state change. * * TODO: Need to do unconfirm when src or target owner removes an Association they had * previously confirmed. */ private void processConfirmationAssociations(ServerRequestContext context) throws RegistryException { try { //Make a copy to avoid ConcurrentModificationException ArrayList topLevelObjects = new ArrayList( ((ServerRequestContext) context).getTopLevelObjectsMap().values()); Iterator iter = topLevelObjects.iterator(); while (iter.hasNext()) { Object obj = iter.next(); if (obj instanceof AssociationType1) { AssociationType1 ass = (AssociationType1) obj; HashMap slotsMap = bu.getSlotsFromRegistryObject(ass); String beingConfirmed = (String) slotsMap.remove(bu.IMPL_SLOT_ASSOCIATION_IS_BEING_CONFIRMED); if ((beingConfirmed != null) && (beingConfirmed.equalsIgnoreCase("true"))) { //Need to set slotMap again ass.getSlot().clear(); bu.addSlotsToRegistryObject(ass, slotsMap); ((ServerRequestContext) context).getConfirmationAssociations().put(ass.getId(), ass); } } } } catch (javax.xml.bind.JAXBException e) { throw new RegistryException(e); } }
From source file:com.lines.activitys.OptionsActivity.java
/** * Here we get the list of characters in the database * /*from w w w .j a v a 2s. com*/ */ private void populateCharacters() { mCursor = mDbAdapter.fetchAllLines(); // First get the data from "character" column and filter out unwanted // characters (e.g. STAGE) if (mCursor.moveToFirst()) { do { String character = mCursor.getString(mCursor.getColumnIndex("character")); if (!(character.equals("STAGE") || character.contains("and"))) { characters.add(character); } } while (mCursor.moveToNext()); } HashMap<String, Integer> charOccur = new HashMap<String, Integer>(); // Get the number of lines spoken by each character and store in HashMap Set<String> unique = new HashSet<String>(characters); for (String key : unique) { charOccur.put(key, Collections.frequency(characters, key)); } characters.clear(); // Sort character list based on the number of lines they have while (charOccur.size() > 0) { int max = Collections.max(charOccur.values()); characters.add(getKeyByValue(charOccur, max)); charOccur.remove(getKeyByValue(charOccur, max)); } // Set contents of Character Spinner mAdapterChar = new ArrayAdapter<String>(OptionsActivity.this, android.R.layout.simple_spinner_item, characters); mAdapterChar.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mChar.setAdapter(mAdapterChar); mCursor.close(); }