public synchronized void messageReceived(int to, Message m) { DrainMsg mhMsg = (DrainMsg) m; log.debug( "incoming: localDest: " + to + " type:" + mhMsg.get_type() + " hops:" + (16 - mhMsg.get_ttl()) + " seqNo:" + mhMsg.get_seqNo() + " source:" + mhMsg.get_source() + " finalDest:" + mhMsg.get_dest()); // lets assume that the network cannot buffer more than 25 drain msgs from a single source at a // time (should be more than reasonable) if (seqNos.containsKey(new Integer(mhMsg.get_source()))) { int oldSeqNo = ((Integer) seqNos.get(new Integer(mhMsg.get_source()))).intValue(); int upperBound = mhMsg.get_seqNo() + 25; int wrappedUpperBound = 25 - (255 - mhMsg.get_seqNo()); if ((oldSeqNo >= mhMsg.get_seqNo() && oldSeqNo < upperBound) || (oldSeqNo >= 0 && oldSeqNo < wrappedUpperBound)) { log.debug( "Dropping message from " + mhMsg.get_source() + " with duplicate seqNo: " + mhMsg.get_seqNo()); return; } } seqNos.put(new Integer(mhMsg.get_source()), new Integer(mhMsg.get_seqNo())); if (to != spAddr && to != MoteIF.TOS_BCAST_ADDR && to != TOS_UART_ADDR) { log.debug("Dropping message not for me."); return; } HashSet promiscuousSet = (HashSet) idTable.get(new Integer(BCAST_ID)); HashSet listenerSet = (HashSet) idTable.get(new Integer(mhMsg.get_type())); if (listenerSet != null && promiscuousSet != null) { listenerSet.addAll(promiscuousSet); } else if (listenerSet == null && promiscuousSet != null) { listenerSet = promiscuousSet; } if (listenerSet == null) { log.debug("No Listener for type: " + mhMsg.get_type()); return; } for (Iterator it = listenerSet.iterator(); it.hasNext(); ) { MessageListener ml = (MessageListener) it.next(); ml.messageReceived(to, mhMsg); } }
/** * get the vocab attributes from teh user bean using filter attr and filter value to check and * return its equivaltnt attrs * * @param eUser EVS_userbean obtained from the database at login * @param sFilterValue string existing value * @param filterAttr int existing vocab name * @param retAttr int returning vocab name * @return value from returning vocab */ public String getVocabAttr( EVS_UserBean eUser, String sFilterValue, int filterAttr, int retAttr) // String sFilterAttr, String sRetAttr) { // go back if origin is emtpy if (sFilterValue == null || sFilterValue.equals("")) return ""; String sRetValue = sFilterValue; // sFilterValue is the value but the full name of 2) Select EVS Vocabulary // from the front end (cdecurate) e.g. Logical Observation Identifier Names // and Codes instead of LOINC Hashtable eHash = eUser.getVocab_Attr(); Vector vVocabs = eUser.getVocabNameList(); if (vVocabs == null) vVocabs = new Vector(); // handle teh special case to make sure vocab for api query is valid if (filterAttr == EVSSearch.VOCAB_NULL) // (sFilterAttr == null || sFilterAttr.equals("")) { // it is valid vocab name if (vVocabs.contains(sFilterValue)) return sFilterValue; // found it // first check if filter value is from diplay vocab list Vector vDisplay = eUser.getVocabDisplayList(); if (vDisplay != null && vDisplay.contains(sFilterValue)) { int iIndex = vDisplay.indexOf(sFilterValue); sRetValue = (String) vVocabs.elementAt(iIndex); return sRetValue; // found it } // filter it as dborigin filterAttr = EVSSearch.VOCAB_DBORIGIN; // sFilterAttr = "vocabDBOrigin"; } for (int i = 0; i < vVocabs.size(); i++) { String sName = (String) vVocabs.elementAt(i); EVS_UserBean usrVocab = (EVS_UserBean) eHash.get(sName); String sValue = ""; // check if the vocab is meta thesaurus String sMeta = usrVocab.getIncludeMeta(); if (sMeta != null && !sMeta.equals("") && sMeta.equals(sFilterValue)) return EVSSearch.META_VALUE; // "MetaValue"; // get teh data from teh bean to match search if (filterAttr == EVSSearch.VOCAB_DISPLAY) // (sFilterAttr.equalsIgnoreCase("vocabDisplay")) sValue = usrVocab.getVocabDisplay(); else if (filterAttr == EVSSearch.VOCAB_DBORIGIN) // (sFilterAttr.equalsIgnoreCase("vocabDBOrigin")) sValue = usrVocab.getVocabDBOrigin(); else if (filterAttr == EVSSearch.VOCAB_NAME) // (sFilterAttr.equalsIgnoreCase("vocabName")) sValue = usrVocab.getVocabName(); // do matching and return the value // System.out.println(sFilterValue + " getvocab " + sValue); // if (sFilterValue.equalsIgnoreCase(sValue)) //check it later if (sFilterValue.contains(sValue)) { // get its value from teh bean for the return attr if (retAttr == EVSSearch.VOCAB_DISPLAY) // (sRetAttr.equalsIgnoreCase("vocabDisplay")) sRetValue = usrVocab.getVocabDisplay(); else if (retAttr == EVSSearch.VOCAB_DBORIGIN) // (sRetAttr.equalsIgnoreCase("vocabDBOrigin")) sRetValue = usrVocab.getVocabDBOrigin(); else if (retAttr == EVSSearch.VOCAB_NAME) // (sRetAttr.equalsIgnoreCase("vocabName")) sRetValue = usrVocab.getVocabName(); break; } } // return the first vocab if null // if ((sRetValue == null || sRetValue.equals("")) && vVocabs != null) // sRetValue = (String)vVocabs.elementAt(0); // System.out.println(sRetValue + sFilterValue + filterAttr + retAttr); if (sRetValue == null) sRetValue = ""; return sRetValue; }