List of usage examples for java.util LinkedHashMap containsKey
boolean containsKey(Object key);
From source file:org.apache.jackrabbit.oak.segment.file.TarReader.java
/** * Scans through the tar file, looking for all segment entries. * * @throws IOException if the tar file could not be read *///from w w w.ja v a2 s . co m private static void recoverEntries(File file, RandomAccessFile access, LinkedHashMap<UUID, byte[]> entries) throws IOException { byte[] header = new byte[BLOCK_SIZE]; while (access.getFilePointer() + BLOCK_SIZE <= access.length()) { // read the tar header block access.readFully(header); // compute the header checksum int sum = 0; for (int i = 0; i < BLOCK_SIZE; i++) { sum += header[i] & 0xff; } // identify possible zero block if (sum == 0 && access.getFilePointer() + 2 * BLOCK_SIZE == access.length()) { return; // found the zero blocks at the end of the file } // replace the actual stored checksum with spaces for comparison for (int i = 148; i < 148 + 8; i++) { sum -= header[i] & 0xff; sum += ' '; } byte[] checkbytes = String.format("%06o\0 ", sum).getBytes(UTF_8); for (int i = 0; i < checkbytes.length; i++) { if (checkbytes[i] != header[148 + i]) { log.warn("Invalid entry checksum at offset {} in tar file {}, skipping...", access.getFilePointer() - BLOCK_SIZE, file); } } // The header checksum passes, so read the entry name and size ByteBuffer buffer = wrap(header); String name = readString(buffer, 100); buffer.position(124); int size = readNumber(buffer, 12); if (access.getFilePointer() + size > access.length()) { // checksum was correct, so the size field should be accurate log.warn("Partial entry {} in tar file {}, ignoring...", name, file); return; } Matcher matcher = NAME_PATTERN.matcher(name); if (matcher.matches()) { UUID id = UUID.fromString(matcher.group(1)); String checksum = matcher.group(3); if (checksum != null || !entries.containsKey(id)) { byte[] data = new byte[size]; access.readFully(data); // skip possible padding to stay at block boundaries long position = access.getFilePointer(); long remainder = position % BLOCK_SIZE; if (remainder != 0) { access.seek(position + (BLOCK_SIZE - remainder)); } if (checksum != null) { CRC32 crc = new CRC32(); crc.update(data); if (crc.getValue() != Long.parseLong(checksum, 16)) { log.warn("Checksum mismatch in entry {} of tar file {}, skipping...", name, file); continue; } } entries.put(id, data); } } else if (!name.equals(file.getName() + ".idx")) { log.warn("Unexpected entry {} in tar file {}, skipping...", name, file); long position = access.getFilePointer() + size; long remainder = position % BLOCK_SIZE; if (remainder != 0) { position += BLOCK_SIZE - remainder; } access.seek(position); } } }
From source file:edu.umd.ks.cm.util.siscm.dao.impl.SisCmDaoImpl.java
private String getNaturalLanguageForStatement(String booleanExpression, List<ReqComponentReference> reqComponentList) throws Exception { HashMap reqComponentMap = new HashMap(); LinkedHashMap<Integer, Integer> parPositionMap = new LinkedHashMap<Integer, Integer>(); ArrayList<Integer> parLeftList = new ArrayList<Integer>(); for (ReqComponentReference reqComponent : reqComponentList) { String translation = this.reqComponentTranslator.translate(reqComponent.getReqComponent(), "KUALI.RULE.CATALOG", "en"); if (translation != null && translation.length() > 0 && translation.substring(translation.length() - 1).equals(".")) translation = translation.substring(0, translation.length() - 1); reqComponentMap.put(reqComponent.getBooleanId(), translation); }//from w w w.ja v a 2 s .c o m BooleanFunction booleanFunction = new BooleanFunction(booleanExpression); List<String> funcSymbs = booleanFunction.getSymbols(); for (int i = 0; i < funcSymbs.size(); i++) { if (funcSymbs.get(i).equals("(")) { parLeftList.add(i); } int parLeftLast = parLeftList.size() - 1; if (funcSymbs.get(i).equals(")")) { parPositionMap.put(parLeftList.get(parLeftLast), i); parLeftList.remove(parLeftLast); } } // For the expression (A + B + (C * D)) want to remove outer () if (parPositionMap.containsKey(0) && parPositionMap.get(0) == funcSymbs.size() - 1) { parPositionMap.remove(0); funcSymbs.set(0, "null"); funcSymbs.set(funcSymbs.size() - 1, "null"); } if (!parPositionMap.isEmpty()) { for (Integer key : parPositionMap.keySet()) { StringBuffer funcSymb = new StringBuffer(""); int pos = 0; String expr = ""; for (int i = key + 1; i < parPositionMap.get(key); i++) { String funcSymbAdd = funcSymbs.get(i); if (!funcSymbAdd.equals("+") && !funcSymbAdd.equals("*") && !funcSymbAdd.equals("null")) { expr = (String) reqComponentMap.get(funcSymbAdd); if (pos == 0 && !funcSymbAdd.substring(0, 1).equals("V") && expr.length() > 2 && expr.substring(0, 1).equals("(") && expr.substring(expr.length() - 1).equals(")")) { expr = expr.substring(1, expr.length() - 1); } pos = 1; //convert the first character of 'expr' to lower case, if necessary if (expr.length() > 0) { char ch0 = expr.charAt(0); if (ch0 <= 'Z' && ch0 >= 'A') { if (expr.length() > 1) { char ch1 = expr.charAt(1); if (ch1 >= 'a' && ch1 <= 'z') { expr = expr.substring(0, 1).toLowerCase() + expr.substring(1); } } else { expr = expr.toLowerCase(); } } } funcSymb.append(expr); } else if (funcSymbAdd.equals("+")) { funcSymb.append("; or "); } else if (funcSymbAdd.equals("*")) { funcSymb.append("; and "); } } // for int i String id = "V" + Integer.toString(key); funcSymb.insert(0, "("); funcSymb.append(")"); reqComponentMap.put(id, funcSymb.toString()); funcSymbs.set(key, id); for (int i = key + 1; i < parPositionMap.get(key) + 1; i++) funcSymbs.set(i, "null"); } } List<String> funcSymbsNew = new ArrayList<String>(); for (int i = 0; i < funcSymbs.size(); i++) { if (!funcSymbs.get(i).equals("null")) funcSymbsNew.add(funcSymbs.get(i)); } String nl = ""; if (funcSymbsNew.size() == 1) { nl = (String) reqComponentMap.get(funcSymbsNew.get(0)); if (nl.substring(0, 1).equals("(") && nl.substring(nl.length() - 1).equals(")")) nl = nl.substring(1, nl.length() - 1); } else { int pos = 0; String expr = ""; for (int i = 0; i < funcSymbsNew.size(); i++) { if (!funcSymbsNew.get(i).equals("*") && !funcSymbsNew.get(i).equals("+")) { expr = (String) reqComponentMap.get(funcSymbsNew.get(i)); if (pos == 0) { if (expr.length() > 2 && expr.substring(0, 1).equals("(") && expr.substring(expr.length() - 1).equals(")")) expr = expr.substring(1, expr.length() - 1); pos = 1; } else { if (funcSymbsNew.get(i).substring(0, 1).equals("V") && expr.length() > 2 && expr.substring(0, 1).equals("(") && expr.substring(expr.length() - 1).equals(")")) expr = expr.substring(1, expr.length() - 1); } nl = nl + expr; } else if (funcSymbsNew.get(i).equals("+")) { if ((i > 0 && funcSymbsNew.get(i - 1).substring(0, 1).equals("V")) || (i < (funcSymbsNew.size() - 1) && funcSymbsNew.get(i + 1).substring(0, 1).equals("V"))) nl = nl + ". Or "; else nl = nl + "; or "; } else if (funcSymbsNew.get(i).equals("*")) { if ((i > 0 && funcSymbsNew.get(i - 1).substring(0, 1).equals("V")) || (i < (funcSymbsNew.size() - 1) && funcSymbsNew.get(i + 1).substring(0, 1).equals("V"))) nl = nl + ". And "; else nl = nl + "; and "; } } } //TODO: Fix Capitalization nl = nl.substring(0, 1).toUpperCase() + nl.substring(1); return nl.trim(); }
From source file:com.sonicle.webtop.vfs.Service.java
public void processManageStoresTree(HttpServletRequest request, HttpServletResponse response, PrintWriter out) { ArrayList<ExtTreeNode> children = new ArrayList<>(); // Node ID is composed in this way: // $shareId|$storeId|$path try {/*from w ww.j a va 2 s . c o m*/ String crud = ServletUtils.getStringParameter(request, "crud", true); if (crud.equals(Crud.READ)) { String node = ServletUtils.getStringParameter(request, "node", true); if (node.equals("root")) { // Share roots... for (StoreShareRoot root : getRootsFromCache()) { children.add(createRootNode(root)); } } else { StoreNodeId nodeId = (StoreNodeId) new StoreNodeId().parse(node); if (nodeId.getSize() == 1) { // Root share's folders... StoreShareRoot root = getRootFromCache(nodeId.getShareId()); if (root instanceof MyStoreRoot) { for (Store cal : manager.listStores()) { MyStoreFolder folder = new MyStoreFolder(node, root.getOwnerProfileId(), cal); children.add(createFolderNode(folder, root.getPerms())); } } else { for (StoreShareFolder fold : getFoldersFromCache(root.getShareId())) { children.add(createFolderNode(fold, root.getPerms())); } } } else if (nodeId.getSize() == 2 || nodeId.getSize() == 3) { // Store's folders (2) or folder's folders (3)... int storeId = Integer.valueOf(nodeId.getStoreId()); StoreShareFolder folder = getFolderFromCache(storeId); String path = (nodeId.getSize() == 2) ? "/" : nodeId.getPath(); boolean showHidden = us.getShowHiddenFiles(); LinkedHashMap<String, SharingLink> dls = manager.listDownloadLinks(storeId, path); LinkedHashMap<String, SharingLink> uls = manager.listUploadLinks(storeId, path); StoreFileSystem sfs = manager.getStoreFileSystem(storeId); for (FileObject fo : manager.listStoreFiles(StoreFileType.FOLDER, storeId, path)) { if (!showHidden && VfsUtils.isFileObjectHidden(fo)) continue; // Relativize path and force trailing separator (it's a folder) final String filePath = PathUtils.ensureTrailingSeparator(sfs.getRelativePath(fo), false); //final String fileId = new StoreNodeId(nodeId.getShareId(), nodeId.getStoreId(), filePath).toString(); final String fileHash = manager.generateStoreFileHash(storeId, filePath); String dlLink = null, ulLink = null; if (dls.containsKey(fileHash)) { dlLink = dls.get(fileHash).getLinkId(); } if (uls.containsKey(fileHash)) { ulLink = uls.get(fileHash).getLinkId(); } children.add(createFileNode(folder, filePath, dlLink, ulLink, fo)); } } } new JsonResult("children", children).printTo(out); } } catch (Exception ex) { logger.error("Error in ManageStoresTree", ex); } }
From source file:com.sonicle.webtop.vfs.VfsManager.java
public HashMap<Integer, StoreShareFolder> listIncomingStoreFolders(String rootShareId) throws WTException { CoreManager core = WT.getCoreManager(getTargetProfileId()); LinkedHashMap<Integer, StoreShareFolder> folders = new LinkedHashMap<>(); // Retrieves incoming folders (from sharing). This lookup already // returns readable shares (we don't need to test READ permission) List<OShare> shares = core.listIncomingShareFolders(rootShareId, GROUPNAME_STORE); for (OShare share : shares) { UserProfile.Id ownerId = core.userUidToProfileId(share.getUserUid()); List<Store> stores = null; if (share.hasWildcard()) { stores = listStores(ownerId); } else {//from ww w . ja v a2 s. c o m stores = Arrays.asList(getStore(Integer.valueOf(share.getInstance()))); } for (Store store : stores) { SharePermsFolder fperms = core.getShareFolderPermissions(share.getShareId().toString()); SharePermsElements eperms = core.getShareElementsPermissions(share.getShareId().toString()); if (folders.containsKey(store.getStoreId())) { StoreShareFolder folder = folders.get(store.getStoreId()); folder.getPerms().merge(fperms); folder.getElementsPerms().merge(eperms); } else { folders.put(store.getStoreId(), new StoreShareFolder(share.getShareId().toString(), ownerId, fperms, eperms, store)); } } } return folders; }
From source file:com.vmware.bdd.manager.ClusterConfigManager.java
private LinkedHashMap<NetTrafficType, List<ClusterNetConfigInfo>> validateAndConvertNetNamesToNetConfigs( Map<NetTrafficType, List<String>> netNamesInfo, boolean isMaprDistro) { LinkedHashMap<NetTrafficType, List<ClusterNetConfigInfo>> netConfigs = new LinkedHashMap<NetTrafficType, List<ClusterNetConfigInfo>>(); LinkedHashMap<String, Set<String>> port2names = new LinkedHashMap<String, Set<String>>(); for (NetTrafficType type : netNamesInfo.keySet()) { netConfigs.put(type, new ArrayList<ClusterNetConfigInfo>()); for (String name : netNamesInfo.get(type)) { NetworkEntity networkEntity = networkMgr.getNetworkEntityByName(name); String pg = networkEntity.getPortGroup(); Boolean isGenerateHostname = networkEntity.getIsGenerateHostname(); String hostnamePrefix = HostnameManager.getHostnamePrefix(); ClusterNetConfigInfo netConfig = new ClusterNetConfigInfo(type, name, pg, networkEntity.getDnsType(), isGenerateHostname, hostnamePrefix); netConfigs.get(type).add(netConfig); if (!port2names.containsKey(pg)) { port2names.put(pg, new HashSet<String>()); }/* w ww . ja va 2 s . c o m*/ port2names.get(pg).add(name); } } if (isMaprDistro && port2names.size() > 1) { throw BddException.MULTI_NETWORKS_FOR_MAPR_DISTRO(); } // if nw1,nw2 are both refer to pg1, should not use them in one cluster for (String pg : port2names.keySet()) { if (port2names.get(pg).size() > 1) { throw BddException.PG_REFERENCED_MULTI_TIMES(); } } return netConfigs; }
From source file:com.sonicle.webtop.core.Service.java
public void processLookupLanguages(HttpServletRequest request, HttpServletResponse response, PrintWriter out) { LinkedHashMap<String, JsSimple> items = new LinkedHashMap<>(); Locale locale = getEnv().getSession().getLocale(); try {/*w w w . ja va2s . com*/ for (AppLocale apploc : WT.getInstalledLocales()) { final Locale loc = apploc.getLocale(); final String lang = loc.getLanguage(); if (!items.containsKey(lang)) { //items.put(lang, new JsSimple(lang, loc.getDisplayLanguage(locale))); items.put(lang, new JsSimple(apploc.getId(), apploc.getLocale().getDisplayName(locale))); } } new JsonResult("languages", items.values(), items.size()).printTo(out); } catch (Exception ex) { logger.error("Error in LookupLanguages", ex); new JsonResult(false, "Unable to lookup languages").printTo(out); } }
From source file:org.openmicroscopy.shoola.agents.util.EditorUtil.java
/** * Transforms the light and its settings. * * @param data The data to transform.//from w ww. j a v a2s . co m * @return See above. */ public static Map<String, Object> transformLightSourceAndSetting(ChannelAcquisitionData data) { LinkedHashMap<String, Object> details = new LinkedHashMap<String, Object>(); Map<String, Object> m; if (data == null) m = transformLightSource(null); else m = transformLightSource(data.getLightSource()); List<String> notSet = (List) m.get(NOT_SET); m.remove(NOT_SET); details.putAll(m); details.put(ATTENUATION, new Double(0)); if (data == null) { details.put(WAVELENGTH, Integer.valueOf(0)); notSet.add(ATTENUATION); notSet.add(WAVELENGTH); details.put(NOT_SET, notSet); return details; } Double f = data.getLigthSettingsAttenuation(); double v = 0; if (f == null) notSet.add(ATTENUATION); else v = f; details.put(ATTENUATION, v * PERCENT_FRACTION); Integer i = data.getLigthSettingsWavelength(); if (details.containsKey(WAVELENGTH)) { if (i != null) { //override the value. details.put(WAVELENGTH, i); } } else { int vi = 0; if (i == null) notSet.add(WAVELENGTH); else vi = i; details.put(WAVELENGTH, vi); } details.put(NOT_SET, notSet); return details; }
From source file:oscar.dms.actions.DmsInboxManageAction.java
public ActionForward prepareForContentPage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {//from w w w . ja v a 2 s .c o m HttpSession session = request.getSession(); try { if (session.getAttribute("userrole") == null) response.sendRedirect("../logout.jsp"); } catch (Exception e) { logger.error("Error", e); } // can't use userrole from session, because it changes if provider A search for provider B's documents // oscar.oscarMDS.data.MDSResultsData mDSData = new oscar.oscarMDS.data.MDSResultsData(); CommonLabResultData comLab = new CommonLabResultData(); // String providerNo = request.getParameter("providerNo"); String providerNo = (String) session.getAttribute("user"); String searchProviderNo = request.getParameter("searchProviderNo"); String ackStatus = request.getParameter("status"); String demographicNo = request.getParameter("demographicNo"); // used when searching for labs by patient instead of provider String scannedDocStatus = request.getParameter("scannedDocument"); Integer page = 0; try { page = Integer.parseInt(request.getParameter("page")); if (page > 0) { page--; } } catch (NumberFormatException nfe) { page = 0; } Integer pageSize = 20; try { String tmp = request.getParameter("pageSize"); pageSize = Integer.parseInt(tmp); } catch (NumberFormatException nfe) { pageSize = 20; } scannedDocStatus = "I"; String startDateStr = request.getParameter("startDate"); String endDateStr = request.getParameter("endDate"); String view = request.getParameter("view"); if (view == null || "".equals(view)) { view = "all"; } boolean mixLabsAndDocs = "normal".equals(view) || "all".equals(view); Date startDate = null; Date endDate = null; try { if (startDateStr != null && startDateStr.length() > 0) { startDateStr = startDateStr.trim(); startDate = UtilDateUtilities.StringToDate(startDateStr); } if (endDateStr != null && endDateStr.length() > 0) { endDateStr = endDateStr.trim(); endDate = UtilDateUtilities.StringToDate(endDateStr); } } catch (Exception e) { startDate = null; endDate = null; } Boolean isAbnormal = null; if ("abnormal".equals(view)) isAbnormal = new Boolean(true); if ("normal".equals(view)) isAbnormal = new Boolean(false); if (ackStatus == null) { ackStatus = "N"; } // default to new labs only if (providerNo == null) { providerNo = ""; } if (searchProviderNo == null) { searchProviderNo = providerNo; } String roleName = ""; List<SecUserRole> roles = secUserRoleDao.getUserRoles(searchProviderNo); for (SecUserRole r : roles) { if (r != null) { if (roleName.length() == 0) { roleName = r.getRoleName(); } else { roleName += "," + r.getRoleName(); } } } roleName += "," + searchProviderNo; // mDSData.populateMDSResultsData2(searchProviderNo, demographicNo, request.getParameter("fname"), request.getParameter("lname"), request.getParameter("hnum"), ackStatus); // HashMap<String,String> docQueue=comLab.getDocumentQueueLinks(); List<QueueDocumentLink> qd = queueDocumentLinkDAO.getQueueDocLinks(); HashMap<String, String> docQueue = new HashMap(); for (QueueDocumentLink qdl : qd) { Integer i = qdl.getDocId(); Integer n = qdl.getQueueId(); docQueue.put(i.toString(), n.toString()); } InboxResultsDao inboxResultsDao = (InboxResultsDao) SpringUtils.getBean("inboxResultsDao"); String patientFirstName = request.getParameter("fname"); String patientLastName = request.getParameter("lname"); String patientHealthNumber = request.getParameter("hnum"); ArrayList<LabResultData> labdocs = new ArrayList<LabResultData>(); if (!"labs".equals(view) && !"abnormal".equals(view)) { labdocs = inboxResultsDao.populateDocumentResultsData(searchProviderNo, demographicNo, patientFirstName, patientLastName, patientHealthNumber, ackStatus, true, page, pageSize, mixLabsAndDocs, isAbnormal); } if (!"documents".equals(view)) { labdocs.addAll(comLab.populateLabResultsData(searchProviderNo, demographicNo, patientFirstName, patientLastName, patientHealthNumber, ackStatus, scannedDocStatus, true, page, pageSize, mixLabsAndDocs, isAbnormal)); } labdocs = (ArrayList<LabResultData>) filterLabDocsForSuperSite(labdocs, providerNo); ArrayList<LabResultData> validlabdocs = new ArrayList<LabResultData>(); DocumentResultsDao documentResultsDao = (DocumentResultsDao) SpringUtils.getBean("documentResultsDao"); // check privilege for documents only for (LabResultData data : labdocs) { if (data.isDocument()) { String docid = data.getSegmentID(); String queueid = docQueue.get(docid); if (queueid != null) { queueid = queueid.trim(); int queueIdInt = Integer.parseInt(queueid); // if doc sent to default queue and no valid provider, do NOT include it if (queueIdInt == Queue.DEFAULT_QUEUE_ID && !documentResultsDao.isSentToValidProvider(docid) && isSegmentIDUnique(validlabdocs, data)) { // validlabdocs.add(data); } // if doc sent to default queue && valid provider, check if it's sent to this provider, if yes include it else if (queueIdInt == Queue.DEFAULT_QUEUE_ID && documentResultsDao.isSentToValidProvider(docid) && documentResultsDao.isSentToProvider(docid, searchProviderNo) && isSegmentIDUnique(validlabdocs, data)) { validlabdocs.add(data); } // if doc setn to non-default queue and valid provider, check if provider is in the queue or equal to the provider else if (queueIdInt != Queue.DEFAULT_QUEUE_ID && documentResultsDao.isSentToValidProvider(docid)) { Vector vec = OscarRoleObjectPrivilege.getPrivilegeProp("_queue." + queueid); if (OscarRoleObjectPrivilege.checkPrivilege(roleName, (Properties) vec.get(0), (Vector) vec.get(1)) || documentResultsDao.isSentToProvider(docid, searchProviderNo)) { // labs is in provider's queue,do nothing if (isSegmentIDUnique(validlabdocs, data)) { validlabdocs.add(data); } } } // if doc sent to non default queue and no valid provider, check if provider is in the non default queue else if (!queueid.equals(Queue.DEFAULT_QUEUE_ID) && !documentResultsDao.isSentToValidProvider(docid)) { Vector vec = OscarRoleObjectPrivilege.getPrivilegeProp("_queue." + queueid); if (OscarRoleObjectPrivilege.checkPrivilege(roleName, (Properties) vec.get(0), (Vector) vec.get(1))) { // labs is in provider's queue,do nothing if (isSegmentIDUnique(validlabdocs, data)) { validlabdocs.add(data); } } } } } else {// add lab if (isSegmentIDUnique(validlabdocs, data)) { validlabdocs.add(data); } } } // Find the oldest lab returned in labdocs, use that as the limit date for the HRM query Date oldestLab = null; Date newestLab = null; if (request.getParameter("newestDate") != null) { try { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); newestLab = formatter.parse(request.getParameter("newestDate")); } catch (Exception e) { logger.error("Couldn't parse date + " + request.getParameter("newestDate"), e); } } for (LabResultData result : labdocs) { if (result != null && result.getDateObj() != null) { if (oldestLab == null || oldestLab.compareTo(result.getDateObj()) > 0) oldestLab = result.getDateObj(); if (request.getParameter("newestDate") != null && (newestLab == null || newestLab.compareTo(result.getDateObj()) < 0)) newestLab = result.getDateObj(); } } HRMResultsData hrmResult = new HRMResultsData(); Collection<LabResultData> hrmDocuments = hrmResult.populateHRMdocumentsResultsData(searchProviderNo, ackStatus, newestLab, oldestLab); if (oldestLab == null) { for (LabResultData hrmDocument : hrmDocuments) { if (oldestLab == null || (hrmDocument.getDateObj() != null && oldestLab.compareTo(hrmDocument.getDateObj()) > 0)) oldestLab = hrmDocument.getDateObj(); } } //labdocs is already filtered for super site access.. not just filter hrmDocuments hrmDocuments = filterLabDocsForSuperSite(hrmDocuments, providerNo); labdocs.addAll(hrmDocuments); Collections.sort(labdocs); HashMap<String, LabResultData> labMap = new HashMap<String, LabResultData>(); LinkedHashMap<String, ArrayList<String>> accessionMap = new LinkedHashMap<String, ArrayList<String>>(); int accessionNumCount = 0; for (LabResultData result : labdocs) { if (startDate != null && startDate.after(result.getDateObj())) { continue; } if (endDate != null && endDate.before(result.getDateObj())) { continue; } String segmentId = result.getSegmentID(); if (result.isDocument()) segmentId += "d"; else if (result.isHRM()) segmentId += "h"; labMap.put(segmentId, result); ArrayList<String> labNums = new ArrayList<String>(); if (result.accessionNumber == null || result.accessionNumber.equals("")) { labNums.add(segmentId); accessionNumCount++; accessionMap.put("noAccessionNum" + accessionNumCount + result.labType, labNums); } else if (!accessionMap.containsKey(result.accessionNumber + result.labType)) { labNums.add(segmentId); accessionMap.put(result.accessionNumber + result.labType, labNums); // Different MDS Labs may have the same accession Number if they are seperated // by two years. So accession numbers are limited to matching only if their // labs are within one year of eachother } else { labNums = accessionMap.get(result.accessionNumber + result.labType); boolean matchFlag = false; for (int j = 0; j < labNums.size(); j++) { LabResultData matchingResult = labMap.get(labNums.get(j)); Date dateA = result.getDateObj(); Date dateB = matchingResult.getDateObj(); int monthsBetween = 0; if (dateA == null || dateB == null) { monthsBetween = 5; } else if (dateA.before(dateB)) { monthsBetween = UtilDateUtilities.getNumMonths(dateA, dateB); } else { monthsBetween = UtilDateUtilities.getNumMonths(dateB, dateA); } if (monthsBetween < 4) { matchFlag = true; break; } } if (!matchFlag) { labNums.add(segmentId); accessionMap.put(result.accessionNumber + result.labType, labNums); } } } labdocs.clear(); for (ArrayList<String> labNums : accessionMap.values()) { // must sort through in reverse to keep the labs in the correct order for (int j = labNums.size() - 1; j >= 0; j--) { labdocs.add(labMap.get(labNums.get(j))); } } logger.debug("labdocs.size()=" + labdocs.size()); /* find all data for the index.jsp page */ Hashtable patientDocs = new Hashtable(); Hashtable patientIdNames = new Hashtable(); String patientIdNamesStr = ""; Hashtable docStatus = new Hashtable(); Hashtable docType = new Hashtable(); Hashtable<String, List<String>> ab_NormalDoc = new Hashtable(); for (int i = 0; i < labdocs.size(); i++) { LabResultData data = labdocs.get(i); List<String> segIDs = new ArrayList<String>(); String labPatientId = data.getLabPatientId(); if (labPatientId == null || labPatientId.equals("-1")) labPatientId = "-1"; if (data.isAbnormal()) { List<String> abns = ab_NormalDoc.get("abnormal"); if (abns == null) { abns = new ArrayList<String>(); abns.add(data.getSegmentID()); } else { abns.add(data.getSegmentID()); } ab_NormalDoc.put("abnormal", abns); } else { List<String> ns = ab_NormalDoc.get("normal"); if (ns == null) { ns = new ArrayList<String>(); ns.add(data.getSegmentID()); } else { ns.add(data.getSegmentID()); } ab_NormalDoc.put("normal", ns); } if (patientDocs.containsKey(labPatientId)) { segIDs = (List) patientDocs.get(labPatientId); segIDs.add(data.getSegmentID()); patientDocs.put(labPatientId, segIDs); } else { segIDs.add(data.getSegmentID()); patientDocs.put(labPatientId, segIDs); patientIdNames.put(labPatientId, data.patientName); patientIdNamesStr += ";" + labPatientId + "=" + data.patientName; } docStatus.put(data.getSegmentID(), data.getAcknowledgedStatus()); docType.put(data.getSegmentID(), data.labType); } Integer totalDocs = 0; Integer totalHL7 = 0; Hashtable<String, List<String>> typeDocLab = new Hashtable(); Enumeration keys = docType.keys(); while (keys.hasMoreElements()) { String keyDocLabId = ((String) keys.nextElement()); String valType = (String) docType.get(keyDocLabId); if (valType.equalsIgnoreCase("DOC")) { if (typeDocLab.containsKey("DOC")) { List<String> docids = typeDocLab.get("DOC"); docids.add(keyDocLabId);// add doc id to list typeDocLab.put("DOC", docids); } else { List<String> docids = new ArrayList<String>(); docids.add(keyDocLabId); typeDocLab.put("DOC", docids); } totalDocs++; } else if (valType.equalsIgnoreCase("HL7")) { if (typeDocLab.containsKey("HL7")) { List<String> hl7ids = typeDocLab.get("HL7"); hl7ids.add(keyDocLabId); typeDocLab.put("HL7", hl7ids); } else { List<String> hl7ids = new ArrayList<String>(); hl7ids.add(keyDocLabId); typeDocLab.put("HL7", hl7ids); } totalHL7++; } } Hashtable patientNumDoc = new Hashtable(); Enumeration patientIds = patientDocs.keys(); String patientIdStr = ""; Integer totalNumDocs = 0; while (patientIds.hasMoreElements()) { String key = (String) patientIds.nextElement(); patientIdStr += key; patientIdStr += ","; List<String> val = (List<String>) patientDocs.get(key); Integer numDoc = val.size(); patientNumDoc.put(key, numDoc); totalNumDocs += numDoc; } List<String> normals = ab_NormalDoc.get("normal"); List<String> abnormals = ab_NormalDoc.get("abnormal"); logger.debug("labdocs.size()=" + labdocs.size()); // set attributes request.setAttribute("pageNum", page); request.setAttribute("docType", docType); request.setAttribute("patientDocs", patientDocs); request.setAttribute("providerNo", providerNo); request.setAttribute("searchProviderNo", searchProviderNo); request.setAttribute("patientIdNames", patientIdNames); request.setAttribute("docStatus", docStatus); request.setAttribute("patientIdStr", patientIdStr); request.setAttribute("typeDocLab", typeDocLab); request.setAttribute("demographicNo", demographicNo); request.setAttribute("ackStatus", ackStatus); request.setAttribute("labdocs", labdocs); request.setAttribute("patientNumDoc", patientNumDoc); request.setAttribute("totalDocs", totalDocs); request.setAttribute("totalHL7", totalHL7); request.setAttribute("normals", normals); request.setAttribute("abnormals", abnormals); request.setAttribute("totalNumDocs", totalNumDocs); request.setAttribute("patientIdNamesStr", patientIdNamesStr); request.setAttribute("oldestLab", oldestLab != null ? DateUtils.formatDate(oldestLab, "yyyy-MM-dd HH:mm:ss") : null); return mapping.findForward("dms_page"); }
From source file:com.eviware.soapui.impl.wsdl.WsdlProject.java
public void importTestSuite(File file) { if (!file.exists()) { UISupport.showErrorMessage("Error loading test case "); return;/* w w w . j a v a 2 s . co m*/ } TestSuiteDocumentConfig newTestSuiteConfig = null; try { newTestSuiteConfig = TestSuiteDocumentConfig.Factory.parse(file); } catch (Exception e) { SoapUI.logError(e); } if (newTestSuiteConfig == null) { UISupport.showErrorMessage("Not valid test case xml"); } else { TestSuiteConfig config = (TestSuiteConfig) projectDocument.getSoapuiProject().addNewTestSuite() .set(newTestSuiteConfig.getTestSuite()); WsdlTestSuite testSuite = buildTestSuite(config); ModelSupport.unsetIds(testSuite); testSuite.afterLoad(); /* * security test keeps reference to test step by id, which gets changed * during importing, so old values needs to be rewritten to new ones. * * Create tarnsition table ( old id , new id ) and use it to replace * all old ids in new imported test case. * * Here needs to be done for all test cases separatly. */ for (int cnt2 = 0; cnt2 < config.getTestCaseList().size(); cnt2++) { TestCaseConfig newTestCase = config.getTestCaseList().get(cnt2); TestCaseConfig importTestCaseConfig = newTestSuiteConfig.getTestSuite().getTestCaseList().get(cnt2); LinkedHashMap<String, String> oldNewIds = new LinkedHashMap<String, String>(); for (int cnt = 0; cnt < importTestCaseConfig.getTestStepList().size(); cnt++) oldNewIds.put(importTestCaseConfig.getTestStepList().get(cnt).getId(), newTestCase.getTestStepList().get(cnt).getId()); for (SecurityTestConfig scan : newTestCase.getSecurityTestList()) for (TestStepSecurityTestConfig secStepConfig : scan.getTestStepSecurityTestList()) if (oldNewIds.containsKey(secStepConfig.getTestStepId())) secStepConfig.setTestStepId(oldNewIds.get(secStepConfig.getTestStepId())); } testSuites.add(testSuite); fireTestSuiteAdded(testSuite); resolveImportedTestSuite(testSuite); } }