List of usage examples for java.util LinkedHashMap get
public V get(Object key)
From source file:com.zenkey.net.prowser.Request.java
/************************************************************************** * Returns a <code>java.util.Map</code> of the parameters contained * within the query string of the URI for this <code>Request</code>. The * keys of the map are parameter names; the values of the map are arrays of * parameter values associated with each parameter name. * // www.j a v a 2 s . co m * @return A <code>java.util.Map</code> of the URI's query string * parameters, or <code>null</code> if the URI has no query * string. */ private Map<String, String[]> getQueryMap() { // If the URI is null, don't do anything if (uri == null) return null; // Declare maps for temp work and the return value LinkedHashMap<String, ArrayList<String>> tempQueryMap = null; LinkedHashMap<String, String[]> queryMap = null; // If the URI has a query string, build a temp map of its parameters String rawQueryString = uri.getRawQuery(); if (rawQueryString != null) { // Parse out the name value pairs String[] queryPairsArray = rawQueryString.split("&"); // Create a temp map of query parameters tempQueryMap = new LinkedHashMap<String, ArrayList<String>>(); String name = null; String value = null; for (String rawQueryPairString : queryPairsArray) { // Split the query param name-value pair into a name and value String[] queryPairArray = rawQueryPairString.split("=", 2); name = queryPairArray[0]; if (queryPairArray.length > 1) value = queryPairArray[1]; else value = EMPTY_STRING; if (value == null) value = EMPTY_STRING; // If the query parameter doesn't exist, create it ArrayList<String> values = tempQueryMap.get(name); if (values == null) { values = new ArrayList<String>(); tempQueryMap.put(name, values); } // Add the specified value to the list of values for the param values.add(value); } // Build the query parameter map to return queryMap = new LinkedHashMap<String, String[]>(); for (String tempName : tempQueryMap.keySet()) { String[] tempValues = tempQueryMap.get(tempName) .toArray(new String[tempQueryMap.get(tempName).size()]); queryMap.put(tempName, tempValues); } } // Return a map of the query's parameters (or null if URI has no query) return queryMap; }
From source file:com.alibaba.wasp.client.WaspAdmin.java
public String describeTable(String tableName) throws IOException { FTable table = getTableDescriptor(Bytes.toBytes(tableName)); String parentTableName = table.getParentName() == null ? "ROOT" : table.getParentName(); StringBuilder builder = new StringBuilder(); builder.append("+-------------------------------------------------------------+\n"); builder.append("| Parent Table |\n"); builder.append("+-------------------------------------------------------------+\n"); builder.append("| ").append(parentTableName).append(getGivenBlanks(60 - parentTableName.length())) .append("|\n"); builder.append("+---------------------------+----------+----------+-----+-----+\n"); builder.append("| Field | Type | REQUIRED | Key | EGK |\n"); builder.append("+---------------------------+----------+----------+-----+-----+\n"); String line = "| {0} | {1} | {2} | {3} | {4} |"; LinkedHashMap<String, Field> priKeys = table.getPrimaryKeys(); Field egKey = table.getEntityGroupKey(); for (Field field : table.getColumns().values()) { String fieldname = field.getName(); String s0 = fieldname + (fieldname.length() < 25 ? getGivenBlanks(25 - fieldname.length()) : ""); String type = field.getType().toString(); String s1 = type + (type.length() < 8 ? getGivenBlanks(8 - type.length()) : ""); String nullAble = field.getKeyWord().toString(); String s2 = nullAble + (nullAble.length() < 8 ? getGivenBlanks(8 - nullAble.length()) : ""); String s3 = priKeys.get(fieldname) != null ? "PRI" : " "; String s4 = fieldname.equals(egKey.getName()) ? "EGK" : " "; builder.append(MessageFormat.format(line, s0, s1, s2, s3, s4)); builder.append("\n"); }/* www .jav a 2 s .co m*/ builder.append("+---------------------------+----------+----------+-----+-----+\n"); return builder.toString(); }
From source file:in.sc.dao.ListGenerator.java
public LinkedHashMap generateCat(int from) { StringBuilder sql = new StringBuilder(); LinkedHashMap rootMap = null; try {//from w ww. j a v a 2 s. c o m sql.append( "select k1.c_unique_name,concAt(li.cat_name,'/',li.home_url_exp) as url,k1.cat_name as child_cat,k2.cat_name as parent_cat,k3.cat_name as root_cat " + "from category_details k1,category_details k2, category_details k3,linkgenerator li where k1.status='B' and " + " k1.parent_cat_id=k2.cat_id and k2.parent_cat_id=k3.cat_id " + " and li.category_id=k1.cat_id " + " order by k3.priority asc"); namedParameterJdbcTemplate = getTemplate(); rootMap = namedParameterJdbcTemplate.query(sql.toString(), new HashMap(), new ResultSetExtractor<LinkedHashMap>() { @Override public LinkedHashMap extractData(ResultSet rs) throws SQLException, DataAccessException { LinkedHashMap rootMap = new LinkedHashMap(); LinkedList li = null; HashMap parentMap = null; while (rs.next()) { try { ArrayList childList = null; String rootCat = ""; String parentCat = ""; String childCat = ""; String childUrl = rs.getString("url"); if (rs.getString("root_cat").equals("Root Category ")) { rootCat = rs.getString("parent_cat"); parentCat = rs.getString("child_cat"); childCat = childUrl; } else { rootCat = rs.getString("root_cat"); parentCat = rs.getString("parent_cat"); childCat = rs.getString("child_cat") + "#" + childUrl; } if (rootMap.containsKey(rootCat)) { parentMap = (HashMap) rootMap.get(rootCat); } else { parentMap = new HashMap(); } if (childCat != null && parentMap.containsKey(parentCat)) { childList = (ArrayList) parentMap.get(parentCat); } else { childList = new ArrayList(); } if (childCat != null) { childList.add(childCat); } parentMap.put(parentCat, childList); rootMap.put(rootCat, parentMap); // if (rootMap.containsKey(rootCat)) { // if (!childCat.equals("")) { // parentMap = (HashMap) rootMap.get(rootCat); // if (parentMap.containsKey(childCat)) { // childList = (ArrayList) parentMap.get(childCat); // } else { // childList = new ArrayList(); // } // childList.add(childCat); // parentMap.put(parentCat, childList); // rootMap.put(rootCat, parentMap); // } // // } else { // if (!childCat.equals("")) { // childList = new ArrayList(); // childList.add(childCat); // parentMap=new HashMap(); // parentMap.put(parentCat, childList); // rootMap.put(rootCat, parentMap); // }else{ // rootMap.put(rootCat, parentCat); // } // // } } catch (Exception e) { e.printStackTrace(); } } return rootMap; } }); // Mainmap.put("data", dataList); } catch (Exception e) { e.printStackTrace(); } finally { } return rootMap; }
From source file:com.fitforbusiness.nafc.dashboard.DashBoardFragment.java
private void loadSessions(String date) { Calendar calendar = Calendar.getInstance(); date = String.format("%d-%02d-%02d", calendar.get(Calendar.YEAR), (calendar.get(Calendar.MONTH) + 1), calendar.get(Calendar.DAY_OF_MONTH)); Date stDate = null;/*from w w w .ja v a2 s .c o m*/ Date edDate = null; try { stDate = new SimpleDateFormat("yyyy-MM-dd").parse(date); stDate.setTime(stDate.getTime() - 1000); edDate = new SimpleDateFormat("yyyy-MM-dd").parse(date); edDate.setTime(edDate.getTime() + (24 * 60 * 60 * 1000)); edDate.setTime(edDate.getTime() - 1000); } catch (Exception e) { e.printStackTrace(); return; } ArrayList<HashMap<String, Object>> mapArrayList = new ArrayList<>(); SQLiteDatabase sqlDB; try { sqlDB = DatabaseHelper.instance().getReadableDatabase(); String query = "select " + Table.Sessions.ID + " , " + Table.Sessions.START_DATE + " , " + Table.Sessions.START_TIME + " , " + Table.Sessions.SESSION_STATUS + " , " + Table.Sessions.GROUP_ID + " , " + Table.Sessions.IS_NATIVE + " , " + Table.Sessions.RECURRENCE_RULE + " , " + Table.Sessions.TITLE + " , " + Table.Sessions.SESSION_TYPE + " " + " from " + Table.Sessions.TABLE_NAME + " where " + Table.DELETED + " = 0 " + " and ( " + Table.Sessions.START_DATE + " = datetime(\'" + date + "\') " + " OR " + Table.Sessions.RECURRENCE_RULE + " IS NOT NULL " + " OR " + Table.Sessions.RECURRENCE_RULE + " != '' ) "; Log.d("query is ", query); assert sqlDB != null; Cursor cursor = sqlDB.rawQuery(query, null); Log.d("Calendar", "Month Count = " + cursor.getCount()); LinkedHashMap<String, Object> row; while (cursor.moveToNext()) { if (cursor.getString(cursor.getColumnIndex(Table.Sessions.RECURRENCE_RULE)) == null || cursor.getString(cursor.getColumnIndex(Table.Sessions.RECURRENCE_RULE)).equals("")) { row = new LinkedHashMap<String, Object>(); long groupSessionId = cursor.getInt(cursor.getColumnIndex(Table.Sessions.GROUP_ID)); int session_type = cursor.getInt(cursor.getColumnIndex(Table.Sessions.SESSION_TYPE)); rowData = getImageName(groupSessionId + "", session_type); row.put("_id", cursor.getString(cursor.getColumnIndex(Table.Sessions.ID))); row.put("name", Utils.dateConversionForRow( cursor.getString(cursor.getColumnIndex(Table.Sessions.START_DATE))) + " " + Utils.timeFormatAMPM( cursor.getString(cursor.getColumnIndex(Table.Sessions.START_TIME)))); row.put("rowId", groupSessionId); row.put("type", session_type); if (cursor.getInt(cursor.getColumnIndex(Table.Sessions.IS_NATIVE)) == 1) { row.put("secondLabel", cursor.getString(cursor.getColumnIndex(Table.Sessions.TITLE))); row.put("thirdLabel", getActivity().getString(R.string.lblNativeStatus)); Log.d("Calendar", "native events"); } else if (rowData.getImageName() != null && rowData.getImageName().length() > 0) { row.put("photo", rowData.getImageName()); row.put("secondLabel", rowData.getPersonName()); row.put("thirdLabel", status[cursor.getInt(cursor.getColumnIndex(Table.Sessions.SESSION_STATUS))]); Log.d("Calendar", "app events"); } Log.d("Calendar", (String) row.get("secondLabel")); mapArrayList.add(row); } else { String rule = cursor.getString(cursor.getColumnIndex(Table.Sessions.RECURRENCE_RULE)); RecurrenceRule recRule = new RecurrenceRule(rule); RecurrenceRule.Freq freq = recRule.getFreq(); Date d = new SimpleDateFormat("dd MMM yyyy").parse(Utils.formatConversionSQLite( cursor.getString(cursor.getColumnIndex(Table.Sessions.START_DATE)))); switch (freq) { case MONTHLY: d.setMonth(stDate.getMonth()); case YEARLY: d.setYear(stDate.getYear()); } if (freq == RecurrenceRule.Freq.MONTHLY || freq == RecurrenceRule.Freq.YEARLY) { if (!(d.after(stDate) && d.before(edDate))) continue; } ArrayList<Calendar> dates; dates = CalendarMonthViewFragment.ruleOccurONDate(rule, stDate, edDate); Log.e("RecurRule", "size = " + dates.size()); if (dates.size() > 0) { row = new LinkedHashMap<String, Object>(); if (freq == RecurrenceRule.Freq.DAILY || freq == RecurrenceRule.Freq.WEEKLY) { if (d.after(dates.get(0).getTime())) continue; } long groupSessionId = cursor.getInt(cursor.getColumnIndex(Table.Sessions.GROUP_ID)); int session_type = cursor.getInt(cursor.getColumnIndex(Table.Sessions.SESSION_TYPE)); rowData = getImageName(groupSessionId + "", session_type); row.put("_id", cursor.getString(cursor.getColumnIndex(Table.Sessions.ID))); row.put("name", Utils.formatConversionDateOnly(stDate) + " " + Utils.timeFormatAMPM( cursor.getString(cursor.getColumnIndex(Table.Sessions.START_TIME)))); row.put("rowId", groupSessionId); row.put("type", session_type); if (cursor.getInt(cursor.getColumnIndex(Table.Sessions.IS_NATIVE)) == 1) { row.put("secondLabel", cursor.getString(cursor.getColumnIndex(Table.Sessions.TITLE))); row.put("thirdLabel", getActivity().getString(R.string.lblNativeStatus)); Log.d("Calendar", "native events"); } else if (rowData.getImageName() != null && rowData.getImageName().length() > 0) { row.put("photo", rowData.getImageName()); row.put("secondLabel", rowData.getPersonName()); row.put("thirdLabel", status[cursor.getInt(cursor.getColumnIndex(Table.Sessions.SESSION_STATUS))]); Log.d("Calendar", "app events"); } Log.d("Calendar", (String) row.get("secondLabel")); mapArrayList.add(row); } } } cursor.close(); } catch (Exception e) { e.printStackTrace(); } CustomAsyncTaskListAdapter adapter = new CustomAsyncTaskListAdapter(getActivity(), R.layout.calendar_day_view_session_row, R.id.ivRowImage, R.id.tvFirstName, R.id.tvSecondLabel, R.id.tvThirdLabel, mapArrayList); sessionList.setAdapter(adapter); }
From source file:oscar.dms.actions.DmsInboxManageAction.java
public ActionForward prepareForContentPage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {//w w w. java 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.ephesoft.dcma.tabbed.TabbedPdfExporter.java
/** * //from w w w.java 2 s. c o m * This will create the PDFMarks file * * @param sFolderToBeExported * @param pdfCreationParam * @param pdfOptimizationParam * @param pdfOptimizationSwitch * @param batchInstanceIdentifier * @param documentPDFMap * @throws DCMAApplicationException * */ private void writePDFMarksFile(String sFolderToBeExported, String pdfCreationParam, String batchInstanceIdentifier, String pdfOptimizationParam, String pdfOptimizationSwitch, LinkedHashMap<String, List<String>> documentPDFMap) throws IOException, DCMAApplicationException { String gsCommand = getGSCommand(); if (gsCommand == null) { LOGGER.info("No ghostcript command specified in properties file. ghostcript command = " + gsCommand); throw new DCMAApplicationException( "No ghostcript command specified in properties file. ghostcript command = " + gsCommand); } Set<String> documentNames; documentNames = documentPDFMap.keySet(); Iterator<String> iterator = documentNames.iterator(); List<String> documentPDFPaths = new ArrayList<String>(); String documentId; Batch batch = batchSchemaService.getBatch(batchInstanceIdentifier); String pdfMarkTemplatePath = batchSchemaService.getAbsolutePath(batch.getBatchClassIdentifier(), batchSchemaService.getScriptConfigFolderName(), true); File pdfMarksSample = new File( pdfMarkTemplatePath + File.separator + TabbedPdfConstant.PDF_MARKS_FILE_NAME); if (!pdfMarksSample.exists()) { throw new DCMAApplicationException("Sample PdfMarks file not provided."); } File localPdfMarksSample = new File(batchSchemaService.getLocalFolderLocation() + File.separator + batchInstanceIdentifier + File.separator + pdfMarksSample.getName()); try { FileUtils.copyFile(pdfMarksSample, localPdfMarksSample); } catch (Exception e) { throw new DCMAApplicationException("Exception in copying the file \"" + localPdfMarksSample.getAbsolutePath() + "\" to \"" + pdfMarksSample.getAbsolutePath() + "\"", e); } String pdfBookMarkTemplate = TabbedPdfConstant.PDF_MARKS_TEMPLATE; FileWriter fileWriter = null; try { fileWriter = new FileWriter(localPdfMarksSample, true); String pdfBookMarkText = ""; while (iterator.hasNext()) { documentId = iterator.next(); List<String> docDetails = documentPDFMap.get(documentId); pdfBookMarkText = pdfBookMarkTemplate.replace(TabbedPdfConstant.BOOKMARK_TITLE_PLACEHOLDER, docDetails.get(0));// page // bookmark pdfBookMarkText = pdfBookMarkText.replace(TabbedPdfConstant.BOOKMARK_PAGE_NUMBER_PLACEHOLDER, docDetails.get(1));// page // title fileWriter.write(pdfBookMarkText + System.getProperty(TabbedPdfConstant.LINE_SEPARATOR)); documentPDFPaths.add(docDetails.get(2)); } } catch (IOException ioException) { throw new DCMAApplicationException("Exception in getting the FileWriter.", ioException); } finally { try { if (fileWriter != null) { fileWriter.close(); } } catch (IOException e) { LOGGER.info("Unable to close the file stream for file:\"" + localPdfMarksSample.getAbsolutePath() + "\""); } } BatchInstanceThread batchInstanceThread = new BatchInstanceThread(batchInstanceIdentifier); List<TabbedPDFExecutor> tabbedPDFExecutors = new ArrayList<TabbedPDFExecutor>(); String batchName = ""; Map<String, String> subPoenaLoanMap = getTabbedPdfName(batch.getDocuments().getDocument()); if (null != subPoenaLoanMap && subPoenaLoanMap.size() == TabbedPdfConstant.MAX_NAME_FIELDS) { batchName = subPoenaLoanMap.get(TabbedPdfConstant.SUBPOENA) + TabbedPdfConstant.UNDERSCORE + subPoenaLoanMap.get(TabbedPdfConstant.LOAN_NUMBER); } if (batchName == null || batchName.isEmpty()) { batchName = batch.getBatchName(); } String tabbedPDFName = batchName + "_" + batchInstanceIdentifier + FileType.PDF.getExtensionWithDot(); String tabbedPDFTempFolder = batchSchemaService.getLocalFolderLocation() + File.separator + batchInstanceIdentifier; String tabbedPDFLocalPath = tabbedPDFTempFolder + File.separator + tabbedPDFName; if (pdfOptimizationSwitch != null && pdfOptimizationSwitch.equalsIgnoreCase(TabbedPdfConstant.ON)) { tabbedPDFExecutors.add(new TabbedPDFExecutor(tabbedPDFName, tabbedPDFTempFolder, documentPDFPaths, localPdfMarksSample.getAbsolutePath(), batchInstanceThread, pdfCreationParam, gsCommand)); } else { tabbedPDFExecutors.add(new TabbedPDFExecutor(tabbedPDFName, sFolderToBeExported, documentPDFPaths, localPdfMarksSample.getAbsolutePath(), batchInstanceThread, pdfCreationParam, gsCommand)); } try { LOGGER.info("Executing commands for creation of tabbed pdf using thread pool."); batchInstanceThread.execute(); LOGGER.info("Tabbed pdf creation ends."); } catch (DCMAApplicationException dcmae) { LOGGER.error("Error in executing command for tabbed pdf using thread pool" + dcmae.getMessage(), dcmae); batchInstanceThread.remove(); // Throw the exception to set the batch status to Error by Application aspect throw new DCMAApplicationException(dcmae.getMessage(), dcmae); } checkForPdfOptimizationSwitch(sFolderToBeExported, batchInstanceIdentifier, pdfOptimizationParam, pdfOptimizationSwitch, tabbedPDFName, tabbedPDFTempFolder); copyMultipagePdfInEphesoftSystemFolder(sFolderToBeExported, tabbedPDFName, tabbedPDFLocalPath); mergeBatchXmlDocs(batchSchemaService, batch, documentNames, documentPDFMap, tabbedPDFName); }
From source file:com.ruesga.rview.fragments.ChangeDetailsFragment.java
@SuppressWarnings("Convert2streamapi") private void updateMessageComments(DataResponse response, Map<String, List<CommentInfo>> comments) { final Map<String, LinkedHashMap<String, List<CommentInfo>>> mwc = response.mMessagesWithComments; // Match comments with messages for (ChangeMessageInfo message : response.mChange.messages) { if (message.message != null && COMMENTS_PATTERN.matcher(message.message).find()) { for (String file : comments.keySet()) { List<CommentInfo> items = comments.get(file); if (items != null) { for (CommentInfo comment : items) { comment.path = file; if (comment.updated.compareTo(message.date) == 0 && comment.author.accountId == message.author.accountId) { if (!mwc.containsKey(message.id)) { mwc.put(message.id, new LinkedHashMap<>()); }/*from w ww. j a va 2s . co m*/ final LinkedHashMap<String, List<CommentInfo>> filesAndComments = mwc .get(message.id); if (!filesAndComments.containsKey(file)) { filesAndComments.put(file, new ArrayList<>()); } List<CommentInfo> list = filesAndComments.get(file); comment.patchSet = message.revisionNumber; list.add(comment); } } } } } } }
From source file:com.primeleaf.krystal.web.view.console.CheckInDocumentView.java
@SuppressWarnings("unchecked") private void printCheckInDocumentForm() throws Exception { printBreadCrumbs();//from w ww .j a v a 2 s . c o m Document document = (Document) request.getAttribute("DOCUMENT"); DocumentClass documentClass = (DocumentClass) request.getAttribute("DOCUMENTCLASS"); LinkedHashMap<String, String> documentIndexes = (LinkedHashMap<String, String>) request .getAttribute("DOCUMENTINDEXES"); if (request.getAttribute(HTTPConstants.REQUEST_ERROR) != null) { printError((String) request.getAttribute(HTTPConstants.REQUEST_ERROR)); } if (request.getAttribute(HTTPConstants.REQUEST_MESSAGE) != null) { printSuccess((String) request.getAttribute(HTTPConstants.REQUEST_MESSAGE)); } if (document != null) { try { out.println("<div class=\"panel panel-default\">"); out.println("<div class=\"panel-heading\"><h4><i class=\"fa fa-lg fa-arrow-right\"></i> Check In - " + documentClass.getClassName() + "</h4></div>"); out.println("<div class=\"panel-body\">"); out.println( "<form action=\"/console/checkindocument\" method=\"post\" id=\"frmCheckInDocument\" class=\"form-horizontal\" enctype=\"multipart/form-data\" accept-charset=\"utf-8\">"); out.println("<div class=\"form-group\">"); out.println("<div class=\"col-sm-offset-3 col-sm-9\">"); out.println("<p>Fields marked with <span style='color:red'>*</span> are mandatory</p>"); out.println("</div>"); out.println("</div>"); out.println("<div class=\"form-group\">"); out.println( "<label for=\"fileDocument\" class=\"col-sm-3 control-label\">Select Document <span style='color:red'>*</span></label>"); out.println("<div class=\"col-sm-9\">"); out.println( "<input type=\"file\" name=\"fileDocument\" class=\"required checkExtension\" title=\"Select document of type " + document.getExtension() + " to check-in\">"); out.println("</div>"); out.println("</div>"); for (IndexDefinition indexDefinition : documentClass.getIndexDefinitions()) { String required = ""; out.println("<div class=\"form-group\">"); out.println("<label for=\"" + indexDefinition.getIndexColumnName() + "\" class=\"col-sm-3 control-label\"> " + StringEscapeUtils.escapeHtml4(indexDefinition.getIndexDisplayName())); if (indexDefinition.isMandatory()) { required = "required"; out.println(" <span style='color:red'>*</span>"); } out.println("</label>"); String value = documentIndexes.get(indexDefinition.getIndexDisplayName()); value = StringEscapeUtils.escapeHtml4(value); if (indexDefinition.getIndexType().equals(IndexDefinition.INDEXTYPE_DATE)) { out.println("<div class=\"col-sm-2\">"); out.println("<div class=\"input-group\">"); out.println("<input type=\"text\" class=\"shortdate isdate form-control " + required + "\" size=\"" + indexDefinition.getIndexMaxLength() + "\" name=\"" + indexDefinition.getIndexColumnName() + "\" id=\"" + indexDefinition.getIndexColumnName() + "\" value=\"" + value + "\" maxlength=\"" + indexDefinition.getIndexMaxLength() + "\" cid=\"" + documentClass.getClassId() + "\">"); out.println("<span class=\"input-group-addon\"><i class=\"fa fa-calendar\"></i></span>"); out.println("</div>"); out.println("</div>"); } else if (indexDefinition.getIndexType().equals(IndexDefinition.INDEXTYPE_NUMBER)) { out.println("<div class=\"col-sm-9\">"); out.println("<input type=\"text\" class=\"number form-control " + required + " autocomplete\" size=\"" + indexDefinition.getIndexMaxLength() + "\" id=\"" + indexDefinition.getIndexColumnName() + "\" name=\"" + indexDefinition.getIndexColumnName() + "\" value=\"" + value + "\" maxlength=\"" + indexDefinition.getIndexMaxLength() + "\" cid=\"" + documentClass.getClassId() + "\">"); out.println("</div>"); } else { out.println("<div class=\"col-sm-9\">"); out.println("<input type=\"text\" class=\"autocomplete form-control " + required + " \" id=\"" + indexDefinition.getIndexColumnName() + "\" name=\"" + indexDefinition.getIndexColumnName() + "\" value=\"" + value + "\"maxlength=\"" + indexDefinition.getIndexMaxLength() + "\" cid=\"" + documentClass.getClassId() + "\">"); out.println("</div>"); } out.println("</div>"); } double rev = Double.parseDouble(document.getRevisionId()); DecimalFormat onePlace = new DecimalFormat("0.0"); // For minor revision id double minorRevisionId = rev + 0.1; // For major revision id rev = Math.floor(rev); double majorRevisionId = rev + 1.0; // revision number field out.println("<div class=\"form-group\">"); out.println("<label for=\"version\" class=\"col-sm-3 control-label\">Version</label>"); out.println("<div class=\"btn-group col-sm-9\" data-toggle=\"buttons\">"); out.println("<label class=\"btn btn-sm btn-default active\">"); out.println("<input type=\"radio\" id=\"version1\" name=\"version\" value=\"minor\" checked>Minor (" + onePlace.format(minorRevisionId) + ")"); out.println("</label>"); out.println("<label class=\"btn btn-sm btn-default\">"); out.println("<input type=\"radio\" id=\"version2\" name=\"version\" value=\"major\">Major (" + onePlace.format(majorRevisionId) + ")"); out.println("</label>"); out.println("</div>"); out.println("</div>"); out.println("<div class=\"form-group\">"); out.println("<label for=\"txtNote\" class=\"col-sm-3 control-label\">Note / Comment </label>"); out.println("<div class=\"col-sm-9\">"); out.println( "<textarea rows=\"3\" name=\"txtNote\" id=\"txtNote\" class=\"form-control\"></textarea>"); out.println("</div>"); out.println("</div>"); out.println("<hr/>"); out.println("<div class=\"form-group\">"); out.println("<div class=\"col-sm-offset-3 col-sm-9\">"); out.println( "<input type=\"hidden\" name=\"documentid\" value=\"" + document.getDocumentId() + "\">"); out.println("<input type=\"hidden\" name=\"fileExtension\" id=\"fileExtension\" value=\"" + document.getExtension().toUpperCase() + "\">"); out.println( "<input type=\"submit\" name=\"btnSubmit\" value=\"Check In\" class=\"btn btn-sm btn-default\">"); out.println("</div>"); out.println("</div>"); out.println("</form>"); out.println("</div>"); //panel-body out.println("</div>"); //panel } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.opengamma.analytics.financial.model.volatility.surface.VolatilitySurfaceFitter.java
/** * @param forwards Forward values of the underlying at the (increasing) expiry times * @param strikes An array of arrays that gives a set of strikes at each maturity (the outer array corresponds to the expiries and the * inner arrays to the set of strikes at a particular expiry) * @param expiries The set of (increasing) expiry times * @param impliedVols An array of arrays that gives a set of implied volatilities at each maturity (with the same structure as strikes) * @param errors An array of arrays that gives a set of 'measurement' errors at each maturity (with the same structure as strikes) * @param model A smile model//from ww w .j av a 2 s. c o m * @param nodePoints The time position of the nodes on each model parameter curve * @param interpolators The base interpolator used for each model parameter curve */ public VolatilitySurfaceFitter(final double[] forwards, final double[][] strikes, final double[] expiries, final double[][] impliedVols, final double[][] errors, final VolatilityFunctionProvider<T> model, final LinkedHashMap<String, double[]> nodePoints, final LinkedHashMap<String, Interpolator1D> interpolators) { Validate.notNull(forwards, "null forwards"); Validate.notNull(strikes, "null strikes"); Validate.notNull(expiries, "null expiries"); Validate.notNull(impliedVols, "null implied vols"); Validate.notNull(errors, "null error"); Validate.notNull(model, "null model"); _nExpiries = expiries.length; Validate.isTrue(forwards.length == _nExpiries, "#forwards != #expiries"); Validate.isTrue(strikes.length == _nExpiries, "#strike sets != #expiries"); Validate.isTrue(impliedVols.length == _nExpiries, "#vol sets != #expiries"); Validate.isTrue(errors.length == _nExpiries, "#error sets != #expiries"); _volFuncs = new ArrayList<Function1D<T, double[]>>(_nExpiries); _volAdjointFuncs = new ArrayList<Function1D<T, double[][]>>(_nExpiries); _struture = new int[_nExpiries]; //check structure of common expiry strips int sum = 0; for (int i = 0; i < _nExpiries; i++) { final int n = strikes[i].length; Validate.isTrue(impliedVols[i].length == n, "#vols in strip " + i + " is wrong"); Validate.isTrue(errors[i].length == n, "#vols in strip " + i + " is wrong"); final Function1D<T, double[]> func = model.getVolatilityFunction(forwards[i], strikes[i], expiries[i]); _volFuncs.add(func); final Function1D<T, double[][]> funcAdjoint = model.getModelAdjointFunction(forwards[i], strikes[i], expiries[i]); _volAdjointFuncs.add(funcAdjoint); _struture[i] = n; sum += n; } _nOptions = sum; _expiries = expiries; _strikes = strikes; final double[] volsTemp = new double[_nOptions]; final double[] errorsTemp = new double[_nOptions]; int index = 0; for (int i = 0; i < _nExpiries; i++) { for (int j = 0; j < _struture[i]; j++) { volsTemp[index] = impliedVols[i][j]; errorsTemp[index] = errors[i][j]; index++; } } _vols = new DoubleMatrix1D(volsTemp); _errors = new DoubleMatrix1D(errorsTemp); final ParameterLimitsTransform[] transforms = getTransforms(); _parameterNames = nodePoints.keySet(); _nSmileModelParameters = _parameterNames.size(); final LinkedHashMap<String, Interpolator1D> transformedInterpolators = new LinkedHashMap<String, Interpolator1D>( _nSmileModelParameters); sum = 0; index = 0; for (final String name : _parameterNames) { sum += nodePoints.get(name).length; final Interpolator1D tInter = new TransformedInterpolator1D(interpolators.get(name), transforms[index++]); transformedInterpolators.put(name, tInter); } _curveBuilder = new InterpolatedCurveBuildingFunction(nodePoints, transformedInterpolators); _nKnotPoints = sum; }